2021-12-29 02:28:50 +00:00
|
|
|
// This claas was created by JaTiTV
|
|
|
|
|
|
|
|
package de.jatitv.opsecurity.config.config;
|
|
|
|
|
|
|
|
import de.jatitv.opsecurity.system.Main;
|
2022-01-06 01:08:20 +00:00
|
|
|
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
|
2021-12-29 02:28:50 +00:00
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.configuration.file.YamlConfiguration;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
public class CreateConfig {
|
|
|
|
|
|
|
|
public static Integer ConfigVersion = 2;
|
|
|
|
|
|
|
|
public static Boolean UpdateCheckOnJoin = true;
|
|
|
|
public static String Prefix = "§8[§2OP§4Security§8] ";
|
|
|
|
public static String language = "english";
|
|
|
|
|
|
|
|
public static Boolean OnlyOPcanUseThePlugin = true;
|
|
|
|
public static Boolean CheckOnJoin = true;
|
|
|
|
public static Boolean CheckOnInteract = true;
|
|
|
|
public static Boolean CheckOnCommand = true;
|
|
|
|
public static Boolean CheckOnChat = true;
|
|
|
|
|
|
|
|
public static String KickCommand = "minecraft:kick [player] [reason]";
|
|
|
|
|
|
|
|
public static Boolean Notify_Warn = true;
|
|
|
|
public static Boolean Notify_Sound_Enable = true;
|
|
|
|
public static String Notify_Sound_1_8 = "NOTE_PIANO";
|
|
|
|
public static String Notify_Sound_1_9_to_1_12 = "BLOCK_NOTE_HARP";
|
|
|
|
public static String Notify_Sound_from_1_13 = "BLOCK_NOTE_BLOCK_HARP";
|
|
|
|
|
|
|
|
public static Boolean Timer_Enable = true;
|
|
|
|
public static int RefreshTime = 60;
|
|
|
|
|
|
|
|
public static Boolean OP_Whitelist_Enable = false;
|
|
|
|
public static Boolean PlayerMustBeOnlineToOp = true;
|
|
|
|
public static String OP_Whitelist_P1 = "player1";
|
|
|
|
public static String OP_Whitelist_P1UUID = "00000000000000000000000000000000";
|
|
|
|
public static String OP_Whitelist_P2 = "player2";
|
|
|
|
public static String OP_Whitelist_P2UUID = "00000000000000000000000000000000";
|
|
|
|
|
|
|
|
public static Boolean no_OP_Player_deop = true;
|
|
|
|
public static Boolean sendPlayerDEOPmsg = true;
|
|
|
|
public static Boolean no_OP_Player_kick = true;
|
|
|
|
public static Boolean customCommand_Enable = false;
|
|
|
|
public static List<String> customKickCommand = Arrays.asList("kick [player] &4You have op but are not authorized to do so, that's why you were kicked!");
|
|
|
|
|
|
|
|
public static Boolean Permission_Whitelist_Enable = false;
|
|
|
|
public static List<String> Permissions = Arrays.asList("*", "opsecurity.admin");
|
|
|
|
public static String Perm_Whitelist_P1 = "player1";
|
|
|
|
public static String Perm_Whitelist_P1UUID = "00000000000000000000000000000000";
|
|
|
|
public static String Perm_Whitelist_P2 = "player2";
|
|
|
|
public static String Perm_Whitelist_P2UUID = "00000000000000000000000000000000";
|
|
|
|
|
|
|
|
public static Boolean PlayerWhithPermission_kick = true;
|
|
|
|
public static Boolean Perm_Command_enable = false;
|
|
|
|
public static List<String> Perm_Command = Arrays.asList("lp user [player] permission unset *", "lp user [player] permission unset opsecurity.admin");
|
|
|
|
|
|
|
|
public static Boolean LP_Enable = false;
|
|
|
|
public static Boolean LP_AllowFromConsole = false;
|
|
|
|
public static List<String> LP_Whitelist = Arrays.asList("player1", "player2");
|
|
|
|
|
|
|
|
public static void configCreate() {
|
|
|
|
Bukkit.getConsoleSender().sendMessage(Prefix + "§4config.yml load...");
|
|
|
|
|
|
|
|
File configYML = new File(Main.plugin.getDataFolder().getPath(), "config.yml");
|
|
|
|
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(configYML);
|
|
|
|
|
|
|
|
yamlConfiguration.set("ConfigVersion", ConfigVersion);
|
|
|
|
|
|
|
|
set("Plugin.UpdateCheckOnJoin", UpdateCheckOnJoin, yamlConfiguration);
|
|
|
|
set("Plugin.language", language, yamlConfiguration);
|
|
|
|
|
|
|
|
set("Plugin.OnlyOPcanUseThePlugin", OnlyOPcanUseThePlugin, yamlConfiguration);
|
|
|
|
set("Check.OnJoin", CheckOnJoin, yamlConfiguration);
|
|
|
|
set("Check.OnInteract", CheckOnInteract, yamlConfiguration);
|
|
|
|
set("Check.OnCommand", CheckOnCommand, yamlConfiguration);
|
|
|
|
set("Check.OnChat", CheckOnChat, yamlConfiguration);
|
|
|
|
set("Check.Timer.Enable", Timer_Enable, yamlConfiguration);
|
|
|
|
set("Check.Timer.RefreshTime_inSec", RefreshTime, yamlConfiguration);
|
|
|
|
|
|
|
|
set("Kick.Command", KickCommand, yamlConfiguration);
|
|
|
|
set("Notify.JoinWarn.Enable", Notify_Warn, yamlConfiguration);
|
|
|
|
set("Notify.Sound.Enable", Notify_Sound_Enable, yamlConfiguration);
|
|
|
|
|
2022-01-06 01:08:20 +00:00
|
|
|
if (MCVersion.minecraft1_8) {
|
2021-12-29 02:28:50 +00:00
|
|
|
set("Notify.Sound.Sound", Notify_Sound_1_8, yamlConfiguration);
|
2022-01-06 01:08:20 +00:00
|
|
|
} else if (MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
|
2021-12-29 02:28:50 +00:00
|
|
|
set("Notify.Sound.Sound", Notify_Sound_1_9_to_1_12, yamlConfiguration);
|
|
|
|
} else set("Notify.Sound.Sound", Notify_Sound_from_1_13, yamlConfiguration);
|
|
|
|
|
|
|
|
set("OP_Whitelist.Enable", OP_Whitelist_Enable, yamlConfiguration);
|
|
|
|
set("OP_Whitelist.PlayerMustBeOnlineToOp", PlayerMustBeOnlineToOp, yamlConfiguration);
|
|
|
|
if (yamlConfiguration.get("OP_Whitelist.Whitelist") == null) {
|
|
|
|
set("OP_Whitelist.Whitelist." + OP_Whitelist_P1 + ".UUID", OP_Whitelist_P1UUID, yamlConfiguration);
|
|
|
|
set("OP_Whitelist.Whitelist." + OP_Whitelist_P2 + ".UUID", OP_Whitelist_P2UUID, yamlConfiguration);
|
|
|
|
}
|
|
|
|
|
|
|
|
set("OP_Whitelist.noOpPlayerDeop.Enable", no_OP_Player_deop, yamlConfiguration);
|
|
|
|
set("OP_Whitelist.noOpPlayerDeop.PlayerSendMessage", sendPlayerDEOPmsg, yamlConfiguration);
|
|
|
|
set("OP_Whitelist.noOpPlayerKick.Enable", no_OP_Player_kick, yamlConfiguration);
|
|
|
|
set("OP_Whitelist.customCommands.Enable", customCommand_Enable, yamlConfiguration);
|
|
|
|
set("OP_Whitelist.customCommands.Commands", customKickCommand, yamlConfiguration);
|
|
|
|
|
|
|
|
set("Permission_Whitelist.Enable", Permission_Whitelist_Enable, yamlConfiguration);
|
|
|
|
set("Permission_Whitelist.Permissions", Permissions, yamlConfiguration);
|
|
|
|
|
|
|
|
if (yamlConfiguration.get("Permission_Whitelist.Whitelist") == null) {
|
|
|
|
set("Permission_Whitelist.Whitelist." + Perm_Whitelist_P1 + ".UUID", Perm_Whitelist_P1UUID, yamlConfiguration);
|
|
|
|
set("Permission_Whitelist.Whitelist." + Perm_Whitelist_P2 + ".UUID", Perm_Whitelist_P2UUID, yamlConfiguration);
|
|
|
|
}
|
|
|
|
|
|
|
|
set("Permission_Whitelist.PlayerWhithPermission_kick", PlayerWhithPermission_kick, yamlConfiguration);
|
|
|
|
set("Permission_Whitelist.customCommands.Enable", Perm_Command_enable, yamlConfiguration);
|
|
|
|
set("Permission_Whitelist.customCommands.Commands", Perm_Command, yamlConfiguration);
|
|
|
|
|
|
|
|
//set("LuckPerms_Whitelist.Enable", LP_Enable, yamlConfiguration);
|
|
|
|
//set("LuckPerms_Whitelist.AllowFromConsole", LP_AllowFromConsole, yamlConfiguration);
|
|
|
|
|
|
|
|
//set("LuckPerms_Whitelist.Whitelist", LP_Whitelist, yamlConfiguration);
|
|
|
|
|
|
|
|
try {
|
|
|
|
yamlConfiguration.save(configYML);
|
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
Bukkit.getConsoleSender().sendMessage(Prefix + "§2Config.yml loaded successfully.");
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void set(String path, String value, YamlConfiguration config) {
|
|
|
|
if (!config.contains(path)) {
|
|
|
|
config.set(path, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void set(String path, Integer value, YamlConfiguration config) {
|
|
|
|
if (!config.contains(path)) {
|
|
|
|
config.set(path, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void set(String path, Double value, YamlConfiguration config) {
|
|
|
|
if (!config.contains(path)) {
|
|
|
|
config.set(path, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void set(String path, Boolean value, YamlConfiguration config) {
|
|
|
|
if (!config.contains(path)) {
|
|
|
|
config.set(path, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void set(String path, List value, YamlConfiguration config) {
|
|
|
|
if (!config.contains(path)) {
|
|
|
|
config.set(path, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|