3.0.1
https://www.spigotmc.org/resources/t2c-opsecurity-permission-security-1-8-x-1-19-x.90739/update?update=478627
This commit is contained in:
parent
930e48484c
commit
224f53d027
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>net.t2code</groupId>
|
||||
<artifactId>T2C-OPSecurity</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<version>3.0.1</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>T2C-OPSecurity</name>
|
||||
|
@ -20,27 +20,45 @@ public class OpCheck {
|
||||
if (!OPWhitelist.enable.valueBoolean) return false;
|
||||
if (!player.isOp()) return false;
|
||||
if (opWhitelist(player)) return false;
|
||||
if (join) T2Csend.console(Language.opWhitelistNotifyOnJoin.value.replace("[player]", player.getName()));
|
||||
if (join) T2Csend.console(Language.opWhitelistNotifyOnJoin.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
Bukkit.getScheduler().runTask(Main.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
execute(player, join);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Config.notifyJoinWarning.valueBoolean&& join) {
|
||||
if (Config.notifyBungee.valueBoolean ) {
|
||||
BungeeSenderReceiver.sendToBungee(Language.opWhitelistNotifyOnJoin.value.replace("[player]", player.getName()));
|
||||
} else Events.notifyPlayer(Language.opWhitelistNotifyOnJoin.value.replace("[player]", player.getName()));
|
||||
private static void execute(Player player, Boolean join) {
|
||||
if (Config.notifyJoinWarning.valueBoolean && join) {
|
||||
if (Config.notifyBungee.valueBoolean) {
|
||||
BungeeSenderReceiver.sendToBungee(Language.opWhitelistNotifyOnJoin.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
} else Events.notifyPlayer(Language.opWhitelistNotifyOnJoin.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
}
|
||||
|
||||
if (OPWhitelist.noOpPlayerSetGameModeEnable.valueBoolean) {
|
||||
player.setGameMode(OPWhitelist.noOpPlayerSetGameModeValue.valueGameMode);
|
||||
}
|
||||
|
||||
if (OPWhitelist.noOpPlayerDeopEnable.valueBoolean) {
|
||||
player.setOp(false);
|
||||
if (OPWhitelist.noOpPlayerKickEnable.valueBoolean) {
|
||||
if (!OPWhitelist.customCommandsEnable.valueBoolean) T2Ccmd.console(Config.kickCommand.path.replace("[player]", player.getName()).replace("[reason]",
|
||||
OPWhitelist.noOpPlayerKickEnable.valueBoolean && OPWhitelist.noOpPlayerDeopEnable.valueBoolean && OPWhitelist.noOpPlayerDeopPlayerSendMessage.valueBoolean
|
||||
? Language.opWhitelistKick.value + "<br><br>" + Language.opWhitelistDeop.value : Language.opWhitelistKick.value));
|
||||
T2Csend.console(Language.opWhitelistNotifyDeop.value.replace("[player]", player.getName()) + "<br>"
|
||||
+ Language.opWhitelistNotifyKick.value.replace("[player]", player.getName()));
|
||||
if (!OPWhitelist.customCommandsEnable.valueBoolean) {
|
||||
if (Config.kickCustomCommand.valueBoolean) {
|
||||
T2Ccmd.console(Config.kickCommand.valueString.replace("[player]", player.getName()).replace("[reason]",
|
||||
OPWhitelist.noOpPlayerKickEnable.valueBoolean && OPWhitelist.noOpPlayerDeopEnable.valueBoolean && OPWhitelist.noOpPlayerDeopPlayerSendMessage.valueBoolean
|
||||
? Language.opWhitelistKick.value + "<br> <br>" + Language.opWhitelistDeop.value : Language.opWhitelistKick.value));
|
||||
} else player.kickPlayer(OPWhitelist.noOpPlayerDeopEnable.valueBoolean && OPWhitelist.noOpPlayerDeopPlayerSendMessage.valueBoolean
|
||||
? Language.opWhitelistKick.value + "\n \n" + Language.opWhitelistDeop.value : Language.opWhitelistKick.value);
|
||||
}
|
||||
T2Csend.console(Language.opWhitelistNotifyDeop.value.replace("[player]", player.getName().replace("[uuid]", String.valueOf(player.getUniqueId()))) + "<br>"
|
||||
+ Language.opWhitelistNotifyKick.value.replace("[player]", player.getName().replace("[uuid]", String.valueOf(player.getUniqueId()))).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
Events.notifyPlayer(Language.opWhitelistNotifyDeop.value.replace("[player]", player.getName()) + "<br>"
|
||||
+ Language.opWhitelistNotifyKick.value.replace("[player]", player.getName()));
|
||||
+ Language.opWhitelistNotifyKick.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
} else {
|
||||
T2Csend.console(Language.opWhitelistNotifyDeop.value.replace("[player]", player.getName()));
|
||||
Events.notifyPlayer(Language.opWhitelistNotifyDeop.value.replace("[player]", player.getName()));
|
||||
T2Csend.console(Language.opWhitelistNotifyDeop.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
Events.notifyPlayer(Language.opWhitelistNotifyDeop.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
|
||||
if (OPWhitelist.noOpPlayerDeopPlayerSendMessage.valueBoolean) {
|
||||
Bukkit.getScheduler().runTaskLater(Main.getPlugin(), new Runnable() {
|
||||
@ -53,25 +71,27 @@ public class OpCheck {
|
||||
}
|
||||
}
|
||||
if (OPWhitelist.noOpPlayerKickEnable.valueBoolean) {
|
||||
if (!OPWhitelist.customCommandsEnable.valueBoolean)
|
||||
T2Ccmd.console(Config.kickCommand.path.replace("[player]", player.getName()).replace("[reason]", Language.opWhitelistKick.value));
|
||||
T2Csend.console(Language.opWhitelistNotifyKick.value.replace("[player]", player.getName()));
|
||||
Events.notifyPlayer(Language.opWhitelistNotifyKick.value.replace("[player]", player.getName()));
|
||||
if (!OPWhitelist.noOpPlayerDeopEnable.valueBoolean) {
|
||||
if (!OPWhitelist.customCommandsEnable.valueBoolean) {
|
||||
if (Config.kickCustomCommand.valueBoolean) {
|
||||
T2Ccmd.console(Config.kickCommand.valueString.replace("[player]", player.getName()).replace("[reason]", Language.opWhitelistKick.value));
|
||||
} else player.kickPlayer(Language.opWhitelistKick.value);
|
||||
}
|
||||
T2Csend.console(Language.opWhitelistNotifyKick.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
Events.notifyPlayer(Language.opWhitelistNotifyKick.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
}
|
||||
}
|
||||
if (OPWhitelist.customCommandsEnable.valueBoolean) {
|
||||
for (String cmd : OPWhitelist.customCommandsCommands.valueStringList) {
|
||||
T2Ccmd.console(cmd.replace("[player]", player.getName()));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static Boolean opWhitelist(Player player) {
|
||||
for (Map.Entry<String, PlayerObject> playerObject : PlayerCash.getOpHashMap().entrySet()){
|
||||
if (playerObject.getValue().playerName.equals(player.getName())) return true;
|
||||
if (playerObject.getValue().uuid.equals(player.getUniqueId().toString())) return true;
|
||||
public static Boolean opWhitelist(Player player) {
|
||||
for (Map.Entry<String, PlayerObject> playerObject : PlayerCash.getOpHashMap().entrySet()) {
|
||||
if (playerObject.getValue().playerName.equals(player.getName()) && playerObject.getValue().uuid.equals(player.getUniqueId().toString())) return true;
|
||||
}
|
||||
T2Csend.console(Language.exactKickReason.value.replace("[reason]", "Player UUID: " + player.getUniqueId().toString() + " not whitelisted (opWhitelist)"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -7,8 +7,10 @@ import net.t2code.opsecurity.events.Events;
|
||||
import net.t2code.opsecurity.objects.PlayerCash;
|
||||
import net.t2code.opsecurity.objects.PlayerObject;
|
||||
import net.t2code.opsecurity.system.BungeeSenderReceiver;
|
||||
import net.t2code.opsecurity.system.Main;
|
||||
import net.t2code.t2codelib.SPIGOT.api.commands.T2Ccmd;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Map;
|
||||
@ -19,35 +21,43 @@ public class PermissionCheck {
|
||||
for (String perm : PermissionWhitelist.permissions.valueStringList) {
|
||||
if (!player.hasPermission(perm)) continue;
|
||||
if (permWhitelist(player)) continue;
|
||||
|
||||
if (join) T2Csend.console(Language.permissionWhitelistNotifyKick.value.replace("[player]", player.getName()));
|
||||
if (Config.notifyJoinWarning.valueBoolean && join) {
|
||||
if (Config.notifyBungee.valueBoolean) {
|
||||
BungeeSenderReceiver.sendToBungee(Language.permissionWhitelistNotifyOnJoin.value.replace("[player]", player.getName()));
|
||||
} else Events.notifyPlayer(Language.permissionWhitelistNotifyOnJoin.value.replace("[player]", player.getName()));
|
||||
}
|
||||
|
||||
if (PermissionWhitelist.playerWithPermissionKick.valueBoolean) {
|
||||
T2Ccmd.console(Config.kickCommand.valueString.replace("[player]", player.getName()).replace("[reason]", Language.permissionWhitelistKick.value));
|
||||
T2Csend.console(Language.permissionWhitelistNotifyKick.value.replace("[player]",
|
||||
player.getName()).replace("[perm]", perm));
|
||||
}
|
||||
if (PermissionWhitelist.customCommandsCommands.valueBoolean) {
|
||||
for (String cmd : PermissionWhitelist.customCommandsCommands.valueStringList) {
|
||||
T2Ccmd.console(cmd.replace("[player]", player.getName()).replace("[perm]", perm));
|
||||
Bukkit.getScheduler().runTask(Main.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
execute(player, join, perm);
|
||||
}
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static Boolean permWhitelist(Player player) {
|
||||
for (Map.Entry<String, PlayerObject> playerObject : PlayerCash.getPermissionHashMap().entrySet()){
|
||||
if (playerObject.getValue().playerName.equals(player.getName())) return true;
|
||||
if (playerObject.getValue().uuid.equals(player.getUniqueId().toString())) return true;
|
||||
private static void execute(Player player, Boolean join, String perm) {
|
||||
if (join) T2Csend.console(Language.permissionWhitelistNotifyKick.value.replace("[player]", player.getName()).replace("[uuid]",String.valueOf(player.getUniqueId())));
|
||||
if (Config.notifyJoinWarning.valueBoolean && join) {
|
||||
if (Config.notifyBungee.valueBoolean) {
|
||||
BungeeSenderReceiver.sendToBungee(Language.permissionWhitelistNotifyOnJoin.value.replace("[player]", player.getName()).replace("[uuid]",String.valueOf(player.getUniqueId())));
|
||||
} else Events.notifyPlayer(Language.permissionWhitelistNotifyOnJoin.value.replace("[player]", player.getName()).replace("[uuid]",String.valueOf(player.getUniqueId())));
|
||||
}
|
||||
|
||||
if (PermissionWhitelist.playerWithPermissionKick.valueBoolean) {
|
||||
if (Config.kickCustomCommand.valueBoolean) {
|
||||
T2Ccmd.console(Config.kickCommand.valueString.replace("[player]", player.getName()).replace("[reason]", Language.permissionWhitelistKick.value));
|
||||
} else player.kickPlayer(Language.permissionWhitelistKick.value);
|
||||
T2Csend.console(Language.permissionWhitelistNotifyKick.value.replace("[player]",
|
||||
player.getName()).replace("[perm]", perm).replace("[uuid]",String.valueOf(player.getUniqueId())));
|
||||
}
|
||||
if (PermissionWhitelist.customCommandsCommands.valueBoolean) {
|
||||
for (String cmd : PermissionWhitelist.customCommandsCommands.valueStringList) {
|
||||
T2Ccmd.console(cmd.replace("[player]", player.getName()).replace("[perm]", perm));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Boolean permWhitelist(Player player) {
|
||||
for (Map.Entry<String, PlayerObject> playerObject : PlayerCash.getPermissionHashMap().entrySet()) {
|
||||
if (playerObject.getValue().playerName.equals(player.getName()) && playerObject.getValue().uuid.equals(player.getUniqueId().toString())) return true;
|
||||
}
|
||||
T2Csend.console(Language.exactKickReason.value.replace("[reason]", "Player UUID: " + player.getUniqueId().toString() + " not whitelisted (permissionWhitelist)"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
// This claas was created by JaTiTV
|
||||
|
||||
|
||||
package net.t2code.opsecurity.check;
|
||||
|
||||
import net.t2code.opsecurity.config.config.Config;
|
||||
|
@ -4,7 +4,8 @@ package net.t2code.opsecurity.command;
|
||||
|
||||
import net.t2code.opsecurity.Util;
|
||||
import net.t2code.opsecurity.config.config.Config;
|
||||
import net.t2code.opsecurity.config.opWhitelist.OPWhitelist;
|
||||
import net.t2code.opsecurity.objects.PlayerCash;
|
||||
import net.t2code.opsecurity.objects.PlayerObject;
|
||||
import net.t2code.opsecurity.system.Main;
|
||||
import net.t2code.opsecurity.system.Permissions;
|
||||
import net.t2code.t2codelib.SPIGOT.api.commands.T2Ctab;
|
||||
@ -17,6 +18,7 @@ import org.bukkit.command.TabCompleter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class CmdExecuter implements CommandExecutor, TabCompleter {
|
||||
|
||||
|
@ -1,9 +1,11 @@
|
||||
package net.t2code.opsecurity.command;
|
||||
|
||||
import net.t2code.opsecurity.Util;
|
||||
import net.t2code.opsecurity.check.OpCheck;
|
||||
import net.t2code.opsecurity.config.FileSelect;
|
||||
import net.t2code.opsecurity.config.config.Config;
|
||||
import net.t2code.opsecurity.config.language.Language;
|
||||
import net.t2code.opsecurity.enums.OpCommandRequest;
|
||||
import net.t2code.opsecurity.objects.PlayerCash;
|
||||
import net.t2code.opsecurity.system.Main;
|
||||
import net.t2code.opsecurity.system.Permissions;
|
||||
@ -52,13 +54,11 @@ public class Commands {
|
||||
}
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
if (!PlayerCash.getOpHashMap().containsKey(player.getName().toLowerCase())) {
|
||||
sender.sendMessage(Util.getPrefix() + " §4You are not on the Whitelist!");
|
||||
return;
|
||||
}
|
||||
if (!PlayerCash.getOpHashMap().get(player.getName().toLowerCase()).uuid.equals(player.getUniqueId().toString().replace("-", ""))) {
|
||||
sender.sendMessage(Util.getPrefix() + " §4You are not on the Whitelist!");
|
||||
return;
|
||||
if (Config.onlyOPcanUseThePlugin.valueBoolean) {
|
||||
if (!OpCheck.opWhitelist(player)) {
|
||||
sender.sendMessage(Util.getPrefix() + " §4You are not on the Whitelist!"); // todo
|
||||
return;
|
||||
}
|
||||
}
|
||||
T2Csend.player(player, Language.reloadStart.value);
|
||||
}
|
||||
@ -76,7 +76,6 @@ public class Commands {
|
||||
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + "§8-------------------------------");
|
||||
}
|
||||
|
||||
|
||||
public static void info(CommandSender sender) {
|
||||
if (!sender.hasPermission(Permissions.info)) {
|
||||
sender.sendMessage(Util.getPrefix() + "§cYou do not have permission for OPSecurity! §7<" + Permissions.info + ">");
|
||||
|
@ -11,6 +11,7 @@ import net.t2code.opsecurity.system.Main;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.languages.SelectLibMsg;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
@ -91,7 +92,6 @@ public class FileSelect {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String selectMSG;
|
||||
File config = new File(Main.getPath(), "languages/" + Config.language.valueString + ".yml");
|
||||
T2Csend.debug(Main.getPlugin(), config.getAbsolutePath());
|
||||
@ -115,6 +115,7 @@ public class FileSelect {
|
||||
}
|
||||
|
||||
public static void selectOpWhitelist() {
|
||||
PlayerCash.getOpHashMap().clear();
|
||||
File config = new File(Main.getPath(), "opWhitelist.yml");
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
for (OPWhitelist value : OPWhitelist.values()) {
|
||||
@ -139,10 +140,22 @@ public class FileSelect {
|
||||
yamlConfiguration.set(value.pathPlayerUuid.replace("KEY", "player2"), value.valuePlayerUuid);
|
||||
}
|
||||
for (String key : yamlConfiguration.getConfigurationSection(value.pathPlayerListPath).getKeys(false)) {
|
||||
String name = yamlConfiguration.getString(value.pathPlayerName.replace("KEY", key));
|
||||
PlayerObject playerObject = new PlayerObject(
|
||||
yamlConfiguration.getString(value.pathPlayerName.replace("KEY", key)),
|
||||
name,
|
||||
yamlConfiguration.getString(value.pathPlayerUuid.replace("KEY", key).replace("-", "")));
|
||||
PlayerCash.getOpHashMap().put(key, playerObject);
|
||||
PlayerCash.getOpHashMap().put(name, playerObject);
|
||||
}
|
||||
break;
|
||||
case GAMEMODE:
|
||||
if (!yamlConfiguration.contains(value.path)) {
|
||||
yamlConfiguration.set(value.path, value.valueGameMode.toString());
|
||||
}
|
||||
try {
|
||||
value.valueGameMode = GameMode.valueOf(yamlConfiguration.getString(value.path).toUpperCase());
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
value.valueGameMode = GameMode.SURVIVAL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -155,6 +168,7 @@ public class FileSelect {
|
||||
}
|
||||
|
||||
public static void selectPermissionWhitelist() {
|
||||
PlayerCash.getPermissionHashMap().clear();
|
||||
File config = new File(Main.getPath(), "permissionWhitelist.yml");
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
for (PermissionWhitelist value : PermissionWhitelist.values()) {
|
||||
@ -179,10 +193,11 @@ public class FileSelect {
|
||||
yamlConfiguration.set(value.pathPlayerUuid.replace("KEY", "player2"), value.valuePlayerUuid);
|
||||
}
|
||||
for (String key : yamlConfiguration.getConfigurationSection(value.pathPlayerListPath).getKeys(false)) {
|
||||
String name = yamlConfiguration.getString(value.pathPlayerName.replace("KEY", key));
|
||||
PlayerObject playerObject = new PlayerObject(
|
||||
yamlConfiguration.getString(value.pathPlayerName.replace("KEY", key)),
|
||||
name,
|
||||
yamlConfiguration.getString(value.pathPlayerUuid.replace("KEY", key).replace("-", "")));
|
||||
PlayerCash.getPermissionHashMap().put(key, playerObject);
|
||||
PlayerCash.getPermissionHashMap().put(name, playerObject);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -15,7 +15,8 @@ public enum Config {
|
||||
checkOnChat("check.onChat", true, ConfigParam.BOOLEAN),
|
||||
checkTimerEnable("check.timer.enable", true, ConfigParam.BOOLEAN),
|
||||
checkTimerRefreshInSec("check.timer.refreshInSec", 60, ConfigParam.INTEGER),
|
||||
kickCommand("kick.command", "minecraft:kick [player] [reason]", ConfigParam.STRING),
|
||||
kickCustomCommand("kick.customCommand.Enable", false, ConfigParam.BOOLEAN),
|
||||
kickCommand("kick.customCommand.command", "minecraft:kick [player] [reason]", ConfigParam.STRING),
|
||||
notifyJoinWarning("notify.joinWarn.enable", true, ConfigParam.BOOLEAN),
|
||||
notifyBungee("notify.allBungeePlayer.enable", false, ConfigParam.BOOLEAN),
|
||||
notifySoundEnable("notify.soundEnable", true, ConfigParam.BOOLEAN),
|
||||
|
@ -30,32 +30,32 @@ public enum Language {
|
||||
"[prefix] <dark_red>The specified player is not on the OP_Whitelist!</dark_red>"),
|
||||
|
||||
opWhitelistNotifyOnJoin("opWhitelist.notify.onJoin",null,
|
||||
"[prefix] <dark_red>Spieler <gold>[player]</gold> ist dem Server beigetreten, befindet sich aber nicht auf der OP_Whitelist!</dark_red>",
|
||||
"[prefix] <dark_red>Player <gold>[player]</gold> is joined to the server but is not on the OP_Whitelist!</dark_red>"),
|
||||
"[prefix] <dark_red>Spieler <gold><hover:show_text:'<gold>Name:</gold> <yellow>[player]</yellow><br><gold>UUID:</gold> <yellow>[uuid]</yellow>'>[player]</hover></gold> ist dem Server beigetreten, befindet sich aber nicht auf der OP_Whitelist!</dark_red>",
|
||||
"[prefix] <dark_red>Player <gold><hover:show_text:'<gold>Name:</gold> <yellow>[player]</yellow><br><gold>UUID:</gold> <yellow>[uuid]</yellow>'>[player]</hover></gold> is joined to the server but is not on the OP_Whitelist!</dark_red>"),
|
||||
|
||||
opWhitelistNotifyDeop("opWhitelist.notify.deop",null,
|
||||
"[prefix] <dark_red>Spieler <gold>[player]</gold> wurde OP entfernt da er nicht auf der Spielerliste steht!</dark_red>",
|
||||
"[prefix] <dark_red>Player <gold>[player]</gold> was removed OP because he is not on the playerlist!</dark_red>"),
|
||||
"[prefix] <dark_red>Spieler <gold><hover:show_text:'<gold>Name:</gold> <yellow>[player]</yellow><br><gold>UUID:</gold> <yellow>[uuid]</yellow>'>[player]</hover></gold> wurde OP entfernt da er nicht auf der Spielerliste steht!</dark_red>",
|
||||
"[prefix] <dark_red>Player <gold><hover:show_text:'<gold>Name:</gold> <yellow>[player]</yellow><br><gold>UUID:</gold> <yellow>[uuid]</yellow>'>[player]</hover></gold> was removed OP because he is not on the playerlist!</dark_red>"),
|
||||
|
||||
opWhitelistNotifyKick("opWhitelist.notify.kick",null,
|
||||
"[prefix] <dark_red>Spieler <gold>[player]</gold> wurde gekickt, da er nicht auf der OP_Whitelist steht!</dark_red>",
|
||||
"[prefix] <dark_red>Player <gold>[player]</gold> was kicked because he is not on the OP_Whitelist!</dark_red>"),
|
||||
"[prefix] <dark_red>Spieler <gold><hover:show_text:'<gold>Name:</gold> <yellow>[player]</yellow><br><gold>UUID:</gold> <yellow>[uuid]</yellow>'>[player]</hover></gold> wurde gekickt, da er nicht auf der OP_Whitelist steht!</dark_red>",
|
||||
"[prefix] <dark_red>Player <gold><hover:show_text:'<gold>Name:</gold> <yellow>[player]</yellow><br><gold>UUID:</gold> <yellow>[uuid]</yellow>'>[player]</hover></gold> was kicked because he is not on the OP_Whitelist!</dark_red>"),
|
||||
|
||||
opWhitelistDeop("opWhitelist.deop",null,
|
||||
"[prefix] <dark_red>Dir wurde OP entfernt da du dazu keine Permission besitzt.</dark_red>",
|
||||
"[prefix] <dark_red>You have been removed from OP because you do not have permission.</dark_red>"),
|
||||
"&4Dir wurde OP entfernt da du dazu keine Permission besitzt.",
|
||||
"&4You have been removed from OP because you do not have permission."),
|
||||
|
||||
opWhitelistKick("opWhitelist.kick",null,
|
||||
"<dark_red>Du hast op bist dazu aber nicht berechtigt, deswegen wurdest du gekickt!</dark_red>",
|
||||
"<dark_red>You have op but are not authorized to do so, that's why you were kicked!</dark_red>"),
|
||||
"&4Du hast OP, bist dazu aber nicht berechtigt. Deswegen wurdest du gekickt!",
|
||||
"&4You have op but are not authorized to do so, that's why you were kicked!"),
|
||||
|
||||
permissionWhitelistNotifyOnJoin("permissionWhitelist.notify.onJoin",null,
|
||||
"[prefix] <dark_red>Player <gold>[player]</gold> hat die Permission <gold>[perm]</gold> und ist dazu nicht berechtigt! <gold>[player]</gold> ist nicht in der Spielerliste!</dark_red>",
|
||||
"[prefix] <dark_red>Player <gold>[player]</gold> has permission <gold>[perm]</gold> and is not authorized to do so! <gold>[player]</gold> is not on the Player list!</dark_red>"),
|
||||
"[prefix] <dark_red>Player <gold><hover:show_text:'<gold>Name:</gold> <yellow>[player]</yellow><br><gold>UUID:</gold> <yellow>[uuid]</yellow>'>[player]</hover></gold> hat die Permission <gold>[perm]</gold> und ist dazu nicht berechtigt! <gold><hover:show_text:'<gold>Name:</gold> <yellow>[player]</yellow><br><gold>UUID:</gold> <yellow>[uuid]</yellow>'>[player]</hover></gold> ist nicht in der Spielerliste!</dark_red>",
|
||||
"[prefix] <dark_red>Player <gold><hover:show_text:'<gold>Name:</gold> <yellow>[player]</yellow><br><gold>UUID:</gold> <yellow>[uuid]</yellow>'>[player]</hover></gold> has permission <gold>[perm]</gold> and is not authorized to do so! <gold><hover:show_text:'<gold>Name:</gold> <yellow>[player]</yellow><br><gold>UUID:</gold> <yellow>[uuid]</yellow>'>[player]</hover></gold> is not on the Player list!</dark_red>"),
|
||||
|
||||
permissionWhitelistNotifyKick("permissionWhitelist.notify.kick",null,
|
||||
"[prefix] <dark_red>Spieler <gold>[player]</gold> hat die Permission <gold>[perm]</gold> und ist dazu nicht berechtigt! Daher wurde er gekickt! <gold>[player]</gold> ist nicht in der Spielerliste!</dark_red>",
|
||||
"[prefix] <dark_red>Player <gold>[player]</gold> has permission <gold>[perm]</gold> and is not authorized to do so! Therefore he was kicked! <gold>[player]</gold> is not on the Player list!</dark_red>"),
|
||||
"[prefix] <dark_red>Spieler <gold><hover:show_text:'<gold>Name:</gold> <yellow>[player]</yellow><br><gold>UUID:</gold> <yellow>[uuid]</yellow>'>[player]</hover></gold> hat die Permission <gold>[perm]</gold> und ist dazu nicht berechtigt! Daher wurde er gekickt! <gold><hover:show_text:'<gold>Name:</gold> <yellow>[player]</yellow><br><gold>UUID:</gold> <yellow>[uuid]</yellow>'>[player]</hover></gold> ist nicht in der Spielerliste!</dark_red>",
|
||||
"[prefix] <dark_red>Player <gold><hover:show_text:'<gold>Name:</gold> <yellow>[player]</yellow><br><gold>UUID:</gold> <yellow>[uuid]</yellow>'>[player]</hover></gold> has permission <gold>[perm]</gold> and is not authorized to do so! Therefore he was kicked! <gold><hover:show_text:'<gold>Name:</gold> <yellow>[player]</yellow><br><gold>UUID:</gold> <yellow>[uuid]</yellow>'>[player]</hover></gold> is not on the Player list!</dark_red>"),
|
||||
|
||||
permissionWhitelistKick("permissionWhitelist.kick",null,
|
||||
"<dark_red>Du wurdest gekickt, da du Permissions besitzt, für die du keine Berechtigung besitzt!</dark_red>",
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.t2code.opsecurity.config.opWhitelist;
|
||||
|
||||
import net.t2code.opsecurity.enums.ConfigParam;
|
||||
import org.bukkit.GameMode;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@ -11,6 +12,8 @@ public enum OPWhitelist {
|
||||
noOpPlayerDeopEnable("opWhitelist.enable", true, ConfigParam.BOOLEAN),
|
||||
noOpPlayerDeopPlayerSendMessage("opWhitelist.noOpPlayerDeop.playerSendMessage", true, ConfigParam.BOOLEAN),
|
||||
noOpPlayerKickEnable("opWhitelist.noOpPlayerKick.enable", true, ConfigParam.BOOLEAN),
|
||||
noOpPlayerSetGameModeEnable("opWhitelist.noOpPlayerSetGameMode.enable", true, ConfigParam.BOOLEAN),
|
||||
noOpPlayerSetGameModeValue("opWhitelist.noOpPlayerSetGameMode.gameMode", GameMode.SURVIVAL, ConfigParam.GAMEMODE),
|
||||
customCommandsEnable("opWhitelist.customCommands.enable", false, ConfigParam.BOOLEAN),
|
||||
customCommandsCommands("opWhitelist.customCommands.commands", Arrays.asList("kick [player] &4You have op but are not authorized to do so, that's why you were kicked!")
|
||||
, ConfigParam.STRINGLIST),
|
||||
@ -25,8 +28,15 @@ public enum OPWhitelist {
|
||||
public List<String> valueStringList;
|
||||
|
||||
public Boolean valueBoolean;
|
||||
public GameMode valueGameMode;
|
||||
public ConfigParam cEnum;
|
||||
|
||||
OPWhitelist(String path, GameMode value, ConfigParam cEnum) {
|
||||
this.path = path;
|
||||
this.valueGameMode = value;
|
||||
this.cEnum = cEnum;
|
||||
}
|
||||
|
||||
OPWhitelist(String listPath,String pathPlayerName, String pathUuid, String playerName, String uuid, ConfigParam cEnum) {
|
||||
this.pathPlayerListPath = listPath;
|
||||
this.pathPlayerName = pathPlayerName;
|
||||
|
@ -6,5 +6,6 @@ public enum ConfigParam {
|
||||
BOOLEAN,
|
||||
STRINGLIST,
|
||||
PLAYERLIST,
|
||||
SOUND
|
||||
SOUND,
|
||||
GAMEMODE
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
package net.t2code.opsecurity.events;
|
||||
|
||||
import net.t2code.opsecurity.check.OpCheck;
|
||||
import net.t2code.opsecurity.config.language.Language;
|
||||
import net.t2code.opsecurity.config.opWhitelist.OPWhitelist;
|
||||
import net.t2code.opsecurity.enums.OpCommandRequest;
|
||||
import net.t2code.opsecurity.objects.PlayerCash;
|
||||
import net.t2code.opsecurity.objects.PlayerObject;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.player.T2CnameHistory;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -14,6 +16,7 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.server.ServerCommandEvent;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
public class OpCommand implements Listener {
|
||||
@EventHandler
|
||||
@ -56,8 +59,7 @@ public class OpCommand implements Listener {
|
||||
Player target = Bukkit.getPlayer(arg);
|
||||
if (OPWhitelist.playerMustBeOnlineToOp.valueBoolean) {
|
||||
if (target == null) return OpCommandRequest.mustOnline;
|
||||
if (!PlayerCash.getOpHashMap().get(target.getName()).playerName.equals(target.getName())) return OpCommandRequest.notWhitelisted;
|
||||
if (!PlayerCash.getOpHashMap().get(target.getName()).uuid.equals(target.getUniqueId().toString().replace("-", ""))) return OpCommandRequest.notWhitelisted;
|
||||
if (!opWhitelist(target.getName(), target.getUniqueId().toString())) return OpCommandRequest.notWhitelisted;
|
||||
}
|
||||
String targetUUID;
|
||||
if (target != null) {
|
||||
@ -69,8 +71,14 @@ public class OpCommand implements Listener {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
if (!PlayerCash.getOpHashMap().get(target.getName()).playerName.equals(arg)) return OpCommandRequest.notWhitelisted;
|
||||
if (!PlayerCash.getOpHashMap().get(target.getName()).uuid.equals(targetUUID.replace("-", ""))) return OpCommandRequest.notWhitelisted;
|
||||
if (!opWhitelist(arg, targetUUID)) return OpCommandRequest.notWhitelisted;
|
||||
return OpCommandRequest.ok;
|
||||
}
|
||||
|
||||
private static Boolean opWhitelist(String playerName, String playerUuid) {
|
||||
for (Map.Entry<String, PlayerObject> playerObject : PlayerCash.getOpHashMap().entrySet()) {
|
||||
if (playerObject.getValue().playerName.equals(playerName) && playerObject.getValue().uuid.equals(playerUuid)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user