From 1d3214cbeeb11411e6bbd5d4d1e7db80efdbefcb Mon Sep 17 00:00:00 2001 From: ryanhamshire Date: Sun, 11 Jan 2015 15:06:03 -0800 Subject: [PATCH] Usability improvement for PvP worlds config. No more typing world names. Also easier to disable for all worlds if that's what you want to do. --- .../GriefPrevention/GriefPrevention.java | 36 +++++-------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java b/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java index 4973ecb..f7a8f27 100644 --- a/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java +++ b/src/me/ryanhamshire/GriefPrevention/GriefPrevention.java @@ -451,35 +451,12 @@ public class GriefPrevention extends JavaPlugin } } - //default for pvp worlds list - ArrayList defaultPvpWorldNames = new ArrayList(); - for(int i = 0; i < worlds.size(); i++) - { - World world = worlds.get(i); - if(world.getPVP()) - { - defaultPvpWorldNames.add(world.getName()); - } - } - - //get pvp world names from the config file - List pvpEnabledWorldNames = config.getStringList("GriefPrevention.PvP.Worlds"); - if(pvpEnabledWorldNames == null || pvpEnabledWorldNames.size() == 0) - { - pvpEnabledWorldNames = defaultPvpWorldNames; - } - - //validate that list + //pvp worlds list this.config_pvp_enabledWorlds = new ArrayList(); - for(int i = 0; i < pvpEnabledWorldNames.size(); i++) + for(World world : worlds) { - String worldName = pvpEnabledWorldNames.get(i); - World world = this.getServer().getWorld(worldName); - if(world == null) - { - AddLogEntry("Error: PvP Configuration: There's no world named \"" + worldName + "\". Please update your config.yml."); - } - else + boolean pvpWorld = config.getBoolean("GriefPrevention.PvP.RulesEnabledInWorld." + world.getName(), world.getPVP()); + if(pvpWorld) { this.config_pvp_enabledWorlds.add(world); } @@ -737,7 +714,10 @@ public class GriefPrevention extends JavaPlugin outConfig.set("GriefPrevention.Spam.AllowedIpAddresses", this.config_spam_allowedIpAddresses); outConfig.set("GriefPrevention.Spam.DeathMessageCooldownSeconds", this.config_spam_deathMessageCooldownSeconds); - outConfig.set("GriefPrevention.PvP.Worlds", pvpEnabledWorldNames); + for(World world : worlds) + { + outConfig.set("GriefPrevention.PvP.RulesEnabledInWorld." + world.getName(), this.config_pvp_enabledWorlds.contains(world)); + } outConfig.set("GriefPrevention.PvP.ProtectFreshSpawns", this.config_pvp_protectFreshSpawns); outConfig.set("GriefPrevention.PvP.PunishLogout", this.config_pvp_punishLogout); outConfig.set("GriefPrevention.PvP.CombatTimeoutSeconds", this.config_pvp_combatTimeoutSeconds);