New Sections

This commit is contained in:
RayzsYT committed 2024-05-19 19:50:30 +02:00
1 parent 68df73ff36
commit 3df43ebe5d
10 files changed
+266 -5

No files matched your search

@@ -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<ConfigStorage> LIST = new ArrayList<>();
public static List<ConfigStorage> 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);
}
}
}
@@ -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<String>(this, "clear", "&aList has been cleared!").getOrSet();
CLEAR_CONFIRM = new ConfigSectionHelper<String>(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<String>(this, "list.message", "&7Listed commands (&f%size%&7)&8: &f%commands%").getOrSet();
LIST_SPLITTER = new ConfigSectionHelper<String>(this, "list.splitter", "&7, ").getOrSet();
LIST_COMMAND = new ConfigSectionHelper<String>(this, "list.command", "&f").getOrSet();
ADD_SUCCESS = new ConfigSectionHelper<String>(this, "add.success", "&aSuccessfully added %command% into the list!").getOrSet();
ADD_FAILED = new ConfigSectionHelper<String>(this, "add.failed", "&c%command% is already in the list!").getOrSet();
REMOVE_SUCCESS = new ConfigSectionHelper<String>(this, "remove.success", "&aSuccessfully removed %command% from the list!").getOrSet();
REMOVE_FAILED = new ConfigSectionHelper<String>(this, "remove.failed", "&c%command% is not listed!").getOrSet();
if(!Reflection.isProxyServer()) return;
CLEAR_SERVER = new ConfigSectionHelper<String>(this, "clear-server", "&aList has been cleared!").getOrSet();
CLEAR_SERVER_CONFIRM = new ConfigSectionHelper<String>(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<String>(this, "list.message-server", "&7Listed commands of %server% (&f%size%&7)&8: &f%commands%").getOrSet();
LIST_SERVER_SPLITTER = new ConfigSectionHelper<String>(this, "list.splitter-server", "&7, ").getOrSet();
LIST_SERVER_COMMAND = new ConfigSectionHelper<String>(this, "list.command-server", "&f").getOrSet();
ADD_SERVER_SUCCESS = new ConfigSectionHelper<String>(this, "add.success-server", "&aSuccessfully added %command% into the list of %server%!").getOrSet();
ADD_SERVER_FAILED = new ConfigSectionHelper<String>(this, "add.failed-server", "&c%command% is already in the list of %server%!").getOrSet();
REMOVE_SERVER_SUCCESS = new ConfigSectionHelper<String>(this, "remove.success-server", "&aSuccessfully removed %command% from the list of %server%!").getOrSet();
REMOVE_SERVER_FAILED = new ConfigSectionHelper<String>(this, "remove.failed-server", "&c%command% is in the list of %server%!").getOrSet();
}
}
@@ -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<String>(this, null, "&cFailed to execute this command! Use \"/pat\" to see all available commands.").getOrSet();
}
}
@@ -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<String>(this, "create", "&aGroup %group% has been created!").getOrSet();
ALREADY_EXIST = new ConfigSectionHelper<String>(this, "already-exist", "&cGroup %group% already exist!").getOrSet();
DOES_NOT_EXIST = new ConfigSectionHelper<String>(this, "does-not-exist", "&cGroup %group% does not exist!").getOrSet();
DELETE = new ConfigSectionHelper<String>(this, "delete", "&cGroup %group% has been deleted!").getOrSet();
DELETE_CONFIRM = new ConfigSectionHelper<String>(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<String>(this, "clear", "&aList of group %group% has been cleared!").getOrSet();
CLEAR_CONFIRM = new ConfigSectionHelper<String>(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<String>(this, "list.message", "&7Listed commands of group %group% (&f%size%&7)&8: &f%commands%").getOrSet();
LIST_SPLITTER = new ConfigSectionHelper<String>(this, "list.splitter", "&7, ").getOrSet();
LIST_COMMAND = new ConfigSectionHelper<String>(this, "list.command", "&f").getOrSet();
LIST_GROUP_MESSAGE = new ConfigSectionHelper<String>(this, "list-groups.message", "&7All groups (&f%size%&7)&8: &f%groups%").getOrSet();
LIST_GROUP_SPLITTER = new ConfigSectionHelper<String>(this, "list-groups.splitter", "&7, ").getOrSet();
LIST_GROUP_GROUPS = new ConfigSectionHelper<String>(this, "list-groups.command", "&f").getOrSet();
ADD_SUCCESS = new ConfigSectionHelper<String>(this, "add.success", "&aSuccessfully added %command% into the list of group %group%!").getOrSet();
ADD_FAILED = new ConfigSectionHelper<String>(this, "add.failed", "&c%command% is already in the list of group %group%!").getOrSet();
REMOVE_SUCCESS = new ConfigSectionHelper<String>(this, "remove.success", "&aSuccessfully removed %command% from the list of group %group%!").getOrSet();
REMOVE_FAILED = new ConfigSectionHelper<String>(this, "remove.failed", "&c%command% is not listed in the group %group%!").getOrSet();
if(!Reflection.isProxyServer()) return;
CREATE_SERVER = new ConfigSectionHelper<String>(this, "create-server", "&aGroup %group% for %server% has been created!").getOrSet();
ALREADY_SERVER_EXIST = new ConfigSectionHelper<String>(this, "already-exist-server", "&cGroup %group% for %server% already exist!").getOrSet();
DOES_NOT_EXIST_SERVER = new ConfigSectionHelper<String>(this, "does-not-exist-server", "&cGroup %group% of %server% does not exist!").getOrSet();
DELETE_SERVER = new ConfigSectionHelper<String>(this, "delete-server", "&cGroup %group% of %server% has been deleted!").getOrSet();
DELETE_SERVER_CONFIRM = new ConfigSectionHelper<String>(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<String>(this, "clear-server", "&aList of group %group% from %server% has been cleared!").getOrSet();
CLEAR_SERVER_CONFIRM = new ConfigSectionHelper<String>(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<String>(this, "list.message-server", "&7Listed commands of group %group% from %server% (&f%size%&7)&8: &f%commands%").getOrSet();
LIST_SERVER_SPLITTER = new ConfigSectionHelper<String>(this, "list.splitter-server", "&7, ").getOrSet();
LIST_SERVER_COMMAND = new ConfigSectionHelper<String>(this, "list.command-server", "&f").getOrSet();
LIST_GROUP_SERVER_MESSAGE = new ConfigSectionHelper<String>(this, "list-groups.message-server", "&7All groups from %server% (&f%size%&7)&8: &f%groups%").getOrSet();
LIST_GROUP_SERVER_SPLITTER = new ConfigSectionHelper<String>(this, "list-groups.splitter-server", "&7, ").getOrSet();
LIST_GROUP_SERVER_GROUPS = new ConfigSectionHelper<String>(this, "list-groups.command-server", "&f").getOrSet();
ADD_SERVER_SUCCESS = new ConfigSectionHelper<String>(this, "add.success-server", "&aSuccessfully added %command% into the list of group %group% for %server%!").getOrSet();
ADD_SERVER_FAILED = new ConfigSectionHelper<String>(this, "add.failed-server", "&c%command% is already in the list of group %group% of %server%!").getOrSet();
REMOVE_SERVER_SUCCESS = new ConfigSectionHelper<String>(this, "remove.success-server", "&aSuccessfully removed %command% from the list of group %group% from %server%!").getOrSet();
REMOVE_SERVER_FAILED = new ConfigSectionHelper<String>(this, "remove.failed-server", "&c%command% is not listed in the group %group% of %server%!").getOrSet();
}
}
@@ -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"
));
}
}
@@ -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<String>(this, null, "&cYou are not allowed to execute this command! Missing permission: &4proantitab.%permission%").getOrSet();
}
}
@@ -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<String>(this, "loading", "&eReloading all configuration files...").getOrSet();
DONE = new ConfigSectionHelper<String>(this, "done", "&aSuccessfully reloaded all configuration files!").getOrSet();
}
}
@@ -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<Boolean>(this, null, false).getOrSet();
}
}
@@ -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
@@ -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();