31 Commits

Author SHA1 Message Date
98fd0409fd load bugfix
Fixed an error that occurred when loading the plugin, because since paper build 404 the T2CodeLib was loaded only after OPSecurity
2023-02-28 00:15:48 +01:00
a2bd88ac7c 3.1.0 | add API 2022-12-28 08:12:36 +01:00
dba1e57b91 code changes 2022-12-23 00:38:55 +01:00
e14f91c584 Update OPWhitelist.java 2022-12-22 02:14:04 +01:00
1547c16093 3.0.7 | Bugfix
- noOpPlayerDeop.enable' was missing in opWhitelist.yml and was read in incorrectly
- kick.customCommand.Enable' was corrected to 'kick.customCommand.enable' in config.yml
2022-12-12 11:38:45 +01:00
44507458e5 3.0.6 2022-11-20 20:17:55 +01:00
ea54d85ecc 3.0.5
https://git.t2code.net/JaTiTV/T2C-OPSecurity/releases/tag/3.0.5
2022-11-19 03:12:53 +01:00
43e51fee59 3.0.4
Bugfix:
- In Permission Whitelist, the customCommands function did not work as expected.
2022-11-17 21:07:15 +01:00
466314f206 Merge branch 'main' of https://git.t2code.net/JaTiTV/OPSecurity 2022-11-15 02:33:22 +01:00
47a9080dba Update pom.xml 2022-11-15 02:31:56 +01:00
JaTiTV
af608fad02 Merge pull request 'dev-3.0.3' (#9) from dev-3.0.3 into main
Reviewed-on: #9
2022-11-15 01:27:43 +00:00
632c23b1ff update to T2CodeLib 13.4 (sn 1) 2022-11-15 00:35:45 +01:00
6fbd56ea63 3.0.3
New Update Checker
2022-11-14 20:15:30 +01:00
31a958ce7f Update pom.xml 2022-11-14 19:50:48 +01:00
JaTiTV
cfd34f6ce6 „README.md“ ändern 2022-11-14 15:55:21 +00:00
JaTiTV
050624f517 „README.md“ ändern 2022-11-14 15:12:16 +00:00
JaTiTV
2bae6f7118 „README.md“ ändern 2022-11-14 15:11:38 +00:00
JaTiTV
8e851dfc15 „README.md“ ändern 2022-11-14 15:10:24 +00:00
JaTiTV
94f0a688c9 „README.md“ ändern 2022-11-14 15:09:37 +00:00
JaTiTV
3ce922c602 „README.md“ ändern 2022-11-14 15:06:00 +00:00
JaTiTV
1ea97b5874 „README.md“ hinzufügen 2022-11-14 15:05:13 +00:00
dab5a4f557 Update pom.xml 2022-11-14 14:19:07 +01:00
5f2d97b5d3 Merge branch '3.0.0-Recode' 2022-11-13 16:02:24 +01:00
672335de98 3.0.2
https://www.spigotmc.org/resources/t2c-opsecurity-permission-security-1-8-x-1-19-x.90739/update?update=478946
2022-11-13 15:54:47 +01:00
224f53d027 3.0.1
https://www.spigotmc.org/resources/t2c-opsecurity-permission-security-1-8-x-1-19-x.90739/update?update=478627
2022-11-09 23:20:25 +01:00
930e48484c 3.0.0
https://www.spigotmc.org/resources/t2c-opsecurity-permission-security-1-8-x-1-19-x.90739/update?update=478193
2022-11-05 12:41:56 +01:00
JaTiTV
fc76ba90be Merge pull request '2.4.3' (#5) from customCommands-fix into main
Reviewed-on: JaTiTV/OPSecurity#5
2022-11-02 18:01:26 +00:00
ddd3a8982f Update Check.java 2022-11-02 18:30:02 +01:00
d66f6d0f59 small code changes 2022-10-25 17:12:54 +02:00
bbc8f2377b 2.4.3
T2CodeLib update to API Version 13.0
Small code changes
2022-10-25 17:06:36 +02:00
485b50de7a 2.4.3-DEV-1 2022-09-05 20:25:23 +02:00
22 changed files with 369 additions and 125 deletions

View File

@@ -1,7 +1,8 @@
// This claas was created by JaTiTV // 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.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@@ -27,6 +28,11 @@ import java.util.zip.GZIPOutputStream;
public class Metrics { 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 Plugin plugin;
private final MetricsBase metricsBase; private final MetricsBase metricsBase;

View File

@@ -6,7 +6,8 @@
<groupId>net.t2code</groupId> <groupId>net.t2code</groupId>
<artifactId>T2C-OPSecurity</artifactId> <artifactId>T2C-OPSecurity</artifactId>
<version>3.0.0-SNAPSHOT-#1</version> <version>3.1.0</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>T2C-OPSecurity</name> <name>T2C-OPSecurity</name>
@@ -17,6 +18,7 @@
</properties> </properties>
<build> <build>
<finalName>${project.artifactId}_${project.version}</finalName>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
@@ -81,7 +83,8 @@
<dependency> <dependency>
<groupId>net.t2code</groupId> <groupId>net.t2code</groupId>
<artifactId>T2CodeLib</artifactId> <artifactId>T2CodeLib</artifactId>
<version>13.0</version> <version>13.4</version>
<scope>provided</scope>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok --> <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency> <dependency>
@@ -90,11 +93,5 @@
<version>1.18.24</version> <version>1.18.24</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@@ -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.config.Config;
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.messages.T2Csend;
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;
return OpCheck.opWhitelist(player);
}
public static boolean checkPermissionWhiteList(Player player) {
if (!PermissionWhitelist.enable.valueBoolean) return true;
return PermissionCheck.permWhitelist(player);
}
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;
}
}

