diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolConfig.java b/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolConfig.java index 078262c7..7e771e0b 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolConfig.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolConfig.java @@ -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. + *

+ * 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. diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java b/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java index 772066fb..c62ae46b 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java @@ -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); } diff --git a/ProtocolLib/src/main/resources/config.yml b/ProtocolLib/src/main/resources/config.yml index 8bc3ca2d..15828ee1 100644 --- a/ProtocolLib/src/main/resources/config.yml +++ b/ProtocolLib/src/main/resources/config.yml @@ -9,4 +9,7 @@ global: # Last update time last: 0 - metrics: true \ No newline at end of file + metrics: true + + # Automatically compile structure modifiers + background compiler: true \ No newline at end of file