diff --git a/build.gradle b/build.gradle index 168dfe0..118cb0a 100644 --- a/build.gradle +++ b/build.gradle @@ -31,6 +31,7 @@ dependencies { "net.md-5:bungeecord-api:1.16-R0.4-SNAPSHOT", "io.github.waterfallmc:waterfall-api:1.16-R0.4-SNAPSHOT", "me.clip:placeholderapi:2.10.9", + files("libs/spigot-1.16.5.jar") ].each {s -> compileOnly s } diff --git a/src/main/java/io/github/simplexdev/simplexcore/command/CommandLoader.java b/src/main/java/io/github/simplexdev/simplexcore/command/CommandLoader.java index 7a2689c..bbbef8c 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/command/CommandLoader.java +++ b/src/main/java/io/github/simplexdev/simplexcore/command/CommandLoader.java @@ -4,6 +4,7 @@ import io.github.simplexdev.api.annotations.CommandInfo; import io.github.simplexdev.simplexcore.command.defaults.DefaultCommand; import io.github.simplexdev.simplexcore.module.SimplexModule; import io.github.simplexdev.simplexcore.utils.ReflectionTools; +import io.github.simplexdev.simplexcore.SimplexCorePlugin; import org.bukkit.Bukkit; import org.bukkit.command.*; import org.bukkit.plugin.Plugin; @@ -73,8 +74,21 @@ public final class CommandLoader { reflections.getTypesAnnotatedWith(CommandInfo.class).forEach(annotated -> { CommandInfo info = annotated.getDeclaredAnnotation(CommandInfo.class); - if (info == null) return; - if (!SimplexCommand.class.isAssignableFrom(annotated)) return; + if (info == null) { + SimplexCorePlugin.getInstance() + .getLogger().warning(annotated.getSimpleName() + + " is missing a required annotation: " + + CommandInfo.class.getSimpleName()); + return; + } + + if (!SimplexCommand.class.isAssignableFrom(annotated)) { + SimplexCorePlugin.getInstance() + .getLogger().warning(annotated.getSimpleName() + + " must extend " + SimplexCommand.class.getSimpleName() + + " to be registered as a command."); + return; + } PluginCommand command = Registry.create(plugin, info.name().toLowerCase()); command.setAliases(Arrays.asList(info.aliases().split(","))); @@ -100,7 +114,10 @@ public final class CommandLoader { public CommandExecutor getExecutorFromName(String name) { for (Class obj : reflections.getSubTypesOf(CommandExecutor.class)) { if (!obj.isAnnotationPresent(CommandInfo.class)) { - throw new RuntimeException("Missing annotation CommandInfo!"); + SimplexCorePlugin.getInstance() + .getLogger().warning(obj.getSimpleName() + + " is missing a required annotation: " + + CommandInfo.class.getSimpleName()); } CommandInfo info = obj.getDeclaredAnnotation(CommandInfo.class); @@ -115,7 +132,7 @@ public final class CommandLoader { } } } - throw new RuntimeException("Unable to get a command executor! Terminating!"); + throw new RuntimeException("Unable to assign a CommandExecutor from the provided classes!"); } /** @@ -130,7 +147,11 @@ public final class CommandLoader { public TabCompleter getTabFromName(String name) { for (Class obj : reflections.getSubTypesOf(TabCompleter.class)) { if (!obj.isAnnotationPresent(CommandInfo.class)) { - throw new RuntimeException("Missing annotation CommandInfo!"); + SimplexCorePlugin.getInstance() + .getLogger().warning(obj.getSimpleName() + + " is missing required annotation: " + + CommandInfo.class.getSimpleName()); + continue; } CommandInfo info = obj.getDeclaredAnnotation(CommandInfo.class); @@ -153,12 +174,10 @@ public final class CommandLoader { private static class Registry { private static final Constructor constructor; private static final Field cmdMapField; - private static final Field knownCmdsField; static { constructor = ReflectionTools.getDeclaredConstructor(PluginCommand.class, String.class, Plugin.class); cmdMapField = ReflectionTools.getDeclaredField(SimplePluginManager.class, "commandMap"); - knownCmdsField = ReflectionTools.getDeclaredField(SimpleCommandMap.class, "knownCommands"); } public static PluginCommand create(@NotNull Plugin plugin, @NotNull String name) { @@ -168,12 +187,6 @@ public final class CommandLoader { public static void registerCommand(PluginCommand command) { try { CommandMap map = (CommandMap) cmdMapField.get(Bukkit.getPluginManager()); - Map knownCommands = map.getKnownCommands(); - - if (knownCommands.containsKey(command.getName().toLowerCase())) { - knownCommands.replace(command.getName().toLowerCase(), command); - } - map.register(command.getName().toLowerCase(), command); } catch (IllegalAccessException e) { throw new RuntimeException(e); diff --git a/src/main/java/io/github/simplexdev/simplexcore/enchanting/SimplexEnch.java b/src/main/java/io/github/simplexdev/simplexcore/enchanting/SimplexEnch.java index 551f242..e3d01d2 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/enchanting/SimplexEnch.java +++ b/src/main/java/io/github/simplexdev/simplexcore/enchanting/SimplexEnch.java @@ -1,12 +1,24 @@ package io.github.simplexdev.simplexcore.enchanting; import io.github.simplexdev.api.IEnchant; +import io.github.simplexdev.simplexcore.module.SimplexModule; +import net.minecraft.server.v1_16_R3.EnchantmentSlotType; +import net.minecraft.server.v1_16_R3.EnumItemSlot; +import net.minecraft.server.v1_16_R3.Enchantment; import org.bukkit.NamespacedKey; -import org.bukkit.enchantments.Enchantment; -import org.jetbrains.annotations.NotNull; public abstract class SimplexEnch extends Enchantment implements IEnchant { - public SimplexEnch(@NotNull NamespacedKey key) { - super(key); + protected final SimplexModule plugin; // What was your question? + + protected SimplexEnch(SimplexModule plugin, Rarity rarity, EnchantmentSlotType type, EnumItemSlot[] enumSlot) { + super(rarity, type, enumSlot); + this.plugin = plugin; + } + + public abstract String name(); + + @Override + public NamespacedKey getNamespacedKey() { + return new NamespacedKey(plugin, name()); } } diff --git a/src/main/java/io/github/simplexdev/simplexcore/structures/block/NBTBlock.java b/src/main/java/io/github/simplexdev/simplexcore/structures/block/NBTBlock.java new file mode 100644 index 0000000..3a9f838 --- /dev/null +++ b/src/main/java/io/github/simplexdev/simplexcore/structures/block/NBTBlock.java @@ -0,0 +1,15 @@ +package io.github.simplexdev.simplexcore.structures.block; + +import net.minecraft.server.v1_16_R3.NBTTagCompound; + +public abstract class NBTBlock { + private final NBTTagCompound nbttag; + + public NBTBlock(NBTTagCompound nbttag){ + this.nbttag = nbttag; + } + + public NBTTagCompound getNbttag(){ + return nbttag; + } +}