mirror of
https://e.coding.net/circlecloud/Residence.git
synced 2025-11-24 21:46:16 +00:00
feat: 添加UUID数据转换
This commit is contained in:
8
pom.xml
8
pom.xml
@@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>pw.yumc</groupId>
|
||||
<artifactId>Residence</artifactId>
|
||||
<version>2.8.2.1</version>
|
||||
<version>2.8.2.2</version>
|
||||
<name>Residence</name>
|
||||
<description>重制版本的领地插件 - 喵♂呜</description>
|
||||
<build>
|
||||
@@ -60,9 +60,9 @@
|
||||
<properties>
|
||||
<update.description>&6更新预告!!! GUI菜单即将上线(&7菜单再等几天= =&6)...</update.description>
|
||||
<update.changes>
|
||||
&b2.8.2.0 - &c修复一个可能被熊孩子利用导致插件奔溃的BUG...;
|
||||
&b2.8.2.0 - &a修复与部分插件TP有冲突的问题...;
|
||||
&b2.8.1.9 - &e修复配置文件载入失败的问题...;
|
||||
&b2.8.2.2 - &e自动转换UUID版本Residence的数据(部分版本)...;
|
||||
&c修复上个版本命令失效的问题(库文件忘了更新了);
|
||||
&b2.8.2.1 - &c修复一个可能被熊孩子利用导致插件奔溃的BUG...;
|
||||
</update.changes>
|
||||
<env.GIT_COMMIT>Debug</env.GIT_COMMIT>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
||||
@@ -27,14 +27,8 @@ import pw.yumc.Residence.ResidenceMain;
|
||||
*/
|
||||
public class FlagPermissions {
|
||||
|
||||
public static enum FlagState {
|
||||
FALSE,
|
||||
INVALID,
|
||||
NEITHER,
|
||||
TRUE
|
||||
}
|
||||
|
||||
protected static ResidenceMain plugin;
|
||||
|
||||
protected static ArrayList<String> validAreaFlags = new ArrayList<String>();
|
||||
protected static HashMap<String, ArrayList<String>> validFlagGroups = new HashMap<String, ArrayList<String>>();
|
||||
protected static ArrayList<String> validFlags = new ArrayList<String>();
|
||||
@@ -43,15 +37,8 @@ public class FlagPermissions {
|
||||
protected Map<String, Boolean> cuboidFlags;
|
||||
protected Map<String, Map<String, Boolean>> groupFlags;
|
||||
protected FlagPermissions parent;
|
||||
|
||||
protected Map<String, Map<String, Boolean>> playerFlags;
|
||||
|
||||
public FlagPermissions() {
|
||||
cuboidFlags = Collections.synchronizedMap(new HashMap<String, Boolean>());
|
||||
playerFlags = Collections.synchronizedMap(new HashMap<String, Map<String, Boolean>>());
|
||||
groupFlags = Collections.synchronizedMap(new HashMap<String, Map<String, Boolean>>());
|
||||
}
|
||||
|
||||
public static void addFlag(String flag) {
|
||||
flag = flag.toLowerCase();
|
||||
if (!validFlags.contains(flag)) {
|
||||
@@ -284,12 +271,39 @@ public class FlagPermissions {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected static FlagPermissions load(final Map<String, Object> root, final FlagPermissions newperms) throws Exception {
|
||||
if (root.containsKey("LastKnownPlayerNames")) {
|
||||
final Map<String, String> uuids = (Map<String, String>) root.get("LastKnownPlayerNames");
|
||||
final Iterator<Entry<String, Map<String, Boolean>>> mpi = ((Map<String, Map<String, Boolean>>) root.get("PlayerFlags")).entrySet().iterator();
|
||||
final Map<String, Map<String, Boolean>> newperm = new LinkedHashMap<>();
|
||||
while (mpi.hasNext()) {
|
||||
final Entry<String, Map<String, Boolean>> pmap = mpi.next();
|
||||
newperm.put(uuids.get(pmap.getKey()), pmap.getValue());
|
||||
mpi.remove();
|
||||
}
|
||||
newperms.playerFlags = newperm;
|
||||
} else {
|
||||
newperms.playerFlags = (Map<String, Map<String, Boolean>>) root.get("PlayerFlags");
|
||||
}
|
||||
newperms.groupFlags = (Map<String, Map<String, Boolean>>) root.get("GroupFlags");
|
||||
newperms.cuboidFlags = (Map<String, Boolean>) root.get("AreaFlags");
|
||||
if (newperms.playerFlags == null) {
|
||||
throw new IllegalArgumentException("错误的PlayerFlags数据...");
|
||||
}
|
||||
if (newperms.groupFlags == null) {
|
||||
throw new IllegalArgumentException("错误的GroupFlags数据...");
|
||||
}
|
||||
if (newperms.cuboidFlags == null) {
|
||||
throw new IllegalArgumentException("错误的CuboidFlags数据...");
|
||||
}
|
||||
return newperms;
|
||||
}
|
||||
|
||||
public FlagPermissions() {
|
||||
cuboidFlags = Collections.synchronizedMap(new HashMap<String, Boolean>());
|
||||
playerFlags = Collections.synchronizedMap(new HashMap<String, Map<String, Boolean>>());
|
||||
groupFlags = Collections.synchronizedMap(new HashMap<String, Map<String, Boolean>>());
|
||||
}
|
||||
|
||||
public boolean checkValidFlag(final String flag, final boolean globalflag) {
|
||||
if (validFlags.contains(flag)) {
|
||||
return true;
|
||||
@@ -632,4 +646,11 @@ public class FlagPermissions {
|
||||
}
|
||||
return def;
|
||||
}
|
||||
|
||||
public static enum FlagState {
|
||||
FALSE,
|
||||
INVALID,
|
||||
NEITHER,
|
||||
TRUE
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,8 +40,9 @@ public class ResidencePermissions extends FlagPermissions {
|
||||
public static ResidencePermissions load(final ResidenceMain plugin, final ClaimedResidence res, final Map<String, Object> root) throws Exception {
|
||||
final ResidencePermissions newperms = new ResidencePermissions(plugin, res);
|
||||
newperms.owner = (String) root.get("Owner");
|
||||
if (newperms.owner == null) {
|
||||
if (root.containsKey("OwnerLastKnownName")) {
|
||||
newperms.owner = (String) root.get("OwnerLastKnownName");
|
||||
plugin.getLogger().info("自动转换 UUID " + root.get("OwnerUUID") + " => " + newperms.owner);
|
||||
}
|
||||
if (newperms.owner == null) {
|
||||
plugin.getLogger().warning("发现未知所有者的领地,转换为Server Land...");
|
||||
@@ -55,15 +56,6 @@ public class ResidencePermissions extends FlagPermissions {
|
||||
if (newperms.world == null) {
|
||||
throw new IllegalArgumentException("错误的World数据...");
|
||||
}
|
||||
if (newperms.playerFlags == null) {
|
||||
throw new IllegalArgumentException("错误的PlayerFlags数据...");
|
||||
}
|
||||
if (newperms.groupFlags == null) {
|
||||
throw new IllegalArgumentException("错误的GroupFlags数据...");
|
||||
}
|
||||
if (newperms.cuboidFlags == null) {
|
||||
throw new IllegalArgumentException("错误的CuboidFlags数据...");
|
||||
}
|
||||
newperms.fixNames();
|
||||
return newperms;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user