diff --git a/build.gradle b/build.gradle index 4ca1ddd..fed9a78 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,13 @@ plugins { id "java" - id "com.github.johnrengelman.shadow" version "6.1.0" + id "com.github.johnrengelman.shadow" version "7.1.2" + id 'maven-publish' + id 'signing' +} + +java { + withJavadocJar() + withSourcesJar() } version project.properties["pluginVersion"] @@ -28,7 +35,6 @@ dependencies { ].each {s -> compileOnly s } - //compile [ "org.jetbrains:annotations:23.0.0", @@ -76,4 +82,59 @@ processResources { "pluginName": project.properties["pluginName"], "pluginMain": "${project.properties["pluginMainPackage"]}.${project.properties["pluginMain"]}" ) -} \ No newline at end of file +} + +publishing { + publications { + mavenJava(MavenPublication) { + artifactId = 'simplexcore' + from components.java + versionMapping { + usage('java-api') { + fromResolutionOf('runtimeClasspath') + } + usage('java-runtime') { + fromResolutionResult() + } + } + pom { + name = 'SimplexCore' + description = 'An API and Library designed for development of Paper plugins.' + url = 'https://simplexdev.app' + licenses { + license { + name = 'GNU General Public License v2.0' + url = 'https://opensource.org/licenses/gpl-2.0.php' + } + } + developers { + developer { + id = 'simplexdevelopment' + name = 'Simplex Development Group' + } + } + scm { + connection = 'scm:git:git://github.com/simplexdevelopment/simplexcore.git' + developerConnection = 'scm:git:ssh://github.com/simplexdevelopment/simplexcore.git' + url = 'https://github.com/SimplexDevelopment/SimplexCore' + } + } + } + } + repositories { + maven { + // change URLs to point to your repos, e.g. http://my.org/repo + def releasesRepoUrl = layout.buildDirectory.dir('https://s01.oss.sonatype.org/content/repository/releases') + def snapshotsRepoUrl = layout.buildDirectory.dir('https://s01.oss.sonatype.org/content/repository/snapshots') + url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl + } + } +} +signing { + sign publishing.publications.mavenJava +} +javadoc { + if(JavaVersion.current().isJava9Compatible()) { + options.addBooleanOption('html5', true) + } +} diff --git a/gradle.properties b/gradle.properties index 8c8d082..c8befd9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,11 @@ +com.gradle.java.home=C:/Program Files/Java/jdk-16.0.1 + pluginMain=SimplexCorePlugin pluginMainPackage=io.github.simplexdev.simplexcore pluginVersion=1.0.0 pluginName=SimplexCore pluginJarClassifier=Alpha + +signing.keyId=0x961A411C +signing.password=simplex21 +signing.secretKeyRingFile=simplexcore.asc diff --git a/simplexcore.asc b/simplexcore.asc new file mode 100644 index 0000000..770d771 --- /dev/null +++ b/simplexcore.asc @@ -0,0 +1,12 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- +mDMEYdpDBxYJKwYBBAHaRw8BAQdAoGRHsaqmeJEq8ZXIpoCUqCQ0aKbNpLVz0lD4 +yq+UM6i0C3NpbXBsZXhjb3JliJoEExYKAEIWIQT65oQCdo6SdgRjZpTAvpGolhpB +HAUCYdpDBwIbAwUJB4WtmQULCQgHAgMiAgEGFQoJCAsCBBYCAwECHgcCF4AACgkQ +wL6RqJYaQRwLkQD+Kef3rW0gUvCx8jodYo5Dwd3Xeb4EpKoYwWVNy59a4f4A/jbP +elULb4W9X2QY5haAlqGgxZWl3b72rbU2coIruqULuDgEYdpDBxIKKwYBBAGXVQEF +AQEHQC9BgyazC+d+LYmrNdqLiQHWb69HFFB0dlRAM6M8YmAYAwEIB4h+BBgWCgAm +FiEE+uaEAnaOknYEY2aUwL6RqJYaQRwFAmHaQwcCGwwFCQeFrZkACgkQwL6RqJYa +QRxmvgEApZfqXwcuiqv/x0KFykus5ECOSgLrfB9l5f1lMzHPwrAA/RH31VsaKq10 +JSvONawvcpjts3x7qy6+wrkjI25LJmUL +=h40b +-----END PGP PUBLIC KEY BLOCK----- diff --git a/src/main/java/io/github/simplexdev/simplexcore/SimplexCorePlugin.java b/src/main/java/io/github/simplexdev/simplexcore/SimplexCorePlugin.java index 2096708..5f0dcc6 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/SimplexCorePlugin.java +++ b/src/main/java/io/github/simplexdev/simplexcore/SimplexCorePlugin.java @@ -11,10 +11,11 @@ import io.github.simplexdev.simplexcore.module.SimplexModule; public final class SimplexCorePlugin extends SimplexModule { private static boolean debug = false; private static boolean suspended = false; - private static SimplexCorePlugin instance; private Yaml config; private Yaml internals; + private static SimplexCorePlugin instance; + public static SimplexCorePlugin getInstance() { return instance; } @@ -26,16 +27,16 @@ public final class SimplexCorePlugin extends SimplexModule { @Override public void init() { - SimplexCorePlugin.instance = this; - this.config = new YamlFactory(this).setDefaultPathways(); - this.internals = new YamlFactory(this).from("internals.yml", getParentFolder(), "internals.yml"); + instance = getPlugin(); + config = new YamlFactory(this).setDefaultPathways(); + internals = new YamlFactory(this).from("internals.yml", getParentFolder(), "internals.yml"); } @Override public void start() { try { getRegistry().register(this); - getCommandLoader().classpath(this, Command_info.class).load(); + getCommandLoader().load(this, Command_info.class); getYamlConfig().reload(); getInternals().reload(); } catch (Exception ex) { diff --git a/src/main/java/io/github/simplexdev/simplexcore/chat/Messages.java b/src/main/java/io/github/simplexdev/simplexcore/chat/Messages.java index aefb045..b96fff5 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/chat/Messages.java +++ b/src/main/java/io/github/simplexdev/simplexcore/chat/Messages.java @@ -8,7 +8,8 @@ public enum Messages { BAN(Component.text("You have been banned from this server.")), KICK(Component.text("You have been kicked by a moderator.")), AFK_KICK(Component.text("You were kicked to ensure space for active players.")), - PERMBAN(Component.text("You are permanently banned from this server.")); + PERMBAN(Component.text("You are permanently banned from this server.")), + NOT_FROM_CONSOLE(Component.text("This command may only be used in game.")); final Component message; 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 f9b7e40..909ab4d 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/command/CommandLoader.java +++ b/src/main/java/io/github/simplexdev/simplexcore/command/CommandLoader.java @@ -22,18 +22,9 @@ import java.util.MissingResourceException; public final class CommandLoader { private Reflections reflections; - private ClassLoader classLoader; private SimplexModule plugin; - private static final CommandLoader instance = new CommandLoader(); private final Registry registry = new Registry(); - /** - * @return A Singleton Pattern instance of this class. - */ - public static CommandLoader getInstance() { - return instance; - } - /** * Prepares the CommandLoader to load your plugin's commands from its own package location. * All your commands MUST be placed in their own package. @@ -46,9 +37,8 @@ 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 CommandLoader classpath(SimplexModule plugin, Class clazz) { + public void load(SimplexModule plugin, Class clazz) { if (clazz == null) { throw new IllegalArgumentException("The class provided cannot be found!"); } @@ -63,18 +53,9 @@ public final class CommandLoader { this.reflections = ReflectionTools.reflect(clazz); this.plugin = plugin; - this.classLoader = plugin.getClass().getClassLoader(); + ClassLoader classLoader = plugin.getClass().getClassLoader(); - return this; - } - - /** - * Loads all the commands from the specified classpath. - * This should be used immediately after {@link CommandLoader#classpath(SimplexModule, Class)} has been called. - * If used before, an exception will be thrown, and your commands will not be loaded. - */ - public void load() { - if (reflections == null || plugin == null || classLoader == null) { + if (reflections == null || classLoader == null) { throw new CommandLoaderException("Please run CommandLoader#classpath(SimplexModule, Class) first!"); } @@ -86,18 +67,18 @@ public final class CommandLoader { if (info == null) { SimplexCorePlugin.getInstance() .getLogger().warning(annotated.getSimpleName() - + " is missing a required annotation: " - + CommandInfo.class.getSimpleName() - + ". Ignoring."); + + " is missing a required annotation: " + + CommandInfo.class.getSimpleName() + + ". Ignoring."); return; } if (!SimplexCommand.class.isAssignableFrom(annotated)) { SimplexCorePlugin.getInstance() .getLogger().warning(annotated.getSimpleName() - + " does not extend " - + SimplexCommand.class.getSimpleName() - + ". Ignoring."); + + " does not extend " + + SimplexCommand.class.getSimpleName() + + ". Ignoring."); return; } diff --git a/src/main/java/io/github/simplexdev/simplexcore/module/SimplexModule.java b/src/main/java/io/github/simplexdev/simplexcore/module/SimplexModule.java index ce68129..cd998d3 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/module/SimplexModule.java +++ b/src/main/java/io/github/simplexdev/simplexcore/module/SimplexModule.java @@ -49,8 +49,7 @@ public abstract class SimplexModule> extends JavaPlug /** * Plugin initialization logic. */ - public void init() { - } + public void init() {} public PluginManager getManager() { return this.getServer().getPluginManager(); @@ -69,6 +68,6 @@ public abstract class SimplexModule> extends JavaPlug } public CommandLoader getCommandLoader() { - return CommandLoader.getInstance(); + return new CommandLoader(); } } diff --git a/src/main/java/io/github/simplexdev/simplexcore/task/SimplexTask.java b/src/main/java/io/github/simplexdev/simplexcore/task/SimplexTask.java index 108c4ba..5e34efa 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/task/SimplexTask.java +++ b/src/main/java/io/github/simplexdev/simplexcore/task/SimplexTask.java @@ -4,6 +4,7 @@ import io.github.simplexdev.api.func.VoidSupplier; import io.github.simplexdev.simplexcore.SimplexCorePlugin; import io.github.simplexdev.simplexcore.module.SimplexModule; import io.github.simplexdev.simplexcore.utils.TickedTime; +import org.bukkit.plugin.Plugin; import org.bukkit.scheduler.BukkitTask; import java.util.Date; @@ -60,19 +61,20 @@ public abstract class SimplexTask implements Consumer { * {@link org.bukkit.scheduler.BukkitScheduler}. * * @param task The instance of a subclass of this class. - * @param repeating Whether or not the task should repeat. - * @param delayed Whether or not to delay the first time the task runs. + * @param repeating Whether the task should repeat. + * @param delayed Whether to delay the first time the task runs. * @param A subclass of SimplexTask. */ public void register(T task, boolean repeating, boolean delayed) { if (delayed && repeating) { - SimplexCorePlugin.getInstance().getScheduler().runTaskTimer(plugin, task, DELAY, INTERVAL); + setTaskId(SimplexCorePlugin.getInstance().getScheduler().scheduleSyncRepeatingTask(plugin, (Runnable)task, DELAY, INTERVAL)); } else if (delayed) { - SimplexCorePlugin.getInstance().getScheduler().runTaskLater(plugin, task, DELAY); + setTaskId(SimplexCorePlugin.getInstance().getScheduler().scheduleSyncDelayedTask(plugin, (Runnable)task, DELAY)); } else if (repeating) { - SimplexCorePlugin.getInstance().getScheduler().runTaskTimer(plugin, task, 0L, INTERVAL); + setTaskId(SimplexCorePlugin.getInstance().getScheduler().scheduleSyncRepeatingTask(plugin, (Runnable)task, 0L, INTERVAL)); } else { SimplexCorePlugin.getInstance().getScheduler().runTask(plugin, task); + setTaskId(-1); } } @@ -83,11 +85,10 @@ public abstract class SimplexTask implements Consumer { * This version of this method will not create a repeating task.. * * @param task The instance of a subclass of this class. - * @param plugin Your plugin instance. - * @param delayed Whether or not to delay the start of the task. + * @param delayed Whether to delay the start of the task. * @param A subclass of SimplexTask. */ - public void register(T task, SimplexModule plugin, boolean delayed) { + public void register(T task, boolean delayed) { register(task, false, delayed); } @@ -97,10 +98,9 @@ public abstract class SimplexTask implements Consumer { * This version of this method will not create a delayed or repeating task. * * @param task The instance of a subclass of this class. - * @param plugin Your plugin instance. * @param A subclass of SimplexTask. */ - public void register(T task, SimplexModule plugin) { + public void register(T task) { register(task, false, false); }