Minor Update

Can't figure out shading but otherwise just a minor update to how things are handled.
This commit is contained in:
Paldiu 2022-01-30 09:07:27 -06:00
parent ca47c7cea5
commit 1d17d36177
8 changed files with 111 additions and 50 deletions

View File

@ -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",
@ -77,3 +83,58 @@ processResources {
"pluginMain": "${project.properties["pluginMainPackage"]}.${project.properties["pluginMain"]}"
)
}
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)
}
}

View File

@ -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

12
simplexcore.asc Normal file
View File

@ -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-----

View File

@ -11,10 +11,11 @@ import io.github.simplexdev.simplexcore.module.SimplexModule;
public final class SimplexCorePlugin extends SimplexModule<SimplexCorePlugin> {
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<SimplexCorePlugin> {
@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) {

View File

@ -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;

View File

@ -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 {
* </p>
*
* @param clazz The command class to load from
* @return An instance of this where the classpath has been prepared for loading the commands.
*/
public <T extends SimplexCommand> CommandLoader classpath(SimplexModule<?> plugin, Class<T> clazz) {
public <T extends SimplexCommand> void load(SimplexModule<?> plugin, Class<T> 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;
}

View File

@ -49,8 +49,7 @@ public abstract class SimplexModule<T extends SimplexModule<T>> 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<T extends SimplexModule<T>> extends JavaPlug
}
public CommandLoader getCommandLoader() {
return CommandLoader.getInstance();
return new CommandLoader();
}
}

View File

@ -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<BukkitTask> {
* {@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 <T> A subclass of SimplexTask.
*/
public <T extends SimplexTask> 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<BukkitTask> {
* 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 <T> A subclass of SimplexTask.
*/
public <T extends SimplexTask> void register(T task, SimplexModule<?> plugin, boolean delayed) {
public <T extends SimplexTask> void register(T task, boolean delayed) {
register(task, false, delayed);
}
@ -97,10 +98,9 @@ public abstract class SimplexTask implements Consumer<BukkitTask> {
* 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 <T> A subclass of SimplexTask.
*/
public <T extends SimplexTask> void register(T task, SimplexModule<?> plugin) {
public <T extends SimplexTask> void register(T task) {
register(task, false, false);
}