Load JavaScript engine on demand.
Dieser Commit ist enthalten in:
Ursprung
169842f265
Commit
e7954a0f79
@ -220,14 +220,15 @@ public class CommandFilter extends CommandBase {
|
|||||||
|
|
||||||
// Script engine
|
// Script engine
|
||||||
private ScriptEngine engine;
|
private ScriptEngine engine;
|
||||||
|
private boolean uninitialized;
|
||||||
|
|
||||||
public CommandFilter(ErrorReporter reporter, Plugin plugin, ProtocolConfig config) {
|
public CommandFilter(ErrorReporter reporter, Plugin plugin, ProtocolConfig config) {
|
||||||
super(reporter, CommandBase.PERMISSION_ADMIN, NAME, 2);
|
super(reporter, CommandBase.PERMISSION_ADMIN, NAME, 2);
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
|
||||||
// Start the engine
|
// Tell the filter system to initialize the script first chance it gets
|
||||||
initalizeScript();
|
this.uninitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initalizeScript() {
|
private void initalizeScript() {
|
||||||
@ -238,6 +239,8 @@ public class CommandFilter extends CommandBase {
|
|||||||
// Oh for ..
|
// Oh for ..
|
||||||
if (!isInitialized()) {
|
if (!isInitialized()) {
|
||||||
throw new ScriptException("A JavaScript engine could not be found.");
|
throw new ScriptException("A JavaScript engine could not be found.");
|
||||||
|
} else {
|
||||||
|
plugin.getLogger().info("Loaded command filter engine.");
|
||||||
}
|
}
|
||||||
} catch (ScriptException e1) {
|
} catch (ScriptException e1) {
|
||||||
// It's not a huge deal
|
// It's not a huge deal
|
||||||
@ -342,12 +345,25 @@ public class CommandFilter extends CommandBase {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the script engine if necessary.
|
||||||
|
*/
|
||||||
|
private void checkScriptStatus() {
|
||||||
|
// Start the engine
|
||||||
|
if (uninitialized) {
|
||||||
|
uninitialized = false;
|
||||||
|
initalizeScript();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Description: Adds or removes a simple packet filter.
|
* Description: Adds or removes a simple packet filter.
|
||||||
Usage: /<command> add|remove name [packet IDs]
|
Usage: /<command> add|remove name [packet IDs]
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected boolean handleCommand(CommandSender sender, String[] args) {
|
protected boolean handleCommand(CommandSender sender, String[] args) {
|
||||||
|
checkScriptStatus();
|
||||||
|
|
||||||
if (!config.isDebug()) {
|
if (!config.isDebug()) {
|
||||||
sender.sendMessage(ChatColor.RED + "Debug mode must be enabled in the configuration first!");
|
sender.sendMessage(ChatColor.RED + "Debug mode must be enabled in the configuration first!");
|
||||||
return true;
|
return true;
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren