// This claas was created by JaTiTV package de.jatitv.opsecurity.config.config; import de.jatitv.opsecurity.Util; import de.jatitv.opsecurity.objects.PlayerObject; import de.jatitv.opsecurity.system.Main; import de.jatitv.opsecurity.system.Permissions; import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.yamlConfiguration.Config; import org.bukkit.Sound; import org.bukkit.command.CommandSender; import org.bukkit.configuration.file.YamlConfiguration; import java.io.File; import java.util.ArrayList; import java.util.List; public class SelectConfig { // Config public static Integer ConfigVersion; public static Boolean UpdateCheckOnJoin; public static String language; public static Boolean OnlyOPcanUseThePlugin; public static Boolean CheckOnJoin; public static Boolean CheckOnInteract; public static Boolean CheckOnCommand; public static Boolean CheckOnChat; public static String KickCommand; public static Boolean Notify_Warn; public static Boolean Notify_Sound_Enable; public static Sound Notify_Sound; public static String Notify_Sound_input; public static Boolean Timer_Enable; public static int RefreshTime; public static Boolean OP_Whitelist_Enable; public static Boolean PlayerMustBeOnlineToOp; public static Boolean no_OP_Player_deop; public static Boolean sendPlayerDEOPmsg; public static Boolean no_OP_Player_kick; public static Boolean customCommand_Enable; public static List customKickCommand; public static Boolean Permission_Whitelist_Enable; public static List permissions; public static Boolean PlayerWhithPermission_kick; public static Boolean Perm_Command_enable; public static List Perm_Command; public static Boolean LP_Enable; public static Boolean LP_AllowFromConsole; public static List LP_Whitelist; //help public static void Help(CommandSender sender) { if (!sender.hasPermission(Permissions.help)) { sender.sendMessage(Util.getPrefix() + " §cYou do not have permission for OPSecurity! §7<" + Permissions.help + ">"); return; } sender.sendMessage(Util.getPrefix() + " §8----- §2OP§4Security §chelp §8-----"); sender.sendMessage(Util.getPrefix()); sender.sendMessage(Util.getPrefix() + " §8'§b/opsecurity reload§8' §eReload the Plugin."); sender.sendMessage(Util.getPrefix() + " §8'§b/opsecurity help§8' §eOpens this help."); sender.sendMessage(Util.getPrefix() + " §8'§b/opsecurity info§8' §eCall the info about §2OP§4Security§e."); sender.sendMessage(Util.getPrefix()); sender.sendMessage(Util.getPrefix() + " §8----------------------------"); } public static void onSelect() { File configYML = new File(Main.plugin.getDataFolder().getPath(), "config.yml"); YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(configYML); Main.opHashMap.clear(); Main.permissionHashMap.clear(); ConfigVersion = yamlConfiguration.getInt("ConfigVersion"); UpdateCheckOnJoin = yamlConfiguration.getBoolean("Plugin.UpdateCheckOnJoin"); language = yamlConfiguration.getString("Plugin.language"); OnlyOPcanUseThePlugin = yamlConfiguration.getBoolean("Plugin.OnlyOPcanUseThePlugin"); CheckOnJoin = yamlConfiguration.getBoolean("Check.OnJoin"); CheckOnInteract = yamlConfiguration.getBoolean("Check.OnInteract"); CheckOnCommand = yamlConfiguration.getBoolean("Check.OnCommand"); CheckOnChat = yamlConfiguration.getBoolean("Check.OnChat"); Timer_Enable = yamlConfiguration.getBoolean("Check.Timer.Enable"); RefreshTime = yamlConfiguration.getInt("Check.Timer.RefreshTime_inSec"); KickCommand = yamlConfiguration.getString("Kick.Command"); Notify_Warn = yamlConfiguration.getBoolean("Notify.JoinWarn.Enable"); Notify_Sound_Enable = yamlConfiguration.getBoolean("Notify.Sound.Enable"); Notify_Sound_input = yamlConfiguration.getString("Notify.Sound.Sound"); OP_Whitelist_Enable = yamlConfiguration.getBoolean("OP_Whitelist.Enable"); PlayerMustBeOnlineToOp = yamlConfiguration.getBoolean("OP_Whitelist.PlayerMustBeOnlineToOp"); ArrayList opWhitelist = new ArrayList<>(); for (String key : yamlConfiguration.getConfigurationSection("OP_Whitelist.Whitelist").getKeys(false)) { PlayerObject player = new PlayerObject( yamlConfiguration.getString("OP_Whitelist.Whitelist." + key + ".UUID").replace("-", "")); opWhitelist.add(player); Main.opHashMap.put(key.toLowerCase(), player); } no_OP_Player_deop = yamlConfiguration.getBoolean("OP_Whitelist.noOpPlayerDeop.Enable"); sendPlayerDEOPmsg = yamlConfiguration.getBoolean("OP_Whitelist.noOpPlayerDeop.PlayerSendMessage"); no_OP_Player_kick = yamlConfiguration.getBoolean("OP_Whitelist.noOpPlayerKick.Enable"); customCommand_Enable = yamlConfiguration.getBoolean("OP_Whitelist.customCommands.Enable"); customKickCommand = yamlConfiguration.getStringList("OP_Whitelist.customCommands.Commands"); Permission_Whitelist_Enable = yamlConfiguration.getBoolean("Permission_Whitelist.Enable"); permissions = yamlConfiguration.getStringList("Permission_Whitelist.Permissions"); ArrayList permWhitelist = new ArrayList<>(); for (String key : yamlConfiguration.getConfigurationSection("Permission_Whitelist.Whitelist").getKeys(false)) { PlayerObject player = new PlayerObject( yamlConfiguration.getString("Permission_Whitelist.Whitelist." + key + ".UUID").replace("-", "")); permWhitelist.add(player); Main.permissionHashMap.put(key.toLowerCase(), player); } PlayerWhithPermission_kick = yamlConfiguration.getBoolean("Permission_Whitelist.PlayerWhithPermission_kick"); Perm_Command_enable = yamlConfiguration.getBoolean("Permission_Whitelist.customCommands.Enable"); Perm_Command = yamlConfiguration.getStringList("Permission_Whitelist.customCommands.Commands"); LP_Enable = yamlConfiguration.getBoolean("LuckPerms_Whitelist.Enable"); LP_AllowFromConsole = yamlConfiguration.getBoolean("LuckPerms_Whitelist.AllowFromConsole"); LP_Whitelist = yamlConfiguration.getStringList("LuckPerms_Whitelist.Whitelist"); } public static void sound() { Notify_Sound = Config.checkSound(CreateConfig.Notify_Sound_1_8, CreateConfig.Notify_Sound_1_9_to_1_12, CreateConfig.Notify_Sound_from_1_13, Notify_Sound_input, Util.getPrefix()); } }