mirror of
https://e.coding.net/circlecloud/Residence.git
synced 2025-11-24 21:46:16 +00:00
add config load tip and format config file...
Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
@@ -343,8 +343,8 @@ public class ResidenceMain extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
taskmanager.cancelall();
|
||||
if (this.init) {
|
||||
taskmanager.cancelall();
|
||||
try {
|
||||
this.saveYml();
|
||||
this.backup.backup();
|
||||
|
||||
@@ -213,6 +213,7 @@ public class ConfigManager {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void load(final FileConfiguration config) {
|
||||
try {
|
||||
defaultGroup = config.getString("Global.DefaultGroup", "default").toLowerCase();
|
||||
adminsOnly = config.getBoolean("Global.AdminOnlyCommands", false);
|
||||
useLeases = config.getBoolean("Global.UseLeaseSystem", false);
|
||||
@@ -246,6 +247,9 @@ public class ConfigManager {
|
||||
customContainers = config.getIntegerList("Global.CustomContainers");
|
||||
customBothClick = config.getIntegerList("Global.CustomBothClick");
|
||||
customRightClick = config.getIntegerList("Global.CustomRightClick");
|
||||
} catch (final Exception e) {
|
||||
throw new RuntimeException("领地配置文件载入错误...", e);
|
||||
}
|
||||
final ConfigurationSection node = config.getConfigurationSection("Global.GroupDefault");
|
||||
|
||||
if (!plugin.is1_8()) {
|
||||
|
||||
@@ -46,11 +46,13 @@ public class WorldFlagManager {
|
||||
public FlagPermissions getPerms(String world) {
|
||||
world = world.toLowerCase();
|
||||
final FlagPermissions list = worldperms.get(world);
|
||||
if (list == null)
|
||||
if (globaldefaults == null)
|
||||
if (list == null) {
|
||||
if (globaldefaults == null) {
|
||||
return new FlagPermissions();
|
||||
else
|
||||
} else {
|
||||
return globaldefaults;
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -58,16 +60,19 @@ public class WorldFlagManager {
|
||||
world = world.toLowerCase();
|
||||
group = group.toLowerCase();
|
||||
final Map<String, FlagPermissions> groupworldperms = groupperms.get(group);
|
||||
if (groupworldperms == null)
|
||||
if (groupworldperms == null) {
|
||||
return this.getPerms(world);
|
||||
}
|
||||
FlagPermissions list = groupworldperms.get(world);
|
||||
if (list == null) {
|
||||
list = groupworldperms.get("global." + world);
|
||||
if (list == null)
|
||||
if (list == null) {
|
||||
list = groupworldperms.get("global");
|
||||
if (list == null)
|
||||
}
|
||||
if (list == null) {
|
||||
return this.getPerms(world);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -75,16 +80,20 @@ public class WorldFlagManager {
|
||||
try {
|
||||
|
||||
Set<String> keys = config.getConfigurationSection("Global.Flags").getKeys(false);
|
||||
if (keys != null)
|
||||
for (final String key : keys)
|
||||
if (key.equalsIgnoreCase("Global"))
|
||||
if (keys != null) {
|
||||
for (final String key : keys) {
|
||||
if (key.equalsIgnoreCase("Global")) {
|
||||
globaldefaults = FlagPermissions.parseFromConfigNode(key, config.getConfigurationSection("Global.Flags"));
|
||||
else
|
||||
} else {
|
||||
worldperms.put(key.toLowerCase(), FlagPermissions.parseFromConfigNode(key, config.getConfigurationSection("Global.Flags")));
|
||||
for (final Entry<String, FlagPermissions> entry : worldperms.entrySet())
|
||||
}
|
||||
}
|
||||
}
|
||||
for (final Entry<String, FlagPermissions> entry : worldperms.entrySet()) {
|
||||
entry.getValue().setParent(globaldefaults);
|
||||
}
|
||||
keys = config.getConfigurationSection("Groups").getKeys(false);
|
||||
if (keys != null)
|
||||
if (keys != null) {
|
||||
for (final String key : keys) {
|
||||
final ConfigurationSection worldkeylist = config.getConfigurationSection("Groups." + key + ".Flags.World");
|
||||
if (worldkeylist != null) {
|
||||
@@ -101,24 +110,28 @@ public class WorldFlagManager {
|
||||
list.setParent(worldperm.getValue());
|
||||
perms.put("global." + worldperm.getKey().toLowerCase(), list);
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
perms.put(wkey.toLowerCase(), list);
|
||||
}
|
||||
}
|
||||
for (final Entry<String, FlagPermissions> entry : perms.entrySet()) {
|
||||
final String wkey = entry.getKey();
|
||||
final FlagPermissions list = entry.getValue();
|
||||
if (!wkey.startsWith("global.")) {
|
||||
list.setParent(perms.get("global." + wkey));
|
||||
if (list.getParent() == null)
|
||||
if (list.getParent() == null) {
|
||||
list.setParent(worldperms.get(wkey));
|
||||
if (list.getParent() == null)
|
||||
}
|
||||
if (list.getParent() == null) {
|
||||
list.setParent(globaldefaults);
|
||||
}
|
||||
}
|
||||
}
|
||||
groupperms.put(key.toLowerCase(), perms);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (final Exception ex) {
|
||||
Logger.getLogger(WorldFlagManager.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
||||
@@ -250,7 +250,7 @@ Groups:
|
||||
#玩家是否可以改变领地进出提示.
|
||||
CanChange: true
|
||||
# 这个文本是当前用户组新建领地后的默认进入信息.
|
||||
# 消息留空将禁用.
|
||||
# 消息留空将禁用信息.
|
||||
DefaultEnter: '欢迎 %player 来到 %owner 的领地 %residence.'
|
||||
# 这个文本是当前用户组新建领地后的默认离开信息.
|
||||
# 消息留空将禁用信息.
|
||||
@@ -301,7 +301,7 @@ Groups:
|
||||
#default: #组名
|
||||
#build: false
|
||||
# 这些Flag将应用于这个组, 当他们在领地之外时将会被使用.
|
||||
# 这些Flag将会覆盖上面的Flag, 均为全局选?钕?
|
||||
# 这些Flag将会覆盖上面的Flag, 均为全局选项.
|
||||
World:
|
||||
Global: # 这些Flag将会应用于所有世界.
|
||||
#build: false
|
||||
|
||||
Reference in New Issue
Block a user