Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
ac44919662 | |||
621458f59a | |||
cefdc37707 | |||
6489b6bb7a | |||
56e704c7f0 | |||
10e8994ab8 | |||
75edfe88d5 | |||
a89cdb837d | |||
09c81238c7 | |||
35ac13b695 | |||
c89430b219 | |||
052592cff6 |
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>net.t2code</groupId>
|
||||
<artifactId>T2C-OPSecurity</artifactId>
|
||||
<version>3.1.2</version>
|
||||
<version>4.0_DEV</version>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
@ -25,8 +25,8 @@
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
<source>11</source>
|
||||
<target>11</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
@ -57,13 +57,9 @@
|
||||
<repositories>
|
||||
<!-- spigot -->
|
||||
<repository>
|
||||
<id>spigotmc-repo</id>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>sonatype</id>
|
||||
<url>https://oss.sonatype.org/content/groups/public/</url>
|
||||
</repository>
|
||||
<!-- t2code -->
|
||||
<repository>
|
||||
<id>T2Code</id>
|
||||
@ -76,22 +72,24 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.19.2-R0.1-SNAPSHOT</version>
|
||||
<version>1.20-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- t2code -->
|
||||
<dependency>
|
||||
<groupId>net.t2code</groupId>
|
||||
<artifactId>T2CodeLib</artifactId>
|
||||
<version>15.0</version>
|
||||
<version>16.7</version>
|
||||
<classifier>dev-24</classifier>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.24</version>
|
||||
<version>1.18.30</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
@ -6,7 +6,7 @@ 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 net.t2code.t2codelib.SPIGOT.api.debug.T2C_Debug;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -15,18 +15,18 @@ import java.util.Map;
|
||||
|
||||
public class T2COpSecAPI {
|
||||
public static boolean checkOPWhiteList(Player player) {
|
||||
if (!OPWhitelist.enable.valueBoolean) return true;
|
||||
String debug = T2Cdebug.debugCode();
|
||||
return OpCheck.opWhitelist(player,debug);
|
||||
if (!(boolean) OPWhitelist.VALUES.enable.getValue()) return true;
|
||||
String debug = T2C_Debug.debugCode();
|
||||
return OpCheck.opWhitelist(player, debug);
|
||||
}
|
||||
|
||||
public static boolean checkPermissionWhiteList(Player player, String debug) {
|
||||
if (!PermissionWhitelist.enable.valueBoolean) return true;
|
||||
if (!(boolean) PermissionWhitelist.VALUES.enable.getValue()) return true;
|
||||
return PermissionCheck.permWhitelist(player, debug);
|
||||
}
|
||||
|
||||
public static T2COpSecAPIPlayerStatus detailCheckOPWhiteList(Player player) {
|
||||
if (!OPWhitelist.enable.valueBoolean) return T2COpSecAPIPlayerStatus.playerOnOpWhitelist;
|
||||
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()) {
|
||||
@ -41,8 +41,9 @@ public class T2COpSecAPI {
|
||||
}
|
||||
return T2COpSecAPIPlayerStatus.playerOnOpWhitelist;
|
||||
}
|
||||
|
||||
public static T2COpSecAPIPlayerStatus detailCheckPermissionWhiteList(Player player) {
|
||||
if (!PermissionWhitelist.enable.valueBoolean) return T2COpSecAPIPlayerStatus.playerOnPermissionWhitelist;
|
||||
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()) {
|
||||
|
@ -1,31 +0,0 @@
|
||||
package net.t2code.opsecurity;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public class Util {
|
||||
|
||||
@Getter
|
||||
private static String infoText = "";
|
||||
|
||||
@Getter
|
||||
private static String requiredT2CodeLibVersion = "15.0";
|
||||
|
||||
@Getter
|
||||
private static String prefix = "§8[§4T2C§8-§2OP§4Security§8]";
|
||||
|
||||
@Getter
|
||||
private static Integer spigotID = 90739;
|
||||
|
||||
@Getter
|
||||
private static String git = "JaTiTV/T2C-OPSecurity";
|
||||
|
||||
@Getter
|
||||
private static Integer bstatsID = 10858;
|
||||
|
||||
@Getter
|
||||
private static String spigot = "https://www.spigotmc.org/resources/" + getSpigotID();
|
||||
|
||||
@Getter
|
||||
private static String discord = "http://dc.t2code.net";
|
||||
|
||||
}
|
@ -1,27 +1,29 @@
|
||||
package net.t2code.opsecurity.check;
|
||||
|
||||
import net.t2code.opsecurity.config.config.Config;
|
||||
import net.t2code.opsecurity.config.language.Language;
|
||||
import net.t2code.opsecurity.config.language.Languages;
|
||||
import net.t2code.opsecurity.config.opWhitelist.OPWhitelist;
|
||||
import net.t2code.opsecurity.events.Events;
|
||||
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 net.t2code.t2codelib.SPIGOT.api.commands.T2C_Cmd;
|
||||
import net.t2code.t2codelib.SPIGOT.api.debug.T2C_Debug;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
|
||||
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, String debug) {
|
||||
if (!OPWhitelist.enable.valueBoolean) return false;
|
||||
if (!(boolean) OPWhitelist.VALUES.enable.getValue()) return false;
|
||||
if (!player.isOp()) 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())));
|
||||
if (join) T2C_Send.console(Languages.VALUES.opWhitelistNotifyOnJoin.getValue().toString().replace("[player]", player.getName()).replace("%player_name%",player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
Bukkit.getScheduler().runTask(Main.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -32,76 +34,76 @@ public class OpCheck {
|
||||
}
|
||||
|
||||
private static void execute(Player player, Boolean join, String debug) {
|
||||
if (Config.notifyJoinWarning.valueBoolean && join) {
|
||||
if (Config.notifyBungee.valueBoolean) {
|
||||
BungeeSenderReceiver.sendToBungee(Language.opWhitelistNotifyOnJoin.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
if ((boolean)Config.VALUES.notifyJoinWarning.getValue() && join) {
|
||||
if ((boolean)Config.VALUES.notifyBungee.getValue()) {
|
||||
BungeeSenderReceiver.sendToBungee(Languages.VALUES.opWhitelistNotifyOnJoin.getValue().toString().replace("[player]", player.getName()).replace("%player_name%",player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
} else
|
||||
Events.notifyPlayer(Language.opWhitelistNotifyOnJoin.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
Events.notifyPlayer(Languages.VALUES.opWhitelistNotifyOnJoin.getValue().toString().replace("[player]", player.getName()).replace("%player_name%",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
|
||||
? 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);
|
||||
if ((boolean)OPWhitelist.VALUES.noOpPlayerKickEnable.getValue()) {
|
||||
if (!(boolean)OPWhitelist.VALUES.customCommandsEnable.getValue()) {
|
||||
if ((boolean) Config.VALUES.kickCustomCommand.getValue()) {
|
||||
T2C_Cmd.console( Config.VALUES.kickCommand.getValue().toString().replace("[player]", player.getName()).replace("%player_name%",player.getName()).replace("[reason]",
|
||||
(boolean)OPWhitelist.VALUES.noOpPlayerKickEnable.getValue() && (boolean)OPWhitelist.VALUES.noOpPlayerDeopEnable.getValue() && (boolean)OPWhitelist.VALUES.noOpPlayerDeopPlayerSendMessage.getValue()
|
||||
? Languages.VALUES.opWhitelistKick.getValue().toString() + "<br> <br>" + Languages.VALUES.opWhitelistDeop.getValue().toString() : Languages.VALUES.opWhitelistKick.getValue().toString()));
|
||||
} else player.kickPlayer((boolean)OPWhitelist.VALUES.noOpPlayerDeopEnable.getValue() && (boolean)OPWhitelist.VALUES.noOpPlayerDeopPlayerSendMessage.getValue()
|
||||
? Languages.VALUES.opWhitelistKick.getValue() + "\n \n" + Languages.VALUES.opWhitelistDeop.getValue() : Languages.VALUES.opWhitelistKick.getValue().toString());
|
||||
}
|
||||
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())));
|
||||
T2C_Send.console("["+debug+ "]" + Languages.VALUES.opWhitelistNotifyDeop.getValue().toString().replace("[player]", player.getName()).replace("%player_name%",player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())) + "<br>"
|
||||
+ Languages.VALUES.opWhitelistNotifyKick.getValue().toString().replace("[player]", player.getName()).replace("%player_name%",player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
Events.notifyPlayer(Languages.VALUES.opWhitelistNotifyDeop.getValue().toString().replace("[player]", player.getName()).replace("%player_name%",player.getName()) + "<br>"
|
||||
+ Languages.VALUES.opWhitelistNotifyKick.getValue().toString().replace("[player]", player.getName()).replace("%player_name%",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())));
|
||||
T2C_Send.console("["+debug+ "]" + Languages.VALUES.opWhitelistNotifyDeop.getValue().toString().replace("[player]", player.getName()).replace("%player_name%",player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
Events.notifyPlayer(Languages.VALUES.opWhitelistNotifyDeop.getValue().toString().replace("[player]", player.getName()).replace("%player_name%",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() {
|
||||
T2Csend.player(player, Language.opWhitelistDeop.value);
|
||||
T2C_Send.player(player, Languages.VALUES.opWhitelistDeop.getValue().toString());
|
||||
}
|
||||
}, 5L);
|
||||
}
|
||||
}
|
||||
}
|
||||
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));
|
||||
} else player.kickPlayer(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()) {
|
||||
T2C_Cmd.console(Config.VALUES.kickCommand.getValue().toString().replace("[player]", player.getName()).replace("%player_name%",player.getName()).replace("[reason]", Languages.VALUES.opWhitelistKick.getValue().toString()));
|
||||
} else player.kickPlayer(Languages.VALUES.opWhitelistKick.getValue().toString());
|
||||
}
|
||||
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())));
|
||||
T2C_Send.console("["+debug+ "]" + Languages.VALUES.opWhitelistNotifyKick.getValue().toString().replace("[player]", player.getName()).replace("%player_name%",player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
Events.notifyPlayer(Languages.VALUES.opWhitelistNotifyKick.getValue().toString().replace("[player]", player.getName()).replace("%player_name%",player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
}
|
||||
}
|
||||
if (OPWhitelist.customCommandsEnable.valueBoolean) {
|
||||
for (String cmd : OPWhitelist.customCommandsCommands.valueStringList) {
|
||||
T2Ccmd.console(cmd.replace("[player]", player.getName()));
|
||||
if ((boolean)OPWhitelist.VALUES.customCommandsEnable.getValue()) {
|
||||
for (String cmd : (List<String>)OPWhitelist.VALUES.customCommandsCommands.getValue()) {
|
||||
T2C_Cmd.console(cmd.replace("[player]", player.getName()).replace("%player_name%",player.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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("-", ""));
|
||||
T2C_Debug.debug(Main.getPlugin(), "[" + debug + "] --------- " + player.getName()+" ---------");
|
||||
T2C_Debug.debug(Main.getPlugin(), "[" + debug + "] opWhitelist playerObject Name: " + playerObject.getValue().playerName);
|
||||
T2C_Debug.debug(Main.getPlugin(), "[" + debug + "] opWhitelist Player Name: " + player.getName());
|
||||
T2C_Debug.debug(Main.getPlugin(), "[" + debug + "] opWhitelist playerObject UUID: " + playerObject.getValue().uuid);
|
||||
T2C_Debug.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(),"");
|
||||
T2C_Debug.debug(Main.getPlugin(), "[" + debug + "] opWhitelist Player on list!");
|
||||
T2C_Debug.debug(Main.getPlugin(),"");
|
||||
return true;
|
||||
} else T2Cdebug.debug(Main.getPlugin(),"");
|
||||
} else T2C_Debug.debug(Main.getPlugin(),"");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1,59 +1,61 @@
|
||||
package net.t2code.opsecurity.check;
|
||||
|
||||
import net.t2code.opsecurity.config.config.Config;
|
||||
import net.t2code.opsecurity.config.language.Language;
|
||||
import net.t2code.opsecurity.config.language.Languages;
|
||||
import net.t2code.opsecurity.config.permissionWhitelist.PermissionWhitelist;
|
||||
import net.t2code.opsecurity.events.Events;
|
||||
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 net.t2code.t2codelib.SPIGOT.api.commands.T2C_Cmd;
|
||||
import net.t2code.t2codelib.SPIGOT.api.debug.T2C_Debug;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class PermissionCheck {
|
||||
public static Boolean onCheck(Player player, Boolean join, String debug) {
|
||||
if (!PermissionWhitelist.enable.valueBoolean) return false;
|
||||
for (String perm : PermissionWhitelist.permissions.valueStringList) {
|
||||
if (!player.hasPermission(perm)) 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;
|
||||
if (!(boolean) PermissionWhitelist.VALUES.enable.getValue()) return false;
|
||||
for (String perm : (List<String>) PermissionWhitelist.VALUES.permissions.getValue()) {
|
||||
if (!player.hasPermission(perm))continue;
|
||||
T2C_Debug.debug(Main.getPlugin(), "[" + debug + "] check Permission: " + perm);
|
||||
if (permWhitelist(player, debug)){
|
||||
Bukkit.getScheduler().runTask(Main.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
execute(player, join, perm, debug);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void execute(Player player, Boolean join, String perm, String debug) {
|
||||
if (join)
|
||||
T2Csend.console("[" + debug + "]" + Language.permissionWhitelistNotifyKick.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
if (Config.notifyJoinWarning.valueBoolean && join) {
|
||||
if (Config.notifyBungee.valueBoolean) {
|
||||
BungeeSenderReceiver.sendToBungee(Language.permissionWhitelistNotifyOnJoin.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
T2C_Send.console("[" + debug + "]" + Languages.VALUES.permissionWhitelistNotifyKick.getValue().toString().replace("[player]", player.getName()).replace("%player_name%", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
if ((boolean) Config.VALUES.notifyJoinWarning.getValue() && join) {
|
||||
if ((boolean) Config.VALUES.notifyBungee.getValue()) {
|
||||
BungeeSenderReceiver.sendToBungee(Languages.VALUES.permissionWhitelistNotifyOnJoin.getValue().toString().replace("[player]", player.getName()).replace("%player_name%", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
} else
|
||||
Events.notifyPlayer(Language.permissionWhitelistNotifyOnJoin.value.replace("[player]", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
Events.notifyPlayer(Languages.VALUES.permissionWhitelistNotifyOnJoin.getValue().toString().replace("[player]", player.getName()).replace("%player_name%", player.getName()).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
}
|
||||
|
||||
if (PermissionWhitelist.playerWithPermissionKick.valueBoolean) {
|
||||
if (Config.kickCustomCommand.valueBoolean) {
|
||||
T2Ccmd.console(Config.kickCommand.valueString.replace("[perm]", perm).replace("[player]", player.getName()).replace("[reason]", Language.permissionWhitelistKick.value));
|
||||
} else player.kickPlayer(Language.permissionWhitelistKick.value);
|
||||
T2Csend.console("[" + debug + "]" + Language.permissionWhitelistNotifyKick.value.replace("[player]",
|
||||
if ((boolean) PermissionWhitelist.VALUES.playerWithPermissionKick.getValue()) {
|
||||
if ((boolean) Config.VALUES.kickCustomCommand.getValue()) {
|
||||
T2C_Cmd.console(Config.VALUES.kickCommand.getValue().toString().replace("[perm]", perm).replace("[player]", player.getName()).replace("%player_name%", player.getName()).replace("[reason]", Languages.VALUES.permissionWhitelistKick.getValue().toString()));
|
||||
} else player.kickPlayer(Languages.VALUES.permissionWhitelistKick.getValue().toString());
|
||||
T2C_Send.console("[" + debug + "]" + Languages.VALUES.permissionWhitelistNotifyKick.getValue().toString().replace("[player]",
|
||||
player.getName()).replace("[perm]", perm).replace("[uuid]", String.valueOf(player.getUniqueId())));
|
||||
}
|
||||
if (PermissionWhitelist.customCommandsEnable.valueBoolean) {
|
||||
for (String cmd : PermissionWhitelist.customCommandsCommands.valueStringList) {
|
||||
T2Ccmd.console(cmd.replace("[player]", player.getName()).replace("[perm]", perm));
|
||||
if ((boolean) PermissionWhitelist.VALUES.customCommandsEnable.getValue()) {
|
||||
for (String cmd : (List<String>) PermissionWhitelist.VALUES.customCommandsCommands.getValue()) {
|
||||
T2C_Cmd.console(cmd.replace("[player]", player.getName()).replace("%player_name%", player.getName()).replace("[perm]", perm));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -61,16 +63,16 @@ public class PermissionCheck {
|
||||
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("-", ""));
|
||||
T2C_Debug.debug(Main.getPlugin(), "[" + debug + "] --------- " + player.getName() + " ---------");
|
||||
T2C_Debug.debug(Main.getPlugin(), "[" + debug + "] permWhitelist playerObject Name: " + playerObject.getValue().playerName);
|
||||
T2C_Debug.debug(Main.getPlugin(), "[" + debug + "] permWhitelist Player Name: " + player.getName());
|
||||
T2C_Debug.debug(Main.getPlugin(), "[" + debug + "] permWhitelist playerObject UUID: " + playerObject.getValue().uuid);
|
||||
T2C_Debug.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(), "");
|
||||
T2C_Debug.debug(Main.getPlugin(), "[" + debug + "] permWhitelist Player on list!");
|
||||
T2C_Debug.debug(Main.getPlugin(), "");
|
||||
return true;
|
||||
} else T2Cdebug.debug(Main.getPlugin(), "");
|
||||
} else T2C_Debug.debug(Main.getPlugin(), "");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -6,25 +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 net.t2code.t2codelib.SPIGOT.api.debug.T2C_Debug;
|
||||
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()) {
|
||||
String debug = T2Cdebug.debugCode();
|
||||
String debug = T2C_Debug.debugCode();
|
||||
OpCheck.onCheck(player, false, debug);
|
||||
PermissionCheck.onCheck(player, false, debug);
|
||||
}
|
||||
}
|
||||
}, 0, 20L * Config.checkTimerRefreshInSec.valueInt);
|
||||
}, 0, 20L * (int) Config.VALUES.checkTimerRefreshInSec.getValue());
|
||||
}
|
||||
}
|
||||
|
@ -2,10 +2,10 @@
|
||||
|
||||
package net.t2code.opsecurity.command;
|
||||
|
||||
import net.t2code.opsecurity.Util;
|
||||
import net.t2code.opsecurity.util.Util;
|
||||
import net.t2code.opsecurity.config.config.Config;
|
||||
import net.t2code.opsecurity.system.Permissions;
|
||||
import net.t2code.t2codelib.SPIGOT.api.commands.T2Ctab;
|
||||
import net.t2code.t2codelib.SPIGOT.api.commands.T2C_Tab;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -22,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;
|
||||
@ -58,7 +58,7 @@ public class CmdExecuter implements CommandExecutor, TabCompleter {
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String s, String[] args) {
|
||||
List<String> list = new ArrayList<>();
|
||||
T2Ctab.tab(list,sender,0,args,arg1);
|
||||
T2C_Tab.tab(list,sender,0,args,arg1);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +1,25 @@
|
||||
package net.t2code.opsecurity.command;
|
||||
|
||||
import net.t2code.opsecurity.Util;
|
||||
import net.t2code.opsecurity.util.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.config.language.Languages;
|
||||
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 net.t2code.t2codelib.SPIGOT.api.debug.T2C_Debug;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Template;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
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);
|
||||
T2C_Send.sender(sender, Languages.VALUES.noPermissionForOpSec.getValue().toString());
|
||||
return;
|
||||
}
|
||||
//todo to language file
|
||||
@ -33,7 +34,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;
|
||||
@ -53,24 +54,24 @@ public class Commands {
|
||||
}
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
if (Config.onlyOPcanUseThePlugin.valueBoolean) {
|
||||
String debug = T2Cdebug.debugCode();
|
||||
if (!OpCheck.opWhitelist(player,debug)) {
|
||||
if ((boolean) Config.VALUES.onlyOPcanUseThePlugin.getValue()) {
|
||||
String debug = T2C_Debug.debugCode();
|
||||
if (!OpCheck.opWhitelist(player, debug)) {
|
||||
sender.sendMessage(Util.getPrefix() + " §4You are not on the Whitelist!"); // todo
|
||||
return;
|
||||
}
|
||||
}
|
||||
T2Csend.player(player, Language.reloadStart.value);
|
||||
T2C_Send.player(player, Languages.VALUES.reloadStart.getValue().toString());
|
||||
}
|
||||
if (sender instanceof Player) T2Csend.player((Player) sender, Language.reloadEnd.value);
|
||||
if (sender instanceof Player) T2C_Send.player((Player) sender, Languages.VALUES.reloadEnd.getValue().toString());
|
||||
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();
|
||||
FileSelect.selectLanguage();
|
||||
FileSelect.selectOpWhitelist();
|
||||
FileSelect.selectPermissionWhitelist();
|
||||
// Load.onLoad(Main.getPlugin(),Main.getAutor(),Main.getVersion());
|
||||
Config.set(true);
|
||||
Languages.set(true);
|
||||
OPWhitelist.set(true);
|
||||
PermissionWhitelist.set(true);
|
||||
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + "§8-------------------------------");
|
||||
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §2Plugin successfully reloaded.");
|
||||
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + "§8-------------------------------");
|
||||
@ -81,6 +82,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());
|
||||
T2C_Template.sendInfo(sender, Main.getPlugin(), Util.getSpigotID(), Util.getDiscord(), Util.getInfoText());
|
||||
}
|
||||
}
|
||||
|
@ -1,212 +0,0 @@
|
||||
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.PlayerCache;
|
||||
import net.t2code.opsecurity.objects.PlayerObject;
|
||||
import net.t2code.opsecurity.system.Main;
|
||||
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.languages.SelectLibMsg;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
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.configParam) {
|
||||
case STRING:
|
||||
if (!yamlConfiguration.contains(value.path)) {
|
||||
yamlConfiguration.set(value.path, value.valueString);
|
||||
}
|
||||
value.valueString = T2Creplace.replace(Util.getPrefix(), Objects.requireNonNull(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"));
|
||||
|
||||
public static void selectLanguage() {
|
||||
long long_ = System.currentTimeMillis();
|
||||
|
||||
for (String language : defaultLanguages) {
|
||||
File config = new File(Main.getPath(), "languages/" + language + ".yml");
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
for (Language value : Language.values()) {
|
||||
if (!yamlConfiguration.contains(value.path)) {
|
||||
switch (language) {
|
||||
case "german":
|
||||
yamlConfiguration.set(value.path, value.german);
|
||||
break;
|
||||
case "english":
|
||||
yamlConfiguration.set(value.path, value.english);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
T2Cdebug.debug(Main.getPlugin(), "save: " + language);
|
||||
try {
|
||||
yamlConfiguration.save(config);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
String selectMSG;
|
||||
File config = new File(Main.getPath(), "languages/" + Config.language.valueString + ".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() + " §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;
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
|
||||
for (Language value : Language.values()) {
|
||||
T2Cdebug.debug(Main.getPlugin(), "Select: File: " + config.getName() + " Path: " + value.path);
|
||||
value.value = T2Creplace.replace(Util.getPrefix(), yamlConfiguration.getString(value.path));
|
||||
}
|
||||
T2Csend.console(Util.getPrefix() + " §2Language successfully selected to: §6" + selectMSG + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||
}
|
||||
|
||||
public static void selectOpWhitelist() {
|
||||
PlayerCache.getOpHashMap().clear();
|
||||
File config = new File(Main.getPath(), "opWhitelist.yml");
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
for (OPWhitelist value : OPWhitelist.values()) {
|
||||
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("-", ""));
|
||||
PlayerCache.getOpHashMap().put(name, playerObject);
|
||||
}
|
||||
break;
|
||||
case GAMEMODE:
|
||||
if (!yamlConfiguration.contains(value.path)) {
|
||||
yamlConfiguration.set(value.path, value.valueGameMode.toString());
|
||||
}
|
||||
try {
|
||||
value.valueGameMode = GameMode.valueOf(yamlConfiguration.getString(value.path).toUpperCase());
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
value.valueGameMode = GameMode.SURVIVAL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
yamlConfiguration.save(config);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void selectPermissionWhitelist() {
|
||||
PlayerCache.getPermissionHashMap().clear();
|
||||
File config = new File(Main.getPath(), "permissionWhitelist.yml");
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
for (PermissionWhitelist value : PermissionWhitelist.values()) {
|
||||
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("-", ""));
|
||||
PlayerCache.getPermissionHashMap().put(name, playerObject);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
yamlConfiguration.save(config);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,66 +1,171 @@
|
||||
// This class was created by JaTiTV.
|
||||
|
||||
package net.t2code.opsecurity.config.config;
|
||||
|
||||
import net.t2code.opsecurity.enums.ConfigParam;
|
||||
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
|
||||
import net.t2code.opsecurity.system.Main;
|
||||
import net.t2code.opsecurity.util.Util;
|
||||
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2C_McVersion;
|
||||
import net.t2code.t2codelib.SPIGOT.api.yaml.T2C_ConfigWriter;
|
||||
import net.t2code.t2codelib.util.T2C_ConfigItem;
|
||||
import net.t2code.t2codelib.util.T2C_LanguageEnum;
|
||||
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 {
|
||||
|
||||
updateCheckOnJoin("plugin.updateCheck.onJoin",true,ConfigParam.BOOLEAN),
|
||||
updateCheckSeePreReleaseUpdates("plugin.updateCheck.seePreReleaseUpdates",true,ConfigParam.BOOLEAN),
|
||||
updateCheckTimeInterval("plugin.updateCheck.timeInterval",60,ConfigParam.INTEGER),
|
||||
public enum VALUES implements T2C_ConfigItem {
|
||||
|
||||
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 String path;
|
||||
public String valueString;
|
||||
public Integer valueInt;
|
||||
public Boolean valueBoolean;
|
||||
public Sound sound;
|
||||
public ConfigParam configParam;
|
||||
language("plugin.language", T2C_LanguageEnum.english, true,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("Hier kannst du die Sprache des Plugins einstellen."));
|
||||
put(T2C_LanguageEnum.english, List.of("Here you can set the language of the plugin."));
|
||||
}}),
|
||||
onlyOPcanUseThePlugin("plugin.onlyOPcanUseThePlugin", true, true,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("Hier kannst du festlegen, dass nur Spieler mit OP die Befehle des Plugins nutzen können."));
|
||||
put(T2C_LanguageEnum.english, List.of("Here you can specify that only players with OP can use the commands of the plugin."));
|
||||
}}),
|
||||
|
||||
Config(String path, String value, ConfigParam cEnum) {
|
||||
this.path = path;
|
||||
this.valueString = value;
|
||||
this.configParam = cEnum;
|
||||
updateCheckOnJoin("plugin.updateCheck.onJoin", true, true,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("Mit dieser Option kannst du festlegen, ob Spieler mit der Berechtigung 't2c.opsecurity.updatemsg' beim Beitritt eine Update-Nachricht erhalten, wenn ein Update für das Plugin verfügbar ist."));
|
||||
put(T2C_LanguageEnum.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."));
|
||||
}}),
|
||||
updateCheckSeePreReleaseUpdates("plugin.updateCheck.seePreReleaseUpdates", true, true,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("In dieser Option kannst du einstellen, ob du Beta- und Snapshot-Versionen in der Update-Prüfung erhalten und anzeigen möchtest."));
|
||||
put(T2C_LanguageEnum.english, List.of("In this option you can set whether you want to receive and display beta and snapshot versions in the update check."));
|
||||
}}),
|
||||
updateCheckTimeInterval("plugin.updateCheck.timeInterval", 60, true,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("Mit dieser Option kannst du das Zeitintervall in Minuten festlegen, in dem Aktualisierungen überprüft werden sollen."));
|
||||
put(T2C_LanguageEnum.english, List.of("In this option you can set the time interval in minutes in which updates should be checked."));
|
||||
}}),
|
||||
|
||||
checkOnJoin("check.onJoin.enable", true, true,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("Aktiviere die Prüfung, ob der Spieler berechtigt ist, wenn er dem Server beitritt."));
|
||||
put(T2C_LanguageEnum.english, List.of("Activate the checks whether the player is authorised when joining the player."));
|
||||
}}),
|
||||
checkOnInteract("check.onInteract.enable", true, true,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("Aktiviere die Prüfung, ob der Spieler für Spielerinteraktionen autorisiert ist."));
|
||||
put(T2C_LanguageEnum.english, List.of("Activate the checks whether the player is authorised for player interactions."));
|
||||
}}),
|
||||
checkOnCommand("check.onCommand.enable", true, true,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("Aktiviere die Prüfung, ob der Spieler berechtigt ist, wenn er einen Befehl ausführt."));
|
||||
put(T2C_LanguageEnum.english, List.of("Activate the checks whether the player is authorised when the player executes a command."));
|
||||
}}),
|
||||
checkOnCommandWhitelist("check.onCommand.whitelist", List.of("command 1", "command 2"), true,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("Hier kannst du Befehle angeben, für die die Prüfung nicht durchgeführt wird."));
|
||||
put(T2C_LanguageEnum.english, List.of("Here you can specify commands for which the check is not carried out."));
|
||||
}}),
|
||||
checkOnChat("check.onChat.enable", true, true,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("Aktiviere die Überprüfung, ob der Spieler autorisiert ist, wenn er eine Chat-Nachricht schreibt."));
|
||||
put(T2C_LanguageEnum.english, List.of("Activate the checks whether the player is authorised when the player writes a chat message."));
|
||||
}}),
|
||||
checkTimerEnable("check.timer.enable", true, true,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("Aktiviere die Überprüfung aller Spieler in einem Zeitintervall."));
|
||||
put(T2C_LanguageEnum.english, List.of("Activate the check of all players in a time interval."));
|
||||
}}),
|
||||
checkTimerRefreshInSec("check.timer.refreshInSec", 60, true,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("Hier stellst du die Sekunden ein, mit denen die Prüfung in einem Zeitintervall durchgeführt wird."));
|
||||
put(T2C_LanguageEnum.english, List.of("Here you set the seconds with which the check is carried out in a time interval."));
|
||||
}}),
|
||||
kickCustomCommand("kick.customCommand.enable", false, true,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("Soll ein separater Kick-Befehl für den Kick verwendet werden? Zum Beispiel, wenn du ein eigenes Verbotssystem verwenden."));
|
||||
put(T2C_LanguageEnum.english, List.of("Should a separate kick command be used for the kick? For example, if you use your own ban system."));
|
||||
}}),
|
||||
kickCommand("kick.customCommand.command", "minecraft:kick [player] [reason]", true,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("Hier kannst du den benutzerdefinierten Kick-Befehl einstellen."));
|
||||
put(T2C_LanguageEnum.english, List.of("This is where you set the user-defined kick command."));
|
||||
}}),
|
||||
notifyJoinWarning("notify.warn.enable", true, true,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("Sollen Spieler mit der Berechtigung 't2c.opsecurity.notify' gewarnt werden, wenn ein Spieler entdeckt wird, der nicht berechtigt ist, mit OP / einer Permission auf dem Server zu sein."));
|
||||
put(T2C_LanguageEnum.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."));
|
||||
}}),
|
||||
notifyBungee("notify.allProxyPlayer.enable", false, true,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("Sollen die Warnungen an das gesamte Netzwerk (true) oder nur an den einzelnen Server (false) gesendet werden.", "Damit diese Funktion funktioniert, muss die T2CodeLib auf deinem Proxy vorhanden sein und in deren Config die API für T2C-OPSecurity aktiviert werden!"));
|
||||
put(T2C_LanguageEnum.english, List.of("Should the warnings be sent on the entire network (true) or only on the individual server (false).", "For this function to work, the T2CodeLib must be present on your proxy and the API for T2C-OPSecurity must be activated in its config!"));
|
||||
}}),
|
||||
notifySoundEnable("notify.soundEnable", true, true,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("Soll ein Sound abgespielt werden, bei einer Benachrichtigung?"));
|
||||
put(T2C_LanguageEnum.english, List.of("Should a sound be played during the warnings?"));
|
||||
}}),
|
||||
notifySoundValue("notify.sound", sound(), true,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("Welcher Sound soll bei Benachrichtigung abgespielt werden?"));
|
||||
put(T2C_LanguageEnum.english, List.of("Which sound should be played during the warnings?"));
|
||||
}}),
|
||||
;
|
||||
|
||||
private final String path;
|
||||
private Object value;
|
||||
private final boolean forceSet;
|
||||
private final HashMap<T2C_LanguageEnum, List<String>> comments;
|
||||
|
||||
VALUES(String path, Object value, boolean forceSet, HashMap<T2C_LanguageEnum, 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<T2C_LanguageEnum, 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.configParam = cEnum;
|
||||
|
||||
public static void set(boolean isReload) {
|
||||
T2C_ConfigWriter.createConfig(Util.getPrefix(), new File(Main.getPath(), "config.yml"), VALUES.values(), isReload, Util.getConfigLogo());
|
||||
}
|
||||
|
||||
Config(String path, Integer value, ConfigParam cEnum) {
|
||||
this.path = path;
|
||||
this.valueInt = value;
|
||||
this.configParam = cEnum;
|
||||
}
|
||||
|
||||
Config(String path, Boolean value, ConfigParam cEnum) {
|
||||
this.path = path;
|
||||
this.valueBoolean = value;
|
||||
this.configParam = cEnum;
|
||||
}
|
||||
|
||||
public static Sound sound() {
|
||||
if (T2CmcVersion.isMc1_8()) {
|
||||
private static Sound sound() {
|
||||
if (T2C_McVersion.isMc1_8()) {
|
||||
return Sound.valueOf("NOTE_PIANO");
|
||||
} else if (T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) {
|
||||
} else if (T2C_McVersion.isMc1_9() || T2C_McVersion.isMc1_10() || T2C_McVersion.isMc1_11() || T2C_McVersion.isMc1_12()) {
|
||||
return Sound.valueOf("BLOCK_NOTE_HARP");
|
||||
} else return Sound.valueOf("BLOCK_NOTE_BLOCK_HARP");
|
||||
}
|
||||
|
@ -4,6 +4,10 @@ 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.opsecurity.util.Util;
|
||||
import net.t2code.t2codelib.SPIGOT.api.yaml.T2C_ConfigWriter;
|
||||
import net.t2code.t2codelib.util.T2C_ConfigItem;
|
||||
import net.t2code.t2codelib.util.T2C_LanguageEnum;
|
||||
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.HashMap;
|
||||
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;
|
||||
|
||||
T2C_ConfigWriter.createConfig(Util.getPrefix(),new File(Main.getPath(), "opWhitelist.yml"), PLAYERENUM.values(),false, 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,74 @@ public class Converter {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void setConfig(String path, T2C_ConfigItem item) {
|
||||
if (yamlConfigurationOld.contains(path)) {
|
||||
item.setValue(yamlConfigurationOld.get(path));
|
||||
}
|
||||
}
|
||||
|
||||
private static void setOPWhitelist(String path, T2C_ConfigItem item) {
|
||||
if (yamlConfigurationOld.contains(path)) {
|
||||
item.setValue(opYml.get(path));
|
||||
}
|
||||
}
|
||||
|
||||
private static void setPermissionWhitelist(String path, T2C_ConfigItem item) {
|
||||
if (yamlConfigurationOld.contains(path)) {
|
||||
item.setValue(permYml.get(path));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private enum PLAYERENUM implements T2C_ConfigItem {
|
||||
|
||||
name("", "", true, new HashMap<>()),
|
||||
uuid("", "", true, new HashMap<>()),
|
||||
|
||||
;
|
||||
|
||||
private String path;
|
||||
private Object value;
|
||||
private final boolean forceSet;
|
||||
private final HashMap<T2C_LanguageEnum, List<String>> comments;
|
||||
|
||||
PLAYERENUM(String path, Object value, boolean forceSet, HashMap<T2C_LanguageEnum, 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<T2C_LanguageEnum, List<String>> getComments() {
|
||||
return comments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLanguagePath() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Object newValue) {
|
||||
value = newValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,81 +0,0 @@
|
||||
package net.t2code.opsecurity.config.language;
|
||||
|
||||
public enum Language {
|
||||
soundNotFound("plugin.soundNotFound",null,
|
||||
"[prefix] <dark_red>Der Sound <gold>[sound]</gold> wurde nicht gefunden! Bitte überprüfe die Einstellungen.</dark_red>",
|
||||
"[prefix] <dark_red>The sound <gold>[sound]</gold> could not be found! Please check your settings.</dark_red>"),
|
||||
|
||||
noPermission("plugin.NoPermission",null,
|
||||
"<dark_red>Keine Berechtigung!</dark_red>",
|
||||
"<dark_red>No Permission!</dark_red>"),
|
||||
|
||||
noPermissionForOpSec("plugin.NoPermission",null,
|
||||
"[prefix] <red>Du hast keine Berechtigung für OPSecurity!</red>",
|
||||
"[prefix] <red>You do not have permission for OPSecurity!</red>"),
|
||||
|
||||
playerMustBeOnlineToOp("plugin.PlayerMustBeOnlineToOp",null,
|
||||
"[prefix] <dark_red>Der Spieler muss online sein, um OP zu erhalten!</dark_red>",
|
||||
"[prefix] <dark_red>Player must be online to get op!</dark_red>"),
|
||||
|
||||
reloadStart("plugin.reload.start",null,
|
||||
"[prefix] <gold>Plugin wird neu geladen...</gold>",
|
||||
"[prefix] <gold>Plugin is reloaded...</gold>"),
|
||||
|
||||
reloadEnd("plugin.reload.end",null,
|
||||
"[prefix] <green>Plugin wurde erfolgreich neu geladen.</green>",
|
||||
"[prefix] <green>Plugin was successfully reloaded.</green>"),
|
||||
|
||||
opWhitelistOpCommand("opWhitelist.opCommand",null,
|
||||
"[prefix] <dark_red>Der angegebene Spieler befindet sich nicht auf der OP_Whitelist!</dark_red>",
|
||||
"[prefix] <dark_red>The specified player is not on the OP_Whitelist!</dark_red>"),
|
||||
|
||||
opWhitelistNotifyOnJoin("opWhitelist.notify.onJoin",null,
|
||||
"[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><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><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,
|
||||
"&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,
|
||||
"&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><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><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,
|
||||
"&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>");
|
||||
|
||||
|
||||
public String path;
|
||||
public String value;
|
||||
public String german;
|
||||
public String english;
|
||||
|
||||
Language(String path,String value, String german,String english) {
|
||||
this.path = path;
|
||||
this.value=value;
|
||||
this.german = german;
|
||||
this.english = english;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,231 @@
|
||||
package net.t2code.opsecurity.config.language;
|
||||
|
||||
import net.t2code.opsecurity.util.Util;
|
||||
import net.t2code.opsecurity.config.config.Config;
|
||||
import net.t2code.opsecurity.system.Main;
|
||||
import net.t2code.t2codelib.SPIGOT.api.yaml.T2C_LanguageWriter;
|
||||
import net.t2code.t2codelib.util.T2C_ConfigItemLanguages;
|
||||
import net.t2code.t2codelib.util.T2C_LanguageEnum;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class Languages {
|
||||
|
||||
public enum VALUES implements T2C_ConfigItemLanguages {
|
||||
otherLang("plugin", null,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, null);
|
||||
put(T2C_LanguageEnum.english, null);
|
||||
}},
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("Wenn du eine Eigene Sprache hinzufügen magst, dann kopiere einfach eine Sprachdatei und benenne sie in deine Sprache, dies kannst du dann in der config.yml einstellen.", ""));
|
||||
put(T2C_LanguageEnum.english, List.of("If you want to add your own language, simply copy a language file and rename it to your language, you can then set this in config.yml.", ""));
|
||||
}}),
|
||||
|
||||
soundNotFound("plugin.soundNotFound", null,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("[prefix] <dark_red>Der Sound <gold>[sound]</gold> wurde nicht gefunden! Bitte überprüfe die Einstellungen.</dark_red>"));
|
||||
put(T2C_LanguageEnum.english, List.of("[prefix] <dark_red>The sound <gold>[sound]</gold> could not be found! Please check your settings.</dark_red>"));
|
||||
}},
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
|
||||
noPermission("plugin.NoPermission", null,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("<dark_red>Keine Berechtigung!</dark_red>"));
|
||||
put(T2C_LanguageEnum.english, List.of("<dark_red>No Permission!</dark_red>"));
|
||||
}},
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
|
||||
noPermissionForOpSec("plugin.NoPermission", null,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("[prefix] <red>Du hast keine Berechtigung für OPSecurity!</red>"));
|
||||
put(T2C_LanguageEnum.english, List.of("[prefix] <red>You do not have permission for OPSecurity!</red>"));
|
||||
}},
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
|
||||
playerMustBeOnlineToOp("plugin.PlayerMustBeOnlineToOp", null,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("[prefix] <dark_red>Der Spieler muss online sein, um OP zu erhalten!</dark_red>"));
|
||||
put(T2C_LanguageEnum.english, List.of("[prefix] <dark_red>Player must be online to get op!</dark_red>"));
|
||||
}},
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
|
||||
reloadStart("plugin.reload.start", null,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("[prefix] <gold>Plugin wird neu geladen...</gold>"));
|
||||
put(T2C_LanguageEnum.english, List.of("[prefix] <gold>Plugin is reloaded...</gold>"));
|
||||
}},
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
|
||||
reloadEnd("plugin.reload.end", null,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("[prefix] <green>Plugin wurde erfolgreich neu geladen.</green>"));
|
||||
put(T2C_LanguageEnum.english, List.of("[prefix] <green>Plugin was successfully reloaded.</green>"));
|
||||
}},
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
|
||||
opWhitelistOpCommand("opWhitelist.opCommand", null,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("[prefix] <dark_red>Der angegebene Spieler befindet sich nicht auf der OP_Whitelist!</dark_red>"));
|
||||
put(T2C_LanguageEnum.english, List.of("[prefix] <dark_red>The specified player is not on the OP_Whitelist!</dark_red>"));
|
||||
}},
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
|
||||
opWhitelistNotifyOnJoin("opWhitelist.notify.onJoin", null,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("[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>"));
|
||||
put(T2C_LanguageEnum.english, List.of("[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>"));
|
||||
}},
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
|
||||
opWhitelistNotifyDeop("opWhitelist.notify.deop", null,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("[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>"));
|
||||
put(T2C_LanguageEnum.english, List.of("[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>"));
|
||||
}},
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
|
||||
opWhitelistNotifyKick("opWhitelist.notify.kick", null,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("[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>"));
|
||||
put(T2C_LanguageEnum.english, List.of("[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>"));
|
||||
}},
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
|
||||
opWhitelistDeop("opWhitelist.deop", null,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("&4Dir wurde OP entfernt da du dazu keine Permission besitzt."));
|
||||
put(T2C_LanguageEnum.english, List.of("&4You have been removed from OP because you do not have permission."));
|
||||
}},
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
|
||||
opWhitelistKick("opWhitelist.kick", null,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("&4Du hast OP, bist dazu aber nicht berechtigt. Deswegen wurdest du gekickt!"));
|
||||
put(T2C_LanguageEnum.english, List.of("&4You have op but are not authorized to do so, that's why you were kicked!"));
|
||||
}},
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
|
||||
permissionWhitelistNotifyOnJoin("permissionWhitelist.notify.onJoin", null,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("[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>"));
|
||||
put(T2C_LanguageEnum.english, List.of("[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>"));
|
||||
}},
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
|
||||
permissionWhitelistNotifyKick("permissionWhitelist.notify.kick", null,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("[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>"));
|
||||
put(T2C_LanguageEnum.english, List.of("[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>"));
|
||||
}},
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
|
||||
permissionWhitelistKick("permissionWhitelist.kick", null,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("&4Du wurdest gekickt, da du Permissions besitzt, für die du keine Berechtigung besitzt!"));
|
||||
put(T2C_LanguageEnum.english, List.of("&4You were kicked because you have permissions to which you do not have permission!"));
|
||||
}},
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
|
||||
exactKickReason("console.exactKickReason", null,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("[prefix] <dark_red>Genauer Grund:</dark_red> <gold>[reason]</gold>"));
|
||||
put(T2C_LanguageEnum.english, List.of("[prefix] <dark_red>Exact reason:</dark_red> <gold>[reason]</gold>"));
|
||||
}},
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
}}),
|
||||
;
|
||||
private final String path;
|
||||
private Object value;
|
||||
private final HashMap<T2C_LanguageEnum, List<String>> lang;
|
||||
private final HashMap<T2C_LanguageEnum, List<String>> comments;
|
||||
|
||||
VALUES(String path, Object value, HashMap<T2C_LanguageEnum, List<String>> lang, HashMap<T2C_LanguageEnum, List<String>> comments) {
|
||||
this.path = path;
|
||||
this.value = value;
|
||||
this.lang = lang;
|
||||
this.comments = comments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
if (value == null) {
|
||||
return lang.get(T2C_LanguageEnum.english);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<T2C_LanguageEnum, List<String>> getLanguage() {
|
||||
return lang;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<T2C_LanguageEnum, List<String>> getComments() {
|
||||
return comments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Object newValue) {
|
||||
value = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
public static void set(boolean isReload) {
|
||||
T2C_LanguageWriter.createConfig(Util.getPrefix(), Main.getPath(), VALUES.values(), Config.VALUES.language.getValue().toString(), isReload, Util.getConfigLogo());
|
||||
}
|
||||
|
||||
}
|
@ -1,60 +1,155 @@
|
||||
// This class was created by JaTiTV.
|
||||
|
||||
package net.t2code.opsecurity.config.opWhitelist;
|
||||
|
||||
import net.t2code.opsecurity.enums.ConfigParam;
|
||||
import net.t2code.opsecurity.config.config.Config;
|
||||
import net.t2code.opsecurity.objects.PlayerCache;
|
||||
import net.t2code.opsecurity.objects.PlayerObject;
|
||||
import net.t2code.opsecurity.system.Main;
|
||||
import net.t2code.opsecurity.util.Util;
|
||||
import net.t2code.t2codelib.SPIGOT.api.yaml.T2C_ConfigWriter;
|
||||
import net.t2code.t2codelib.util.T2C_ConfigItem;
|
||||
import net.t2code.t2codelib.util.T2C_LanguageEnum;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public enum OPWhitelist {
|
||||
enable("opWhitelist.enable", false, ConfigParam.BOOLEAN),
|
||||
playerMustBeOnlineToOp("opWhitelist.playerMustBeOnlineToOp", true, ConfigParam.BOOLEAN),
|
||||
noOpPlayerDeopEnable("opWhitelist.noOpPlayerDeop.enable", true, ConfigParam.BOOLEAN),
|
||||
noOpPlayerDeopPlayerSendMessage("opWhitelist.noOpPlayerDeop.playerSendMessage", true, ConfigParam.BOOLEAN),
|
||||
noOpPlayerKickEnable("opWhitelist.noOpPlayerKick.enable", true, ConfigParam.BOOLEAN),
|
||||
noOpPlayerSetGameModeEnable("opWhitelist.noOpPlayerSetGameMode.enable", true, ConfigParam.BOOLEAN),
|
||||
noOpPlayerSetGameModeValue("opWhitelist.noOpPlayerSetGameMode.gameMode", GameMode.SURVIVAL, ConfigParam.GAMEMODE),
|
||||
customCommandsEnable("opWhitelist.customCommands.enable", false, ConfigParam.BOOLEAN),
|
||||
customCommandsCommands("opWhitelist.customCommands.commands", Arrays.asList("kick [player] &4You have op but are not authorized to do so, that's why you were kicked!")
|
||||
, ConfigParam.STRINGLIST),
|
||||
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 T2C_ConfigItem {
|
||||
|
||||
public Boolean valueBoolean;
|
||||
public GameMode valueGameMode;
|
||||
public ConfigParam cEnum;
|
||||
enable("opWhitelist.enable", false, true,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("Hiermit aktivierst du die OP-Whitelist."));
|
||||
put(T2C_LanguageEnum.english, List.of("This activates the OP whitelist."));
|
||||
}}),
|
||||
playerMustBeOnlineToOp("opWhitelist.playerMustBeOnlineToOp", true, true,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("Wenn diese Option aktiviert ist, muss der Spieler dem OP gegeben werden soll sich auf dem Server befinden.", "Dies gilt auch wenn man einen Spieler per Console OP geben möchte."));
|
||||
put(T2C_LanguageEnum.english, List.of("If this option is activated, the player to whom the OP is to be given must be on the server.", "This also applies if you want to OP a player via console."));
|
||||
}}),
|
||||
noOpPlayerDeopEnable("opWhitelist.noOpPlayerDeop.enable", true, true,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("Sollen den Spielern die OP besitzen, die aber nicht auf der Whitelist stehen, OP entfernt bekommen?"));
|
||||
put(T2C_LanguageEnum.english, List.of("Should players who have OP but are not on the whitelist have OP removed?"));
|
||||
}}),
|
||||
noOpPlayerDeopPlayerSendMessage("opWhitelist.noOpPlayerDeop.playerSendMessage", true, true,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("Sollen Spieler eine Benachrichtigung erhalten, wenn sie OP entfernt bekommen?"));
|
||||
put(T2C_LanguageEnum.english, List.of("Should players receive a notification when they get OP removed?"));
|
||||
}}),
|
||||
noOpPlayerKickEnable("opWhitelist.noOpPlayerKick.enable", true, true,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("Hier legst du fest ob ein Spieler gekickt werden soll, wenn er OP besitzt und nicht auf der Whitelist steht."));
|
||||
put(T2C_LanguageEnum.english, List.of("Here you determine whether a player should be kicked if he has OP and is not on the whitelist."));
|
||||
}}),
|
||||
noOpPlayerSetGameModeEnable("opWhitelist.noOpPlayerSetGameMode.enable", true, true,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("Sollen Spieler, die OP besitzen und nicht auf der Whitelist stehen in einen bestimmten Gamemode gesetzt werden?"));
|
||||
put(T2C_LanguageEnum.english, List.of("Should players who own OP and are not on the whitelist be set to a specific gamemode?"));
|
||||
}}),
|
||||
noOpPlayerSetGameModeValue("opWhitelist.noOpPlayerSetGameMode.gameMode", GameMode.SURVIVAL, true,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("Hier legst du den Gamemode fest, in den Spieler gesetzt werden sollen, die OP besitzen und nicht auf der Whitelist stehen."));
|
||||
put(T2C_LanguageEnum.english, List.of("Here you define the game mode in which players who have OP and are not on the whitelist are to be set."));
|
||||
}}),
|
||||
customCommandsEnable("opWhitelist.customCommands.enable", false, true,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("Soll ein bestimmter befehl ausgeführt werden, wenn ein Spieler OP hat und nicht auf der Whitelist steht."));
|
||||
put(T2C_LanguageEnum.english, List.of("Should a certain command be executed if a player has OP and is not on the whitelist."));
|
||||
}}),
|
||||
customCommandsCommands("opWhitelist.customCommands.commands", List.of("kick [player] &4You have op but are not authorized to do so, that's why you were kicked!"), true,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of("Hier kann man Mehrere Commands einfügen, die ausgeführt werden, wenn ein Spieler OP hat und nicht auf der Whitelist steht."));
|
||||
put(T2C_LanguageEnum.english, List.of("Here you can add several commands that are executed when a player has OP and is not on the whitelist."));
|
||||
}}),
|
||||
|
||||
OPWhitelist(String path, GameMode value, ConfigParam cEnum) {
|
||||
this.path = path;
|
||||
this.valueGameMode = value;
|
||||
this.cEnum = cEnum;
|
||||
playerSection("opWhitelist.whitelist", null, true,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.german, List.of(
|
||||
"Hier legst du wie im Beispiel die Spieler an, die OP besitzen dürfen.",
|
||||
"Wichtig:",
|
||||
" Es muss der Spielername und die UUID angegeben werden!",
|
||||
" Der Spielername muss mit Groß/Kleinschreibung eingefügt werden!",
|
||||
"Die UUID eines Spielers kannst du hier finden: https://mcuuid.net",
|
||||
"Wenn dein Server nicht im OnlineModus ist, werden alle Spieler andere UUIDs erhalten, dann findest du die UUID eines Spielers in deiner Console, wenn der Spieler den Server betritt."
|
||||
));
|
||||
put(T2C_LanguageEnum.english, List.of(
|
||||
"Here, as in the example, you create the players who are allowed to own OP.",
|
||||
"Important:",
|
||||
" The player name and the UUID must be entered!",
|
||||
" The player name must be inserted with upper/lower case!",
|
||||
"You can find the UUID of a player here: https://mcuuid.net",
|
||||
"If your server is not in online mode, all players will receive different UUIDs, then you will find the UUID of a player in your console when the player enters the server."
|
||||
));
|
||||
}}),
|
||||
player1name("opWhitelist.whitelist.player1.name", "player1", false, new HashMap<>()),
|
||||
player1uuid("opWhitelist.whitelist.player1.uuid", "00000000000000000000000000000000", false, new HashMap<>()),
|
||||
player2name("opWhitelist.whitelist.player2.name", "player2", false, new HashMap<>()),
|
||||
player2uuid("opWhitelist.whitelist.player2.uuid", "00000000000000000000000000000000", false, new HashMap<>()),
|
||||
;
|
||||
|
||||
private final String path;
|
||||
private Object value;
|
||||
private final boolean forceSet;
|
||||
private final HashMap<T2C_LanguageEnum, List<String>> comments;
|
||||
|
||||
VALUES(String path, Object value, boolean forceSet, HashMap<T2C_LanguageEnum, 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<T2C_LanguageEnum, List<String>> getComments() {
|
||||
return comments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLanguagePath() {
|
||||
return Config.VALUES.language.getValue().toString();
|
||||
}
|
||||
|
||||
@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(boolean isReload) {
|
||||
File file = new File(Main.getPath(), "opWhitelist.yml");
|
||||
T2C_ConfigWriter.createConfig(Util.getPrefix(), file, VALUES.values(), isReload, Util.getConfigLogo());
|
||||
getPlayer(file);
|
||||
}
|
||||
|
||||
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 getPlayer(File file) {
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(file);
|
||||
for (String key : yamlConfiguration.getConfigurationSection(VALUES.playerSection.getPath()).getKeys(false)) {
|
||||
String name = yamlConfiguration.getString(VALUES.playerSection.getPath() + "." + key + ".name");
|
||||
String uuid = yamlConfiguration.getString(VALUES.playerSection.getPath() + "." + key + ".uuid").replace("-", "");
|
||||
PlayerObject playerObject = new PlayerObject(
|
||||
name,
|
||||
uuid);
|
||||
PlayerCache.getOpHashMap().put(name, playerObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,47 +1,127 @@
|
||||
// This class was created by JaTiTV.
|
||||
|
||||
package net.t2code.opsecurity.config.permissionWhitelist;
|
||||
|
||||
import net.t2code.opsecurity.enums.ConfigParam;
|
||||
import net.t2code.opsecurity.config.config.Config;
|
||||
import net.t2code.opsecurity.objects.PlayerCache;
|
||||
import net.t2code.opsecurity.objects.PlayerObject;
|
||||
import net.t2code.opsecurity.system.Main;
|
||||
import net.t2code.opsecurity.util.Util;
|
||||
import net.t2code.t2codelib.SPIGOT.api.yaml.T2C_ConfigWriter;
|
||||
import net.t2code.t2codelib.util.T2C_ConfigItem;
|
||||
import net.t2code.t2codelib.util.T2C_LanguageEnum;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
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 T2C_ConfigItem {
|
||||
|
||||
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,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
}}),
|
||||
playerWithPermissionKick("permissionWhitelist.playerWithPermissionKick", true, true,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
}}),
|
||||
permissions("permissionWhitelist.permissions", Arrays.asList("*", "t2c.opsecurity.admin"), true,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
}}),
|
||||
customCommandsEnable("permissionWhitelist.customCommands.enable", false, true,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
}}),
|
||||
customCommandsCommands("permissionWhitelist.customCommands.commands", Arrays.asList("lp user [player] permission unset *", "lp user [player] permission unset t2c.opsecurity.admin"), true,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
}}),
|
||||
|
||||
playerSection("permissionWhitelist.whitelist", null, true,
|
||||
new HashMap<>() {{
|
||||
put(T2C_LanguageEnum.english, List.of());
|
||||
put(T2C_LanguageEnum.german, List.of());
|
||||
}}),
|
||||
player1name("permissionWhitelist.whitelist.player1.name", "player1", false,
|
||||
new HashMap<>()),
|
||||
player1uuid("permissionWhitelist.whitelist.player1.uuid", "00000000000000000000000000000000", false,
|
||||
new HashMap<>()),
|
||||
player2name("permissionWhitelist.whitelist.player2.name", "player2", false,
|
||||
new HashMap<>()),
|
||||
player2uuid("permissionWhitelist.whitelist.player2.uuid", "00000000000000000000000000000000", false,
|
||||
new HashMap<>()),
|
||||
|
||||
;
|
||||
|
||||
private final String path;
|
||||
private Object value;
|
||||
private final boolean forceSet;
|
||||
private final HashMap<T2C_LanguageEnum, List<String>> comments;
|
||||
|
||||
VALUES(String path, Object value, boolean forceSet, HashMap<T2C_LanguageEnum, 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<T2C_LanguageEnum, List<String>> getComments() {
|
||||
return comments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLanguagePath() {
|
||||
return Config.VALUES.language.getValue().toString();
|
||||
}
|
||||
|
||||
@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(boolean isReload) {
|
||||
File file = new File(Main.getPath(), "permissionWhitelist.yml");
|
||||
T2C_ConfigWriter.createConfig(Util.getPrefix(), file, VALUES.values(), isReload, Util.getConfigLogo());
|
||||
getPlayer(file);
|
||||
}
|
||||
|
||||
PermissionWhitelist(String path, Boolean value, ConfigParam cEnum) {
|
||||
this.path = path;
|
||||
this.valueBoolean = value;
|
||||
this.cEnum = cEnum;
|
||||
|
||||
private static void getPlayer(File file) {
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(file);
|
||||
for (String key : yamlConfiguration.getConfigurationSection(VALUES.playerSection.getPath()).getKeys(false)) {
|
||||
String name = yamlConfiguration.getString(VALUES.playerSection.getPath() + "." + key + ".name");
|
||||
String uuid = yamlConfiguration.getString(VALUES.playerSection.getPath() + "." + key + ".uuid").replace("-", "");
|
||||
PlayerObject playerObject = new PlayerObject(
|
||||
name,
|
||||
uuid);
|
||||
PlayerCache.getOpHashMap().put(name, playerObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,56 +1,69 @@
|
||||
package net.t2code.opsecurity.events;
|
||||
|
||||
import net.t2code.opsecurity.Util;
|
||||
import net.t2code.opsecurity.config.config.Config;
|
||||
import net.t2code.opsecurity.util.Util;
|
||||
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 net.t2code.t2codelib.SPIGOT.api.debug.T2C_Debug;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
|
||||
import net.t2code.t2codelib.SPIGOT.api.update.T2C_UpdateAPI;
|
||||
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);
|
||||
T2C_Send.player(notifyPlayer, msg);
|
||||
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();
|
||||
String debug = T2Cdebug.debugCode();
|
||||
String debug = T2C_Debug.debugCode();
|
||||
|
||||
for (String s : (List<String>) 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();
|
||||
String debug2 = T2C_Debug.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();
|
||||
String debug = T2Cdebug.debugCode();
|
||||
String debug = T2C_Debug.debugCode();
|
||||
if (OpCheck.onCheck(player, false, debug)) {
|
||||
if (event.isCancelled()) return;
|
||||
event.setCancelled(true);
|
||||
}
|
||||
String debug2 = T2Cdebug.debugCode();
|
||||
String debug2 = T2C_Debug.debugCode();
|
||||
if (PermissionCheck.onCheck(player, false, debug2)) {
|
||||
if (event.isCancelled()) return;
|
||||
event.setCancelled(true);
|
||||
@ -59,16 +72,16 @@ public class Events implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEvent event) {
|
||||
if (!Config.checkOnInteract.valueBoolean) return;
|
||||
if (!(boolean) Config.VALUES.checkOnInteract.getValue()) return;
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(Main.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Player player = event.getPlayer();
|
||||
String debug = T2Cdebug.debugCode();
|
||||
String debug = T2C_Debug.debugCode();
|
||||
if (OpCheck.onCheck(player, false, debug)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
String debug2 = T2Cdebug.debugCode();
|
||||
String debug2 = T2C_Debug.debugCode();
|
||||
if (PermissionCheck.onCheck(player, false, debug2)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -78,14 +91,14 @@ public class Events implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onJoinCheck(PlayerJoinEvent event) {
|
||||
if (!Config.checkOnJoin.valueBoolean) return;
|
||||
if (!(boolean) Config.VALUES.checkOnJoin.getValue()) return;
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(Main.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Player player = event.getPlayer();
|
||||
String debug = T2Cdebug.debugCode();
|
||||
String debug = T2C_Debug.debugCode();
|
||||
OpCheck.onCheck(player, true, debug);
|
||||
String debug2 = T2Cdebug.debugCode();
|
||||
String debug2 = T2C_Debug.debugCode();
|
||||
PermissionCheck.onCheck(player, true, debug2);
|
||||
}
|
||||
}, 1L);
|
||||
@ -94,6 +107,6 @@ public class Events implements Listener {
|
||||
@EventHandler
|
||||
public void onJoinEvent(PlayerLoginEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
T2CupdateAPI.join(Main.getPlugin(), Util.getPrefix(), Permissions.updatemsg, player, Util.getSpigotID(), Util.getDiscord());
|
||||
T2C_UpdateAPI.join(Main.getPlugin(), Util.getPrefix(), Permissions.updatemsg, player, Util.getSpigotID(), Util.getDiscord());
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
package net.t2code.opsecurity.events;
|
||||
|
||||
import net.t2code.opsecurity.config.language.Language;
|
||||
import net.t2code.opsecurity.config.language.Languages;
|
||||
import net.t2code.opsecurity.config.opWhitelist.OPWhitelist;
|
||||
import net.t2code.opsecurity.enums.OpCommandRequest;
|
||||
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 net.t2code.t2codelib.SPIGOT.api.debug.T2C_Debug;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
|
||||
import net.t2code.t2codelib.SPIGOT.api.player.T2C_NameHistory;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -22,15 +22,15 @@ 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:
|
||||
T2Csend.sender(event.getSender(), Language.playerMustBeOnlineToOp.value);
|
||||
T2C_Send.sender(event.getSender(), Languages.VALUES.playerMustBeOnlineToOp.getValue().toString());
|
||||
event.setCancelled(true);
|
||||
break;
|
||||
case notWhitelisted:
|
||||
T2Csend.sender(event.getSender(), Language.opWhitelistOpCommand.value);
|
||||
T2C_Send.sender(event.getSender(), Languages.VALUES.opWhitelistOpCommand.getValue());
|
||||
event.setCancelled(true);
|
||||
break;
|
||||
}
|
||||
@ -39,15 +39,15 @@ 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:
|
||||
T2Csend.player(event.getPlayer(), Language.playerMustBeOnlineToOp.value);
|
||||
T2C_Send.player(event.getPlayer(), Languages.VALUES.playerMustBeOnlineToOp.getValue().toString());
|
||||
event.setCancelled(true);
|
||||
break;
|
||||
case notWhitelisted:
|
||||
T2Csend.player(event.getPlayer(), Language.opWhitelistOpCommand.value);
|
||||
T2C_Send.player(event.getPlayer(), Languages.VALUES.opWhitelistOpCommand.getValue().toString());
|
||||
event.setCancelled(true);
|
||||
break;
|
||||
}
|
||||
@ -59,7 +59,7 @@ public class OpCommand implements Listener {
|
||||
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;
|
||||
}
|
||||
@ -69,7 +69,7 @@ public class OpCommand implements Listener {
|
||||
targetUUID = target.getUniqueId().toString();
|
||||
} else {
|
||||
try {
|
||||
targetUUID = T2CnameHistory.NameLookup.getPlayerUUID(arg);
|
||||
targetUUID = T2C_NameHistory.NameLookup.getPlayerUUID(arg);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@ -80,13 +80,13 @@ public class OpCommand implements Listener {
|
||||
|
||||
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 );
|
||||
T2C_Debug.debug(Main.getPlugin(), "--------- " + playerName);
|
||||
T2C_Debug.debug(Main.getPlugin(),"opWhitelist (op command) playerObject Name: "+playerObject.getValue().playerName );
|
||||
T2C_Debug.debug(Main.getPlugin(),"opWhitelist (op command) Player Name: "+ playerName );
|
||||
T2C_Debug.debug(Main.getPlugin(),"opWhitelist (op command) playerObject UUID: "+playerObject.getValue().uuid );
|
||||
T2C_Debug.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!");
|
||||
T2C_Debug.debug(Main.getPlugin(),"opWhitelist (op command) on list!");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
package net.t2code.opsecurity.events;
|
||||
|
||||
import net.t2code.opsecurity.Util;
|
||||
import net.t2code.opsecurity.util.Util;
|
||||
import net.t2code.opsecurity.system.Main;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
@ -20,7 +20,7 @@ public class PlugManCommand implements Listener {
|
||||
|| (event.getCommand().toLowerCase().contains("plugman restart") && event.getCommand().toLowerCase().contains(Main.getPlugin().getDescription().getName().toLowerCase()))
|
||||
) {
|
||||
event.setCancelled(true);
|
||||
T2Csend.console(Util.getPrefix() + " §4OPSecurity cannot be deactivated!");
|
||||
T2C_Send.console(Util.getPrefix() + " §4OPSecurity cannot be deactivated!");
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ public class PlugManCommand implements Listener {
|
||||
|| (event.getMessage().toLowerCase().startsWith("/plugman restart") && event.getMessage().toLowerCase().contains(Main.getPlugin().getDescription().getName().toLowerCase()))
|
||||
) {
|
||||
event.setCancelled(true);
|
||||
T2Csend.player(event.getPlayer(), Util.getPrefix() + " §4OPSecurity cannot be deactivated!");
|
||||
T2C_Send.player(event.getPlayer(), Util.getPrefix() + " §4OPSecurity cannot be deactivated!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.t2code.opsecurity.objects;
|
||||
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
@ -1,8 +1,8 @@
|
||||
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 net.t2code.t2codelib.SPIGOT.api.debug.T2C_Debug;
|
||||
import net.t2code.t2codelib.util.T2C_Util;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
@ -20,7 +20,7 @@ public class BungeeSenderReceiver implements PluginMessageListener {
|
||||
e.printStackTrace();
|
||||
}
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
player.sendPluginMessage(Main.getPlugin(), "t2c:opsec", stream.toByteArray());
|
||||
player.sendPluginMessage(Main.getPlugin(), T2C_Util.getPluginChannel_OPSecurity(), stream.toByteArray());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -28,11 +28,11 @@ public class BungeeSenderReceiver implements PluginMessageListener {
|
||||
@Override
|
||||
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
|
||||
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(message));
|
||||
T2Cdebug.debug(Main.getPlugin(), "stream: " + stream.toString());
|
||||
T2C_Debug.debug(Main.getPlugin(), "stream: " + stream.toString());
|
||||
try {
|
||||
String subChannel = stream.readUTF();
|
||||
String information = stream.readUTF();
|
||||
if (subChannel.equals("T2Cconsole")) {
|
||||
if (subChannel.equals(T2C_Util.getPluginSubChannel_Console())) {
|
||||
Events.notifyPlayer(information);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
@ -1,18 +1,23 @@
|
||||
package net.t2code.opsecurity.system;
|
||||
|
||||
import net.t2code.opsecurity.Util;
|
||||
import net.t2code.opsecurity.util.Util;
|
||||
import net.t2code.opsecurity.check.Timer;
|
||||
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.language.Languages;
|
||||
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.T2Ctemplate;
|
||||
import net.t2code.t2codelib.SPIGOT.api.register.T2Cregister;
|
||||
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
|
||||
import org.checkerframework.checker.units.qual.C;
|
||||
import net.t2code.t2codelib.SPIGOT.api.debug.T2C_Debug;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Template;
|
||||
import net.t2code.t2codelib.SPIGOT.api.register.T2C_Register;
|
||||
import net.t2code.t2codelib.SPIGOT.api.update.T2C_UpdateAPI;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.config.T2C_LibConfig;
|
||||
import net.t2code.t2codelib.util.T2C_Util;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
@ -20,7 +25,7 @@ import java.util.logging.Level;
|
||||
public class Load {
|
||||
|
||||
public static void onLoad(Main plugin, List<String> autor, String version) {
|
||||
long long_ = T2Ctemplate.onLoadHeader(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord());
|
||||
long long_ = T2C_Template.onLoadHeader(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord());
|
||||
try {
|
||||
Converter.convert();
|
||||
} catch (Exception ex) {
|
||||
@ -28,22 +33,25 @@ public class Load {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
FileSelect.selectConfig();
|
||||
FileSelect.selectLanguage();
|
||||
FileSelect.selectOpWhitelist();
|
||||
FileSelect.selectPermissionWhitelist();
|
||||
Config.set(false);
|
||||
Languages.set(false);
|
||||
OPWhitelist.set(false);
|
||||
PermissionWhitelist.set(false);
|
||||
|
||||
plugin.getCommand("t2c-opsecurity").setExecutor(new CmdExecuter());
|
||||
|
||||
T2Cregister.listener(new OpCommand(), plugin);
|
||||
T2Cregister.listener(new PlugManCommand(), plugin);
|
||||
T2Cregister.listener(new Events(), plugin);
|
||||
|
||||
T2C_Register.listener(new OpCommand(), plugin);
|
||||
T2C_Register.listener(new PlugManCommand(), plugin);
|
||||
T2C_Register.listener(new Events(), plugin);
|
||||
if ((boolean) T2C_LibConfig.VALUES.proxy.getValue()) {
|
||||
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, T2C_Util.getPluginChannel_OPSecurity());
|
||||
T2C_Debug.debug(plugin, "registerIncomingPluginChannel §e:" + T2C_Util.getPluginChannel_OPSecurity());
|
||||
}
|
||||
Timer.refreshTimer();
|
||||
Permissions.register();
|
||||
T2CupdateAPI.onUpdateCheck(plugin, Util.getPrefix(),Util.getGit(),Util.getSpigotID(),Util.getDiscord(), Config.updateCheckOnJoin.valueBoolean,
|
||||
Config.updateCheckSeePreReleaseUpdates.valueBoolean, Config.updateCheckTimeInterval.valueInt);
|
||||
T2C_UpdateAPI.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_);
|
||||
T2C_Template.onLoadFooter(Util.getPrefix(), long_);
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package net.t2code.opsecurity.system;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.t2code.opsecurity.Util;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
||||
import net.t2code.opsecurity.util.Util;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Template;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
@ -53,11 +53,11 @@ public final class Main extends JavaPlugin {
|
||||
@Override
|
||||
public void onDisable() {
|
||||
// Plugin shutdown logic
|
||||
if (t2codeLib) T2Ctemplate.onDisable(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord());
|
||||
if (t2codeLib) T2C_Template.onDisable(Util.getPrefix(),plugin);
|
||||
}
|
||||
|
||||
private static Boolean pluginNotFound(String pl, Integer spigotID, String ver) {
|
||||
if (Bukkit.getPluginManager().getPlugin(pl) == null) {
|
||||
if (Bukkit.getPluginManager().getPlugin(pl) == null || !Bukkit.getPluginManager().isPluginEnabled(pl)) {
|
||||
plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!");
|
||||
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §e" + pl + " §4could not be found. Please download it here: "
|
||||
+ "§6https://spigotmc.org/resources/" + pl + "." + spigotID + " §4to be able to use this plugin.");
|
||||
|
@ -1,6 +1,6 @@
|
||||
package net.t2code.opsecurity.system;
|
||||
|
||||
import net.t2code.t2codelib.SPIGOT.api.register.T2Cregister;
|
||||
import net.t2code.t2codelib.SPIGOT.api.register.T2C_Register;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
public class Permissions {
|
||||
@ -16,17 +16,17 @@ public class Permissions {
|
||||
public static final PermissionDefault notOp = PermissionDefault.NOT_OP;
|
||||
|
||||
protected static void register() {
|
||||
T2Cregister.permission(notify, op, Main.getPlugin());
|
||||
T2Cregister.permissionDescription(notify,"Players with this permission get the update message when joining if an update is available",Main.getPlugin());
|
||||
T2Cregister.permission(updatemsg, op, Main.getPlugin());
|
||||
T2Cregister.permission(reload, op, Main.getPlugin());
|
||||
T2Cregister.permission(info, op, Main.getPlugin());
|
||||
T2Cregister.permission(help, op, Main.getPlugin());
|
||||
T2C_Register.permission(notify, op, Main.getPlugin());
|
||||
T2C_Register.permissionDescription(notify,"Players with this permission get the update message when joining if an update is available",Main.getPlugin());
|
||||
T2C_Register.permission(updatemsg, op, Main.getPlugin());
|
||||
T2C_Register.permission(reload, op, Main.getPlugin());
|
||||
T2C_Register.permission(info, op, Main.getPlugin());
|
||||
T2C_Register.permission(help, op, Main.getPlugin());
|
||||
|
||||
T2Cregister.permission(admin, op, notify, true, Main.getPlugin());
|
||||
T2Cregister.permission(admin, op, updatemsg, true, Main.getPlugin());
|
||||
T2Cregister.permission(admin, op, reload, true, Main.getPlugin());
|
||||
T2Cregister.permission(admin, op, info, true, Main.getPlugin());
|
||||
T2Cregister.permission(admin, op, help, true, Main.getPlugin());
|
||||
T2C_Register.permission(admin, op, notify, true, Main.getPlugin());
|
||||
T2C_Register.permission(admin, op, updatemsg, true, Main.getPlugin());
|
||||
T2C_Register.permission(admin, op, reload, true, Main.getPlugin());
|
||||
T2C_Register.permission(admin, op, info, true, Main.getPlugin());
|
||||
T2C_Register.permission(admin, op, help, true, Main.getPlugin());
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,40 @@
|
||||
package net.t2code.opsecurity.util;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.t2code.t2codelib.util.T2C_Util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Util {
|
||||
|
||||
@Getter
|
||||
private static String infoText = "";
|
||||
|
||||
@Getter
|
||||
private static String requiredT2CodeLibVersion = "16.7";
|
||||
|
||||
@Getter
|
||||
private static String prefix = "§8[§4T2C§8-§2OP§4Security§8]";
|
||||
|
||||
@Getter
|
||||
private static Integer spigotID = 90739;
|
||||
|
||||
@Getter
|
||||
private static String git = "JaTiTV/T2C-OPSecurity";
|
||||
|
||||
@Getter
|
||||
private static Integer bstatsID = 10858;
|
||||
|
||||
@Getter
|
||||
private static String spigot = "https://spigotmc.org/resources/" + getSpigotID();
|
||||
|
||||
@Getter
|
||||
private static String discord = "http://dc.t2code.net";
|
||||
|
||||
public static String[] getConfigLogo() {
|
||||
ArrayList<String> arrayList = new ArrayList<>(T2C_Util.getConfigT2CodeLogo());
|
||||
arrayList.addAll(Arrays.asList("", "# Spigot: " + spigot));
|
||||
return arrayList.toArray(new String[0]);
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ load: STARTUP
|
||||
prefix: T2C-OPSecurity
|
||||
authors: [ JaTiTV ]
|
||||
|
||||
|
||||
softdepend:
|
||||
- T2CodeLib
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user