39 Commits

Author SHA1 Message Date
a89cdb837d . 2024-07-04 00:46:30 +02:00
09c81238c7 Delete Languages.java 2024-07-03 03:33:28 +02:00
35ac13b695 Config build change to new ConfigBuilder 2024-07-03 03:32:03 +02:00
c89430b219 3.2
In this update, minor bugs have been fixed and the config has been slightly revised.

Config changes:
- check.onJoin -> check.onJoin.enable
- check.onInteract -> check.onInteract.enable
- check.onCommand -> check.onCommand.enable
- check.onChat -> check.onChat.enable
- add check.onCommand.whitelist

A whitelist has been added for commands for which no check is performed.
2024-03-31 13:35:45 +02:00
052592cff6 3.1.3
The notify.allBungeePlayer option did not work as it should, this bug was fixed
2023-06-19 21:09:03 +02:00
f5dfca5f72 3.1.2
- API update to Minecraft version 1.20
- T2CodeLib API update to 15.0 (this version is required from now on)
2023-06-08 06:58:46 +02:00
0dc694d29f Security bugfixes and improved debug messages 2023-04-23 16:35:32 +02:00
9351c0dfb7 better debug information & async bugfix 2023-04-23 12:53:25 +02:00
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
25 changed files with 938 additions and 441 deletions

View File

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

View File

@@ -6,7 +6,8 @@
<groupId>net.t2code</groupId>
<artifactId>T2C-OPSecurity</artifactId>
<version>3.0.0-SNAPSHOT-#1</version>
<version>3.3_DEV-1</version>
<packaging>jar</packaging>
<name>T2C-OPSecurity</name>
@@ -17,14 +18,15 @@
</properties>
<build>
<finalName>${project.artifactId}_${project.version}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<source>9</source>
<target>9</target>
</configuration>
</plugin>
<plugin>
@@ -74,14 +76,16 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19.2-R0.1-SNAPSHOT</version>
<version>1.20.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- t2code -->
<dependency>
<groupId>net.t2code</groupId>
<artifactId>T2CodeLib</artifactId>
<version>13.0</version>
<version>16.7</version>
<classifier>dev-6</classifier>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
@@ -90,11 +94,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>

View File

