mirror of
https://github.com/SimplexDevelopment/SimplexCore.git
synced 2024-12-22 08:37:37 +00:00
BLEEDING EDGE 1.3_12
This commit is contained in:
parent
99c19f0ff7
commit
c4b94c3754
@ -31,6 +31,7 @@ dependencies {
|
|||||||
"net.md-5:bungeecord-api:1.16-R0.4-SNAPSHOT",
|
"net.md-5:bungeecord-api:1.16-R0.4-SNAPSHOT",
|
||||||
"io.github.waterfallmc:waterfall-api:1.16-R0.4-SNAPSHOT",
|
"io.github.waterfallmc:waterfall-api:1.16-R0.4-SNAPSHOT",
|
||||||
"me.clip:placeholderapi:2.10.9",
|
"me.clip:placeholderapi:2.10.9",
|
||||||
|
files("libs/spigot-1.16.5.jar")
|
||||||
].each {s ->
|
].each {s ->
|
||||||
compileOnly s
|
compileOnly s
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import io.github.simplexdev.api.annotations.CommandInfo;
|
|||||||
import io.github.simplexdev.simplexcore.command.defaults.DefaultCommand;
|
import io.github.simplexdev.simplexcore.command.defaults.DefaultCommand;
|
||||||
import io.github.simplexdev.simplexcore.module.SimplexModule;
|
import io.github.simplexdev.simplexcore.module.SimplexModule;
|
||||||
import io.github.simplexdev.simplexcore.utils.ReflectionTools;
|
import io.github.simplexdev.simplexcore.utils.ReflectionTools;
|
||||||
|
import io.github.simplexdev.simplexcore.SimplexCorePlugin;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.*;
|
import org.bukkit.command.*;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
@ -73,8 +74,21 @@ public final class CommandLoader {
|
|||||||
reflections.getTypesAnnotatedWith(CommandInfo.class).forEach(annotated -> {
|
reflections.getTypesAnnotatedWith(CommandInfo.class).forEach(annotated -> {
|
||||||
CommandInfo info = annotated.getDeclaredAnnotation(CommandInfo.class);
|
CommandInfo info = annotated.getDeclaredAnnotation(CommandInfo.class);
|
||||||
|
|
||||||
if (info == null) return;
|
if (info == null) {
|
||||||
if (!SimplexCommand.class.isAssignableFrom(annotated)) return;
|
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());
|
PluginCommand command = Registry.create(plugin, info.name().toLowerCase());
|
||||||
command.setAliases(Arrays.asList(info.aliases().split(",")));
|
command.setAliases(Arrays.asList(info.aliases().split(",")));
|
||||||
@ -100,7 +114,10 @@ public final class CommandLoader {
|
|||||||
public CommandExecutor getExecutorFromName(String name) {
|
public CommandExecutor getExecutorFromName(String name) {
|
||||||
for (Class<? extends CommandExecutor> obj : reflections.getSubTypesOf(CommandExecutor.class)) {
|
for (Class<? extends CommandExecutor> obj : reflections.getSubTypesOf(CommandExecutor.class)) {
|
||||||
if (!obj.isAnnotationPresent(CommandInfo.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);
|
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) {
|
public TabCompleter getTabFromName(String name) {
|
||||||
for (Class<? extends TabCompleter> obj : reflections.getSubTypesOf(TabCompleter.class)) {
|
for (Class<? extends TabCompleter> obj : reflections.getSubTypesOf(TabCompleter.class)) {
|
||||||
if (!obj.isAnnotationPresent(CommandInfo.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);
|
CommandInfo info = obj.getDeclaredAnnotation(CommandInfo.class);
|
||||||
@ -153,12 +174,10 @@ public final class CommandLoader {
|
|||||||
private static class Registry {
|
private static class Registry {
|
||||||
private static final Constructor<PluginCommand> constructor;
|
private static final Constructor<PluginCommand> constructor;
|
||||||
private static final Field cmdMapField;
|
private static final Field cmdMapField;
|
||||||
private static final Field knownCmdsField;
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
constructor = ReflectionTools.getDeclaredConstructor(PluginCommand.class, String.class, Plugin.class);
|
constructor = ReflectionTools.getDeclaredConstructor(PluginCommand.class, String.class, Plugin.class);
|
||||||
cmdMapField = ReflectionTools.getDeclaredField(SimplePluginManager.class, "commandMap");
|
cmdMapField = ReflectionTools.getDeclaredField(SimplePluginManager.class, "commandMap");
|
||||||
knownCmdsField = ReflectionTools.getDeclaredField(SimpleCommandMap.class, "knownCommands");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PluginCommand create(@NotNull Plugin plugin, @NotNull String name) {
|
public static PluginCommand create(@NotNull Plugin plugin, @NotNull String name) {
|
||||||
@ -168,12 +187,6 @@ public final class CommandLoader {
|
|||||||
public static void registerCommand(PluginCommand command) {
|
public static void registerCommand(PluginCommand command) {
|
||||||
try {
|
try {
|
||||||
CommandMap map = (CommandMap) cmdMapField.get(Bukkit.getPluginManager());
|
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);
|
map.register(command.getName().toLowerCase(), command);
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
@ -1,12 +1,24 @@
|
|||||||
package io.github.simplexdev.simplexcore.enchanting;
|
package io.github.simplexdev.simplexcore.enchanting;
|
||||||
|
|
||||||
import io.github.simplexdev.api.IEnchant;
|
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.NamespacedKey;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public abstract class SimplexEnch extends Enchantment implements IEnchant {
|
public abstract class SimplexEnch extends Enchantment implements IEnchant {
|
||||||
public SimplexEnch(@NotNull NamespacedKey key) {
|
protected final SimplexModule<?> plugin; // What was your question?
|
||||||
super(key);
|
|
||||||
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user