3.1.0 | add API
This commit is contained in:
parent
dba1e57b91
commit
a2bd88ac7c
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>net.t2code</groupId>
|
||||
<artifactId>T2C-OPSecurity</artifactId>
|
||||
<version>3.0.7</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
|
||||
}
|
@ -54,7 +54,7 @@ public class PermissionCheck {
|
||||
}
|
||||
}
|
||||
|
||||
private static Boolean permWhitelist(Player player) {
|
||||
public static Boolean permWhitelist(Player player) {
|
||||
|
||||
for (Map.Entry<String, PlayerObject> playerObject : PlayerCache.getPermissionHashMap().entrySet()) {
|
||||
T2Csend.debug(Main.getPlugin(), "--------- " + player.getName());
|
||||
|
Loading…
Reference in New Issue
Block a user