@@ -0,0 +1,61 @@
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 (!(boolean) OPWhitelist.VALUES.enable.getValue()) return true;
String debug = T2Cdebug.debugCode();
return OpCheck.opWhitelist(player, debug);
}
public static boolean checkPermissionWhiteList(Player player, String debug) {
if (!(boolean) PermissionWhitelist.VALUES.enable.getValue()) return true;
return PermissionCheck.permWhitelist(player, debug);
}
public static T2COpSecAPIPlayerStatus detailCheckOPWhiteList(Player player) {
if (!(boolean) OPWhitelist.VALUES.enable.getValue()) 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 (!(boolean)PermissionWhitelist.VALUES.enable.getValue()) 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 = "";
@Getter
private static String requiredT2CodeLibVersion = "13.1";
private static String requiredT2CodeLibVersion = "16.7";
@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;
@@ -25,4 +28,22 @@ public class Util {
@Getter
private static String discord = "http://dc.t2code.net";
@Getter
private static final String[] configLogo = new String[]{
"####################################################################################################################",
"## ##",
"## /$$$$$$$$ /$$$$$$ /$$$$$$ /$$ /$$ ##",
"## |__ $$__//$$__ $$ /$$__ $$ | $$ | $$ ##",
"## | $$ |__/ \\ $$| $$ \\__/ /$$$$$$ /$$$$$$$ /$$$$$$ /$$$$$$$ /$$$$$$ /$$$$$$ ##",
"## | $$ /$$$$$$/| $$ /$$__ $$ /$$__ $$ /$$__ $$ | $$__ $$ /$$__ $$|_ $$_/ ##",
"## | $$ /$$____/ | $$ | $$ \\ $$| $$ | $$| $$$$$$$$ | $$ \\ $$| $$$$$$$$ | $$ ##",
"## | $$ | $$ | $$ $$| $$ | $$| $$ | $$| $$_____/ | $$ | $$| $$_____/ | $$ /$$ ##",
"## | $$ | $$$$$$$$| $$$$$$/| $$$$$$/| $$$$$$$| $$$$$$$ /$$| $$ | $$| $$$$$$$ | $$$$/ ##",
"## |__/ |________/ \\______/ \\______/ \\_______/ \\_______/|__/|__/ |__/ \\_______/ \\___/ ##",
"## ##",
"## T2CodeLib from JaTiTV / T2Code.net. In case of problems please contact the Discord: https://dc.t2code.net ##",
"## ##",
"####################################################################################################################"};
}

View File

@@ -1,48 +1,71 @@
package net.t2code.opsecurity.check;
import com.sun.org.apache.xerces.internal.xs.StringList;
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.GameMode;
import org.bukkit.entity.Player;
import java.util.List;
import java.util.Map;
public class OpCheck {
public static Boolean onCheck(Player player, Boolean join) {
if (!OPWhitelist.enable.valueBoolean) return false;
public static Boolean onCheck(Player player, Boolean join, String debug) {
if (!(boolean) OPWhitelist.VALUES.enable.getValue()) 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 ((boolean)Config.VALUES.notifyJoinWarning.getValue() && join) {
if ((boolean)Config.VALUES.notifyBungee.getValue()) {
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.noOpPlayerDeopEnable.valueBoolean) {
player.setOp(false);
if (OPWhitelist.noOpPlayerKickEnable.valueBoolean) {
if (!OPWhitelist.customCommandsEnable.valueBoolean) T2Ccmd.console(Config.kickCommand.path.replace("[player]", player.getName()).replace("[reason]",
OPWhitelist.noOpPlayerKickEnable.valueBoolean && OPWhitelist.noOpPlayerDeopEnable.valueBoolean && OPWhitelist.noOpPlayerDeopPlayerSendMessage.valueBoolean
? Language.opWhitelistKick.value + "<br><br>" + Language.opWhitelistDeop.value : Language.opWhitelistKick.value));
T2Csend.console(Language.opWhitelistNotifyDeop.value.replace("[player]", player.getName()) + "<br>"
+ Language.opWhitelistNotifyKick.value.replace("[player]", player.getName()));
Events.notifyPlayer(Language.opWhitelistNotifyDeop.value.replace("[player]", player.getName()) + "<br>"
+ Language.opWhitelistNotifyKick.value.replace("[player]", player.getName()));
} else {
T2Csend.console(Language.opWhitelistNotifyDeop.value.replace("[player]", player.getName()));
Events.notifyPlayer(Language.opWhitelistNotifyDeop.value.replace("[player]", player.getName()));
if ((boolean)OPWhitelist.VALUES.noOpPlayerSetGameModeEnable.getValue()) {
player.setGameMode(GameMode.valueOf( OPWhitelist.VALUES.noOpPlayerSetGameModeValue.getValue().toString()));
}
if (OPWhitelist.noOpPlayerDeopPlayerSendMessage.valueBoolean) {
if ((boolean)OPWhitelist.VALUES.noOpPlayerDeopEnable.getValue()) {
player.setOp(false);
if ((boolean)OPWhitelist.VALUES.noOpPlayerKickEnable.getValue()) {
if (!(boolean)OPWhitelist.VALUES.customCommandsEnable.getValue()) {
if ((boolean) Config.VALUES.kickCustomCommand.getValue()) {
T2Ccmd.console( Config.VALUES.kickCommand.getValue().toString().replace("[player]", player.getName()).replace("[reason]",
(boolean)OPWhitelist.VALUES.noOpPlayerKickEnable.getValue() && (boolean)OPWhitelist.VALUES.noOpPlayerDeopEnable.getValue() && (boolean)OPWhitelist.VALUES.noOpPlayerDeopPlayerSendMessage.getValue()
? Language.opWhitelistKick.value + "<br> <br>" + Language.opWhitelistDeop.value : Language.opWhitelistKick.value));
} else player.kickPlayer((boolean)OPWhitelist.VALUES.noOpPlayerDeopEnable.getValue() && (boolean)OPWhitelist.VALUES.noOpPlayerDeopPlayerSendMessage.getValue()
? 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()).replace("[uuid]", String.valueOf(player.getUniqueId())));
} else {
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 ((boolean)OPWhitelist.VALUES.noOpPlayerDeopPlayerSendMessage.getValue()) {
Bukkit.getScheduler().runTaskLater(Main.getPlugin(), new Runnable() {
@Override
public void run() {
@@ -52,26 +75,37 @@ 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 ((boolean)OPWhitelist.VALUES.noOpPlayerKickEnable.getValue()) {
if (!(boolean)OPWhitelist.VALUES.noOpPlayerDeopEnable.getValue()) {
if (!(boolean)OPWhitelist.VALUES.customCommandsEnable.getValue()) {
if ((boolean)Config.VALUES.kickCustomCommand.getValue()) {
T2Ccmd.console(Config.VALUES.kickCommand.getValue().toString().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) {
if ((boolean)OPWhitelist.VALUES.customCommandsEnable.getValue()) {
for (String cmd : (StringList)OPWhitelist.VALUES.customCommandsCommands.getValue()) {
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;
}
}

View File

@@ -1,53 +1,78 @@
package net.t2code.opsecurity.check;
import com.sun.org.apache.xerces.internal.xs.StringList;
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) {
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));
public static Boolean onCheck(Player player, Boolean join, String debug) {
if (!(boolean) PermissionWhitelist.VALUES.enable.getValue()) return false;
for (String perm : (StringList) PermissionWhitelist.VALUES.permissions.getValue()) {
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 ((boolean) Config.VALUES.notifyJoinWarning.getValue() && join) {
if ((boolean) Config.VALUES.notifyBungee.getValue()) {
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 ((boolean)PermissionWhitelist.VALUES.playerWithPermissionKick.getValue()) {
if ((boolean) Config.VALUES.kickCustomCommand.getValue()) {
T2Ccmd.console(Config.VALUES.kickCommand.getValue().toString().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 ((boolean)PermissionWhitelist.VALUES.customCommandsEnable.getValue()) {
for (String cmd : (StringList)PermissionWhitelist.VALUES.customCommandsCommands.getValue()) {
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;
}
}

View File

@@ -1,29 +1,30 @@
// 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;
public class Timer {
public static void refreshTimer() {
if (!(OPWhitelist.enable.valueBoolean && PermissionWhitelist.enable.valueBoolean)) return;
if (!Config.checkTimerEnable.valueBoolean) return;
if (!((boolean)OPWhitelist.VALUES.enable.getValue() && (boolean)PermissionWhitelist.VALUES.enable.getValue())) return;
if (!(boolean) Config.VALUES.checkTimerEnable.getValue()) return;
Bukkit.getScheduler().scheduleAsyncRepeatingTask(Main.getPlugin(), new Runnable() {
@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);
}, 0, 20L * (int) Config.VALUES.checkTimerRefreshInSec.getValue());
}
}

View File

@@ -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;
@@ -25,7 +22,7 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
if (args.length == 0) {
Commands.mainCommand(sender);
} else {
if (Config.onlyOPcanUseThePlugin.valueBoolean) {
if ((boolean)Config.VALUES.onlyOPcanUseThePlugin.getValue()) {
if (!sender.isOp()) {
sender.sendMessage(Util.getPrefix() + "§cOnly OPs can use OPSecurity!");
return false;
@@ -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:

View File

@@ -1,12 +1,15 @@
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.config.opWhitelist.OPWhitelist;
import net.t2code.opsecurity.config.permissionWhitelist.PermissionWhitelist;
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;
@@ -15,7 +18,7 @@ import org.bukkit.entity.Player;
public class Commands {
public static void help(CommandSender sender){
public static void help(CommandSender sender) {
if (!sender.hasPermission(Permissions.help)) {
T2Csend.sender(sender, Language.noPermissionForOpSec.value);
return;
@@ -32,7 +35,7 @@ public class Commands {
}
public static void mainCommand(CommandSender sender) {
if (Config.onlyOPcanUseThePlugin.valueBoolean) {
if ((boolean) Config.VALUES.onlyOPcanUseThePlugin.getValue()) {
if (!sender.isOp()) {
sender.sendMessage(Util.getPrefix() + "§cOnly OPs can use OPSecurity!");
return;
@@ -52,13 +55,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!");
return;
}
if (!PlayerCash.getOpHashMap().get(player.getName().toLowerCase()).uuid.equals(player.getUniqueId().toString().replace("-", ""))) {
sender.sendMessage(Util.getPrefix() + " §4You are not on the Whitelist!");
return;
if ((boolean) Config.VALUES.onlyOPcanUseThePlugin.getValue()) {
String debug = T2Cdebug.debugCode();
if (!OpCheck.opWhitelist(player, debug)) {
sender.sendMessage(Util.getPrefix() + " §4You are not on the Whitelist!"); // todo
return;
}
}
T2Csend.player(player, Language.reloadStart.value);
}
@@ -66,22 +68,21 @@ public class Commands {
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + "§8-------------------------------");
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §6Plugin reload...");
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + "§8-------------------------------");
// Load.onLoad(Main.getPlugin(),Main.getAutor(),Main.getVersion());
FileSelect.selectConfig();
// Load.onLoad(Main.getPlugin(),Main.getAutor(),Main.getVersion());
Config.set();
FileSelect.selectLanguage();
FileSelect.selectOpWhitelist();
FileSelect.selectPermissionWhitelist();
OPWhitelist.set();
PermissionWhitelist.set();
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + "§8-------------------------------");
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §2Plugin successfully reloaded.");
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 + ">");
return;
}
T2Ctemplate.sendInfo(sender,Main.getPlugin(),Util.getSpigotID(),Util.getDiscord(),Util.getInfoText());
T2Ctemplate.sendInfo(sender, Main.getPlugin(), Util.getSpigotID(), Util.getDiscord(), Util.getInfoText());
}
}

View File

@@ -3,15 +3,11 @@ package net.t2code.opsecurity.config;
import net.t2code.opsecurity.Util;
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.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.Sound;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
@@ -19,49 +15,6 @@ import java.io.IOException;
import java.util.*;
public class FileSelect {
public static void selectConfig() {
File config = new File(Main.getPath(), "config.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
for (Config value : Config.values()) {
switch (value.cEnum) {
case STRING:
if (!yamlConfiguration.contains(value.path)) {
yamlConfiguration.set(value.path, value.valueString);
}
value.valueString = T2Creplace.replace(Util.getPrefix(), yamlConfiguration.getString(value.path));
break;
case SOUND:
if (!yamlConfiguration.contains(value.path)) {
yamlConfiguration.set(value.path, value.sound.toString());
}
try {
value.sound = Sound.valueOf(yamlConfiguration.getString(value.path));
} catch (Exception ex) {
T2Csend.console("§4\n§4\n§4\n" + SelectLibMsg.soundNotFound.replace("[prefix]", Util.getPrefix())
.replace("[sound]", "§8" + value.path + ": §6" + yamlConfiguration.getString(value.path)) + "§4\n§4\n§4\n");
}
break;
case BOOLEAN:
if (!yamlConfiguration.contains(value.path)) {
yamlConfiguration.set(value.path, value.valueBoolean);
}
value.valueBoolean = yamlConfiguration.getBoolean(value.path);
break;
case INTEGER:
if (!yamlConfiguration.contains(value.path)) {
yamlConfiguration.set(value.path, value.valueInt);
}
value.valueInt = yamlConfiguration.getInt(value.path);
break;
}
}
try {
yamlConfiguration.save(config);
} catch (IOException e) {
e.printStackTrace();
}
}
private static ArrayList<String> defaultLanguages = new ArrayList<>(Arrays.asList("german", "english"));
@@ -83,7 +36,7 @@ public class FileSelect {
}
}
}
T2Csend.debug(Main.getPlugin(), "save: " + language);
T2Cdebug.debug(Main.getPlugin(), "save: " + language);
try {
yamlConfiguration.save(config);
} catch (IOException e) {
@@ -91,106 +44,25 @@ public class FileSelect {
}
}
String selectMSG;
File config = new File(Main.getPath(), "languages/" + Config.language.valueString + ".yml");
T2Csend.debug(Main.getPlugin(), config.getAbsolutePath());
File config = new File(Main.getPath(), "languages/" + Config.VALUES.language.getValue() + ".yml");
T2Cdebug.debug(Main.getPlugin(), config.getAbsolutePath());
if (!config.isFile()) {
T2Csend.console(Util.getPrefix());
T2Csend.console(Util.getPrefix() + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
T2Csend.console(Util.getPrefix() + " §4The selected §c" + Config.language.valueString + " §4language file was not found.");
T2Csend.console(Util.getPrefix() + " §4The selected §c" + Config.VALUES.language.getValue() + " §4language file was not found.");
T2Csend.console(Util.getPrefix() + " §6The default language §eEnglish §6is used!");
T2Csend.console(Util.getPrefix() + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
T2Csend.console(Util.getPrefix());
config = new File(Main.getPath(), "languages/" + "english.yml");
selectMSG = "english";
} else selectMSG = Config.language.valueString;
} else selectMSG = Config.VALUES.language.getValue().toString();
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() {
File config = new File(Main.getPath(), "opWhitelist.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
for (OPWhitelist value : OPWhitelist.values()) {
switch (value.cEnum) {
case BOOLEAN:
if (!yamlConfiguration.contains(value.path)) {
yamlConfiguration.set(value.path, value.valueBoolean);
}
value.valueBoolean = yamlConfiguration.getBoolean(value.path);
break;
case STRINGLIST:
if (!yamlConfiguration.contains(value.path)) {
yamlConfiguration.set(value.path, value.valueBoolean);
}
value.valueStringList = T2Creplace.replace(Util.getPrefix(), yamlConfiguration.getStringList(value.path));
break;
case PLAYERLIST:
if (!yamlConfiguration.contains(value.pathPlayerListPath)) {
yamlConfiguration.set(value.pathPlayerName.replace("KEY", "player1"), value.valuePlayerName);
yamlConfiguration.set(value.pathPlayerUuid.replace("KEY", "player1"), value.valuePlayerUuid);
yamlConfiguration.set(value.pathPlayerName.replace("KEY", "player2"), value.valuePlayerName);
yamlConfiguration.set(value.pathPlayerUuid.replace("KEY", "player2"), value.valuePlayerUuid);
}
for (String key : yamlConfiguration.getConfigurationSection(value.pathPlayerListPath).getKeys(false)) {
PlayerObject playerObject = new PlayerObject(
yamlConfiguration.getString(value.pathPlayerName.replace("KEY", key)),
yamlConfiguration.getString(value.pathPlayerUuid.replace("KEY", key).replace("-", "")));
PlayerCash.getOpHashMap().put(key, playerObject);
}
break;
}
}
try {
yamlConfiguration.save(config);
} catch (IOException e) {
e.printStackTrace();
}
}
public static void selectPermissionWhitelist() {
File config = new File(Main.getPath(), "permissionWhitelist.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
for (PermissionWhitelist value : PermissionWhitelist.values()) {
switch (value.cEnum) {
case BOOLEAN:
if (!yamlConfiguration.contains(value.path)) {
yamlConfiguration.set(value.path, value.valueBoolean);
}
value.valueBoolean = yamlConfiguration.getBoolean(value.path);
break;
case STRINGLIST:
if (!yamlConfiguration.contains(value.path)) {
yamlConfiguration.set(value.path, value.valueBoolean);
}
value.valueStringList = T2Creplace.replace(Util.getPrefix(), yamlConfiguration.getStringList(value.path));
break;
case PLAYERLIST:
if (!yamlConfiguration.contains(value.pathPlayerListPath)) {
yamlConfiguration.set(value.pathPlayerName.replace("KEY", "player1"), value.valuePlayerName);
yamlConfiguration.set(value.pathPlayerUuid.replace("KEY", "player1"), value.valuePlayerUuid);
yamlConfiguration.set(value.pathPlayerName.replace("KEY", "player2"), value.valuePlayerName);
yamlConfiguration.set(value.pathPlayerUuid.replace("KEY", "player2"), value.valuePlayerUuid);
}
for (String key : yamlConfiguration.getConfigurationSection(value.pathPlayerListPath).getKeys(false)) {
PlayerObject playerObject = new PlayerObject(
yamlConfiguration.getString(value.pathPlayerName.replace("KEY", key)),
yamlConfiguration.getString(value.pathPlayerUuid.replace("KEY", key).replace("-", "")));
PlayerCash.getPermissionHashMap().put(key, playerObject);
}
break;
}
}
try {
yamlConfiguration.save(config);
} catch (IOException e) {
e.printStackTrace();
}
T2Ctemplate.onStartMsg(Util.getPrefix(),"§2Language successfully selected to: §6" + selectMSG + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
}
}

View File

@@ -1,58 +1,171 @@
// This class was created by JaTiTV.
package net.t2code.opsecurity.config.config;
import net.t2code.opsecurity.enums.ConfigParam;
import net.t2code.opsecurity.system.Main;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
import net.t2code.t2codelib.SPIGOT.api.yaml.T2CconfigWriter;
import net.t2code.t2codelib.T2CLanguageEnum;
import net.t2code.t2codelib.T2CconfigItem;
import net.t2code.opsecurity.Util;
import org.bukkit.Sound;
public enum Config {
import java.io.File;
import java.util.HashMap;
import java.util.List;
language("plugin.language", "english", ConfigParam.STRING),
onlyOPcanUseThePlugin("plugin.onlyOPcanUseThePlugin", true, ConfigParam.BOOLEAN),
public class Config {
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),
notifyJoinWarning("notify.joinWarn.enable", true, ConfigParam.BOOLEAN),
notifyBungee("notify.allBungeePlayer.enable", false, ConfigParam.BOOLEAN),
notifySoundEnable("notify.soundEnable", true, ConfigParam.BOOLEAN),
notifySoundValue("notify.sound", sound(), ConfigParam.SOUND);
public enum VALUES implements T2CconfigItem {
public String path;
public String valueString;
public Integer valueInt;
public Boolean valueBoolean;
public Sound sound;
public ConfigParam cEnum;
language("plugin.language", "english", true,
new HashMap<>() {{
put(T2CLanguageEnum.english, List.of("Here you can set the language of the plugin."));
put(T2CLanguageEnum.german, List.of());
}}),
onlyOPcanUseThePlugin("plugin.onlyOPcanUseThePlugin", true, true,
new HashMap<>() {{
put(T2CLanguageEnum.english, List.of("Here you can specify that only players with OP can use the commands of the plugin."));
put(T2CLanguageEnum.german, List.of());
}}),
Config(String path, String value, ConfigParam cEnum) {
this.path = path;
this.valueString = value;
this.cEnum = cEnum;
updateCheckOnJoin("plugin.updateCheck.onJoin", true, true,
new HashMap<>() {{
put(T2CLanguageEnum.english, List.of("In this option you can set if players with the permission 't2c.opsecurity.updatemsg' will get an update message on join when an update for the plugin is available."));
put(T2CLanguageEnum.german, List.of());
}}),
updateCheckSeePreReleaseUpdates("plugin.updateCheck.seePreReleaseUpdates", true, true,
new HashMap<>() {{
put(T2CLanguageEnum.english, List.of("In this option you can set whether you want to receive and display beta and snapshot versions in the update check."));
put(T2CLanguageEnum.german, List.of());
}}),
updateCheckTimeInterval("plugin.updateCheck.timeInterval", 60, true,
new HashMap<>() {{
put(T2CLanguageEnum.english, List.of("In this option you can set the time interval in minutes in which updates should be checked."));
put(T2CLanguageEnum.german, List.of());
}}),
checkOnJoin("check.onJoin.enable", true, true,
new HashMap<>() {{
put(T2CLanguageEnum.english, List.of("Activate the checks whether the player is authorised when joining the player."));
put(T2CLanguageEnum.german, List.of());
}}),
checkOnInteract("check.onInteract.enable", true, true,
new HashMap<>() {{
put(T2CLanguageEnum.english, List.of("Activate the checks whether the player is authorised for player interactions."));
put(T2CLanguageEnum.german, List.of());
}}),
checkOnCommand("check.onCommand.enable", true, true,
new HashMap<>() {{
put(T2CLanguageEnum.english, List.of("Activate the checks whether the player is authorised when the player executes a command."));
put(T2CLanguageEnum.german, List.of());
}}),
checkOnCommandWhitelist("check.onCommand.whitelist", List.of("command 1", "command 2"), true,
new HashMap<>() {{
put(T2CLanguageEnum.english, List.of("Here you can specify commands for which the check is not carried out."));
put(T2CLanguageEnum.german, List.of());
}}),
checkOnChat("check.onChat.enable", true, true,
new HashMap<>() {{
put(T2CLanguageEnum.english, List.of("Activate the checks whether the player is authorised when the player writes a chat message."));
put(T2CLanguageEnum.german, List.of());
}}),
checkTimerEnable("check.timer.enable", true, true,
new HashMap<>() {{
put(T2CLanguageEnum.english, List.of("Activate the check of all players in a time interval."));
put(T2CLanguageEnum.german, List.of());
}}),
checkTimerRefreshInSec("check.timer.refreshInSec", 60, true,
new HashMap<>() {{
put(T2CLanguageEnum.english, List.of("Here you set the seconds with which the check is carried out in a time interval."));
put(T2CLanguageEnum.german, List.of());
}}),
kickCustomCommand("kick.customCommand.enable", false, true,
new HashMap<>() {{
put(T2CLanguageEnum.english, List.of("Should a separate kick command be used for the kick? For example, if you use your own ban system."));
put(T2CLanguageEnum.german, List.of());
}}),
kickCommand("kick.customCommand.command", "minecraft:kick [player] [reason]", true,
new HashMap<>() {{
put(T2CLanguageEnum.english, List.of("This is where you set the user-defined kick command."));
put(T2CLanguageEnum.german, List.of());
}}),
notifyJoinWarning("notify.warn.enable", true, true,
new HashMap<>() {{
put(T2CLanguageEnum.english, List.of("Should players with the permission 't2c.opsecurity.notify' be warned if a player is detected who is not authorised to be on the server with OP / a permission."));
put(T2CLanguageEnum.german, List.of());
}}),
notifyBungee("notify.allBungeePlayer.enable", false, true,
new HashMap<>() {{
put(T2CLanguageEnum.english, List.of("Should the warnings be sent on the entire network (true) or only on the individual server (false)."));
put(T2CLanguageEnum.german, List.of());
}}),
notifySoundEnable("notify.soundEnable", true, true,
new HashMap<>() {{
put(T2CLanguageEnum.english, List.of("Should a sound be played during the warnings?"));
put(T2CLanguageEnum.german, List.of());
}}),
notifySoundValue("notify.sound", sound(), true,
new HashMap<>() {{
put(T2CLanguageEnum.english, List.of("Which sound should be played during the warnings?"));
put(T2CLanguageEnum.german, List.of());
}}),
;
private final String path;
private Object value;
private final boolean forceSet;
private final HashMap<T2CLanguageEnum, List<String>> comments;
VALUES(String path, Object value, boolean forceSet, HashMap<T2CLanguageEnum, List<String>> comments) {
this.path = path;
this.value = value;
this.forceSet = forceSet;
this.comments = comments;
}
@Override
public String getPath() {
return path;
}
@Override
public Object getValue() {
return value;
}
@Override
public boolean getForceSet() {
return forceSet;
}
@Override
public HashMap<T2CLanguageEnum, List<String>> getComments() {
return comments;
}
@Override
public String getLanguagePath() {
return language.path;
}
@Override
public void setValue(Object newValue) {
value = newValue;
}
}
Config(String path, Sound value, ConfigParam cEnum) {
this.path = path;
this.sound = value;
this.cEnum = cEnum;
public static void set() {
long long_ = System.currentTimeMillis();
T2CconfigWriter.createConfig(new File(Main.getPath(), "config.yml"), VALUES.values(), Util.getConfigLogo());
T2Ctemplate.onStartMsg(Util.getPrefix(), "§2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
}
Config(String path, Integer value, ConfigParam cEnum) {
this.path = path;
this.valueInt = value;
this.cEnum = cEnum;
}
Config(String path, Boolean value, ConfigParam cEnum) {
this.path = path;
this.valueBoolean = value;
this.cEnum = cEnum;
}
public static Sound sound() {
private static Sound sound() {
if (T2CmcVersion.isMc1_8()) {
return Sound.valueOf("NOTE_PIANO");
} else if (T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) {

View File

@@ -1,9 +1,13 @@
package net.t2code.opsecurity.config.config;
import net.t2code.opsecurity.Util;
import net.t2code.opsecurity.config.opWhitelist.OPWhitelist;
import net.t2code.opsecurity.config.permissionWhitelist.PermissionWhitelist;
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.yaml.T2CconfigWriter;
import net.t2code.t2codelib.T2CconfigItem;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
@@ -12,8 +16,14 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class Converter {
private static YamlConfiguration yamlConfigurationOld;
private static YamlConfiguration opYml;
private static YamlConfiguration permYml;
public static void convert() {
Path pathOld = Paths.get("plugins/OPSecurity/config.yml");
Path pathNew = Paths.get(Main.getPath() + "/config.yml");
@@ -23,52 +33,61 @@ public class Converter {
if (Files.exists(pathOld) && !Files.isDirectory(pathOld)) {
File configOld = new File("plugins/OPSecurity/config.yml");
YamlConfiguration yamlConfigurationOld = YamlConfiguration.loadConfiguration(configOld);
yamlConfigurationOld = YamlConfiguration.loadConfiguration(configOld);
File opConfig = new File(Main.getPath(), "opWhitelist.yml");
YamlConfiguration opYml = YamlConfiguration.loadConfiguration(opConfig);
opYml = YamlConfiguration.loadConfiguration(opConfig);
File permConfig = new File(Main.getPath(), "permissionWhitelist.yml");
YamlConfiguration permYml = YamlConfiguration.loadConfiguration(permConfig);
permYml = YamlConfiguration.loadConfiguration(permConfig);
Config.language.valueString = yamlConfigurationOld.getString("Plugin.language");
Config.onlyOPcanUseThePlugin.valueBoolean = yamlConfigurationOld.getBoolean("Plugin.OnlyOPcanUseThePlugin");
Config.checkOnJoin.valueBoolean = yamlConfigurationOld.getBoolean("Check.OnJoin");
Config.checkOnInteract.valueBoolean = yamlConfigurationOld.getBoolean("Check.OnInteract");
Config.checkOnCommand.valueBoolean = yamlConfigurationOld.getBoolean("Check.OnCommand");
Config.checkOnChat.valueBoolean = yamlConfigurationOld.getBoolean("Check.OnChat");
Config.checkTimerEnable.valueBoolean = yamlConfigurationOld.getBoolean("Check.Timer.Enable");
Config.checkTimerRefreshInSec.valueInt = yamlConfigurationOld.getInt("Check.Timer.RefreshTime_inSec");
Config.kickCommand.valueString = yamlConfigurationOld.getString("Kick.Command");
Config.notifyJoinWarning.valueBoolean = yamlConfigurationOld.getBoolean("Notify.JoinWarn.Enable");
Config.notifySoundEnable.valueBoolean = yamlConfigurationOld.getBoolean("Notify.Sound.Enable");
Config.notifySoundValue.valueString = yamlConfigurationOld.getString("Notify.Sound.Sound");
setConfig("Plugin.language", Config.VALUES.language);
setConfig("Plugin.OnlyOPcanUseThePlugin", Config.VALUES.onlyOPcanUseThePlugin);
setConfig("Check.OnJoin", Config.VALUES.checkOnJoin);
setConfig("Check.OnInteract", Config.VALUES.checkOnInteract);
setConfig("Check.OnCommand", Config.VALUES.checkOnCommand);
setConfig("Check.OnChat", Config.VALUES.checkOnChat);
setConfig("Check.Timer.Enable", Config.VALUES.checkTimerEnable);
setConfig("Check.Timer.RefreshTime_inSec", Config.VALUES.checkTimerRefreshInSec);
setConfig("Kick.Command", Config.VALUES.kickCommand);
setConfig("Notify.JoinWarn.Enable", Config.VALUES.notifyJoinWarning);
setConfig("Notify.Sound.Enable", Config.VALUES.notifySoundEnable);
setConfig("Notify.Sound.Sound", Config.VALUES.notifySoundValue);
OPWhitelist.enable.valueBoolean = yamlConfigurationOld.getBoolean("OP_Whitelist.Enable");
OPWhitelist.playerMustBeOnlineToOp.valueBoolean = yamlConfigurationOld.getBoolean("OP_Whitelist.PlayerMustBeOnlineToOp");
setOPWhitelist("OP_Whitelist.Enable", OPWhitelist.VALUES.enable);
setOPWhitelist("OP_Whitelist.PlayerMustBeOnlineToOp", OPWhitelist.VALUES.playerMustBeOnlineToOp);
setOPWhitelist("OP_Whitelist.noOpPlayerDeop.Enable", OPWhitelist.VALUES.noOpPlayerDeopEnable);
setOPWhitelist("OP_Whitelist.noOpPlayerDeop.PlayerSendMessage", OPWhitelist.VALUES.noOpPlayerDeopPlayerSendMessage);
setOPWhitelist("OP_Whitelist.noOpPlayerKick.Enable", OPWhitelist.VALUES.noOpPlayerKickEnable);
setOPWhitelist("OP_Whitelist.customCommands.Enable", OPWhitelist.VALUES.customCommandsEnable);
setOPWhitelist("OP_Whitelist.customCommands.Commands", OPWhitelist.VALUES.customCommandsCommands);
OPWhitelist.noOpPlayerDeopEnable.valueBoolean = yamlConfigurationOld.getBoolean("OP_Whitelist.noOpPlayerDeop.Enable");
OPWhitelist.noOpPlayerDeopPlayerSendMessage.valueBoolean = yamlConfigurationOld.getBoolean("OP_Whitelist.noOpPlayerDeop.PlayerSendMessage");
OPWhitelist.noOpPlayerKickEnable.valueBoolean = yamlConfigurationOld.getBoolean("OP_Whitelist.noOpPlayerKick.Enable");
OPWhitelist.customCommandsEnable.valueBoolean = yamlConfigurationOld.getBoolean("OP_Whitelist.customCommands.Enable");
OPWhitelist.customCommandsCommands.valueStringList = yamlConfigurationOld.getStringList("OP_Whitelist.customCommands.Commands");
ArrayList<PlayerObject> opWhitelist = new ArrayList<>();
for (String key : yamlConfigurationOld.getConfigurationSection("OP_Whitelist.Whitelist").getKeys(false)) {
PlayerObject player = new PlayerObject(key,
yamlConfigurationOld.getString("OP_Whitelist.Whitelist." + key + ".UUID").replace("-", ""));
opWhitelist.add(player);
}
for (PlayerObject playerObject : opWhitelist) {
opYml.set("opWhitelist.whitelist.KEY.name".replace("KEY", playerObject.playerName), playerObject.playerName);
opYml.set("opWhitelist.whitelist.KEY.uuid".replace("KEY", playerObject.playerName), playerObject.uuid);
if (yamlConfigurationOld.contains("OP_Whitelist.Whitelist")){
ArrayList<PlayerObject> opWhitelist = new ArrayList<>();
for (String key : yamlConfigurationOld.getConfigurationSection("OP_Whitelist.Whitelist").getKeys(false)) {
PlayerObject player = new PlayerObject(key,
yamlConfigurationOld.getString("OP_Whitelist.Whitelist." + key + ".UUID").replace("-", ""));
opWhitelist.add(player);
}
for (PlayerObject playerObject : opWhitelist) {
PLAYERENUM.name.path = "opWhitelist.whitelist.KEY.name".replace("KEY", playerObject.playerName);
PLAYERENUM.name.value = playerObject.playerName;
PLAYERENUM.uuid.path = "opWhitelist.whitelist.KEY.uuid".replace("KEY", playerObject.playerName);
PLAYERENUM.uuid.value=playerObject.uuid;
T2CconfigWriter.createConfig(new File(Main.getPath(), "opWhitelist.yml"), PLAYERENUM.values(), Util.getConfigLogo());
}
}
PermissionWhitelist.enable.valueBoolean = yamlConfigurationOld.getBoolean("Permission_Whitelist.Enable");
PermissionWhitelist.permissions.valueStringList = yamlConfigurationOld.getStringList("Permission_Whitelist.Permissions");
PermissionWhitelist.playerWithPermissionKick.valueBoolean = yamlConfigurationOld.getBoolean("Permission_Whitelist.PlayerWhithPermission_kick");
PermissionWhitelist.customCommandsEnable.valueBoolean = yamlConfigurationOld.getBoolean("Permission_Whitelist.customCommands.Enable");
PermissionWhitelist.customCommandsCommands.valueStringList = yamlConfigurationOld.getStringList("Permission_Whitelist.customCommands.Commands");
setPermissionWhitelist("Permission_Whitelist.Enable", PermissionWhitelist.VALUES.enable);
setPermissionWhitelist("Permission_Whitelist.Permissions", PermissionWhitelist.VALUES.permissions);
setPermissionWhitelist("Permission_Whitelist.PlayerWhithPermission_kick", PermissionWhitelist.VALUES.playerWithPermissionKick);
setPermissionWhitelist("Permission_Whitelist.customCommands.Enable", PermissionWhitelist.VALUES.customCommandsEnable);
setPermissionWhitelist("Permission_Whitelist.customCommands.Commands", PermissionWhitelist.VALUES.customCommandsCommands);
ArrayList<PlayerObject> permWhitelist = new ArrayList<>();
for (String key : yamlConfigurationOld.getConfigurationSection("Permission_Whitelist.Whitelist").getKeys(false)) {
@@ -93,4 +112,102 @@ public class Converter {
}
}
}
public static void convertCheck() {
File config = new File(Main.getPath(), "config.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
if (!yamlConfiguration.contains("check.onJoin.enable")) {
Boolean onJoin = yamlConfiguration.getBoolean("check.onJoin");
T2Csend.debugmsg(Main.getPlugin(), "onJoin = " + onJoin);
yamlConfiguration.set("check.onJoin.enable", onJoin);
}
if (!yamlConfiguration.contains("check.onInteract.enable")) {
Boolean onInteract = yamlConfiguration.getBoolean("check.onInteract");
T2Csend.debugmsg(Main.getPlugin(), "onInteract = " + onInteract);
yamlConfiguration.set("check.onInteract.enable", onInteract);
}
if (!yamlConfiguration.contains("check.onCommand.enable")) {
Boolean onCommand = yamlConfiguration.getBoolean("check.onCommand");
T2Csend.debugmsg(Main.getPlugin(), "onCommand = " + onCommand);
yamlConfiguration.set("check.onCommand.enable", onCommand);
}
if (!yamlConfiguration.contains("check.onChat.enable")) {
Boolean onChat = yamlConfiguration.getBoolean("check.onChat");
T2Csend.debugmsg(Main.getPlugin(), "onChat = " + onChat);
yamlConfiguration.set("check.onChat.enable", onChat);
}
try {
yamlConfiguration.save(config);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private static void setConfig(String path, T2CconfigItem item) {
if (yamlConfigurationOld.contains(path)) {
item.setValue(yamlConfigurationOld.get(path));
}
}
private static void setOPWhitelist(String path, T2CconfigItem item) {
if (yamlConfigurationOld.contains(path)) {
item.setValue(opYml.get(path));
}
}
private static void setPermissionWhitelist(String path, T2CconfigItem item) {
if (yamlConfigurationOld.contains(path)) {
item.setValue(permYml.get(path));
}
}
private enum PLAYERENUM implements T2CconfigItem {
name("", "", true),
uuid("", "", true),
;
protected String path;
protected Object value;
private boolean forceSet;
private final List<String> comments;
PLAYERENUM(String path, Object value,boolean forceSet, String... comments) {
this.path = path;
this.value = value;
this.forceSet = forceSet;
this.comments = new ArrayList<>(Arrays.asList(comments));
}
@Override
public String getPath() {
return path;
}
@Override
public Object getValue() {
return value;
}
@Override
public boolean getForceSet() {
return forceSet;
}
@Override
public List<String> getComments() {
return comments;
}
@Override
public void setValue(Object newValue) {
value = newValue;
}
}
}

View File

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

View File

@@ -1,50 +1,99 @@
// This class was created by JaTiTV.
package net.t2code.opsecurity.config.opWhitelist;
import net.t2code.opsecurity.enums.ConfigParam;
import net.t2code.opsecurity.Util;
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.T2Ctemplate;
import net.t2code.t2codelib.SPIGOT.api.yaml.T2CconfigWriter;
import net.t2code.t2codelib.T2CconfigItem;
import org.bukkit.GameMode;
import org.bukkit.configuration.ConfigurationSection;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
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),
noOpPlayerDeopPlayerSendMessage("opWhitelist.noOpPlayerDeop.playerSendMessage", true, ConfigParam.BOOLEAN),
noOpPlayerKickEnable("opWhitelist.noOpPlayerKick.enable", true, 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!")
, ConfigParam.STRINGLIST),
player("opWhitelist.whitelist","opWhitelist.whitelist.KEY.name", "opWhitelist.whitelist.KEY.uuid", "PlayerName", "00000000000000000000000000000000", ConfigParam.PLAYERLIST);
public class OPWhitelist {
public String path;
public String pathPlayerListPath;
public String pathPlayerName;
public String pathPlayerUuid;
public String valuePlayerName;
public String valuePlayerUuid;
public List<String> valueStringList;
public enum VALUES implements T2CconfigItem {
public Boolean valueBoolean;
public ConfigParam cEnum;
enable("opWhitelist.enable", false, true),
playerMustBeOnlineToOp("opWhitelist.playerMustBeOnlineToOp", true, true),
noOpPlayerDeopEnable("opWhitelist.noOpPlayerDeop.enable", true, true),
noOpPlayerDeopPlayerSendMessage("opWhitelist.noOpPlayerDeop.playerSendMessage", true, true),
noOpPlayerKickEnable("opWhitelist.noOpPlayerKick.enable", true, true),
noOpPlayerSetGameModeEnable("opWhitelist.noOpPlayerSetGameMode.enable", true, true),
noOpPlayerSetGameModeValue("opWhitelist.noOpPlayerSetGameMode.gameMode", GameMode.SURVIVAL, true),
customCommandsEnable("opWhitelist.customCommands.enable", false, true),
customCommandsCommands("opWhitelist.customCommands.commands", Arrays.asList("kick [player] &4You have op but are not authorized to do so, that's why you were kicked!"), true),
OPWhitelist(String listPath,String pathPlayerName, String pathUuid, String playerName, String uuid, ConfigParam cEnum) {
this.pathPlayerListPath = listPath;
this.pathPlayerName = pathPlayerName;
this.pathPlayerUuid = pathUuid;
this.valuePlayerName = playerName;
this.valuePlayerUuid = uuid;
this.cEnum = cEnum;
playerSection("opWhitelist.whitelist", null, true),
player1name("opWhitelist.whitelist.player1.name", "player1", false),
player1uuid("opWhitelist.whitelist.player1.uuid", "00000000000000000000000000000000", false),
player2name("opWhitelist.whitelist.player2.name", "player2", false),
player2uuid("opWhitelist.whitelist.player2.uuid", "00000000000000000000000000000000", false),
;
private final String path;
private Object value;
private final boolean forceSet;
private final List<String> comments;
VALUES(String path, Object value, boolean forceSet, String... comments) {
this.path = path;
this.value = value;
this.forceSet = forceSet;
this.comments = new ArrayList<>(Arrays.asList(comments));
}
@Override
public String getPath() {
return path;
}
@Override
public Object getValue() {
return value;
}
@Override
public boolean getForceSet() {
return forceSet;
}
@Override
public List<String> getComments() {
return comments;
}
@Override
public void setValue(Object newValue) {
value = newValue;
}
}
OPWhitelist(String path, List<String> value, ConfigParam cEnum) {
this.path = path;
this.valueStringList = value;
this.cEnum = cEnum;
public static void set() {
long long_ = System.currentTimeMillis();
T2CconfigWriter.createConfig(new File(Main.getPath(), "opWhitelist.yml"), VALUES.values(), Util.getConfigLogo());
player();
T2Ctemplate.onStartMsg(Util.getPrefix(), "§2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
}
OPWhitelist(String path, Boolean value, ConfigParam cEnum) {
this.path = path;
this.valueBoolean = value;
this.cEnum = cEnum;
private static void player() {
ConfigurationSection section = (ConfigurationSection) VALUES.playerSection.getValue();
for (String key : section.getConfigurationSection("").getKeys(false)) {
String name = section.getString(key + ".name");
PlayerObject playerObject = new PlayerObject(
name,
section.getString(key + ".uuid").replace("-", ""));
PlayerCache.getOpHashMap().put(name, playerObject);
}
}
}

View File

@@ -1,47 +1,94 @@
// This class was created by JaTiTV.
package net.t2code.opsecurity.config.permissionWhitelist;
import net.t2code.opsecurity.enums.ConfigParam;
import net.t2code.opsecurity.Util;
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.T2Ctemplate;
import net.t2code.t2codelib.SPIGOT.api.yaml.T2CconfigWriter;
import net.t2code.t2codelib.T2CconfigItem;
import org.bukkit.configuration.ConfigurationSection;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public enum PermissionWhitelist {
enable("permissionWhitelist.enable", false, ConfigParam.BOOLEAN),
playerWithPermissionKick("permissionWhitelist.playerWithPermissionKick", true, ConfigParam.BOOLEAN),
permissions("permissionWhitelist.permissions", Arrays.asList("*", "t2c.opsecurity.admin"), ConfigParam.STRINGLIST),
customCommandsEnable("permissionWhitelist.customCommands.enable", false, ConfigParam.BOOLEAN),
customCommandsCommands("permissionWhitelist.customCommands.commands", Arrays.asList("lp user [player] permission unset *", "lp user [player] permission unset t2c.opsecurity.admin")
, ConfigParam.STRINGLIST),
player("permissionWhitelist.whitelist", "permissionWhitelist.whitelist.KEY.name", "permissionWhitelist.whitelist.KEY.uuid", "PlayerName", "00000000000000000000000000000000", ConfigParam.PLAYERLIST);
public class PermissionWhitelist {
public String path;
public String pathPlayerListPath;
public String pathPlayerName;
public String pathPlayerUuid;
public String valuePlayerName;
public String valuePlayerUuid;
public List<String> valueStringList;
public Boolean valueBoolean;
public ConfigParam cEnum;
public enum VALUES implements T2CconfigItem {
PermissionWhitelist(String listPath, String pathPlayerName, String pathUuid, String playerName, String uuid, ConfigParam cEnum) {
this.pathPlayerListPath = listPath;
this.pathPlayerName = pathPlayerName;
this.pathPlayerUuid = pathUuid;
this.valuePlayerName = playerName;
this.valuePlayerUuid = uuid;
this.cEnum = cEnum;
enable("permissionWhitelist.enable", false, true),
playerWithPermissionKick("permissionWhitelist.playerWithPermissionKick", true, true),
permissions("permissionWhitelist.permissions", Arrays.asList("*", "t2c.opsecurity.admin"), true),
customCommandsEnable("permissionWhitelist.customCommands.enable", false, true),
customCommandsCommands("permissionWhitelist.customCommands.commands", Arrays.asList("lp user [player] permission unset *", "lp user [player] permission unset t2c.opsecurity.admin"), true),
playerSection("permissionWhitelist.whitelist", null, true),
player1name("permissionWhitelist.whitelist.player1.name", "player1", false),
player1uuid("permissionWhitelist.whitelist.player1.uuid", "00000000000000000000000000000000", false),
player2name("permissionWhitelist.whitelist.player2.name", "player2", false),
player2uuid("permissionWhitelist.whitelist.player2.uuid", "00000000000000000000000000000000", false),
;
private final String path;
private Object value;
private final boolean forceSet;
private final List<String> comments;
VALUES(String path, Object value, boolean forceSet, String... comments) {
this.path = path;
this.value = value;
this.forceSet = forceSet;
this.comments = new ArrayList<>(Arrays.asList(comments));
}
@Override
public String getPath() {
return path;
}
@Override
public Object getValue() {
return value;
}
@Override
public boolean getForceSet() {
return forceSet;
}
@Override
public List<String> getComments() {
return comments;
}
@Override
public void setValue(Object newValue) {
value = newValue;
}
}
PermissionWhitelist(String path, List<String> value, ConfigParam cEnum) {
this.path = path;
this.valueStringList = value;
this.cEnum = cEnum;
public static void set() {
long long_ = System.currentTimeMillis();
T2CconfigWriter.createConfig(new File(Main.getPath(), "permissionWhitelist.yml"), VALUES.values(), Util.getConfigLogo());
player();
T2Ctemplate.onStartMsg(Util.getPrefix(), "§2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
}
PermissionWhitelist(String path, Boolean value, ConfigParam cEnum) {
this.path = path;
this.valueBoolean = value;
this.cEnum = cEnum;
private static void player() {
ConfigurationSection section = (ConfigurationSection) VALUES.playerSection.getValue();
for (String key : section.getConfigurationSection("").getKeys(false)) {
String name = section.getString(key + ".name");
PlayerObject playerObject = new PlayerObject(
name,
section.getString(key + ".uuid").replace("-", ""));
PlayerCache.getOpHashMap().put(name, playerObject);
}
}
}

View File

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

View File

@@ -1,48 +1,69 @@
package net.t2code.opsecurity.events;
import com.sun.org.apache.xerces.internal.xs.StringList;
import net.t2code.opsecurity.Util;
import net.t2code.opsecurity.config.config.Config;
import net.t2code.opsecurity.check.OpCheck;
import net.t2code.opsecurity.check.PermissionCheck;
import net.t2code.opsecurity.config.config.Config;
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;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.*;
import java.util.List;
public class Events implements Listener {
public static void notifyPlayer(String msg) {
if (!Config.notifyJoinWarning.valueBoolean) return;
if (!(boolean) Config.VALUES.notifyJoinWarning.getValue()) return;
for (Player notifyPlayer : Bukkit.getOnlinePlayers()) {
if (!notifyPlayer.hasPermission(Permissions.notify)) continue;
T2Csend.player(notifyPlayer, msg);
if (Config.notifySoundEnable.valueBoolean) notifyPlayer.playSound(notifyPlayer.getLocation(), Config.notifySoundValue.sound, 3, 1);
if ((boolean) Config.VALUES.notifySoundEnable.getValue()) notifyPlayer.playSound(notifyPlayer.getLocation(), Sound.valueOf(Config.VALUES.notifySoundValue.getValue().toString()), 3, 1);
}
}
@EventHandler
public void CommandSendEvent(PlayerCommandPreprocessEvent event) {
if (!Config.checkOnCommand.valueBoolean) return;
if (!(boolean) Config.VALUES.checkOnCommand.getValue()) 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();
for (String s : (StringList) Config.VALUES.checkOnCommandWhitelist.getValue()) {
if (event.getMessage().startsWith("/" + s)) {
return;
}
}
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);
}
}
@EventHandler
public void PlayerChatEvent(PlayerChatEvent event) {
if (!Config.checkOnChat.valueBoolean) return;
if (!(boolean) Config.VALUES.checkOnChat.getValue()) 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);
}
@@ -50,12 +71,17 @@ public class Events implements Listener {
@EventHandler
public void onInteract(PlayerInteractEvent event) {
if (!Config.checkOnInteract.valueBoolean) return;
Player player = event.getPlayer();
if (!(boolean) Config.VALUES.checkOnInteract.getValue()) return;
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);
}
}
@@ -64,13 +90,15 @@ public class Events implements Listener {
@EventHandler
public void onJoinCheck(PlayerJoinEvent event) {
if (!Config.checkOnJoin.valueBoolean) return;
Player player = event.getPlayer();
if (!(boolean) Config.VALUES.checkOnJoin.getValue()) return;
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);
}

View File

@@ -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,11 +17,12 @@ 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
public void onOPServer(ServerCommandEvent event) {
if (!OPWhitelist.enable.valueBoolean) return;
if (!(boolean) OPWhitelist.VALUES.enable.getValue()) return;
if ((event.getCommand().toLowerCase().startsWith("op ") || event.getCommand().toLowerCase().startsWith("minecraft:op "))) {
switch (isNotOPWTL(event.getCommand())) {
case mustOnline:
@@ -35,7 +39,7 @@ public class OpCommand implements Listener {
@EventHandler
public void onOpPlayer(PlayerCommandPreprocessEvent event) {
if (!OPWhitelist.enable.valueBoolean) return;
if (!(boolean) OPWhitelist.VALUES.enable.getValue()) return;
if ((event.getMessage().toLowerCase().startsWith("/op ") || event.getMessage().toLowerCase().startsWith("/minecraft:op "))) {
switch (isNotOPWTL(event.getMessage())) {
case mustOnline:
@@ -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 ((boolean)OPWhitelist.VALUES.playerMustBeOnlineToOp.getValue()) {
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;
}
}

View File

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

View File

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

View File

@@ -3,15 +3,25 @@ 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.config.opWhitelist.OPWhitelist;
import net.t2code.opsecurity.config.permissionWhitelist.PermissionWhitelist;
import net.t2code.opsecurity.events.Events;
import net.t2code.opsecurity.events.OpCommand;
import net.t2code.opsecurity.events.PlugManCommand;
import net.t2code.opsecurity.check.Timer;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
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 net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.logging.Level;
@@ -26,20 +36,25 @@ public class Load {
ex.printStackTrace();
}
FileSelect.selectConfig();
Config.set();
FileSelect.selectLanguage();
FileSelect.selectOpWhitelist();
FileSelect.selectPermissionWhitelist();
OPWhitelist.set();
PermissionWhitelist.set();
plugin.getCommand("t2c-opsecurity").setExecutor(new CmdExecuter());
T2Cregister.listener(new OpCommand(), plugin);
T2Cregister.listener(new PlugManCommand(), plugin);
T2Cregister.listener(new Events(), plugin);
if ((boolean) T2CLibConfig.VALUES.proxy.getValue()) {
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "t2c:opsec");
T2Csend.debug(plugin, "registerIncomingPluginChannel §et2c:opsec");
}
Timer.refreshTimer();
Permissions.register();
T2CupdateAPI.onUpdateCheck(plugin, Util.getPrefix(), Util.getSpigotID(), Util.getDiscord());
T2CupdateAPI.onUpdateCheck(plugin, Util.getPrefix(), Util.getGit(), Util.getSpigotID(), Util.getDiscord(), (boolean) Config.VALUES.updateCheckOnJoin.getValue(),
(boolean) Config.VALUES.updateCheckSeePreReleaseUpdates.getValue(), (int) Config.VALUES.updateCheckTimeInterval.getValue());
Metrics.Bstats(plugin, Util.getBstatsID());
T2Ctemplate.onLoadFooter(Util.getPrefix(), long_);
}

View File

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

View File

@@ -6,9 +6,11 @@ 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
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">