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
pluginMainPackage=io.github.simplexdev.simplexcore
pluginVersion=1.3_08
pluginVersion=1.3_10
pluginName=SimplexCore
pluginJarClassifier=BLEEDING

View File

@ -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<Block, Location> getBlockLocations();
File getStructureFile();
}

View File

@ -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 <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)) {
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<? extends CommandExecutor> 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<? extends TabCompleter> obj : reflections.getSubTypesOf(TabCompleter.class)) {
if (!obj.isAnnotationPresent(CommandInfo.class)) {
throw new RuntimeException("Missing annotation CommandInfo!");