Fixes, another plugin disable event
Fixed/implemented number handling in config Fixed help text error Fixed annotation processing in other plugins Fixed error message on console chat Fixed CI building (hopefully) - Spigot repo
This commit is contained in:
parent
a4e96b0ed7
commit
ab603276d3
7 changed files with 234 additions and 204 deletions
|
@ -20,6 +20,7 @@
|
|||
<orderEntry type="library" scope="RUNTIME" name="Maven: net.bytebuddy:byte-buddy:1.6.11" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Maven: net.bytebuddy:byte-buddy-agent:1.6.11" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Maven: org.objenesis:objenesis:2.5" level="project" />
|
||||
<orderEntry type="module" module-name="ButtonProcessor" />
|
||||
<orderEntry type="library" name="Maven: org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
|
||||
|
|
|
@ -167,7 +167,7 @@
|
|||
<groupId>com.github.TBMCPlugins.ButtonCore</groupId>
|
||||
<artifactId>ButtonProcessor</artifactId>
|
||||
<version>master-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ess3</groupId>
|
||||
|
|
|
@ -132,6 +132,7 @@ public class MainPlugin extends ButtonPlugin {
|
|||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (command.getName().equals("dontrunthiscmd")) return true; //Used in chat preprocess for console
|
||||
sender.sendMessage("§cThis command isn't available."); //In theory, unregistered commands use this method
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -21,8 +21,17 @@ public abstract class ButtonPlugin extends JavaPlugin {
|
|||
|
||||
protected abstract void pluginEnable();
|
||||
|
||||
/**
|
||||
* Called after the components are unregistered
|
||||
*/
|
||||
protected abstract void pluginDisable();
|
||||
|
||||
/**
|
||||
* Called before the components are unregistered
|
||||
*/
|
||||
protected void pluginPreDisable() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onEnable() {
|
||||
var section = super.getConfig().getConfigurationSection("global");
|
||||
|
@ -38,6 +47,7 @@ public abstract class ButtonPlugin extends JavaPlugin {
|
|||
@Override
|
||||
public final void onDisable() {
|
||||
try {
|
||||
pluginPreDisable();
|
||||
ComponentManager.unregComponents(this);
|
||||
pluginDisable();
|
||||
saveConfig();
|
||||
|
|
|
@ -62,6 +62,18 @@ public class ConfigData<T> { //TODO: Save after a while
|
|||
if (hmm == null) hmm = def; //Set if the getter returned null
|
||||
return hmm;
|
||||
}
|
||||
if (val instanceof Number) {
|
||||
if (def instanceof Long)
|
||||
val = ((Number) val).longValue();
|
||||
else if (def instanceof Short)
|
||||
val = ((Number) val).shortValue();
|
||||
else if (def instanceof Byte)
|
||||
val = ((Number) val).byteValue();
|
||||
else if (def instanceof Float)
|
||||
val = ((Number) val).floatValue();
|
||||
else if (def instanceof Double)
|
||||
val = ((Number) val).doubleValue();
|
||||
}
|
||||
return (T) val;
|
||||
}
|
||||
|
||||
|
|
|
@ -174,12 +174,12 @@ public abstract class Command2 {
|
|||
}
|
||||
|
||||
private static String[] getHelpText(Method method, String[] ht, String subcommand) { //TODO: helpText[0]="§6---- "+helpText[0]+" ----";
|
||||
val str = Command2.class.getResourceAsStream("/commands.yml");
|
||||
val str = method.getDeclaringClass().getResourceAsStream("/commands.yml");
|
||||
if (str == null)
|
||||
TBMCCoreAPI.SendException("Error while getting command data!", new Exception("Resource not found!"));
|
||||
else {
|
||||
YamlConfiguration yc = YamlConfiguration.loadConfiguration(new InputStreamReader(str)); //Generated by ButtonProcessor
|
||||
val ccs = yc.getConfigurationSection(method.getDeclaringClass().getName());
|
||||
val ccs = yc.getConfigurationSection(method.getDeclaringClass().getCanonicalName());
|
||||
if (ccs != null) {
|
||||
val cs = ccs.getConfigurationSection(method.getName());
|
||||
if (cs != null) {
|
||||
|
@ -191,11 +191,11 @@ public abstract class Command2 {
|
|||
both[ht.length] = "Usage: " + subcommand + " " + params;
|
||||
ht = both;
|
||||
} else
|
||||
TBMCCoreAPI.SendException("Error while getting command data!", new Exception("Method '" + method.toString() + "' != " + mname + " or params is " + params));
|
||||
TBMCCoreAPI.SendException("Error while getting command data for " + method + "!", new Exception("Method '" + method.toString() + "' != " + mname + " or params is " + params));
|
||||
} else
|
||||
TBMCCoreAPI.SendException("Error while getting command data!", new Exception("cs is " + cs));
|
||||
TBMCCoreAPI.SendException("Error while getting command data for " + method + "!", new Exception("cs is " + cs));
|
||||
} else
|
||||
TBMCCoreAPI.SendException("Error while getting command data!", new Exception("ccs is " + ccs));
|
||||
TBMCCoreAPI.SendException("Error while getting command data for " + method + "!", new Exception("ccs is " + ccs + " - class: " + method.getDeclaringClass().getCanonicalName()));
|
||||
}
|
||||
return ht;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.yaml</groupId>
|
||||
|
|
Loading…
Reference in a new issue