1
0
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:
502647092
2015-09-30 21:39:40 +08:00
parent a898be349c
commit d23eb1c154
4 changed files with 162 additions and 145 deletions

View File

@@ -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();

View File

@@ -213,39 +213,43 @@ public class ConfigManager {
@SuppressWarnings("deprecation")
private void load(final FileConfiguration config) {
defaultGroup = config.getString("Global.DefaultGroup", "default").toLowerCase();
adminsOnly = config.getBoolean("Global.AdminOnlyCommands", false);
useLeases = config.getBoolean("Global.UseLeaseSystem", false);
leaseAutoRenew = config.getBoolean("Global.LeaseAutoRenew", true);
enableEconomy = config.getBoolean("Global.EnableEconomy", false);
economySystem = config.getString("Global.EconomySystem", "iConomy");
infoToolId = config.getInt("Global.InfoToolId", Material.STRING.getId());
selectionToolId = config.getInt("Global.SelectionToolId", Material.WOOD_AXE.getId());
adminOps = config.getBoolean("Global.AdminOPs", true);
multiworldPlugin = config.getString("Global.MultiWorldPlugin");
enableRentSystem = config.getBoolean("Global.EnableRentSystem", false);
rentCheckInterval = config.getInt("Global.RentCheckInterval", 10);
leaseCheckInterval = config.getInt("Global.LeaseCheckInterval", 10);
autoSaveInt = config.getInt("Global.SaveInterval", 10);
flagsInherit = config.getBoolean("Global.ResidenceFlagsInherit", false);
minMoveUpdate = config.getInt("Global.MoveCheckInterval", 500);
chatEnable = config.getBoolean("Global.ResidenceChatEnable", true);
actionBar = config.getBoolean("Global.UseActionBar", true);
enforceAreaInsideArea = config.getBoolean("Global.EnforceAreaInsideArea", false);
language = config.getString("Global.Language", "English");
globalCreatorDefaults = FlagPermissions.parseFromConfigNode("CreatorDefault", config.getConfigurationSection("Global"));
globalResidenceDefaults = FlagPermissions.parseFromConfigNode("ResidenceDefault", config.getConfigurationSection("Global"));
preventBuildInRent = config.getBoolean("Global.PreventRentModify", true);
stopOnSaveError = config.getBoolean("Global.StopOnSaveFault", true);
legacyperms = config.getBoolean("Global.LegacyPermissions", false);
namefix = config.getString("Global.ResidenceNameRegex", "[^A-Za-z0-9\\u4e00-\\u9fa5\\-\\_]");// "[^a-zA-Z0-9\\-\\_]"
showIntervalMessages = config.getBoolean("Global.ShowIntervalMessages", false);
spoutEnable = config.getBoolean("Global.EnableSpout", false);
enableLeaseMoneyAccount = config.getBoolean("Global.EnableLeaseMoneyAccount", true);
enableDebug = config.getBoolean("Global.EnableDebug", false);
customContainers = config.getIntegerList("Global.CustomContainers");
customBothClick = config.getIntegerList("Global.CustomBothClick");
customRightClick = config.getIntegerList("Global.CustomRightClick");
try {
defaultGroup = config.getString("Global.DefaultGroup", "default").toLowerCase();
adminsOnly = config.getBoolean("Global.AdminOnlyCommands", false);
useLeases = config.getBoolean("Global.UseLeaseSystem", false);
leaseAutoRenew = config.getBoolean("Global.LeaseAutoRenew", true);
enableEconomy = config.getBoolean("Global.EnableEconomy", false);
economySystem = config.getString("Global.EconomySystem", "iConomy");
infoToolId = config.getInt("Global.InfoToolId", Material.STRING.getId());
selectionToolId = config.getInt("Global.SelectionToolId", Material.WOOD_AXE.getId());
adminOps = config.getBoolean("Global.AdminOPs", true);
multiworldPlugin = config.getString("Global.MultiWorldPlugin");
enableRentSystem = config.getBoolean("Global.EnableRentSystem", false);
rentCheckInterval = config.getInt("Global.RentCheckInterval", 10);
leaseCheckInterval = config.getInt("Global.LeaseCheckInterval", 10);
autoSaveInt = config.getInt("Global.SaveInterval", 10);
flagsInherit = config.getBoolean("Global.ResidenceFlagsInherit", false);
minMoveUpdate = config.getInt("Global.MoveCheckInterval", 500);
chatEnable = config.getBoolean("Global.ResidenceChatEnable", true);
actionBar = config.getBoolean("Global.UseActionBar", true);
enforceAreaInsideArea = config.getBoolean("Global.EnforceAreaInsideArea", false);
language = config.getString("Global.Language", "English");
globalCreatorDefaults = FlagPermissions.parseFromConfigNode("CreatorDefault", config.getConfigurationSection("Global"));
globalResidenceDefaults = FlagPermissions.parseFromConfigNode("ResidenceDefault", config.getConfigurationSection("Global"));
preventBuildInRent = config.getBoolean("Global.PreventRentModify", true);
stopOnSaveError = config.getBoolean("Global.StopOnSaveFault", true);
legacyperms = config.getBoolean("Global.LegacyPermissions", false);
namefix = config.getString("Global.ResidenceNameRegex", "[^A-Za-z0-9\\u4e00-\\u9fa5\\-\\_]");// "[^a-zA-Z0-9\\-\\_]"
showIntervalMessages = config.getBoolean("Global.ShowIntervalMessages", false);
spoutEnable = config.getBoolean("Global.EnableSpout", false);
enableLeaseMoneyAccount = config.getBoolean("Global.EnableLeaseMoneyAccount", true);
enableDebug = config.getBoolean("Global.EnableDebug", false);
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()) {

View File

@@ -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,15 +60,18 @@ 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);
}