Compare commits
23 Commits
Author | SHA1 | Date | |
---|---|---|---|
a89cdb837d | |||
09c81238c7 | |||
35ac13b695 | |||
c89430b219 | |||
052592cff6 | |||
f5dfca5f72 | |||
0dc694d29f | |||
9351c0dfb7 | |||
98fd0409fd | |||
a2bd88ac7c | |||
dba1e57b91 | |||
e14f91c584 | |||
1547c16093 | |||
44507458e5 | |||
ea54d85ecc | |||
43e51fee59 | |||
466314f206 | |||
47a9080dba | |||
|
af608fad02 | ||
632c23b1ff | |||
6fbd56ea63 | |||
31a958ce7f | |||
dab5a4f557 |
@@ -6,7 +6,8 @@
|
||||
|
||||
<groupId>net.t2code</groupId>
|
||||
<artifactId>T2C-OPSecurity</artifactId>
|
||||
<version>3.0.2</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.2</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>
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
package net.t2code.opsecurity.API;
|
||||
|
||||
public enum T2COpSecAPIPlayerStatus {
|
||||
playerOnOpWhitelist,
|
||||
playerNameNotOnTheOpWhitelist,
|
||||
playerUuidNotOnTheOpWhitelist,
|
||||
playerOnPermissionWhitelist,
|
||||
playerNameNotOnThePermissionWhitelist,
|
||||
playerUuidNotOnThePermissionWhitelist
|
||||
}
|
@@ -8,7 +8,7 @@ public class Util {
|
||||
private static String infoText = "";
|
||||
|
||||
@Getter
|
||||
private static String requiredT2CodeLibVersion = "13.2";
|
||||
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 ##",
|
||||
"## ##",
|
||||
"####################################################################################################################"};
|
||||
|
||||
|
||||
}
|
||||
|
@@ -1,66 +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 (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);
|
||||
execute(player, join, debug);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void execute(Player player, Boolean join) {
|
||||
if (Config.notifyJoinWarning.valueBoolean && join) {
|
||||
if (Config.notifyBungee.valueBoolean) {
|
||||
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())));
|
||||
} 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 ((boolean)OPWhitelist.VALUES.noOpPlayerSetGameModeEnable.getValue()) {
|
||||
player.setGameMode(GameMode.valueOf( OPWhitelist.VALUES.noOpPlayerSetGameModeValue.getValue().toString()));
|
||||
}
|
||||
|
||||
if (OPWhitelist.noOpPlayerDeopEnable.valueBoolean) {
|
||||
if ((boolean)OPWhitelist.VALUES.noOpPlayerDeopEnable.getValue()) {
|
||||
player.setOp(false);
|
||||
if (OPWhitelist.noOpPlayerKickEnable.valueBoolean) {
|
||||
if (!OPWhitelist.customCommandsEnable.valueBoolean) {
|
||||
if (Config.kickCustomCommand.valueBoolean) {
|
||||
T2Ccmd.console(Config.kickCommand.valueString.replace("[player]", player.getName()).replace("[reason]",
|
||||
OPWhitelist.noOpPlayerKickEnable.valueBoolean && OPWhitelist.noOpPlayerDeopEnable.valueBoolean && OPWhitelist.noOpPlayerDeopPlayerSendMessage.valueBoolean
|
||||
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(OPWhitelist.noOpPlayerDeopEnable.valueBoolean && OPWhitelist.noOpPlayerDeopPlayerSendMessage.valueBoolean
|
||||
? Language.opWhitelistKick.value + "\n \n" + 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(Language.opWhitelistNotifyDeop.value.replace("[player]", player.getName().replace("[uuid]", String.valueOf(player.getUniqueId()))) + "<br>"
|
||||
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(Language.opWhitelistNotifyDeop.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
T2Csend.console("["+debug+ "]" +Language.opWhitelistNotifyDeop.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
Events.notifyPlayer(Language.opWhitelistNotifyDeop.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
|
||||
if (OPWhitelist.noOpPlayerDeopPlayerSendMessage.valueBoolean) {
|
||||
if ((boolean)OPWhitelist.VALUES.noOpPlayerDeopPlayerSendMessage.getValue()) {
|
||||
Bukkit.getScheduler().runTaskLater(Main.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -70,27 +75,36 @@ public class OpCheck {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (OPWhitelist.noOpPlayerKickEnable.valueBoolean) {
|
||||
if (!OPWhitelist.noOpPlayerDeopEnable.valueBoolean) {
|
||||
if (!OPWhitelist.customCommandsEnable.valueBoolean) {
|
||||
if (Config.kickCustomCommand.valueBoolean) {
|
||||
T2Ccmd.console(Config.kickCommand.valueString.replace("[player]", player.getName()).replace("[reason]", Language.opWhitelistKick.value));
|
||||
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(Language.opWhitelistNotifyKick.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Boolean opWhitelist(Player player) {
|
||||
for (Map.Entry<String, PlayerObject> playerObject : PlayerCash.getOpHashMap().entrySet()) {
|
||||
if (playerObject.getValue().playerName.equals(player.getName()) && playerObject.getValue().uuid.equals(player.getUniqueId().toString())) return true;
|
||||
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(),"");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@@ -1,14 +1,16 @@
|
||||
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;
|
||||
@@ -16,15 +18,16 @@ 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;
|
||||
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);
|
||||
execute(player, join, perm, debug);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
@@ -32,31 +35,43 @@ public class PermissionCheck {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void execute(Player player, Boolean join, String perm) {
|
||||
if (join) T2Csend.console(Language.permissionWhitelistNotifyKick.value.replace("[player]", player.getName()).replace("[uuid]",String.valueOf(player.getUniqueId())));
|
||||
if (Config.notifyJoinWarning.valueBoolean && join) {
|
||||
if (Config.notifyBungee.valueBoolean) {
|
||||
BungeeSenderReceiver.sendToBungee(Language.permissionWhitelistNotifyOnJoin.value.replace("[player]", player.getName()).replace("[uuid]",String.valueOf(player.getUniqueId())));
|
||||
} else Events.notifyPlayer(Language.permissionWhitelistNotifyOnJoin.value.replace("[player]", player.getName()).replace("[uuid]",String.valueOf(player.getUniqueId())));
|
||||
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 (PermissionWhitelist.playerWithPermissionKick.valueBoolean) {
|
||||
if (Config.kickCustomCommand.valueBoolean) {
|
||||
T2Ccmd.console(Config.kickCommand.valueString.replace("[player]", player.getName()).replace("[reason]", Language.permissionWhitelistKick.value));
|
||||
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(Language.permissionWhitelistNotifyKick.value.replace("[player]",
|
||||
player.getName()).replace("[perm]", perm).replace("[uuid]",String.valueOf(player.getUniqueId())));
|
||||
T2Csend.console("[" + debug + "]" + Language.permissionWhitelistNotifyKick.value.replace("[player]",
|
||||
player.getName()).replace("[perm]", perm).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
}
|
||||
if (PermissionWhitelist.customCommandsCommands.valueBoolean) {
|
||||
for (String cmd : PermissionWhitelist.customCommandsCommands.valueStringList) {
|
||||
if ((boolean)PermissionWhitelist.VALUES.customCommandsEnable.getValue()) {
|
||||
for (String cmd : (StringList)PermissionWhitelist.VALUES.customCommandsCommands.getValue()) {
|
||||
T2Ccmd.console(cmd.replace("[player]", player.getName()).replace("[perm]", perm));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Boolean permWhitelist(Player player) {
|
||||
for (Map.Entry<String, PlayerObject> playerObject : PlayerCash.getPermissionHashMap().entrySet()) {
|
||||
if (playerObject.getValue().playerName.equals(player.getName()) && playerObject.getValue().uuid.equals(player.getUniqueId().toString())) return true;
|
||||
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(), "");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@@ -6,23 +6,25 @@ 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());
|
||||
}
|
||||
}
|
||||
|
@@ -4,12 +4,8 @@ package net.t2code.opsecurity.command;
|
||||
|
||||
import net.t2code.opsecurity.Util;
|
||||
import net.t2code.opsecurity.config.config.Config;
|
||||
import net.t2code.opsecurity.objects.PlayerCash;
|
||||
import net.t2code.opsecurity.objects.PlayerObject;
|
||||
import net.t2code.opsecurity.system.Main;
|
||||
import net.t2code.opsecurity.system.Permissions;
|
||||
import net.t2code.t2codelib.SPIGOT.api.commands.T2Ctab;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -18,7 +14,6 @@ import org.bukkit.command.TabCompleter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class CmdExecuter implements CommandExecutor, TabCompleter {
|
||||
|
||||
@@ -27,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;
|
||||
|
@@ -5,10 +5,11 @@ import net.t2code.opsecurity.check.OpCheck;
|
||||
import net.t2code.opsecurity.config.FileSelect;
|
||||
import net.t2code.opsecurity.config.config.Config;
|
||||
import net.t2code.opsecurity.config.language.Language;
|
||||
import net.t2code.opsecurity.enums.OpCommandRequest;
|
||||
import net.t2code.opsecurity.objects.PlayerCash;
|
||||
import net.t2code.opsecurity.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;
|
||||
@@ -17,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;
|
||||
@@ -34,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;
|
||||
@@ -54,8 +55,9 @@ public class Commands {
|
||||
}
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
if (Config.onlyOPcanUseThePlugin.valueBoolean) {
|
||||
if (!OpCheck.opWhitelist(player)) {
|
||||
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;
|
||||
}
|
||||
@@ -66,11 +68,11 @@ 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-------------------------------");
|
||||
@@ -81,6 +83,6 @@ public class Commands {
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
@@ -3,16 +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.GameMode;
|
||||
import org.bukkit.Sound;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
@@ -20,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"));
|
||||
|
||||
@@ -84,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) {
|
||||
@@ -93,119 +45,24 @@ 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() {
|
||||
PlayerCash.getOpHashMap().clear();
|
||||
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)) {
|
||||
String name = yamlConfiguration.getString(value.pathPlayerName.replace("KEY", key));
|
||||
PlayerObject playerObject = new PlayerObject(
|
||||
name,
|
||||
yamlConfiguration.getString(value.pathPlayerUuid.replace("KEY", key).replace("-", "")));
|
||||
PlayerCash.getOpHashMap().put(name, playerObject);
|
||||
}
|
||||
break;
|
||||
case GAMEMODE:
|
||||
if (!yamlConfiguration.contains(value.path)) {
|
||||
yamlConfiguration.set(value.path, value.valueGameMode.toString());
|
||||
}
|
||||
try {
|
||||
value.valueGameMode = GameMode.valueOf(yamlConfiguration.getString(value.path).toUpperCase());
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
value.valueGameMode = GameMode.SURVIVAL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
yamlConfiguration.save(config);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void selectPermissionWhitelist() {
|
||||
PlayerCash.getPermissionHashMap().clear();
|
||||
File config = new File(Main.getPath(), "permissionWhitelist.yml");
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
for (PermissionWhitelist value : PermissionWhitelist.values()) {
|
||||
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.valueStringList);
|
||||
}
|
||||
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)) {
|
||||
String name = yamlConfiguration.getString(value.pathPlayerName.replace("KEY", key));
|
||||
PlayerObject playerObject = new PlayerObject(
|
||||
name,
|
||||
yamlConfiguration.getString(value.pathPlayerUuid.replace("KEY", key).replace("-", "")));
|
||||
PlayerCash.getPermissionHashMap().put(name, 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");
|
||||
}
|
||||
}
|
||||
|
@@ -1,59 +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),
|
||||
kickCustomCommand("kick.customCommand.Enable", false, ConfigParam.BOOLEAN),
|
||||
kickCommand("kick.customCommand.command", "minecraft:kick [player] [reason]", ConfigParam.STRING),
|
||||
notifyJoinWarning("notify.joinWarn.enable", true, ConfigParam.BOOLEAN),
|
||||
notifyBungee("notify.allBungeePlayer.enable", false, ConfigParam.BOOLEAN),
|
||||
notifySoundEnable("notify.soundEnable", true, ConfigParam.BOOLEAN),
|
||||
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()) {
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -58,8 +58,9 @@ public enum Language {
|
||||
"[prefix] <dark_red>Player <gold><hover:show_text:'<gold>Name:</gold> <yellow>[player]</yellow><br><gold>UUID:</gold> <yellow>[uuid]</yellow>'>[player]</hover></gold> has permission <gold>[perm]</gold> and is not authorized to do so! Therefore he was kicked! <gold><hover:show_text:'<gold>Name:</gold> <yellow>[player]</yellow><br><gold>UUID:</gold> <yellow>[uuid]</yellow>'>[player]</hover></gold> is not on the Player list!</dark_red>"),
|
||||
|
||||
permissionWhitelistKick("permissionWhitelist.kick",null,
|
||||
"<dark_red>Du wurdest gekickt, da du Permissions besitzt, für die du keine Berechtigung besitzt!</dark_red>",
|
||||
"<dark_red>You were kicked because you have permissions to which you do not have permission!</dark_red>"),
|
||||
"&4Du wurdest gekickt, da du Permissions besitzt, für die du keine Berechtigung besitzt!",
|
||||
"&4You were kicked because you have permissions to which you do not have permission!"),
|
||||
|
||||
exactKickReason("console.exactKickReason", null,
|
||||
"[prefix] <dark_red>Genauer Grund:</dark_red> <gold>[reason]</gold>",
|
||||
"[prefix] <dark_red>Exact reason:</dark_red> <gold>[reason]</gold>");
|
||||
|
@@ -1,60 +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),
|
||||
noOpPlayerSetGameModeEnable("opWhitelist.noOpPlayerSetGameMode.enable", true, ConfigParam.BOOLEAN),
|
||||
noOpPlayerSetGameModeValue("opWhitelist.noOpPlayerSetGameMode.gameMode", GameMode.SURVIVAL, ConfigParam.GAMEMODE),
|
||||
customCommandsEnable("opWhitelist.customCommands.enable", false, ConfigParam.BOOLEAN),
|
||||
customCommandsCommands("opWhitelist.customCommands.commands", Arrays.asList("kick [player] &4You have op but are not authorized to do so, that's why you were kicked!")
|
||||
, ConfigParam.STRINGLIST),
|
||||
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 GameMode valueGameMode;
|
||||
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 path, GameMode value, ConfigParam cEnum) {
|
||||
this.path = path;
|
||||
this.valueGameMode = value;
|
||||
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 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;
|
||||
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, List<String> value, ConfigParam cEnum) {
|
||||
this.path = path;
|
||||
this.valueStringList = value;
|
||||
this.cEnum = cEnum;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,44 +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();
|
||||
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();
|
||||
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);
|
||||
}
|
||||
@@ -46,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);
|
||||
}
|
||||
}
|
||||
@@ -60,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);
|
||||
}
|
||||
|
@@ -1,11 +1,12 @@
|
||||
package net.t2code.opsecurity.events;
|
||||
|
||||
import net.t2code.opsecurity.check.OpCheck;
|
||||
import net.t2code.opsecurity.config.language.Language;
|
||||
import net.t2code.opsecurity.config.opWhitelist.OPWhitelist;
|
||||
import net.t2code.opsecurity.enums.OpCommandRequest;
|
||||
import net.t2code.opsecurity.objects.PlayerCash;
|
||||
import net.t2code.opsecurity.objects.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;
|
||||
@@ -21,7 +22,7 @@ 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:
|
||||
@@ -38,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:
|
||||
@@ -57,10 +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 (!opWhitelist(target.getName(), target.getUniqueId().toString())) return OpCommandRequest.notWhitelisted;
|
||||
}
|
||||
|
||||
String targetUUID;
|
||||
if (target != null) {
|
||||
targetUUID = target.getUniqueId().toString();
|
||||
@@ -76,8 +79,16 @@ public class OpCommand implements Listener {
|
||||
}
|
||||
|
||||
private static Boolean opWhitelist(String playerName, String playerUuid) {
|
||||
for (Map.Entry<String, PlayerObject> playerObject : PlayerCash.getOpHashMap().entrySet()) {
|
||||
if (playerObject.getValue().playerName.equals(playerName) && playerObject.getValue().uuid.equals(playerUuid)) return true;
|
||||
for (Map.Entry<String, PlayerObject> playerObject : PlayerCache.getOpHashMap().entrySet()) {
|
||||
T2Cdebug.debug(Main.getPlugin(), "--------- " + playerName);
|
||||
T2Cdebug.debug(Main.getPlugin(),"opWhitelist (op command) playerObject Name: "+playerObject.getValue().playerName );
|
||||
T2Cdebug.debug(Main.getPlugin(),"opWhitelist (op command) Player Name: "+ playerName );
|
||||
T2Cdebug.debug(Main.getPlugin(),"opWhitelist (op command) playerObject UUID: "+playerObject.getValue().uuid );
|
||||
T2Cdebug.debug(Main.getPlugin(),"opWhitelist (op command) Player UUID: "+ playerUuid );
|
||||
if (playerObject.getValue().playerName.equals(playerName) && playerObject.getValue().uuid.equals(playerUuid.replace("-", ""))) {
|
||||
T2Cdebug.debug(Main.getPlugin(),"opWhitelist (op command) on list!");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@ import lombok.Getter;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class PlayerCash {
|
||||
public class PlayerCache {
|
||||
@Getter
|
||||
private static HashMap<String, PlayerObject> opHashMap = new HashMap<String, PlayerObject>();
|
||||
@Getter
|
@@ -1,6 +1,7 @@
|
||||
package net.t2code.opsecurity.system;
|
||||
|
||||
import net.t2code.opsecurity.events.Events;
|
||||
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -27,7 +28,7 @@ public class BungeeSenderReceiver implements PluginMessageListener {
|
||||
@Override
|
||||
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
|
||||
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(message));
|
||||
T2Csend.debug(Main.getPlugin(), "stream: " + stream.toString());
|
||||
T2Cdebug.debug(Main.getPlugin(), "stream: " + stream.toString());
|
||||
try {
|
||||
String subChannel = stream.readUTF();
|
||||
String information = stream.readUTF();
|
||||
|
@@ -3,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_);
|
||||
}
|
||||
|
@@ -32,6 +32,20 @@ public final class Main extends JavaPlugin {
|
||||
autor = this.getDescription().getAuthors();
|
||||
version = this.getDescription().getVersion();
|
||||
if (pluginNotFound("T2CodeLib", 96388, Util.getRequiredT2CodeLibVersion())) return;
|
||||
load();
|
||||
|
||||
|
||||
}
|
||||
private static void load(){
|
||||
if (!Bukkit.getPluginManager().getPlugin("T2CodeLib").isEnabled()){
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
load();
|
||||
}
|
||||
},5L);
|
||||
return;
|
||||
}
|
||||
t2codeLib = true;
|
||||
Load.onLoad(plugin,autor,version);
|
||||
}
|
||||
|
@@ -6,9 +6,11 @@ api-version: 1.13
|
||||
load: STARTUP
|
||||
prefix: T2C-OPSecurity
|
||||
authors: [ JaTiTV ]
|
||||
|
||||
|
||||
softdepend:
|
||||
- T2CodeLib
|
||||
- OPSecurity
|
||||
|
||||
commands:
|
||||
t2c-opsecurity:
|
||||
aliases: [opsec, opsecurity]
|
Reference in New Issue
Block a user