Compare commits
No commits in common. "e7b528718ca463aa16609dd9a33b0bd44bc39e08" and "decf3028518bd6cc8b4f8c031c41065854dacd81" have entirely different histories.
e7b528718c
...
decf302851
@ -25,6 +25,7 @@ import java.util.function.Function;
|
|||||||
*/
|
*/
|
||||||
public class PandalibBungeePermissions implements Listener {
|
public class PandalibBungeePermissions implements Listener {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers event listener to redirect permission checks to {@code pandalib-permissions}.
|
* Registers event listener to redirect permission checks to {@code pandalib-permissions}.
|
||||||
* @param bungeePlugin a BungeeCord plugin.
|
* @param bungeePlugin a BungeeCord plugin.
|
||||||
@ -34,8 +35,6 @@ public class PandalibBungeePermissions implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private PandalibBungeePermissions() {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event handler called when a plugin asks if a player has a permission.
|
* Event handler called when a plugin asks if a player has a permission.
|
||||||
* @param event the permission check event.
|
* @param event the permission check event.
|
||||||
|
@ -43,7 +43,4 @@ public class PandaLibBungee {
|
|||||||
public static Plugin getPlugin() {
|
public static Plugin getPlugin() {
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PandaLibBungee() {}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -35,11 +35,4 @@ public class BungeeBackupConfig {
|
|||||||
* A list of ignored files or directory in the workdir to exclude from the backup.
|
* A list of ignored files or directory in the workdir to exclude from the backup.
|
||||||
*/
|
*/
|
||||||
public List<String> workdirIgnoreList = new ArrayList<>();
|
public List<String> workdirIgnoreList = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new {@link BungeeBackupConfig}.
|
|
||||||
*/
|
|
||||||
public BungeeBackupConfig() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,6 @@ import net.kyori.adventure.text.Component;
|
|||||||
import net.kyori.adventure.text.ComponentBuilder;
|
import net.kyori.adventure.text.ComponentBuilder;
|
||||||
import net.kyori.adventure.text.ComponentLike;
|
import net.kyori.adventure.text.ComponentLike;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import net.kyori.adventure.text.TranslationArgument;
|
|
||||||
import net.kyori.adventure.text.TranslationArgumentLike;
|
|
||||||
import net.kyori.adventure.text.event.ClickEvent;
|
import net.kyori.adventure.text.event.ClickEvent;
|
||||||
import net.kyori.adventure.text.event.HoverEvent;
|
import net.kyori.adventure.text.event.HoverEvent;
|
||||||
import net.kyori.adventure.text.event.HoverEventSource;
|
import net.kyori.adventure.text.event.HoverEventSource;
|
||||||
@ -974,38 +972,21 @@ public abstract sealed class Chat extends ChatStatic implements HoverEventSource
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* package */ static ComponentLike filterObjToComponentLike(Object v) {
|
|
||||||
return switch (v) {
|
|
||||||
case BaseComponent[] baseComponents -> toAdventure(baseComponents);
|
|
||||||
case BaseComponent baseComponent -> toAdventure(baseComponent);
|
|
||||||
case ComponentLike componentLike -> componentLike;
|
|
||||||
case null, default -> Component.text(Objects.toString(v));
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/* package */ static ComponentLike[] filterObjToComponentLike(Object[] values) {
|
/* package */ static ComponentLike[] filterObjToComponentLike(Object[] values) {
|
||||||
if (values == null)
|
if (values == null)
|
||||||
return null;
|
return null;
|
||||||
ComponentLike[] ret = new ComponentLike[values.length];
|
ComponentLike[] ret = new ComponentLike[values.length];
|
||||||
for (int i = 0; i < values.length; i++) {
|
|
||||||
ret[i] = filterObjToComponentLike(values[i]);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* package */ static TranslationArgumentLike[] filterObjToTranslationArgumentLike(Object[] values) {
|
|
||||||
if (values == null)
|
|
||||||
return null;
|
|
||||||
TranslationArgumentLike[] ret = new TranslationArgumentLike[values.length];
|
|
||||||
for (int i = 0; i < values.length; i++) {
|
for (int i = 0; i < values.length; i++) {
|
||||||
Object v = values[i];
|
Object v = values[i];
|
||||||
if (v instanceof Number n)
|
if (v instanceof BaseComponent[])
|
||||||
ret[i] = TranslationArgument.numeric(n);
|
ret[i] = toAdventure((BaseComponent[]) v);
|
||||||
else if (v instanceof Boolean b)
|
else if (v instanceof BaseComponent)
|
||||||
ret[i] = TranslationArgument.bool(b);
|
ret[i] = toAdventure((BaseComponent) v);
|
||||||
|
else if (v instanceof ComponentLike)
|
||||||
|
ret[i] = (ComponentLike) v;
|
||||||
else
|
else
|
||||||
ret[i] = TranslationArgument.component(filterObjToComponentLike(values[i]));
|
ret[i] = Component.text(Objects.toString(v));
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
* A custom gradient with at least 2 colors in it.
|
* A custom gradient with at least 2 colors in it.
|
||||||
*/
|
*/
|
||||||
public class ChatColorGradient {
|
public class ChatColorGradient {
|
||||||
|
|
||||||
private record GradientColor(
|
private record GradientColor(
|
||||||
float location,
|
float location,
|
||||||
TextColor color
|
TextColor color
|
||||||
@ -23,11 +22,6 @@ public class ChatColorGradient {
|
|||||||
|
|
||||||
private final List<GradientColor> colors = new ArrayList<>();
|
private final List<GradientColor> colors = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
|
||||||
* Create the custom gradient.
|
|
||||||
*/
|
|
||||||
public ChatColorGradient() {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Put a specific color at a specific location in the gradient.
|
* Put a specific color at a specific location in the gradient.
|
||||||
* @param gradientLocation the location in the gradient.
|
* @param gradientLocation the location in the gradient.
|
||||||
@ -49,7 +43,7 @@ public class ChatColorGradient {
|
|||||||
if (colors.isEmpty())
|
if (colors.isEmpty())
|
||||||
throw new IllegalStateException("Must define at least one color in this ChatColorGradient instance.");
|
throw new IllegalStateException("Must define at least one color in this ChatColorGradient instance.");
|
||||||
if (colors.size() == 1)
|
if (colors.size() == 1)
|
||||||
return colors.getFirst().color();
|
return colors.get(0).color();
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (; i < colors.size(); i++) {
|
for (; i < colors.size(); i++) {
|
||||||
@ -60,7 +54,7 @@ public class ChatColorGradient {
|
|||||||
if (i == 0)
|
if (i == 0)
|
||||||
return colors.get(i).color();
|
return colors.get(i).color();
|
||||||
if (i == colors.size())
|
if (i == colors.size())
|
||||||
return colors.getLast().color();
|
return colors.get(colors.size() - 1).color();
|
||||||
|
|
||||||
int p = i - 1;
|
int p = i - 1;
|
||||||
float pLoc = colors.get(p).location();
|
float pLoc = colors.get(p).location();
|
||||||
|
@ -293,7 +293,4 @@ public class ChatColorUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private ChatColorUtil() {}
|
|
||||||
|
|
||||||
}
|
}
|
@ -157,9 +157,5 @@ public class ChatConfig {
|
|||||||
.thenText("] ");
|
.thenText("] ");
|
||||||
}
|
}
|
||||||
|
|
||||||
private PandaTheme() {}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ChatConfig() {}
|
|
||||||
}
|
}
|
||||||
|
@ -264,7 +264,7 @@ public abstract class ChatStatic {
|
|||||||
* @return a new {@link FormatableChat} with the provided translation key and parameters.
|
* @return a new {@link FormatableChat} with the provided translation key and parameters.
|
||||||
*/
|
*/
|
||||||
public static FormatableChat translation(String key, Object... with) {
|
public static FormatableChat translation(String key, Object... with) {
|
||||||
return new FormatableChat(Component.translatable().key(key).arguments(Chat.filterObjToTranslationArgumentLike(with)));
|
return new FormatableChat(Component.translatable().key(key).args(Chat.filterObjToComponentLike(with)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -632,39 +632,52 @@ public abstract class ChatStatic {
|
|||||||
|
|
||||||
|
|
||||||
private static ComponentBuilder<?, ?> componentToBuilder(Component c) {
|
private static ComponentBuilder<?, ?> componentToBuilder(Component c) {
|
||||||
ComponentBuilder<?, ?> builder = switch (c) {
|
ComponentBuilder<?, ?> builder;
|
||||||
case TextComponent textComponent -> Component.text()
|
if (c instanceof TextComponent) {
|
||||||
.content(textComponent.content());
|
builder = Component.text()
|
||||||
case TranslatableComponent translatableComponent -> Component.translatable()
|
.content(((TextComponent) c).content());
|
||||||
.key(translatableComponent.key()).arguments(translatableComponent.arguments());
|
}
|
||||||
case SelectorComponent selectorComponent -> Component.selector()
|
else if (c instanceof TranslatableComponent) {
|
||||||
.pattern(selectorComponent.pattern());
|
builder = Component.translatable()
|
||||||
case ScoreComponent scoreComponent -> Component.score()
|
.key(((TranslatableComponent) c).key())
|
||||||
.name(scoreComponent.name())
|
.args(((TranslatableComponent) c).args());
|
||||||
.objective(scoreComponent.objective());
|
}
|
||||||
case KeybindComponent keybindComponent -> Component.keybind()
|
else if (c instanceof SelectorComponent) {
|
||||||
.keybind(keybindComponent.keybind());
|
builder = Component.selector()
|
||||||
case BlockNBTComponent blockNBTComponent -> Component.blockNBT()
|
.pattern(((SelectorComponent) c).pattern());
|
||||||
.interpret(blockNBTComponent.interpret())
|
}
|
||||||
.nbtPath(blockNBTComponent.nbtPath())
|
else if (c instanceof ScoreComponent) {
|
||||||
.pos(blockNBTComponent.pos());
|
builder = Component.score()
|
||||||
case EntityNBTComponent entityNBTComponent -> Component.entityNBT()
|
.name(((ScoreComponent) c).name())
|
||||||
.interpret(entityNBTComponent.interpret())
|
.objective(((ScoreComponent) c).objective());
|
||||||
.nbtPath(entityNBTComponent.nbtPath())
|
}
|
||||||
.selector(entityNBTComponent.selector());
|
else if (c instanceof KeybindComponent) {
|
||||||
case StorageNBTComponent storageNBTComponent -> Component.storageNBT()
|
builder = Component.keybind()
|
||||||
.interpret(storageNBTComponent.interpret())
|
.keybind(((KeybindComponent) c).keybind());
|
||||||
.nbtPath(storageNBTComponent.nbtPath())
|
}
|
||||||
.storage(storageNBTComponent.storage());
|
else if (c instanceof BlockNBTComponent) {
|
||||||
case null, default -> throw new IllegalArgumentException("Unknown component type " + (c == null ? "null" : c.getClass()));
|
builder = Component.blockNBT()
|
||||||
};
|
.interpret(((BlockNBTComponent) c).interpret())
|
||||||
|
.nbtPath(((BlockNBTComponent) c).nbtPath())
|
||||||
|
.pos(((BlockNBTComponent) c).pos());
|
||||||
|
}
|
||||||
|
else if (c instanceof EntityNBTComponent) {
|
||||||
|
builder = Component.entityNBT()
|
||||||
|
.interpret(((EntityNBTComponent) c).interpret())
|
||||||
|
.nbtPath(((EntityNBTComponent) c).nbtPath())
|
||||||
|
.selector(((EntityNBTComponent) c).selector());
|
||||||
|
}
|
||||||
|
else if (c instanceof StorageNBTComponent) {
|
||||||
|
builder = Component.storageNBT()
|
||||||
|
.interpret(((StorageNBTComponent) c).interpret())
|
||||||
|
.nbtPath(((StorageNBTComponent) c).nbtPath())
|
||||||
|
.storage(((StorageNBTComponent) c).storage());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new IllegalArgumentException("Unknown component type " + c.getClass());
|
||||||
|
}
|
||||||
return builder.style(c.style()).append(c.children());
|
return builder.style(c.style()).append(c.children());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new {@link ChatStatic} instance.
|
|
||||||
*/
|
|
||||||
protected ChatStatic() {}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@ import net.kyori.adventure.text.Component;
|
|||||||
import net.kyori.adventure.text.ComponentLike;
|
import net.kyori.adventure.text.ComponentLike;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import net.kyori.adventure.text.TranslatableComponent;
|
import net.kyori.adventure.text.TranslatableComponent;
|
||||||
import net.kyori.adventure.text.TranslationArgument;
|
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.kyori.adventure.text.format.TextColor;
|
import net.kyori.adventure.text.format.TextColor;
|
||||||
import net.kyori.adventure.text.format.TextDecoration;
|
import net.kyori.adventure.text.format.TextDecoration;
|
||||||
@ -266,8 +265,8 @@ public class ChatUtil {
|
|||||||
count += strWidth(((TextComponent)component).content(), console, actuallyBold);
|
count += strWidth(((TextComponent)component).content(), console, actuallyBold);
|
||||||
}
|
}
|
||||||
else if (component instanceof TranslatableComponent) {
|
else if (component instanceof TranslatableComponent) {
|
||||||
for (TranslationArgument c : ((TranslatableComponent)component).arguments())
|
for (Component c : ((TranslatableComponent)component).args())
|
||||||
count += componentWidth(c.asComponent(), console, actuallyBold);
|
count += componentWidth(c, console, actuallyBold);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Component c : component.children())
|
for (Component c : component.children())
|
||||||
@ -481,7 +480,7 @@ public class ChatUtil {
|
|||||||
spacedRow.thenText(space);
|
spacedRow.thenText(space);
|
||||||
}
|
}
|
||||||
if (!row.isEmpty())
|
if (!row.isEmpty())
|
||||||
spacedRow.then(row.getLast());
|
spacedRow.then(row.get(row.size() - 1));
|
||||||
spacedRows.add(spacedRow.getAdv());
|
spacedRows.add(spacedRow.getAdv());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -658,6 +657,5 @@ public class ChatUtil {
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ChatUtil() {}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,9 +25,6 @@ public class CLIBrigadierDispatcher extends BrigadierDispatcher<CLICommandSender
|
|||||||
public static final CLICommandSender CLI_CONSOLE_COMMAND_SENDER = new CLIConsoleCommandSender();
|
public static final CLICommandSender CLI_CONSOLE_COMMAND_SENDER = new CLIConsoleCommandSender();
|
||||||
|
|
||||||
|
|
||||||
private CLIBrigadierDispatcher() {}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the provided command as the console.
|
* Executes the provided command as the console.
|
||||||
* @param commandWithoutSlash the command, without the eventual slash at the beginning.
|
* @param commandWithoutSlash the command, without the eventual slash at the beginning.
|
||||||
|
@ -11,12 +11,6 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
* The console command sender.
|
* The console command sender.
|
||||||
*/
|
*/
|
||||||
public class CLIConsoleCommandSender implements CLICommandSender {
|
public class CLIConsoleCommandSender implements CLICommandSender {
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new console command sender.
|
|
||||||
*/
|
|
||||||
protected CLIConsoleCommandSender() {}
|
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "Console";
|
return "Console";
|
||||||
}
|
}
|
||||||
|
@ -36,11 +36,6 @@ import static fr.pandacube.lib.chat.ChatStatic.text;
|
|||||||
*/
|
*/
|
||||||
public class CommandAdmin extends CLIBrigadierCommand {
|
public class CommandAdmin extends CLIBrigadierCommand {
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes the admin command.
|
|
||||||
*/
|
|
||||||
public CommandAdmin() {}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected LiteralArgumentBuilder<CLICommandSender> buildCommand() {
|
protected LiteralArgumentBuilder<CLICommandSender> buildCommand() {
|
||||||
return literal("admin")
|
return literal("admin")
|
||||||
|
@ -9,11 +9,6 @@ import fr.pandacube.lib.cli.CLIApplication;
|
|||||||
*/
|
*/
|
||||||
public class CommandStop extends CLIBrigadierCommand {
|
public class CommandStop extends CLIBrigadierCommand {
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes the admin command.
|
|
||||||
*/
|
|
||||||
public CommandStop() {}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected LiteralArgumentBuilder<CLICommandSender> buildCommand() {
|
protected LiteralArgumentBuilder<CLICommandSender> buildCommand() {
|
||||||
return literal("stop")
|
return literal("stop")
|
||||||
|
@ -98,6 +98,4 @@ public class CLILogger {
|
|||||||
return ps;
|
return ps;
|
||||||
}
|
}
|
||||||
|
|
||||||
private CLILogger() {}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,11 +25,6 @@ import java.util.function.Predicate;
|
|||||||
*/
|
*/
|
||||||
public abstract class BrigadierCommand<S> {
|
public abstract class BrigadierCommand<S> {
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a Brigadier command.
|
|
||||||
*/
|
|
||||||
public BrigadierCommand() {}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a builder for this command.
|
* Returns a builder for this command.
|
||||||
|
@ -21,11 +21,6 @@ public abstract class BrigadierDispatcher<S> {
|
|||||||
|
|
||||||
private final CommandDispatcher<S> dispatcher = new CommandDispatcher<>();
|
private final CommandDispatcher<S> dispatcher = new CommandDispatcher<>();
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new Dispatcher instance.
|
|
||||||
*/
|
|
||||||
public BrigadierDispatcher() {}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers the provided command node into this dispatcher.
|
* Registers the provided command node into this dispatcher.
|
||||||
|
@ -140,8 +140,4 @@ public class BrigadierSuggestionsUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private BrigadierSuggestionsUtil() {}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -70,11 +70,6 @@ public abstract class BackupCleaner implements UnaryOperator<TreeSet<LocalDateTi
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a backup cleaner.
|
|
||||||
*/
|
|
||||||
public BackupCleaner() {}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new {@link BackupCleaner} that keeps the archives kept by this {@link BackupCleaner} or by the provided
|
* Creates a new {@link BackupCleaner} that keeps the archives kept by this {@link BackupCleaner} or by the provided
|
||||||
|
@ -54,7 +54,7 @@ public class CronScheduler {
|
|||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
|
|
||||||
if (!tasks.isEmpty()) {
|
if (!tasks.isEmpty()) {
|
||||||
CronTask next = tasks.getFirst();
|
CronTask next = tasks.get(0);
|
||||||
if (next.nextRun <= now) {
|
if (next.nextRun <= now) {
|
||||||
next.runAsync();
|
next.runAsync();
|
||||||
setLastRun(next.taskId, now);
|
setLastRun(next.taskId, now);
|
||||||
@ -224,6 +224,5 @@ public class CronScheduler {
|
|||||||
.toEpochMilli();
|
.toEpochMilli();
|
||||||
}
|
}
|
||||||
|
|
||||||
private CronScheduler() {}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -163,6 +163,4 @@ public class Json {
|
|||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
private Json() {}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,8 +30,6 @@ public class ThrowableAdapter implements JsonSerializer<Throwable>, JsonDeserial
|
|||||||
|
|
||||||
/* package */ static final TypeAdapterFactory FACTORY = TreeTypeAdapter.newTypeHierarchyFactory(Throwable.class, new ThrowableAdapter());
|
/* package */ static final TypeAdapterFactory FACTORY = TreeTypeAdapter.newTypeHierarchyFactory(Throwable.class, new ThrowableAdapter());
|
||||||
|
|
||||||
private ThrowableAdapter() {}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Throwable deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
public Throwable deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||||
|
@ -238,7 +238,4 @@ public class TypeConverter {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private TypeConverter() {}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -58,9 +58,6 @@ public record MinecraftVersionList(
|
|||||||
|
|
||||||
private static final TypeToken<Map<String, Integer>> MAP_STR_INT_TYPE = new TypeToken<>() { };
|
private static final TypeToken<Map<String, Integer>> MAP_STR_INT_TYPE = new TypeToken<>() { };
|
||||||
private static final TypeToken<Map<Integer, List<String>>> MAP_INT_LIST_STRING_TYPE = new TypeToken<>() { };
|
private static final TypeToken<Map<Integer, List<String>>> MAP_INT_LIST_STRING_TYPE = new TypeToken<>() { };
|
||||||
|
|
||||||
private MinecraftVersionListAdapter() {}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MinecraftVersionList deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
public MinecraftVersionList deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||||
if (!(json instanceof JsonObject jsonObj))
|
if (!(json instanceof JsonObject jsonObj))
|
||||||
|
@ -135,7 +135,4 @@ public class MinecraftVersionUtil {
|
|||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private MinecraftVersionUtil() {}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -56,21 +56,18 @@
|
|||||||
<artifact>org.apache.commons:commons-dbcp2</artifact>
|
<artifact>org.apache.commons:commons-dbcp2</artifact>
|
||||||
<excludes>
|
<excludes>
|
||||||
<exclude>META-INF/MANIFEST.MF</exclude>
|
<exclude>META-INF/MANIFEST.MF</exclude>
|
||||||
<exclude>META-INF/versions/9/**</exclude>
|
|
||||||
</excludes>
|
</excludes>
|
||||||
</filter>
|
</filter>
|
||||||
<filter>
|
<filter>
|
||||||
<artifact>org.apache.commons:commons-pool2</artifact>
|
<artifact>org.apache.commons:commons-pool2</artifact>
|
||||||
<excludes>
|
<excludes>
|
||||||
<exclude>META-INF/MANIFEST.MF</exclude>
|
<exclude>META-INF/MANIFEST.MF</exclude>
|
||||||
<exclude>META-INF/versions/9/**</exclude>
|
|
||||||
</excludes>
|
</excludes>
|
||||||
</filter>
|
</filter>
|
||||||
<filter>
|
<filter>
|
||||||
<artifact>commons-logging:commons-logging</artifact>
|
<artifact>commons-logging:commons-logging</artifact>
|
||||||
<excludes>
|
<excludes>
|
||||||
<exclude>META-INF/MANIFEST.MF</exclude>
|
<exclude>META-INF/MANIFEST.MF</exclude>
|
||||||
<exclude>META-INF/versions/9/**</exclude>
|
|
||||||
</excludes>
|
</excludes>
|
||||||
</filter>
|
</filter>
|
||||||
</filters>
|
</filters>
|
||||||
|
@ -16,11 +16,6 @@ import java.util.stream.Collectors;
|
|||||||
*/
|
*/
|
||||||
public class SQLElementList<E extends SQLElement<E>> extends ArrayList<E> {
|
public class SQLElementList<E extends SQLElement<E>> extends ArrayList<E> {
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates an empty list of sql elements.
|
|
||||||
*/
|
|
||||||
public SQLElementList() {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores all the values modified by {@link #setCommon(SQLField, Object)}.
|
* Stores all the values modified by {@link #setCommon(SQLField, Object)}.
|
||||||
*/
|
*/
|
||||||
|
@ -232,8 +232,12 @@ public class SQLField<E extends SQLElement<E>, T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
/* package */ Object fromJavaTypeToJDBCType(Object value) throws DBException {
|
public Object fromJavaTypeToJDBCType(Object value) throws DBException {
|
||||||
Object ret = value;
|
Object ret = value;
|
||||||
if (value != null && type instanceof SQLCustomType customType) {
|
if (value != null && type instanceof SQLCustomType customType) {
|
||||||
try {
|
try {
|
||||||
@ -246,7 +250,7 @@ public class SQLField<E extends SQLElement<E>, T> {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* package */ Collection<Object> fromListJavaTypeToJDBCType(Collection<?> values) throws DBException {
|
public Collection<Object> fromListJavaTypeToJDBCType(Collection<?> values) throws DBException {
|
||||||
if (values == null)
|
if (values == null)
|
||||||
return null;
|
return null;
|
||||||
List<Object> ret = new ArrayList<>(values.size());
|
List<Object> ret = new ArrayList<>(values.size());
|
||||||
|
@ -13,11 +13,6 @@ import fr.pandacube.lib.util.log.Log;
|
|||||||
*/
|
*/
|
||||||
public abstract class SQLWhere<E extends SQLElement<E>> {
|
public abstract class SQLWhere<E extends SQLElement<E>> {
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a SQL WHERE expression.
|
|
||||||
*/
|
|
||||||
protected SQLWhere() {}
|
|
||||||
|
|
||||||
/* package */ abstract ParameterizedSQLString toSQL() throws DBException;
|
/* package */ abstract ParameterizedSQLString toSQL() throws DBException;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -74,7 +69,6 @@ public abstract class SQLWhere<E extends SQLElement<E>> {
|
|||||||
* Create a custom SQL {@code WHERE} expression.
|
* Create a custom SQL {@code WHERE} expression.
|
||||||
* @param whereExpr the raw SQL {@code WHERE} expression.
|
* @param whereExpr the raw SQL {@code WHERE} expression.
|
||||||
* @return a new SQL {@code WHERE} expression.
|
* @return a new SQL {@code WHERE} expression.
|
||||||
* @param <E> the table type.
|
|
||||||
*/
|
*/
|
||||||
public static <E extends SQLElement<E>> SQLWhere<E> expression(String whereExpr) {
|
public static <E extends SQLElement<E>> SQLWhere<E> expression(String whereExpr) {
|
||||||
return expression(whereExpr, List.of());
|
return expression(whereExpr, List.of());
|
||||||
@ -85,7 +79,6 @@ public abstract class SQLWhere<E extends SQLElement<E>> {
|
|||||||
* @param whereExpr the raw SQL {@code WHERE} expression.
|
* @param whereExpr the raw SQL {@code WHERE} expression.
|
||||||
* @param params the parameters of the provided expression.
|
* @param params the parameters of the provided expression.
|
||||||
* @return a new SQL {@code WHERE} expression.
|
* @return a new SQL {@code WHERE} expression.
|
||||||
* @param <E> the table type.
|
|
||||||
*/
|
*/
|
||||||
public static <E extends SQLElement<E>> SQLWhere<E> expression(String whereExpr, List<Object> params) {
|
public static <E extends SQLElement<E>> SQLWhere<E> expression(String whereExpr, List<Object> params) {
|
||||||
return new SQLWhereCustomExpression<>(whereExpr, params);
|
return new SQLWhereCustomExpression<>(whereExpr, params);
|
||||||
@ -96,7 +89,6 @@ public abstract class SQLWhere<E extends SQLElement<E>> {
|
|||||||
* @param leftExpr the raw SQL left operand.
|
* @param leftExpr the raw SQL left operand.
|
||||||
* @param valuesIn the values on the right of the {@code IN} operator.
|
* @param valuesIn the values on the right of the {@code IN} operator.
|
||||||
* @return a new SQL {@code WHERE} expression.
|
* @return a new SQL {@code WHERE} expression.
|
||||||
* @param <E> the table type.
|
|
||||||
*/
|
*/
|
||||||
public static <E extends SQLElement<E>> SQLWhere<E> expressionIn(String leftExpr, Collection<?> valuesIn) {
|
public static <E extends SQLElement<E>> SQLWhere<E> expressionIn(String leftExpr, Collection<?> valuesIn) {
|
||||||
return expressionIn(leftExpr, List.of(), valuesIn);
|
return expressionIn(leftExpr, List.of(), valuesIn);
|
||||||
@ -108,7 +100,6 @@ public abstract class SQLWhere<E extends SQLElement<E>> {
|
|||||||
* @param leftParams the parameters of the left operand.
|
* @param leftParams the parameters of the left operand.
|
||||||
* @param valuesIn the values on the right of the {@code IN} operator.
|
* @param valuesIn the values on the right of the {@code IN} operator.
|
||||||
* @return a new SQL {@code WHERE} expression.
|
* @return a new SQL {@code WHERE} expression.
|
||||||
* @param <E> the table type.
|
|
||||||
*/
|
*/
|
||||||
public static <E extends SQLElement<E>> SQLWhere<E> expressionIn(String leftExpr, List<Object> leftParams, Collection<?> valuesIn) {
|
public static <E extends SQLElement<E>> SQLWhere<E> expressionIn(String leftExpr, List<Object> leftParams, Collection<?> valuesIn) {
|
||||||
return new SQLWhereInCustom<>(leftExpr, leftParams, valuesIn);
|
return new SQLWhereInCustom<>(leftExpr, leftParams, valuesIn);
|
||||||
|
@ -21,8 +21,4 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<properties>
|
|
||||||
<maven.javadoc.skip>true</maven.javadoc.skip>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -82,12 +82,6 @@ public class PandalibPaperPermissions implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a {@link PandalibPaperPermissions} instance.
|
|
||||||
*/
|
|
||||||
private PandalibPaperPermissions() {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Player login event handler.
|
* Player login event handler.
|
||||||
* @param event the event.
|
* @param event the event.
|
||||||
|
@ -2,26 +2,38 @@ package fr.pandacube.lib.paper.commands;
|
|||||||
|
|
||||||
import com.destroystokyo.paper.brigadier.BukkitBrigadierCommandSource;
|
import com.destroystokyo.paper.brigadier.BukkitBrigadierCommandSource;
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
|
import com.mojang.brigadier.arguments.ArgumentType;
|
||||||
import com.mojang.brigadier.context.CommandContext;
|
import com.mojang.brigadier.context.CommandContext;
|
||||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
import com.mojang.brigadier.suggestion.SuggestionProvider;
|
import com.mojang.brigadier.suggestion.SuggestionProvider;
|
||||||
|
import com.mojang.brigadier.tree.CommandNode;
|
||||||
import com.mojang.brigadier.tree.LiteralCommandNode;
|
import com.mojang.brigadier.tree.LiteralCommandNode;
|
||||||
import com.mojang.brigadier.tree.RootCommandNode;
|
import com.mojang.brigadier.tree.RootCommandNode;
|
||||||
import fr.pandacube.lib.chat.Chat;
|
import fr.pandacube.lib.chat.Chat;
|
||||||
import fr.pandacube.lib.commands.BadCommandUsage;
|
import fr.pandacube.lib.commands.BadCommandUsage;
|
||||||
import fr.pandacube.lib.commands.BrigadierCommand;
|
import fr.pandacube.lib.commands.BrigadierCommand;
|
||||||
import fr.pandacube.lib.commands.SuggestionsSupplier;
|
import fr.pandacube.lib.commands.SuggestionsSupplier;
|
||||||
|
import fr.pandacube.lib.paper.permissions.PandalibPaperPermissions;
|
||||||
import fr.pandacube.lib.paper.reflect.PandalibPaperReflect;
|
import fr.pandacube.lib.paper.reflect.PandalibPaperReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.craftbukkit.CraftServer;
|
import fr.pandacube.lib.paper.reflect.wrapper.craftbukkit.CraftServer;
|
||||||
|
import fr.pandacube.lib.paper.reflect.wrapper.craftbukkit.CraftVector;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.craftbukkit.VanillaCommandWrapper;
|
import fr.pandacube.lib.paper.reflect.wrapper.craftbukkit.VanillaCommandWrapper;
|
||||||
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.BlockPosArgument;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.Commands;
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.Commands;
|
||||||
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.ComponentArgument;
|
||||||
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.Coordinates;
|
||||||
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.EntityArgument;
|
||||||
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.EntitySelector;
|
||||||
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.Vec3Argument;
|
||||||
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.core.BlockPos;
|
||||||
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.ServerPlayer;
|
||||||
|
import fr.pandacube.lib.paper.reflect.wrapper.paper.PaperAdventure;
|
||||||
import fr.pandacube.lib.players.standalone.AbstractOffPlayer;
|
import fr.pandacube.lib.players.standalone.AbstractOffPlayer;
|
||||||
import fr.pandacube.lib.players.standalone.AbstractOnlinePlayer;
|
import fr.pandacube.lib.players.standalone.AbstractOnlinePlayer;
|
||||||
import fr.pandacube.lib.players.standalone.AbstractPlayerManager;
|
import fr.pandacube.lib.players.standalone.AbstractPlayerManager;
|
||||||
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.reflect.wrapper.ReflectWrapper;
|
||||||
import fr.pandacube.lib.util.log.Log;
|
import fr.pandacube.lib.util.log.Log;
|
||||||
import io.papermc.paper.command.brigadier.CommandSourceStack;
|
import net.kyori.adventure.text.Component;
|
||||||
import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -29,10 +41,18 @@ import org.bukkit.command.CommandMap;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
|
import org.bukkit.command.defaults.BukkitCommand;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerCommandSendEvent;
|
||||||
|
import org.bukkit.event.server.ServerLoadEvent;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.bukkit.util.BlockVector;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -44,9 +64,7 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
|||||||
/**
|
/**
|
||||||
* Abstract class to hold a command to be integrated into a Paper server vanilla command dispatcher.
|
* Abstract class to hold a command to be integrated into a Paper server vanilla command dispatcher.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("UnstableApiUsage")
|
public abstract class PaperBrigadierCommand extends BrigadierCommand<BukkitBrigadierCommandSource> implements Listener {
|
||||||
public abstract class PaperBrigadierCommand extends BrigadierCommand<CommandSourceStack> implements Listener {
|
|
||||||
|
|
||||||
|
|
||||||
private static final Commands vanillaCommandDispatcher;
|
private static final Commands vanillaCommandDispatcher;
|
||||||
private static final CommandDispatcher<BukkitBrigadierCommandSource> nmsDispatcher;
|
private static final CommandDispatcher<BukkitBrigadierCommandSource> nmsDispatcher;
|
||||||
@ -73,7 +91,6 @@ public abstract class PaperBrigadierCommand extends BrigadierCommand<CommandSour
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Log.info("Removing Bukkit command /" + name + " (" + getCommandIdentity(bukkitCommand) + ")");
|
Log.info("Removing Bukkit command /" + name + " (" + getCommandIdentity(bukkitCommand) + ")");
|
||||||
Log.warning("[1.20.6 update] Please test that the bukkit command removal is actually working.");
|
|
||||||
bukkitCmdMap.getKnownCommands().remove(name.toLowerCase(java.util.Locale.ENGLISH));
|
bukkitCmdMap.getKnownCommands().remove(name.toLowerCase(java.util.Locale.ENGLISH));
|
||||||
bukkitCommand.unregister(bukkitCmdMap);
|
bukkitCommand.unregister(bukkitCmdMap);
|
||||||
|
|
||||||
@ -114,13 +131,7 @@ public abstract class PaperBrigadierCommand extends BrigadierCommand<CommandSour
|
|||||||
/**
|
/**
|
||||||
* The command node of this command.
|
* The command node of this command.
|
||||||
*/
|
*/
|
||||||
protected final LiteralCommandNode<CommandSourceStack> commandNode;
|
protected final LiteralCommandNode<BukkitBrigadierCommandSource> commandNode;
|
||||||
/**
|
|
||||||
* The command requested aliases.
|
|
||||||
*/
|
|
||||||
protected final String[] aliases;
|
|
||||||
|
|
||||||
protected final String description;
|
|
||||||
|
|
||||||
private final RegistrationPolicy registrationPolicy;
|
private final RegistrationPolicy registrationPolicy;
|
||||||
|
|
||||||
@ -136,14 +147,12 @@ public abstract class PaperBrigadierCommand extends BrigadierCommand<CommandSour
|
|||||||
plugin = pl;
|
plugin = pl;
|
||||||
registrationPolicy = regPolicy;
|
registrationPolicy = regPolicy;
|
||||||
commandNode = buildCommand().build();
|
commandNode = buildCommand().build();
|
||||||
String[] aliasesTmp = getAliases();
|
|
||||||
aliases = aliasesTmp == null ? new String[0] : aliasesTmp;
|
|
||||||
description = getDescription();
|
|
||||||
postBuildCommand(commandNode);
|
postBuildCommand(commandNode);
|
||||||
register();
|
register();
|
||||||
//try {
|
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||||
// PandalibPaperPermissions.addPermissionMapping("minecraft.command." + commandNode.getLiteral().toLowerCase(), getTargetPermission().toLowerCase());
|
try {
|
||||||
//} catch (NoClassDefFoundError ignored) { }
|
PandalibPaperPermissions.addPermissionMapping("minecraft.command." + commandNode.getLiteral().toLowerCase(), getTargetPermission().toLowerCase());
|
||||||
|
} catch (NoClassDefFoundError ignored) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -158,28 +167,130 @@ public abstract class PaperBrigadierCommand extends BrigadierCommand<CommandSour
|
|||||||
|
|
||||||
|
|
||||||
private void register() {
|
private void register() {
|
||||||
plugin.getLifecycleManager().registerEventHandler(LifecycleEvents.COMMANDS, event -> {
|
|
||||||
|
|
||||||
registeredAliases = new HashSet<>(event.registrar().register(commandNode, description, List.of(aliases)));
|
String[] aliases = getAliases();
|
||||||
|
if (aliases == null)
|
||||||
|
aliases = new String[0];
|
||||||
|
|
||||||
if (registrationPolicy == RegistrationPolicy.ALL) {
|
String pluginName = plugin.getName().toLowerCase();
|
||||||
// enforce registration of aliases
|
|
||||||
for (String alias : aliases) {
|
|
||||||
if (!registeredAliases.contains(alias))
|
|
||||||
registeredAliases.addAll(event.registrar().register(getAliasNode(alias), description));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
registeredAliases = new HashSet<>();
|
||||||
|
registerNode(commandNode, false);
|
||||||
|
registerAlias(pluginName + ":" + commandNode.getLiteral(), true);
|
||||||
|
|
||||||
|
for (String alias : aliases) {
|
||||||
|
registerAlias(alias, false);
|
||||||
|
registerAlias(pluginName + ":" + alias, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private LiteralCommandNode<CommandSourceStack> getAliasNode(String alias) {
|
private void registerAlias(String alias, boolean prefixed) {
|
||||||
return literal(alias)
|
LiteralCommandNode<BukkitBrigadierCommandSource> node = literal(alias)
|
||||||
.requires(commandNode.getRequirement())
|
.requires(commandNode.getRequirement())
|
||||||
.executes(commandNode.getCommand())
|
.executes(commandNode.getCommand())
|
||||||
.redirect(commandNode)
|
.redirect(commandNode)
|
||||||
.build();
|
.build();
|
||||||
|
registerNode(node, prefixed);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void registerNode(LiteralCommandNode<BukkitBrigadierCommandSource> node, boolean prefixed) {
|
||||||
|
RootCommandNode<BukkitBrigadierCommandSource> root = getRootNode();
|
||||||
|
String name = node.getLiteral();
|
||||||
|
boolean isAlias = node.getRedirect() == commandNode;
|
||||||
|
boolean forceRegistration = switch (registrationPolicy) {
|
||||||
|
case NONE -> false;
|
||||||
|
case ONLY_BASE_COMMAND -> prefixed || !isAlias;
|
||||||
|
case ALL -> true;
|
||||||
|
};
|
||||||
|
|
||||||
|
// nmsDispatcher integration and conflit resolution
|
||||||
|
boolean nmsRegister = false, nmsRegistered = false;
|
||||||
|
CommandNode<BukkitBrigadierCommandSource> nmsConflicted = root.getChild(name);
|
||||||
|
if (nmsConflicted != null) {
|
||||||
|
|
||||||
|
if (isFromThisCommand(nmsConflicted)) {
|
||||||
|
// this command is already registered in NMS. Don’t need to register again
|
||||||
|
nmsRegistered = true;
|
||||||
|
}
|
||||||
|
else if (forceRegistration) {
|
||||||
|
nmsRegister = true;
|
||||||
|
Log.info("Overwriting Brigadier command /" + name);
|
||||||
|
}
|
||||||
|
else if (prefixed || !isAlias) {
|
||||||
|
Log.severe("/" + name + " already in NMS Brigadier instance."
|
||||||
|
+ " Wont replace it because registration is not forced for prefixed or initial name of a command.");
|
||||||
|
}
|
||||||
|
else { // conflict, won't replace, not forced but only an alias anyway
|
||||||
|
Log.info("/" + name + " already in NMS Brigadier instance."
|
||||||
|
+ " Wont replace it because registration is not forced for a non-prefixed alias.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
nmsRegister = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nmsRegister) {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
var rCommandNode = ReflectWrapper.wrapTyped(root, fr.pandacube.lib.paper.reflect.wrapper.brigadier.CommandNode.class);
|
||||||
|
rCommandNode.removeCommand(name);
|
||||||
|
root.addChild(node);
|
||||||
|
nmsRegistered = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!nmsRegistered) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
registeredAliases.add(name);
|
||||||
|
|
||||||
|
// bukkit dispatcher conflict resolution
|
||||||
|
boolean bukkitRegister = false;
|
||||||
|
CommandMap bukkitCmdMap = Bukkit.getCommandMap();
|
||||||
|
Command bukkitConflicted = bukkitCmdMap.getCommand(name);
|
||||||
|
if (bukkitConflicted != null) {
|
||||||
|
if (!isFromThisCommand(bukkitConflicted)) {
|
||||||
|
if (forceRegistration) {
|
||||||
|
bukkitRegister = true;
|
||||||
|
Log.info("Overwriting Bukkit command /" + name
|
||||||
|
+ " (" + getCommandIdentity(bukkitConflicted) + ")");
|
||||||
|
}
|
||||||
|
else if (prefixed || !isAlias) {
|
||||||
|
Log.severe("/" + name + " already in Bukkit dispatcher (" + getCommandIdentity(bukkitConflicted) + ")." +
|
||||||
|
" Wont replace it because registration is not forced for prefixed or initial name of a command.");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Log.info("/" + name + " already in Bukkit dispatcher (" + getCommandIdentity(bukkitConflicted) + ")." +
|
||||||
|
" Wont replace it because registration is not forced for a non-prefixed alias.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bukkitRegister = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bukkitRegister) {
|
||||||
|
bukkitCmdMap.getKnownCommands().remove(name.toLowerCase());
|
||||||
|
if (bukkitConflicted != null)
|
||||||
|
bukkitConflicted.unregister(bukkitCmdMap);
|
||||||
|
|
||||||
|
Command newCommand = new VanillaCommandWrapper(vanillaCommandDispatcher, node).__getRuntimeInstance();
|
||||||
|
bukkitCmdMap.getKnownCommands().put(name.toLowerCase(), newCommand);
|
||||||
|
newCommand.register(bukkitCmdMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isFromThisCommand(CommandNode<BukkitBrigadierCommandSource> node) {
|
||||||
|
return node == commandNode || node.getRedirect() == commandNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isFromThisCommand(Command bukkitCmd) {
|
||||||
|
if (VanillaCommandWrapper.REFLECT.get().isInstance(bukkitCmd)) {
|
||||||
|
return isFromThisCommand(ReflectWrapper.wrapTyped((BukkitCommand) bukkitCmd, VanillaCommandWrapper.class).vanillaCommand());
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getCommandIdentity(Command bukkitCmd) {
|
private static String getCommandIdentity(Command bukkitCmd) {
|
||||||
@ -194,6 +305,25 @@ public abstract class PaperBrigadierCommand extends BrigadierCommand<CommandSour
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Player command sender event handler.
|
||||||
|
* @param event the event.
|
||||||
|
*/
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerCommandSend(PlayerCommandSendEvent event) {
|
||||||
|
event.getCommands().removeAll(registeredAliases.stream().map(s -> "minecraft:" + s).toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Server load event handler.
|
||||||
|
* @param event the event.
|
||||||
|
*/
|
||||||
|
@EventHandler
|
||||||
|
public void onServerLoad(ServerLoadEvent event) {
|
||||||
|
register();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -212,15 +342,6 @@ public abstract class PaperBrigadierCommand extends BrigadierCommand<CommandSour
|
|||||||
*/
|
*/
|
||||||
protected abstract String getTargetPermission();
|
protected abstract String getTargetPermission();
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the permission that should be tested instead of "minecraft.command.cmdName". The conversion from the
|
|
||||||
* minecraft prefixed permission node to the returned node is done by the {@code pandalib-paper-permissions} if it
|
|
||||||
* is present in the classpath during runtime.
|
|
||||||
* @return the permission that should be tested instead of "minecraft.command.cmdName".
|
|
||||||
*/
|
|
||||||
protected String getDescription() {
|
|
||||||
return "A command from " + plugin.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -234,14 +355,13 @@ public abstract class PaperBrigadierCommand extends BrigadierCommand<CommandSour
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isConsole(BukkitBrigadierCommandSource wrapper) {
|
||||||
public boolean isConsole(CommandSourceStack wrapper) {
|
|
||||||
return isConsole(getCommandSender(wrapper));
|
return isConsole(getCommandSender(wrapper));
|
||||||
}
|
}
|
||||||
public boolean isPlayer(CommandSourceStack wrapper) {
|
public boolean isPlayer(BukkitBrigadierCommandSource wrapper) {
|
||||||
return isPlayer(getCommandSender(wrapper));
|
return isPlayer(getCommandSender(wrapper));
|
||||||
}
|
}
|
||||||
public Predicate<CommandSourceStack> hasPermission(String permission) {
|
public Predicate<BukkitBrigadierCommandSource> hasPermission(String permission) {
|
||||||
return wrapper -> getCommandSender(wrapper).hasPermission(permission);
|
return wrapper -> getCommandSender(wrapper).hasPermission(permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,7 +395,7 @@ public abstract class PaperBrigadierCommand extends BrigadierCommand<CommandSour
|
|||||||
* @param context the command context from which to get the Bukkit command sender.
|
* @param context the command context from which to get the Bukkit command sender.
|
||||||
* @return the Bukkit command sender.
|
* @return the Bukkit command sender.
|
||||||
*/
|
*/
|
||||||
public static CommandSender getCommandSender(CommandContext<CommandSourceStack> context) {
|
public static CommandSender getCommandSender(CommandContext<BukkitBrigadierCommandSource> context) {
|
||||||
return getCommandSender(context.getSource());
|
return getCommandSender(context.getSource());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,8 +404,8 @@ public abstract class PaperBrigadierCommand extends BrigadierCommand<CommandSour
|
|||||||
* @param wrapper the wrapper from which to get the Bukkit command sender.
|
* @param wrapper the wrapper from which to get the Bukkit command sender.
|
||||||
* @return the Bukkit command sender.
|
* @return the Bukkit command sender.
|
||||||
*/
|
*/
|
||||||
public static CommandSender getCommandSender(CommandSourceStack wrapper) {
|
public static CommandSender getCommandSender(BukkitBrigadierCommandSource wrapper) {
|
||||||
return wrapper.getSender();
|
return wrapper.getBukkitSender();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -293,8 +413,8 @@ public abstract class PaperBrigadierCommand extends BrigadierCommand<CommandSour
|
|||||||
* @param sender the command sender.
|
* @param sender the command sender.
|
||||||
* @return a new instance of a command sender wrapper for the provided command sender.
|
* @return a new instance of a command sender wrapper for the provided command sender.
|
||||||
*/
|
*/
|
||||||
public static CommandSourceStack getBrigadierCommandSource(CommandSender sender) {
|
public static BukkitBrigadierCommandSource getBrigadierCommandSource(CommandSender sender) {
|
||||||
throw new UnsupportedOperationException("The 1.20.6 Paper API update uses a different wrapper for Brigadier command sender.");
|
return VanillaCommandWrapper.getListener(sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -323,7 +443,7 @@ public abstract class PaperBrigadierCommand extends BrigadierCommand<CommandSour
|
|||||||
* @param suggestions the suggestions to wrap.
|
* @param suggestions the suggestions to wrap.
|
||||||
* @return a {@link SuggestionProvider} generating the suggestions from the provided {@link SuggestionsSupplier}.
|
* @return a {@link SuggestionProvider} generating the suggestions from the provided {@link SuggestionsSupplier}.
|
||||||
*/
|
*/
|
||||||
public SuggestionProvider<CommandSourceStack> wrapSuggestions(SuggestionsSupplier<CommandSender> suggestions) {
|
public SuggestionProvider<BukkitBrigadierCommandSource> wrapSuggestions(SuggestionsSupplier<CommandSender> suggestions) {
|
||||||
return wrapSuggestions(suggestions, PaperBrigadierCommand::getCommandSender);
|
return wrapSuggestions(suggestions, PaperBrigadierCommand::getCommandSender);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,7 +456,7 @@ public abstract class PaperBrigadierCommand extends BrigadierCommand<CommandSour
|
|||||||
* @param cmd the command executor to wrap.
|
* @param cmd the command executor to wrap.
|
||||||
* @return a wrapper command executor.
|
* @return a wrapper command executor.
|
||||||
*/
|
*/
|
||||||
protected static com.mojang.brigadier.Command<CommandSourceStack> wrapCommand(com.mojang.brigadier.Command<CommandSourceStack> cmd) {
|
protected static com.mojang.brigadier.Command<BukkitBrigadierCommandSource> wrapCommand(com.mojang.brigadier.Command<BukkitBrigadierCommandSource> cmd) {
|
||||||
return context -> {
|
return context -> {
|
||||||
try {
|
try {
|
||||||
return cmd.run(context);
|
return cmd.run(context);
|
||||||
@ -365,13 +485,181 @@ public abstract class PaperBrigadierCommand extends BrigadierCommand<CommandSour
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new instance of the Brigadier argument type {@code minecraft:entity}.
|
||||||
|
* @param singleTarget if this argument takes only a single target.
|
||||||
|
* @param playersOnly if this argument takes players only.
|
||||||
|
* @return the {@code minecraft:entity} argument type with the specified parameters.
|
||||||
|
*/
|
||||||
|
public static ArgumentType<Object> argumentMinecraftEntity(boolean singleTarget, boolean playersOnly) {
|
||||||
|
if (playersOnly) {
|
||||||
|
return singleTarget ? EntityArgument.player() : EntityArgument.players();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return singleTarget ? EntityArgument.entity() : EntityArgument.entities();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the provided argument of type {@code minecraft:entity} (list of entities), from the provided context.
|
||||||
|
* @param context the command execution context.
|
||||||
|
* @param argument the argument name.
|
||||||
|
* @return the value of the argument, or null if not found.
|
||||||
|
*/
|
||||||
|
public List<Entity> tryGetMinecraftEntityArgument(CommandContext<BukkitBrigadierCommandSource> context, String argument) {
|
||||||
|
EntitySelector es = ReflectWrapper.wrap(tryGetArgument(context, argument, EntitySelector.MAPPING.runtimeClass()), EntitySelector.class);
|
||||||
|
if (es == null)
|
||||||
|
return null;
|
||||||
|
List<fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.Entity> nmsEntityList = es.findEntities(context.getSource());
|
||||||
|
List<Entity> entityList = new ArrayList<>(nmsEntityList.size());
|
||||||
|
for (fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.Entity nmsEntity : nmsEntityList) {
|
||||||
|
entityList.add(nmsEntity.getBukkitEntity());
|
||||||
|
}
|
||||||
|
return entityList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the provided argument of type {@code minecraft:entity} (list of players), from the provided context.
|
||||||
|
* @param context the command execution context.
|
||||||
|
* @param argument the argument name.
|
||||||
|
* @return the value of the argument, or null if not found.
|
||||||
|
*/
|
||||||
|
public List<Player> tryGetMinecraftEntityArgumentPlayers(CommandContext<BukkitBrigadierCommandSource> context, String argument) {
|
||||||
|
EntitySelector es = ReflectWrapper.wrap(tryGetArgument(context, argument, EntitySelector.MAPPING.runtimeClass()), EntitySelector.class);
|
||||||
|
if (es == null)
|
||||||
|
return null;
|
||||||
|
List<ServerPlayer> nmsPlayerList = es.findPlayers(context.getSource());
|
||||||
|
List<Player> playerList = new ArrayList<>(nmsPlayerList.size());
|
||||||
|
for (ServerPlayer nmsPlayer : nmsPlayerList) {
|
||||||
|
playerList.add(nmsPlayer.getBukkitEntity());
|
||||||
|
}
|
||||||
|
return playerList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the provided argument of type {@code minecraft:entity} (one entity), from the provided context.
|
||||||
|
* @param context the command execution context.
|
||||||
|
* @param argument the argument name.
|
||||||
|
* @return the value of the argument, or null if not found.
|
||||||
|
*/
|
||||||
|
public Entity tryGetMinecraftEntityArgumentOneEntity(CommandContext<BukkitBrigadierCommandSource> context, String argument) {
|
||||||
|
EntitySelector es = ReflectWrapper.wrap(tryGetArgument(context, argument, EntitySelector.MAPPING.runtimeClass()), EntitySelector.class);
|
||||||
|
if (es == null)
|
||||||
|
return null;
|
||||||
|
fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.Entity nmsEntity = es.findSingleEntity(context.getSource());
|
||||||
|
return nmsEntity == null ? null : nmsEntity.getBukkitEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the provided argument of type {@code minecraft:entity} (one player), from the provided context.
|
||||||
|
* @param context the command execution context.
|
||||||
|
* @param argument the argument name.
|
||||||
|
* @return the value of the argument, or null if not found.
|
||||||
|
*/
|
||||||
|
public Player tryGetMinecraftEntityArgumentOnePlayer(CommandContext<BukkitBrigadierCommandSource> context, String argument) {
|
||||||
|
EntitySelector es = ReflectWrapper.wrap(tryGetArgument(context, argument, EntitySelector.MAPPING.runtimeClass()), EntitySelector.class);
|
||||||
|
if (es == null)
|
||||||
|
return null;
|
||||||
|
ServerPlayer nmsPlayer = es.findSinglePlayer(context.getSource());
|
||||||
|
return nmsPlayer == null ? null : nmsPlayer.getBukkitEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new instance of the Brigadier argument type {@code minecraft:block_pos}.
|
||||||
|
* @return the {@code minecraft:block_pos} argument type.
|
||||||
|
*/
|
||||||
|
public static ArgumentType<Object> argumentMinecraftBlockPosition() {
|
||||||
|
return BlockPosArgument.blockPos();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the provided argument of type {@code minecraft:block_pos}, from the provided context.
|
||||||
|
* @param context the command execution context.
|
||||||
|
* @param argument the argument name.
|
||||||
|
* @param deflt a default value if the argument is not found.
|
||||||
|
* @return the value of the argument.
|
||||||
|
*/
|
||||||
|
public BlockVector tryGetMinecraftBlockPositionArgument(CommandContext<BukkitBrigadierCommandSource> context,
|
||||||
|
String argument, BlockVector deflt) {
|
||||||
|
return tryGetArgument(context, argument, Coordinates.MAPPING.runtimeClass(), nmsCoordinate -> {
|
||||||
|
BlockPos bp = ReflectWrapper.wrap(nmsCoordinate, Coordinates.class).getBlockPos(context.getSource());
|
||||||
|
return new BlockVector(bp.getX(), bp.getY(), bp.getZ());
|
||||||
|
}, deflt);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new instance of the Brigadier argument type {@code minecraft:vec3}.
|
||||||
|
* @return the {@code minecraft:vec3} argument type.
|
||||||
|
*/
|
||||||
|
public static ArgumentType<Object> argumentMinecraftVec3() {
|
||||||
|
return Vec3Argument.vec3(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the provided argument of type {@code minecraft:vec3}, from the provided context.
|
||||||
|
* @param context the command execution context.
|
||||||
|
* @param argument the argument name.
|
||||||
|
* @param deflt a default value if the argument is not found.
|
||||||
|
* @return the value of the argument.
|
||||||
|
*/
|
||||||
|
public Vector tryGetMinecraftVec3Argument(CommandContext<BukkitBrigadierCommandSource> context, String argument,
|
||||||
|
Vector deflt) {
|
||||||
|
return tryGetArgument(context, argument, Coordinates.MAPPING.runtimeClass(),
|
||||||
|
nmsCoordinate -> CraftVector.toBukkit(
|
||||||
|
ReflectWrapper.wrap(nmsCoordinate, Coordinates.class).getPosition(context.getSource())
|
||||||
|
),
|
||||||
|
deflt);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new instance of the Brigadier argument type {@code minecraft:component}.
|
||||||
|
* @return the {@code minecraft:component} argument type.
|
||||||
|
*/
|
||||||
|
public static ArgumentType<Object> argumentMinecraftChatComponent() {
|
||||||
|
return ComponentArgument.textComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the provided argument of type {@code minecraft:component}, from the provided context.
|
||||||
|
* @param context the command execution context.
|
||||||
|
* @param argument the argument name.
|
||||||
|
* @param deflt a default value if the argument is not found.
|
||||||
|
* @return the value of the argument.
|
||||||
|
*/
|
||||||
|
public Component tryGetMinecraftChatComponentArgument(CommandContext<BukkitBrigadierCommandSource> context,
|
||||||
|
String argument, Component deflt) {
|
||||||
|
return tryGetArgument(context, argument,
|
||||||
|
fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.chat.Component.MAPPING.runtimeClass(),
|
||||||
|
nmsComp -> PaperAdventure.asAdventure(
|
||||||
|
ReflectWrapper.wrap(nmsComp,
|
||||||
|
fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.chat.Component.class)
|
||||||
|
),
|
||||||
|
deflt);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All possible choices on how to force the registration of a command, based on certain conditions.
|
* All possible choices on how to force the registration of a command, based on certain conditions.
|
||||||
*/
|
*/
|
||||||
public enum RegistrationPolicy {
|
public enum RegistrationPolicy {
|
||||||
|
/**
|
||||||
|
* Do not force to register a command node or an alias if there is already a command with that name in the
|
||||||
|
* vanilla Brigadier dispatcher.
|
||||||
|
* Note that all plugin-name-prefixed aliases will be registered anyway.
|
||||||
|
*/
|
||||||
|
NONE,
|
||||||
/**
|
/**
|
||||||
* Force only the base command (but not the aliases) to be registered, even if a command with that name already
|
* Force only the base command (but not the aliases) to be registered, even if a command with that name already
|
||||||
* exists in the vanilla Brigadier dispatcher.
|
* exists in the vanilla Brigadier dispatcher.
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package fr.pandacube.lib.paper.util;
|
package fr.pandacube.lib.paper.util;
|
||||||
|
|
||||||
|
import com.destroystokyo.paper.Namespaced;
|
||||||
import com.google.common.collect.Streams;
|
import com.google.common.collect.Streams;
|
||||||
import fr.pandacube.lib.chat.Chat;
|
import fr.pandacube.lib.chat.Chat;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
@ -12,8 +13,10 @@ import org.bukkit.inventory.meta.Damageable;
|
|||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import static fr.pandacube.lib.chat.ChatStatic.chatComponent;
|
import static fr.pandacube.lib.chat.ChatStatic.chatComponent;
|
||||||
@ -180,7 +183,7 @@ public class ItemStackBuilder {
|
|||||||
|
|
||||||
public ItemStackBuilder fakeEnchant(boolean apply) {
|
public ItemStackBuilder fakeEnchant(boolean apply) {
|
||||||
if (apply) {
|
if (apply) {
|
||||||
enchant(Enchantment.UNBREAKING, 1);
|
enchant(Enchantment.DURABILITY, 1);
|
||||||
return hideEnchants();
|
return hideEnchants();
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
@ -194,6 +197,22 @@ public class ItemStackBuilder {
|
|||||||
return meta(m -> m.setUnbreakable(unbreakable));
|
return meta(m -> m.setUnbreakable(unbreakable));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ItemStackBuilder canDestroy(Set<Material> destroyable) {
|
||||||
|
return canDestroy(destroyable.stream().map(m -> (Namespaced) m.getKey()).toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStackBuilder canPlaceOn(Set<Material> placeOn) {
|
||||||
|
return canPlaceOn(placeOn.stream().map(m -> (Namespaced) m.getKey()).toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStackBuilder canDestroy(Collection<Namespaced> destroyable) {
|
||||||
|
return meta(m -> m.setDestroyableKeys(destroyable));
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStackBuilder canPlaceOn(Collection<Namespaced> placeOn) {
|
||||||
|
return meta(m -> m.setPlaceableKeys(placeOn));
|
||||||
|
}
|
||||||
|
|
||||||
public ItemStackBuilder damage(int d) {
|
public ItemStackBuilder damage(int d) {
|
||||||
return meta(m -> m.setDamage(d), Damageable.class);
|
return meta(m -> m.setDamage(d), Damageable.class);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import java.util.function.IntUnaryOperator;
|
import java.util.function.IntUnaryOperator;
|
||||||
@ -99,7 +98,7 @@ public record PlayerDataWrapper(CompoundTag data) {
|
|||||||
Inventory inv = Bukkit.createInventory(null, bukkitType);
|
Inventory inv = Bukkit.createInventory(null, bukkitType);
|
||||||
if (stacks.isEmpty())
|
if (stacks.isEmpty())
|
||||||
return inv;
|
return inv;
|
||||||
for (Entry<Integer, ItemStack> is : stacks.entrySet()) {
|
for (Map.Entry<Integer, ItemStack> is : stacks.entrySet()) {
|
||||||
inv.setItem(nbtToBukkitSlotConverter.applyAsInt(is.getKey()), is.getValue());
|
inv.setItem(nbtToBukkitSlotConverter.applyAsInt(is.getKey()), is.getValue());
|
||||||
}
|
}
|
||||||
return inv;
|
return inv;
|
||||||
@ -143,7 +142,7 @@ public record PlayerDataWrapper(CompoundTag data) {
|
|||||||
|
|
||||||
private void setRawInventoryContent(String key, Map<Integer, ItemStack> stacks) {
|
private void setRawInventoryContent(String key, Map<Integer, ItemStack> stacks) {
|
||||||
ListTag list = new ListTag();
|
ListTag list = new ListTag();
|
||||||
for (Entry<Integer, ItemStack> is : stacks.entrySet()) {
|
for (Map.Entry<Integer, ItemStack> is : stacks.entrySet()) {
|
||||||
ItemStack stack = filterStack(is.getValue());
|
ItemStack stack = filterStack(is.getValue());
|
||||||
if (stack == null)
|
if (stack == null)
|
||||||
continue;
|
continue;
|
||||||
@ -313,7 +312,6 @@ public record PlayerDataWrapper(CompoundTag data) {
|
|||||||
case LEGS -> Objects.requireNonNullElseGet(this.getLeggings(), () -> new ItemStack(Material.AIR));
|
case LEGS -> Objects.requireNonNullElseGet(this.getLeggings(), () -> new ItemStack(Material.AIR));
|
||||||
case CHEST -> Objects.requireNonNullElseGet(this.getChestplate(), () -> new ItemStack(Material.AIR));
|
case CHEST -> Objects.requireNonNullElseGet(this.getChestplate(), () -> new ItemStack(Material.AIR));
|
||||||
case HEAD -> Objects.requireNonNullElseGet(this.getHelmet(), () -> new ItemStack(Material.AIR));
|
case HEAD -> Objects.requireNonNullElseGet(this.getHelmet(), () -> new ItemStack(Material.AIR));
|
||||||
case BODY -> new ItemStack(Material.AIR); // for horses/wolves armor
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,6 +120,4 @@ public class PermissionExpressionParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private PermissionExpressionParser() {}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -200,6 +200,4 @@ public class Permissions {
|
|||||||
return backendReader.getFullPermissionsList();
|
return backendReader.getFullPermissionsList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Permissions() {}
|
|
||||||
|
|
||||||
}
|
}
|
@ -48,5 +48,4 @@ public class Reflect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Reflect() {}
|
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,4 @@ public class WrapperRegistry {
|
|||||||
ReflectConstructor<? extends ReflectWrapperI> objectWrapperConstructor) {
|
ReflectConstructor<? extends ReflectWrapperI> objectWrapperConstructor) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private WrapperRegistry() {}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,4 @@ public class DistanceUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private DistanceUtil() {}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -84,6 +84,4 @@ public class EnumUtil {
|
|||||||
return RandomUtil.arrayElement(enumType.getEnumConstants());
|
return RandomUtil.arrayElement(enumType.getEnumConstants());
|
||||||
}
|
}
|
||||||
|
|
||||||
private EnumUtil() {}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,4 @@ public class FileUtils {
|
|||||||
Files.copy(source.toPath(), target.toPath());
|
Files.copy(source.toPath(), target.toPath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private FileUtils() {}
|
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,4 @@ public class ListUtil {
|
|||||||
list.add(i);
|
list.add(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private ListUtil() {}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -159,6 +159,4 @@ public class MemoryUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private MemoryUtil() {}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -98,8 +98,6 @@ public class MinecraftWebUtil {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private MinecraftWebUtil() {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ import java.util.UUID;
|
|||||||
* <p>
|
* <p>
|
||||||
* You can generate the UUID programmatically using {@link #getFromNickName(String)} and
|
* You can generate the UUID programmatically using {@link #getFromNickName(String)} and
|
||||||
* {@link #getFromNickNames(String[])}.
|
* {@link #getFromNickNames(String[])}.
|
||||||
* <p>
|
*
|
||||||
* To use this class as a program, type
|
* To use this class as a program, type
|
||||||
* <pre>
|
* <pre>
|
||||||
* java -cp<anyClassPathContainingThisClass> fr.pandacube.lib.util.OfflineUUID [playernames...]
|
* java -cp<anyClassPathContainingThisClass> fr.pandacube.lib.util.OfflineUUID [playernames...]
|
||||||
@ -67,6 +67,4 @@ public class OfflineUUID {
|
|||||||
System.out.println(arg + "\t" + getFromNickName(arg));
|
System.out.println(arg + "\t" + getFromNickName(arg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private OfflineUUID() {}
|
|
||||||
}
|
}
|
||||||
|
@ -172,7 +172,7 @@ public class RandomUtil {
|
|||||||
return String.valueOf(pw);
|
return String.valueOf(pw);
|
||||||
}
|
}
|
||||||
|
|
||||||
private RandomUtil() {}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -146,6 +146,6 @@ public class StringUtil {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
private StringUtil() {}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -147,6 +147,5 @@ public class ThrowableUtil {
|
|||||||
return new RuntimeException(t);
|
return new RuntimeException(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ThrowableUtil() {}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,4 @@ public class Tick {
|
|||||||
return Duration.ofMillis(toMs(tick));
|
return Duration.ofMillis(toMs(tick));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Tick() {}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -481,7 +481,4 @@ public class TimeUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private TimeUtil() {}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,6 @@ package fr.pandacube.lib.util.function;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A consumer that can possibly throw a checked exception.
|
* A consumer that can possibly throw a checked exception.
|
||||||
* @param <T> the first parameter for this bi-consumer.
|
|
||||||
* @param <U> the second parameter for this bi-consumer.
|
|
||||||
* @param <E> the exception type that this interface method can throw.
|
|
||||||
*/
|
*/
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface BiConsumerException<T, U, E extends Exception> {
|
public interface BiConsumerException<T, U, E extends Exception> {
|
||||||
|
@ -2,8 +2,6 @@ package fr.pandacube.lib.util.function;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A predicate that can possibly throw a checked exception.
|
* A predicate that can possibly throw a checked exception.
|
||||||
* @param <T> the parameter for this predicate.
|
|
||||||
* @param <E> the exception type that this predicate can throw.
|
|
||||||
*/
|
*/
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface PredicateException<T, E extends Exception> {
|
public interface PredicateException<T, E extends Exception> {
|
||||||
|
@ -2,7 +2,6 @@ package fr.pandacube.lib.util.function;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A runnable that can possibly throw a checked exception.
|
* A runnable that can possibly throw a checked exception.
|
||||||
* @param <E> the exception type that this interface method can throw.
|
|
||||||
*/
|
*/
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface RunnableException<E extends Exception> {
|
public interface RunnableException<E extends Exception> {
|
||||||
|
@ -2,8 +2,6 @@ package fr.pandacube.lib.util.function;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A supplier that can possibly throw a checked exception.
|
* A supplier that can possibly throw a checked exception.
|
||||||
* @param <T> the return type of this supplier.
|
|
||||||
* @param <E> the exception type that this interface method can throw.
|
|
||||||
*/
|
*/
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface SupplierException<T, E extends Exception> {
|
public interface SupplierException<T, E extends Exception> {
|
||||||
|
@ -2,9 +2,6 @@ package fr.pandacube.lib.util.function;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A function that can possibly throw a checked exception.
|
* A function that can possibly throw a checked exception.
|
||||||
* @param <T> the first parameter for this bi-function.
|
|
||||||
* @param <U> the second parameter for this bi-function.
|
|
||||||
* @param <E> the exception type that this interface method can throw.
|
|
||||||
*/
|
*/
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface ToIntBiFunctionException<T, U, E extends Exception> {
|
public interface ToIntBiFunctionException<T, U, E extends Exception> {
|
||||||
|
@ -2,10 +2,6 @@ package fr.pandacube.lib.util.function;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A consumer that can possibly throw a checked exception.
|
* A consumer that can possibly throw a checked exception.
|
||||||
* @param <T> the first parameter for this tri-consumer.
|
|
||||||
* @param <U> the second parameter for this tri-consumer.
|
|
||||||
* @param <V> the third parameter for this tri-consumer.
|
|
||||||
* @param <E> the exception type that this interface method can throw.
|
|
||||||
*/
|
*/
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface TriConsumerException<T, U, V, E extends Exception> {
|
public interface TriConsumerException<T, U, V, E extends Exception> {
|
||||||
|
@ -30,11 +30,6 @@ public class DailyLogRotateFileHandler extends Handler {
|
|||||||
private String currentFileDate = getCurrentDay();
|
private String currentFileDate = getCurrentDay();
|
||||||
private boolean closed = false;
|
private boolean closed = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new {@link DailyLogRotateFileHandler}.
|
|
||||||
*/
|
|
||||||
public DailyLogRotateFileHandler() {}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void close() throws SecurityException {
|
public synchronized void close() throws SecurityException {
|
||||||
|
@ -159,6 +159,4 @@ public final class Log {
|
|||||||
logger.info(message);
|
logger.info(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Log() {}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,6 @@ public abstract class AbstractServerWS extends WebSocketAdapter implements Abstr
|
|||||||
|
|
||||||
private boolean isClosed = false;
|
private boolean isClosed = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a Websocket server endpoint.
|
|
||||||
*/
|
|
||||||
public AbstractServerWS() {}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void onWebSocketConnect(Session session)
|
public final void onWebSocketConnect(Session session)
|
||||||
{
|
{
|
||||||
|
@ -100,6 +100,4 @@ public class PayloadRegistry {
|
|||||||
registerPayloadType("login-succeed", LoginSucceedPayload.class);
|
registerPayloadType("login-succeed", LoginSucceedPayload.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private PayloadRegistry() {}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,4 @@ package fr.pandacube.lib.ws.payloads;
|
|||||||
* Payload used by the server in inform the client the login was successful.
|
* Payload used by the server in inform the client the login was successful.
|
||||||
*/
|
*/
|
||||||
public class LoginSucceedPayload extends Payload {
|
public class LoginSucceedPayload extends Payload {
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new {@link LoginSucceedPayload}.
|
|
||||||
*/
|
|
||||||
public LoginSucceedPayload() {}
|
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,4 @@ package fr.pandacube.lib.ws.payloads;
|
|||||||
*/
|
*/
|
||||||
public abstract class Payload {
|
public abstract class Payload {
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new {@link Payload}.
|
|
||||||
*/
|
|
||||||
public Payload() {}
|
|
||||||
}
|
}
|
6
pom.xml
6
pom.xml
@ -25,7 +25,7 @@
|
|||||||
</developer>
|
</developer>
|
||||||
</developers>
|
</developers>
|
||||||
|
|
||||||
<inceptionYear>2011</inceptionYear>
|
<inceptionYear>2015</inceptionYear>
|
||||||
|
|
||||||
<ciManagement>
|
<ciManagement>
|
||||||
<system>jenkins</system>
|
<system>jenkins</system>
|
||||||
@ -56,8 +56,8 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
|
||||||
<bungeecord.version>1.20-R0.3-SNAPSHOT</bungeecord.version>
|
<bungeecord.version>1.20-R0.3-SNAPSHOT</bungeecord.version>
|
||||||
<paper.version>1.20.6-R0.1</paper.version>
|
<paper.version>1.20.4-R0.1</paper.version>
|
||||||
<mc.version>1.20.6</mc.version>
|
<mc.version>1.20.4</mc.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
|
Loading…
Reference in New Issue
Block a user