Compare commits
15 Commits
testversio
...
3.1.0
Author | SHA1 | Date | |
---|---|---|---|
98fd0409fd | |||
a2bd88ac7c | |||
dba1e57b91 | |||
e14f91c584 | |||
1547c16093 | |||
44507458e5 | |||
ea54d85ecc | |||
43e51fee59 | |||
466314f206 | |||
47a9080dba | |||
|
af608fad02 | ||
632c23b1ff | |||
6fbd56ea63 | |||
31a958ce7f | |||
dab5a4f557 |
@@ -6,7 +6,8 @@
|
||||
|
||||
<groupId>net.t2code</groupId>
|
||||
<artifactId>T2C-OPSecurity</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<version>3.1.0</version>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>T2C-OPSecurity</name>
|
||||
@@ -17,6 +18,7 @@
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}_${project.version}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
@@ -81,7 +83,8 @@
|
||||
<dependency>
|
||||
<groupId>net.t2code</groupId>
|
||||
<artifactId>T2CodeLib</artifactId>
|
||||
<version>13.2</version>
|
||||
<version>13.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
|
||||
<dependency>
|
||||
@@ -90,11 +93,5 @@
|
||||
<version>1.18.24</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.22</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
@@ -0,0 +1,60 @@
|
||||
package net.t2code.opsecurity.API;
|
||||
|
||||
import net.t2code.opsecurity.check.OpCheck;
|
||||
import net.t2code.opsecurity.check.PermissionCheck;
|
||||
import net.t2code.opsecurity.config.config.Config;
|
||||
import net.t2code.opsecurity.config.opWhitelist.OPWhitelist;
|
||||
import net.t2code.opsecurity.config.permissionWhitelist.PermissionWhitelist;
|
||||
import net.t2code.opsecurity.objects.PlayerCache;
|
||||
import net.t2code.opsecurity.objects.PlayerObject;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class T2COpSecAPI {
|
||||
public static boolean checkOPWhiteList(Player player) {
|
||||
if (!OPWhitelist.enable.valueBoolean) return true;
|
||||
return OpCheck.opWhitelist(player);
|
||||
}
|
||||
|
||||
public static boolean checkPermissionWhiteList(Player player) {
|
||||
if (!PermissionWhitelist.enable.valueBoolean) return true;
|
||||
return PermissionCheck.permWhitelist(player);
|
||||
}
|
||||
|
||||
public static T2COpSecAPIPlayerStatus detailCheckOPWhiteList(Player player) {
|
||||
if (!OPWhitelist.enable.valueBoolean) return T2COpSecAPIPlayerStatus.playerOnOpWhitelist;
|
||||
List<String> nameList = new ArrayList<>();
|
||||
List<String> uuidList = new ArrayList<>();
|
||||
for (Map.Entry<String, PlayerObject> playerObject : PlayerCache.getOpHashMap().entrySet()) {
|
||||
nameList.add(playerObject.getValue().playerName);
|
||||
uuidList.add(playerObject.getValue().uuid);
|
||||
}
|
||||
if (!nameList.contains(player.getName())) {
|
||||
return T2COpSecAPIPlayerStatus.playerNameNotOnTheOpWhitelist;
|
||||
}
|
||||
if (!uuidList.contains(player.getUniqueId().toString().replace("-", ""))) {
|
||||
return T2COpSecAPIPlayerStatus.playerUuidNotOnTheOpWhitelist;
|
||||
}
|
||||
return T2COpSecAPIPlayerStatus.playerOnOpWhitelist;
|
||||
}
|
||||
public static T2COpSecAPIPlayerStatus detailCheckPermissionWhiteList(Player player) {
|
||||
if (!PermissionWhitelist.enable.valueBoolean) return T2COpSecAPIPlayerStatus.playerOnPermissionWhitelist;
|
||||
List<String> nameList = new ArrayList<>();
|
||||
List<String> uuidList = new ArrayList<>();
|
||||
for (Map.Entry<String, PlayerObject> playerObject : PlayerCache.getPermissionHashMap().entrySet()) {
|
||||
nameList.add(playerObject.getValue().playerName);
|
||||
uuidList.add(playerObject.getValue().uuid);
|
||||
}
|
||||
if (!nameList.contains(player.getName())) {
|
||||
return T2COpSecAPIPlayerStatus.playerNameNotOnThePermissionWhitelist;
|
||||
}
|
||||
if (!uuidList.contains(player.getUniqueId().toString().replace("-", ""))) {
|
||||
return T2COpSecAPIPlayerStatus.playerUuidNotOnThePermissionWhitelist;
|
||||
}
|
||||
return T2COpSecAPIPlayerStatus.playerOnPermissionWhitelist;
|
||||
}
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
package net.t2code.opsecurity.API;
|
||||
|
||||
public enum T2COpSecAPIPlayerStatus {
|
||||
playerOnOpWhitelist,
|
||||
playerNameNotOnTheOpWhitelist,
|
||||
playerUuidNotOnTheOpWhitelist,
|
||||
playerOnPermissionWhitelist,
|
||||
playerNameNotOnThePermissionWhitelist,
|
||||
playerUuidNotOnThePermissionWhitelist
|
||||
}
|
@@ -8,7 +8,7 @@ public class Util {
|
||||
private static String infoText = "";
|
||||
|
||||
@Getter
|
||||
private static String requiredT2CodeLibVersion = "13.2";
|
||||
private static String requiredT2CodeLibVersion = "13.4";
|
||||
|
||||
@Getter
|
||||
private static String prefix = "§8[§4T2C§8-§2OP§4Security§8]";
|
||||
@@ -16,6 +16,9 @@ public class Util {
|
||||
@Getter
|
||||
private static Integer spigotID = 90739;
|
||||
|
||||
@Getter
|
||||
private static String git = "JaTiTV/T2C-OPSecurity";
|
||||
|
||||
@Getter
|
||||
private static Integer bstatsID = 10858;
|
||||
|
||||
|
@@ -4,7 +4,7 @@ import net.t2code.opsecurity.config.config.Config;
|
||||
import net.t2code.opsecurity.config.language.Language;
|
||||
import net.t2code.opsecurity.config.opWhitelist.OPWhitelist;
|
||||
import net.t2code.opsecurity.events.Events;
|
||||
import net.t2code.opsecurity.objects.PlayerCash;
|
||||
import net.t2code.opsecurity.objects.PlayerCache;
|
||||
import net.t2code.opsecurity.objects.PlayerObject;
|
||||
import net.t2code.opsecurity.system.BungeeSenderReceiver;
|
||||
import net.t2code.opsecurity.system.Main;
|
||||
@@ -89,8 +89,16 @@ public class OpCheck {
|
||||
}
|
||||
|
||||
public static Boolean opWhitelist(Player player) {
|
||||
for (Map.Entry<String, PlayerObject> playerObject : PlayerCash.getOpHashMap().entrySet()) {
|
||||
if (playerObject.getValue().playerName.equals(player.getName()) && playerObject.getValue().uuid.equals(player.getUniqueId().toString())) return true;
|
||||
for (Map.Entry<String, PlayerObject> playerObject : PlayerCache.getOpHashMap().entrySet()) {
|
||||
T2Csend.debug(Main.getPlugin(), "--------- " + player.getName());
|
||||
T2Csend.debug(Main.getPlugin(), "opWhitelist playerObject Name: " + playerObject.getValue().playerName);
|
||||
T2Csend.debug(Main.getPlugin(), "opWhitelist Player Name: " + player.getName());
|
||||
T2Csend.debug(Main.getPlugin(), "opWhitelist playerObject UUID: " + playerObject.getValue().uuid);
|
||||
T2Csend.debug(Main.getPlugin(), "opWhitelist Player UUID: " + player.getUniqueId().toString().replace("-", ""));
|
||||
if (playerObject.getValue().playerName.equals(player.getName()) && playerObject.getValue().uuid.equals(player.getUniqueId().toString().replace("-", ""))) {
|
||||
T2Csend.debug(Main.getPlugin(), "opWhitelist Player on list!");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@ import net.t2code.opsecurity.config.config.Config;
|
||||
import net.t2code.opsecurity.config.language.Language;
|
||||
import net.t2code.opsecurity.config.permissionWhitelist.PermissionWhitelist;
|
||||
import net.t2code.opsecurity.events.Events;
|
||||
import net.t2code.opsecurity.objects.PlayerCash;
|
||||
import net.t2code.opsecurity.objects.PlayerCache;
|
||||
import net.t2code.opsecurity.objects.PlayerObject;
|
||||
import net.t2code.opsecurity.system.BungeeSenderReceiver;
|
||||
import net.t2code.opsecurity.system.Main;
|
||||
@@ -19,8 +19,8 @@ public class PermissionCheck {
|
||||
public static Boolean onCheck(Player player, Boolean join) {
|
||||
if (!PermissionWhitelist.enable.valueBoolean) return false;
|
||||
for (String perm : PermissionWhitelist.permissions.valueStringList) {
|
||||
if (!player.hasPermission(perm)) continue;
|
||||
if (permWhitelist(player)) continue;
|
||||
if (!player.hasPermission(perm)) return false;
|
||||
if (permWhitelist(player)) return false;
|
||||
Bukkit.getScheduler().runTask(Main.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -42,21 +42,30 @@ public class PermissionCheck {
|
||||
|
||||
if (PermissionWhitelist.playerWithPermissionKick.valueBoolean) {
|
||||
if (Config.kickCustomCommand.valueBoolean) {
|
||||
T2Ccmd.console(Config.kickCommand.valueString.replace("[player]", player.getName()).replace("[reason]", Language.permissionWhitelistKick.value));
|
||||
T2Ccmd.console(Config.kickCommand.valueString.replace("[perm]", perm).replace("[player]", player.getName()).replace("[reason]", Language.permissionWhitelistKick.value));
|
||||
} else player.kickPlayer(Language.permissionWhitelistKick.value);
|
||||
T2Csend.console(Language.permissionWhitelistNotifyKick.value.replace("[player]",
|
||||
player.getName()).replace("[perm]", perm).replace("[uuid]",String.valueOf(player.getUniqueId())));
|
||||
}
|
||||
if (PermissionWhitelist.customCommandsCommands.valueBoolean) {
|
||||
if (PermissionWhitelist.customCommandsEnable.valueBoolean) {
|
||||
for (String cmd : PermissionWhitelist.customCommandsCommands.valueStringList) {
|
||||
T2Ccmd.console(cmd.replace("[player]", player.getName()).replace("[perm]", perm));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Boolean permWhitelist(Player player) {
|
||||
for (Map.Entry<String, PlayerObject> playerObject : PlayerCash.getPermissionHashMap().entrySet()) {
|
||||
if (playerObject.getValue().playerName.equals(player.getName()) && playerObject.getValue().uuid.equals(player.getUniqueId().toString())) return true;
|
||||
public static Boolean permWhitelist(Player player) {
|
||||
|
||||
for (Map.Entry<String, PlayerObject> playerObject : PlayerCache.getPermissionHashMap().entrySet()) {
|
||||
T2Csend.debug(Main.getPlugin(), "--------- " + player.getName());
|
||||
T2Csend.debug(Main.getPlugin(),"permWhitelist playerObject Name: "+playerObject.getValue().playerName );
|
||||
T2Csend.debug(Main.getPlugin(),"permWhitelist Player Name: "+player.getName() );
|
||||
T2Csend.debug(Main.getPlugin(),"permWhitelist playerObject UUID: "+playerObject.getValue().uuid );
|
||||
T2Csend.debug(Main.getPlugin(),"permWhitelist Player UUID: "+player.getUniqueId().toString().replace("-","") );
|
||||
if (playerObject.getValue().playerName.equals(player.getName()) && playerObject.getValue().uuid.equals(player.getUniqueId().toString().replace("-",""))){
|
||||
T2Csend.debug(Main.getPlugin(),"permWhitelist Player on list!");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@@ -4,12 +4,8 @@ package net.t2code.opsecurity.command;
|
||||
|
||||
import net.t2code.opsecurity.Util;
|
||||
import net.t2code.opsecurity.config.config.Config;
|
||||
import net.t2code.opsecurity.objects.PlayerCash;
|
||||
import net.t2code.opsecurity.objects.PlayerObject;
|
||||
import net.t2code.opsecurity.system.Main;
|
||||
import net.t2code.opsecurity.system.Permissions;
|
||||
import net.t2code.t2codelib.SPIGOT.api.commands.T2Ctab;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -18,7 +14,6 @@ import org.bukkit.command.TabCompleter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class CmdExecuter implements CommandExecutor, TabCompleter {
|
||||
|
||||
|
@@ -5,8 +5,6 @@ import net.t2code.opsecurity.check.OpCheck;
|
||||
import net.t2code.opsecurity.config.FileSelect;
|
||||
import net.t2code.opsecurity.config.config.Config;
|
||||
import net.t2code.opsecurity.config.language.Language;
|
||||
import net.t2code.opsecurity.enums.OpCommandRequest;
|
||||
import net.t2code.opsecurity.objects.PlayerCash;
|
||||
import net.t2code.opsecurity.system.Main;
|
||||
import net.t2code.opsecurity.system.Permissions;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
|
@@ -5,7 +5,7 @@ import net.t2code.opsecurity.config.config.Config;
|
||||
import net.t2code.opsecurity.config.language.Language;
|
||||
import net.t2code.opsecurity.config.opWhitelist.OPWhitelist;
|
||||
import net.t2code.opsecurity.config.permissionWhitelist.PermissionWhitelist;
|
||||
import net.t2code.opsecurity.objects.PlayerCash;
|
||||
import net.t2code.opsecurity.objects.PlayerCache;
|
||||
import net.t2code.opsecurity.objects.PlayerObject;
|
||||
import net.t2code.opsecurity.system.Main;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
|
||||
@@ -24,12 +24,12 @@ public class FileSelect {
|
||||
File config = new File(Main.getPath(), "config.yml");
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
for (Config value : Config.values()) {
|
||||
switch (value.cEnum) {
|
||||
switch (value.configParam) {
|
||||
case STRING:
|
||||
if (!yamlConfiguration.contains(value.path)) {
|
||||
yamlConfiguration.set(value.path, value.valueString);
|
||||
}
|
||||
value.valueString = T2Creplace.replace(Util.getPrefix(), yamlConfiguration.getString(value.path));
|
||||
value.valueString = T2Creplace.replace(Util.getPrefix(), Objects.requireNonNull(yamlConfiguration.getString(value.path)));
|
||||
break;
|
||||
case SOUND:
|
||||
if (!yamlConfiguration.contains(value.path)) {
|
||||
@@ -115,7 +115,7 @@ public class FileSelect {
|
||||
}
|
||||
|
||||
public static void selectOpWhitelist() {
|
||||
PlayerCash.getOpHashMap().clear();
|
||||
PlayerCache.getOpHashMap().clear();
|
||||
File config = new File(Main.getPath(), "opWhitelist.yml");
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
for (OPWhitelist value : OPWhitelist.values()) {
|
||||
@@ -128,7 +128,7 @@ public class FileSelect {
|
||||
break;
|
||||
case STRINGLIST:
|
||||
if (!yamlConfiguration.contains(value.path)) {
|
||||
yamlConfiguration.set(value.path, value.valueBoolean);
|
||||
yamlConfiguration.set(value.path, value.valueStringList);
|
||||
}
|
||||
value.valueStringList = T2Creplace.replace(Util.getPrefix(), yamlConfiguration.getStringList(value.path));
|
||||
break;
|
||||
@@ -143,8 +143,8 @@ public class FileSelect {
|
||||
String name = yamlConfiguration.getString(value.pathPlayerName.replace("KEY", key));
|
||||
PlayerObject playerObject = new PlayerObject(
|
||||
name,
|
||||
yamlConfiguration.getString(value.pathPlayerUuid.replace("KEY", key).replace("-", "")));
|
||||
PlayerCash.getOpHashMap().put(name, playerObject);
|
||||
yamlConfiguration.getString(value.pathPlayerUuid.replace("KEY", key)).replace("-", ""));
|
||||
PlayerCache.getOpHashMap().put(name, playerObject);
|
||||
}
|
||||
break;
|
||||
case GAMEMODE:
|
||||
@@ -168,7 +168,7 @@ public class FileSelect {
|
||||
}
|
||||
|
||||
public static void selectPermissionWhitelist() {
|
||||
PlayerCash.getPermissionHashMap().clear();
|
||||
PlayerCache.getPermissionHashMap().clear();
|
||||
File config = new File(Main.getPath(), "permissionWhitelist.yml");
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
for (PermissionWhitelist value : PermissionWhitelist.values()) {
|
||||
@@ -196,8 +196,8 @@ public class FileSelect {
|
||||
String name = yamlConfiguration.getString(value.pathPlayerName.replace("KEY", key));
|
||||
PlayerObject playerObject = new PlayerObject(
|
||||
name,
|
||||
yamlConfiguration.getString(value.pathPlayerUuid.replace("KEY", key).replace("-", "")));
|
||||
PlayerCash.getPermissionHashMap().put(name, playerObject);
|
||||
yamlConfiguration.getString(value.pathPlayerUuid.replace("KEY", key)).replace("-", ""));
|
||||
PlayerCache.getPermissionHashMap().put(name, playerObject);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@@ -9,13 +9,17 @@ public enum Config {
|
||||
language("plugin.language", "english", ConfigParam.STRING),
|
||||
onlyOPcanUseThePlugin("plugin.onlyOPcanUseThePlugin", true, ConfigParam.BOOLEAN),
|
||||
|
||||
updateCheckOnJoin("plugin.updateCheck.onJoin",true,ConfigParam.BOOLEAN),
|
||||
updateCheckSeePreReleaseUpdates("plugin.updateCheck.seePreReleaseUpdates",true,ConfigParam.BOOLEAN),
|
||||
updateCheckTimeInterval("plugin.updateCheck.timeInterval",60,ConfigParam.INTEGER),
|
||||
|
||||
checkOnJoin("check.onJoin", true, ConfigParam.BOOLEAN),
|
||||
checkOnInteract("check.onInteract", true, ConfigParam.BOOLEAN),
|
||||
checkOnCommand("check.onCommand", true, ConfigParam.BOOLEAN),
|
||||
checkOnChat("check.onChat", true, ConfigParam.BOOLEAN),
|
||||
checkTimerEnable("check.timer.enable", true, ConfigParam.BOOLEAN),
|
||||
checkTimerRefreshInSec("check.timer.refreshInSec", 60, ConfigParam.INTEGER),
|
||||
kickCustomCommand("kick.customCommand.Enable", false, ConfigParam.BOOLEAN),
|
||||
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),
|
||||
@@ -27,30 +31,30 @@ public enum Config {
|
||||
public Integer valueInt;
|
||||
public Boolean valueBoolean;
|
||||
public Sound sound;
|
||||
public ConfigParam cEnum;
|
||||
public ConfigParam configParam;
|
||||
|
||||
Config(String path, String value, ConfigParam cEnum) {
|
||||
this.path = path;
|
||||
this.valueString = value;
|
||||
this.cEnum = cEnum;
|
||||
this.configParam = cEnum;
|
||||
}
|
||||
|
||||
Config(String path, Sound value, ConfigParam cEnum) {
|
||||
this.path = path;
|
||||
this.sound = value;
|
||||
this.cEnum = cEnum;
|
||||
this.configParam = cEnum;
|
||||
}
|
||||
|
||||
Config(String path, Integer value, ConfigParam cEnum) {
|
||||
this.path = path;
|
||||
this.valueInt = value;
|
||||
this.cEnum = cEnum;
|
||||
this.configParam = cEnum;
|
||||
}
|
||||
|
||||
Config(String path, Boolean value, ConfigParam cEnum) {
|
||||
this.path = path;
|
||||
this.valueBoolean = value;
|
||||
this.cEnum = cEnum;
|
||||
this.configParam = cEnum;
|
||||
}
|
||||
|
||||
public static Sound sound() {
|
||||
|
@@ -58,8 +58,9 @@ public enum Language {
|
||||
"[prefix] <dark_red>Player <gold><hover:show_text:'<gold>Name:</gold> <yellow>[player]</yellow><br><gold>UUID:</gold> <yellow>[uuid]</yellow>'>[player]</hover></gold> has permission <gold>[perm]</gold> and is not authorized to do so! Therefore he was kicked! <gold><hover:show_text:'<gold>Name:</gold> <yellow>[player]</yellow><br><gold>UUID:</gold> <yellow>[uuid]</yellow>'>[player]</hover></gold> is not on the Player list!</dark_red>"),
|
||||
|
||||
permissionWhitelistKick("permissionWhitelist.kick",null,
|
||||
"<dark_red>Du wurdest gekickt, da du Permissions besitzt, für die du keine Berechtigung besitzt!</dark_red>",
|
||||
"<dark_red>You were kicked because you have permissions to which you do not have permission!</dark_red>"),
|
||||
"&4Du wurdest gekickt, da du Permissions besitzt, für die du keine Berechtigung besitzt!",
|
||||
"&4You were kicked because you have permissions to which you do not have permission!"),
|
||||
|
||||
exactKickReason("console.exactKickReason", null,
|
||||
"[prefix] <dark_red>Genauer Grund:</dark_red> <gold>[reason]</gold>",
|
||||
"[prefix] <dark_red>Exact reason:</dark_red> <gold>[reason]</gold>");
|
||||
|
@@ -9,7 +9,7 @@ import java.util.List;
|
||||
public enum OPWhitelist {
|
||||
enable("opWhitelist.enable", false, ConfigParam.BOOLEAN),
|
||||
playerMustBeOnlineToOp("opWhitelist.playerMustBeOnlineToOp", true, ConfigParam.BOOLEAN),
|
||||
noOpPlayerDeopEnable("opWhitelist.enable", true, ConfigParam.BOOLEAN),
|
||||
noOpPlayerDeopEnable("opWhitelist.noOpPlayerDeop.enable", true, ConfigParam.BOOLEAN),
|
||||
noOpPlayerDeopPlayerSendMessage("opWhitelist.noOpPlayerDeop.playerSendMessage", true, ConfigParam.BOOLEAN),
|
||||
noOpPlayerKickEnable("opWhitelist.noOpPlayerKick.enable", true, ConfigParam.BOOLEAN),
|
||||
noOpPlayerSetGameModeEnable("opWhitelist.noOpPlayerSetGameMode.enable", true, ConfigParam.BOOLEAN),
|
||||
|
@@ -1,11 +1,11 @@
|
||||
package net.t2code.opsecurity.events;
|
||||
|
||||
import net.t2code.opsecurity.check.OpCheck;
|
||||
import net.t2code.opsecurity.config.language.Language;
|
||||
import net.t2code.opsecurity.config.opWhitelist.OPWhitelist;
|
||||
import net.t2code.opsecurity.enums.OpCommandRequest;
|
||||
import net.t2code.opsecurity.objects.PlayerCash;
|
||||
import net.t2code.opsecurity.objects.PlayerCache;
|
||||
import net.t2code.opsecurity.objects.PlayerObject;
|
||||
import net.t2code.opsecurity.system.Main;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.player.T2CnameHistory;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -57,10 +57,12 @@ public class OpCommand implements Listener {
|
||||
if (command.charAt(0) == '/') command = command.replaceFirst("/", "");
|
||||
String arg = command.replace("op ", "");
|
||||
Player target = Bukkit.getPlayer(arg);
|
||||
|
||||
if (OPWhitelist.playerMustBeOnlineToOp.valueBoolean) {
|
||||
if (target == null) return OpCommandRequest.mustOnline;
|
||||
if (!opWhitelist(target.getName(), target.getUniqueId().toString())) return OpCommandRequest.notWhitelisted;
|
||||
}
|
||||
|
||||
String targetUUID;
|
||||
if (target != null) {
|
||||
targetUUID = target.getUniqueId().toString();
|
||||
@@ -76,8 +78,16 @@ public class OpCommand implements Listener {
|
||||
}
|
||||
|
||||
private static Boolean opWhitelist(String playerName, String playerUuid) {
|
||||
for (Map.Entry<String, PlayerObject> playerObject : PlayerCash.getOpHashMap().entrySet()) {
|
||||
if (playerObject.getValue().playerName.equals(playerName) && playerObject.getValue().uuid.equals(playerUuid)) return true;
|
||||
for (Map.Entry<String, PlayerObject> playerObject : PlayerCache.getOpHashMap().entrySet()) {
|
||||
T2Csend.debug(Main.getPlugin(), "--------- " + playerName);
|
||||
T2Csend.debug(Main.getPlugin(),"opWhitelist (op command) playerObject Name: "+playerObject.getValue().playerName );
|
||||
T2Csend.debug(Main.getPlugin(),"opWhitelist (op command) Player Name: "+ playerName );
|
||||
T2Csend.debug(Main.getPlugin(),"opWhitelist (op command) playerObject UUID: "+playerObject.getValue().uuid );
|
||||
T2Csend.debug(Main.getPlugin(),"opWhitelist (op command) Player UUID: "+ playerUuid );
|
||||
if (playerObject.getValue().playerName.equals(playerName) && playerObject.getValue().uuid.equals(playerUuid.replace("-", ""))) {
|
||||
T2Csend.debug(Main.getPlugin(),"opWhitelist (op command) on list!");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@ import lombok.Getter;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class PlayerCash {
|
||||
public class PlayerCache {
|
||||
@Getter
|
||||
private static HashMap<String, PlayerObject> opHashMap = new HashMap<String, PlayerObject>();
|
||||
@Getter
|
@@ -3,6 +3,7 @@ package net.t2code.opsecurity.system;
|
||||
import net.t2code.opsecurity.Util;
|
||||
import net.t2code.opsecurity.command.CmdExecuter;
|
||||
import net.t2code.opsecurity.config.FileSelect;
|
||||
import net.t2code.opsecurity.config.config.Config;
|
||||
import net.t2code.opsecurity.config.config.Converter;
|
||||
import net.t2code.opsecurity.events.Events;
|
||||
import net.t2code.opsecurity.events.OpCommand;
|
||||
@@ -11,6 +12,7 @@ import net.t2code.opsecurity.check.Timer;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
||||
import net.t2code.t2codelib.SPIGOT.api.register.T2Cregister;
|
||||
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
|
||||
import org.checkerframework.checker.units.qual.C;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
@@ -39,7 +41,8 @@ public class Load {
|
||||
|
||||
Timer.refreshTimer();
|
||||
Permissions.register();
|
||||
T2CupdateAPI.onUpdateCheck(plugin, Util.getPrefix(), Util.getSpigotID(), Util.getDiscord());
|
||||
T2CupdateAPI.onUpdateCheck(plugin, Util.getPrefix(),Util.getGit(),Util.getSpigotID(),Util.getDiscord(), Config.updateCheckOnJoin.valueBoolean,
|
||||
Config.updateCheckSeePreReleaseUpdates.valueBoolean, Config.updateCheckTimeInterval.valueInt);
|
||||
Metrics.Bstats(plugin, Util.getBstatsID());
|
||||
T2Ctemplate.onLoadFooter(Util.getPrefix(), long_);
|
||||
}
|
||||
|
@@ -32,6 +32,20 @@ public final class Main extends JavaPlugin {
|
||||
autor = this.getDescription().getAuthors();
|
||||
version = this.getDescription().getVersion();
|
||||
if (pluginNotFound("T2CodeLib", 96388, Util.getRequiredT2CodeLibVersion())) return;
|
||||
load();
|
||||
|
||||
|
||||
}
|
||||
private static void load(){
|
||||
if (!Bukkit.getPluginManager().getPlugin("T2CodeLib").isEnabled()){
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
load();
|
||||
}
|
||||
},5L);
|
||||
return;
|
||||
}
|
||||
t2codeLib = true;
|
||||
Load.onLoad(plugin,autor,version);
|
||||
}
|
||||
|
@@ -6,9 +6,10 @@ api-version: 1.13
|
||||
load: STARTUP
|
||||
prefix: T2C-OPSecurity
|
||||
authors: [ JaTiTV ]
|
||||
|
||||
softdepend:
|
||||
- T2CodeLib
|
||||
- OPSecurity
|
||||
|
||||
commands:
|
||||
t2c-opsecurity:
|
||||
aliases: [opsec, opsecurity]
|
Reference in New Issue
Block a user