small code changes

This commit is contained in:
JaTiTV 2022-10-25 17:12:54 +02:00
parent bbc8f2377b
commit d66f6d0f59
7 changed files with 79 additions and 86 deletions

View File

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

View File

@ -15,7 +15,7 @@ import org.bukkit.entity.Player;
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;

View File

@ -19,47 +19,43 @@ 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 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<String> customKickCommand;
public static Boolean Permission_Whitelist_Enable;
public static Boolean permissionWhitelistEnable;
public static List<String> permissions;
public static Boolean PlayerWhithPermission_kick;
public static Boolean Perm_Command_enable;
public static List<String> Perm_Command;
public static Boolean LP_Enable;
public static Boolean LP_AllowFromConsole;
public static List<String> LP_Whitelist;
public static Boolean playerWhithPermissionKick;
public static Boolean permCommandEnable;
public static List<String> permCommand;
//help
@ -85,25 +81,25 @@ public class SelectConfig {
Main.getOpHashMap().clear();
Main.getPermissionHashMap().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");
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<PlayerObject> opWhitelist = new ArrayList<>();
for (String key : yamlConfiguration.getConfigurationSection("OP_Whitelist.Whitelist").getKeys(false)) {
@ -113,12 +109,12 @@ public class SelectConfig {
Main.getOpHashMap().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<PlayerObject> permWhitelist = new ArrayList<>();
@ -129,15 +125,12 @@ public class SelectConfig {
Main.getPermissionHashMap().put(key.toLowerCase(), player);
}
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");
playerWhithPermissionKick = yamlConfiguration.getBoolean("Permission_Whitelist.PlayerWhithPermission_kick");
permCommandEnable = yamlConfiguration.getBoolean("Permission_Whitelist.customCommands.Enable");
permCommand = yamlConfiguration.getStringList("Permission_Whitelist.customCommands.Commands");
}
public static void sound() {
Notify_Sound = T2Cconfig.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 = T2Cconfig.checkSound(CreateConfig.Notify_Sound_1_8, CreateConfig.Notify_Sound_1_9_to_1_12, CreateConfig.Notify_Sound_from_1_13, notifySoundInput, Util.getPrefix());
}
}

View File

@ -14,7 +14,7 @@ import org.bukkit.scheduler.BukkitRunnable;
public class Check {
public static Boolean onCheck(Player player, Boolean join) {
if (SelectConfig.OP_Whitelist_Enable) {
if (SelectConfig.opWhitelistEnable) {
if (player.isOp()) {
if (opWhitelist(player)) {
return false;
@ -24,27 +24,27 @@ public class Check {
T2Csend.console(T2Creplace.replace(Util.getPrefix(), SelectMessages.OP_consoleOnJoin.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(T2Creplace.replace(Util.getPrefix(), SelectMessages.OP_consoleOnJoin.replace("[player]", player.getName())));
} else notifyperm.sendMessage(T2Creplace.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);
T2Ccmd.console(SelectConfig.KickCommand.replace("[player]", player.getName())
T2Ccmd.console(SelectConfig.kickCommand.replace("[player]", player.getName())
.replace("[reason]", T2Creplace.replace(Util.getPrefix(), SelectMessages.OP_kick + "\n" + "\n" + SelectMessages.OP_deop)));
T2Csend.console(T2Creplace.replace(Util.getPrefix(), SelectMessages.OP_consoleKick.replace("[player]", player.getName())));
} else {
if (SelectConfig.no_OP_Player_kick) {
T2Ccmd.console(SelectConfig.KickCommand.replace("[player]", player.getName()).replace("[reason]", T2Creplace.replace(Util.getPrefix(), SelectMessages.OP_kick)));
if (SelectConfig.noOpPlayerKick) {
T2Ccmd.console(SelectConfig.kickCommand.replace("[player]", player.getName()).replace("[reason]", T2Creplace.replace(Util.getPrefix(), SelectMessages.OP_kick)));
T2Csend.console(T2Creplace.replace(Util.getPrefix(), SelectMessages.OP_consoleKick.replace("[player]", player.getName())));
for (Player notifyperm : Bukkit.getOnlinePlayers()) {
if (notifyperm.hasPermission(Permissions.notify)) {
@ -53,7 +53,7 @@ public class Check {
}
}
}
if (SelectConfig.no_OP_Player_deop) {
if (SelectConfig.noOPPlayerDeop) {
player.setOp(false);
if (SelectConfig.sendPlayerDEOPmsg) {
new BukkitRunnable() {
@ -73,7 +73,7 @@ public class Check {
}
}
if (SelectConfig.customCommand_Enable) {
if (SelectConfig.customCommandEnable) {
for (String cmd : SelectConfig.customKickCommand) {
T2Ccmd.console(T2Creplace.replace(Util.getPrefix(), cmd.replace("[player]", player.getName())));
@ -83,14 +83,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 (join) {
T2Csend.console(T2Creplace.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) {
@ -98,27 +98,27 @@ public class Check {
player.getName()).replace("[perm]", s)));
} else notifyperm.sendMessage(T2Creplace.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) {
T2Ccmd.console(SelectConfig.KickCommand.replace("[player]", player.getName()).replace("[reason]", T2Creplace.replace(Util.getPrefix(), SelectMessages.Perm_kick)));
if (SelectConfig.playerWhithPermissionKick && SelectConfig.permCommandEnable) {
T2Ccmd.console(SelectConfig.kickCommand.replace("[player]", player.getName()).replace("[reason]", T2Creplace.replace(Util.getPrefix(), SelectMessages.Perm_kick)));
T2Csend.console(T2Creplace.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));
}
}
if (SelectConfig.PlayerWhithPermission_kick) {
T2Ccmd.console(SelectConfig.KickCommand.replace("[player]", player.getName()).replace("[reason]", T2Creplace.replace(Util.getPrefix(), SelectMessages.Perm_kick)));
if (SelectConfig.playerWhithPermissionKick) {
T2Ccmd.console(SelectConfig.kickCommand.replace("[player]", player.getName()).replace("[reason]", T2Creplace.replace(Util.getPrefix(), SelectMessages.Perm_kick)));
T2Csend.console(T2Creplace.replace(Util.getPrefix(), SelectMessages.Perm_consoleKick.replace("[player]",
player.getName()).replace("[perm]", s)));
}
if (SelectConfig.Perm_Command_enable) {
for (String cmd : SelectConfig.Perm_Command) {
if (SelectConfig.permCommandEnable) {
for (String cmd : SelectConfig.permCommand) {
T2Ccmd.console(cmd.replace("[player]", player.getName()).replace("[perm]", s));
}
}

View File

@ -15,7 +15,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 +26,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 +37,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 +50,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

View File

@ -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:
T2Csend.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.getOpHashMap().containsKey(arg.toLowerCase())) {
Player target = Bukkit.getPlayer(arg);
if (target == null) {

View File

@ -11,8 +11,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.getPlugin(), new Runnable() {
@Override
public void run() {
@ -20,7 +20,7 @@ public class Timer {
Check.onCheck(player, false);
}
}
}, 0, SelectConfig.RefreshTime * 20L);
}, 0, SelectConfig.refreshTime * 20L);
}
}
}