0

Updated API

API Version 2.0.0

Modules no longer have to keep track of their enabled status, the
ModuleLoader is now responsible for this. This allows for easier module
development and finer control over modules through the loader and the
debugger. More features to follow in a future update.
This commit is contained in:
Pepich
2017-03-02 20:07:44 +01:00
parent b0358d6235
commit ca849074aa
32 changed files with 196 additions and 474 deletions

View File

@@ -22,17 +22,16 @@ import com.redstoner.misc.mysql.elements.MysqlDatabase;
import com.redstoner.misc.mysql.elements.MysqlTable;
import com.redstoner.modules.Module;
@Version(major = 1, minor = 1, revision = 1, compatible = 1)
@Version(major = 2, minor = 0, revision = 0, compatible = 2)
public class WebToken implements Module
{
private boolean enabled = false;
private static final int TOKEN_LENGTH = 6;
private static final String CONSONANTS = "bcdfghjklmnpqrstvwxyz";
private static final String VOWELS = "aeiou";
private MysqlTable table;
@Override
public void onEnable()
public boolean onEnable()
{
Config config;
try
@@ -42,16 +41,14 @@ public class WebToken implements Module
catch (IOException | ParseException e1)
{
e1.printStackTrace();
enabled = false;
return;
return false;
}
if (config == null || !config.containsKey("database") || !config.containsKey("table"))
{
Utils.error("Could not load the WebToken config file, disabling!");
config.put("database", "redstoner");
config.put("table", "webtoken");
enabled = false;
return;
return false;
}
try
{
@@ -61,10 +58,9 @@ public class WebToken implements Module
catch (NullPointerException e)
{
Utils.error("Could not use the WebToken config, disabling!");
enabled = false;
return;
return false;
}
enabled = true;
return true;
}
private String getNextId() throws Exception
@@ -206,15 +202,7 @@ public class WebToken implements Module
@Override
public void onDisable()
{
enabled = false;
}
@Override
public boolean enabled()
{
return enabled;
}
{}
// @noformat
@Override