Config build change to new ConfigBuilder
This commit is contained in:
parent
c89430b219
commit
35ac13b695
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>net.t2code</groupId>
|
||||
<artifactId>T2C-OPSecurity</artifactId>
|
||||
<version>3.2</version>
|
||||
<version>3.3_DEV-1</version>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@ -83,7 +83,8 @@
|
||||
<dependency>
|
||||
<groupId>net.t2code</groupId>
|
||||
<artifactId>T2CodeLib</artifactId>
|
||||
<version>16.4</version>
|
||||
<version>16.7</version>
|
||||
<classifier>dev-3</classifier>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
|
||||
|
@ -15,18 +15,18 @@ import java.util.Map;
|
||||
|
||||
public class T2COpSecAPI {
|
||||
public static boolean checkOPWhiteList(Player player) {
|
||||
if (!OPWhitelist.enable.valueBoolean) return true;
|
||||
if (!(boolean) OPWhitelist.VALUES.enable.getValue()) return true;
|
||||
String debug = T2Cdebug.debugCode();
|
||||
return OpCheck.opWhitelist(player,debug);
|
||||
return OpCheck.opWhitelist(player, debug);
|
||||
}
|
||||
|
||||
public static boolean checkPermissionWhiteList(Player player, String debug) {
|
||||
if (!PermissionWhitelist.enable.valueBoolean) return true;
|
||||
if (!(boolean) PermissionWhitelist.VALUES.enable.getValue()) return true;
|
||||
return PermissionCheck.permWhitelist(player, debug);
|
||||
}
|
||||
|
||||
public static T2COpSecAPIPlayerStatus detailCheckOPWhiteList(Player player) {
|
||||
if (!OPWhitelist.enable.valueBoolean) return T2COpSecAPIPlayerStatus.playerOnOpWhitelist;
|
||||
if (!(boolean) OPWhitelist.VALUES.enable.getValue()) return T2COpSecAPIPlayerStatus.playerOnOpWhitelist;
|
||||
List<String> nameList = new ArrayList<>();
|
||||
List<String> uuidList = new ArrayList<>();
|
||||
for (Map.Entry<String, PlayerObject> playerObject : PlayerCache.getOpHashMap().entrySet()) {
|
||||
@ -41,8 +41,9 @@ public class T2COpSecAPI {
|
||||
}
|
||||
return T2COpSecAPIPlayerStatus.playerOnOpWhitelist;
|
||||
}
|
||||
|
||||
public static T2COpSecAPIPlayerStatus detailCheckPermissionWhiteList(Player player) {
|
||||
if (!PermissionWhitelist.enable.valueBoolean) return T2COpSecAPIPlayerStatus.playerOnPermissionWhitelist;
|
||||
if (!(boolean)PermissionWhitelist.VALUES.enable.getValue()) return T2COpSecAPIPlayerStatus.playerOnPermissionWhitelist;
|
||||
List<String> nameList = new ArrayList<>();
|
||||
List<String> uuidList = new ArrayList<>();
|
||||
for (Map.Entry<String, PlayerObject> playerObject : PlayerCache.getPermissionHashMap().entrySet()) {
|
||||
|
@ -8,7 +8,7 @@ public class Util {
|
||||
private static String infoText = "";
|
||||
|
||||
@Getter
|
||||
private static String requiredT2CodeLibVersion = "15.0";
|
||||
private static String requiredT2CodeLibVersion = "16.7";
|
||||
|
||||
@Getter
|
||||
private static String prefix = "§8[§4T2C§8-§2OP§4Security§8]";
|
||||
@ -27,8 +27,23 @@ public class Util {
|
||||
|
||||
@Getter
|
||||
private static String discord = "http://dc.t2code.net";
|
||||
|
||||
@Getter
|
||||
private static Integer configVersion = 2;
|
||||
private static final String[] configLogo = new String[]{
|
||||
"####################################################################################################################",
|
||||
"## ##",
|
||||
"## /$$$$$$$$ /$$$$$$ /$$$$$$ /$$ /$$ ##",
|
||||
"## |__ $$__//$$__ $$ /$$__ $$ | $$ | $$ ##",
|
||||
"## | $$ |__/ \\ $$| $$ \\__/ /$$$$$$ /$$$$$$$ /$$$$$$ /$$$$$$$ /$$$$$$ /$$$$$$ ##",
|
||||
"## | $$ /$$$$$$/| $$ /$$__ $$ /$$__ $$ /$$__ $$ | $$__ $$ /$$__ $$|_ $$_/ ##",
|
||||
"## | $$ /$$____/ | $$ | $$ \\ $$| $$ | $$| $$$$$$$$ | $$ \\ $$| $$$$$$$$ | $$ ##",
|
||||
"## | $$ | $$ | $$ $$| $$ | $$| $$ | $$| $$_____/ | $$ | $$| $$_____/ | $$ /$$ ##",
|
||||
"## | $$ | $$$$$$$$| $$$$$$/| $$$$$$/| $$$$$$$| $$$$$$$ /$$| $$ | $$| $$$$$$$ | $$$$/ ##",
|
||||
"## |__/ |________/ \\______/ \\______/ \\_______/ \\_______/|__/|__/ |__/ \\_______/ \\___/ ##",
|
||||
"## ##",
|
||||
"## T2CodeLib from JaTiTV / T2Code.net. In case of problems please contact the Discord: https://dc.t2code.net ##",
|
||||
"## ##",
|
||||
"####################################################################################################################"};
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.t2code.opsecurity.check;
|
||||
|
||||
import com.sun.org.apache.xerces.internal.xs.StringList;
|
||||
import net.t2code.opsecurity.config.config.Config;
|
||||
import net.t2code.opsecurity.config.language.Language;
|
||||
import net.t2code.opsecurity.config.opWhitelist.OPWhitelist;
|
||||
@ -12,13 +13,15 @@ import net.t2code.t2codelib.SPIGOT.api.commands.T2Ccmd;
|
||||
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class OpCheck {
|
||||
public static Boolean onCheck(Player player, Boolean join, String debug) {
|
||||
if (!OPWhitelist.enable.valueBoolean) return false;
|
||||
if (!(boolean) OPWhitelist.VALUES.enable.getValue()) return false;
|
||||
if (!player.isOp()) return false;
|
||||
if (opWhitelist(player, debug)) return false;
|
||||
if (join) T2Csend.console(Language.opWhitelistNotifyOnJoin.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
@ -32,26 +35,26 @@ public class OpCheck {
|
||||
}
|
||||
|
||||
private static void execute(Player player, Boolean join, String debug) {
|
||||
if (Config.notifyJoinWarning.valueBoolean && join) {
|
||||
if (Config.notifyBungee.valueBoolean) {
|
||||
if ((boolean)Config.VALUES.notifyJoinWarning.getValue() && join) {
|
||||
if ((boolean)Config.VALUES.notifyBungee.getValue()) {
|
||||
BungeeSenderReceiver.sendToBungee(Language.opWhitelistNotifyOnJoin.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
} else
|
||||
Events.notifyPlayer(Language.opWhitelistNotifyOnJoin.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
}
|
||||
|
||||
if (OPWhitelist.noOpPlayerSetGameModeEnable.valueBoolean) {
|
||||
player.setGameMode(OPWhitelist.noOpPlayerSetGameModeValue.valueGameMode);
|
||||
if ((boolean)OPWhitelist.VALUES.noOpPlayerSetGameModeEnable.getValue()) {
|
||||
player.setGameMode(GameMode.valueOf( OPWhitelist.VALUES.noOpPlayerSetGameModeValue.getValue().toString()));
|
||||
}
|
||||
|
||||
if (OPWhitelist.noOpPlayerDeopEnable.valueBoolean) {
|
||||
if ((boolean)OPWhitelist.VALUES.noOpPlayerDeopEnable.getValue()) {
|
||||
player.setOp(false);
|
||||
if (OPWhitelist.noOpPlayerKickEnable.valueBoolean) {
|
||||
if (!OPWhitelist.customCommandsEnable.valueBoolean) {
|
||||
if (Config.kickCustomCommand.valueBoolean) {
|
||||
T2Ccmd.console( Config.kickCommand.valueString.replace("[player]", player.getName()).replace("[reason]",
|
||||
OPWhitelist.noOpPlayerKickEnable.valueBoolean && OPWhitelist.noOpPlayerDeopEnable.valueBoolean && OPWhitelist.noOpPlayerDeopPlayerSendMessage.valueBoolean
|
||||
if ((boolean)OPWhitelist.VALUES.noOpPlayerKickEnable.getValue()) {
|
||||
if (!(boolean)OPWhitelist.VALUES.customCommandsEnable.getValue()) {
|
||||
if ((boolean) Config.VALUES.kickCustomCommand.getValue()) {
|
||||
T2Ccmd.console( Config.VALUES.kickCommand.getValue().toString().replace("[player]", player.getName()).replace("[reason]",
|
||||
(boolean)OPWhitelist.VALUES.noOpPlayerKickEnable.getValue() && (boolean)OPWhitelist.VALUES.noOpPlayerDeopEnable.getValue() && (boolean)OPWhitelist.VALUES.noOpPlayerDeopPlayerSendMessage.getValue()
|
||||
? Language.opWhitelistKick.value + "<br> <br>" + Language.opWhitelistDeop.value : Language.opWhitelistKick.value));
|
||||
} else player.kickPlayer(OPWhitelist.noOpPlayerDeopEnable.valueBoolean && OPWhitelist.noOpPlayerDeopPlayerSendMessage.valueBoolean
|
||||
} else player.kickPlayer((boolean)OPWhitelist.VALUES.noOpPlayerDeopEnable.getValue() && (boolean)OPWhitelist.VALUES.noOpPlayerDeopPlayerSendMessage.getValue()
|
||||
? Language.opWhitelistKick.value + "\n \n" + Language.opWhitelistDeop.value : Language.opWhitelistKick.value);
|
||||
}
|
||||
T2Csend.console("["+debug+ "]" +Language.opWhitelistNotifyDeop.value.replace("[player]", player.getName().replace("[uuid]", String.valueOf(player.getUniqueId()))) + "<br>"
|
||||
@ -62,7 +65,7 @@ public class OpCheck {
|
||||
T2Csend.console("["+debug+ "]" +Language.opWhitelistNotifyDeop.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
Events.notifyPlayer(Language.opWhitelistNotifyDeop.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
|
||||
if (OPWhitelist.noOpPlayerDeopPlayerSendMessage.valueBoolean) {
|
||||
if ((boolean)OPWhitelist.VALUES.noOpPlayerDeopPlayerSendMessage.getValue()) {
|
||||
Bukkit.getScheduler().runTaskLater(Main.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -72,19 +75,19 @@ public class OpCheck {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (OPWhitelist.noOpPlayerKickEnable.valueBoolean) {
|
||||
if (!OPWhitelist.noOpPlayerDeopEnable.valueBoolean) {
|
||||
if (!OPWhitelist.customCommandsEnable.valueBoolean) {
|
||||
if (Config.kickCustomCommand.valueBoolean) {
|
||||
T2Ccmd.console(Config.kickCommand.valueString.replace("[player]", player.getName()).replace("[reason]", Language.opWhitelistKick.value));
|
||||
if ((boolean)OPWhitelist.VALUES.noOpPlayerKickEnable.getValue()) {
|
||||
if (!(boolean)OPWhitelist.VALUES.noOpPlayerDeopEnable.getValue()) {
|
||||
if (!(boolean)OPWhitelist.VALUES.customCommandsEnable.getValue()) {
|
||||
if ((boolean)Config.VALUES.kickCustomCommand.getValue()) {
|
||||
T2Ccmd.console(Config.VALUES.kickCommand.getValue().toString().replace("[player]", player.getName()).replace("[reason]", Language.opWhitelistKick.value));
|
||||
} else player.kickPlayer(Language.opWhitelistKick.value);
|
||||
}
|
||||
T2Csend.console("["+debug+ "]" +Language.opWhitelistNotifyKick.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
Events.notifyPlayer(Language.opWhitelistNotifyKick.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
}
|
||||
}
|
||||
if (OPWhitelist.customCommandsEnable.valueBoolean) {
|
||||
for (String cmd : OPWhitelist.customCommandsCommands.valueStringList) {
|
||||
if ((boolean)OPWhitelist.VALUES.customCommandsEnable.getValue()) {
|
||||
for (String cmd : (StringList)OPWhitelist.VALUES.customCommandsCommands.getValue()) {
|
||||
T2Ccmd.console(cmd.replace("[player]", player.getName()));
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.t2code.opsecurity.check;
|
||||
|
||||
import com.sun.org.apache.xerces.internal.xs.StringList;
|
||||
import net.t2code.opsecurity.config.config.Config;
|
||||
import net.t2code.opsecurity.config.language.Language;
|
||||
import net.t2code.opsecurity.config.permissionWhitelist.PermissionWhitelist;
|
||||
@ -18,8 +19,8 @@ import java.util.Map;
|
||||
|
||||
public class PermissionCheck {
|
||||
public static Boolean onCheck(Player player, Boolean join, String debug) {
|
||||
if (!PermissionWhitelist.enable.valueBoolean) return false;
|
||||
for (String perm : PermissionWhitelist.permissions.valueStringList) {
|
||||
if (!(boolean) PermissionWhitelist.VALUES.enable.getValue()) return false;
|
||||
for (String perm : (StringList) PermissionWhitelist.VALUES.permissions.getValue()) {
|
||||
if (!player.hasPermission(perm)) return false;
|
||||
T2Cdebug.debug(Main.getPlugin(), "[" + debug + "] check Permission: " + perm);
|
||||
if (permWhitelist(player, debug)) return false;
|
||||
@ -37,22 +38,22 @@ public class PermissionCheck {
|
||||
private static void execute(Player player, Boolean join, String perm, String debug) {
|
||||
if (join)
|
||||
T2Csend.console("[" + debug + "]" + Language.permissionWhitelistNotifyKick.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
if (Config.notifyJoinWarning.valueBoolean && join) {
|
||||
if (Config.notifyBungee.valueBoolean) {
|
||||
if ((boolean) Config.VALUES.notifyJoinWarning.getValue() && join) {
|
||||
if ((boolean) Config.VALUES.notifyBungee.getValue()) {
|
||||
BungeeSenderReceiver.sendToBungee(Language.permissionWhitelistNotifyOnJoin.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
} else
|
||||
Events.notifyPlayer(Language.permissionWhitelistNotifyOnJoin.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
}
|
||||
|
||||
if (PermissionWhitelist.playerWithPermissionKick.valueBoolean) {
|
||||
if (Config.kickCustomCommand.valueBoolean) {
|
||||
T2Ccmd.console(Config.kickCommand.valueString.replace("[perm]", perm).replace("[player]", player.getName()).replace("[reason]", Language.permissionWhitelistKick.value));
|
||||
if ((boolean)PermissionWhitelist.VALUES.playerWithPermissionKick.getValue()) {
|
||||
if ((boolean) Config.VALUES.kickCustomCommand.getValue()) {
|
||||
T2Ccmd.console(Config.VALUES.kickCommand.getValue().toString().replace("[perm]", perm).replace("[player]", player.getName()).replace("[reason]", Language.permissionWhitelistKick.value));
|
||||
} else player.kickPlayer(Language.permissionWhitelistKick.value);
|
||||
T2Csend.console("[" + debug + "]" + Language.permissionWhitelistNotifyKick.value.replace("[player]",
|
||||
player.getName()).replace("[perm]", perm).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
}
|
||||
if (PermissionWhitelist.customCommandsEnable.valueBoolean) {
|
||||
for (String cmd : PermissionWhitelist.customCommandsCommands.valueStringList) {
|
||||
if ((boolean)PermissionWhitelist.VALUES.customCommandsEnable.getValue()) {
|
||||
for (String cmd : (StringList)PermissionWhitelist.VALUES.customCommandsCommands.getValue()) {
|
||||
T2Ccmd.console(cmd.replace("[player]", player.getName()).replace("[perm]", perm));
|
||||
}
|
||||
}
|
||||
|
@ -13,8 +13,8 @@ import org.bukkit.entity.Player;
|
||||
public class Timer {
|
||||
|
||||
public static void refreshTimer() {
|
||||
if (!(OPWhitelist.enable.valueBoolean && PermissionWhitelist.enable.valueBoolean)) return;
|
||||
if (!Config.checkTimerEnable.valueBoolean) return;
|
||||
if (!((boolean)OPWhitelist.VALUES.enable.getValue() && (boolean)PermissionWhitelist.VALUES.enable.getValue())) return;
|
||||
if (!(boolean) Config.VALUES.checkTimerEnable.getValue()) return;
|
||||
|
||||
Bukkit.getScheduler().scheduleAsyncRepeatingTask(Main.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
@ -25,6 +25,6 @@ public class Timer {
|
||||
PermissionCheck.onCheck(player, false, debug);
|
||||
}
|
||||
}
|
||||
}, 0, 20L * Config.checkTimerRefreshInSec.valueInt);
|
||||
}, 0, 20L * (int) Config.VALUES.checkTimerRefreshInSec.getValue());
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
|
||||
if (args.length == 0) {
|
||||
Commands.mainCommand(sender);
|
||||
} else {
|
||||
if (Config.onlyOPcanUseThePlugin.valueBoolean) {
|
||||
if ((boolean)Config.VALUES.onlyOPcanUseThePlugin.getValue()) {
|
||||
if (!sender.isOp()) {
|
||||
sender.sendMessage(Util.getPrefix() + "§cOnly OPs can use OPSecurity!");
|
||||
return false;
|
||||
|
@ -5,6 +5,8 @@ import net.t2code.opsecurity.check.OpCheck;
|
||||
import net.t2code.opsecurity.config.FileSelect;
|
||||
import net.t2code.opsecurity.config.config.Config;
|
||||
import net.t2code.opsecurity.config.language.Language;
|
||||
import net.t2code.opsecurity.config.opWhitelist.OPWhitelist;
|
||||
import net.t2code.opsecurity.config.permissionWhitelist.PermissionWhitelist;
|
||||
import net.t2code.opsecurity.system.Main;
|
||||
import net.t2code.opsecurity.system.Permissions;
|
||||
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
|
||||
@ -33,7 +35,7 @@ public class Commands {
|
||||
}
|
||||
|
||||
public static void mainCommand(CommandSender sender) {
|
||||
if (Config.onlyOPcanUseThePlugin.valueBoolean) {
|
||||
if ((boolean) Config.VALUES.onlyOPcanUseThePlugin.getValue()) {
|
||||
if (!sender.isOp()) {
|
||||
sender.sendMessage(Util.getPrefix() + "§cOnly OPs can use OPSecurity!");
|
||||
return;
|
||||
@ -53,7 +55,7 @@ public class Commands {
|
||||
}
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
if (Config.onlyOPcanUseThePlugin.valueBoolean) {
|
||||
if ((boolean) Config.VALUES.onlyOPcanUseThePlugin.getValue()) {
|
||||
String debug = T2Cdebug.debugCode();
|
||||
if (!OpCheck.opWhitelist(player, debug)) {
|
||||
sender.sendMessage(Util.getPrefix() + " §4You are not on the Whitelist!"); // todo
|
||||
@ -67,10 +69,10 @@ public class Commands {
|
||||
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §6Plugin reload...");
|
||||
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + "§8-------------------------------");
|
||||
// Load.onLoad(Main.getPlugin(),Main.getAutor(),Main.getVersion());
|
||||
FileSelect.selectConfig();
|
||||
Config.set();
|
||||
FileSelect.selectLanguage();
|
||||
FileSelect.selectOpWhitelist();
|
||||
FileSelect.selectPermissionWhitelist();
|
||||
OPWhitelist.set();
|
||||
PermissionWhitelist.set();
|
||||
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + "§8-------------------------------");
|
||||
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §2Plugin successfully reloaded.");
|
||||
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + "§8-------------------------------");
|
||||
|
@ -2,20 +2,12 @@ package net.t2code.opsecurity.config;
|
||||
|
||||
import net.t2code.opsecurity.Util;
|
||||
import net.t2code.opsecurity.config.config.Config;
|
||||
import net.t2code.opsecurity.config.config.Converter;
|
||||
import net.t2code.opsecurity.config.language.Language;
|
||||
import net.t2code.opsecurity.config.opWhitelist.OPWhitelist;
|
||||
import net.t2code.opsecurity.config.permissionWhitelist.PermissionWhitelist;
|
||||
import net.t2code.opsecurity.objects.PlayerCache;
|
||||
import net.t2code.opsecurity.objects.PlayerObject;
|
||||
import net.t2code.opsecurity.system.Main;
|
||||
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.yaml.T2Cconfig;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.languages.SelectLibMsg;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Sound;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
@ -23,69 +15,6 @@ import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
public class FileSelect {
|
||||
public static void selectConfig() {
|
||||
File config = new File(Main.getPath(), "config.yml");
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
if (!config.exists()) T2Cconfig.set("configVersion", Util.getConfigVersion(), yamlConfiguration);
|
||||
if (yamlConfiguration.getInt("configVersion") < Util.getConfigVersion() && new File(Main.getPath(), "config.yml").exists()) {
|
||||
if (yamlConfiguration.getInt("configVersion") < 2) {
|
||||
Converter.convertCheck();
|
||||
T2Csend.console(Util.getPrefix() + " §4----------------------");
|
||||
T2Csend.console(Util.getPrefix() + " ");
|
||||
T2Csend.console(Util.getPrefix() + " §6New features have been added to T2C-OPSecurity. The Config is adapted!");
|
||||
T2Csend.console(Util.getPrefix() + " ");
|
||||
T2Csend.console(Util.getPrefix() + " §4----------------------");
|
||||
}
|
||||
config = new File(Main.getPath(), "config.yml");
|
||||
yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
}
|
||||
|
||||
for (Config value : Config.values()) {
|
||||
switch (value.configParam) {
|
||||
case STRING:
|
||||
if (!yamlConfiguration.contains(value.path)) {
|
||||
yamlConfiguration.set(value.path, value.valueString);
|
||||
}
|
||||
value.valueString = T2Creplace.replace(Util.getPrefix(), Objects.requireNonNull(yamlConfiguration.getString(value.path)));
|
||||
break;
|
||||
case STRINGLIST:
|
||||
if (!yamlConfiguration.contains(value.path)) {
|
||||
yamlConfiguration.set(value.path, value.valueStringList);
|
||||
}
|
||||
value.valueStringList = T2Creplace.replace(Util.getPrefix(), yamlConfiguration.getStringList(value.path));
|
||||
break;
|
||||
case SOUND:
|
||||
if (!yamlConfiguration.contains(value.path)) {
|
||||
yamlConfiguration.set(value.path, value.sound.toString());
|
||||
}
|
||||
try {
|
||||
value.sound = Sound.valueOf(yamlConfiguration.getString(value.path));
|
||||
} catch (Exception ex) {
|
||||
T2Csend.console("§4\n§4\n§4\n" + SelectLibMsg.soundNotFound.replace("[prefix]", Util.getPrefix())
|
||||
.replace("[sound]", "§8" + value.path + ": §6" + yamlConfiguration.getString(value.path)) + "§4\n§4\n§4\n");
|
||||
}
|
||||
break;
|
||||
case BOOLEAN:
|
||||
if (!yamlConfiguration.contains(value.path)) {
|
||||
yamlConfiguration.set(value.path, value.valueBoolean);
|
||||
}
|
||||
value.valueBoolean = yamlConfiguration.getBoolean(value.path);
|
||||
break;
|
||||
case INTEGER:
|
||||
if (!yamlConfiguration.contains(value.path)) {
|
||||
yamlConfiguration.set(value.path, value.valueInt);
|
||||
}
|
||||
|
||||
value.valueInt = yamlConfiguration.getInt(value.path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
yamlConfiguration.save(config);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static ArrayList<String> defaultLanguages = new ArrayList<>(Arrays.asList("german", "english"));
|
||||
|
||||
@ -116,119 +45,24 @@ public class FileSelect {
|
||||
}
|
||||
|
||||
String selectMSG;
|
||||
File config = new File(Main.getPath(), "languages/" + Config.language.valueString + ".yml");
|
||||
File config = new File(Main.getPath(), "languages/" + Config.VALUES.language.getValue() + ".yml");
|
||||
T2Cdebug.debug(Main.getPlugin(), config.getAbsolutePath());
|
||||
if (!config.isFile()) {
|
||||
T2Csend.console(Util.getPrefix());
|
||||
T2Csend.console(Util.getPrefix() + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
T2Csend.console(Util.getPrefix() + " §4The selected §c" + Config.language.valueString + " §4language file was not found.");
|
||||
T2Csend.console(Util.getPrefix() + " §4The selected §c" + Config.VALUES.language.getValue() + " §4language file was not found.");
|
||||
T2Csend.console(Util.getPrefix() + " §6The default language §eEnglish §6is used!");
|
||||
T2Csend.console(Util.getPrefix() + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
T2Csend.console(Util.getPrefix());
|
||||
config = new File(Main.getPath(), "languages/" + "english.yml");
|
||||
selectMSG = "english";
|
||||
} else selectMSG = Config.language.valueString;
|
||||
} else selectMSG = Config.VALUES.language.getValue().toString();
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
|
||||
for (Language value : Language.values()) {
|
||||
T2Cdebug.debug(Main.getPlugin(), "Select: File: " + config.getName() + " Path: " + value.path);
|
||||
value.value = T2Creplace.replace(Util.getPrefix(), yamlConfiguration.getString(value.path));
|
||||
}
|
||||
T2Csend.console(Util.getPrefix() + " §2Language successfully selected to: §6" + selectMSG + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||
}
|
||||
|
||||
public static void selectOpWhitelist() {
|
||||
PlayerCache.getOpHashMap().clear();
|
||||
File config = new File(Main.getPath(), "opWhitelist.yml");
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
for (OPWhitelist value : OPWhitelist.values()) {
|
||||
switch (value.cEnum) {
|
||||
case BOOLEAN:
|
||||
if (!yamlConfiguration.contains(value.path)) {
|
||||
yamlConfiguration.set(value.path, value.valueBoolean);
|
||||
}
|
||||
value.valueBoolean = yamlConfiguration.getBoolean(value.path);
|
||||
break;
|
||||
case STRINGLIST:
|
||||
if (!yamlConfiguration.contains(value.path)) {
|
||||
yamlConfiguration.set(value.path, value.valueStringList);
|
||||
}
|
||||
value.valueStringList = T2Creplace.replace(Util.getPrefix(), yamlConfiguration.getStringList(value.path));
|
||||
break;
|
||||
case PLAYERLIST:
|
||||
if (!yamlConfiguration.contains(value.pathPlayerListPath)) {
|
||||
yamlConfiguration.set(value.pathPlayerName.replace("KEY", "player1"), value.valuePlayerName);
|
||||
yamlConfiguration.set(value.pathPlayerUuid.replace("KEY", "player1"), value.valuePlayerUuid);
|
||||
yamlConfiguration.set(value.pathPlayerName.replace("KEY", "player2"), value.valuePlayerName);
|
||||
yamlConfiguration.set(value.pathPlayerUuid.replace("KEY", "player2"), value.valuePlayerUuid);
|
||||
}
|
||||
for (String key : yamlConfiguration.getConfigurationSection(value.pathPlayerListPath).getKeys(false)) {
|
||||
String name = yamlConfiguration.getString(value.pathPlayerName.replace("KEY", key));
|
||||
PlayerObject playerObject = new PlayerObject(
|
||||
name,
|
||||
yamlConfiguration.getString(value.pathPlayerUuid.replace("KEY", key)).replace("-", ""));
|
||||
PlayerCache.getOpHashMap().put(name, playerObject);
|
||||
}
|
||||
break;
|
||||
case GAMEMODE:
|
||||
if (!yamlConfiguration.contains(value.path)) {
|
||||
yamlConfiguration.set(value.path, value.valueGameMode.toString());
|
||||
}
|
||||
try {
|
||||
value.valueGameMode = GameMode.valueOf(yamlConfiguration.getString(value.path).toUpperCase());
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
value.valueGameMode = GameMode.SURVIVAL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
yamlConfiguration.save(config);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void selectPermissionWhitelist() {
|
||||
PlayerCache.getPermissionHashMap().clear();
|
||||
File config = new File(Main.getPath(), "permissionWhitelist.yml");
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
for (PermissionWhitelist value : PermissionWhitelist.values()) {
|
||||
switch (value.cEnum) {
|
||||
case BOOLEAN:
|
||||
if (!yamlConfiguration.contains(value.path)) {
|
||||
yamlConfiguration.set(value.path, value.valueBoolean);
|
||||
}
|
||||
value.valueBoolean = yamlConfiguration.getBoolean(value.path);
|
||||
break;
|
||||
case STRINGLIST:
|
||||
if (!yamlConfiguration.contains(value.path)) {
|
||||
yamlConfiguration.set(value.path, value.valueStringList);
|
||||
}
|
||||
value.valueStringList = T2Creplace.replace(Util.getPrefix(), yamlConfiguration.getStringList(value.path));
|
||||
break;
|
||||
case PLAYERLIST:
|
||||
if (!yamlConfiguration.contains(value.pathPlayerListPath)) {
|
||||
yamlConfiguration.set(value.pathPlayerName.replace("KEY", "player1"), value.valuePlayerName);
|
||||
yamlConfiguration.set(value.pathPlayerUuid.replace("KEY", "player1"), value.valuePlayerUuid);
|
||||
yamlConfiguration.set(value.pathPlayerName.replace("KEY", "player2"), value.valuePlayerName);
|
||||
yamlConfiguration.set(value.pathPlayerUuid.replace("KEY", "player2"), value.valuePlayerUuid);
|
||||
}
|
||||
for (String key : yamlConfiguration.getConfigurationSection(value.pathPlayerListPath).getKeys(false)) {
|
||||
String name = yamlConfiguration.getString(value.pathPlayerName.replace("KEY", key));
|
||||
PlayerObject playerObject = new PlayerObject(
|
||||
name,
|
||||
yamlConfiguration.getString(value.pathPlayerUuid.replace("KEY", key)).replace("-", ""));
|
||||
PlayerCache.getPermissionHashMap().put(name, playerObject);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
yamlConfiguration.save(config);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
T2Ctemplate.onStartMsg(Util.getPrefix(),"§2Language successfully selected to: §6" + selectMSG + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||
}
|
||||
}
|
||||
|
@ -1,73 +1,95 @@
|
||||
// This class was created by JaTiTV.
|
||||
|
||||
package net.t2code.opsecurity.config.config;
|
||||
|
||||
import net.t2code.opsecurity.enums.ConfigParam;
|
||||
import net.t2code.opsecurity.system.Main;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
||||
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
|
||||
import net.t2code.t2codelib.SPIGOT.api.yaml.T2CconfigWriter;
|
||||
import net.t2code.t2codelib.T2CconfigItem;
|
||||
import net.t2code.opsecurity.Util;
|
||||
import org.bukkit.Sound;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public enum Config {
|
||||
public class Config {
|
||||
|
||||
language("plugin.language", "english", ConfigParam.STRING),
|
||||
onlyOPcanUseThePlugin("plugin.onlyOPcanUseThePlugin", true, ConfigParam.BOOLEAN),
|
||||
public enum VALUES implements T2CconfigItem {
|
||||
|
||||
updateCheckOnJoin("plugin.updateCheck.onJoin",true,ConfigParam.BOOLEAN),
|
||||
updateCheckSeePreReleaseUpdates("plugin.updateCheck.seePreReleaseUpdates",true,ConfigParam.BOOLEAN),
|
||||
updateCheckTimeInterval("plugin.updateCheck.timeInterval",60,ConfigParam.INTEGER),
|
||||
language("plugin.language", "english", true,"Here you can set the language of the plugin."),
|
||||
onlyOPcanUseThePlugin("plugin.onlyOPcanUseThePlugin", true, true, "Here you can specify that only players with OP can use the commands of the plugin."),
|
||||
|
||||
checkOnJoin("check.onJoin.enable", true, ConfigParam.BOOLEAN),
|
||||
checkOnInteract("check.onInteract.enable", true, ConfigParam.BOOLEAN),
|
||||
checkOnCommand("check.onCommand.enable", true, ConfigParam.BOOLEAN),
|
||||
checkOnCommandWhitelist("check.onCommand.whitelist", Arrays.asList("command 1","command 2"), ConfigParam.STRINGLIST),
|
||||
checkOnChat("check.onChat.enable", true, ConfigParam.BOOLEAN),
|
||||
checkTimerEnable("check.timer.enable", true, ConfigParam.BOOLEAN),
|
||||
checkTimerRefreshInSec("check.timer.refreshInSec", 60, ConfigParam.INTEGER),
|
||||
kickCustomCommand("kick.customCommand.enable", false, ConfigParam.BOOLEAN),
|
||||
kickCommand("kick.customCommand.command", "minecraft:kick [player] [reason]", ConfigParam.STRING),
|
||||
notifyJoinWarning("notify.joinWarn.enable", true, ConfigParam.BOOLEAN),
|
||||
notifyBungee("notify.allBungeePlayer.enable", false, ConfigParam.BOOLEAN),
|
||||
notifySoundEnable("notify.soundEnable", true, ConfigParam.BOOLEAN),
|
||||
notifySoundValue("notify.sound", sound(), ConfigParam.SOUND);
|
||||
updateCheckOnJoin("plugin.updateCheck.onJoin",true,true, "In this option you can set if players with the permission 't2c.opsecurity.updatemsg' will get an update message on join when an update for the plugin is available."),
|
||||
updateCheckSeePreReleaseUpdates("plugin.updateCheck.seePreReleaseUpdates",true,true,"In this option you can set whether you want to receive and display beta and snapshot versions in the update check."),
|
||||
updateCheckTimeInterval("plugin.updateCheck.timeInterval",60,true,"In this option you can set the time interval in minutes in which updates should be checked."),
|
||||
|
||||
public String path;
|
||||
public String valueString;
|
||||
public List<String> valueStringList;
|
||||
public Integer valueInt;
|
||||
public Boolean valueBoolean;
|
||||
public Sound sound;
|
||||
public ConfigParam configParam;
|
||||
checkOnJoin("check.onJoin.enable", true, true, "Activate the checks whether the player is authorised when joining the player."),
|
||||
checkOnInteract("check.onInteract.enable", true, true,"Activate the checks whether the player is authorised for player interactions."),
|
||||
checkOnCommand("check.onCommand.enable", true, true,"Activate the checks whether the player is authorised when the player executes a command."),
|
||||
checkOnCommandWhitelist("check.onCommand.whitelist", Arrays.asList("command 1","command 2"), true, "Here you can specify commands for which the check is not carried out."),
|
||||
checkOnChat("check.onChat.enable", true, true,"Activate the checks whether the player is authorised when the player writes a chat message." ),
|
||||
checkTimerEnable("check.timer.enable", true, true, "Activate the check of all players in a time interval."),
|
||||
checkTimerRefreshInSec("check.timer.refreshInSec", 60, true,"Here you set the seconds with which the check is carried out in a time interval."),
|
||||
kickCustomCommand("kick.customCommand.enable", false,true, "Should a separate kick command be used for the kick? For example, if you use your own ban system."),
|
||||
kickCommand("kick.customCommand.command", "minecraft:kick [player] [reason]", true, "This is where you set the user-defined kick command."),
|
||||
notifyJoinWarning("notify.warn.enable", true, true, "Should players with the permission 't2c.opsecurity.notify' be warned if a player is detected who is not authorised to be on the server with OP / a permission."),
|
||||
notifyBungee("notify.allBungeePlayer.enable", false, true, "Should the warnings be sent on the entire network (true) or only on the individual server (false)."),
|
||||
notifySoundEnable("notify.soundEnable", true, true, "Should a sound be played during the warnings?"),
|
||||
notifySoundValue("notify.sound", sound(), true, "Which sound should be played during the warnings?"),
|
||||
;
|
||||
|
||||
Config(String path, String value, ConfigParam cEnum) {
|
||||
this.path = path;
|
||||
this.valueString = value;
|
||||
this.configParam = cEnum;
|
||||
private final String path;
|
||||
private Object value;
|
||||
private final boolean forceSet;
|
||||
private final List<String> comments;
|
||||
|
||||
VALUES(String path, Object value,boolean forceSet, String... comments) {
|
||||
this.path = path;
|
||||
this.value = value;
|
||||
this.forceSet = forceSet;
|
||||
this.comments = new ArrayList<>(Arrays.asList(comments));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getForceSet() {
|
||||
return forceSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getComments() {
|
||||
return comments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Object newValue) {
|
||||
value = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
Config(String path, Sound value, ConfigParam cEnum) {
|
||||
this.path = path;
|
||||
this.sound = value;
|
||||
this.configParam = cEnum;
|
||||
|
||||
|
||||
public static void set() {
|
||||
long long_ = System.currentTimeMillis();
|
||||
T2CconfigWriter.createConfig(new File(Main.getPath(), "config.yml"), VALUES.values(), Util.getConfigLogo());
|
||||
|
||||
T2Ctemplate.onStartMsg(Util.getPrefix(), "§2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||
}
|
||||
|
||||
Config(String path, Integer value, ConfigParam cEnum) {
|
||||
this.path = path;
|
||||
this.valueInt = value;
|
||||
this.configParam = cEnum;
|
||||
}
|
||||
|
||||
Config(String path, Boolean value, ConfigParam cEnum) {
|
||||
this.path = path;
|
||||
this.valueBoolean = value;
|
||||
this.configParam = cEnum;
|
||||
}
|
||||
Config(String path, List<String> value, ConfigParam cEnum) {
|
||||
this.path = path;
|
||||
this.valueStringList = value;
|
||||
this.configParam = cEnum;
|
||||
}
|
||||
|
||||
public static Sound sound() {
|
||||
private static Sound sound() {
|
||||
if (T2CmcVersion.isMc1_8()) {
|
||||
return Sound.valueOf("NOTE_PIANO");
|
||||
} else if (T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) {
|
||||
|
@ -1,10 +1,13 @@
|
||||
package net.t2code.opsecurity.config.config;
|
||||
|
||||
import net.t2code.opsecurity.Util;
|
||||
import net.t2code.opsecurity.config.opWhitelist.OPWhitelist;
|
||||
import net.t2code.opsecurity.config.permissionWhitelist.PermissionWhitelist;
|
||||
import net.t2code.opsecurity.objects.PlayerObject;
|
||||
import net.t2code.opsecurity.system.Main;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.yaml.T2CconfigWriter;
|
||||
import net.t2code.t2codelib.T2CconfigItem;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
@ -13,8 +16,14 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Converter {
|
||||
private static YamlConfiguration yamlConfigurationOld;
|
||||
private static YamlConfiguration opYml;
|
||||
private static YamlConfiguration permYml;
|
||||
|
||||
public static void convert() {
|
||||
Path pathOld = Paths.get("plugins/OPSecurity/config.yml");
|
||||
Path pathNew = Paths.get(Main.getPath() + "/config.yml");
|
||||
@ -24,52 +33,61 @@ public class Converter {
|
||||
if (Files.exists(pathOld) && !Files.isDirectory(pathOld)) {
|
||||
|
||||
File configOld = new File("plugins/OPSecurity/config.yml");
|
||||
YamlConfiguration yamlConfigurationOld = YamlConfiguration.loadConfiguration(configOld);
|
||||
yamlConfigurationOld = YamlConfiguration.loadConfiguration(configOld);
|
||||
File opConfig = new File(Main.getPath(), "opWhitelist.yml");
|
||||
YamlConfiguration opYml = YamlConfiguration.loadConfiguration(opConfig);
|
||||
opYml = YamlConfiguration.loadConfiguration(opConfig);
|
||||
File permConfig = new File(Main.getPath(), "permissionWhitelist.yml");
|
||||
YamlConfiguration permYml = YamlConfiguration.loadConfiguration(permConfig);
|
||||
permYml = YamlConfiguration.loadConfiguration(permConfig);
|
||||
|
||||
Config.language.valueString = yamlConfigurationOld.getString("Plugin.language");
|
||||
Config.onlyOPcanUseThePlugin.valueBoolean = yamlConfigurationOld.getBoolean("Plugin.OnlyOPcanUseThePlugin");
|
||||
Config.checkOnJoin.valueBoolean = yamlConfigurationOld.getBoolean("Check.OnJoin");
|
||||
Config.checkOnInteract.valueBoolean = yamlConfigurationOld.getBoolean("Check.OnInteract");
|
||||
Config.checkOnCommand.valueBoolean = yamlConfigurationOld.getBoolean("Check.OnCommand");
|
||||
Config.checkOnChat.valueBoolean = yamlConfigurationOld.getBoolean("Check.OnChat");
|
||||
Config.checkTimerEnable.valueBoolean = yamlConfigurationOld.getBoolean("Check.Timer.Enable");
|
||||
Config.checkTimerRefreshInSec.valueInt = yamlConfigurationOld.getInt("Check.Timer.RefreshTime_inSec");
|
||||
|
||||
Config.kickCommand.valueString = yamlConfigurationOld.getString("Kick.Command");
|
||||
Config.notifyJoinWarning.valueBoolean = yamlConfigurationOld.getBoolean("Notify.JoinWarn.Enable");
|
||||
Config.notifySoundEnable.valueBoolean = yamlConfigurationOld.getBoolean("Notify.Sound.Enable");
|
||||
Config.notifySoundValue.valueString = yamlConfigurationOld.getString("Notify.Sound.Sound");
|
||||
setConfig("Plugin.language", Config.VALUES.language);
|
||||
setConfig("Plugin.OnlyOPcanUseThePlugin", Config.VALUES.onlyOPcanUseThePlugin);
|
||||
setConfig("Check.OnJoin", Config.VALUES.checkOnJoin);
|
||||
setConfig("Check.OnInteract", Config.VALUES.checkOnInteract);
|
||||
setConfig("Check.OnCommand", Config.VALUES.checkOnCommand);
|
||||
setConfig("Check.OnChat", Config.VALUES.checkOnChat);
|
||||
setConfig("Check.Timer.Enable", Config.VALUES.checkTimerEnable);
|
||||
setConfig("Check.Timer.RefreshTime_inSec", Config.VALUES.checkTimerRefreshInSec);
|
||||
setConfig("Kick.Command", Config.VALUES.kickCommand);
|
||||
setConfig("Notify.JoinWarn.Enable", Config.VALUES.notifyJoinWarning);
|
||||
setConfig("Notify.Sound.Enable", Config.VALUES.notifySoundEnable);
|
||||
setConfig("Notify.Sound.Sound", Config.VALUES.notifySoundValue);
|
||||
|
||||
OPWhitelist.enable.valueBoolean = yamlConfigurationOld.getBoolean("OP_Whitelist.Enable");
|
||||
OPWhitelist.playerMustBeOnlineToOp.valueBoolean = yamlConfigurationOld.getBoolean("OP_Whitelist.PlayerMustBeOnlineToOp");
|
||||
setOPWhitelist("OP_Whitelist.Enable", OPWhitelist.VALUES.enable);
|
||||
setOPWhitelist("OP_Whitelist.PlayerMustBeOnlineToOp", OPWhitelist.VALUES.playerMustBeOnlineToOp);
|
||||
setOPWhitelist("OP_Whitelist.noOpPlayerDeop.Enable", OPWhitelist.VALUES.noOpPlayerDeopEnable);
|
||||
setOPWhitelist("OP_Whitelist.noOpPlayerDeop.PlayerSendMessage", OPWhitelist.VALUES.noOpPlayerDeopPlayerSendMessage);
|
||||
setOPWhitelist("OP_Whitelist.noOpPlayerKick.Enable", OPWhitelist.VALUES.noOpPlayerKickEnable);
|
||||
setOPWhitelist("OP_Whitelist.customCommands.Enable", OPWhitelist.VALUES.customCommandsEnable);
|
||||
setOPWhitelist("OP_Whitelist.customCommands.Commands", OPWhitelist.VALUES.customCommandsCommands);
|
||||
|
||||
OPWhitelist.noOpPlayerDeopEnable.valueBoolean = yamlConfigurationOld.getBoolean("OP_Whitelist.noOpPlayerDeop.Enable");
|
||||
OPWhitelist.noOpPlayerDeopPlayerSendMessage.valueBoolean = yamlConfigurationOld.getBoolean("OP_Whitelist.noOpPlayerDeop.PlayerSendMessage");
|
||||
OPWhitelist.noOpPlayerKickEnable.valueBoolean = yamlConfigurationOld.getBoolean("OP_Whitelist.noOpPlayerKick.Enable");
|
||||
OPWhitelist.customCommandsEnable.valueBoolean = yamlConfigurationOld.getBoolean("OP_Whitelist.customCommands.Enable");
|
||||
OPWhitelist.customCommandsCommands.valueStringList = yamlConfigurationOld.getStringList("OP_Whitelist.customCommands.Commands");
|
||||
|
||||
ArrayList<PlayerObject> opWhitelist = new ArrayList<>();
|
||||
for (String key : yamlConfigurationOld.getConfigurationSection("OP_Whitelist.Whitelist").getKeys(false)) {
|
||||
PlayerObject player = new PlayerObject(key,
|
||||
yamlConfigurationOld.getString("OP_Whitelist.Whitelist." + key + ".UUID").replace("-", ""));
|
||||
opWhitelist.add(player);
|
||||
}
|
||||
for (PlayerObject playerObject : opWhitelist) {
|
||||
opYml.set("opWhitelist.whitelist.KEY.name".replace("KEY", playerObject.playerName), playerObject.playerName);
|
||||
opYml.set("opWhitelist.whitelist.KEY.uuid".replace("KEY", playerObject.playerName), playerObject.uuid);
|
||||
if (yamlConfigurationOld.contains("OP_Whitelist.Whitelist")){
|
||||
ArrayList<PlayerObject> opWhitelist = new ArrayList<>();
|
||||
for (String key : yamlConfigurationOld.getConfigurationSection("OP_Whitelist.Whitelist").getKeys(false)) {
|
||||
PlayerObject player = new PlayerObject(key,
|
||||
yamlConfigurationOld.getString("OP_Whitelist.Whitelist." + key + ".UUID").replace("-", ""));
|
||||
opWhitelist.add(player);
|
||||
}
|
||||
|
||||
for (PlayerObject playerObject : opWhitelist) {
|
||||
PLAYERENUM.name.path = "opWhitelist.whitelist.KEY.name".replace("KEY", playerObject.playerName);
|
||||
PLAYERENUM.name.value = playerObject.playerName;
|
||||
|
||||
PLAYERENUM.uuid.path = "opWhitelist.whitelist.KEY.uuid".replace("KEY", playerObject.playerName);
|
||||
PLAYERENUM.uuid.value=playerObject.uuid;
|
||||
|
||||
T2CconfigWriter.createConfig(new File(Main.getPath(), "opWhitelist.yml"), PLAYERENUM.values(), Util.getConfigLogo());
|
||||
}
|
||||
}
|
||||
|
||||
PermissionWhitelist.enable.valueBoolean = yamlConfigurationOld.getBoolean("Permission_Whitelist.Enable");
|
||||
PermissionWhitelist.permissions.valueStringList = yamlConfigurationOld.getStringList("Permission_Whitelist.Permissions");
|
||||
|
||||
PermissionWhitelist.playerWithPermissionKick.valueBoolean = yamlConfigurationOld.getBoolean("Permission_Whitelist.PlayerWhithPermission_kick");
|
||||
PermissionWhitelist.customCommandsEnable.valueBoolean = yamlConfigurationOld.getBoolean("Permission_Whitelist.customCommands.Enable");
|
||||
PermissionWhitelist.customCommandsCommands.valueStringList = yamlConfigurationOld.getStringList("Permission_Whitelist.customCommands.Commands");
|
||||
setPermissionWhitelist("Permission_Whitelist.Enable", PermissionWhitelist.VALUES.enable);
|
||||
setPermissionWhitelist("Permission_Whitelist.Permissions", PermissionWhitelist.VALUES.permissions);
|
||||
setPermissionWhitelist("Permission_Whitelist.PlayerWhithPermission_kick", PermissionWhitelist.VALUES.playerWithPermissionKick);
|
||||
setPermissionWhitelist("Permission_Whitelist.customCommands.Enable", PermissionWhitelist.VALUES.customCommandsEnable);
|
||||
setPermissionWhitelist("Permission_Whitelist.customCommands.Commands", PermissionWhitelist.VALUES.customCommandsCommands);
|
||||
|
||||
|
||||
ArrayList<PlayerObject> permWhitelist = new ArrayList<>();
|
||||
for (String key : yamlConfigurationOld.getConfigurationSection("Permission_Whitelist.Whitelist").getKeys(false)) {
|
||||
@ -102,22 +120,22 @@ public class Converter {
|
||||
|
||||
if (!yamlConfiguration.contains("check.onJoin.enable")) {
|
||||
Boolean onJoin = yamlConfiguration.getBoolean("check.onJoin");
|
||||
T2Csend.debugmsg(Main.getPlugin(),"onJoin = " + onJoin);
|
||||
T2Csend.debugmsg(Main.getPlugin(), "onJoin = " + onJoin);
|
||||
yamlConfiguration.set("check.onJoin.enable", onJoin);
|
||||
}
|
||||
if (!yamlConfiguration.contains("check.onInteract.enable")) {
|
||||
Boolean onInteract = yamlConfiguration.getBoolean("check.onInteract");
|
||||
T2Csend.debugmsg(Main.getPlugin(),"onInteract = " + onInteract);
|
||||
T2Csend.debugmsg(Main.getPlugin(), "onInteract = " + onInteract);
|
||||
yamlConfiguration.set("check.onInteract.enable", onInteract);
|
||||
}
|
||||
if (!yamlConfiguration.contains("check.onCommand.enable")) {
|
||||
Boolean onCommand = yamlConfiguration.getBoolean("check.onCommand");
|
||||
T2Csend.debugmsg(Main.getPlugin(),"onCommand = " + onCommand);
|
||||
T2Csend.debugmsg(Main.getPlugin(), "onCommand = " + onCommand);
|
||||
yamlConfiguration.set("check.onCommand.enable", onCommand);
|
||||
}
|
||||
if (!yamlConfiguration.contains("check.onChat.enable")) {
|
||||
Boolean onChat = yamlConfiguration.getBoolean("check.onChat");
|
||||
T2Csend.debugmsg(Main.getPlugin(),"onChat = " + onChat);
|
||||
T2Csend.debugmsg(Main.getPlugin(), "onChat = " + onChat);
|
||||
yamlConfiguration.set("check.onChat.enable", onChat);
|
||||
}
|
||||
|
||||
@ -127,4 +145,69 @@ public class Converter {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static void setConfig(String path, T2CconfigItem item) {
|
||||
if (yamlConfigurationOld.contains(path)) {
|
||||
item.setValue(yamlConfigurationOld.get(path));
|
||||
}
|
||||
}
|
||||
|
||||
private static void setOPWhitelist(String path, T2CconfigItem item) {
|
||||
if (yamlConfigurationOld.contains(path)) {
|
||||
item.setValue(opYml.get(path));
|
||||
}
|
||||
}
|
||||
|
||||
private static void setPermissionWhitelist(String path, T2CconfigItem item) {
|
||||
if (yamlConfigurationOld.contains(path)) {
|
||||
item.setValue(permYml.get(path));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private enum PLAYERENUM implements T2CconfigItem {
|
||||
|
||||
name("", "", true),
|
||||
uuid("", "", true),
|
||||
|
||||
;
|
||||
|
||||
protected String path;
|
||||
protected Object value;
|
||||
private boolean forceSet;
|
||||
private final List<String> comments;
|
||||
|
||||
PLAYERENUM(String path, Object value,boolean forceSet, String... comments) {
|
||||
this.path = path;
|
||||
this.value = value;
|
||||
this.forceSet = forceSet;
|
||||
this.comments = new ArrayList<>(Arrays.asList(comments));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getForceSet() {
|
||||
return forceSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getComments() {
|
||||
return comments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Object newValue) {
|
||||
value = newValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,65 @@
|
||||
// This class was created by JaTiTV.
|
||||
|
||||
package net.t2code.opsecurity.config.language.news;
|
||||
|
||||
import net.t2code.t2codelib.SPIGOT.api.yaml.T2CconfigWriter;
|
||||
import net.t2code.t2codelib.T2CconfigItem;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Languages {
|
||||
|
||||
|
||||
public enum VALUES implements T2CconfigItem {
|
||||
VALUE1("path", VALUE, true, "DESCRIPTION"),
|
||||
VALUE2("path", VALUE, true, "DESCRIPTION"),
|
||||
|
||||
;
|
||||
|
||||
private final String path;
|
||||
private Object value;
|
||||
private final boolean forceSet;
|
||||
private final List<String> comments;
|
||||
|
||||
VALUES(String path, Object value,boolean forceSet, String... comments) {
|
||||
this.path = path;
|
||||
this.value = value;
|
||||
this.forceSet=forceSet;
|
||||
this.comments = new ArrayList<>(Arrays.asList(comments));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getForceSet() {
|
||||
return forceSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getComments() {
|
||||
return comments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Object newValue) {
|
||||
value = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
public static void set(){
|
||||
|
||||
T2CconfigWriter.createConfig(new File(getPlugin().getDataFolder(), "config.yml"), VALUES.values(), FILEHEADER);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,60 +1,99 @@
|
||||
// This class was created by JaTiTV.
|
||||
|
||||
package net.t2code.opsecurity.config.opWhitelist;
|
||||
|
||||
import net.t2code.opsecurity.enums.ConfigParam;
|
||||
import net.t2code.opsecurity.Util;
|
||||
import net.t2code.opsecurity.objects.PlayerCache;
|
||||
import net.t2code.opsecurity.objects.PlayerObject;
|
||||
import net.t2code.opsecurity.system.Main;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
||||
import net.t2code.t2codelib.SPIGOT.api.yaml.T2CconfigWriter;
|
||||
import net.t2code.t2codelib.T2CconfigItem;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public enum OPWhitelist {
|
||||
enable("opWhitelist.enable", false, ConfigParam.BOOLEAN),
|
||||
playerMustBeOnlineToOp("opWhitelist.playerMustBeOnlineToOp", true, ConfigParam.BOOLEAN),
|
||||
noOpPlayerDeopEnable("opWhitelist.noOpPlayerDeop.enable", true, ConfigParam.BOOLEAN),
|
||||
noOpPlayerDeopPlayerSendMessage("opWhitelist.noOpPlayerDeop.playerSendMessage", true, ConfigParam.BOOLEAN),
|
||||
noOpPlayerKickEnable("opWhitelist.noOpPlayerKick.enable", true, ConfigParam.BOOLEAN),
|
||||
noOpPlayerSetGameModeEnable("opWhitelist.noOpPlayerSetGameMode.enable", true, ConfigParam.BOOLEAN),
|
||||
noOpPlayerSetGameModeValue("opWhitelist.noOpPlayerSetGameMode.gameMode", GameMode.SURVIVAL, ConfigParam.GAMEMODE),
|
||||
customCommandsEnable("opWhitelist.customCommands.enable", false, ConfigParam.BOOLEAN),
|
||||
customCommandsCommands("opWhitelist.customCommands.commands", Arrays.asList("kick [player] &4You have op but are not authorized to do so, that's why you were kicked!")
|
||||
, ConfigParam.STRINGLIST),
|
||||
player("opWhitelist.whitelist","opWhitelist.whitelist.KEY.name", "opWhitelist.whitelist.KEY.uuid", "PlayerName", "00000000000000000000000000000000", ConfigParam.PLAYERLIST);
|
||||
public class OPWhitelist {
|
||||
|
||||
public String path;
|
||||
public String pathPlayerListPath;
|
||||
public String pathPlayerName;
|
||||
public String pathPlayerUuid;
|
||||
public String valuePlayerName;
|
||||
public String valuePlayerUuid;
|
||||
public List<String> valueStringList;
|
||||
public enum VALUES implements T2CconfigItem {
|
||||
|
||||
public Boolean valueBoolean;
|
||||
public GameMode valueGameMode;
|
||||
public ConfigParam cEnum;
|
||||
enable("opWhitelist.enable", false, true),
|
||||
playerMustBeOnlineToOp("opWhitelist.playerMustBeOnlineToOp", true, true),
|
||||
noOpPlayerDeopEnable("opWhitelist.noOpPlayerDeop.enable", true, true),
|
||||
noOpPlayerDeopPlayerSendMessage("opWhitelist.noOpPlayerDeop.playerSendMessage", true, true),
|
||||
noOpPlayerKickEnable("opWhitelist.noOpPlayerKick.enable", true, true),
|
||||
noOpPlayerSetGameModeEnable("opWhitelist.noOpPlayerSetGameMode.enable", true, true),
|
||||
noOpPlayerSetGameModeValue("opWhitelist.noOpPlayerSetGameMode.gameMode", GameMode.SURVIVAL, true),
|
||||
customCommandsEnable("opWhitelist.customCommands.enable", false, true),
|
||||
customCommandsCommands("opWhitelist.customCommands.commands", Arrays.asList("kick [player] &4You have op but are not authorized to do so, that's why you were kicked!"), true),
|
||||
|
||||
OPWhitelist(String path, GameMode value, ConfigParam cEnum) {
|
||||
this.path = path;
|
||||
this.valueGameMode = value;
|
||||
this.cEnum = cEnum;
|
||||
playerSection("opWhitelist.whitelist", null, true),
|
||||
player1name("opWhitelist.whitelist.player1.name", "player1", false),
|
||||
player1uuid("opWhitelist.whitelist.player1.uuid", "00000000000000000000000000000000", false),
|
||||
player2name("opWhitelist.whitelist.player2.name", "player2", false),
|
||||
player2uuid("opWhitelist.whitelist.player2.uuid", "00000000000000000000000000000000", false),
|
||||
|
||||
;
|
||||
|
||||
private final String path;
|
||||
private Object value;
|
||||
private final boolean forceSet;
|
||||
private final List<String> comments;
|
||||
|
||||
VALUES(String path, Object value, boolean forceSet, String... comments) {
|
||||
this.path = path;
|
||||
this.value = value;
|
||||
this.forceSet = forceSet;
|
||||
this.comments = new ArrayList<>(Arrays.asList(comments));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getForceSet() {
|
||||
return forceSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getComments() {
|
||||
return comments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Object newValue) {
|
||||
value = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
OPWhitelist(String listPath,String pathPlayerName, String pathUuid, String playerName, String uuid, ConfigParam cEnum) {
|
||||
this.pathPlayerListPath = listPath;
|
||||
this.pathPlayerName = pathPlayerName;
|
||||
this.pathPlayerUuid = pathUuid;
|
||||
this.valuePlayerName = playerName;
|
||||
this.valuePlayerUuid = uuid;
|
||||
this.cEnum = cEnum;
|
||||
public static void set() {
|
||||
long long_ = System.currentTimeMillis();
|
||||
T2CconfigWriter.createConfig(new File(Main.getPath(), "opWhitelist.yml"), VALUES.values(), Util.getConfigLogo());
|
||||
player();
|
||||
|
||||
T2Ctemplate.onStartMsg(Util.getPrefix(), "§2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||
}
|
||||
|
||||
OPWhitelist(String path, List<String> value, ConfigParam cEnum) {
|
||||
this.path = path;
|
||||
this.valueStringList = value;
|
||||
this.cEnum = cEnum;
|
||||
}
|
||||
|
||||
OPWhitelist(String path, Boolean value, ConfigParam cEnum) {
|
||||
this.path = path;
|
||||
this.valueBoolean = value;
|
||||
this.cEnum = cEnum;
|
||||
private static void player() {
|
||||
ConfigurationSection section = (ConfigurationSection) VALUES.playerSection.getValue();
|
||||
for (String key : section.getConfigurationSection("").getKeys(false)) {
|
||||
String name = section.getString(key + ".name");
|
||||
PlayerObject playerObject = new PlayerObject(
|
||||
name,
|
||||
section.getString(key + ".uuid").replace("-", ""));
|
||||
PlayerCache.getOpHashMap().put(name, playerObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,47 +1,94 @@
|
||||
// This class was created by JaTiTV.
|
||||
|
||||
package net.t2code.opsecurity.config.permissionWhitelist;
|
||||
|
||||
import net.t2code.opsecurity.enums.ConfigParam;
|
||||
import net.t2code.opsecurity.Util;
|
||||
import net.t2code.opsecurity.objects.PlayerCache;
|
||||
import net.t2code.opsecurity.objects.PlayerObject;
|
||||
import net.t2code.opsecurity.system.Main;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
||||
import net.t2code.t2codelib.SPIGOT.api.yaml.T2CconfigWriter;
|
||||
import net.t2code.t2codelib.T2CconfigItem;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public enum PermissionWhitelist {
|
||||
enable("permissionWhitelist.enable", false, ConfigParam.BOOLEAN),
|
||||
playerWithPermissionKick("permissionWhitelist.playerWithPermissionKick", true, ConfigParam.BOOLEAN),
|
||||
permissions("permissionWhitelist.permissions", Arrays.asList("*", "t2c.opsecurity.admin"), ConfigParam.STRINGLIST),
|
||||
customCommandsEnable("permissionWhitelist.customCommands.enable", false, ConfigParam.BOOLEAN),
|
||||
customCommandsCommands("permissionWhitelist.customCommands.commands", Arrays.asList("lp user [player] permission unset *", "lp user [player] permission unset t2c.opsecurity.admin")
|
||||
, ConfigParam.STRINGLIST),
|
||||
player("permissionWhitelist.whitelist", "permissionWhitelist.whitelist.KEY.name", "permissionWhitelist.whitelist.KEY.uuid", "PlayerName", "00000000000000000000000000000000", ConfigParam.PLAYERLIST);
|
||||
public class PermissionWhitelist {
|
||||
|
||||
public String path;
|
||||
public String pathPlayerListPath;
|
||||
public String pathPlayerName;
|
||||
public String pathPlayerUuid;
|
||||
public String valuePlayerName;
|
||||
public String valuePlayerUuid;
|
||||
public List<String> valueStringList;
|
||||
public Boolean valueBoolean;
|
||||
public ConfigParam cEnum;
|
||||
public enum VALUES implements T2CconfigItem {
|
||||
|
||||
PermissionWhitelist(String listPath, String pathPlayerName, String pathUuid, String playerName, String uuid, ConfigParam cEnum) {
|
||||
this.pathPlayerListPath = listPath;
|
||||
this.pathPlayerName = pathPlayerName;
|
||||
this.pathPlayerUuid = pathUuid;
|
||||
this.valuePlayerName = playerName;
|
||||
this.valuePlayerUuid = uuid;
|
||||
this.cEnum = cEnum;
|
||||
enable("permissionWhitelist.enable", false, true),
|
||||
playerWithPermissionKick("permissionWhitelist.playerWithPermissionKick", true, true),
|
||||
permissions("permissionWhitelist.permissions", Arrays.asList("*", "t2c.opsecurity.admin"), true),
|
||||
customCommandsEnable("permissionWhitelist.customCommands.enable", false, true),
|
||||
customCommandsCommands("permissionWhitelist.customCommands.commands", Arrays.asList("lp user [player] permission unset *", "lp user [player] permission unset t2c.opsecurity.admin"), true),
|
||||
|
||||
playerSection("permissionWhitelist.whitelist", null, true),
|
||||
player1name("permissionWhitelist.whitelist.player1.name", "player1", false),
|
||||
player1uuid("permissionWhitelist.whitelist.player1.uuid", "00000000000000000000000000000000", false),
|
||||
player2name("permissionWhitelist.whitelist.player2.name", "player2", false),
|
||||
player2uuid("permissionWhitelist.whitelist.player2.uuid", "00000000000000000000000000000000", false),
|
||||
|
||||
;
|
||||
|
||||
private final String path;
|
||||
private Object value;
|
||||
private final boolean forceSet;
|
||||
private final List<String> comments;
|
||||
|
||||
VALUES(String path, Object value, boolean forceSet, String... comments) {
|
||||
this.path = path;
|
||||
this.value = value;
|
||||
this.forceSet = forceSet;
|
||||
this.comments = new ArrayList<>(Arrays.asList(comments));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getForceSet() {
|
||||
return forceSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getComments() {
|
||||
return comments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Object newValue) {
|
||||
value = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
PermissionWhitelist(String path, List<String> value, ConfigParam cEnum) {
|
||||
this.path = path;
|
||||
this.valueStringList = value;
|
||||
this.cEnum = cEnum;
|
||||
public static void set() {
|
||||
long long_ = System.currentTimeMillis();
|
||||
T2CconfigWriter.createConfig(new File(Main.getPath(), "permissionWhitelist.yml"), VALUES.values(), Util.getConfigLogo());
|
||||
player();
|
||||
|
||||
T2Ctemplate.onStartMsg(Util.getPrefix(), "§2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||
}
|
||||
|
||||
PermissionWhitelist(String path, Boolean value, ConfigParam cEnum) {
|
||||
this.path = path;
|
||||
this.valueBoolean = value;
|
||||
this.cEnum = cEnum;
|
||||
|
||||
private static void player() {
|
||||
ConfigurationSection section = (ConfigurationSection) VALUES.playerSection.getValue();
|
||||
for (String key : section.getConfigurationSection("").getKeys(false)) {
|
||||
String name = section.getString(key + ".name");
|
||||
PlayerObject playerObject = new PlayerObject(
|
||||
name,
|
||||
section.getString(key + ".uuid").replace("-", ""));
|
||||
PlayerCache.getOpHashMap().put(name, playerObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,38 +1,42 @@
|
||||
package net.t2code.opsecurity.events;
|
||||
|
||||
import com.sun.org.apache.xerces.internal.xs.StringList;
|
||||
import net.t2code.opsecurity.Util;
|
||||
import net.t2code.opsecurity.config.config.Config;
|
||||
import net.t2code.opsecurity.check.OpCheck;
|
||||
import net.t2code.opsecurity.check.PermissionCheck;
|
||||
import net.t2code.opsecurity.config.config.Config;
|
||||
import net.t2code.opsecurity.system.Main;
|
||||
import net.t2code.opsecurity.system.Permissions;
|
||||
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Events implements Listener {
|
||||
public static void notifyPlayer(String msg) {
|
||||
if (!Config.notifyJoinWarning.valueBoolean) return;
|
||||
if (!(boolean) Config.VALUES.notifyJoinWarning.getValue()) return;
|
||||
for (Player notifyPlayer : Bukkit.getOnlinePlayers()) {
|
||||
if (!notifyPlayer.hasPermission(Permissions.notify)) continue;
|
||||
T2Csend.player(notifyPlayer, msg);
|
||||
if (Config.notifySoundEnable.valueBoolean) notifyPlayer.playSound(notifyPlayer.getLocation(), Config.notifySoundValue.sound, 3, 1);
|
||||
if ((boolean) Config.VALUES.notifySoundEnable.getValue()) notifyPlayer.playSound(notifyPlayer.getLocation(), Sound.valueOf(Config.VALUES.notifySoundValue.getValue().toString()), 3, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void CommandSendEvent(PlayerCommandPreprocessEvent event) {
|
||||
if (!Config.checkOnCommand.valueBoolean) return;
|
||||
if (!(boolean) Config.VALUES.checkOnCommand.getValue()) return;
|
||||
Player player = event.getPlayer();
|
||||
String debug = T2Cdebug.debugCode();
|
||||
|
||||
for (String s : Config.checkOnCommandWhitelist.valueStringList){
|
||||
if (event.getMessage().startsWith("/"+s)) {
|
||||
for (String s : (StringList) Config.VALUES.checkOnCommandWhitelist.getValue()) {
|
||||
if (event.getMessage().startsWith("/" + s)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -51,7 +55,7 @@ public class Events implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void PlayerChatEvent(PlayerChatEvent event) {
|
||||
if (!Config.checkOnChat.valueBoolean) return;
|
||||
if (!(boolean) Config.VALUES.checkOnChat.getValue()) return;
|
||||
Player player = event.getPlayer();
|
||||
String debug = T2Cdebug.debugCode();
|
||||
if (OpCheck.onCheck(player, false, debug)) {
|
||||
@ -67,7 +71,7 @@ public class Events implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEvent event) {
|
||||
if (!Config.checkOnInteract.valueBoolean) return;
|
||||
if (!(boolean) Config.VALUES.checkOnInteract.getValue()) return;
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(Main.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -86,7 +90,7 @@ public class Events implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onJoinCheck(PlayerJoinEvent event) {
|
||||
if (!Config.checkOnJoin.valueBoolean) return;
|
||||
if (!(boolean) Config.VALUES.checkOnJoin.getValue()) return;
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(Main.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -22,7 +22,7 @@ import java.util.Map;
|
||||
public class OpCommand implements Listener {
|
||||
@EventHandler
|
||||
public void onOPServer(ServerCommandEvent event) {
|
||||
if (!OPWhitelist.enable.valueBoolean) return;
|
||||
if (!(boolean) OPWhitelist.VALUES.enable.getValue()) return;
|
||||
if ((event.getCommand().toLowerCase().startsWith("op ") || event.getCommand().toLowerCase().startsWith("minecraft:op "))) {
|
||||
switch (isNotOPWTL(event.getCommand())) {
|
||||
case mustOnline:
|
||||
@ -39,7 +39,7 @@ public class OpCommand implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onOpPlayer(PlayerCommandPreprocessEvent event) {
|
||||
if (!OPWhitelist.enable.valueBoolean) return;
|
||||
if (!(boolean) OPWhitelist.VALUES.enable.getValue()) return;
|
||||
if ((event.getMessage().toLowerCase().startsWith("/op ") || event.getMessage().toLowerCase().startsWith("/minecraft:op "))) {
|
||||
switch (isNotOPWTL(event.getMessage())) {
|
||||
case mustOnline:
|
||||
@ -59,7 +59,7 @@ public class OpCommand implements Listener {
|
||||
String arg = command.replace("op ", "");
|
||||
Player target = Bukkit.getPlayer(arg);
|
||||
|
||||
if (OPWhitelist.playerMustBeOnlineToOp.valueBoolean) {
|
||||
if ((boolean)OPWhitelist.VALUES.playerMustBeOnlineToOp.getValue()) {
|
||||
if (target == null) return OpCommandRequest.mustOnline;
|
||||
if (!opWhitelist(target.getName(), target.getUniqueId().toString())) return OpCommandRequest.notWhitelisted;
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ import net.t2code.opsecurity.command.CmdExecuter;
|
||||
import net.t2code.opsecurity.config.FileSelect;
|
||||
import net.t2code.opsecurity.config.config.Config;
|
||||
import net.t2code.opsecurity.config.config.Converter;
|
||||
import net.t2code.opsecurity.config.opWhitelist.OPWhitelist;
|
||||
import net.t2code.opsecurity.config.permissionWhitelist.PermissionWhitelist;
|
||||
import net.t2code.opsecurity.events.Events;
|
||||
import net.t2code.opsecurity.events.OpCommand;
|
||||
import net.t2code.opsecurity.events.PlugManCommand;
|
||||
@ -13,10 +15,10 @@ import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
||||
import net.t2code.t2codelib.SPIGOT.api.register.T2Cregister;
|
||||
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
|
||||
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.checkerframework.checker.units.qual.C;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -34,37 +36,26 @@ public class Load {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
FileSelect.selectConfig();
|
||||
FileSelect.selectLanguage();
|
||||
FileSelect.selectOpWhitelist();
|
||||
FileSelect.selectPermissionWhitelist();
|
||||
Config.set();
|
||||
|
||||
setConfigVersion();
|
||||
FileSelect.selectLanguage();
|
||||
OPWhitelist.set();
|
||||
PermissionWhitelist.set();
|
||||
|
||||
plugin.getCommand("t2c-opsecurity").setExecutor(new CmdExecuter());
|
||||
|
||||
T2Cregister.listener(new OpCommand(), plugin);
|
||||
T2Cregister.listener(new PlugManCommand(), plugin);
|
||||
T2Cregister.listener(new Events(), plugin);
|
||||
if (SelectLibConfig.getBungee()) {
|
||||
if ((boolean) T2CLibConfig.VALUES.proxy.getValue()) {
|
||||
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "t2c:opsec");
|
||||
T2Csend.debug(plugin, "registerIncomingPluginChannel §et2c:opsec");
|
||||
}
|
||||
Timer.refreshTimer();
|
||||
Permissions.register();
|
||||
T2CupdateAPI.onUpdateCheck(plugin, Util.getPrefix(),Util.getGit(),Util.getSpigotID(),Util.getDiscord(), Config.updateCheckOnJoin.valueBoolean,
|
||||
Config.updateCheckSeePreReleaseUpdates.valueBoolean, Config.updateCheckTimeInterval.valueInt);
|
||||
T2CupdateAPI.onUpdateCheck(plugin, Util.getPrefix(), Util.getGit(), Util.getSpigotID(), Util.getDiscord(), (boolean) Config.VALUES.updateCheckOnJoin.getValue(),
|
||||
(boolean) Config.VALUES.updateCheckSeePreReleaseUpdates.getValue(), (int) Config.VALUES.updateCheckTimeInterval.getValue());
|
||||
Metrics.Bstats(plugin, Util.getBstatsID());
|
||||
T2Ctemplate.onLoadFooter(Util.getPrefix(), long_);
|
||||
}
|
||||
public static void setConfigVersion() {
|
||||
File config = new File(Main.getPath(), "config.yml");
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
yamlConfiguration.set("configVersion", Util.getConfigVersion());
|
||||
try {
|
||||
yamlConfiguration.save(config);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user