Compare commits
33 Commits
3.0.0-SNAP
...
3.1.1
Author | SHA1 | Date | |
---|---|---|---|
0dc694d29f | |||
9351c0dfb7 | |||
98fd0409fd | |||
a2bd88ac7c | |||
dba1e57b91 | |||
e14f91c584 | |||
1547c16093 | |||
44507458e5 | |||
ea54d85ecc | |||
43e51fee59 | |||
466314f206 | |||
47a9080dba | |||
|
af608fad02 | ||
632c23b1ff | |||
6fbd56ea63 | |||
31a958ce7f | |||
|
cfd34f6ce6 | ||
|
050624f517 | ||
|
2bae6f7118 | ||
|
8e851dfc15 | ||
|
94f0a688c9 | ||
|
3ce922c602 | ||
|
1ea97b5874 | ||
dab5a4f557 | |||
5f2d97b5d3 | |||
672335de98 | |||
224f53d027 | |||
930e48484c | |||
|
fc76ba90be | ||
ddd3a8982f | |||
d66f6d0f59 | |||
bbc8f2377b | |||
485b50de7a |
@@ -1,7 +1,8 @@
|
||||
// This claas was created by JaTiTV
|
||||
|
||||
package de.jatitv.opsecurity.util;
|
||||
package de.jatitv.opsecurity.system;
|
||||
|
||||
import de.jatitv.opsecurity.Util;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -27,6 +28,11 @@ import java.util.zip.GZIPOutputStream;
|
||||
|
||||
public class Metrics {
|
||||
|
||||
public static void Bstats() {
|
||||
int pluginId = Util.getBstatsID(); // <-- Replace with the id of your plugin!
|
||||
Metrics metrics = new Metrics(Main.getPlugin(), pluginId);
|
||||
}
|
||||
|
||||
private final Plugin plugin;
|
||||
|
||||
private final MetricsBase metricsBase;
|
||||
|
@@ -6,7 +6,8 @@
|
||||
|
||||
<groupId>net.t2code</groupId>
|
||||
<artifactId>T2C-OPSecurity</artifactId>
|
||||
<version>3.0.0-SNAPSHOT-#1</version>
|
||||
<version>3.1.1</version>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>T2C-OPSecurity</name>
|
||||
@@ -17,6 +18,7 @@
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}_${project.version}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
@@ -81,7 +83,8 @@
|
||||
<dependency>
|
||||
<groupId>net.t2code</groupId>
|
||||
<artifactId>T2CodeLib</artifactId>
|
||||
<version>13.0</version>
|
||||
<version>14.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
|
||||
<dependency>
|
||||
@@ -90,11 +93,5 @@
|
||||
<version>1.18.24</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.22</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
@@ -0,0 +1,60 @@
|
||||
package net.t2code.opsecurity.API;
|
||||
|
||||
import net.t2code.opsecurity.check.OpCheck;
|
||||
import net.t2code.opsecurity.check.PermissionCheck;
|
||||
import net.t2code.opsecurity.config.opWhitelist.OPWhitelist;
|
||||
import net.t2code.opsecurity.config.permissionWhitelist.PermissionWhitelist;
|
||||
import net.t2code.opsecurity.objects.PlayerCache;
|
||||
import net.t2code.opsecurity.objects.PlayerObject;
|
||||
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class T2COpSecAPI {
|
||||
public static boolean checkOPWhiteList(Player player) {
|
||||
if (!OPWhitelist.enable.valueBoolean) return true;
|
||||
String debug = T2Cdebug.debugCode();
|
||||
return OpCheck.opWhitelist(player,debug);
|
||||
}
|
||||
|
||||
public static boolean checkPermissionWhiteList(Player player, String debug) {
|
||||
if (!PermissionWhitelist.enable.valueBoolean) return true;
|
||||
return PermissionCheck.permWhitelist(player, debug);
|
||||
}
|
||||
|
||||
public static T2COpSecAPIPlayerStatus detailCheckOPWhiteList(Player player) {
|
||||
if (!OPWhitelist.enable.valueBoolean) return T2COpSecAPIPlayerStatus.playerOnOpWhitelist;
|
||||
List<String> nameList = new ArrayList<>();
|
||||
List<String> uuidList = new ArrayList<>();
|
||||
for (Map.Entry<String, PlayerObject> playerObject : PlayerCache.getOpHashMap().entrySet()) {
|
||||
nameList.add(playerObject.getValue().playerName);
|
||||
uuidList.add(playerObject.getValue().uuid);
|
||||
}
|
||||
if (!nameList.contains(player.getName())) {
|
||||
return T2COpSecAPIPlayerStatus.playerNameNotOnTheOpWhitelist;
|
||||
}
|
||||
if (!uuidList.contains(player.getUniqueId().toString().replace("-", ""))) {
|
||||
return T2COpSecAPIPlayerStatus.playerUuidNotOnTheOpWhitelist;
|
||||
}
|
||||
return T2COpSecAPIPlayerStatus.playerOnOpWhitelist;
|
||||
}
|
||||
public static T2COpSecAPIPlayerStatus detailCheckPermissionWhiteList(Player player) {
|
||||
if (!PermissionWhitelist.enable.valueBoolean) return T2COpSecAPIPlayerStatus.playerOnPermissionWhitelist;
|
||||
List<String> nameList = new ArrayList<>();
|
||||
List<String> uuidList = new ArrayList<>();
|
||||
for (Map.Entry<String, PlayerObject> playerObject : PlayerCache.getPermissionHashMap().entrySet()) {
|
||||
nameList.add(playerObject.getValue().playerName);
|
||||
uuidList.add(playerObject.getValue().uuid);
|
||||
}
|
||||
if (!nameList.contains(player.getName())) {
|
||||
return T2COpSecAPIPlayerStatus.playerNameNotOnThePermissionWhitelist;
|
||||
}
|
||||
if (!uuidList.contains(player.getUniqueId().toString().replace("-", ""))) {
|
||||
return T2COpSecAPIPlayerStatus.playerUuidNotOnThePermissionWhitelist;
|
||||
}
|
||||
return T2COpSecAPIPlayerStatus.playerOnPermissionWhitelist;
|
||||
}
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
package net.t2code.opsecurity.API;
|
||||
|
||||
public enum T2COpSecAPIPlayerStatus {
|
||||
playerOnOpWhitelist,
|
||||
playerNameNotOnTheOpWhitelist,
|
||||
playerUuidNotOnTheOpWhitelist,
|
||||
playerOnPermissionWhitelist,
|
||||
playerNameNotOnThePermissionWhitelist,
|
||||
playerUuidNotOnThePermissionWhitelist
|
||||
}
|
@@ -8,7 +8,7 @@ public class Util {
|
||||
private static String infoText = "";
|
||||
|
||||
@Getter
|
||||
private static String requiredT2CodeLibVersion = "13.1";
|
||||
private static String requiredT2CodeLibVersion = "14.4";
|
||||
|
||||
@Getter
|
||||
private static String prefix = "§8[§4T2C§8-§2OP§4Security§8]";
|
||||
@@ -16,6 +16,9 @@ public class Util {
|
||||
@Getter
|
||||
private static Integer spigotID = 90739;
|
||||
|
||||
@Getter
|
||||
private static String git = "JaTiTV/T2C-OPSecurity";
|
||||
|
||||
@Getter
|
||||
private static Integer bstatsID = 10858;
|
||||
|
||||
|
@@ -4,11 +4,12 @@ import net.t2code.opsecurity.config.config.Config;
|
||||
import net.t2code.opsecurity.config.language.Language;
|
||||
import net.t2code.opsecurity.config.opWhitelist.OPWhitelist;
|
||||
import net.t2code.opsecurity.events.Events;
|
||||
import net.t2code.opsecurity.objects.PlayerCash;
|
||||
import net.t2code.opsecurity.objects.PlayerCache;
|
||||
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.debug.T2Cdebug;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -16,31 +17,50 @@ import org.bukkit.entity.Player;
|
||||
import java.util.Map;
|
||||
|
||||
public class OpCheck {
|
||||
public static Boolean onCheck(Player player, Boolean join) {
|
||||
public static Boolean onCheck(Player player, Boolean join, String debug) {
|
||||
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 (opWhitelist(player, debug)) return false;
|
||||
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, debug);
|
||||
}
|
||||
});
|
||||
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, String debug) {
|
||||
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]",
|
||||
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));
|
||||
T2Csend.console(Language.opWhitelistNotifyDeop.value.replace("[player]", player.getName()) + "<br>"
|
||||
+ Language.opWhitelistNotifyKick.value.replace("[player]", player.getName()));
|
||||
? 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("["+debug+ "]" +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("["+debug+ "]" +Language.opWhitelistNotifyDeop.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
Events.notifyPlayer(Language.opWhitelistNotifyDeop.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
|
||||
if (OPWhitelist.noOpPlayerDeopPlayerSendMessage.valueBoolean) {
|
||||
Bukkit.getScheduler().runTaskLater(Main.getPlugin(), new Runnable() {
|
||||
@@ -53,25 +73,36 @@ 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("["+debug+ "]" +Language.opWhitelistNotifyKick.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
Events.notifyPlayer(Language.opWhitelistNotifyKick.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
}
|
||||
}
|
||||
if (OPWhitelist.customCommandsEnable.valueBoolean) {
|
||||
for (String cmd : OPWhitelist.customCommandsCommands.valueStringList) {
|
||||
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, String debug) {
|
||||
for (Map.Entry<String, PlayerObject> playerObject : PlayerCache.getOpHashMap().entrySet()) {
|
||||
T2Cdebug.debug(Main.getPlugin(), "[" + debug + "] --------- " + player.getName()+" ---------");
|
||||
T2Cdebug.debug(Main.getPlugin(), "[" + debug + "] opWhitelist playerObject Name: " + playerObject.getValue().playerName);
|
||||
T2Cdebug.debug(Main.getPlugin(), "[" + debug + "] opWhitelist Player Name: " + player.getName());
|
||||
T2Cdebug.debug(Main.getPlugin(), "[" + debug + "] opWhitelist playerObject UUID: " + playerObject.getValue().uuid);
|
||||
T2Cdebug.debug(Main.getPlugin(), "[" + debug + "] opWhitelist Player UUID: " + player.getUniqueId().toString().replace("-", ""));
|
||||
if (playerObject.getValue().playerName.equals(player.getName()) && playerObject.getValue().uuid.equals(player.getUniqueId().toString().replace("-", ""))) {
|
||||
T2Cdebug.debug(Main.getPlugin(), "[" + debug + "] opWhitelist Player on list!");
|
||||
T2Cdebug.debug(Main.getPlugin(),"");
|
||||
return true;
|
||||
} else T2Cdebug.debug(Main.getPlugin(),"");
|
||||
}
|
||||
T2Csend.console(Language.exactKickReason.value.replace("[reason]", "Player UUID: " + player.getUniqueId().toString() + " not whitelisted (opWhitelist)"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -4,50 +4,74 @@ import net.t2code.opsecurity.config.config.Config;
|
||||
import net.t2code.opsecurity.config.language.Language;
|
||||
import net.t2code.opsecurity.config.permissionWhitelist.PermissionWhitelist;
|
||||
import net.t2code.opsecurity.events.Events;
|
||||
import net.t2code.opsecurity.objects.PlayerCash;
|
||||
import net.t2code.opsecurity.objects.PlayerCache;
|
||||
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.debug.T2Cdebug;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class PermissionCheck {
|
||||
public static Boolean onCheck(Player player, Boolean join) {
|
||||
public static Boolean onCheck(Player player, Boolean join, String debug) {
|
||||
if (!PermissionWhitelist.enable.valueBoolean) return false;
|
||||
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));
|
||||
}
|
||||
if (!player.hasPermission(perm)) return false;
|
||||
T2Cdebug.debug(Main.getPlugin(), "[" + debug + "] check Permission: " + perm);
|
||||
if (permWhitelist(player, debug)) return false;
|
||||
Bukkit.getScheduler().runTask(Main.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
execute(player, join, perm, debug);
|
||||
}
|
||||
});
|
||||
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, String debug) {
|
||||
if (join)
|
||||
T2Csend.console("[" + debug + "]" + Language.permissionWhitelistNotifyKick.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
if (Config.notifyJoinWarning.valueBoolean && join) {
|
||||
if (Config.notifyBungee.valueBoolean) {
|
||||
BungeeSenderReceiver.sendToBungee(Language.permissionWhitelistNotifyOnJoin.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
} else
|
||||
Events.notifyPlayer(Language.permissionWhitelistNotifyOnJoin.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
}
|
||||
|
||||
if (PermissionWhitelist.playerWithPermissionKick.valueBoolean) {
|
||||
if (Config.kickCustomCommand.valueBoolean) {
|
||||
T2Ccmd.console(Config.kickCommand.valueString.replace("[perm]", perm).replace("[player]", player.getName()).replace("[reason]", Language.permissionWhitelistKick.value));
|
||||
} else player.kickPlayer(Language.permissionWhitelistKick.value);
|
||||
T2Csend.console("[" + debug + "]" + Language.permissionWhitelistNotifyKick.value.replace("[player]",
|
||||
player.getName()).replace("[perm]", perm).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
}
|
||||
if (PermissionWhitelist.customCommandsEnable.valueBoolean) {
|
||||
for (String cmd : PermissionWhitelist.customCommandsCommands.valueStringList) {
|
||||
T2Ccmd.console(cmd.replace("[player]", player.getName()).replace("[perm]", perm));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Boolean permWhitelist(Player player, String debug) {
|
||||
|
||||
for (Map.Entry<String, PlayerObject> playerObject : PlayerCache.getPermissionHashMap().entrySet()) {
|
||||
T2Cdebug.debug(Main.getPlugin(), "[" + debug + "] --------- " + player.getName() + " ---------");
|
||||
T2Cdebug.debug(Main.getPlugin(), "[" + debug + "] permWhitelist playerObject Name: " + playerObject.getValue().playerName);
|
||||
T2Cdebug.debug(Main.getPlugin(), "[" + debug + "] permWhitelist Player Name: " + player.getName());
|
||||
T2Cdebug.debug(Main.getPlugin(), "[" + debug + "] permWhitelist playerObject UUID: " + playerObject.getValue().uuid);
|
||||
T2Cdebug.debug(Main.getPlugin(), "[" + debug + "] permWhitelist Player UUID: " + player.getUniqueId().toString().replace("-", ""));
|
||||
if (playerObject.getValue().playerName.equals(player.getName()) && playerObject.getValue().uuid.equals(player.getUniqueId().toString().replace("-", ""))) {
|
||||
T2Cdebug.debug(Main.getPlugin(), "[" + debug + "] permWhitelist Player on list!");
|
||||
T2Cdebug.debug(Main.getPlugin(), "");
|
||||
return true;
|
||||
} else T2Cdebug.debug(Main.getPlugin(), "");
|
||||
}
|
||||
T2Csend.console(Language.exactKickReason.value.replace("[reason]", "Player UUID: " + player.getUniqueId().toString() + " not whitelisted (permissionWhitelist)"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -1,12 +1,12 @@
|
||||
// This claas was created by JaTiTV
|
||||
|
||||
|
||||
package net.t2code.opsecurity.check;
|
||||
|
||||
import net.t2code.opsecurity.config.config.Config;
|
||||
import net.t2code.opsecurity.config.opWhitelist.OPWhitelist;
|
||||
import net.t2code.opsecurity.config.permissionWhitelist.PermissionWhitelist;
|
||||
import net.t2code.opsecurity.system.Main;
|
||||
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -20,8 +20,9 @@ public class Timer {
|
||||
@Override
|
||||
public void run() {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
OpCheck.onCheck(player, false);
|
||||
PermissionCheck.onCheck(player, false);
|
||||
String debug = T2Cdebug.debugCode();
|
||||
OpCheck.onCheck(player, false, debug);
|
||||
PermissionCheck.onCheck(player, false, debug);
|
||||
}
|
||||
}
|
||||
}, 0, 20L * Config.checkTimerRefreshInSec.valueInt);
|
||||
|
@@ -4,11 +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.system.Main;
|
||||
import net.t2code.opsecurity.system.Permissions;
|
||||
import net.t2code.t2codelib.SPIGOT.api.commands.T2Ctab;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -42,11 +39,6 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
|
||||
case "version":
|
||||
case "ver":
|
||||
Commands.info(sender);
|
||||
break;
|
||||
case "test":
|
||||
T2Csend.debugmsg(Main.getPlugin(), OPWhitelist.enable.valueBoolean.toString());
|
||||
T2Csend.debugmsg(Main.getPlugin(), Config.onlyOPcanUseThePlugin.valueBoolean.toString());
|
||||
|
||||
break;
|
||||
case "help":
|
||||
default:
|
||||
|
@@ -1,12 +1,13 @@
|
||||
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.objects.PlayerCash;
|
||||
import net.t2code.opsecurity.system.Main;
|
||||
import net.t2code.opsecurity.system.Permissions;
|
||||
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -52,13 +53,12 @@ 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!");
|
||||
if (Config.onlyOPcanUseThePlugin.valueBoolean) {
|
||||
String debug = T2Cdebug.debugCode();
|
||||
if (!OpCheck.opWhitelist(player,debug)) {
|
||||
sender.sendMessage(Util.getPrefix() + " §4You are not on the Whitelist!"); // todo
|
||||
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;
|
||||
}
|
||||
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 + ">");
|
||||
|
@@ -5,12 +5,14 @@ import net.t2code.opsecurity.config.config.Config;
|
||||
import net.t2code.opsecurity.config.language.Language;
|
||||
import net.t2code.opsecurity.config.opWhitelist.OPWhitelist;
|
||||
import net.t2code.opsecurity.config.permissionWhitelist.PermissionWhitelist;
|
||||
import net.t2code.opsecurity.objects.PlayerCash;
|
||||
import net.t2code.opsecurity.objects.PlayerCache;
|
||||
import net.t2code.opsecurity.objects.PlayerObject;
|
||||
import net.t2code.opsecurity.system.Main;
|
||||
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.languages.SelectLibMsg;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
@@ -23,12 +25,12 @@ public class FileSelect {
|
||||
File config = new File(Main.getPath(), "config.yml");
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
for (Config value : Config.values()) {
|
||||
switch (value.cEnum) {
|
||||
switch (value.configParam) {
|
||||
case STRING:
|
||||
if (!yamlConfiguration.contains(value.path)) {
|
||||
yamlConfiguration.set(value.path, value.valueString);
|
||||
}
|
||||
value.valueString = T2Creplace.replace(Util.getPrefix(), yamlConfiguration.getString(value.path));
|
||||
value.valueString = T2Creplace.replace(Util.getPrefix(), Objects.requireNonNull(yamlConfiguration.getString(value.path)));
|
||||
break;
|
||||
case SOUND:
|
||||
if (!yamlConfiguration.contains(value.path)) {
|
||||
@@ -83,7 +85,7 @@ public class FileSelect {
|
||||
}
|
||||
}
|
||||
}
|
||||
T2Csend.debug(Main.getPlugin(), "save: " + language);
|
||||
T2Cdebug.debug(Main.getPlugin(), "save: " + language);
|
||||
try {
|
||||
yamlConfiguration.save(config);
|
||||
} catch (IOException e) {
|
||||
@@ -91,10 +93,9 @@ public class FileSelect {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String selectMSG;
|
||||
File config = new File(Main.getPath(), "languages/" + Config.language.valueString + ".yml");
|
||||
T2Csend.debug(Main.getPlugin(), config.getAbsolutePath());
|
||||
T2Cdebug.debug(Main.getPlugin(), config.getAbsolutePath());
|
||||
if (!config.isFile()) {
|
||||
T2Csend.console(Util.getPrefix());
|
||||
T2Csend.console(Util.getPrefix() + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
@@ -108,13 +109,14 @@ public class FileSelect {
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
|
||||
for (Language value : Language.values()) {
|
||||
T2Csend.debug(Main.getPlugin(), "Select: File: " + config.getName() + " Path: " + value.path);
|
||||
T2Cdebug.debug(Main.getPlugin(), "Select: File: " + config.getName() + " Path: " + value.path);
|
||||
value.value = T2Creplace.replace(Util.getPrefix(), yamlConfiguration.getString(value.path));
|
||||
}
|
||||
T2Csend.console(Util.getPrefix() + " §2Language successfully selected to: §6" + selectMSG + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||
}
|
||||
|
||||
public static void selectOpWhitelist() {
|
||||
PlayerCache.getOpHashMap().clear();
|
||||
File config = new File(Main.getPath(), "opWhitelist.yml");
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
for (OPWhitelist value : OPWhitelist.values()) {
|
||||
@@ -127,7 +129,7 @@ public class FileSelect {
|
||||
break;
|
||||
case STRINGLIST:
|
||||
if (!yamlConfiguration.contains(value.path)) {
|
||||
yamlConfiguration.set(value.path, value.valueBoolean);
|
||||
yamlConfiguration.set(value.path, value.valueStringList);
|
||||
}
|
||||
value.valueStringList = T2Creplace.replace(Util.getPrefix(), yamlConfiguration.getStringList(value.path));
|
||||
break;
|
||||
@@ -139,10 +141,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)),
|
||||
yamlConfiguration.getString(value.pathPlayerUuid.replace("KEY", key).replace("-", "")));
|
||||
PlayerCash.getOpHashMap().put(key, playerObject);
|
||||
name,
|
||||
yamlConfiguration.getString(value.pathPlayerUuid.replace("KEY", key)).replace("-", ""));
|
||||
PlayerCache.getOpHashMap().put(name, playerObject);
|
||||
}
|
||||
break;
|
||||
case GAMEMODE:
|
||||
if (!yamlConfiguration.contains(value.path)) {
|
||||
yamlConfiguration.set(value.path, value.valueGameMode.toString());
|
||||
}
|
||||
try {
|
||||
value.valueGameMode = GameMode.valueOf(yamlConfiguration.getString(value.path).toUpperCase());
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
value.valueGameMode = GameMode.SURVIVAL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -155,6 +169,7 @@ public class FileSelect {
|
||||
}
|
||||
|
||||
public static void selectPermissionWhitelist() {
|
||||
PlayerCache.getPermissionHashMap().clear();
|
||||
File config = new File(Main.getPath(), "permissionWhitelist.yml");
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
for (PermissionWhitelist value : PermissionWhitelist.values()) {
|
||||
@@ -167,7 +182,7 @@ public class FileSelect {
|
||||
break;
|
||||
case STRINGLIST:
|
||||
if (!yamlConfiguration.contains(value.path)) {
|
||||
yamlConfiguration.set(value.path, value.valueBoolean);
|
||||
yamlConfiguration.set(value.path, value.valueStringList);
|
||||
}
|
||||
value.valueStringList = T2Creplace.replace(Util.getPrefix(), yamlConfiguration.getStringList(value.path));
|
||||
break;
|
||||
@@ -179,10 +194,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)),
|
||||
yamlConfiguration.getString(value.pathPlayerUuid.replace("KEY", key).replace("-", "")));
|
||||
PlayerCash.getPermissionHashMap().put(key, playerObject);
|
||||
name,
|
||||
yamlConfiguration.getString(value.pathPlayerUuid.replace("KEY", key)).replace("-", ""));
|
||||
PlayerCache.getPermissionHashMap().put(name, playerObject);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@@ -9,13 +9,18 @@ public enum Config {
|
||||
language("plugin.language", "english", ConfigParam.STRING),
|
||||
onlyOPcanUseThePlugin("plugin.onlyOPcanUseThePlugin", true, ConfigParam.BOOLEAN),
|
||||
|
||||
updateCheckOnJoin("plugin.updateCheck.onJoin",true,ConfigParam.BOOLEAN),
|
||||
updateCheckSeePreReleaseUpdates("plugin.updateCheck.seePreReleaseUpdates",true,ConfigParam.BOOLEAN),
|
||||
updateCheckTimeInterval("plugin.updateCheck.timeInterval",60,ConfigParam.INTEGER),
|
||||
|
||||
checkOnJoin("check.onJoin", true, ConfigParam.BOOLEAN),
|
||||
checkOnInteract("check.onInteract", true, ConfigParam.BOOLEAN),
|
||||
checkOnCommand("check.onCommand", true, ConfigParam.BOOLEAN),
|
||||
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),
|
||||
@@ -26,30 +31,30 @@ public enum Config {
|
||||
public Integer valueInt;
|
||||
public Boolean valueBoolean;
|
||||
public Sound sound;
|
||||
public ConfigParam cEnum;
|
||||
public ConfigParam configParam;
|
||||
|
||||
Config(String path, String value, ConfigParam cEnum) {
|
||||
this.path = path;
|
||||
this.valueString = value;
|
||||
this.cEnum = cEnum;
|
||||
this.configParam = cEnum;
|
||||
}
|
||||
|
||||
Config(String path, Sound value, ConfigParam cEnum) {
|
||||
this.path = path;
|
||||
this.sound = value;
|
||||
this.cEnum = cEnum;
|
||||
this.configParam = cEnum;
|
||||
}
|
||||
|
||||
Config(String path, Integer value, ConfigParam cEnum) {
|
||||
this.path = path;
|
||||
this.valueInt = value;
|
||||
this.cEnum = cEnum;
|
||||
this.configParam = cEnum;
|
||||
}
|
||||
|
||||
Config(String path, Boolean value, ConfigParam cEnum) {
|
||||
this.path = path;
|
||||
this.valueBoolean = value;
|
||||
this.cEnum = cEnum;
|
||||
this.configParam = cEnum;
|
||||
}
|
||||
|
||||
public static Sound sound() {
|
||||
|
@@ -30,36 +30,37 @@ 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>",
|
||||
"<dark_red>You were kicked because you have permissions to which you do not have permission!</dark_red>"),
|
||||
"&4Du wurdest gekickt, da du Permissions besitzt, für die du keine Berechtigung besitzt!",
|
||||
"&4You were kicked because you have permissions to which you do not have permission!"),
|
||||
|
||||
exactKickReason("console.exactKickReason", null,
|
||||
"[prefix] <dark_red>Genauer Grund:</dark_red> <gold>[reason]</gold>",
|
||||
"[prefix] <dark_red>Exact reason:</dark_red> <gold>[reason]</gold>");
|
||||
|
@@ -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;
|
||||
@@ -8,9 +9,11 @@ import java.util.List;
|
||||
public enum OPWhitelist {
|
||||
enable("opWhitelist.enable", false, ConfigParam.BOOLEAN),
|
||||
playerMustBeOnlineToOp("opWhitelist.playerMustBeOnlineToOp", true, ConfigParam.BOOLEAN),
|
||||
noOpPlayerDeopEnable("opWhitelist.enable", true, ConfigParam.BOOLEAN),
|
||||
noOpPlayerDeopEnable("opWhitelist.noOpPlayerDeop.enable", true, ConfigParam.BOOLEAN),
|
||||
noOpPlayerDeopPlayerSendMessage("opWhitelist.noOpPlayerDeop.playerSendMessage", true, ConfigParam.BOOLEAN),
|
||||
noOpPlayerKickEnable("opWhitelist.noOpPlayerKick.enable", true, ConfigParam.BOOLEAN),
|
||||
noOpPlayerSetGameModeEnable("opWhitelist.noOpPlayerSetGameMode.enable", true, ConfigParam.BOOLEAN),
|
||||
noOpPlayerSetGameModeValue("opWhitelist.noOpPlayerSetGameMode.gameMode", GameMode.SURVIVAL, ConfigParam.GAMEMODE),
|
||||
customCommandsEnable("opWhitelist.customCommands.enable", false, ConfigParam.BOOLEAN),
|
||||
customCommandsCommands("opWhitelist.customCommands.commands", Arrays.asList("kick [player] &4You have op but are not authorized to do so, that's why you were kicked!")
|
||||
, ConfigParam.STRINGLIST),
|
||||
@@ -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
|
||||
}
|
||||
|
@@ -6,6 +6,7 @@ import net.t2code.opsecurity.check.OpCheck;
|
||||
import net.t2code.opsecurity.check.PermissionCheck;
|
||||
import net.t2code.opsecurity.system.Main;
|
||||
import net.t2code.opsecurity.system.Permissions;
|
||||
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -28,9 +29,13 @@ public class Events implements Listener {
|
||||
public void CommandSendEvent(PlayerCommandPreprocessEvent event) {
|
||||
if (!Config.checkOnCommand.valueBoolean) return;
|
||||
Player player = event.getPlayer();
|
||||
T2Csend.debugmsg(Main.getPlugin(), "1 "+ OpCheck.onCheck(player,false));
|
||||
T2Csend.debugmsg(Main.getPlugin(), "1 "+ PermissionCheck.onCheck(player,false));
|
||||
if (OpCheck.onCheck(player, false) || PermissionCheck.onCheck(player, false)) {
|
||||
String debug = T2Cdebug.debugCode();
|
||||
if (OpCheck.onCheck(player, false, debug)) {
|
||||
if (event.isCancelled()) return;
|
||||
event.setCancelled(true);
|
||||
}
|
||||
String debug2 = T2Cdebug.debugCode();
|
||||
if (PermissionCheck.onCheck(player, false, debug2)) {
|
||||
if (event.isCancelled()) return;
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@@ -40,9 +45,13 @@ public class Events implements Listener {
|
||||
public void PlayerChatEvent(PlayerChatEvent event) {
|
||||
if (!Config.checkOnChat.valueBoolean) return;
|
||||
Player player = event.getPlayer();
|
||||
T2Csend.debugmsg(Main.getPlugin(), "2 "+OpCheck.onCheck(player,false));
|
||||
T2Csend.debugmsg(Main.getPlugin(), "2 "+PermissionCheck.onCheck(player,false));
|
||||
if (OpCheck.onCheck(player, false) || PermissionCheck.onCheck(player, false)) {
|
||||
String debug = T2Cdebug.debugCode();
|
||||
if (OpCheck.onCheck(player, false, debug)) {
|
||||
if (event.isCancelled()) return;
|
||||
event.setCancelled(true);
|
||||
}
|
||||
String debug2 = T2Cdebug.debugCode();
|
||||
if (PermissionCheck.onCheck(player, false, debug2)) {
|
||||
if (event.isCancelled()) return;
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@@ -51,11 +60,16 @@ public class Events implements Listener {
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEvent event) {
|
||||
if (!Config.checkOnInteract.valueBoolean) return;
|
||||
Player player = event.getPlayer();
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(Main.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (OpCheck.onCheck(player, false) || PermissionCheck.onCheck(player, false)) {
|
||||
Player player = event.getPlayer();
|
||||
String debug = T2Cdebug.debugCode();
|
||||
if (OpCheck.onCheck(player, false, debug)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
String debug2 = T2Cdebug.debugCode();
|
||||
if (PermissionCheck.onCheck(player, false, debug2)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@@ -65,12 +79,14 @@ public class Events implements Listener {
|
||||
@EventHandler
|
||||
public void onJoinCheck(PlayerJoinEvent event) {
|
||||
if (!Config.checkOnJoin.valueBoolean) return;
|
||||
Player player = event.getPlayer();
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(Main.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
OpCheck.onCheck(player, true);
|
||||
PermissionCheck.onCheck(player, true);
|
||||
Player player = event.getPlayer();
|
||||
String debug = T2Cdebug.debugCode();
|
||||
OpCheck.onCheck(player, true, debug);
|
||||
String debug2 = T2Cdebug.debugCode();
|
||||
PermissionCheck.onCheck(player, true, debug2);
|
||||
}
|
||||
}, 1L);
|
||||
}
|
||||
|
@@ -3,7 +3,10 @@ package net.t2code.opsecurity.events;
|
||||
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.PlayerCache;
|
||||
import net.t2code.opsecurity.objects.PlayerObject;
|
||||
import net.t2code.opsecurity.system.Main;
|
||||
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.player.T2CnameHistory;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -14,6 +17,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
|
||||
@@ -54,11 +58,12 @@ public class OpCommand implements Listener {
|
||||
if (command.charAt(0) == '/') command = command.replaceFirst("/", "");
|
||||
String arg = command.replace("op ", "");
|
||||
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) {
|
||||
targetUUID = target.getUniqueId().toString();
|
||||
@@ -69,8 +74,22 @@ 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 : PlayerCache.getOpHashMap().entrySet()) {
|
||||
T2Cdebug.debug(Main.getPlugin(), "--------- " + playerName);
|
||||
T2Cdebug.debug(Main.getPlugin(),"opWhitelist (op command) playerObject Name: "+playerObject.getValue().playerName );
|
||||
T2Cdebug.debug(Main.getPlugin(),"opWhitelist (op command) Player Name: "+ playerName );
|
||||
T2Cdebug.debug(Main.getPlugin(),"opWhitelist (op command) playerObject UUID: "+playerObject.getValue().uuid );
|
||||
T2Cdebug.debug(Main.getPlugin(),"opWhitelist (op command) Player UUID: "+ playerUuid );
|
||||
if (playerObject.getValue().playerName.equals(playerName) && playerObject.getValue().uuid.equals(playerUuid.replace("-", ""))) {
|
||||
T2Cdebug.debug(Main.getPlugin(),"opWhitelist (op command) on list!");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@ import lombok.Getter;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class PlayerCash {
|
||||
public class PlayerCache {
|
||||
@Getter
|
||||
private static HashMap<String, PlayerObject> opHashMap = new HashMap<String, PlayerObject>();
|
||||
@Getter
|
@@ -1,6 +1,7 @@
|
||||
package net.t2code.opsecurity.system;
|
||||
|
||||
import net.t2code.opsecurity.events.Events;
|
||||
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -27,7 +28,7 @@ public class BungeeSenderReceiver implements PluginMessageListener {
|
||||
@Override
|
||||
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
|
||||
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(message));
|
||||
T2Csend.debug(Main.getPlugin(), "stream: " + stream.toString());
|
||||
T2Cdebug.debug(Main.getPlugin(), "stream: " + stream.toString());
|
||||
try {
|
||||
String subChannel = stream.readUTF();
|
||||
String information = stream.readUTF();
|
||||
|
@@ -3,6 +3,7 @@ package net.t2code.opsecurity.system;
|
||||
import net.t2code.opsecurity.Util;
|
||||
import net.t2code.opsecurity.command.CmdExecuter;
|
||||
import net.t2code.opsecurity.config.FileSelect;
|
||||
import net.t2code.opsecurity.config.config.Config;
|
||||
import net.t2code.opsecurity.config.config.Converter;
|
||||
import net.t2code.opsecurity.events.Events;
|
||||
import net.t2code.opsecurity.events.OpCommand;
|
||||
@@ -11,6 +12,7 @@ import net.t2code.opsecurity.check.Timer;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
||||
import net.t2code.t2codelib.SPIGOT.api.register.T2Cregister;
|
||||
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
|
||||
import org.checkerframework.checker.units.qual.C;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
@@ -39,7 +41,8 @@ public class Load {
|
||||
|
||||
Timer.refreshTimer();
|
||||
Permissions.register();
|
||||
T2CupdateAPI.onUpdateCheck(plugin, Util.getPrefix(), Util.getSpigotID(), Util.getDiscord());
|
||||
T2CupdateAPI.onUpdateCheck(plugin, Util.getPrefix(),Util.getGit(),Util.getSpigotID(),Util.getDiscord(), Config.updateCheckOnJoin.valueBoolean,
|
||||
Config.updateCheckSeePreReleaseUpdates.valueBoolean, Config.updateCheckTimeInterval.valueInt);
|
||||
Metrics.Bstats(plugin, Util.getBstatsID());
|
||||
T2Ctemplate.onLoadFooter(Util.getPrefix(), long_);
|
||||
}
|
||||
|
@@ -32,6 +32,20 @@ public final class Main extends JavaPlugin {
|
||||
autor = this.getDescription().getAuthors();
|
||||
version = this.getDescription().getVersion();
|
||||
if (pluginNotFound("T2CodeLib", 96388, Util.getRequiredT2CodeLibVersion())) return;
|
||||
load();
|
||||
|
||||
|
||||
}
|
||||
private static void load(){
|
||||
if (!Bukkit.getPluginManager().getPlugin("T2CodeLib").isEnabled()){
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
load();
|
||||
}
|
||||
},5L);
|
||||
return;
|
||||
}
|
||||
t2codeLib = true;
|
||||
Load.onLoad(plugin,autor,version);
|
||||
}
|
||||
|
@@ -6,9 +6,10 @@ api-version: 1.13
|
||||
load: STARTUP
|
||||
prefix: T2C-OPSecurity
|
||||
authors: [ JaTiTV ]
|
||||
|
||||
softdepend:
|
||||
- T2CodeLib
|
||||
- OPSecurity
|
||||
|
||||
commands:
|
||||
t2c-opsecurity:
|
||||
aliases: [opsec, opsecurity]
|
69
README.md
Normal file
69
README.md
Normal file
@@ -0,0 +1,69 @@
|
||||
<p align="center">
|
||||
<img src="https://i.imgur.com/TjwVdDO.png" width="300">
|
||||
</p>
|
||||
|
||||
---
|
||||
# Links
|
||||
* [Spigot](https://www.spigotmc.org/resources/t2c-opsecurity-permission-security-1-8-x-1-19-x.90739/)
|
||||
* [Discord](http://dc.T2Code.net)
|
||||
|
||||
---
|
||||
|
||||
<img src="https://i.imgur.com/9ahfmOG.png" width="600">
|
||||
|
||||
With OPSecurity you can specify usernames that are allowed to have OP or certain permissions.
|
||||
If someone enters the server with OP who is not on this whitelist, Optional can be kicked or have OP removed.
|
||||
|
||||
|
||||
This plugin also protects players from getting OP via unauthorized ways, e.g. hacked client, because only players who are on the OP whitelist can get OP with the command /op.
|
||||
|
||||
You can also use a timer that checks every few seconds (adjustable) if there is a player with OP or a permission on the server who is not on the whitelist.
|
||||
|
||||
Please note that you can only give OP via the console to players who are on the whitelist!
|
||||
|
||||
**Features:**
|
||||
- Protection against op hacks
|
||||
- Protection for specific permissions
|
||||
- Decide who may have OP
|
||||
- Even via console protects OP Security
|
||||
|
||||
Just come to the support Discord for further questions.
|
||||
|
||||
|
||||
|
||||
**You can use MiniMessage:**
|
||||
|
||||
Wiki: https://docs.adventure.kyori.net/minimessage/format.html
|
||||
|
||||
WebUI: https://webui.adventure.kyori.net
|
||||
|
||||
|
||||
<img src="https://i.imgur.com/55BlvCg.png" width="600">
|
||||
|
||||
**/t2c-opsecurity** | **/opsecurity** | **/opsec**
|
||||
|
||||
**/t2c-opsecurity help** - Open the help.
|
||||
|
||||
**/t2c-opsecurity info** - See the current plugin version.
|
||||
|
||||
**/t2c-opsecurity reload** - Reloads the Plugin.
|
||||
|
||||
|
||||
*t2c.opsecurity.notify* - Permission for ingame notifications when a player joins that is not on the whitelist
|
||||
|
||||
*t2c.opsecurity.updatemsg* - Update Check on join
|
||||
|
||||
*t2c.opsecurity.command.reload* - Reload command
|
||||
|
||||
*t2c.opsecurity.command.info* - Info command
|
||||
|
||||
*t2c.opsecurity.command.help* - Help command
|
||||
|
||||
*t2c.opsecurity.admin* - All permissions of T2C-OPSecurity
|
||||
|
||||
|
||||
<img src="https://i.imgur.com/YbDziZO.png" width="600">
|
||||
|
||||
---
|
||||
<img src="https://i.imgur.com/HoZSt7c.png" width="600">
|
||||
<img src="https://bstats.org/signatures/bukkit/OPWhitelist.svg" width="600">
|
Reference in New Issue
Block a user