BLEEDING EDGE 1.3_12

This commit is contained in:
Paldiu 2021-03-25 13:17:05 -05:00
parent 99c19f0ff7
commit c4b94c3754
4 changed files with 58 additions and 17 deletions

View File

@ -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
}

View File

@ -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<? extends CommandExecutor> 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<? extends TabCompleter> 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<PluginCommand> 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<String, Command> 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);

View File

@ -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());
}
}

View File

@ -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;
}
}