From 0f71a93b54bc200e3b94c764ac43000b775df563 Mon Sep 17 00:00:00 2001 From: Paldiu Date: Wed, 27 Jan 2021 13:33:10 -0600 Subject: [PATCH] Felt cute, might delete later --- .../paldiu/simplexcore/SimplexCore.java | 5 +-- .../simplexcore/command/CommandLoader.java | 13 +++---- .../command/defaults/DefaultCommand.java | 16 +++++++++ .../paldiu/simplexcore/math/Cuboid.java | 32 ++++++++++++++--- .../paldiu/simplexcore/plugin/Addon.java | 10 +----- .../simplexcore/plugin/AddonRegistry.java | 2 +- .../paldiu/simplexcore/utils/Constants.java | 36 +++++++++++++++++-- target/classes/plugin.yml | 7 ++++ target/maven-archiver/pom.properties | 5 +++ .../compile/default-compile/createdFiles.lst | 17 +++++++++ .../compile/default-compile/inputFiles.lst | 14 ++++++++ .../default-testCompile/createdFiles.lst | 0 .../default-testCompile/inputFiles.lst | 0 13 files changed, 133 insertions(+), 24 deletions(-) create mode 100644 src/main/java/io/github/paldiu/simplexcore/command/defaults/DefaultCommand.java create mode 100644 target/classes/plugin.yml create mode 100644 target/maven-archiver/pom.properties create mode 100644 target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst create mode 100644 target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst create mode 100644 target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst create mode 100644 target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst diff --git a/src/main/java/io/github/paldiu/simplexcore/SimplexCore.java b/src/main/java/io/github/paldiu/simplexcore/SimplexCore.java index fcda473..e45804e 100644 --- a/src/main/java/io/github/paldiu/simplexcore/SimplexCore.java +++ b/src/main/java/io/github/paldiu/simplexcore/SimplexCore.java @@ -5,8 +5,9 @@ import io.github.paldiu.simplexcore.plugin.Addon; import io.github.paldiu.simplexcore.utils.Constants; public final class SimplexCore extends Addon { - protected SimplexCore(SimplexCore plugin) { - super(plugin); + @Override + public SimplexCore getPlugin() { + return this; } @Override diff --git a/src/main/java/io/github/paldiu/simplexcore/command/CommandLoader.java b/src/main/java/io/github/paldiu/simplexcore/command/CommandLoader.java index 6e5ae59..9da0e92 100644 --- a/src/main/java/io/github/paldiu/simplexcore/command/CommandLoader.java +++ b/src/main/java/io/github/paldiu/simplexcore/command/CommandLoader.java @@ -1,5 +1,6 @@ package io.github.paldiu.simplexcore.command; +import io.github.paldiu.simplexcore.command.defaults.DefaultCommand; import io.github.paldiu.simplexcore.utils.Constants; import org.bukkit.Bukkit; import org.bukkit.command.*; @@ -19,7 +20,7 @@ import java.util.MissingResourceException; public class CommandLoader { private Reflections reflections; - public CommandLoader classpath(Class clazz) { + public synchronized CommandLoader classpath(Class clazz) { if (!clazz.isAnnotationPresent(CommandInfo.class)) { throw new MissingResourceException("Cannot register this class as the main resource location!", clazz.getSimpleName(), "@CommandInfo"); } @@ -32,7 +33,7 @@ public class CommandLoader { return this; } - public void load() { + public synchronized void load() { reflections.getTypesAnnotatedWith(CommandInfo.class).forEach(annotated -> { CommandInfo info = annotated.getDeclaredAnnotation(CommandInfo.class); @@ -52,7 +53,7 @@ public class CommandLoader { }); } - public CommandExecutor getFromSetName(String name) { + public synchronized CommandExecutor getFromSetName(String name) { for (Class obj : reflections.getSubTypesOf(CommandExecutor.class)) { if (!obj.isAnnotationPresent(CommandInfo.class)) { throw new RuntimeException("Missing annotation CommandInfo!"); @@ -65,7 +66,7 @@ public class CommandLoader { Constructor constr = obj.getDeclaredConstructor(); return constr.newInstance(); } catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) { - throw new RuntimeException(e); + return new DefaultCommand(); } } } @@ -73,7 +74,7 @@ public class CommandLoader { } @Nullable - public TabCompleter getTabFromName(String name) { + public synchronized TabCompleter getTabFromName(String name) { for (Class obj : reflections.getSubTypesOf(TabCompleter.class)) { if (!obj.isAnnotationPresent(CommandInfo.class)) { throw new RuntimeException("Missing annotation CommandInfo!"); @@ -85,7 +86,7 @@ public class CommandLoader { Constructor constr = obj.getDeclaredConstructor(); return constr.newInstance(); } catch (NoSuchMethodException | InstantiationException | InvocationTargetException | IllegalAccessException e) { - e.printStackTrace(); + return new DefaultCommand(); } } } diff --git a/src/main/java/io/github/paldiu/simplexcore/command/defaults/DefaultCommand.java b/src/main/java/io/github/paldiu/simplexcore/command/defaults/DefaultCommand.java new file mode 100644 index 0000000..f424ff1 --- /dev/null +++ b/src/main/java/io/github/paldiu/simplexcore/command/defaults/DefaultCommand.java @@ -0,0 +1,16 @@ +package io.github.paldiu.simplexcore.command.defaults; + +import io.github.paldiu.simplexcore.command.CommandBase; +import io.github.paldiu.simplexcore.command.CommandInfo; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.jetbrains.annotations.NotNull; + +@CommandInfo(name = "defaultcommand", usage = "/", description = "Default plugin command.") +public class DefaultCommand extends CommandBase { + @Override + public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { + sender.sendMessage("If you are seeing this when running your command, your command didn't register properly."); + return true; + } +} diff --git a/src/main/java/io/github/paldiu/simplexcore/math/Cuboid.java b/src/main/java/io/github/paldiu/simplexcore/math/Cuboid.java index a80d08f..3af3f5a 100644 --- a/src/main/java/io/github/paldiu/simplexcore/math/Cuboid.java +++ b/src/main/java/io/github/paldiu/simplexcore/math/Cuboid.java @@ -1,6 +1,11 @@ package io.github.paldiu.simplexcore.math; +import io.github.paldiu.simplexcore.utils.Constants; import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.scheduler.BukkitTask; + +import java.util.function.Consumer; public class Cuboid { private final int x, y, z; @@ -19,9 +24,28 @@ public class Cuboid { this(size.getX(), size.getY(), size.getZ()); } - public void generate(Location location) { - int t1 = location.getBlockX(); - int t2 = location.getBlockY(); - int t3 = location.getBlockZ(); + public synchronized void generate(Location location, Material material) { + Consumer task = bukkitTask -> { + int t1 = location.getBlockX(); + int t2 = location.getBlockY(); + int t3 = location.getBlockZ(); + + int a = t1+x; + int b = t2+y; + int c = t3+z; + + while (t1 < a) { + while (t2 < b) { + while (t3 < c) { + t3++; + location.getWorld().getBlockAt(t1, t2, t3).setType(material); + } + t2++; + } + t1++; + } + }; + + Constants.getScheduler().runTaskLaterAsynchronously(Constants.getPlugin(), task, Constants.getTimeValues().SECOND()); } } diff --git a/src/main/java/io/github/paldiu/simplexcore/plugin/Addon.java b/src/main/java/io/github/paldiu/simplexcore/plugin/Addon.java index 2f7969f..e08a636 100644 --- a/src/main/java/io/github/paldiu/simplexcore/plugin/Addon.java +++ b/src/main/java/io/github/paldiu/simplexcore/plugin/Addon.java @@ -3,20 +3,12 @@ package io.github.paldiu.simplexcore.plugin; import org.bukkit.plugin.java.JavaPlugin; public abstract class Addon> extends JavaPlugin { - private final T plugin; - - protected Addon(T plugin) { - this.plugin = plugin; - } - /** * Gets your plugin as an addon. * * @return The addon. */ - public T getPlugin() { - return plugin; - } + public abstract T getPlugin(); @Override public void onLoad() { diff --git a/src/main/java/io/github/paldiu/simplexcore/plugin/AddonRegistry.java b/src/main/java/io/github/paldiu/simplexcore/plugin/AddonRegistry.java index 1b5b20c..15c9a7f 100644 --- a/src/main/java/io/github/paldiu/simplexcore/plugin/AddonRegistry.java +++ b/src/main/java/io/github/paldiu/simplexcore/plugin/AddonRegistry.java @@ -14,7 +14,7 @@ public class AddonRegistry { return instance; } - public > void register(T addon) { + public >void register(T addon) { getComponents().add(addon); } diff --git a/src/main/java/io/github/paldiu/simplexcore/utils/Constants.java b/src/main/java/io/github/paldiu/simplexcore/utils/Constants.java index 9ae154b..10dd905 100644 --- a/src/main/java/io/github/paldiu/simplexcore/utils/Constants.java +++ b/src/main/java/io/github/paldiu/simplexcore/utils/Constants.java @@ -37,11 +37,43 @@ public final class Constants { return scheduler; } - public static AddonRegistry getRegistry() { + public static synchronized AddonRegistry getRegistry() { return AddonRegistry.getInstance(); } - public static CommandLoader getCommandLoader() { + public static synchronized CommandLoader getCommandLoader() { return CommandLoader.getInstance(); } + + public static TimeValues getTimeValues() { + return new TimeValues(); + } + + public static class TimeValues { + public long SECOND() { + return 20L; + } + + public long MINUTE() { + return 1200L; + } + + public long HOUR() { + return 72000L; + } + + public long DAY() { + return 1728000L; + } + + public long MONTH() { + return 51840000L; + } + + public long YEAR() { + return 622080000L; + } + } + } + diff --git a/target/classes/plugin.yml b/target/classes/plugin.yml new file mode 100644 index 0000000..6597f32 --- /dev/null +++ b/target/classes/plugin.yml @@ -0,0 +1,7 @@ +name: SimplexCore +version: 1.0.0-BLEEDING +main: pw.coomer.simplexcore.SimplexCore +api-version: 1.16 +prefix: Simplex +authors: [ Paldiu ] +description: Core for a group of plugins designed to enhance gameplay to the max diff --git a/target/maven-archiver/pom.properties b/target/maven-archiver/pom.properties new file mode 100644 index 0000000..9246faa --- /dev/null +++ b/target/maven-archiver/pom.properties @@ -0,0 +1,5 @@ +#Generated by Maven +#Wed Jan 27 08:29:34 CST 2021 +groupId=io.github.paldiu.simplexcore +artifactId=SimplexCore +version=1.0.0-BLEEDING diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..f23d571 --- /dev/null +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,17 @@ +io\github\paldiu\simplexcore\command\defaults\Command_info.class +io\github\paldiu\simplexcore\command\CommandLoader.class +io\github\paldiu\simplexcore\math\Size.class +io\github\paldiu\simplexcore\command\CommandBase.class +io\github\paldiu\simplexcore\command\CommandInfo.class +io\github\paldiu\simplexcore\plugin\AddonRegistry.class +io\github\paldiu\simplexcore\command\CommandLoader$Registry.class +io\github\paldiu\simplexcore\utils\Constants$TimeValues.class +io\github\paldiu\simplexcore\utils\Bean.class +io\github\paldiu\simplexcore\utils\Constants.class +io\github\paldiu\simplexcore\SimplexCore.class +io\github\paldiu\simplexcore\utils\Trio.class +io\github\paldiu\simplexcore\plugin\AddonManager.class +io\github\paldiu\simplexcore\math\Cuboid.class +io\github\paldiu\simplexcore\plugin\Addon.class +io\github\paldiu\simplexcore\command\defaults\DefaultCommand.class +io\github\paldiu\simplexcore\utils\Utilities.class diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..f737540 --- /dev/null +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,14 @@ +C:\Users\Samantha\IdeaProjects\SimplexCore\src\main\java\io\github\paldiu\simplexcore\utils\Utilities.java +C:\Users\Samantha\IdeaProjects\SimplexCore\src\main\java\io\github\paldiu\simplexcore\command\CommandInfo.java +C:\Users\Samantha\IdeaProjects\SimplexCore\src\main\java\io\github\paldiu\simplexcore\plugin\AddonManager.java +C:\Users\Samantha\IdeaProjects\SimplexCore\src\main\java\io\github\paldiu\simplexcore\math\Size.java +C:\Users\Samantha\IdeaProjects\SimplexCore\src\main\java\io\github\paldiu\simplexcore\utils\Trio.java +C:\Users\Samantha\IdeaProjects\SimplexCore\src\main\java\io\github\paldiu\simplexcore\command\CommandBase.java +C:\Users\Samantha\IdeaProjects\SimplexCore\src\main\java\io\github\paldiu\simplexcore\plugin\Addon.java +C:\Users\Samantha\IdeaProjects\SimplexCore\src\main\java\io\github\paldiu\simplexcore\plugin\AddonRegistry.java +C:\Users\Samantha\IdeaProjects\SimplexCore\src\main\java\io\github\paldiu\simplexcore\utils\Bean.java +C:\Users\Samantha\IdeaProjects\SimplexCore\src\main\java\io\github\paldiu\simplexcore\command\CommandLoader.java +C:\Users\Samantha\IdeaProjects\SimplexCore\src\main\java\io\github\paldiu\simplexcore\command\defaults\Command_info.java +C:\Users\Samantha\IdeaProjects\SimplexCore\src\main\java\io\github\paldiu\simplexcore\SimplexCore.java +C:\Users\Samantha\IdeaProjects\SimplexCore\src\main\java\io\github\paldiu\simplexcore\math\Cuboid.java +C:\Users\Samantha\IdeaProjects\SimplexCore\src\main\java\io\github\paldiu\simplexcore\utils\Constants.java diff --git a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..e69de29