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 @Override
public void registerGroupAdapter(GroupAdapter groupAdapter) { 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 NEVER
} }
public static final int CONFIG_VERSION = 16; public static final int CONFIG_VERSION = 17;
private String language = "english"; private String language = "english";
private boolean enableEconomy = false; private boolean enableEconomy = false;
private boolean groupAdaptersEnabled = false;
/* Chat */ /* Chat */
private boolean chatEnabled = true; private boolean chatEnabled = true;
@ -149,6 +150,20 @@ public class MainConfig extends DREConfig {
enableEconomy = enabled; 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 * @return if the dungeon chat is enabled
*/ */
@ -472,6 +487,10 @@ public class MainConfig extends DREConfig {
config.set("enableEconomy", enableEconomy); config.set("enableEconomy", enableEconomy);
} }
if (!config.contains("groupAdaptersEnabled")) {
config.set("groupAdaptersEnabled", groupAdaptersEnabled);
}
if (!config.contains("chatEnabled")) { if (!config.contains("chatEnabled")) {
config.set("chatEnabled", chatEnabled); config.set("chatEnabled", chatEnabled);
} }
@ -581,6 +600,7 @@ public class MainConfig extends DREConfig {
language = config.getString("language", language); language = config.getString("language", language);
plugin.getMessageHandler().setDefaultLanguage(language); plugin.getMessageHandler().setDefaultLanguage(language);
enableEconomy = config.getBoolean("enableEconomy", enableEconomy); enableEconomy = config.getBoolean("enableEconomy", enableEconomy);
groupAdaptersEnabled = config.getBoolean("groupAdaptersEnabled", groupAdaptersEnabled);
chatEnabled = config.getBoolean("chatEnabled", chatEnabled); chatEnabled = config.getBoolean("chatEnabled", chatEnabled);
chatFormatEdit = config.getString("chatFormat.edit", chatFormatEdit); chatFormatEdit = config.getString("chatFormat.edit", chatFormatEdit);
chatFormatGame = config.getString("chatFormat.game", chatFormatGame); chatFormatGame = config.getString("chatFormat.game", chatFormatGame);