T2C-OPSecurity/OpSecurity V2/src/main/java/de/jatitv/opsecurity/config/config/SelectConfig.java

137 lines
6.2 KiB
Java

// 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.t2codelib.SPIGOT.api.yaml.T2Cconfig;
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 notifyWarn;
public static Boolean notifySoundEnable;
public static Sound notifySound;
public static String notifySoundInput;
public static Boolean timerEnable;
public static int refreshTime;
public static Boolean opWhitelistEnable;
public static Boolean playerMustBeOnlineToOp;
public static Boolean noOPPlayerDeop;
public static Boolean sendPlayerDEOPmsg;
public static Boolean noOpPlayerKick;
public static Boolean customCommandEnable;
public static List<String> customKickCommand;
public static Boolean permissionWhitelistEnable;
public static List<String> permissions;
public static Boolean playerWhithPermissionKick;
public static Boolean permCommandEnable;
public static List<String> permCommand;
//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.getPlugin().getDataFolder().getPath(), "config.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(configYML);
Main.getOpHashMap().clear();
Main.getPermissionHashMap().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");
timerEnable = yamlConfiguration.getBoolean("Check.Timer.Enable");
refreshTime = yamlConfiguration.getInt("Check.Timer.RefreshTime_inSec");
kickCommand = yamlConfiguration.getString("Kick.Command");
notifyWarn = yamlConfiguration.getBoolean("Notify.JoinWarn.Enable");
notifySoundEnable = yamlConfiguration.getBoolean("Notify.Sound.Enable");
notifySoundInput = yamlConfiguration.getString("Notify.Sound.Sound");
opWhitelistEnable = yamlConfiguration.getBoolean("OP_Whitelist.Enable");
playerMustBeOnlineToOp = yamlConfiguration.getBoolean("OP_Whitelist.PlayerMustBeOnlineToOp");
ArrayList<PlayerObject> 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.getOpHashMap().put(key.toLowerCase(), player);
}
noOPPlayerDeop = yamlConfiguration.getBoolean("OP_Whitelist.noOpPlayerDeop.Enable");
sendPlayerDEOPmsg = yamlConfiguration.getBoolean("OP_Whitelist.noOpPlayerDeop.PlayerSendMessage");
noOpPlayerKick = yamlConfiguration.getBoolean("OP_Whitelist.noOpPlayerKick.Enable");
customCommandEnable = yamlConfiguration.getBoolean("OP_Whitelist.customCommands.Enable");
customKickCommand = yamlConfiguration.getStringList("OP_Whitelist.customCommands.Commands");
permissionWhitelistEnable = yamlConfiguration.getBoolean("Permission_Whitelist.Enable");
permissions = yamlConfiguration.getStringList("Permission_Whitelist.Permissions");
ArrayList<PlayerObject> 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.getPermissionHashMap().put(key.toLowerCase(), player);
}
playerWhithPermissionKick = yamlConfiguration.getBoolean("Permission_Whitelist.PlayerWhithPermission_kick");
permCommandEnable = yamlConfiguration.getBoolean("Permission_Whitelist.customCommands.Enable");
permCommand = yamlConfiguration.getStringList("Permission_Whitelist.customCommands.Commands");
}
public static void sound() {
notifySound = T2Cconfig.checkSound(CreateConfig.Notify_Sound_1_8, CreateConfig.Notify_Sound_1_9_to_1_12, CreateConfig.Notify_Sound_from_1_13, notifySoundInput, Util.getPrefix());
}
}