This commit is contained in:
JaTiTV 2022-07-19 19:40:11 +02:00
parent 0dc34cd1d3
commit 3e2d62c8b2
15 changed files with 226 additions and 283 deletions

View File

@ -6,7 +6,7 @@
<groupId>de.jatitv</groupId> <groupId>de.jatitv</groupId>
<artifactId>OPSecurity</artifactId> <artifactId>OPSecurity</artifactId>
<version>2.4.3</version> <version>2.4.3-DEV-1</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>OPSecurity</name> <name>OPSecurity</name>

View File

@ -23,7 +23,7 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
if (args.length == 0) { if (args.length == 0) {
Commands.mainCommand(sender); Commands.mainCommand(sender);
} else { } else {
if (SelectConfig.OnlyOPcanUseThePlugin) { if (SelectConfig.onlyOPcanUseThePlugin) {
if (!sender.isOp()) { if (!sender.isOp()) {
sender.sendMessage(Util.getPrefix() + "§cOnly OPs can use OPSecurity!"); sender.sendMessage(Util.getPrefix() + "§cOnly OPs can use OPSecurity!");
return false; return false;

View File

@ -6,22 +6,17 @@ import de.jatitv.opsecurity.config.config.SelectConfig;
import de.jatitv.opsecurity.system.Load; import de.jatitv.opsecurity.system.Load;
import de.jatitv.opsecurity.system.Main; import de.jatitv.opsecurity.system.Main;
import de.jatitv.opsecurity.system.Permissions; 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.T2CodeTemplate;
import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.update.UpdateAPI; import net.t2code.lib.Spigot.Lib.update.UpdateAPI;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import java.util.List;
public class Commands { public class Commands {
public static void mainCommand(CommandSender sender) { public static void mainCommand(CommandSender sender) {
if (SelectConfig.OnlyOPcanUseThePlugin) { if (SelectConfig.onlyOPcanUseThePlugin) {
if (!sender.isOp()) { if (!sender.isOp()) {
sender.sendMessage(Util.getPrefix() + "§cOnly OPs can use OPSecurity!"); sender.sendMessage(Util.getPrefix() + "§cOnly OPs can use OPSecurity!");
return; return;

View File

@ -14,56 +14,7 @@ import java.util.List;
public class CreateConfig { public class CreateConfig {
public static Integer ConfigVersion = 2; private static String Prefix = "§8[§2OP§4Security§8] ";
public static Boolean UpdateCheckOnJoin = true;
public static String Prefix = "§8[§2OP§4Security§8] ";
public static String language = "english";
public static Boolean OnlyOPcanUseThePlugin = true;
public static Boolean CheckOnJoin = true;
public static Boolean CheckOnInteract = true;
public static Boolean CheckOnCommand = true;
public static Boolean CheckOnChat = true;
public static String KickCommand = "minecraft:kick [player] [reason]";
public static Boolean Notify_Warn = true;
public static Boolean Notify_Sound_Enable = true;
public static String Notify_Sound_1_8 = "NOTE_PIANO";
public static String Notify_Sound_1_9_to_1_12 = "BLOCK_NOTE_HARP";
public static String Notify_Sound_from_1_13 = "BLOCK_NOTE_BLOCK_HARP";
public static Boolean Timer_Enable = true;
public static int RefreshTime = 60;
public static Boolean OP_Whitelist_Enable = false;
public static Boolean PlayerMustBeOnlineToOp = true;
public static String OP_Whitelist_P1 = "player1";
public static String OP_Whitelist_P1UUID = "00000000000000000000000000000000";
public static String OP_Whitelist_P2 = "player2";
public static String OP_Whitelist_P2UUID = "00000000000000000000000000000000";
public static Boolean no_OP_Player_deop = true;
public static Boolean sendPlayerDEOPmsg = true;
public static Boolean no_OP_Player_kick = true;
public static Boolean customCommand_Enable = false;
public static List<String> customKickCommand = Arrays.asList("kick [player] &4You have op but are not authorized to do so, that's why you were kicked!");
public static Boolean Permission_Whitelist_Enable = false;
public static List<String> Permissions = Arrays.asList("*", "opsecurity.admin");
public static String Perm_Whitelist_P1 = "player1";
public static String Perm_Whitelist_P1UUID = "00000000000000000000000000000000";
public static String Perm_Whitelist_P2 = "player2";
public static String Perm_Whitelist_P2UUID = "00000000000000000000000000000000";
public static Boolean PlayerWhithPermission_kick = true;
public static Boolean Perm_Command_enable = false;
public static List<String> Perm_Command = Arrays.asList("lp user [player] permission unset *", "lp user [player] permission unset opsecurity.admin");
public static Boolean LP_Enable = false;
public static Boolean LP_AllowFromConsole = false;
public static List<String> LP_Whitelist = Arrays.asList("player1", "player2");
public static void configCreate() { public static void configCreate() {
Bukkit.getConsoleSender().sendMessage(Prefix + "§4config.yml load..."); Bukkit.getConsoleSender().sendMessage(Prefix + "§4config.yml load...");
@ -71,53 +22,54 @@ public class CreateConfig {
File configYML = new File(Main.plugin.getDataFolder().getPath(), "config.yml"); File configYML = new File(Main.plugin.getDataFolder().getPath(), "config.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(configYML); YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(configYML);
yamlConfiguration.set("ConfigVersion", ConfigVersion); yamlConfiguration.set("ConfigVersion", 3);
set("Plugin.UpdateCheckOnJoin", UpdateCheckOnJoin, yamlConfiguration); set("Plugin.UpdateCheckOnJoin", true, yamlConfiguration);
set("Plugin.language", language, yamlConfiguration); set("Plugin.language", "english", yamlConfiguration);
set("Plugin.OnlyOPcanUseThePlugin", true, yamlConfiguration);
set("Plugin.Bungee", false, yamlConfiguration);
set("Plugin.OnlyOPcanUseThePlugin", OnlyOPcanUseThePlugin, yamlConfiguration); set("Check.OnJoin", true, yamlConfiguration);
set("Check.OnJoin", CheckOnJoin, yamlConfiguration); set("Check.OnInteract", true, yamlConfiguration);
set("Check.OnInteract", CheckOnInteract, yamlConfiguration); set("Check.OnCommand", true, yamlConfiguration);
set("Check.OnCommand", CheckOnCommand, yamlConfiguration); set("Check.OnChat", true, yamlConfiguration);
set("Check.OnChat", CheckOnChat, yamlConfiguration); set("Check.Timer.Enable", true, yamlConfiguration);
set("Check.Timer.Enable", Timer_Enable, yamlConfiguration); set("Check.Timer.RefreshTime_inSec", 60, yamlConfiguration);
set("Check.Timer.RefreshTime_inSec", RefreshTime, yamlConfiguration);
set("Kick.Command", KickCommand, yamlConfiguration); set("Kick.Command", "minecraft:kick [player] [reason]", yamlConfiguration);
set("Notify.JoinWarn.Enable", Notify_Warn, yamlConfiguration); set("Notify.JoinWarn.Enable", true, yamlConfiguration);
set("Notify.Sound.Enable", Notify_Sound_Enable, yamlConfiguration); set("Notify.Sound.Enable", true, yamlConfiguration);
if (MCVersion.minecraft1_8) { 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) { } 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); set("Notify.Sound.Sound", "BLOCK_NOTE_HARP", yamlConfiguration);
} else set("Notify.Sound.Sound", Notify_Sound_from_1_13, yamlConfiguration); } else set("Notify.Sound.Sound", "BLOCK_NOTE_BLOCK_HARP", yamlConfiguration);
set("OP_Whitelist.Enable", OP_Whitelist_Enable, yamlConfiguration); set("OP_Whitelist.Enable", false, yamlConfiguration);
set("OP_Whitelist.PlayerMustBeOnlineToOp", PlayerMustBeOnlineToOp, yamlConfiguration); set("OP_Whitelist.PlayerMustBeOnlineToOp", true, yamlConfiguration);
if (yamlConfiguration.get("OP_Whitelist.Whitelist") == null) { if (yamlConfiguration.get("OP_Whitelist.Whitelist") == null) {
set("OP_Whitelist.Whitelist." + OP_Whitelist_P1 + ".UUID", OP_Whitelist_P1UUID, yamlConfiguration); set("OP_Whitelist.Whitelist." + "player1" + ".UUID", "00000000-0000-0000-0000-000000000000", yamlConfiguration);
set("OP_Whitelist.Whitelist." + OP_Whitelist_P2 + ".UUID", OP_Whitelist_P2UUID, 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.Enable", true, yamlConfiguration);
set("OP_Whitelist.noOpPlayerDeop.PlayerSendMessage", sendPlayerDEOPmsg, yamlConfiguration); set("OP_Whitelist.noOpPlayerDeop.PlayerSendMessage", true, yamlConfiguration);
set("OP_Whitelist.noOpPlayerKick.Enable", no_OP_Player_kick, yamlConfiguration); set("OP_Whitelist.noOpPlayerKick.Enable", true, yamlConfiguration);
set("OP_Whitelist.customCommands.Enable", customCommand_Enable, yamlConfiguration); set("OP_Whitelist.customCommands.Enable", false, yamlConfiguration);
set("OP_Whitelist.customCommands.Commands", customKickCommand, 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.Enable", false, yamlConfiguration);
set("Permission_Whitelist.Permissions", Permissions, yamlConfiguration); set("Permission_Whitelist.Permissions", Arrays.asList("*", "opsecurity.admin"), yamlConfiguration);
if (yamlConfiguration.get("Permission_Whitelist.Whitelist") == null) { if (yamlConfiguration.get("Permission_Whitelist.Whitelist") == null) {
set("Permission_Whitelist.Whitelist." + Perm_Whitelist_P1 + ".UUID", Perm_Whitelist_P1UUID, yamlConfiguration); set("Permission_Whitelist.Whitelist." + "player1" + ".UUID", "00000000-0000-0000-0000-000000000000", yamlConfiguration);
set("Permission_Whitelist.Whitelist." + Perm_Whitelist_P2 + ".UUID", Perm_Whitelist_P2UUID, yamlConfiguration); set("Permission_Whitelist.Whitelist." + "player2" + ".UUID", "00000000-0000-0000-0000-000000000000", yamlConfiguration);
} }
set("Permission_Whitelist.PlayerWhithPermission_kick", PlayerWhithPermission_kick, yamlConfiguration); set("Permission_Whitelist.PlayerWhithPermission_kick", true, yamlConfiguration);
set("Permission_Whitelist.customCommands.Enable", Perm_Command_enable, yamlConfiguration); set("Permission_Whitelist.customCommands.Enable", false, yamlConfiguration);
set("Permission_Whitelist.customCommands.Commands", Perm_Command, 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.Enable", LP_Enable, yamlConfiguration);
//set("LuckPerms_Whitelist.AllowFromConsole", LP_AllowFromConsole, yamlConfiguration); //set("LuckPerms_Whitelist.AllowFromConsole", LP_AllowFromConsole, yamlConfiguration);

View File

@ -6,7 +6,6 @@ import de.jatitv.opsecurity.Util;
import de.jatitv.opsecurity.objects.PlayerObject; import de.jatitv.opsecurity.objects.PlayerObject;
import de.jatitv.opsecurity.system.Main; import de.jatitv.opsecurity.system.Main;
import de.jatitv.opsecurity.system.Permissions; import de.jatitv.opsecurity.system.Permissions;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.yamlConfiguration.Config; import net.t2code.lib.Spigot.Lib.yamlConfiguration.Config;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -20,47 +19,44 @@ public class SelectConfig {
// Config // Config
public static Integer ConfigVersion; public static Integer configVersion;
public static Boolean UpdateCheckOnJoin; public static Boolean updateCheckOnJoin;
public static String language; public static String language;
public static Boolean OnlyOPcanUseThePlugin; public static Boolean onlyOPcanUseThePlugin;
public static Boolean CheckOnJoin; public static Boolean bungee;
public static Boolean CheckOnInteract; public static Boolean checkOnJoin;
public static Boolean CheckOnCommand; public static Boolean checkOnInteract;
public static Boolean CheckOnChat; public static Boolean checkOnCommand;
public static Boolean checkOnChat;
public static String KickCommand; public static String kickCommand;
public static Boolean Notify_Warn; public static Boolean notifyWarn;
public static Boolean Notify_Sound_Enable; public static Boolean notifySoundEnable;
public static Sound Notify_Sound; public static Sound notifySound;
public static String Notify_Sound_input; public static String notifySoundInput;
public static Boolean Timer_Enable; public static Boolean timerEnable;
public static int RefreshTime; public static int refreshTime;
public static Boolean OP_Whitelist_Enable; public static Boolean opWhitelistEnable;
public static Boolean PlayerMustBeOnlineToOp; public static Boolean playerMustBeOnlineToOp;
public static Boolean no_OP_Player_deop; public static Boolean noOPPlayerDeop;
public static Boolean sendPlayerDEOPmsg; public static Boolean sendPlayerDEOPmsg;
public static Boolean no_OP_Player_kick; public static Boolean nooPPlayerKick;
public static Boolean customCommand_Enable; public static Boolean customCommandEnable;
public static List<String> customKickCommand; public static List<String> customKickCommand;
public static Boolean Permission_Whitelist_Enable; public static Boolean permissionWhitelistEnable;
public static List<String> permissions; public static List<String> permissions;
public static Boolean PlayerWhithPermission_kick; public static Boolean PlayerWhithPermission_kick;
public static Boolean Perm_Command_enable; public static Boolean permCommandEnable;
public static List<String> Perm_Command; public static List<String> permCommand;
public static Boolean LP_Enable;
public static Boolean LP_AllowFromConsole;
public static List<String> LP_Whitelist;
//help //help
@ -86,25 +82,26 @@ public class SelectConfig {
Main.opHashMap.clear(); Main.opHashMap.clear();
Main.permissionHashMap.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"); language = yamlConfiguration.getString("Plugin.language");
OnlyOPcanUseThePlugin = yamlConfiguration.getBoolean("Plugin.OnlyOPcanUseThePlugin"); onlyOPcanUseThePlugin = yamlConfiguration.getBoolean("Plugin.OnlyOPcanUseThePlugin");
CheckOnJoin = yamlConfiguration.getBoolean("Check.OnJoin"); bungee = yamlConfiguration.getBoolean("Plugin.Bungee");
CheckOnInteract = yamlConfiguration.getBoolean("Check.OnInteract"); checkOnJoin = yamlConfiguration.getBoolean("Check.OnJoin");
CheckOnCommand = yamlConfiguration.getBoolean("Check.OnCommand"); checkOnInteract = yamlConfiguration.getBoolean("Check.OnInteract");
CheckOnChat = yamlConfiguration.getBoolean("Check.OnChat"); checkOnCommand = yamlConfiguration.getBoolean("Check.OnCommand");
Timer_Enable = yamlConfiguration.getBoolean("Check.Timer.Enable"); checkOnChat = yamlConfiguration.getBoolean("Check.OnChat");
RefreshTime = yamlConfiguration.getInt("Check.Timer.RefreshTime_inSec"); timerEnable = yamlConfiguration.getBoolean("Check.Timer.Enable");
refreshTime = yamlConfiguration.getInt("Check.Timer.RefreshTime_inSec");
KickCommand = yamlConfiguration.getString("Kick.Command"); kickCommand = yamlConfiguration.getString("Kick.Command");
Notify_Warn = yamlConfiguration.getBoolean("Notify.JoinWarn.Enable"); notifyWarn = yamlConfiguration.getBoolean("Notify.JoinWarn.Enable");
Notify_Sound_Enable = yamlConfiguration.getBoolean("Notify.Sound.Enable"); notifySoundEnable = yamlConfiguration.getBoolean("Notify.Sound.Enable");
Notify_Sound_input = yamlConfiguration.getString("Notify.Sound.Sound"); notifySoundInput = yamlConfiguration.getString("Notify.Sound.Sound");
OP_Whitelist_Enable = yamlConfiguration.getBoolean("OP_Whitelist.Enable"); opWhitelistEnable = yamlConfiguration.getBoolean("OP_Whitelist.Enable");
PlayerMustBeOnlineToOp = yamlConfiguration.getBoolean("OP_Whitelist.PlayerMustBeOnlineToOp"); playerMustBeOnlineToOp = yamlConfiguration.getBoolean("OP_Whitelist.PlayerMustBeOnlineToOp");
ArrayList<PlayerObject> opWhitelist = new ArrayList<>(); ArrayList<PlayerObject> opWhitelist = new ArrayList<>();
for (String key : yamlConfiguration.getConfigurationSection("OP_Whitelist.Whitelist").getKeys(false)) { for (String key : yamlConfiguration.getConfigurationSection("OP_Whitelist.Whitelist").getKeys(false)) {
@ -114,12 +111,12 @@ public class SelectConfig {
Main.opHashMap.put(key.toLowerCase(), player); 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"); sendPlayerDEOPmsg = yamlConfiguration.getBoolean("OP_Whitelist.noOpPlayerDeop.PlayerSendMessage");
no_OP_Player_kick = yamlConfiguration.getBoolean("OP_Whitelist.noOpPlayerKick.Enable"); nooPPlayerKick = yamlConfiguration.getBoolean("OP_Whitelist.noOpPlayerKick.Enable");
customCommand_Enable = yamlConfiguration.getBoolean("OP_Whitelist.customCommands.Enable"); customCommandEnable = yamlConfiguration.getBoolean("OP_Whitelist.customCommands.Enable");
customKickCommand = yamlConfiguration.getStringList("OP_Whitelist.customCommands.Commands"); 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"); permissions = yamlConfiguration.getStringList("Permission_Whitelist.Permissions");
ArrayList<PlayerObject> permWhitelist = new ArrayList<>(); ArrayList<PlayerObject> permWhitelist = new ArrayList<>();
@ -131,14 +128,11 @@ public class SelectConfig {
} }
PlayerWhithPermission_kick = yamlConfiguration.getBoolean("Permission_Whitelist.PlayerWhithPermission_kick"); PlayerWhithPermission_kick = yamlConfiguration.getBoolean("Permission_Whitelist.PlayerWhithPermission_kick");
Perm_Command_enable = yamlConfiguration.getBoolean("Permission_Whitelist.customCommands.Enable"); permCommandEnable = yamlConfiguration.getBoolean("Permission_Whitelist.customCommands.Enable");
Perm_Command = yamlConfiguration.getStringList("Permission_Whitelist.customCommands.Commands"); permCommand = yamlConfiguration.getStringList("Permission_Whitelist.customCommands.Commands");
LP_Enable = yamlConfiguration.getBoolean("LuckPerms_Whitelist.Enable");
LP_AllowFromConsole = yamlConfiguration.getBoolean("LuckPerms_Whitelist.AllowFromConsole");
LP_Whitelist = yamlConfiguration.getStringList("LuckPerms_Whitelist.Whitelist");
} }
public static void sound() { 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());
} }
} }

View File

@ -26,12 +26,12 @@ public class LanguagesCreate {
set("Plugin.Reload.Start", MSG.DE_ReloadStart, yamlConfigurationDE); set("Plugin.Reload.Start", MSG.DE_ReloadStart, yamlConfigurationDE);
set("Plugin.Reload.End", MSG.DE_ReloadEnd, yamlConfigurationDE); set("Plugin.Reload.End", MSG.DE_ReloadEnd, yamlConfigurationDE);
set("OP_Whitelist.opCommand", MSG.DE_OP_opCommand, yamlConfigurationDE); set("OP_Whitelist.opCommand", MSG.DE_OP_notifyNotOnWhitelist, yamlConfigurationDE);
set("OP_Whitelist.consoleOnJoin", MSG.DE_OP_consoleOnJoin, yamlConfigurationDE); set("OP_Whitelist.consoleOnJoin", MSG.DE_OP_notifyNotOnWhiteListJoin, yamlConfigurationDE);
set("OP_Whitelist.deop", MSG.DE_OP_deop, yamlConfigurationDE); set("OP_Whitelist.deop", MSG.DE_OP_ReasonDeop, yamlConfigurationDE);
set("OP_Whitelist.consoleDeop", MSG.DE_OP_consoleDeop, yamlConfigurationDE); set("OP_Whitelist.consoleDeop", MSG.DE_OP_playerDeop, yamlConfigurationDE);
set("OP_Whitelist.kick", MSG.DE_OP_kick, yamlConfigurationDE); set("OP_Whitelist.kick", MSG.DE_OP_ReasonKick, yamlConfigurationDE);
set("OP_Whitelist.consoleKick", MSG.DE_OP_consoleKick, yamlConfigurationDE); set("OP_Whitelist.consoleKick", MSG.DE_OP_notifyKick, yamlConfigurationDE);
set("Permission_Whitelist.consoleOnJoin", MSG.DE_Perm_consoleOnJoin, yamlConfigurationDE); set("Permission_Whitelist.consoleOnJoin", MSG.DE_Perm_consoleOnJoin, yamlConfigurationDE);
set("Permission_Whitelist.kick", MSG.DE_Perm_kick, yamlConfigurationDE); set("Permission_Whitelist.kick", MSG.DE_Perm_kick, yamlConfigurationDE);
set("Permission_Whitelist.consoleKick", MSG.DE_Perm_consoleKick, yamlConfigurationDE); set("Permission_Whitelist.consoleKick", MSG.DE_Perm_consoleKick, yamlConfigurationDE);

View File

@ -29,14 +29,14 @@ public class MSG {
public static String DE_ReloadStart = "[prefix] &6Plugin wird neu geladen..."; 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_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_notifyNotOnWhitelist = "&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_notifyNotOnWhiteListJoin = "&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_ReasonDeop = "&4You have been removed from OP because you do not have permission.\n" +
"&4Dir wurde OP entfernt da du dazu keine Permission besitzt."; "&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_playerDeop = "&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_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!"; "&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_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!"; 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!";

View File

@ -24,7 +24,7 @@ public class SelectMessages {
public static String ReloadEnd; public static String ReloadEnd;
public static String OP_opCommand; public static String OP_opCommand;
public static String OP_consoleOnJoin; public static String opConsoleOnJoin;
public static String OP_deop; public static String OP_deop;
public static String OP_consoleDeop; public static String OP_consoleDeop;
public static String OP_kick; public static String OP_kick;
@ -66,7 +66,7 @@ public class SelectMessages {
OP_opCommand = select("OP_Whitelist.opCommand", yamlConfiguration); OP_opCommand = select("OP_Whitelist.opCommand", yamlConfiguration);
OP_deop = select("OP_Whitelist.deop", yamlConfiguration); OP_deop = select("OP_Whitelist.deop", yamlConfiguration);
OP_consoleDeop = select("OP_Whitelist.consoleDeop", 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_kick = select("OP_Whitelist.kick", yamlConfiguration);
OP_consoleKick = select("OP_Whitelist.consoleKick", yamlConfiguration); OP_consoleKick = select("OP_Whitelist.consoleKick", yamlConfiguration);

View File

@ -1,8 +1,8 @@
package de.jatitv.opsecurity.listener; package de.jatitv.opsecurity.listener;
import de.jatitv.opsecurity.Util; import de.jatitv.opsecurity.Util;
import de.jatitv.opsecurity.config.languages.SelectMessages;
import de.jatitv.opsecurity.config.config.SelectConfig; 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.Main;
import de.jatitv.opsecurity.system.Permissions; import de.jatitv.opsecurity.system.Permissions;
import net.t2code.lib.Spigot.Lib.commands.Cmd; import net.t2code.lib.Spigot.Lib.commands.Cmd;
@ -12,37 +12,37 @@ import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
public class Check { public class CheckOLD {
public static Boolean onCheck(Player player, Boolean join) { public static Boolean onCheck(Player player, Boolean join) {
if (SelectConfig.OP_Whitelist_Enable) { if (SelectConfig.opWhitelistEnable) {
if (player.isOp()) { if (player.isOp()) {
if (opWhitelist(player)) { if (checkOpWhitelist(player)) {
return false; return false;
} }
if (join) { 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()) { for (Player notifyperm : Bukkit.getOnlinePlayers()) {
if (notifyperm.hasPermission(Permissions.notify)) { if (notifyperm.hasPermission(Permissions.notify)) {
if (join) { 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()))); } else notifyperm.sendMessage(Replace.replace(Util.getPrefix(),SelectMessages.OP_consoleKick.replace("[player]", player.getName())));
if (SelectConfig.Notify_Sound_Enable) { if (SelectConfig.notifySoundEnable) {
notifyperm.playSound(player.getLocation(), SelectConfig.Notify_Sound, 3, 1); 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); 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))); .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()))); send.console(Replace.replace(Util.getPrefix(),SelectMessages.OP_consoleKick.replace("[player]", player.getName())));
return true; return true;
} else { } else {
if (SelectConfig.no_OP_Player_kick) { if (SelectConfig.nooPPlayerKick) {
Cmd.console(SelectConfig.KickCommand.replace("[player]", player.getName()).replace("[reason]", Replace.replace(Util.getPrefix(),SelectMessages.OP_kick))); 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()))); send.console(Replace.replace(Util.getPrefix(),SelectMessages.OP_consoleKick.replace("[player]", player.getName())));
for (Player notifyperm : Bukkit.getOnlinePlayers()) { for (Player notifyperm : Bukkit.getOnlinePlayers()) {
if (notifyperm.hasPermission(Permissions.notify)) { if (notifyperm.hasPermission(Permissions.notify)) {
@ -52,7 +52,7 @@ public class Check {
} }
return true; return true;
} }
if (SelectConfig.no_OP_Player_deop) { if (SelectConfig.noOPPlayerDeop) {
player.setOp(false); player.setOp(false);
if (SelectConfig.sendPlayerDEOPmsg) { if (SelectConfig.sendPlayerDEOPmsg) {
new BukkitRunnable() { new BukkitRunnable() {
@ -72,7 +72,7 @@ public class Check {
return true; return true;
} }
} }
if (SelectConfig.customCommand_Enable) { if (SelectConfig.customCommandEnable) {
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
@ -86,14 +86,14 @@ public class Check {
} }
} }
if (SelectConfig.Permission_Whitelist_Enable) { if (SelectConfig.permissionWhitelistEnable) {
for (String s : SelectConfig.permissions) { for (String s : SelectConfig.permissions) {
if (player.hasPermission(s)) { if (player.hasPermission(s)) {
if (!permWhitelist(player)) { if (!checkPermWhitelist(player)) {
if (join) { if (join) {
send.console(Replace.replace(Util.getPrefix(),SelectMessages.Perm_consoleOnJoin.replace("[player]", player.getName()).replace("[perm]", s))); 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()) { for (Player notifyperm : Bukkit.getOnlinePlayers()) {
if (notifyperm.hasPermission(Permissions.notify)) { if (notifyperm.hasPermission(Permissions.notify)) {
if (join) { if (join) {
@ -101,30 +101,30 @@ public class Check {
player.getName()).replace("[perm]", s))); player.getName()).replace("[perm]", s)));
} else notifyperm.sendMessage(Replace.replace(Util.getPrefix(),SelectMessages.Perm_consoleKick.replace("[player]", } else notifyperm.sendMessage(Replace.replace(Util.getPrefix(),SelectMessages.Perm_consoleKick.replace("[player]",
player.getName()).replace("[perm]", s))); player.getName()).replace("[perm]", s)));
if (SelectConfig.Notify_Sound_Enable) { if (SelectConfig.notifySoundEnable) {
notifyperm.playSound(player.getLocation(), SelectConfig.Notify_Sound, 3, 1); notifyperm.playSound(player.getLocation(), SelectConfig.notifySound, 3, 1);
} }
} }
} }
} }
if (SelectConfig.PlayerWhithPermission_kick && SelectConfig.Perm_Command_enable) { if (SelectConfig.PlayerWhithPermission_kick && SelectConfig.permCommandEnable) {
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]", send.console(Replace.replace(Util.getPrefix(),SelectMessages.Perm_consoleKick.replace("[player]",
player.getName()).replace("[perm]", s))); 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)); Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), cmd.replace("[player]", player.getName()).replace("[perm]", s));
} }
return true; return true;
} }
if (SelectConfig.PlayerWhithPermission_kick) { 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]", send.console(Replace.replace(Util.getPrefix(),SelectMessages.Perm_consoleKick.replace("[player]",
player.getName()).replace("[perm]", s))); player.getName()).replace("[perm]", s)));
return true; return true;
} }
if (SelectConfig.Perm_Command_enable) { if (SelectConfig.permCommandEnable) {
for (String cmd : SelectConfig.Perm_Command) { for (String cmd : SelectConfig.permCommand) {
Cmd.console(cmd.replace("[player]", player.getName()).replace("[perm]", s)); Cmd.console(cmd.replace("[player]", player.getName()).replace("[perm]", s));
} }
return true; return true;
@ -137,7 +137,11 @@ public class Check {
return false; 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.containsKey(player.getName().toLowerCase())) {
if (Main.opHashMap.get(player.getName().toLowerCase()).UUID.equals(player.getUniqueId().toString().replace("-", ""))) { if (Main.opHashMap.get(player.getName().toLowerCase()).UUID.equals(player.getUniqueId().toString().replace("-", ""))) {
return true; 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.containsKey(player.getName().toLowerCase())) {
if (Main.permissionHashMap.get(player.getName().toLowerCase()).UUID.equals(player.getUniqueId().toString().replace("-", ""))) { if (Main.permissionHashMap.get(player.getName().toLowerCase()).UUID.equals(player.getUniqueId().toString().replace("-", ""))) {
return true; return true;

View File

@ -4,6 +4,7 @@ package de.jatitv.opsecurity.listener;
import de.jatitv.opsecurity.Util; import de.jatitv.opsecurity.Util;
import de.jatitv.opsecurity.config.config.SelectConfig; import de.jatitv.opsecurity.config.config.SelectConfig;
import de.jatitv.opsecurity.listener.opWhitelist.Check;
import de.jatitv.opsecurity.system.Main; import de.jatitv.opsecurity.system.Main;
import net.t2code.lib.Spigot.Lib.update.UpdateAPI; import net.t2code.lib.Spigot.Lib.update.UpdateAPI;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -15,7 +16,7 @@ public class Events implements org.bukkit.event.Listener {
@EventHandler @EventHandler
public void CommandSendEvent(PlayerCommandPreprocessEvent event) { public void CommandSendEvent(PlayerCommandPreprocessEvent event) {
if (SelectConfig.CheckOnCommand) { if (SelectConfig.checkOnCommand) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (Check.onCheck(player, false)) { if (Check.onCheck(player, false)) {
if (event.isCancelled()) return; if (event.isCancelled()) return;
@ -26,7 +27,7 @@ public class Events implements org.bukkit.event.Listener {
@EventHandler @EventHandler
public void PlayerChatEvent(PlayerChatEvent event) { public void PlayerChatEvent(PlayerChatEvent event) {
if (SelectConfig.CheckOnChat) { if (SelectConfig.checkOnChat) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (Check.onCheck(player, false)) { if (Check.onCheck(player, false)) {
if (event.isCancelled()) return; if (event.isCancelled()) return;
@ -37,7 +38,7 @@ public class Events implements org.bukkit.event.Listener {
@EventHandler @EventHandler
public void onInteract(PlayerInteractEvent event) { public void onInteract(PlayerInteractEvent event) {
if (SelectConfig.CheckOnInteract) { if (SelectConfig.checkOnInteract) {
Player player = event.getPlayer(); Player player = event.getPlayer();
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
@ -50,7 +51,7 @@ public class Events implements org.bukkit.event.Listener {
@EventHandler @EventHandler
public void onJoinCheck(PlayerJoinEvent event) { public void onJoinCheck(PlayerJoinEvent event) {
if (SelectConfig.CheckOnJoin) { if (SelectConfig.checkOnJoin) {
Player player = event.getPlayer(); Player player = event.getPlayer();
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override

View File

@ -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);
}
}
*/
}

View File

@ -24,7 +24,7 @@ public class OPCommand implements Listener {
@EventHandler @EventHandler
public void onOPServer(ServerCommandEvent event) { 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())) { switch (this.isNotOPWTL(event.getCommand())) {
case 1: case 1:
send.sender(event.getSender(), Util.getPrefix() + " " + SelectMessages.PlayerMustBeOnlineToOp); send.sender(event.getSender(), Util.getPrefix() + " " + SelectMessages.PlayerMustBeOnlineToOp);
@ -41,7 +41,7 @@ public class OPCommand implements Listener {
@EventHandler @EventHandler
public void onOpPlayer(PlayerCommandPreprocessEvent event) { 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 "))) { if ((event.getMessage().toLowerCase().startsWith("/op ") || event.getMessage().toLowerCase().startsWith("/minecraft:op "))) {
switch (this.isNotOPWTL(event.getMessage())) { switch (this.isNotOPWTL(event.getMessage())) {
case 1: case 1:
@ -62,7 +62,7 @@ public class OPCommand implements Listener {
if (command.charAt(0) == '/') command = command.replaceFirst("/", ""); if (command.charAt(0) == '/') command = command.replaceFirst("/", "");
String arg = command.replace("op ", ""); String arg = command.replace("op ", "");
if (SelectConfig.PlayerMustBeOnlineToOp) { if (SelectConfig.playerMustBeOnlineToOp) {
if (Main.opHashMap.containsKey(arg.toLowerCase())) { if (Main.opHashMap.containsKey(arg.toLowerCase())) {
Player target = Bukkit.getPlayer(arg); Player target = Bukkit.getPlayer(arg);
if (target == null) { if (target == null) {

View File

@ -4,6 +4,7 @@
package de.jatitv.opsecurity.listener; package de.jatitv.opsecurity.listener;
import de.jatitv.opsecurity.config.config.SelectConfig; import de.jatitv.opsecurity.config.config.SelectConfig;
import de.jatitv.opsecurity.listener.opWhitelist.Check;
import de.jatitv.opsecurity.system.Main; import de.jatitv.opsecurity.system.Main;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -11,8 +12,8 @@ import org.bukkit.entity.Player;
public class Timer { public class Timer {
public static void RefreshTimer() { public static void RefreshTimer() {
if (SelectConfig.OP_Whitelist_Enable || SelectConfig.Permission_Whitelist_Enable) { if (SelectConfig.opWhitelistEnable || SelectConfig.permissionWhitelistEnable) {
if (SelectConfig.Timer_Enable) { if (SelectConfig.timerEnable) {
int Count = Bukkit.getScheduler().scheduleSyncRepeatingTask(Main.plugin, new Runnable() { int Count = Bukkit.getScheduler().scheduleSyncRepeatingTask(Main.plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
@ -20,7 +21,7 @@ public class Timer {
Check.onCheck(player, false); Check.onCheck(player, false);
} }
} }
}, 0, SelectConfig.RefreshTime * 20L); }, 0, SelectConfig.refreshTime * 20L);
} }
} }
} }

View File

@ -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;
}
}
}

View File

@ -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) {
}
}