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:
Norbi Peti 2019-01-30 23:31:20 +01:00
parent a4e96b0ed7
commit ab603276d3
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
7 changed files with 234 additions and 204 deletions

View file

@ -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: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: 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="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: 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: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" /> <orderEntry type="library" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />

View file

@ -167,7 +167,7 @@
<groupId>com.github.TBMCPlugins.ButtonCore</groupId> <groupId>com.github.TBMCPlugins.ButtonCore</groupId>
<artifactId>ButtonProcessor</artifactId> <artifactId>ButtonProcessor</artifactId>
<version>master-SNAPSHOT</version> <version>master-SNAPSHOT</version>
<scope>provided</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.ess3</groupId> <groupId>net.ess3</groupId>

View file

@ -132,6 +132,7 @@ public class MainPlugin extends ButtonPlugin {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { 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 sender.sendMessage("§cThis command isn't available."); //In theory, unregistered commands use this method
return true; return true;
} }

View file

@ -21,8 +21,17 @@ public abstract class ButtonPlugin extends JavaPlugin {
protected abstract void pluginEnable(); protected abstract void pluginEnable();
/**
* Called after the components are unregistered
*/
protected abstract void pluginDisable(); protected abstract void pluginDisable();
/**
* Called before the components are unregistered
*/
protected void pluginPreDisable() {
}
@Override @Override
public final void onEnable() { public final void onEnable() {
var section = super.getConfig().getConfigurationSection("global"); var section = super.getConfig().getConfigurationSection("global");
@ -38,6 +47,7 @@ public abstract class ButtonPlugin extends JavaPlugin {
@Override @Override
public final void onDisable() { public final void onDisable() {
try { try {
pluginPreDisable();
ComponentManager.unregComponents(this); ComponentManager.unregComponents(this);
pluginDisable(); pluginDisable();
saveConfig(); saveConfig();

View file

@ -62,6 +62,18 @@ public class ConfigData<T> { //TODO: Save after a while
if (hmm == null) hmm = def; //Set if the getter returned null if (hmm == null) hmm = def; //Set if the getter returned null
return hmm; 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; return (T) val;
} }

View file

@ -174,12 +174,12 @@ public abstract class Command2 {
} }
private static String[] getHelpText(Method method, String[] ht, String subcommand) { //TODO: helpText[0]="§6---- "+helpText[0]+" ----"; 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) if (str == null)
TBMCCoreAPI.SendException("Error while getting command data!", new Exception("Resource not found!")); TBMCCoreAPI.SendException("Error while getting command data!", new Exception("Resource not found!"));
else { else {
YamlConfiguration yc = YamlConfiguration.loadConfiguration(new InputStreamReader(str)); //Generated by ButtonProcessor 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) { if (ccs != null) {
val cs = ccs.getConfigurationSection(method.getName()); val cs = ccs.getConfigurationSection(method.getName());
if (cs != null) { if (cs != null) {
@ -191,11 +191,11 @@ public abstract class Command2 {
both[ht.length] = "Usage: " + subcommand + " " + params; both[ht.length] = "Usage: " + subcommand + " " + params;
ht = both; ht = both;
} else } 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 } 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 } 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; return ht;
} }

View file

@ -1,6 +1,12 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <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"> 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> <modelVersion>4.0.0</modelVersion>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.yaml</groupId> <groupId>org.yaml</groupId>