diff --git a/src/main/java/de/rayzs/pat/api/storage/Storage.java b/src/main/java/de/rayzs/pat/api/storage/Storage.java index 89f93023..e8d82d18 100644 --- a/src/main/java/de/rayzs/pat/api/storage/Storage.java +++ b/src/main/java/de/rayzs/pat/api/storage/Storage.java @@ -2,8 +2,7 @@ package de.rayzs.pat.api.storage; import de.rayzs.pat.api.storage.blacklist.BlacklistCreator; import de.rayzs.pat.api.storage.blacklist.impl.GeneralBlacklist; -import de.rayzs.pat.api.storage.config.messages.OnlyForProxySection; -import de.rayzs.pat.api.storage.config.messages.StatsSection; +import de.rayzs.pat.api.storage.config.messages.*; import de.rayzs.pat.api.storage.config.settings.*; import de.rayzs.pat.api.storage.templates.ConfigStorage; import de.rayzs.pat.utils.configuration.ConfigurationBuilder; @@ -25,20 +24,29 @@ public class Storage { public static class ConfigSections { - public static List LIST = new ArrayList<>(); + public static List SECTIONS = new ArrayList<>(); public static class Messages { + + public static BlacklistSection BLACKLIST = new BlacklistSection(); + public static CommandFailedSection COMMAND_FAILED = new CommandFailedSection(); + public static GroupSection GROUP = new GroupSection(); + public static HelpSection HELP = new HelpSection(); + public static NoPermissionSection NO_PERMISSION = new NoPermissionSection(); public static OnlyForProxySection NO_PROXY = new OnlyForProxySection(); + public static ReloadSection RELOAD = new ReloadSection(); public static StatsSection STATS_SECTION = new StatsSection(); public static void initialize() {} } public static class Settings { + public static CancelCommandSection CANCEL_COMMAND = new CancelCommandSection(); public static CustomBrandSection CUSTOM_BRAND = new CustomBrandSection(); public static CustomPluginsSection CUSTOM_PLUGIN = new CustomPluginsSection(); public static CustomUnknownCommandSection CUSTOM_UNKNOWN_COMMAND = new CustomUnknownCommandSection(); + public static TurnBlacklistToWhitelistSection TURN_BLACKLIST_TO_WHITELIST = new TurnBlacklistToWhitelistSection(); public static UpdateSection UPDATE = new UpdateSection(); public static void initialize() {} @@ -48,7 +56,7 @@ public class Storage { Messages.initialize(); Settings.initialize(); - LIST.forEach(ConfigStorage::load); + SECTIONS.forEach(ConfigStorage::load); } } } diff --git a/src/main/java/de/rayzs/pat/api/storage/config/messages/BlacklistSection.java b/src/main/java/de/rayzs/pat/api/storage/config/messages/BlacklistSection.java new file mode 100644 index 00000000..8991a7ef --- /dev/null +++ b/src/main/java/de/rayzs/pat/api/storage/config/messages/BlacklistSection.java @@ -0,0 +1,52 @@ +package de.rayzs.pat.api.storage.config.messages; + +import de.rayzs.pat.api.storage.templates.ConfigStorage; +import de.rayzs.pat.utils.Reflection; +import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper; + +public class BlacklistSection extends ConfigStorage { + + public String CLEAR, CLEAR_CONFIRM, CLEAR_SERVER, CLEAR_SERVER_CONFIRM; + public String LIST_MESSAGE, LIST_SPLITTER, LIST_COMMAND, LIST_SERVER_MESSAGE, LIST_SERVER_SPLITTER, LIST_SERVER_COMMAND; + + public String ADD_SUCCESS, ADD_FAILED; + public String REMOVE_SUCCESS, REMOVE_FAILED; + + public String ADD_SERVER_SUCCESS, ADD_SERVER_FAILED; + public String REMOVE_SERVER_SUCCESS, REMOVE_SERVER_FAILED; + + public BlacklistSection() { + super("blacklist"); + } + + @Override + public void load() { + super.load(); + CLEAR = new ConfigSectionHelper(this, "clear", "&aList has been cleared!").getOrSet(); + CLEAR_CONFIRM = new ConfigSectionHelper(this, "clear-confirmation", "&4Warning! &7This command will &cclear the entire list&7! &7Repeat the &esame command &7to confirm this action.").getOrSet(); + + LIST_MESSAGE = new ConfigSectionHelper(this, "list.message", "&7Listed commands (&f%size%&7)&8: &f%commands%").getOrSet(); + LIST_SPLITTER = new ConfigSectionHelper(this, "list.splitter", "&7, ").getOrSet(); + LIST_COMMAND = new ConfigSectionHelper(this, "list.command", "&f").getOrSet(); + + ADD_SUCCESS = new ConfigSectionHelper(this, "add.success", "&aSuccessfully added %command% into the list!").getOrSet(); + ADD_FAILED = new ConfigSectionHelper(this, "add.failed", "&c%command% is already in the list!").getOrSet(); + + REMOVE_SUCCESS = new ConfigSectionHelper(this, "remove.success", "&aSuccessfully removed %command% from the list!").getOrSet(); + REMOVE_FAILED = new ConfigSectionHelper(this, "remove.failed", "&c%command% is not listed!").getOrSet(); + if(!Reflection.isProxyServer()) return; + + CLEAR_SERVER = new ConfigSectionHelper(this, "clear-server", "&aList has been cleared!").getOrSet(); + CLEAR_SERVER_CONFIRM = new ConfigSectionHelper(this, "clear-confirmation-server", "&4Warning! &7This command will &cclear the entire list of this server&7! &7Repeat the &esame command &7to confirm this action.").getOrSet(); + + LIST_SERVER_MESSAGE = new ConfigSectionHelper(this, "list.message-server", "&7Listed commands of %server% (&f%size%&7)&8: &f%commands%").getOrSet(); + LIST_SERVER_SPLITTER = new ConfigSectionHelper(this, "list.splitter-server", "&7, ").getOrSet(); + LIST_SERVER_COMMAND = new ConfigSectionHelper(this, "list.command-server", "&f").getOrSet(); + + ADD_SERVER_SUCCESS = new ConfigSectionHelper(this, "add.success-server", "&aSuccessfully added %command% into the list of %server%!").getOrSet(); + ADD_SERVER_FAILED = new ConfigSectionHelper(this, "add.failed-server", "&c%command% is already in the list of %server%!").getOrSet(); + + REMOVE_SERVER_SUCCESS = new ConfigSectionHelper(this, "remove.success-server", "&aSuccessfully removed %command% from the list of %server%!").getOrSet(); + REMOVE_SERVER_FAILED = new ConfigSectionHelper(this, "remove.failed-server", "&c%command% is in the list of %server%!").getOrSet(); + } +} diff --git a/src/main/java/de/rayzs/pat/api/storage/config/messages/CommandFailedSection.java b/src/main/java/de/rayzs/pat/api/storage/config/messages/CommandFailedSection.java new file mode 100644 index 00000000..ae7167d6 --- /dev/null +++ b/src/main/java/de/rayzs/pat/api/storage/config/messages/CommandFailedSection.java @@ -0,0 +1,19 @@ +package de.rayzs.pat.api.storage.config.messages; + +import de.rayzs.pat.api.storage.templates.ConfigStorage; +import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper; + +public class CommandFailedSection extends ConfigStorage { + + public String MESSAGE; + + public CommandFailedSection() { + super("command-failed"); + } + + @Override + public void load() { + super.load(); + MESSAGE = new ConfigSectionHelper(this, null, "&cFailed to execute this command! Use \"/pat\" to see all available commands.").getOrSet(); + } +} diff --git a/src/main/java/de/rayzs/pat/api/storage/config/messages/GroupSection.java b/src/main/java/de/rayzs/pat/api/storage/config/messages/GroupSection.java new file mode 100644 index 00000000..71694f56 --- /dev/null +++ b/src/main/java/de/rayzs/pat/api/storage/config/messages/GroupSection.java @@ -0,0 +1,77 @@ +package de.rayzs.pat.api.storage.config.messages; + +import de.rayzs.pat.api.storage.templates.ConfigStorage; +import de.rayzs.pat.utils.Reflection; +import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper; + +public class GroupSection extends ConfigStorage { + + public String CREATE, ALREADY_EXIST, DOES_NOT_EXIST, DELETE, DELETE_CONFIRM, CREATE_SERVER, ALREADY_SERVER_EXIST, DOES_NOT_EXIST_SERVER, DELETE_SERVER, DELETE_SERVER_CONFIRM; + public String CLEAR, CLEAR_CONFIRM, CLEAR_SERVER, CLEAR_SERVER_CONFIRM; + + public String LIST_MESSAGE, LIST_SPLITTER, LIST_COMMAND, LIST_SERVER_MESSAGE, LIST_SERVER_SPLITTER, LIST_SERVER_COMMAND; + public String LIST_GROUP_MESSAGE, LIST_GROUP_SPLITTER, LIST_GROUP_GROUPS, LIST_GROUP_SERVER_MESSAGE, LIST_GROUP_SERVER_SPLITTER, LIST_GROUP_SERVER_GROUPS; + + public String ADD_SUCCESS, ADD_FAILED; + public String REMOVE_SUCCESS, REMOVE_FAILED; + + public String ADD_SERVER_SUCCESS, ADD_SERVER_FAILED; + public String REMOVE_SERVER_SUCCESS, REMOVE_SERVER_FAILED; + + public GroupSection() { + super("group"); + } + + @Override + public void load() { + super.load(); + + CREATE = new ConfigSectionHelper(this, "create", "&aGroup %group% has been created!").getOrSet(); + ALREADY_EXIST = new ConfigSectionHelper(this, "already-exist", "&cGroup %group% already exist!").getOrSet(); + DOES_NOT_EXIST = new ConfigSectionHelper(this, "does-not-exist", "&cGroup %group% does not exist!").getOrSet(); + DELETE = new ConfigSectionHelper(this, "delete", "&cGroup %group% has been deleted!").getOrSet(); + DELETE_CONFIRM = new ConfigSectionHelper(this, "delete-confirmation", "&4Warning! &7This command will &cdelete the group with the whole list&7 of this group! &7Repeat the &esame command &7to confirm this action.").getOrSet(); + + CLEAR = new ConfigSectionHelper(this, "clear", "&aList of group %group% has been cleared!").getOrSet(); + CLEAR_CONFIRM = new ConfigSectionHelper(this, "clear-confirmation", "&4Warning! &7This command will &cclear the entire list&7 of this group! &7Repeat the &esame command &7to confirm this action.").getOrSet(); + + LIST_MESSAGE = new ConfigSectionHelper(this, "list.message", "&7Listed commands of group %group% (&f%size%&7)&8: &f%commands%").getOrSet(); + LIST_SPLITTER = new ConfigSectionHelper(this, "list.splitter", "&7, ").getOrSet(); + LIST_COMMAND = new ConfigSectionHelper(this, "list.command", "&f").getOrSet(); + + LIST_GROUP_MESSAGE = new ConfigSectionHelper(this, "list-groups.message", "&7All groups (&f%size%&7)&8: &f%groups%").getOrSet(); + LIST_GROUP_SPLITTER = new ConfigSectionHelper(this, "list-groups.splitter", "&7, ").getOrSet(); + LIST_GROUP_GROUPS = new ConfigSectionHelper(this, "list-groups.command", "&f").getOrSet(); + + ADD_SUCCESS = new ConfigSectionHelper(this, "add.success", "&aSuccessfully added %command% into the list of group %group%!").getOrSet(); + ADD_FAILED = new ConfigSectionHelper(this, "add.failed", "&c%command% is already in the list of group %group%!").getOrSet(); + + REMOVE_SUCCESS = new ConfigSectionHelper(this, "remove.success", "&aSuccessfully removed %command% from the list of group %group%!").getOrSet(); + REMOVE_FAILED = new ConfigSectionHelper(this, "remove.failed", "&c%command% is not listed in the group %group%!").getOrSet(); + if(!Reflection.isProxyServer()) return; + + CREATE_SERVER = new ConfigSectionHelper(this, "create-server", "&aGroup %group% for %server% has been created!").getOrSet(); + ALREADY_SERVER_EXIST = new ConfigSectionHelper(this, "already-exist-server", "&cGroup %group% for %server% already exist!").getOrSet(); + DOES_NOT_EXIST_SERVER = new ConfigSectionHelper(this, "does-not-exist-server", "&cGroup %group% of %server% does not exist!").getOrSet(); + DELETE_SERVER = new ConfigSectionHelper(this, "delete-server", "&cGroup %group% of %server% has been deleted!").getOrSet(); + DELETE_SERVER_CONFIRM = new ConfigSectionHelper(this, "delete-confirmation-server", "&4Warning! &7This command will &cdelete the group of the server %server% with the whole list&7 of this group! &7Repeat the &esame command &7to confirm this action.").getOrSet(); + + CLEAR_SERVER = new ConfigSectionHelper(this, "clear-server", "&aList of group %group% from %server% has been cleared!").getOrSet(); + CLEAR_SERVER_CONFIRM = new ConfigSectionHelper(this, "clear-confirmation-server", "&4Warning! &7This command will &cclear the entire list&7 of this group for %server%! &7Repeat the &esame command &7to confirm this action.").getOrSet(); + + LIST_SERVER_MESSAGE = new ConfigSectionHelper(this, "list.message-server", "&7Listed commands of group %group% from %server% (&f%size%&7)&8: &f%commands%").getOrSet(); + LIST_SERVER_SPLITTER = new ConfigSectionHelper(this, "list.splitter-server", "&7, ").getOrSet(); + LIST_SERVER_COMMAND = new ConfigSectionHelper(this, "list.command-server", "&f").getOrSet(); + + LIST_GROUP_SERVER_MESSAGE = new ConfigSectionHelper(this, "list-groups.message-server", "&7All groups from %server% (&f%size%&7)&8: &f%groups%").getOrSet(); + LIST_GROUP_SERVER_SPLITTER = new ConfigSectionHelper(this, "list-groups.splitter-server", "&7, ").getOrSet(); + LIST_GROUP_SERVER_GROUPS = new ConfigSectionHelper(this, "list-groups.command-server", "&f").getOrSet(); + + ADD_SERVER_SUCCESS = new ConfigSectionHelper(this, "add.success-server", "&aSuccessfully added %command% into the list of group %group% for %server%!").getOrSet(); + ADD_SERVER_FAILED = new ConfigSectionHelper(this, "add.failed-server", "&c%command% is already in the list of group %group% of %server%!").getOrSet(); + + REMOVE_SERVER_SUCCESS = new ConfigSectionHelper(this, "remove.success-server", "&aSuccessfully removed %command% from the list of group %group% from %server%!").getOrSet(); + REMOVE_SERVER_FAILED = new ConfigSectionHelper(this, "remove.failed-server", "&c%command% is not listed in the group %group% of %server%!").getOrSet(); + + } +} diff --git a/src/main/java/de/rayzs/pat/api/storage/config/messages/HelpSection.java b/src/main/java/de/rayzs/pat/api/storage/config/messages/HelpSection.java new file mode 100644 index 00000000..6e1ea7e4 --- /dev/null +++ b/src/main/java/de/rayzs/pat/api/storage/config/messages/HelpSection.java @@ -0,0 +1,46 @@ +package de.rayzs.pat.api.storage.config.messages; + +import de.rayzs.pat.api.storage.templates.ConfigStorage; +import de.rayzs.pat.utils.Reflection; +import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper; +import de.rayzs.pat.utils.configuration.helper.MultipleMessagesHelper; + +import java.util.Arrays; + +public class HelpSection extends ConfigStorage { + + public MultipleMessagesHelper MESSAGE; + + public HelpSection() { + super("help"); + } + + @Override + public void load() { + super.load(); + MESSAGE = new MultipleMessagesHelper(this, null, Reflection.isProxyServer() ? + Arrays.asList( + "&7Available commands are: &f/%label%&7..." + , "&f reload &7to reload the plugin" + , "&f stats &7view when data has been synced" + , "&f notify &7to get alerted" + , "&f listgroups &7List all groups" + , "&f creategroup (group) &7Create a group" + , "&f deletegroup (group) &7Delete a group" + , "&f list &8(optional: group) &7to see all listed commands" + , "&f clear &8(optional: group) &7to clear the list" + , "&f add/remove (command) &8(optional: group) &7to manage the list") + : + Arrays.asList( + "&7Available commands are: &f/%label%&7..." + , "&f reload &7to reload the plugin" + , "&f notify &7to get alerted" + , "&f listgroups &7List all groups" + , "&f creategroup (group) &7Create a group" + , "&f deletegroup (group) &7Delete a group" + , "&f list &8(optional: group) &7to see all listed commands" + , "&f clear &8(optional: group) &7to clear the list" + , "&f add/remove (command) &8(optional: group) &7to manage the list" + )); + } +} diff --git a/src/main/java/de/rayzs/pat/api/storage/config/messages/NoPermissionSection.java b/src/main/java/de/rayzs/pat/api/storage/config/messages/NoPermissionSection.java new file mode 100644 index 00000000..d5782edd --- /dev/null +++ b/src/main/java/de/rayzs/pat/api/storage/config/messages/NoPermissionSection.java @@ -0,0 +1,19 @@ +package de.rayzs.pat.api.storage.config.messages; + +import de.rayzs.pat.api.storage.templates.ConfigStorage; +import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper; + +public class NoPermissionSection extends ConfigStorage { + + public String MESSAGE; + + public NoPermissionSection() { + super("no-permissions"); + } + + @Override + public void load() { + super.load(); + MESSAGE = new ConfigSectionHelper(this, null, "&cYou are not allowed to execute this command! Missing permission: &4proantitab.%permission%").getOrSet(); + } +} diff --git a/src/main/java/de/rayzs/pat/api/storage/config/messages/ReloadSection.java b/src/main/java/de/rayzs/pat/api/storage/config/messages/ReloadSection.java new file mode 100644 index 00000000..f65cf0a0 --- /dev/null +++ b/src/main/java/de/rayzs/pat/api/storage/config/messages/ReloadSection.java @@ -0,0 +1,20 @@ +package de.rayzs.pat.api.storage.config.messages; + +import de.rayzs.pat.api.storage.templates.ConfigStorage; +import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper; + +public class ReloadSection extends ConfigStorage { + + public String LOADING, DONE; + + public ReloadSection() { + super("reload"); + } + + @Override + public void load() { + super.load(); + LOADING = new ConfigSectionHelper(this, "loading", "&eReloading all configuration files...").getOrSet(); + DONE = new ConfigSectionHelper(this, "done", "&aSuccessfully reloaded all configuration files!").getOrSet(); + } +} diff --git a/src/main/java/de/rayzs/pat/api/storage/config/settings/TurnBlacklistToWhitelistSection.java b/src/main/java/de/rayzs/pat/api/storage/config/settings/TurnBlacklistToWhitelistSection.java new file mode 100644 index 00000000..d7162def --- /dev/null +++ b/src/main/java/de/rayzs/pat/api/storage/config/settings/TurnBlacklistToWhitelistSection.java @@ -0,0 +1,19 @@ +package de.rayzs.pat.api.storage.config.settings; + +import de.rayzs.pat.api.storage.templates.ConfigStorage; +import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper; + +public class TurnBlacklistToWhitelistSection extends ConfigStorage { + + public boolean ENABLED; + + public TurnBlacklistToWhitelistSection() { + super("turn-blacklist-to-whitelist"); + } + + @Override + public void load() { + super.load(); + ENABLED = new ConfigSectionHelper(this, null, false).getOrSet(); + } +} diff --git a/src/main/java/de/rayzs/pat/api/storage/templates/ConfigStorage.java b/src/main/java/de/rayzs/pat/api/storage/templates/ConfigStorage.java index 842cbc82..9a1615ed 100644 --- a/src/main/java/de/rayzs/pat/api/storage/templates/ConfigStorage.java +++ b/src/main/java/de/rayzs/pat/api/storage/templates/ConfigStorage.java @@ -7,7 +7,7 @@ public class ConfigStorage extends StorageTemplate { public ConfigStorage(String navigatePath) { super(Storage.Files.CONFIGURATION, navigatePath); - Storage.ConfigSections.LIST.add(this); + Storage.ConfigSections.SECTIONS.add(this); } @Override diff --git a/src/main/java/de/rayzs/pat/plugin/BungeeLoader.java b/src/main/java/de/rayzs/pat/plugin/BungeeLoader.java index f9557a82..eee4ff25 100644 --- a/src/main/java/de/rayzs/pat/plugin/BungeeLoader.java +++ b/src/main/java/de/rayzs/pat/plugin/BungeeLoader.java @@ -39,6 +39,7 @@ public class BungeeLoader extends Plugin { Storage.CURRENT_VERSION_NAME = getDescription().getVersion(); Storage.load(true); + de.rayzs.pat.api.storage.Storage.ConfigSections.loadAll(); MessageTranslator.initialize(); CustomServerBrand.initialize(); GroupManager.initialize();