BLEEDING EDGE 1.3_10

EPICO!
This commit is contained in:
Paldiu 2021-03-17 14:04:44 -05:00
parent ae95b89641
commit 77400bd81a
3 changed files with 36 additions and 18 deletions

View File

@ -1,5 +1,5 @@
pluginMain=SimplexCorePlugin pluginMain=SimplexCorePlugin
pluginMainPackage=io.github.simplexdev.simplexcore pluginMainPackage=io.github.simplexdev.simplexcore
pluginVersion=1.3_08 pluginVersion=1.3_10
pluginName=SimplexCore pluginName=SimplexCore
pluginJarClassifier=BLEEDING pluginJarClassifier=BLEEDING

View File

@ -7,14 +7,17 @@ import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import java.io.File; import java.io.File;
import java.util.Map;
public interface IStructure { public interface IStructure {
NamespacedKey getNamespacedKey(); NamespacedKey getNamespacedKey();
String getName(); String getName();
int getId(); /**
* Gets the location where the structure is supposed to generate.
* @return Structure Location
*/
Location getLocation(); Location getLocation();
World getWorld(); World getWorld();
@ -25,9 +28,19 @@ public interface IStructure {
void generate(Location location, World world, boolean generateNaturally); 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(); Size getApproximateSize();
Block[] getBlocks(); Block[] getBlocks();
Map<Block, Location> getBlockLocations();
File getStructureFile(); File getStructureFile();
} }

View File

@ -25,7 +25,7 @@ public final class CommandLoader {
/** /**
* @return A Singleton Pattern instance of this class. * @return A Singleton Pattern instance of this class.
*/ */
public static synchronized CommandLoader getInstance() { public static CommandLoader getInstance() {
return instance; return instance;
} }
@ -43,7 +43,11 @@ public final class CommandLoader {
* @param clazz The command class to load from * @param clazz The command class to load from
* @return An instance of this where the classpath has been prepared for loading the commands. * @return An instance of this where the classpath has been prepared for loading the commands.
*/ */
public synchronized CommandLoader classpath(Class<?> clazz) { public <T extends SimplexCommand> CommandLoader classpath(Class<T> clazz) {
if (clazz == null) {
throw new IllegalStateException("The class provided cannot be found!");
}
if (!clazz.isAnnotationPresent(CommandInfo.class)) { if (!clazz.isAnnotationPresent(CommandInfo.class)) {
throw new MissingResourceException("Cannot register this class as the main resource location!", clazz.getSimpleName(), "@CommandInfo"); 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); reflections = new Reflections(clazz);
return this; 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. * @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 -> { 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) return;
if (!SimplexCommand.class.isAssignableFrom(annotated)) return; if (!SimplexCommand.class.isAssignableFrom(annotated)) return;
PluginCommand objectToRegister = Registry.create(plugin, info.name().toLowerCase()); PluginCommand command = Registry.create(plugin, info.name().toLowerCase());
objectToRegister.setAliases(Arrays.asList(info.aliases().split(","))); command.setAliases(Arrays.asList(info.aliases().split(",")));
objectToRegister.setDescription(info.description()); command.setDescription(info.description());
objectToRegister.setExecutor(getExecutorFromName(info.name())); command.setExecutor(getExecutorFromName(info.name()));
objectToRegister.setLabel(info.name().toLowerCase()); command.setLabel(info.name().toLowerCase());
objectToRegister.setPermission(info.permission()); command.setPermission(info.permission());
objectToRegister.setPermissionMessage(info.permissionMessage()); command.setPermissionMessage(info.permissionMessage());
objectToRegister.setTabCompleter(getTabFromName(info.name())); command.setTabCompleter(getTabFromName(info.name()));
objectToRegister.setUsage(info.usage()); command.setUsage(info.usage());
Registry.registerCommand(objectToRegister); Registry.registerCommand(command);
}); });
} }
@ -90,7 +95,7 @@ public final class CommandLoader {
* @param name The name of the command. * @param name The name of the command.
* @return An instance of the command class as a CommandExecutor. * @return An instance of the command class as a CommandExecutor.
*/ */
public synchronized 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!"); throw new RuntimeException("Missing annotation CommandInfo!");
@ -119,7 +124,7 @@ public final class CommandLoader {
* @return The command as an instance of TabCompleter * @return The command as an instance of TabCompleter
*/ */
@Nullable @Nullable
public synchronized 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!"); throw new RuntimeException("Missing annotation CommandInfo!");