From 77400bd81ae5bedc0a83b49ccd74881cab5be4fa Mon Sep 17 00:00:00 2001 From: Paldiu Date: Wed, 17 Mar 2021 14:04:44 -0500 Subject: [PATCH] BLEEDING EDGE 1.3_10 EPICO! --- gradle.properties | 2 +- .../io/github/simplexdev/api/IStructure.java | 17 +++++++-- .../simplexcore/command/CommandLoader.java | 35 +++++++++++-------- 3 files changed, 36 insertions(+), 18 deletions(-) diff --git a/gradle.properties b/gradle.properties index a24f182..fbc5b5e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ pluginMain=SimplexCorePlugin pluginMainPackage=io.github.simplexdev.simplexcore -pluginVersion=1.3_08 +pluginVersion=1.3_10 pluginName=SimplexCore pluginJarClassifier=BLEEDING diff --git a/src/main/java/io/github/simplexdev/api/IStructure.java b/src/main/java/io/github/simplexdev/api/IStructure.java index 663fa90..aad88f4 100644 --- a/src/main/java/io/github/simplexdev/api/IStructure.java +++ b/src/main/java/io/github/simplexdev/api/IStructure.java @@ -7,14 +7,17 @@ import org.bukkit.World; import org.bukkit.block.Block; import java.io.File; +import java.util.Map; public interface IStructure { NamespacedKey getNamespacedKey(); String getName(); - int getId(); - + /** + * Gets the location where the structure is supposed to generate. + * @return Structure Location + */ Location getLocation(); World getWorld(); @@ -25,9 +28,19 @@ public interface IStructure { void generate(Location location, World world, boolean generateNaturally); + /** + * Gets the approximate size of the structure / schematic. + * This is for natural generation of structures, to ensure it doesn't generate somewhere + * which is occluded or otherwise populated. This will always round up to the nearest + * related size, and never down. + * @return The approximate {@link Size} of the structure. + */ Size getApproximateSize(); Block[] getBlocks(); + Map getBlockLocations(); + File getStructureFile(); } + 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 a2011e3..08c4423 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/command/CommandLoader.java +++ b/src/main/java/io/github/simplexdev/simplexcore/command/CommandLoader.java @@ -25,7 +25,7 @@ public final class CommandLoader { /** * @return A Singleton Pattern instance of this class. */ - public static synchronized CommandLoader getInstance() { + public static CommandLoader getInstance() { return instance; } @@ -43,7 +43,11 @@ public final class CommandLoader { * @param clazz The command class to load from * @return An instance of this where the classpath has been prepared for loading the commands. */ - public synchronized CommandLoader classpath(Class clazz) { + public CommandLoader classpath(Class clazz) { + if (clazz == null) { + throw new IllegalStateException("The class provided cannot be found!"); + } + if (!clazz.isAnnotationPresent(CommandInfo.class)) { throw new MissingResourceException("Cannot register this class as the main resource location!", clazz.getSimpleName(), "@CommandInfo"); } @@ -53,6 +57,7 @@ public final class CommandLoader { } reflections = new Reflections(clazz); + return this; } @@ -63,23 +68,23 @@ public final class CommandLoader { * * @param plugin An instance of your plugin to assign as the parent plugin for each command. */ - public synchronized void load(SimplexAddon plugin) { + public void load(SimplexAddon plugin) { reflections.getTypesAnnotatedWith(CommandInfo.class).forEach(annotated -> { CommandInfo info = annotated.getDeclaredAnnotation(CommandInfo.class); if (info == null) return; if (!SimplexCommand.class.isAssignableFrom(annotated)) return; - PluginCommand objectToRegister = Registry.create(plugin, info.name().toLowerCase()); - objectToRegister.setAliases(Arrays.asList(info.aliases().split(","))); - objectToRegister.setDescription(info.description()); - objectToRegister.setExecutor(getExecutorFromName(info.name())); - objectToRegister.setLabel(info.name().toLowerCase()); - objectToRegister.setPermission(info.permission()); - objectToRegister.setPermissionMessage(info.permissionMessage()); - objectToRegister.setTabCompleter(getTabFromName(info.name())); - objectToRegister.setUsage(info.usage()); - Registry.registerCommand(objectToRegister); + PluginCommand command = Registry.create(plugin, info.name().toLowerCase()); + command.setAliases(Arrays.asList(info.aliases().split(","))); + command.setDescription(info.description()); + command.setExecutor(getExecutorFromName(info.name())); + command.setLabel(info.name().toLowerCase()); + command.setPermission(info.permission()); + command.setPermissionMessage(info.permissionMessage()); + command.setTabCompleter(getTabFromName(info.name())); + command.setUsage(info.usage()); + Registry.registerCommand(command); }); } @@ -90,7 +95,7 @@ public final class CommandLoader { * @param name The name of the command. * @return An instance of the command class as a CommandExecutor. */ - public synchronized CommandExecutor getExecutorFromName(String name) { + public CommandExecutor getExecutorFromName(String name) { for (Class obj : reflections.getSubTypesOf(CommandExecutor.class)) { if (!obj.isAnnotationPresent(CommandInfo.class)) { throw new RuntimeException("Missing annotation CommandInfo!"); @@ -119,7 +124,7 @@ public final class CommandLoader { * @return The command as an instance of TabCompleter */ @Nullable - public synchronized TabCompleter getTabFromName(String name) { + public TabCompleter getTabFromName(String name) { for (Class obj : reflections.getSubTypesOf(TabCompleter.class)) { if (!obj.isAnnotationPresent(CommandInfo.class)) { throw new RuntimeException("Missing annotation CommandInfo!");