Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
98fd0409fd | |||
a2bd88ac7c | |||
dba1e57b91 | |||
e14f91c584 | |||
1547c16093 |
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>net.t2code</groupId>
|
||||
<artifactId>T2C-OPSecurity</artifactId>
|
||||
<version>3.0.6</version>
|
||||
<version>3.1.0</version>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
|
@@ -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
|
||||
}
|
@@ -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,7 +89,7 @@ public class OpCheck {
|
||||
}
|
||||
|
||||
public static Boolean opWhitelist(Player player) {
|
||||
for (Map.Entry<String, PlayerObject> playerObject : PlayerCash.getOpHashMap().entrySet()) {
|
||||
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());
|
||||
|
@@ -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;
|
||||
@@ -54,9 +54,9 @@ public class PermissionCheck {
|
||||
}
|
||||
}
|
||||
|
||||
private static Boolean permWhitelist(Player player) {
|
||||
public static Boolean permWhitelist(Player player) {
|
||||
|
||||
for (Map.Entry<String, PlayerObject> playerObject : PlayerCash.getPermissionHashMap().entrySet()) {
|
||||
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() );
|
||||
|
@@ -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;
|
||||
@@ -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()) {
|
||||
@@ -144,7 +144,7 @@ public class FileSelect {
|
||||
PlayerObject playerObject = new PlayerObject(
|
||||
name,
|
||||
yamlConfiguration.getString(value.pathPlayerUuid.replace("KEY", key)).replace("-", ""));
|
||||
PlayerCash.getOpHashMap().put(name, playerObject);
|
||||
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()) {
|
||||
@@ -197,7 +197,7 @@ public class FileSelect {
|
||||
PlayerObject playerObject = new PlayerObject(
|
||||
name,
|
||||
yamlConfiguration.getString(value.pathPlayerUuid.replace("KEY", key)).replace("-", ""));
|
||||
PlayerCash.getPermissionHashMap().put(name, playerObject);
|
||||
PlayerCache.getPermissionHashMap().put(name, playerObject);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@ public enum Config {
|
||||
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),
|
||||
|
@@ -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,10 +1,9 @@
|
||||
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;
|
||||
@@ -79,7 +78,7 @@ public class OpCommand implements Listener {
|
||||
}
|
||||
|
||||
private static Boolean opWhitelist(String playerName, String playerUuid) {
|
||||
for (Map.Entry<String, PlayerObject> playerObject : PlayerCash.getOpHashMap().entrySet()) {
|
||||
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 );
|
||||
|
@@ -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
|
@@ -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