diff --git a/pom.xml b/pom.xml index 7563c24..0c5cfdb 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ de.jatitv OPSecurity - 2.4.3 + 2.4.3-DEV-1 jar OPSecurity diff --git a/src/main/java/de/jatitv/opsecurity/cmdManagement/CmdExecuter.java b/src/main/java/de/jatitv/opsecurity/cmdManagement/CmdExecuter.java index 39b5c4c..4d0ed81 100644 --- a/src/main/java/de/jatitv/opsecurity/cmdManagement/CmdExecuter.java +++ b/src/main/java/de/jatitv/opsecurity/cmdManagement/CmdExecuter.java @@ -23,7 +23,7 @@ public class CmdExecuter implements CommandExecutor, TabCompleter { if (args.length == 0) { Commands.mainCommand(sender); } else { - if (SelectConfig.OnlyOPcanUseThePlugin) { + if (SelectConfig.onlyOPcanUseThePlugin) { if (!sender.isOp()) { sender.sendMessage(Util.getPrefix() + "§cOnly OPs can use OPSecurity!"); return false; diff --git a/src/main/java/de/jatitv/opsecurity/cmdManagement/Commands.java b/src/main/java/de/jatitv/opsecurity/cmdManagement/Commands.java index 76d3af6..14c2414 100644 --- a/src/main/java/de/jatitv/opsecurity/cmdManagement/Commands.java +++ b/src/main/java/de/jatitv/opsecurity/cmdManagement/Commands.java @@ -6,22 +6,17 @@ import de.jatitv.opsecurity.config.config.SelectConfig; import de.jatitv.opsecurity.system.Load; import de.jatitv.opsecurity.system.Main; import de.jatitv.opsecurity.system.Permissions; -import net.md_5.bungee.api.chat.ClickEvent; -import net.md_5.bungee.api.chat.TextComponent; import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate; import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.update.UpdateAPI; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; - -import java.util.List; public class Commands { public static void mainCommand(CommandSender sender) { - if (SelectConfig.OnlyOPcanUseThePlugin) { + if (SelectConfig.onlyOPcanUseThePlugin) { if (!sender.isOp()) { sender.sendMessage(Util.getPrefix() + "§cOnly OPs can use OPSecurity!"); return; diff --git a/src/main/java/de/jatitv/opsecurity/config/config/CreateConfig.java b/src/main/java/de/jatitv/opsecurity/config/config/CreateConfig.java index f95a0e3..3b548ab 100644 --- a/src/main/java/de/jatitv/opsecurity/config/config/CreateConfig.java +++ b/src/main/java/de/jatitv/opsecurity/config/config/CreateConfig.java @@ -14,56 +14,7 @@ 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 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 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 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 LP_Whitelist = Arrays.asList("player1", "player2"); + private static String Prefix = "§8[§2OP§4Security§8] "; public static void configCreate() { Bukkit.getConsoleSender().sendMessage(Prefix + "§4config.yml load..."); @@ -71,53 +22,54 @@ public class CreateConfig { File configYML = new File(Main.plugin.getDataFolder().getPath(), "config.yml"); YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(configYML); - yamlConfiguration.set("ConfigVersion", ConfigVersion); + yamlConfiguration.set("ConfigVersion", 3); - set("Plugin.UpdateCheckOnJoin", UpdateCheckOnJoin, yamlConfiguration); - set("Plugin.language", language, yamlConfiguration); + set("Plugin.UpdateCheckOnJoin", true, yamlConfiguration); + set("Plugin.language", "english", yamlConfiguration); + set("Plugin.OnlyOPcanUseThePlugin", true, yamlConfiguration); + set("Plugin.Bungee", false, 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("Check.OnJoin", true, yamlConfiguration); + set("Check.OnInteract", true, yamlConfiguration); + set("Check.OnCommand", true, yamlConfiguration); + set("Check.OnChat", true, yamlConfiguration); + set("Check.Timer.Enable", true, yamlConfiguration); + set("Check.Timer.RefreshTime_inSec", 60, yamlConfiguration); - set("Kick.Command", KickCommand, yamlConfiguration); - set("Notify.JoinWarn.Enable", Notify_Warn, yamlConfiguration); - set("Notify.Sound.Enable", Notify_Sound_Enable, yamlConfiguration); + set("Kick.Command", "minecraft:kick [player] [reason]", yamlConfiguration); + set("Notify.JoinWarn.Enable", true, yamlConfiguration); + set("Notify.Sound.Enable", true, yamlConfiguration); if (MCVersion.minecraft1_8) { - set("Notify.Sound.Sound", Notify_Sound_1_8, yamlConfiguration); + set("Notify.Sound.Sound", "NOTE_PIANO", yamlConfiguration); } else if (MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) { - set("Notify.Sound.Sound", Notify_Sound_1_9_to_1_12, yamlConfiguration); - } else set("Notify.Sound.Sound", Notify_Sound_from_1_13, yamlConfiguration); + set("Notify.Sound.Sound", "BLOCK_NOTE_HARP", yamlConfiguration); + } else set("Notify.Sound.Sound", "BLOCK_NOTE_BLOCK_HARP", yamlConfiguration); - set("OP_Whitelist.Enable", OP_Whitelist_Enable, yamlConfiguration); - set("OP_Whitelist.PlayerMustBeOnlineToOp", PlayerMustBeOnlineToOp, yamlConfiguration); + set("OP_Whitelist.Enable", false, yamlConfiguration); + set("OP_Whitelist.PlayerMustBeOnlineToOp", true, 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.Whitelist." + "player1" + ".UUID", "00000000-0000-0000-0000-000000000000", yamlConfiguration); + set("OP_Whitelist.Whitelist." + "player2" + ".UUID", "00000000-0000-0000-0000-000000000000", 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("OP_Whitelist.noOpPlayerDeop.Enable", true, yamlConfiguration); + set("OP_Whitelist.noOpPlayerDeop.PlayerSendMessage", true, yamlConfiguration); + set("OP_Whitelist.noOpPlayerKick.Enable", true, yamlConfiguration); + set("OP_Whitelist.customCommands.Enable", false, yamlConfiguration); + set("OP_Whitelist.customCommands.Commands", Arrays.asList("kick [player] &4You have op but are not authorized to do so, that's why you were kicked!"), yamlConfiguration); - set("Permission_Whitelist.Enable", Permission_Whitelist_Enable, yamlConfiguration); - set("Permission_Whitelist.Permissions", Permissions, yamlConfiguration); + set("Permission_Whitelist.Enable", false, yamlConfiguration); + set("Permission_Whitelist.Permissions", Arrays.asList("*", "opsecurity.admin"), 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.Whitelist." + "player1" + ".UUID", "00000000-0000-0000-0000-000000000000", yamlConfiguration); + set("Permission_Whitelist.Whitelist." + "player2" + ".UUID", "00000000-0000-0000-0000-000000000000", 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("Permission_Whitelist.PlayerWhithPermission_kick", true, yamlConfiguration); + set("Permission_Whitelist.customCommands.Enable", false, yamlConfiguration); + set("Permission_Whitelist.customCommands.Commands", Arrays.asList("lp user [player] permission unset *", "lp user [player] permission unset opsecurity.admin"), yamlConfiguration); //set("LuckPerms_Whitelist.Enable", LP_Enable, yamlConfiguration); //set("LuckPerms_Whitelist.AllowFromConsole", LP_AllowFromConsole, yamlConfiguration); diff --git a/src/main/java/de/jatitv/opsecurity/config/config/SelectConfig.java b/src/main/java/de/jatitv/opsecurity/config/config/SelectConfig.java index f415e95..fd8b35b 100644 --- a/src/main/java/de/jatitv/opsecurity/config/config/SelectConfig.java +++ b/src/main/java/de/jatitv/opsecurity/config/config/SelectConfig.java @@ -6,7 +6,6 @@ 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; @@ -20,47 +19,44 @@ public class SelectConfig { // Config - public static Integer ConfigVersion; + public static Integer configVersion; - public static Boolean UpdateCheckOnJoin; + 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 Boolean onlyOPcanUseThePlugin; + public static Boolean bungee; + public static Boolean checkOnJoin; + public static Boolean checkOnInteract; + public static Boolean checkOnCommand; + public static Boolean checkOnChat; - public static String KickCommand; + 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 notifyWarn; + public static Boolean notifySoundEnable; + public static Sound notifySound; + public static String notifySoundInput; - public static Boolean Timer_Enable; - public static int RefreshTime; + public static Boolean timerEnable; + public static int refreshTime; - public static Boolean OP_Whitelist_Enable; - public static Boolean PlayerMustBeOnlineToOp; + public static Boolean opWhitelistEnable; + public static Boolean playerMustBeOnlineToOp; - public static Boolean no_OP_Player_deop; + public static Boolean noOPPlayerDeop; public static Boolean sendPlayerDEOPmsg; - public static Boolean no_OP_Player_kick; - public static Boolean customCommand_Enable; + public static Boolean nooPPlayerKick; + public static Boolean customCommandEnable; public static List customKickCommand; - public static Boolean Permission_Whitelist_Enable; + public static Boolean permissionWhitelistEnable; 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; + public static Boolean permCommandEnable; + public static List permCommand; //help @@ -86,25 +82,26 @@ public class SelectConfig { Main.opHashMap.clear(); Main.permissionHashMap.clear(); - ConfigVersion = yamlConfiguration.getInt("ConfigVersion"); + configVersion = yamlConfiguration.getInt("ConfigVersion"); - UpdateCheckOnJoin = yamlConfiguration.getBoolean("Plugin.UpdateCheckOnJoin"); + 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"); + onlyOPcanUseThePlugin = yamlConfiguration.getBoolean("Plugin.OnlyOPcanUseThePlugin"); + bungee = yamlConfiguration.getBoolean("Plugin.Bungee"); + 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"); - Notify_Warn = yamlConfiguration.getBoolean("Notify.JoinWarn.Enable"); - Notify_Sound_Enable = yamlConfiguration.getBoolean("Notify.Sound.Enable"); - Notify_Sound_input = yamlConfiguration.getString("Notify.Sound.Sound"); + kickCommand = yamlConfiguration.getString("Kick.Command"); + notifyWarn = yamlConfiguration.getBoolean("Notify.JoinWarn.Enable"); + notifySoundEnable = yamlConfiguration.getBoolean("Notify.Sound.Enable"); + notifySoundInput = yamlConfiguration.getString("Notify.Sound.Sound"); - OP_Whitelist_Enable = yamlConfiguration.getBoolean("OP_Whitelist.Enable"); - PlayerMustBeOnlineToOp = yamlConfiguration.getBoolean("OP_Whitelist.PlayerMustBeOnlineToOp"); + opWhitelistEnable = 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)) { @@ -114,12 +111,12 @@ public class SelectConfig { Main.opHashMap.put(key.toLowerCase(), player); } - no_OP_Player_deop = yamlConfiguration.getBoolean("OP_Whitelist.noOpPlayerDeop.Enable"); + noOPPlayerDeop = 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"); + nooPPlayerKick = yamlConfiguration.getBoolean("OP_Whitelist.noOpPlayerKick.Enable"); + customCommandEnable = yamlConfiguration.getBoolean("OP_Whitelist.customCommands.Enable"); customKickCommand = yamlConfiguration.getStringList("OP_Whitelist.customCommands.Commands"); - Permission_Whitelist_Enable = yamlConfiguration.getBoolean("Permission_Whitelist.Enable"); + permissionWhitelistEnable = yamlConfiguration.getBoolean("Permission_Whitelist.Enable"); permissions = yamlConfiguration.getStringList("Permission_Whitelist.Permissions"); ArrayList permWhitelist = new ArrayList<>(); @@ -131,14 +128,11 @@ public class SelectConfig { } 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"); + permCommandEnable = yamlConfiguration.getBoolean("Permission_Whitelist.customCommands.Enable"); + permCommand = yamlConfiguration.getStringList("Permission_Whitelist.customCommands.Commands"); } 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()); + notifySound = Config.checkSound("NOTE_PIANO", "BLOCK_NOTE_HARP", "BLOCK_NOTE_BLOCK_HARP", notifySoundInput, Util.getPrefix()); } } diff --git a/src/main/java/de/jatitv/opsecurity/config/languages/LanguagesCreate.java b/src/main/java/de/jatitv/opsecurity/config/languages/LanguagesCreate.java index 1b81816..fd4db0b 100644 --- a/src/main/java/de/jatitv/opsecurity/config/languages/LanguagesCreate.java +++ b/src/main/java/de/jatitv/opsecurity/config/languages/LanguagesCreate.java @@ -26,12 +26,12 @@ public class LanguagesCreate { set("Plugin.Reload.Start", MSG.DE_ReloadStart, yamlConfigurationDE); set("Plugin.Reload.End", MSG.DE_ReloadEnd, yamlConfigurationDE); - set("OP_Whitelist.opCommand", MSG.DE_OP_opCommand, yamlConfigurationDE); - set("OP_Whitelist.consoleOnJoin", MSG.DE_OP_consoleOnJoin, yamlConfigurationDE); - set("OP_Whitelist.deop", MSG.DE_OP_deop, yamlConfigurationDE); - set("OP_Whitelist.consoleDeop", MSG.DE_OP_consoleDeop, yamlConfigurationDE); - set("OP_Whitelist.kick", MSG.DE_OP_kick, yamlConfigurationDE); - set("OP_Whitelist.consoleKick", MSG.DE_OP_consoleKick, yamlConfigurationDE); + set("OP_Whitelist.opCommand", MSG.DE_OP_notifyNotOnWhitelist, yamlConfigurationDE); + set("OP_Whitelist.consoleOnJoin", MSG.DE_OP_notifyNotOnWhiteListJoin, yamlConfigurationDE); + set("OP_Whitelist.deop", MSG.DE_OP_ReasonDeop, yamlConfigurationDE); + set("OP_Whitelist.consoleDeop", MSG.DE_OP_playerDeop, yamlConfigurationDE); + set("OP_Whitelist.kick", MSG.DE_OP_ReasonKick, yamlConfigurationDE); + set("OP_Whitelist.consoleKick", MSG.DE_OP_notifyKick, yamlConfigurationDE); set("Permission_Whitelist.consoleOnJoin", MSG.DE_Perm_consoleOnJoin, yamlConfigurationDE); set("Permission_Whitelist.kick", MSG.DE_Perm_kick, yamlConfigurationDE); set("Permission_Whitelist.consoleKick", MSG.DE_Perm_consoleKick, yamlConfigurationDE); diff --git a/src/main/java/de/jatitv/opsecurity/config/languages/MSG.java b/src/main/java/de/jatitv/opsecurity/config/languages/MSG.java index 30ede80..049a511 100644 --- a/src/main/java/de/jatitv/opsecurity/config/languages/MSG.java +++ b/src/main/java/de/jatitv/opsecurity/config/languages/MSG.java @@ -29,14 +29,14 @@ public class MSG { public static String DE_ReloadStart = "[prefix] &6Plugin wird neu geladen..."; public static String DE_ReloadEnd = "[prefix] &2Plugin wurde erfolgreich neu geladen."; - public static String DE_OP_opCommand = "&4Der angegebene Spieler befindet sich nicht auf der OP_Whitelist!"; - public static String DE_OP_consoleOnJoin = "&4Spieler &6[player] &4ist dem Server beigetreten, befindet sich aber nicht auf der OP_Whitelist!"; - public static String DE_OP_deop = "&4You have been removed from OP because you do not have permission.\n" + + public static String DE_OP_notifyNotOnWhitelist = "&4Der angegebene Spieler befindet sich nicht auf der OP_Whitelist!"; + public static String DE_OP_notifyNotOnWhiteListJoin = "&4Spieler &6[player] &4ist dem Server beigetreten, befindet sich aber nicht auf der OP_Whitelist!"; + public static String DE_OP_ReasonDeop = "&4You have been removed from OP because you do not have permission.\n" + "&4Dir wurde OP entfernt da du dazu keine Permission besitzt."; - public static String DE_OP_consoleDeop = "&4Spieler &6[player] &4 wurde OP entfernt da er nicht auf der Spielerliste steht!"; - public static String DE_OP_kick = "&4You have op but are not authorized to do so, that's why you were kicked\n" + + public static String DE_OP_playerDeop = "&4Spieler &6[player] &4 wurde OP entfernt da er nicht auf der Spielerliste steht!"; + public static String DE_OP_ReasonKick = "&4You have op but are not authorized to do so, that's why you were kicked\n" + "&4Du hast op bist dazu aber nicht berechtigt, deswegen wurdest du gekickt!"; - public static String DE_OP_consoleKick = "&4Spieler &6[player] &4wurde gekickt, da er nicht auf der OP_Whitelist steht!"; + public static String DE_OP_notifyKick = "&4Spieler &6[player] &4wurde gekickt, da er nicht auf der OP_Whitelist steht!"; public static String DE_ExactKickReason = "[prefix] &4Genauer Grund: &6[reason]"; public static String DE_Perm_consoleOnJoin = "&4Player &6[player] &4hat die Permission &6[perm] &4und ist dazu nicht berechtigt! &6[player] &4ist nicht in der Spielerliste!"; diff --git a/src/main/java/de/jatitv/opsecurity/config/languages/SelectMessages.java b/src/main/java/de/jatitv/opsecurity/config/languages/SelectMessages.java index 353b570..659546f 100644 --- a/src/main/java/de/jatitv/opsecurity/config/languages/SelectMessages.java +++ b/src/main/java/de/jatitv/opsecurity/config/languages/SelectMessages.java @@ -24,7 +24,7 @@ public class SelectMessages { public static String ReloadEnd; public static String OP_opCommand; - public static String OP_consoleOnJoin; + public static String opConsoleOnJoin; public static String OP_deop; public static String OP_consoleDeop; public static String OP_kick; @@ -66,7 +66,7 @@ public class SelectMessages { OP_opCommand = select("OP_Whitelist.opCommand", yamlConfiguration); OP_deop = select("OP_Whitelist.deop", yamlConfiguration); OP_consoleDeop = select("OP_Whitelist.consoleDeop", yamlConfiguration); - OP_consoleOnJoin = select("OP_Whitelist.consoleOnJoin", yamlConfiguration); + opConsoleOnJoin = select("OP_Whitelist.consoleOnJoin", yamlConfiguration); OP_kick = select("OP_Whitelist.kick", yamlConfiguration); OP_consoleKick = select("OP_Whitelist.consoleKick", yamlConfiguration); diff --git a/src/main/java/de/jatitv/opsecurity/listener/Check.java b/src/main/java/de/jatitv/opsecurity/listener/CheckOLD.java similarity index 83% rename from src/main/java/de/jatitv/opsecurity/listener/Check.java rename to src/main/java/de/jatitv/opsecurity/listener/CheckOLD.java index 340edd9..5b2d490 100644 --- a/src/main/java/de/jatitv/opsecurity/listener/Check.java +++ b/src/main/java/de/jatitv/opsecurity/listener/CheckOLD.java @@ -1,8 +1,8 @@ package de.jatitv.opsecurity.listener; import de.jatitv.opsecurity.Util; -import de.jatitv.opsecurity.config.languages.SelectMessages; import de.jatitv.opsecurity.config.config.SelectConfig; +import de.jatitv.opsecurity.config.languages.SelectMessages; import de.jatitv.opsecurity.system.Main; import de.jatitv.opsecurity.system.Permissions; import net.t2code.lib.Spigot.Lib.commands.Cmd; @@ -12,37 +12,37 @@ import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; -public class Check { +public class CheckOLD { public static Boolean onCheck(Player player, Boolean join) { - if (SelectConfig.OP_Whitelist_Enable) { + if (SelectConfig.opWhitelistEnable) { if (player.isOp()) { - if (opWhitelist(player)) { + if (checkOpWhitelist(player)) { return false; } if (join) { - send.console(Replace.replace(Util.getPrefix(),SelectMessages.OP_consoleOnJoin.replace("[player]", player.getName()))); + send.console(Replace.replace(Util.getPrefix(),SelectMessages.opConsoleOnJoin.replace("[player]", player.getName()))); } - if (SelectConfig.Notify_Warn) { + if (SelectConfig.notifyWarn) { for (Player notifyperm : Bukkit.getOnlinePlayers()) { if (notifyperm.hasPermission(Permissions.notify)) { if (join) { - notifyperm.sendMessage(Replace.replace(Util.getPrefix(),SelectMessages.OP_consoleOnJoin.replace("[player]", player.getName()))); + notifyperm.sendMessage(Replace.replace(Util.getPrefix(),SelectMessages.opConsoleOnJoin.replace("[player]", player.getName()))); } else notifyperm.sendMessage(Replace.replace(Util.getPrefix(),SelectMessages.OP_consoleKick.replace("[player]", player.getName()))); - if (SelectConfig.Notify_Sound_Enable) { - notifyperm.playSound(player.getLocation(), SelectConfig.Notify_Sound, 3, 1); + if (SelectConfig.notifySoundEnable) { + notifyperm.playSound(player.getLocation(), SelectConfig.notifySound, 3, 1); } } } } - if (SelectConfig.no_OP_Player_kick && SelectConfig.no_OP_Player_deop) { + if (SelectConfig.nooPPlayerKick && SelectConfig.noOPPlayerDeop) { player.setOp(false); - Cmd.console(SelectConfig.KickCommand.replace("[player]", player.getName()) + Cmd.console(SelectConfig.kickCommand.replace("[player]", player.getName()) .replace("[reason]", Replace.replace(Util.getPrefix(),SelectMessages.OP_kick + "\n" + "\n" + SelectMessages.OP_deop))); send.console(Replace.replace(Util.getPrefix(),SelectMessages.OP_consoleKick.replace("[player]", player.getName()))); return true; } else { - if (SelectConfig.no_OP_Player_kick) { - Cmd.console(SelectConfig.KickCommand.replace("[player]", player.getName()).replace("[reason]", Replace.replace(Util.getPrefix(),SelectMessages.OP_kick))); + if (SelectConfig.nooPPlayerKick) { + Cmd.console(SelectConfig.kickCommand.replace("[player]", player.getName()).replace("[reason]", Replace.replace(Util.getPrefix(),SelectMessages.OP_kick))); send.console(Replace.replace(Util.getPrefix(),SelectMessages.OP_consoleKick.replace("[player]", player.getName()))); for (Player notifyperm : Bukkit.getOnlinePlayers()) { if (notifyperm.hasPermission(Permissions.notify)) { @@ -52,7 +52,7 @@ public class Check { } return true; } - if (SelectConfig.no_OP_Player_deop) { + if (SelectConfig.noOPPlayerDeop) { player.setOp(false); if (SelectConfig.sendPlayerDEOPmsg) { new BukkitRunnable() { @@ -72,7 +72,7 @@ public class Check { return true; } } - if (SelectConfig.customCommand_Enable) { + if (SelectConfig.customCommandEnable) { new BukkitRunnable() { @Override public void run() { @@ -86,14 +86,14 @@ public class Check { } } - if (SelectConfig.Permission_Whitelist_Enable) { + if (SelectConfig.permissionWhitelistEnable) { for (String s : SelectConfig.permissions) { if (player.hasPermission(s)) { - if (!permWhitelist(player)) { + if (!checkPermWhitelist(player)) { if (join) { send.console(Replace.replace(Util.getPrefix(),SelectMessages.Perm_consoleOnJoin.replace("[player]", player.getName()).replace("[perm]", s))); } - if (SelectConfig.Notify_Warn) { + if (SelectConfig.notifyWarn) { for (Player notifyperm : Bukkit.getOnlinePlayers()) { if (notifyperm.hasPermission(Permissions.notify)) { if (join) { @@ -101,30 +101,30 @@ public class Check { player.getName()).replace("[perm]", s))); } else notifyperm.sendMessage(Replace.replace(Util.getPrefix(),SelectMessages.Perm_consoleKick.replace("[player]", player.getName()).replace("[perm]", s))); - if (SelectConfig.Notify_Sound_Enable) { - notifyperm.playSound(player.getLocation(), SelectConfig.Notify_Sound, 3, 1); + if (SelectConfig.notifySoundEnable) { + notifyperm.playSound(player.getLocation(), SelectConfig.notifySound, 3, 1); } } } } - if (SelectConfig.PlayerWhithPermission_kick && SelectConfig.Perm_Command_enable) { - Cmd.console(SelectConfig.KickCommand.replace("[player]", player.getName()).replace("[reason]", Replace.replace(Util.getPrefix(),SelectMessages.Perm_kick))); + if (SelectConfig.PlayerWhithPermission_kick && SelectConfig.permCommandEnable) { + Cmd.console(SelectConfig.kickCommand.replace("[player]", player.getName()).replace("[reason]", Replace.replace(Util.getPrefix(),SelectMessages.Perm_kick))); send.console(Replace.replace(Util.getPrefix(),SelectMessages.Perm_consoleKick.replace("[player]", player.getName()).replace("[perm]", s))); - for (String cmd : SelectConfig.Perm_Command) { + for (String cmd : SelectConfig.permCommand) { Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), cmd.replace("[player]", player.getName()).replace("[perm]", s)); } return true; } if (SelectConfig.PlayerWhithPermission_kick) { - Cmd.console(SelectConfig.KickCommand.replace("[player]", player.getName()).replace("[reason]", Replace.replace(Util.getPrefix(),SelectMessages.Perm_kick))); + Cmd.console(SelectConfig.kickCommand.replace("[player]", player.getName()).replace("[reason]", Replace.replace(Util.getPrefix(),SelectMessages.Perm_kick))); send.console(Replace.replace(Util.getPrefix(),SelectMessages.Perm_consoleKick.replace("[player]", player.getName()).replace("[perm]", s))); return true; } - if (SelectConfig.Perm_Command_enable) { - for (String cmd : SelectConfig.Perm_Command) { + if (SelectConfig.permCommandEnable) { + for (String cmd : SelectConfig.permCommand) { Cmd.console(cmd.replace("[player]", player.getName()).replace("[perm]", s)); } return true; @@ -137,7 +137,11 @@ public class Check { return false; } - private static Boolean opWhitelist(Player player) { + private static void opSec(Player player){ + + } + + private static Boolean checkOpWhitelist(Player player) { if (Main.opHashMap.containsKey(player.getName().toLowerCase())) { if (Main.opHashMap.get(player.getName().toLowerCase()).UUID.equals(player.getUniqueId().toString().replace("-", ""))) { return true; @@ -151,7 +155,7 @@ public class Check { } } - private static Boolean permWhitelist(Player player) { + private static Boolean checkPermWhitelist(Player player) { if (Main.permissionHashMap.containsKey(player.getName().toLowerCase())) { if (Main.permissionHashMap.get(player.getName().toLowerCase()).UUID.equals(player.getUniqueId().toString().replace("-", ""))) { return true; diff --git a/src/main/java/de/jatitv/opsecurity/listener/Events.java b/src/main/java/de/jatitv/opsecurity/listener/Events.java index c613a04..d4a7c46 100644 --- a/src/main/java/de/jatitv/opsecurity/listener/Events.java +++ b/src/main/java/de/jatitv/opsecurity/listener/Events.java @@ -4,6 +4,7 @@ package de.jatitv.opsecurity.listener; import de.jatitv.opsecurity.Util; import de.jatitv.opsecurity.config.config.SelectConfig; +import de.jatitv.opsecurity.listener.opWhitelist.Check; import de.jatitv.opsecurity.system.Main; import net.t2code.lib.Spigot.Lib.update.UpdateAPI; import org.bukkit.entity.Player; @@ -15,7 +16,7 @@ public class Events implements org.bukkit.event.Listener { @EventHandler public void CommandSendEvent(PlayerCommandPreprocessEvent event) { - if (SelectConfig.CheckOnCommand) { + if (SelectConfig.checkOnCommand) { Player player = event.getPlayer(); if (Check.onCheck(player, false)) { if (event.isCancelled()) return; @@ -26,7 +27,7 @@ public class Events implements org.bukkit.event.Listener { @EventHandler public void PlayerChatEvent(PlayerChatEvent event) { - if (SelectConfig.CheckOnChat) { + if (SelectConfig.checkOnChat) { Player player = event.getPlayer(); if (Check.onCheck(player, false)) { if (event.isCancelled()) return; @@ -37,7 +38,7 @@ public class Events implements org.bukkit.event.Listener { @EventHandler public void onInteract(PlayerInteractEvent event) { - if (SelectConfig.CheckOnInteract) { + if (SelectConfig.checkOnInteract) { Player player = event.getPlayer(); new BukkitRunnable() { @Override @@ -50,7 +51,7 @@ public class Events implements org.bukkit.event.Listener { @EventHandler public void onJoinCheck(PlayerJoinEvent event) { - if (SelectConfig.CheckOnJoin) { + if (SelectConfig.checkOnJoin) { Player player = event.getPlayer(); new BukkitRunnable() { @Override diff --git a/src/main/java/de/jatitv/opsecurity/listener/LPCommand.java b/src/main/java/de/jatitv/opsecurity/listener/LPCommand.java deleted file mode 100644 index b52978d..0000000 --- a/src/main/java/de/jatitv/opsecurity/listener/LPCommand.java +++ /dev/null @@ -1,89 +0,0 @@ -// This claas was created by JaTiTV - - -package de.jatitv.opsecurity.listener; - -import de.jatitv.opsecurity.Util; -import de.jatitv.opsecurity.config.languages.SelectMessages; -import de.jatitv.opsecurity.config.config.SelectConfig; -import de.jatitv.opsecurity.system.Main; -import net.t2code.lib.Spigot.Lib.replace.Replace; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.server.ServerCommandEvent; - -import java.util.Iterator; - -public class LPCommand implements Listener { - - /* - private boolean LPCheck(String command) { - if (command.charAt(0) == '/') { - command = command.replaceFirst("/", ""); - } - Iterator inter = SelectConfig.LP_Whitelist.iterator(); - String lpwtl; - do { - if (!inter.hasNext()) { - return true; - } - lpwtl = (String) inter.next(); - } while (!command.equalsIgnoreCase("lp " + lpwtl) && - !command.equalsIgnoreCase("luckperms " + lpwtl) && - !command.equalsIgnoreCase("permissions " + lpwtl) && - !command.equalsIgnoreCase("perms " + lpwtl) && - !command.equalsIgnoreCase("perm " + lpwtl) && - !command.equalsIgnoreCase("lpb " + lpwtl) && - !command.equalsIgnoreCase("luckpermsbungee " + lpwtl) && - !command.equalsIgnoreCase("lpv " + lpwtl) && - !command.equalsIgnoreCase("luckpermsvelocity " + lpwtl)); - return false; - } - - @EventHandler - public void onOPServer(ServerCommandEvent event) { - if (SelectConfig.LP_AllowFromConsole) { - if (!(event.getSender() instanceof Player)) { - return; - } - } - if ((event.getCommand().toLowerCase().startsWith("lp ") || - event.getCommand().toLowerCase().startsWith("luckperms ") || - event.getCommand().toLowerCase().startsWith("permissions ") || - event.getCommand().toLowerCase().startsWith("perms ") || - event.getCommand().toLowerCase().startsWith("perm ") || - event.getCommand().toLowerCase().startsWith("lpb ") || - event.getCommand().toLowerCase().startsWith("luckpermsbungee ") || - event.getCommand().toLowerCase().startsWith("lpv ") || - event.getCommand().toLowerCase().startsWith("luckpermsvelocity ")) && SelectConfig.LP_Enable - && this.LPCheck(event.getCommand())) { - event.getSender().sendMessage(Replace.replace(Util.getPrefix(),Util.getPrefix() + SelectMessages.OP_opCommand)); - event.setCancelled(true); - } - } - - @EventHandler - public void onOpPlayer(PlayerCommandPreprocessEvent event) { - if (SelectConfig.LP_AllowFromConsole) { - if (!(event.getPlayer() instanceof Player)) { - return; - } - } - if ((event.getPlayer().isOp() || event.getPlayer().hasPermission("*")) && - event.getMessage().toLowerCase().startsWith("/lp ") || - event.getMessage().toLowerCase().startsWith("/luckperms ") || - event.getMessage().toLowerCase().startsWith("/permissions ") || - event.getMessage().toLowerCase().startsWith("/perms ") || - event.getMessage().toLowerCase().startsWith("/lpb ") || - event.getMessage().toLowerCase().startsWith("/luckpermsbungee ") || - event.getMessage().toLowerCase().startsWith("/lpv ") || - event.getMessage().toLowerCase().startsWith("/luckpermsvelocity ") && SelectConfig.OP_Whitelist_Enable && this.LPCheck(event.getMessage())) { - event.getPlayer().sendMessage(Replace.replace(Util.getPrefix(),Util.getPrefix() + SelectMessages.OP_opCommand)); - event.setCancelled(true); - } - } - - */ -} diff --git a/src/main/java/de/jatitv/opsecurity/listener/OPCommand.java b/src/main/java/de/jatitv/opsecurity/listener/OPCommand.java index 9265a04..c3e83df 100644 --- a/src/main/java/de/jatitv/opsecurity/listener/OPCommand.java +++ b/src/main/java/de/jatitv/opsecurity/listener/OPCommand.java @@ -24,7 +24,7 @@ public class OPCommand implements Listener { @EventHandler public void onOPServer(ServerCommandEvent event) { - if ((event.getCommand().toLowerCase().startsWith("op ") || event.getCommand().toLowerCase().startsWith("minecraft:op ")) && SelectConfig.OP_Whitelist_Enable) { + if ((event.getCommand().toLowerCase().startsWith("op ") || event.getCommand().toLowerCase().startsWith("minecraft:op ")) && SelectConfig.opWhitelistEnable) { switch (this.isNotOPWTL(event.getCommand())) { case 1: send.sender(event.getSender(), Util.getPrefix() + " " + SelectMessages.PlayerMustBeOnlineToOp); @@ -41,7 +41,7 @@ public class OPCommand implements Listener { @EventHandler public void onOpPlayer(PlayerCommandPreprocessEvent event) { - if (SelectConfig.OP_Whitelist_Enable) { + if (SelectConfig.opWhitelistEnable) { if ((event.getMessage().toLowerCase().startsWith("/op ") || event.getMessage().toLowerCase().startsWith("/minecraft:op "))) { switch (this.isNotOPWTL(event.getMessage())) { case 1: @@ -62,7 +62,7 @@ public class OPCommand implements Listener { if (command.charAt(0) == '/') command = command.replaceFirst("/", ""); String arg = command.replace("op ", ""); - if (SelectConfig.PlayerMustBeOnlineToOp) { + if (SelectConfig.playerMustBeOnlineToOp) { if (Main.opHashMap.containsKey(arg.toLowerCase())) { Player target = Bukkit.getPlayer(arg); if (target == null) { diff --git a/src/main/java/de/jatitv/opsecurity/listener/Timer.java b/src/main/java/de/jatitv/opsecurity/listener/Timer.java index 79969d6..4fe08f9 100644 --- a/src/main/java/de/jatitv/opsecurity/listener/Timer.java +++ b/src/main/java/de/jatitv/opsecurity/listener/Timer.java @@ -4,6 +4,7 @@ package de.jatitv.opsecurity.listener; import de.jatitv.opsecurity.config.config.SelectConfig; +import de.jatitv.opsecurity.listener.opWhitelist.Check; import de.jatitv.opsecurity.system.Main; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -11,8 +12,8 @@ import org.bukkit.entity.Player; public class Timer { public static void RefreshTimer() { - if (SelectConfig.OP_Whitelist_Enable || SelectConfig.Permission_Whitelist_Enable) { - if (SelectConfig.Timer_Enable) { + if (SelectConfig.opWhitelistEnable || SelectConfig.permissionWhitelistEnable) { + if (SelectConfig.timerEnable) { int Count = Bukkit.getScheduler().scheduleSyncRepeatingTask(Main.plugin, new Runnable() { @Override public void run() { @@ -20,7 +21,7 @@ public class Timer { Check.onCheck(player, false); } } - }, 0, SelectConfig.RefreshTime * 20L); + }, 0, SelectConfig.refreshTime * 20L); } } } diff --git a/src/main/java/de/jatitv/opsecurity/listener/opWhitelist/Check.java b/src/main/java/de/jatitv/opsecurity/listener/opWhitelist/Check.java new file mode 100644 index 0000000..4b4c17b --- /dev/null +++ b/src/main/java/de/jatitv/opsecurity/listener/opWhitelist/Check.java @@ -0,0 +1,77 @@ +package de.jatitv.opsecurity.listener.opWhitelist; + +import de.jatitv.opsecurity.Util; +import de.jatitv.opsecurity.config.languages.SelectMessages; +import de.jatitv.opsecurity.config.config.SelectConfig; +import de.jatitv.opsecurity.system.BungeeSend; +import de.jatitv.opsecurity.system.Main; +import de.jatitv.opsecurity.system.Permissions; +import net.t2code.lib.Spigot.Lib.commands.Cmd; +import net.t2code.lib.Spigot.Lib.messages.send; +import net.t2code.lib.Spigot.Lib.replace.Replace; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + +public class Check { + public static Boolean onCheck(Player player, Boolean join) { + if (!SelectConfig.opWhitelistEnable) return false; + if (!player.isOp()) return false; + if (checkOpWhitelist(player)) return false; + if (join) { + send.console(Replace.replace(Util.getPrefix(),SelectMessages.opConsoleOnJoin.replace("[player]", player.getName()))); + } + if (SelectConfig.notifyWarn) { + + } + + + + + + } + private static void notify(Player player, Boolean join){ + if (SelectConfig.bungee){ + BungeeSend.notify(player,join); + return; + } + + for (Player target : Bukkit.getOnlinePlayers()) { + if (target.hasPermission(Permissions.notify)) { + send.player(target,SelectMessages.opConsoleOnJoin.replace("[player]", player.getName())); + + + + + if (join) { + target.sendMessage(Replace.replace(Util.getPrefix(),SelectMessages.opConsoleOnJoin.replace("[player]", player.getName()))); + } else target.sendMessage(Replace.replace(Util.getPrefix(),SelectMessages.OP_consoleKick.replace("[player]", player.getName()))); + if (SelectConfig.notifySoundEnable) { + target.playSound(player.getLocation(), SelectConfig.notifySound, 3, 1); + } + } + } + } + + + private static void kickCMD(Player player, String cmd) { + if (cmd.contains("bungee:")) { + //todo + return; + } + Cmd.console(cmd.replace("[player]", player.getName())); + } + + private static Boolean checkOpWhitelist(Player player) { + if (Main.opHashMap.containsKey(player.getName().toLowerCase())) { + if (Main.opHashMap.get(player.getName().toLowerCase()).UUID.equals(player.getUniqueId().toString().replace("-", ""))) { + return true; + } else { + send.console(SelectMessages.ExactReason.replace("[reason]", "Player UUID: " + player.getUniqueId().toString() + " not whitelisted")); + return false; + } + } else { + send.console(SelectMessages.ExactReason.replace("[reason]", "Player name: " + player.getName() + " not whitelisted")); + return false; + } + } +} diff --git a/src/main/java/de/jatitv/opsecurity/system/BungeeSend.java b/src/main/java/de/jatitv/opsecurity/system/BungeeSend.java new file mode 100644 index 0000000..50af862 --- /dev/null +++ b/src/main/java/de/jatitv/opsecurity/system/BungeeSend.java @@ -0,0 +1,8 @@ +package de.jatitv.opsecurity.system; + +import org.bukkit.entity.Player; + +public class BungeeSend { + public static void notify(Player player, Boolean join) { + } +}