View File

@@ -0,0 +1,10 @@
package net.t2code.opsecurity.API;
public enum T2COpSecAPIPlayerStatus {
playerOnOpWhitelist,
playerNameNotOnTheOpWhitelist,
playerUuidNotOnTheOpWhitelist,
playerOnPermissionWhitelist,
playerNameNotOnThePermissionWhitelist,
playerUuidNotOnThePermissionWhitelist
}

View File

@@ -8,7 +8,7 @@ public class Util {
private static String infoText = ""; private static String infoText = "";
@Getter @Getter
private static String requiredT2CodeLibVersion = "13.1"; private static String requiredT2CodeLibVersion = "13.4";
@Getter @Getter
private static String prefix = "§8[§4T2C§8-§2OP§4Security§8]"; private static String prefix = "§8[§4T2C§8-§2OP§4Security§8]";
@@ -16,6 +16,9 @@ public class Util {
@Getter @Getter
private static Integer spigotID = 90739; private static Integer spigotID = 90739;
@Getter
private static String git = "JaTiTV/T2C-OPSecurity";
@Getter @Getter
private static Integer bstatsID = 10858; private static Integer bstatsID = 10858;

View File

@@ -4,7 +4,7 @@ import net.t2code.opsecurity.config.config.Config;
import net.t2code.opsecurity.config.language.Language; import net.t2code.opsecurity.config.language.Language;
import net.t2code.opsecurity.config.opWhitelist.OPWhitelist; import net.t2code.opsecurity.config.opWhitelist.OPWhitelist;
import net.t2code.opsecurity.events.Events; 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.objects.PlayerObject;
import net.t2code.opsecurity.system.BungeeSenderReceiver; import net.t2code.opsecurity.system.BungeeSenderReceiver;
import net.t2code.opsecurity.system.Main; import net.t2code.opsecurity.system.Main;
@@ -20,27 +20,45 @@ public class OpCheck {
if (!OPWhitelist.enable.valueBoolean) return false; if (!OPWhitelist.enable.valueBoolean) return false;
if (!player.isOp()) return false; if (!player.isOp()) return false;
if (opWhitelist(player)) 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) { private static void execute(Player player, Boolean join) {
if (Config.notifyBungee.valueBoolean ) { if (Config.notifyJoinWarning.valueBoolean && join) {
BungeeSenderReceiver.sendToBungee(Language.opWhitelistNotifyOnJoin.value.replace("[player]", player.getName())); if (Config.notifyBungee.valueBoolean) {
} else Events.notifyPlayer(Language.opWhitelistNotifyOnJoin.value.replace("[player]", player.getName())); 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) { if (OPWhitelist.noOpPlayerDeopEnable.valueBoolean) {
player.setOp(false); player.setOp(false);
if (OPWhitelist.noOpPlayerKickEnable.valueBoolean) { if (OPWhitelist.noOpPlayerKickEnable.valueBoolean) {
if (!OPWhitelist.customCommandsEnable.valueBoolean) T2Ccmd.console(Config.kickCommand.path.replace("[player]", player.getName()).replace("[reason]", if (!OPWhitelist.customCommandsEnable.valueBoolean) {
OPWhitelist.noOpPlayerKickEnable.valueBoolean && OPWhitelist.noOpPlayerDeopEnable.valueBoolean && OPWhitelist.noOpPlayerDeopPlayerSendMessage.valueBoolean if (Config.kickCustomCommand.valueBoolean) {
? Language.opWhitelistKick.value + "<br><br>" + Language.opWhitelistDeop.value : Language.opWhitelistKick.value)); T2Ccmd.console(Config.kickCommand.valueString.replace("[player]", player.getName()).replace("[reason]",
T2Csend.console(Language.opWhitelistNotifyDeop.value.replace("[player]", player.getName()) + "<br>" OPWhitelist.noOpPlayerKickEnable.valueBoolean && OPWhitelist.noOpPlayerDeopEnable.valueBoolean && OPWhitelist.noOpPlayerDeopPlayerSendMessage.valueBoolean
+ 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(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>" 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 { } else {
T2Csend.console(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())); Events.notifyPlayer(Language.opWhitelistNotifyDeop.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
if (OPWhitelist.noOpPlayerDeopPlayerSendMessage.valueBoolean) { if (OPWhitelist.noOpPlayerDeopPlayerSendMessage.valueBoolean) {
Bukkit.getScheduler().runTaskLater(Main.getPlugin(), new Runnable() { Bukkit.getScheduler().runTaskLater(Main.getPlugin(), new Runnable() {
@@ -53,25 +71,35 @@ public class OpCheck {
} }
} }
if (OPWhitelist.noOpPlayerKickEnable.valueBoolean) { if (OPWhitelist.noOpPlayerKickEnable.valueBoolean) {
if (!OPWhitelist.customCommandsEnable.valueBoolean) if (!OPWhitelist.noOpPlayerDeopEnable.valueBoolean) {
T2Ccmd.console(Config.kickCommand.path.replace("[player]", player.getName()).replace("[reason]", Language.opWhitelistKick.value)); if (!OPWhitelist.customCommandsEnable.valueBoolean) {
T2Csend.console(Language.opWhitelistNotifyKick.value.replace("[player]", player.getName())); if (Config.kickCustomCommand.valueBoolean) {
Events.notifyPlayer(Language.opWhitelistNotifyKick.value.replace("[player]", player.getName())); 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) { if (OPWhitelist.customCommandsEnable.valueBoolean) {
for (String cmd : OPWhitelist.customCommandsCommands.valueStringList) { for (String cmd : OPWhitelist.customCommandsCommands.valueStringList) {
T2Ccmd.console(cmd.replace("[player]", player.getName())); T2Ccmd.console(cmd.replace("[player]", player.getName()));
} }
} }
return true;
} }
private static Boolean opWhitelist(Player player) { public static Boolean opWhitelist(Player player) {
for (Map.Entry<String, PlayerObject> playerObject : PlayerCash.getOpHashMap().entrySet()){ for (Map.Entry<String, PlayerObject> playerObject : PlayerCache.getOpHashMap().entrySet()) {
if (playerObject.getValue().playerName.equals(player.getName())) return true; T2Csend.debug(Main.getPlugin(), "--------- " + player.getName());
if (playerObject.getValue().uuid.equals(player.getUniqueId().toString())) return true; T2Csend.debug(Main.getPlugin(), "opWhitelist playerObject Name: " + playerObject.getValue().playerName);
T2Csend.debug(Main.getPlugin(), "opWhitelist Player Name: " + player.getName());
T2Csend.debug(Main.getPlugin(), "opWhitelist playerObject UUID: " + playerObject.getValue().uuid);
T2Csend.debug(Main.getPlugin(), "opWhitelist Player UUID: " + player.getUniqueId().toString().replace("-", ""));
if (playerObject.getValue().playerName.equals(player.getName()) && playerObject.getValue().uuid.equals(player.getUniqueId().toString().replace("-", ""))) {
T2Csend.debug(Main.getPlugin(), "opWhitelist Player on list!");
return true;
}
} }
T2Csend.console(Language.exactKickReason.value.replace("[reason]", "Player UUID: " + player.getUniqueId().toString() + " not whitelisted (opWhitelist)"));
return false; return false;
} }
} }

View File

@@ -4,11 +4,13 @@ import net.t2code.opsecurity.config.config.Config;
import net.t2code.opsecurity.config.language.Language; import net.t2code.opsecurity.config.language.Language;
import net.t2code.opsecurity.config.permissionWhitelist.PermissionWhitelist; import net.t2code.opsecurity.config.permissionWhitelist.PermissionWhitelist;
import net.t2code.opsecurity.events.Events; 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.objects.PlayerObject;
import net.t2code.opsecurity.system.BungeeSenderReceiver; 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.commands.T2Ccmd;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.Map; import java.util.Map;
@@ -17,37 +19,54 @@ public class PermissionCheck {
public static Boolean onCheck(Player player, Boolean join) { public static Boolean onCheck(Player player, Boolean join) {
if (!PermissionWhitelist.enable.valueBoolean) return false; if (!PermissionWhitelist.enable.valueBoolean) return false;
for (String perm : PermissionWhitelist.permissions.valueStringList) { for (String perm : PermissionWhitelist.permissions.valueStringList) {
if (!player.hasPermission(perm)) continue; if (!player.hasPermission(perm)) return false;
if (permWhitelist(player)) continue; if (permWhitelist(player)) return false;
Bukkit.getScheduler().runTask(Main.getPlugin(), new Runnable() {
if (join) T2Csend.console(Language.permissionWhitelistNotifyKick.value.replace("[player]", player.getName())); @Override
if (Config.notifyJoinWarning.valueBoolean && join) { public void run() {
if (Config.notifyBungee.valueBoolean) { execute(player, join, perm);
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));
} }
} });
return true; return true;
} }
return false; return false;
} }
private static Boolean permWhitelist(Player player) { private static void execute(Player player, Boolean join, String perm) {
for (Map.Entry<String, PlayerObject> playerObject : PlayerCash.getPermissionHashMap().entrySet()){ if (join) T2Csend.console(Language.permissionWhitelistNotifyKick.value.replace("[player]", player.getName()).replace("[uuid]",String.valueOf(player.getUniqueId())));
if (playerObject.getValue().playerName.equals(player.getName())) return true; if (Config.notifyJoinWarning.valueBoolean && join) {
if (playerObject.getValue().uuid.equals(player.getUniqueId().toString())) return true; 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(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) {
for (Map.Entry<String, PlayerObject> playerObject : PlayerCache.getPermissionHashMap().entrySet()) {
T2Csend.debug(Main.getPlugin(), "--------- " + player.getName());
T2Csend.debug(Main.getPlugin(),"permWhitelist playerObject Name: "+playerObject.getValue().playerName );
T2Csend.debug(Main.getPlugin(),"permWhitelist Player Name: "+player.getName() );
T2Csend.debug(Main.getPlugin(),"permWhitelist playerObject UUID: "+playerObject.getValue().uuid );
T2Csend.debug(Main.getPlugin(),"permWhitelist Player UUID: "+player.getUniqueId().toString().replace("-","") );
if (playerObject.getValue().playerName.equals(player.getName()) && playerObject.getValue().uuid.equals(player.getUniqueId().toString().replace("-",""))){
T2Csend.debug(Main.getPlugin(),"permWhitelist Player on list!");
return true;
}
} }
T2Csend.console(Language.exactKickReason.value.replace("[reason]", "Player UUID: " + player.getUniqueId().toString() + " not whitelisted (permissionWhitelist)"));
return false; return false;
} }
} }

View File

@@ -1,6 +1,5 @@
// This claas was created by JaTiTV // This claas was created by JaTiTV
package net.t2code.opsecurity.check; package net.t2code.opsecurity.check;
import net.t2code.opsecurity.config.config.Config; import net.t2code.opsecurity.config.config.Config;

View File

@@ -4,11 +4,8 @@ package net.t2code.opsecurity.command;
import net.t2code.opsecurity.Util; import net.t2code.opsecurity.Util;
import net.t2code.opsecurity.config.config.Config; 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.opsecurity.system.Permissions;
import net.t2code.t2codelib.SPIGOT.api.commands.T2Ctab; 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.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@@ -42,11 +39,6 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
case "version": case "version":
case "ver": case "ver":
Commands.info(sender); Commands.info(sender);
break;
case "test":
T2Csend.debugmsg(Main.getPlugin(), OPWhitelist.enable.valueBoolean.toString());
T2Csend.debugmsg(Main.getPlugin(), Config.onlyOPcanUseThePlugin.valueBoolean.toString());
break; break;
case "help": case "help":
default: default:

View File

@@ -1,10 +1,10 @@
package net.t2code.opsecurity.command; package net.t2code.opsecurity.command;
import net.t2code.opsecurity.Util; import net.t2code.opsecurity.Util;
import net.t2code.opsecurity.check.OpCheck;
import net.t2code.opsecurity.config.FileSelect; import net.t2code.opsecurity.config.FileSelect;
import net.t2code.opsecurity.config.config.Config; import net.t2code.opsecurity.config.config.Config;
import net.t2code.opsecurity.config.language.Language; import net.t2code.opsecurity.config.language.Language;
import net.t2code.opsecurity.objects.PlayerCash;
import net.t2code.opsecurity.system.Main; import net.t2code.opsecurity.system.Main;
import net.t2code.opsecurity.system.Permissions; import net.t2code.opsecurity.system.Permissions;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
@@ -52,13 +52,11 @@ public class Commands {
} }
if (sender instanceof Player) { if (sender instanceof Player) {
Player player = (Player) sender; Player player = (Player) sender;
if (!PlayerCash.getOpHashMap().containsKey(player.getName().toLowerCase())) { if (Config.onlyOPcanUseThePlugin.valueBoolean) {
sender.sendMessage(Util.getPrefix() + " §4You are not on the Whitelist!"); if (!OpCheck.opWhitelist(player)) {
return; 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); T2Csend.player(player, Language.reloadStart.value);
} }
@@ -76,7 +74,6 @@ public class Commands {
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + "§8-------------------------------"); Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + "§8-------------------------------");
} }
public static void info(CommandSender sender) { public static void info(CommandSender sender) {
if (!sender.hasPermission(Permissions.info)) { if (!sender.hasPermission(Permissions.info)) {
sender.sendMessage(Util.getPrefix() + "§cYou do not have permission for OPSecurity! §7<" + Permissions.info + ">"); sender.sendMessage(Util.getPrefix() + "§cYou do not have permission for OPSecurity! §7<" + Permissions.info + ">");

View File

@@ -5,12 +5,13 @@ import net.t2code.opsecurity.config.config.Config;
import net.t2code.opsecurity.config.language.Language; import net.t2code.opsecurity.config.language.Language;
import net.t2code.opsecurity.config.opWhitelist.OPWhitelist; import net.t2code.opsecurity.config.opWhitelist.OPWhitelist;
import net.t2code.opsecurity.config.permissionWhitelist.PermissionWhitelist; 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.objects.PlayerObject;
import net.t2code.opsecurity.system.Main; import net.t2code.opsecurity.system.Main;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace; import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.system.config.languages.SelectLibMsg; import net.t2code.t2codelib.SPIGOT.system.config.languages.SelectLibMsg;
import org.bukkit.GameMode;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
@@ -23,12 +24,12 @@ public class FileSelect {
File config = new File(Main.getPath(), "config.yml"); File config = new File(Main.getPath(), "config.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
for (Config value : Config.values()) { for (Config value : Config.values()) {
switch (value.cEnum) { switch (value.configParam) {
case STRING: case STRING:
if (!yamlConfiguration.contains(value.path)) { if (!yamlConfiguration.contains(value.path)) {
yamlConfiguration.set(value.path, value.valueString); 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; break;
case SOUND: case SOUND:
if (!yamlConfiguration.contains(value.path)) { if (!yamlConfiguration.contains(value.path)) {
@@ -91,7 +92,6 @@ public class FileSelect {
} }
} }
String selectMSG; String selectMSG;
File config = new File(Main.getPath(), "languages/" + Config.language.valueString + ".yml"); File config = new File(Main.getPath(), "languages/" + Config.language.valueString + ".yml");
T2Csend.debug(Main.getPlugin(), config.getAbsolutePath()); T2Csend.debug(Main.getPlugin(), config.getAbsolutePath());
@@ -115,6 +115,7 @@ public class FileSelect {
} }
public static void selectOpWhitelist() { public static void selectOpWhitelist() {
PlayerCache.getOpHashMap().clear();
File config = new File(Main.getPath(), "opWhitelist.yml"); File config = new File(Main.getPath(), "opWhitelist.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
for (OPWhitelist value : OPWhitelist.values()) { for (OPWhitelist value : OPWhitelist.values()) {
@@ -127,7 +128,7 @@ public class FileSelect {
break; break;
case STRINGLIST: case STRINGLIST:
if (!yamlConfiguration.contains(value.path)) { 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)); value.valueStringList = T2Creplace.replace(Util.getPrefix(), yamlConfiguration.getStringList(value.path));
break; break;
@@ -139,10 +140,22 @@ public class FileSelect {
yamlConfiguration.set(value.pathPlayerUuid.replace("KEY", "player2"), value.valuePlayerUuid); yamlConfiguration.set(value.pathPlayerUuid.replace("KEY", "player2"), value.valuePlayerUuid);
} }
for (String key : yamlConfiguration.getConfigurationSection(value.pathPlayerListPath).getKeys(false)) { for (String key : yamlConfiguration.getConfigurationSection(value.pathPlayerListPath).getKeys(false)) {
String name = yamlConfiguration.getString(value.pathPlayerName.replace("KEY", key));
PlayerObject playerObject = new PlayerObject( PlayerObject playerObject = new PlayerObject(
yamlConfiguration.getString(value.pathPlayerName.replace("KEY", key)), name,
yamlConfiguration.getString(value.pathPlayerUuid.replace("KEY", key).replace("-", ""))); yamlConfiguration.getString(value.pathPlayerUuid.replace("KEY", key)).replace("-", ""));
PlayerCash.getOpHashMap().put(key, playerObject); 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; break;
} }
@@ -155,6 +168,7 @@ public class FileSelect {
} }
public static void selectPermissionWhitelist() { public static void selectPermissionWhitelist() {
PlayerCache.getPermissionHashMap().clear();
File config = new File(Main.getPath(), "permissionWhitelist.yml"); File config = new File(Main.getPath(), "permissionWhitelist.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
for (PermissionWhitelist value : PermissionWhitelist.values()) { for (PermissionWhitelist value : PermissionWhitelist.values()) {
@@ -167,7 +181,7 @@ public class FileSelect {
break; break;
case STRINGLIST: case STRINGLIST:
if (!yamlConfiguration.contains(value.path)) { 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)); value.valueStringList = T2Creplace.replace(Util.getPrefix(), yamlConfiguration.getStringList(value.path));
break; break;
@@ -179,10 +193,11 @@ public class FileSelect {
yamlConfiguration.set(value.pathPlayerUuid.replace("KEY", "player2"), value.valuePlayerUuid); yamlConfiguration.set(value.pathPlayerUuid.replace("KEY", "player2"), value.valuePlayerUuid);
} }
for (String key : yamlConfiguration.getConfigurationSection(value.pathPlayerListPath).getKeys(false)) { for (String key : yamlConfiguration.getConfigurationSection(value.pathPlayerListPath).getKeys(false)) {
String name = yamlConfiguration.getString(value.pathPlayerName.replace("KEY", key));
PlayerObject playerObject = new PlayerObject( PlayerObject playerObject = new PlayerObject(
yamlConfiguration.getString(value.pathPlayerName.replace("KEY", key)), name,
yamlConfiguration.getString(value.pathPlayerUuid.replace("KEY", key).replace("-", ""))); yamlConfiguration.getString(value.pathPlayerUuid.replace("KEY", key)).replace("-", ""));
PlayerCash.getPermissionHashMap().put(key, playerObject); PlayerCache.getPermissionHashMap().put(name, playerObject);
} }
break; break;
} }

View File

@@ -9,13 +9,18 @@ public enum Config {
language("plugin.language", "english", ConfigParam.STRING), language("plugin.language", "english", ConfigParam.STRING),
onlyOPcanUseThePlugin("plugin.onlyOPcanUseThePlugin", true, ConfigParam.BOOLEAN), 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), checkOnJoin("check.onJoin", true, ConfigParam.BOOLEAN),
checkOnInteract("check.onInteract", true, ConfigParam.BOOLEAN), checkOnInteract("check.onInteract", true, ConfigParam.BOOLEAN),
checkOnCommand("check.onCommand", true, ConfigParam.BOOLEAN), checkOnCommand("check.onCommand", true, ConfigParam.BOOLEAN),
checkOnChat("check.onChat", true, ConfigParam.BOOLEAN), checkOnChat("check.onChat", true, ConfigParam.BOOLEAN),
checkTimerEnable("check.timer.enable", true, ConfigParam.BOOLEAN), checkTimerEnable("check.timer.enable", true, ConfigParam.BOOLEAN),
checkTimerRefreshInSec("check.timer.refreshInSec", 60, ConfigParam.INTEGER), 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), notifyJoinWarning("notify.joinWarn.enable", true, ConfigParam.BOOLEAN),
notifyBungee("notify.allBungeePlayer.enable", false, ConfigParam.BOOLEAN), notifyBungee("notify.allBungeePlayer.enable", false, ConfigParam.BOOLEAN),
notifySoundEnable("notify.soundEnable", true, ConfigParam.BOOLEAN), notifySoundEnable("notify.soundEnable", true, ConfigParam.BOOLEAN),
@@ -26,30 +31,30 @@ public enum Config {
public Integer valueInt; public Integer valueInt;
public Boolean valueBoolean; public Boolean valueBoolean;
public Sound sound; public Sound sound;
public ConfigParam cEnum; public ConfigParam configParam;
Config(String path, String value, ConfigParam cEnum) { Config(String path, String value, ConfigParam cEnum) {
this.path = path; this.path = path;
this.valueString = value; this.valueString = value;
this.cEnum = cEnum; this.configParam = cEnum;
} }
Config(String path, Sound value, ConfigParam cEnum) { Config(String path, Sound value, ConfigParam cEnum) {
this.path = path; this.path = path;
this.sound = value; this.sound = value;
this.cEnum = cEnum; this.configParam = cEnum;
} }
Config(String path, Integer value, ConfigParam cEnum) { Config(String path, Integer value, ConfigParam cEnum) {
this.path = path; this.path = path;
this.valueInt = value; this.valueInt = value;
this.cEnum = cEnum; this.configParam = cEnum;
} }
Config(String path, Boolean value, ConfigParam cEnum) { Config(String path, Boolean value, ConfigParam cEnum) {
this.path = path; this.path = path;
this.valueBoolean = value; this.valueBoolean = value;
this.cEnum = cEnum; this.configParam = cEnum;
} }
public static Sound sound() { public static Sound sound() {

View File

@@ -30,36 +30,37 @@ public enum Language {
"[prefix] <dark_red>The specified player is not on the OP_Whitelist!</dark_red>"), "[prefix] <dark_red>The specified player is not on the OP_Whitelist!</dark_red>"),
opWhitelistNotifyOnJoin("opWhitelist.notify.onJoin",null, 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>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>[player]</gold> is joined to the server but is not on the 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, 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>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>[player]</gold> was removed OP because he is not on the playerlist!</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, 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>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>[player]</gold> was kicked because he is not on the 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> was kicked because he is not on the OP_Whitelist!</dark_red>"),
opWhitelistDeop("opWhitelist.deop",null, opWhitelistDeop("opWhitelist.deop",null,
"[prefix] <dark_red>Dir wurde OP entfernt da du dazu keine Permission besitzt.</dark_red>", "&4Dir wurde OP entfernt da du dazu keine Permission besitzt.",
"[prefix] <dark_red>You have been removed from OP because you do not have permission.</dark_red>"), "&4You have been removed from OP because you do not have permission."),
opWhitelistKick("opWhitelist.kick",null, opWhitelistKick("opWhitelist.kick",null,
"<dark_red>Du hast op bist dazu aber nicht berechtigt, deswegen wurdest du gekickt!</dark_red>", "&4Du hast OP, bist dazu aber nicht berechtigt. Deswegen wurdest du gekickt!",
"<dark_red>You have op but are not authorized to do so, that's why you were kicked!</dark_red>"), "&4You have op but are not authorized to do so, that's why you were kicked!"),
permissionWhitelistNotifyOnJoin("permissionWhitelist.notify.onJoin",null, 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><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>[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> 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, 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>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>[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>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, permissionWhitelistKick("permissionWhitelist.kick",null,
"<dark_red>Du wurdest gekickt, da du Permissions besitzt, für die du keine Berechtigung besitzt!</dark_red>", "&4Du wurdest gekickt, da du Permissions besitzt, für die du keine Berechtigung besitzt!",
"<dark_red>You were kicked because you have permissions to which you do not have permission!</dark_red>"), "&4You were kicked because you have permissions to which you do not have permission!"),
exactKickReason("console.exactKickReason", null, exactKickReason("console.exactKickReason", null,
"[prefix] <dark_red>Genauer Grund:</dark_red> <gold>[reason]</gold>", "[prefix] <dark_red>Genauer Grund:</dark_red> <gold>[reason]</gold>",
"[prefix] <dark_red>Exact reason:</dark_red> <gold>[reason]</gold>"); "[prefix] <dark_red>Exact reason:</dark_red> <gold>[reason]</gold>");

View File

@@ -1,6 +1,7 @@
package net.t2code.opsecurity.config.opWhitelist; package net.t2code.opsecurity.config.opWhitelist;
import net.t2code.opsecurity.enums.ConfigParam; import net.t2code.opsecurity.enums.ConfigParam;
import org.bukkit.GameMode;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@@ -8,9 +9,11 @@ import java.util.List;
public enum OPWhitelist { public enum OPWhitelist {
enable("opWhitelist.enable", false, ConfigParam.BOOLEAN), enable("opWhitelist.enable", false, ConfigParam.BOOLEAN),
playerMustBeOnlineToOp("opWhitelist.playerMustBeOnlineToOp", true, 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), noOpPlayerDeopPlayerSendMessage("opWhitelist.noOpPlayerDeop.playerSendMessage", true, ConfigParam.BOOLEAN),
noOpPlayerKickEnable("opWhitelist.noOpPlayerKick.enable", 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), 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!") 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), , ConfigParam.STRINGLIST),
@@ -25,8 +28,15 @@ public enum OPWhitelist {
public List<String> valueStringList; public List<String> valueStringList;
public Boolean valueBoolean; public Boolean valueBoolean;
public GameMode valueGameMode;
public ConfigParam cEnum; 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) { OPWhitelist(String listPath,String pathPlayerName, String pathUuid, String playerName, String uuid, ConfigParam cEnum) {
this.pathPlayerListPath = listPath; this.pathPlayerListPath = listPath;
this.pathPlayerName = pathPlayerName; this.pathPlayerName = pathPlayerName;

View File

@@ -6,5 +6,6 @@ public enum ConfigParam {
BOOLEAN, BOOLEAN,
STRINGLIST, STRINGLIST,
PLAYERLIST, PLAYERLIST,
SOUND SOUND,
GAMEMODE
} }

View File

@@ -28,8 +28,6 @@ public class Events implements Listener {
public void CommandSendEvent(PlayerCommandPreprocessEvent event) { public void CommandSendEvent(PlayerCommandPreprocessEvent event) {
if (!Config.checkOnCommand.valueBoolean) return; if (!Config.checkOnCommand.valueBoolean) return;
Player player = event.getPlayer(); 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)) { if (OpCheck.onCheck(player, false) || PermissionCheck.onCheck(player, false)) {
if (event.isCancelled()) return; if (event.isCancelled()) return;
event.setCancelled(true); event.setCancelled(true);
@@ -40,8 +38,6 @@ public class Events implements Listener {
public void PlayerChatEvent(PlayerChatEvent event) { public void PlayerChatEvent(PlayerChatEvent event) {
if (!Config.checkOnChat.valueBoolean) return; if (!Config.checkOnChat.valueBoolean) return;
Player player = event.getPlayer(); 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)) { if (OpCheck.onCheck(player, false) || PermissionCheck.onCheck(player, false)) {
if (event.isCancelled()) return; if (event.isCancelled()) return;
event.setCancelled(true); event.setCancelled(true);

View File

@@ -3,7 +3,9 @@ package net.t2code.opsecurity.events;
import net.t2code.opsecurity.config.language.Language; import net.t2code.opsecurity.config.language.Language;
import net.t2code.opsecurity.config.opWhitelist.OPWhitelist; import net.t2code.opsecurity.config.opWhitelist.OPWhitelist;
import net.t2code.opsecurity.enums.OpCommandRequest; 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.messages.T2Csend; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.player.T2CnameHistory; import net.t2code.t2codelib.SPIGOT.api.player.T2CnameHistory;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@@ -14,6 +16,7 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.server.ServerCommandEvent; import org.bukkit.event.server.ServerCommandEvent;
import java.io.IOException; import java.io.IOException;
import java.util.Map;
public class OpCommand implements Listener { public class OpCommand implements Listener {
@EventHandler @EventHandler
@@ -54,11 +57,12 @@ public class OpCommand implements Listener {
if (command.charAt(0) == '/') command = command.replaceFirst("/", ""); if (command.charAt(0) == '/') command = command.replaceFirst("/", "");
String arg = command.replace("op ", ""); String arg = command.replace("op ", "");
Player target = Bukkit.getPlayer(arg); Player target = Bukkit.getPlayer(arg);
if (OPWhitelist.playerMustBeOnlineToOp.valueBoolean) { if (OPWhitelist.playerMustBeOnlineToOp.valueBoolean) {
if (target == null) return OpCommandRequest.mustOnline; if (target == null) return OpCommandRequest.mustOnline;
if (!PlayerCash.getOpHashMap().get(target.getName()).playerName.equals(target.getName())) return OpCommandRequest.notWhitelisted; if (!opWhitelist(target.getName(), target.getUniqueId().toString())) return OpCommandRequest.notWhitelisted;
if (!PlayerCash.getOpHashMap().get(target.getName()).uuid.equals(target.getUniqueId().toString().replace("-", ""))) return OpCommandRequest.notWhitelisted;
} }
String targetUUID; String targetUUID;
if (target != null) { if (target != null) {
targetUUID = target.getUniqueId().toString(); targetUUID = target.getUniqueId().toString();
@@ -69,8 +73,22 @@ public class OpCommand implements Listener {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
if (!PlayerCash.getOpHashMap().get(target.getName()).playerName.equals(arg)) return OpCommandRequest.notWhitelisted; if (!opWhitelist(arg, targetUUID)) return OpCommandRequest.notWhitelisted;
if (!PlayerCash.getOpHashMap().get(target.getName()).uuid.equals(targetUUID.replace("-", ""))) return OpCommandRequest.notWhitelisted;
return OpCommandRequest.ok; return OpCommandRequest.ok;
} }
private static Boolean opWhitelist(String playerName, String playerUuid) {
for (Map.Entry<String, PlayerObject> playerObject : PlayerCache.getOpHashMap().entrySet()) {
T2Csend.debug(Main.getPlugin(), "--------- " + playerName);
T2Csend.debug(Main.getPlugin(),"opWhitelist (op command) playerObject Name: "+playerObject.getValue().playerName );
T2Csend.debug(Main.getPlugin(),"opWhitelist (op command) Player Name: "+ playerName );
T2Csend.debug(Main.getPlugin(),"opWhitelist (op command) playerObject UUID: "+playerObject.getValue().uuid );
T2Csend.debug(Main.getPlugin(),"opWhitelist (op command) Player UUID: "+ playerUuid );
if (playerObject.getValue().playerName.equals(playerName) && playerObject.getValue().uuid.equals(playerUuid.replace("-", ""))) {
T2Csend.debug(Main.getPlugin(),"opWhitelist (op command) on list!");
return true;
}
}
return false;
}
} }

View File

@@ -4,7 +4,7 @@ import lombok.Getter;
import java.util.HashMap; import java.util.HashMap;
public class PlayerCash { public class PlayerCache {
@Getter @Getter
private static HashMap<String, PlayerObject> opHashMap = new HashMap<String, PlayerObject>(); private static HashMap<String, PlayerObject> opHashMap = new HashMap<String, PlayerObject>();
@Getter @Getter

View File

@@ -3,6 +3,7 @@ package net.t2code.opsecurity.system;
import net.t2code.opsecurity.Util; import net.t2code.opsecurity.Util;
import net.t2code.opsecurity.command.CmdExecuter; import net.t2code.opsecurity.command.CmdExecuter;
import net.t2code.opsecurity.config.FileSelect; import net.t2code.opsecurity.config.FileSelect;
import net.t2code.opsecurity.config.config.Config;
import net.t2code.opsecurity.config.config.Converter; import net.t2code.opsecurity.config.config.Converter;
import net.t2code.opsecurity.events.Events; import net.t2code.opsecurity.events.Events;
import net.t2code.opsecurity.events.OpCommand; 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.messages.T2Ctemplate;
import net.t2code.t2codelib.SPIGOT.api.register.T2Cregister; import net.t2code.t2codelib.SPIGOT.api.register.T2Cregister;
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI; import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
import org.checkerframework.checker.units.qual.C;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
@@ -39,7 +41,8 @@ public class Load {
Timer.refreshTimer(); Timer.refreshTimer();
Permissions.register(); 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()); Metrics.Bstats(plugin, Util.getBstatsID());
T2Ctemplate.onLoadFooter(Util.getPrefix(), long_); T2Ctemplate.onLoadFooter(Util.getPrefix(), long_);
} }

View File

@@ -32,6 +32,20 @@ public final class Main extends JavaPlugin {
autor = this.getDescription().getAuthors(); autor = this.getDescription().getAuthors();
version = this.getDescription().getVersion(); version = this.getDescription().getVersion();
if (pluginNotFound("T2CodeLib", 96388, Util.getRequiredT2CodeLibVersion())) return; 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; t2codeLib = true;
Load.onLoad(plugin,autor,version); Load.onLoad(plugin,autor,version);
} }

View File

@@ -6,9 +6,10 @@ api-version: 1.13
load: STARTUP load: STARTUP
prefix: T2C-OPSecurity prefix: T2C-OPSecurity
authors: [ JaTiTV ] authors: [ JaTiTV ]
softdepend: softdepend:
- T2CodeLib - T2CodeLib
- OPSecurity
commands: commands:
t2c-opsecurity: t2c-opsecurity:
aliases: [opsec, opsecurity] aliases: [opsec, opsecurity]

69
README.md Normal file
View 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">