Added the ability to enable or disable the background compiler.

This commit is contained in:
Kristian S. Stangeland 2012-11-19 23:44:13 +01:00
parent cdc5740f85
commit d5aa1cde51
3 changed files with 26 additions and 2 deletions

View File

@ -18,6 +18,8 @@ class ProtocolConfig {
private static final String METRICS_ENABLED = "metrics";
private static final String BACKGROUND_COMPILER_ENABLED = "background compiler";
private static final String UPDATER_NOTIFY = "notify";
private static final String UPDATER_DOWNLAD = "download";
private static final String UPDATER_DELAY = "delay";
@ -166,6 +168,25 @@ class ProtocolConfig {
global.set(METRICS_ENABLED, enabled);
}
/**
* Retrieve whether or not the background compiler for structure modifiers is enabled or not.
* @return TRUE if it is enabled, FALSE otherwise.
*/
public boolean isBackgroundCompilerEnabled() {
return global.getBoolean(BACKGROUND_COMPILER_ENABLED, true);
}
/**
* Set whether or not the background compiler for structure modifiers is enabled or not.
* <p>
* This setting will take effect next time ProtocolLib is started.
*
* @param enabled - TRUE if is enabled/running, FALSE otherwise.
*/
public void setBackgroundCompilerEnabled(boolean enabled) {
global.set(BACKGROUND_COMPILER_ENABLED, enabled);
}
/**
* Set the last time we updated, in seconds since 1970.01.01 00:00.
* @param lastTimeSeconds - new last update time.

View File

@ -166,7 +166,7 @@ public class ProtocolLibrary extends JavaPlugin {
return;
// Initialize background compiler
if (backgroundCompiler == null) {
if (backgroundCompiler == null && config.isBackgroundCompilerEnabled()) {
backgroundCompiler = new BackgroundCompiler(getClassLoader());
BackgroundCompiler.setInstance(backgroundCompiler);
}

View File

@ -9,4 +9,7 @@ global:
# Last update time
last: 0
metrics: true
metrics: true
# Automatically compile structure modifiers
background compiler: true