Add option to disable group adapters

This commit is contained in:
Daniel Saukel 2020-04-01 16:11:36 +02:00
parent b1c884341b
commit 4b222c914b
2 changed files with 26 additions and 2 deletions

View File

@ -535,7 +535,11 @@ public class DungeonsXL extends DREPlugin implements DungeonsAPI {
@Override
public void registerGroupAdapter(GroupAdapter groupAdapter) {
groupAdapters.add(groupAdapter);
if (mainConfig.areGroupAdaptersEnabled()) {
groupAdapters.add(groupAdapter);
} else {
MessageUtil.log(this, "&4The group adapter &6" + groupAdapter.getClass().getName() + " &4was not registered because the feature is disabled.");
}
}
/**

View File

@ -48,10 +48,11 @@ public class MainConfig extends DREConfig {
NEVER
}
public static final int CONFIG_VERSION = 16;
public static final int CONFIG_VERSION = 17;
private String language = "english";
private boolean enableEconomy = false;
private boolean groupAdaptersEnabled = false;
/* Chat */
private boolean chatEnabled = true;
@ -149,6 +150,20 @@ public class MainConfig extends DREConfig {
enableEconomy = enabled;
}
/**
* @return if DungeonsXL should use group adapters
*/
public boolean areGroupAdaptersEnabled() {
return groupAdaptersEnabled;
}
/**
* @param enabled if DungeonsXL should use group adapters
*/
public void setGroupAdaptersEnabled(boolean enabled) {
groupAdaptersEnabled = enabled;
}
/**
* @return if the dungeon chat is enabled
*/
@ -472,6 +487,10 @@ public class MainConfig extends DREConfig {
config.set("enableEconomy", enableEconomy);
}
if (!config.contains("groupAdaptersEnabled")) {
config.set("groupAdaptersEnabled", groupAdaptersEnabled);
}
if (!config.contains("chatEnabled")) {
config.set("chatEnabled", chatEnabled);
}
@ -581,6 +600,7 @@ public class MainConfig extends DREConfig {
language = config.getString("language", language);
plugin.getMessageHandler().setDefaultLanguage(language);
enableEconomy = config.getBoolean("enableEconomy", enableEconomy);
groupAdaptersEnabled = config.getBoolean("groupAdaptersEnabled", groupAdaptersEnabled);
chatEnabled = config.getBoolean("chatEnabled", chatEnabled);
chatFormatEdit = config.getString("chatFormat.edit", chatFormatEdit);
chatFormatGame = config.getString("chatFormat.game", chatFormatGame);