From 21783ef9d4f7ab17fc12aa05f40be6c83291b7e4 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Sun, 23 Oct 2011 22:08:57 +0200 Subject: [PATCH] Woop --- plugin.yml | 14 -- src/com/massivecraft/factions/Board.java | 4 +- src/com/massivecraft/factions/Conf.java | 48 ++-- src/com/massivecraft/factions/FPlayer.java | 71 +----- src/com/massivecraft/factions/Faction.java | 37 +-- .../massivecraft/factions/cmd/CmdBoom.java | 44 ---- .../massivecraft/factions/cmd/CmdHelp.java | 6 +- .../massivecraft/factions/cmd/CmdHome.java | 3 +- .../factions/cmd/CmdPeaceful.java | 63 ------ .../factions/cmd/CmdRelationTruce.java | 4 +- .../factions/cmd/CmdSafeunclaimall.java | 41 ---- .../massivecraft/factions/cmd/CmdShow.java | 4 +- .../massivecraft/factions/cmd/CmdUnclaim.java | 81 ------- .../factions/cmd/CmdWarunclaimall.java | 41 ---- .../massivecraft/factions/cmd/FCmdRoot.java | 10 +- .../factions/cmd/FRelationCommand.java | 5 +- .../factions/integration/SpoutFeatures.java | 2 +- .../listeners/FactionsBlockListener.java | 54 ----- .../listeners/FactionsEntityListener.java | 210 +++++------------- .../listeners/FactionsPlayerListener.java | 69 +----- .../factions/struct/FactionFlag.java | 8 +- .../factions/struct/Permission.java | 2 - src/com/massivecraft/factions/struct/Rel.java | 27 ++- .../factions/util/RelationUtil.java | 13 +- 24 files changed, 149 insertions(+), 712 deletions(-) delete mode 100644 src/com/massivecraft/factions/cmd/CmdBoom.java delete mode 100644 src/com/massivecraft/factions/cmd/CmdPeaceful.java delete mode 100644 src/com/massivecraft/factions/cmd/CmdSafeunclaimall.java delete mode 100644 src/com/massivecraft/factions/cmd/CmdWarunclaimall.java diff --git a/plugin.yml b/plugin.yml index adca604f..159b5d48 100644 --- a/plugin.yml +++ b/plugin.yml @@ -25,16 +25,12 @@ permissions: children: factions.kit.halfmod: true factions.disband.any: true - factions.setpermanent: true - factions.setpeaceful: true factions.sethome.any: true factions.money.*: true factions.kit.halfmod: description: Zones, bypassing, and kicking children: factions.kit.fullplayer: true - factions.managesafezone: true - factions.managewarzone: true factions.bypass: true factions.flag.any: true factions.kick.any: true @@ -124,10 +120,6 @@ permissions: description: see a list of the factions factions.lock: description: lock all write stuff - factions.managesafezone: - description: claim land as a safe zone and build/destroy within safe zones - factions.managewarzone: - description: claim land as a war zone and build/destroy within war zones factions.map: description: show the territory map, and set optional auto update factions.officer: @@ -167,8 +159,6 @@ permissions: factions.money.f2f: true factions.money.f2p: true factions.money.p2f: true - factions.noboom: - description: toggle explosions (peaceful factions only) factions.open: description: switch if invitation is required to join factions.owner: @@ -177,10 +167,6 @@ permissions: description: list owner(s) of this claimed land factions.ownershipbypass: description: bypass ownership restrictions within own faction's territory - factions.setpeaceful: - description: designate a faction as peaceful - factions.setpermanent: - description: designate a faction as permanent factions.power: description: show player power info factions.power.any: diff --git a/src/com/massivecraft/factions/Board.java b/src/com/massivecraft/factions/Board.java index 339a3f43..feba9ea7 100644 --- a/src/com/massivecraft/factions/Board.java +++ b/src/com/massivecraft/factions/Board.java @@ -218,14 +218,14 @@ public class Board { row += ChatColor.GRAY+"-"; } - else if (factionHere.isSafeZone()) + /*else if (factionHere.isSafeZone()) { row += Conf.colorPeaceful+"+"; } else if (factionHere.isWarZone()) { row += ChatColor.DARK_RED+"+"; - } + }*/ else if ( factionHere == faction diff --git a/src/com/massivecraft/factions/Conf.java b/src/com/massivecraft/factions/Conf.java index 691d6ce1..0f4a6335 100644 --- a/src/com/massivecraft/factions/Conf.java +++ b/src/com/massivecraft/factions/Conf.java @@ -15,11 +15,12 @@ public class Conf // Colors public static ChatColor colorMember = ChatColor.GREEN; public static ChatColor colorAlly = ChatColor.LIGHT_PURPLE; + public static ChatColor colorTruce = ChatColor.GOLD; public static ChatColor colorNeutral = ChatColor.WHITE; public static ChatColor colorEnemy = ChatColor.RED; - public static ChatColor colorPeaceful = ChatColor.GOLD; - public static ChatColor colorWar = ChatColor.DARK_RED; + //public static ChatColor colorPeaceful = ChatColor.GOLD; + //public static ChatColor colorWar = ChatColor.DARK_RED; //public static ChatColor colorWilderness = ChatColor.DARK_GREEN; @@ -143,6 +144,12 @@ public class Conf public static boolean territoryAllyPainBuildWhenOffline = false; public static boolean territoryAllyDenyUseage = true; public static boolean territoryAllyProtectMaterials = true; + public static boolean territoryTruceDenyBuild = true; + public static boolean territoryTruceDenyBuildWhenOffline = true; + public static boolean territoryTrucePainBuild = false; + public static boolean territoryTrucePainBuildWhenOffline = false; + public static boolean territoryTruceDenyUseage = true; + public static boolean territoryTruceProtectMaterials = true; public static boolean territoryBlockCreepers = false; public static boolean territoryBlockCreepersWhenOffline = false; public static boolean territoryBlockFireballs = false; @@ -152,7 +159,7 @@ public class Conf public static boolean territoryDenyEndermanBlocks = true; public static boolean territoryDenyEndermanBlocksWhenOffline = true; - public static boolean safeZoneDenyBuild = true; + /*public static boolean safeZoneDenyBuild = true; public static boolean safeZoneDenyUseage = true; public static boolean safeZoneBlockTNT = true; public static boolean safeZonePreventAllDamageToPlayers = false; @@ -166,14 +173,15 @@ public class Conf public static boolean warZonePowerLoss = true; public static boolean warZoneFriendlyFire = false; public static boolean warZoneDenyEndermanBlocks = true; + */ - public static boolean wildernessDenyBuild = false; + /*public static boolean wildernessDenyBuild = false; public static boolean wildernessDenyUseage = false; public static boolean wildernessBlockCreepers = false; public static boolean wildernessBlockFireballs = false; public static boolean wildernessBlockTNT = false; public static boolean wildernessPowerLoss = true; - public static boolean wildernessDenyEndermanBlocks = false; + public static boolean wildernessDenyEndermanBlocks = false;*/ // for claimed areas where further faction-member ownership can be defined public static boolean ownedAreasEnabled = true; @@ -198,6 +206,7 @@ public class Conf public static Set territoryProtectedMaterialsWhenOffline = EnumSet.noneOf(Material.class); public static Set territoryDenyUseageMaterialsWhenOffline = EnumSet.noneOf(Material.class); + // TODO: Rename to monsterCreatureTypes public static transient Set safeZoneNerfedCreatureTypes = EnumSet.noneOf(CreatureType.class); // Spout features @@ -257,6 +266,7 @@ public class Conf public static Set worldsNoClaiming = new HashSet(); public static Set worldsNoPowerLoss = new HashSet(); public static Set worldsIgnorePvP = new HashSet(); + // TODO: A better solution Would be to have One wilderness faction per world. public static Set worldsNoWildernessProtection = new HashSet(); public static transient int mapHeight = 8; @@ -268,30 +278,12 @@ public class Conf baseCommandAliases.add("f"); factionFlagDefaults = new LinkedHashMap(); - factionFlagDefaults.put(FactionFlag.PERMANENT, FactionFlag.PERMANENT.defaultDefaultValue); - factionFlagDefaults.put(FactionFlag.PEACEFUL, FactionFlag.PEACEFUL.defaultDefaultValue); - factionFlagDefaults.put(FactionFlag.INFPOWER, FactionFlag.INFPOWER.defaultDefaultValue); - factionFlagDefaults.put(FactionFlag.POWERLOSS, FactionFlag.POWERLOSS.defaultDefaultValue); - factionFlagDefaults.put(FactionFlag.PVP, FactionFlag.PVP.defaultDefaultValue); - factionFlagDefaults.put(FactionFlag.FRIENDLYFIRE, FactionFlag.FRIENDLYFIRE.defaultDefaultValue); - factionFlagDefaults.put(FactionFlag.MONSTERS, FactionFlag.MONSTERS.defaultDefaultValue); - factionFlagDefaults.put(FactionFlag.EXPLOSIONS, FactionFlag.EXPLOSIONS.defaultDefaultValue); - factionFlagDefaults.put(FactionFlag.FIRESPREAD, FactionFlag.FIRESPREAD.defaultDefaultValue); - factionFlagDefaults.put(FactionFlag.LIGHTNING, FactionFlag.LIGHTNING.defaultDefaultValue); - factionFlagDefaults.put(FactionFlag.ENDERGRIEF, FactionFlag.ENDERGRIEF.defaultDefaultValue); - factionFlagIsChangeable = new LinkedHashMap(); - factionFlagIsChangeable.put(FactionFlag.PERMANENT, FactionFlag.PERMANENT.defaultDefaultChangeable); - factionFlagIsChangeable.put(FactionFlag.PEACEFUL, FactionFlag.PEACEFUL.defaultDefaultChangeable); - factionFlagIsChangeable.put(FactionFlag.INFPOWER, FactionFlag.INFPOWER.defaultDefaultChangeable); - factionFlagIsChangeable.put(FactionFlag.POWERLOSS, FactionFlag.POWERLOSS.defaultDefaultChangeable); - factionFlagIsChangeable.put(FactionFlag.PVP, FactionFlag.PVP.defaultDefaultChangeable); - factionFlagIsChangeable.put(FactionFlag.FRIENDLYFIRE, FactionFlag.FRIENDLYFIRE.defaultDefaultChangeable); - factionFlagIsChangeable.put(FactionFlag.MONSTERS, FactionFlag.MONSTERS.defaultDefaultChangeable); - factionFlagIsChangeable.put(FactionFlag.EXPLOSIONS, FactionFlag.EXPLOSIONS.defaultDefaultChangeable); - factionFlagIsChangeable.put(FactionFlag.FIRESPREAD, FactionFlag.FIRESPREAD.defaultDefaultChangeable); - factionFlagIsChangeable.put(FactionFlag.LIGHTNING, FactionFlag.LIGHTNING.defaultDefaultChangeable); - factionFlagIsChangeable.put(FactionFlag.ENDERGRIEF, FactionFlag.ENDERGRIEF.defaultDefaultChangeable); + for (FactionFlag flag : FactionFlag.values()) + { + factionFlagDefaults.put(flag, flag.defaultDefaultValue); + factionFlagIsChangeable.put(flag, flag.defaultDefaultChangeable); + } territoryEnemyDenyCommands.add("home"); territoryEnemyDenyCommands.add("sethome"); diff --git a/src/com/massivecraft/factions/FPlayer.java b/src/com/massivecraft/factions/FPlayer.java index 78a63abe..d0dae7ee 100644 --- a/src/com/massivecraft/factions/FPlayer.java +++ b/src/com/massivecraft/factions/FPlayer.java @@ -15,7 +15,6 @@ import com.massivecraft.factions.integration.SpoutFeatures; import com.massivecraft.factions.integration.Worldguard; import com.massivecraft.factions.struct.ChatMode; import com.massivecraft.factions.struct.FactionFlag; -import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Rel; import com.massivecraft.factions.util.RelationUtil; import com.massivecraft.factions.zcore.persist.PlayerEntity; @@ -78,40 +77,8 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator public void setAutoClaimFor(Faction faction) { this.autoClaimFor = faction; - if (this.autoClaimFor != null) - { - // TODO: merge these into same autoclaim - this.autoSafeZoneEnabled = false; - this.autoWarZoneEnabled = false; - } } - - // FIELD: autoSafeZoneEnabled - private transient boolean autoSafeZoneEnabled; - public boolean isAutoSafeClaimEnabled() { return autoSafeZoneEnabled; } - public void setIsAutoSafeClaimEnabled(boolean enabled) - { - this.autoSafeZoneEnabled = enabled; - if (enabled) - { - this.autoClaimFor = null; - this.autoWarZoneEnabled = false; - } - } - - // FIELD: autoWarZoneEnabled - private transient boolean autoWarZoneEnabled; - public boolean isAutoWarClaimEnabled() { return autoWarZoneEnabled; } - public void setIsAutoWarClaimEnabled(boolean enabled) - { - this.autoWarZoneEnabled = enabled; - if (enabled) - { - this.autoClaimFor = null; - this.autoSafeZoneEnabled = false; - } - } - + private transient boolean isAdminBypassing = false; public boolean isAdminBypassing() { return this.isAdminBypassing; } public void setIsAdminBypassing(boolean val) { this.isAdminBypassing = val; } @@ -154,8 +121,6 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator this.lastLoginTime = System.currentTimeMillis(); this.mapAutoUpdating = false; this.autoClaimFor = null; - this.autoSafeZoneEnabled = false; - this.autoWarZoneEnabled = false; this.loginPvpDisabled = (Conf.noPVPDamageToOthersForXSecondsAfterLogin > 0) ? true : false; this.deleteMe = false; @@ -653,14 +618,6 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator { return true; } - else if (forFaction.isSafeZone() && Permission.MANAGE_SAFE_ZONE.has(getPlayer())) - { - return true; - } - else if (forFaction.isWarZone() && Permission.MANAGE_WAR_ZONE.has(getPlayer())) - { - return true; - } else if (myFaction != forFaction) { error = P.p.txt.parse("You can't claim land for %s.", forFaction.describeTo(this)); @@ -677,21 +634,13 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator { error = P.p.txt.parse("Factions must have at least %s members to claim land.", Conf.claimsRequireMinFactionMembers); } - else if (currentFaction.isSafeZone()) - { - error = P.p.txt.parse("You can not claim a Safe Zone."); - } - else if (currentFaction.isWarZone()) - { - error = P.p.txt.parse("You can not claim a War Zone."); - } else if (ownedLand >= forFaction.getPowerRounded()) { error = P.p.txt.parse("You can't claim more land! You need more power!"); } - else if (currentFaction.getRelationTo(forFaction) == Rel.ALLY) + else if (currentFaction.getRelationTo(forFaction).isAtLeast(Rel.TRUCE)) { - error = P.p.txt.parse("You can't claim the land of your allies."); + error = P.p.txt.parse("You can't claim this land due to your relation with the current owner."); } else if ( @@ -709,15 +658,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator } else if (currentFaction.isNormal()) { - if (myFaction.isPeaceful()) - { - error = P.p.txt.parse("%s owns this land. Your faction is peaceful, so you cannot claim land from other factions.", currentFaction.getTag(this)); - } - else if (currentFaction.isPeaceful()) - { - error = P.p.txt.parse("%s owns this land, and is a peaceful faction. You cannot claim land from them.", currentFaction.getTag(this)); - } - else if ( ! currentFaction.hasLandInflation()) + if ( ! currentFaction.hasLandInflation()) { // TODO more messages WARN current faction most importantly error = P.p.txt.parse("%s owns this land and is strong enough to keep it.", currentFaction.getTag(this)); @@ -748,7 +689,9 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator if ( ! this.canClaimForFactionAtLocation(forFaction, location, notifyFailure)) return false; // if economy is enabled and they're not on the bypass list, make 'em pay - if (Econ.shouldBeUsed() && ! this.isAdminBypassing() && ! forFaction.isSafeZone() && ! forFaction.isWarZone()) + // TODO: Add flag no costs?? + //if (Econ.shouldBeUsed() && ! this.isAdminBypassing() && ! forFaction.isSafeZone() && ! forFaction.isWarZone()) + if (Econ.shouldBeUsed() && ! this.isAdminBypassing()) { double cost = Econ.calculateClaimCost(ownedLand, currentFaction.isNormal()); //String costString = Econ.moneyString(cost); diff --git a/src/com/massivecraft/factions/Faction.java b/src/com/massivecraft/factions/Faction.java index 153188d3..aeadefc3 100644 --- a/src/com/massivecraft/factions/Faction.java +++ b/src/com/massivecraft/factions/Faction.java @@ -41,16 +41,16 @@ public class Faction extends Entity implements EconomyParticipator // FIELD: peaceful // "peaceful" status can only be set by server admins/moderators/ops, and prevents PvP and land capture to/from the faction - private boolean peaceful; - public boolean isPeaceful() { return this.peaceful; } - public void setPeaceful(boolean isPeaceful) { this.peaceful = isPeaceful; } + //private boolean peaceful; + //public boolean isPeaceful() { return this.peaceful; } + //public void setPeaceful(boolean isPeaceful) { this.peaceful = isPeaceful; } // FIELD: peacefulExplosionsEnabled - private boolean peacefulExplosionsEnabled; - public void setPeacefulExplosionsEnabled(boolean val) { peacefulExplosionsEnabled = val; } - public boolean getPeacefulExplosionsEnabled(){ return this.peacefulExplosionsEnabled; } + //private boolean peacefulExplosionsEnabled; + //public void setPeacefulExplosionsEnabled(boolean val) { peacefulExplosionsEnabled = val; } + //public boolean getPeacefulExplosionsEnabled(){ return this.peacefulExplosionsEnabled; } - public boolean noExplosionsInTerritory() { return this.peaceful && ! peacefulExplosionsEnabled; } + //public boolean noExplosionsInTerritory() { return this.peaceful && ! peacefulExplosionsEnabled; } // FIELD: permanent // "permanent" status can only be set by server admins/moderators/ops, and allows the faction to remain even with 0 members @@ -163,8 +163,8 @@ public class Faction extends Entity implements EconomyParticipator this.tag = "???"; this.description = "Default faction description :("; this.lastPlayerLoggedOffTime = 0; - this.peaceful = false; - this.peacefulExplosionsEnabled = false; + //this.peaceful = false; + //this.peacefulExplosionsEnabled = false; this.money = 0.0; this.flagOverrides = new LinkedHashMap(); } @@ -173,9 +173,9 @@ public class Faction extends Entity implements EconomyParticipator // Extra Getters And Setters // -------------------------------------------- // - public boolean noPvPInTerritory() { return isSafeZone() || (peaceful && Conf.peacefulTerritoryDisablePVP); } + //public boolean noPvPInTerritory() { return isSafeZone() || (peaceful && Conf.peacefulTerritoryDisablePVP); } - public boolean noMonstersInTerritory() { return isSafeZone() || (peaceful && Conf.peacefulTerritoryDisableMonsters); } + //public boolean noMonstersInTerritory() { return isSafeZone() || (peaceful && Conf.peacefulTerritoryDisableMonsters); } @@ -187,7 +187,8 @@ public class Faction extends Entity implements EconomyParticipator public boolean isNormal() { - return ! (this.isNone() || this.isSafeZone() || this.isWarZone()); + //return ! (this.isNone() || this.isSafeZone() || this.isWarZone()); + return ! this.isNone(); } public boolean isNone() @@ -195,7 +196,7 @@ public class Faction extends Entity implements EconomyParticipator return this.getId().equals("0"); } - public boolean isSafeZone() + /*public boolean isSafeZone() { return this.getId().equals("-1"); } @@ -208,7 +209,7 @@ public class Faction extends Entity implements EconomyParticipator public boolean isPlayerFreeType() { return this.isSafeZone() || this.isWarZone(); - } + }*/ // ------------------------------- @@ -338,7 +339,7 @@ public class Faction extends Entity implements EconomyParticipator public ArrayList getFPlayers() { ArrayList ret = new ArrayList(); - if (this.isPlayerFreeType()) return ret; + //if (this.isPlayerFreeType()) return ret; for (FPlayer fplayer : FPlayers.i.get()) { @@ -354,7 +355,7 @@ public class Faction extends Entity implements EconomyParticipator public ArrayList getFPlayersWhereOnline(boolean online) { ArrayList ret = new ArrayList(); - if (this.isPlayerFreeType()) return ret; + //if (this.isPlayerFreeType()) return ret; for (FPlayer fplayer : FPlayers.i.get()) { @@ -400,7 +401,7 @@ public class Faction extends Entity implements EconomyParticipator public ArrayList getOnlinePlayers() { ArrayList ret = new ArrayList(); - if (this.isPlayerFreeType()) return ret; + //if (this.isPlayerFreeType()) return ret; for (Player player: P.p.getServer().getOnlinePlayers()) { @@ -418,7 +419,7 @@ public class Faction extends Entity implements EconomyParticipator public boolean hasPlayersOnline() { // only real factions can have players online, not safe zone / war zone - if (this.isPlayerFreeType()) return false; + //if (this.isPlayerFreeType()) return false; for (Player player: P.p.getServer().getOnlinePlayers()) { diff --git a/src/com/massivecraft/factions/cmd/CmdBoom.java b/src/com/massivecraft/factions/cmd/CmdBoom.java deleted file mode 100644 index 8775ded2..00000000 --- a/src/com/massivecraft/factions/cmd/CmdBoom.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.massivecraft.factions.cmd; - -import com.massivecraft.factions.Conf; -import com.massivecraft.factions.struct.Permission; - -public class CmdBoom extends FCommand -{ - public CmdBoom() - { - super(); - this.aliases.add("noboom"); - - //this.requiredArgs.add(""); - this.optionalArgs.put("on/off", "flip"); - - this.permission = Permission.NO_BOOM.node; - this.disableOnLock = true; - - senderMustBePlayer = true; - senderMustBeMember = false; - senderMustBeOfficer = true; - senderMustBeLeader = false; - } - - @Override - public void perform() - { - if ( ! myFaction.isPeaceful()) - { - fme.msg("This command is only usable by factions which are specially designated as peaceful."); - return; - } - - // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay - if ( ! payForCommand(Conf.econCostNoBoom, "to toggle explosions", "for toggling explosions")) return; - - myFaction.setPeacefulExplosionsEnabled(this.argAsBool(0, ! myFaction.getPeacefulExplosionsEnabled())); - - String enabled = myFaction.noExplosionsInTerritory() ? "disabled" : "enabled"; - - // Inform - myFaction.msg("%s has "+enabled+" explosions in your faction's territory.", fme.describeTo(myFaction)); - } -} diff --git a/src/com/massivecraft/factions/cmd/CmdHelp.java b/src/com/massivecraft/factions/cmd/CmdHelp.java index 40b1eaa2..1c28aed3 100644 --- a/src/com/massivecraft/factions/cmd/CmdHelp.java +++ b/src/com/massivecraft/factions/cmd/CmdHelp.java @@ -113,7 +113,6 @@ public class CmdHelp extends FCommand pageLines = new ArrayList(); pageLines.add( p.cmdBase.cmdMap.getUseageTemplate(true) ); - pageLines.add( p.cmdBase.cmdBoom.getUseageTemplate(true) ); pageLines.add( p.cmdBase.cmdOwner.getUseageTemplate(true) ); pageLines.add( p.cmdBase.cmdOwnerList.getUseageTemplate(true) ); pageLines.add(p.txt.parse("Claimed land with ownership set is further protected so")); @@ -125,6 +124,7 @@ public class CmdHelp extends FCommand pageLines.add( p.cmdBase.cmdDisband.getUseageTemplate(true) ); pageLines.add(""); pageLines.add( p.cmdBase.cmdRelationAlly.getUseageTemplate(true) ); + pageLines.add( p.cmdBase.cmdRelationTruce.getUseageTemplate(true) ); pageLines.add( p.cmdBase.cmdRelationNeutral.getUseageTemplate(true) ); pageLines.add( p.cmdBase.cmdRelationEnemy.getUseageTemplate(true) ); pageLines.add(p.txt.parse("Set the relation you WISH to have with another faction.")); @@ -163,15 +163,11 @@ public class CmdHelp extends FCommand pageLines.add(p.txt.parse("/f claim safezone claim land for the Safe Zone")); pageLines.add(p.txt.parse("/f claim warzone claim land for the War Zone")); pageLines.add(p.txt.parse("/f autoclaim [safezone|warzone] take a guess")); - pageLines.add( p.cmdBase.cmdSafeunclaimall.getUseageTemplate(true) ); - pageLines.add( p.cmdBase.cmdWarunclaimall.getUseageTemplate(true) ); pageLines.add(p.txt.parse("Note: " + p.cmdBase.cmdUnclaim.getUseageTemplate(false) + P.p.txt.parse("") + " works on safe/war zones as well.")); - pageLines.add( p.cmdBase.cmdPeaceful.getUseageTemplate(true) ); helpPages.add(pageLines); pageLines = new ArrayList(); pageLines.add(p.txt.parse("More commands for server admins:")); - pageLines.add( p.cmdBase.cmdPeaceful.getUseageTemplate(true) ); pageLines.add(p.txt.parse("Peaceful factions are protected from PvP and land capture.")); pageLines.add( p.cmdBase.cmdLock.getUseageTemplate(true) ); pageLines.add( p.cmdBase.cmdReload.getUseageTemplate(true) ); diff --git a/src/com/massivecraft/factions/cmd/CmdHome.java b/src/com/massivecraft/factions/cmd/CmdHome.java index bb688f57..0db42cf7 100644 --- a/src/com/massivecraft/factions/cmd/CmdHome.java +++ b/src/com/massivecraft/factions/cmd/CmdHome.java @@ -13,6 +13,7 @@ import com.massivecraft.factions.FLocation; import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.Faction; +import com.massivecraft.factions.struct.FactionFlag; import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Rel; import com.massivecraft.factions.zcore.util.SmokeUtil; @@ -79,7 +80,7 @@ public class CmdHome extends FCommand ( Conf.homesTeleportAllowedEnemyDistance > 0 && - ! faction.isSafeZone() + faction.getFlag(FactionFlag.PVP) && ( ! fme.isInOwnTerritory() diff --git a/src/com/massivecraft/factions/cmd/CmdPeaceful.java b/src/com/massivecraft/factions/cmd/CmdPeaceful.java deleted file mode 100644 index eb7ba39e..00000000 --- a/src/com/massivecraft/factions/cmd/CmdPeaceful.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.massivecraft.factions.cmd; - -import com.massivecraft.factions.FPlayers; -import com.massivecraft.factions.Faction; -import com.massivecraft.factions.FPlayer; -import com.massivecraft.factions.integration.SpoutFeatures; -import com.massivecraft.factions.struct.Permission; - -public class CmdPeaceful extends FCommand -{ - - public CmdPeaceful() - { - super(); - this.aliases.add("peaceful"); - - this.requiredArgs.add("faction tag"); - //this.optionalArgs.put("", ""); - - this.permission = Permission.SET_PEACEFUL.node; - this.disableOnLock = true; - - senderMustBePlayer = false; - senderMustBeMember = false; - senderMustBeOfficer = false; - senderMustBeLeader = false; - } - - @Override - public void perform() - { - Faction faction = this.argAsFaction(0); - if (faction == null) return; - - String change; - if (faction.isPeaceful()) - { - change = "removed peaceful status from"; - faction.setPeaceful(false); - } - else - { - change = "granted peaceful status to"; - faction.setPeaceful(true); - } - - // Inform all players - for (FPlayer fplayer : FPlayers.i.getOnline()) - { - if (fplayer.getFaction() == faction) - { - fplayer.msg((fme == null ? "A server admin" : fme.describeTo(fplayer, true))+" has "+change+" your faction."); - } - else - { - fplayer.msg((fme == null ? "A server admin" : fme.describeTo(fplayer, true))+" has "+change+" the faction \"" + faction.getTag(fplayer) + "\"."); - } - } - - SpoutFeatures.updateAppearances(faction); - } - -} diff --git a/src/com/massivecraft/factions/cmd/CmdRelationTruce.java b/src/com/massivecraft/factions/cmd/CmdRelationTruce.java index f43cf908..de58d4eb 100644 --- a/src/com/massivecraft/factions/cmd/CmdRelationTruce.java +++ b/src/com/massivecraft/factions/cmd/CmdRelationTruce.java @@ -6,7 +6,7 @@ public class CmdRelationTruce extends FRelationCommand { public CmdRelationTruce() { - aliases.add("neutral"); - targetRelation = Rel.NEUTRAL; + aliases.add("truce"); + targetRelation = Rel.TRUCE; } } diff --git a/src/com/massivecraft/factions/cmd/CmdSafeunclaimall.java b/src/com/massivecraft/factions/cmd/CmdSafeunclaimall.java deleted file mode 100644 index 9f1b8992..00000000 --- a/src/com/massivecraft/factions/cmd/CmdSafeunclaimall.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.massivecraft.factions.cmd; - -import com.massivecraft.factions.Board; -import com.massivecraft.factions.Conf; -import com.massivecraft.factions.Factions; -import com.massivecraft.factions.P; -import com.massivecraft.factions.struct.Permission; - -public class CmdSafeunclaimall extends FCommand -{ - - public CmdSafeunclaimall() - { - this.aliases.add("safeunclaimall"); - this.aliases.add("safedeclaimall"); - - //this.requiredArgs.add(""); - //this.optionalArgs.put("radius", "0"); - - this.permission = Permission.MANAGE_SAFE_ZONE.node; - this.disableOnLock = true; - - senderMustBePlayer = false; - senderMustBeMember = false; - senderMustBeOfficer = false; - senderMustBeLeader = false; - - this.setHelpShort("Unclaim all safezone land"); - } - - @Override - public void perform() - { - Board.unclaimAll(Factions.i.getSafeZone().getId()); - msg("You unclaimed ALL safe zone land."); - - if (Conf.logLandUnclaims) - P.p.log(fme.getName()+" unclaimed all safe zones."); - } - -} diff --git a/src/com/massivecraft/factions/cmd/CmdShow.java b/src/com/massivecraft/factions/cmd/CmdShow.java index fa7d64b5..898abe9d 100644 --- a/src/com/massivecraft/factions/cmd/CmdShow.java +++ b/src/com/massivecraft/factions/cmd/CmdShow.java @@ -56,9 +56,9 @@ public class CmdShow extends FCommand } String peaceStatus = ""; - if (faction.isPeaceful()) + if (faction.getFlag(FactionFlag.PEACEFUL)) { - peaceStatus = " "+Conf.colorNeutral+"This faction is Peaceful"; + peaceStatus = " "+Conf.colorTruce+"This faction is Peaceful"; } msg("Joining: "+(faction.getOpen() ? "no invitation is needed" : "invitation is required")+peaceStatus); diff --git a/src/com/massivecraft/factions/cmd/CmdUnclaim.java b/src/com/massivecraft/factions/cmd/CmdUnclaim.java index 110d87e0..037e7c5d 100644 --- a/src/com/massivecraft/factions/cmd/CmdUnclaim.java +++ b/src/com/massivecraft/factions/cmd/CmdUnclaim.java @@ -35,41 +35,6 @@ public class CmdUnclaim extends FCommand FLocation flocation = new FLocation(fme); Faction otherFaction = Board.getFactionAt(flocation); - if (otherFaction.isSafeZone()) - { - if (Permission.MANAGE_SAFE_ZONE.has(sender)) - { - Board.removeAt(flocation); - SpoutFeatures.updateTerritoryDisplayLoc(flocation); - msg("Safe zone was unclaimed."); - - if (Conf.logLandUnclaims) - P.p.log(fme.getName()+" unclaimed land at ("+flocation.getCoordString()+") from the faction: "+otherFaction.getTag()); - } - else - { - msg("This is a safe zone. You lack permissions to unclaim."); - } - return; - } - else if (otherFaction.isWarZone()) - { - if (Permission.MANAGE_WAR_ZONE.has(sender)) - { - Board.removeAt(flocation); - SpoutFeatures.updateTerritoryDisplayLoc(flocation); - msg("War zone was unclaimed."); - - if (Conf.logLandUnclaims) - P.p.log(fme.getName()+" unclaimed land at ("+flocation.getCoordString()+") from the faction: "+otherFaction.getTag()); - } - else - { - msg("This is a war zone. You lack permissions to unclaim."); - } - return; - } - if (fme.isAdminBypassing()) { Board.removeAt(flocation); @@ -114,52 +79,6 @@ public class CmdUnclaim extends FCommand { if ( ! Econ.modifyMoney(fme , refund, "to unclaim this land", "for unclaiming this land")) return; } - - /* - // a real refund - if (refund > 0.0) - { - if(Conf.bankFactionPaysLandCosts) - { - Faction faction = myFaction; - faction.addMoney(refund); - moneyBack = " "+faction.getTag()+" received a refund of "+Econ.moneyString(refund)+"."; - } - else - { - Econ.addMoney(fme.getName(), refund); - moneyBack = " They received a refund of "+Econ.moneyString(refund)+"."; - } - } - // wait, you're charging people to unclaim land? outrageous - else if (refund < 0.0) - { - if(Conf.bankFactionPaysLandCosts) - { - Faction faction = myFaction; - if(!faction.removeMoney(-refund)) - { - msg("Unclaiming this land will cost %s which your faction can't currently afford.", Econ.moneyString(-refund)); - return; - } - moneyBack = " It cost "+faction.getTag()+" "+Econ.moneyString(refund)+"."; - } - else - { - if (!Econ.deductMoney(fme.getName(), -refund)) - { - msg("Unclaiming this land will cost %s which you can't currently afford.", Econ.moneyString(-refund)); - return; - } - moneyBack = " It cost them "+Econ.moneyString(refund)+"."; - } - } - // no refund - else - { - moneyBack = ""; - } - */ } Board.removeAt(flocation); diff --git a/src/com/massivecraft/factions/cmd/CmdWarunclaimall.java b/src/com/massivecraft/factions/cmd/CmdWarunclaimall.java deleted file mode 100644 index f80690ef..00000000 --- a/src/com/massivecraft/factions/cmd/CmdWarunclaimall.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.massivecraft.factions.cmd; - -import com.massivecraft.factions.Board; -import com.massivecraft.factions.Conf; -import com.massivecraft.factions.Factions; -import com.massivecraft.factions.P; -import com.massivecraft.factions.struct.Permission; - -public class CmdWarunclaimall extends FCommand -{ - - public CmdWarunclaimall() - { - this.aliases.add("warunclaimall"); - this.aliases.add("wardeclaimall"); - - //this.requiredArgs.add(""); - //this.optionalArgs.put("", ""); - - this.permission = Permission.MANAGE_WAR_ZONE.node; - this.disableOnLock = true; - - senderMustBePlayer = false; - senderMustBeMember = false; - senderMustBeOfficer = false; - senderMustBeLeader = false; - - this.setHelpShort("unclaim all warzone land"); - } - - @Override - public void perform() - { - Board.unclaimAll(Factions.i.getWarZone().getId()); - msg("You unclaimed ALL war zone land."); - - if (Conf.logLandUnclaims) - P.p.log(fme.getName()+" unclaimed all war zones."); - } - -} diff --git a/src/com/massivecraft/factions/cmd/FCmdRoot.java b/src/com/massivecraft/factions/cmd/FCmdRoot.java index add68149..883b0ad2 100644 --- a/src/com/massivecraft/factions/cmd/FCmdRoot.java +++ b/src/com/massivecraft/factions/cmd/FCmdRoot.java @@ -8,7 +8,6 @@ public class FCmdRoot extends FCommand { public CmdLeader cmdLeader = new CmdLeader(); public CmdAutoClaim cmdAutoClaim = new CmdAutoClaim(); - public CmdBoom cmdBoom = new CmdBoom(); public CmdBypass cmdBypass = new CmdBypass(); public CmdChat cmdChat = new CmdChat(); public CmdClaim cmdClaim = new CmdClaim(); @@ -32,13 +31,12 @@ public class FCmdRoot extends FCommand public CmdOpen cmdOpen = new CmdOpen(); public CmdOwner cmdOwner = new CmdOwner(); public CmdOwnerList cmdOwnerList = new CmdOwnerList(); - public CmdPeaceful cmdPeaceful = new CmdPeaceful(); public CmdPower cmdPower = new CmdPower(); public CmdRelationAlly cmdRelationAlly = new CmdRelationAlly(); public CmdRelationEnemy cmdRelationEnemy = new CmdRelationEnemy(); public CmdRelationNeutral cmdRelationNeutral = new CmdRelationNeutral(); + public CmdRelationTruce cmdRelationTruce = new CmdRelationTruce(); public CmdReload cmdReload = new CmdReload(); - public CmdSafeunclaimall cmdSafeunclaimall = new CmdSafeunclaimall(); public CmdSaveAll cmdSaveAll = new CmdSaveAll(); public CmdSethome cmdSethome = new CmdSethome(); public CmdShow cmdShow = new CmdShow(); @@ -47,7 +45,6 @@ public class FCmdRoot extends FCommand public CmdUnclaim cmdUnclaim = new CmdUnclaim(); public CmdUnclaimall cmdUnclaimall = new CmdUnclaimall(); public CmdVersion cmdVersion = new CmdVersion(); - public CmdWarunclaimall cmdWarunclaimall = new CmdWarunclaimall(); public FCmdRoot() { @@ -73,7 +70,6 @@ public class FCmdRoot extends FCommand this.addSubCommand(this.cmdLeader); this.addSubCommand(this.cmdAutoClaim); - this.addSubCommand(this.cmdBoom); this.addSubCommand(this.cmdBypass); this.addSubCommand(this.cmdChat); this.addSubCommand(this.cmdClaim); @@ -97,13 +93,12 @@ public class FCmdRoot extends FCommand this.addSubCommand(this.cmdOpen); this.addSubCommand(this.cmdOwner); this.addSubCommand(this.cmdOwnerList); - this.addSubCommand(this.cmdPeaceful); this.addSubCommand(this.cmdPower); this.addSubCommand(this.cmdRelationAlly); this.addSubCommand(this.cmdRelationEnemy); this.addSubCommand(this.cmdRelationNeutral); + this.addSubCommand(this.cmdRelationTruce); this.addSubCommand(this.cmdReload); - this.addSubCommand(this.cmdSafeunclaimall); this.addSubCommand(this.cmdSaveAll); this.addSubCommand(this.cmdSethome); this.addSubCommand(this.cmdShow); @@ -112,7 +107,6 @@ public class FCmdRoot extends FCommand this.addSubCommand(this.cmdUnclaim); this.addSubCommand(this.cmdUnclaimall); this.addSubCommand(this.cmdVersion); - this.addSubCommand(this.cmdWarunclaimall); } @Override diff --git a/src/com/massivecraft/factions/cmd/FRelationCommand.java b/src/com/massivecraft/factions/cmd/FRelationCommand.java index fd850868..b08ac9b8 100644 --- a/src/com/massivecraft/factions/cmd/FRelationCommand.java +++ b/src/com/massivecraft/factions/cmd/FRelationCommand.java @@ -5,6 +5,7 @@ import org.bukkit.ChatColor; import com.massivecraft.factions.Conf; import com.massivecraft.factions.Faction; import com.massivecraft.factions.integration.SpoutFeatures; +import com.massivecraft.factions.struct.FactionFlag; import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Rel; @@ -63,13 +64,13 @@ public abstract class FRelationCommand extends FCommand myFaction.msg(currentRelationColor+them.getTag()+" were informed that you wish to be "+targetRelation.getColor()+targetRelation); } - if ( targetRelation != Rel.NEUTRAL && them.isPeaceful()) + if ( targetRelation != Rel.NEUTRAL && them.getFlag(FactionFlag.PEACEFUL)) { them.msg("This will have no effect while your faction is peaceful."); myFaction.msg("This will have no effect while their faction is peaceful."); } - if ( targetRelation != Rel.NEUTRAL && myFaction.isPeaceful()) + if ( targetRelation != Rel.NEUTRAL && myFaction.getFlag(FactionFlag.PEACEFUL)) { them.msg("This will have no effect while their faction is peaceful."); myFaction.msg("This will have no effect while your faction is peaceful."); diff --git a/src/com/massivecraft/factions/integration/SpoutFeatures.java b/src/com/massivecraft/factions/integration/SpoutFeatures.java index 607e9a29..9e87d433 100644 --- a/src/com/massivecraft/factions/integration/SpoutFeatures.java +++ b/src/com/massivecraft/factions/integration/SpoutFeatures.java @@ -267,7 +267,7 @@ public class SpoutFeatures { // yeah, no cape if no faction } - else if (viewedFaction.isPeaceful()) + else if (relation == Rel.TRUCE) cape = Conf.capePeaceful; else if (relation == Rel.NEUTRAL) cape = Conf.capeNeutral; diff --git a/src/com/massivecraft/factions/listeners/FactionsBlockListener.java b/src/com/massivecraft/factions/listeners/FactionsBlockListener.java index e6997976..d5b570a2 100644 --- a/src/com/massivecraft/factions/listeners/FactionsBlockListener.java +++ b/src/com/massivecraft/factions/listeners/FactionsBlockListener.java @@ -18,7 +18,6 @@ import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.Faction; import com.massivecraft.factions.P; -import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Rel; @@ -129,28 +128,6 @@ public class FactionsBlockListener extends BlockListener if (pistonFaction == otherFaction) return true; - if (otherFaction.isNone()) - { - if (!Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(target.getWorld().getName())) - return true; - - return false; - } - else if (otherFaction.isSafeZone()) - { - if ( ! Conf.safeZoneDenyBuild) - return true; - - return false; - } - else if (otherFaction.isWarZone()) - { - if ( ! Conf.warZoneDenyBuild) - return true; - - return false; - } - Rel rel = pistonFaction.getRelationTo(otherFaction); if (rel.confDenyBuild(otherFaction.hasPlayersOnline())) @@ -169,37 +146,6 @@ public class FactionsBlockListener extends BlockListener FLocation loc = new FLocation(location); Faction otherFaction = Board.getFactionAt(loc); - if (otherFaction.isNone()) - { - if (!Conf.wildernessDenyBuild || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName())) - return true; // This is not faction territory. Use whatever you like here. - - if (!justCheck) - me.msg("You can't "+action+" in the wilderness."); - - return false; - } - else if (otherFaction.isSafeZone()) - { - if (!Conf.safeZoneDenyBuild || Permission.MANAGE_SAFE_ZONE.has(player)) - return true; - - if (!justCheck) - me.msg("You can't "+action+" in a safe zone."); - - return false; - } - else if (otherFaction.isWarZone()) - { - if (!Conf.warZoneDenyBuild || Permission.MANAGE_WAR_ZONE.has(player)) - return true; - - if (!justCheck) - me.msg("You can't "+action+" in a war zone."); - - return false; - } - Faction myFaction = me.getFaction(); Rel rel = myFaction.getRelationTo(otherFaction); boolean online = otherFaction.hasPlayersOnline(); diff --git a/src/com/massivecraft/factions/listeners/FactionsEntityListener.java b/src/com/massivecraft/factions/listeners/FactionsEntityListener.java index ddbdecb2..84e427b7 100644 --- a/src/com/massivecraft/factions/listeners/FactionsEntityListener.java +++ b/src/com/massivecraft/factions/listeners/FactionsEntityListener.java @@ -3,9 +3,7 @@ package com.massivecraft.factions.listeners; import java.text.MessageFormat; import org.bukkit.Location; -import org.bukkit.entity.Creeper; import org.bukkit.entity.Entity; -import org.bukkit.entity.Fireball; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; import org.bukkit.event.entity.CreatureSpawnEvent; @@ -28,6 +26,7 @@ import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.Faction; import com.massivecraft.factions.P; +import com.massivecraft.factions.struct.FactionFlag; import com.massivecraft.factions.struct.Rel; import com.massivecraft.factions.util.MiscUtil; @@ -44,42 +43,24 @@ public class FactionsEntityListener extends EntityListener public void onEntityDeath(EntityDeathEvent event) { Entity entity = event.getEntity(); - if ( ! (entity instanceof Player)) - { - return; - } - + if ( ! (entity instanceof Player)) return; + Player player = (Player) entity; FPlayer fplayer = FPlayers.i.get(player); Faction faction = Board.getFactionAt(new FLocation(player.getLocation())); - if (faction.isWarZone()) + + if ( ! faction.getFlag(FactionFlag.POWERLOSS)) { - // war zones always override worldsNoPowerLoss either way, thus this layout - if (! Conf.warZonePowerLoss) - { - fplayer.msg("You didn't lose any power since you were in a war zone."); - return; - } - if (Conf.worldsNoPowerLoss.contains(player.getWorld().getName())) - { - fplayer.msg("The world you are in has power loss normally disabled, but you still lost power since you were in a war zone."); - } - } - else if (faction.isNone() && !Conf.wildernessPowerLoss && !Conf.worldsNoWildernessProtection.contains(player.getWorld().getName())) - { - fplayer.msg("You didn't lose any power since you were in the wilderness."); + fplayer.msg("You didn't lose any power since the territory you died in works that way."); return; } - else if (Conf.worldsNoPowerLoss.contains(player.getWorld().getName())) + + if (Conf.worldsNoPowerLoss.contains(player.getWorld().getName())) { fplayer.msg("You didn't lose any power due to the world you died in."); return; } - else if (Conf.peacefulMembersDisablePowerLoss && fplayer.hasFaction() && fplayer.getFaction().isPeaceful()) - { - fplayer.msg("You didn't lose any power since you are in a peaceful faction."); - return; - } + fplayer.onDeath(); fplayer.msg("Your power is now "+fplayer.getPowerRounded()+" / "+fplayer.getPowerMaxRounded()); } @@ -103,11 +84,12 @@ public class FactionsEntityListener extends EntityListener event.setCancelled(true); } } - else if (Conf.safeZonePreventAllDamageToPlayers && isPlayerInSafeZone(event.getEntity())) + // TODO: Add a no damage at all flag?? + /*else if (Conf.safeZonePreventAllDamageToPlayers && isPlayerInSafeZone(event.getEntity())) { // Players can not take any damage in a Safe Zone event.setCancelled(true); - } + }*/ } @Override @@ -119,87 +101,14 @@ public class FactionsEntityListener extends EntityListener Faction faction = Board.getFactionAt(new FLocation(loc)); - if (faction.noExplosionsInTerritory()) + if (faction.getFlag(FactionFlag.EXPLOSIONS) == false) { // faction is peaceful and has explosions set to disabled event.setCancelled(true); return; } - - boolean online = faction.hasPlayersOnline(); - - if - ( - event.getEntity() instanceof Creeper - && - ( - (faction.isNone() && Conf.wildernessBlockCreepers && !Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName())) - || - (faction.isNormal() && (online ? Conf.territoryBlockCreepers : Conf.territoryBlockCreepersWhenOffline)) - || - (faction.isWarZone() && Conf.warZoneBlockCreepers) - || - faction.isSafeZone() - ) - ) - { - // creeper which needs prevention - event.setCancelled(true); - } - else if - ( - event.getEntity() instanceof Fireball - && - ( - (faction.isNone() && Conf.wildernessBlockFireballs && !Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName())) - || - (faction.isNormal() && (online ? Conf.territoryBlockFireballs : Conf.territoryBlockFireballsWhenOffline)) - || - (faction.isWarZone() && Conf.warZoneBlockFireballs) - || - faction.isSafeZone() - ) - ) - { - // ghast fireball which needs prevention - event.setCancelled(true); - } - else if - ( - ( - faction.isNone() - && - Conf.wildernessBlockTNT - && - ! Conf.worldsNoWildernessProtection.contains(loc.getWorld().getName()) - ) - || - ( - faction.isNormal() - && - ( - online ? Conf.territoryBlockTNT : Conf.territoryBlockTNTWhenOffline - ) - ) - || - ( - faction.isWarZone() - && - Conf.warZoneBlockTNT - ) - || - ( - faction.isSafeZone() - && - Conf.safeZoneBlockTNT - ) - ) - { - // we'll assume it's TNT, which needs prevention - event.setCancelled(true); - } } - +/* public boolean isPlayerInSafeZone(Entity damagee) { if ( ! (damagee instanceof Player)) @@ -212,7 +121,7 @@ public class FactionsEntityListener extends EntityListener } return false; } - +*/ public boolean canDamagerHurtDamagee(EntityDamageByEntityEvent sub) { Entity damager = sub.getDamager(); @@ -247,14 +156,16 @@ public class FactionsEntityListener extends EntityListener } // Players can not take attack damage in a SafeZone, or possibly peaceful territory - if (defLocFaction.noPvPInTerritory()) { + + if (defLocFaction.getFlag(FactionFlag.PVP) == false) + { if (damager instanceof Player) { FPlayer attacker = FPlayers.i.get((Player)damager); - attacker.msg("You can't hurt other players in "+(defLocFaction.isSafeZone() ? "a SafeZone." : "peaceful territory.")); + attacker.msg("You can't hurt other players here."); return false; } - return !defLocFaction.noMonstersInTerritory(); + return defLocFaction.getFlag(FactionFlag.MONSTERS); } if ( ! (damager instanceof Player)) @@ -278,15 +189,11 @@ public class FactionsEntityListener extends EntityListener Faction locFaction = Board.getFactionAt(new FLocation(attacker)); // so we know from above that the defender isn't in a safezone... what about the attacker, sneaky dog that he might be? - if (locFaction.noPvPInTerritory()) + if (locFaction.getFlag(FactionFlag.PVP) == false) { - attacker.msg("You can't hurt other players while you are in "+(locFaction.isSafeZone() ? "a SafeZone." : "peaceful territory.")); + attacker.msg("You can't hurt other players here."); return false; } - else if (locFaction.isWarZone() && Conf.warZoneFriendlyFire) - { - return true; - } Faction defendFaction = defender.getFaction(); Faction attackFaction = attacker.getFaction(); @@ -310,17 +217,6 @@ public class FactionsEntityListener extends EntityListener } } - if (defendFaction.isPeaceful()) - { - attacker.msg("You can't hurt players who are in a peaceful faction."); - return false; - } - else if (attackFaction.isPeaceful()) - { - attacker.msg("You can't hurt players while you are in a peaceful faction."); - return false; - } - Rel relation = defendFaction.getRelationTo(attackFaction); // You can not hurt neutral factions @@ -370,15 +266,16 @@ public class FactionsEntityListener extends EntityListener @Override public void onCreatureSpawn(CreatureSpawnEvent event) { - if (event.isCancelled() || event.getLocation() == null) - { - return; - } + if (event.isCancelled()) return; + if (event.getLocation() == null) return; - if (Conf.safeZoneNerfedCreatureTypes.contains(event.getCreatureType()) && Board.getFactionAt(new FLocation(event.getLocation())).noMonstersInTerritory()) - { - event.setCancelled(true); - } + FLocation floc = new FLocation(event.getLocation()); + Faction faction = Board.getFactionAt(floc); + + if (faction.getFlag(FactionFlag.MONSTERS)) return; + if ( ! Conf.safeZoneNerfedCreatureTypes.contains(event.getCreatureType())) return; + + event.setCancelled(true); } @Override @@ -388,22 +285,17 @@ public class FactionsEntityListener extends EntityListener // if there is a target Entity target = event.getTarget(); - if (target == null) - { - return; - } + if (target == null) return; // We are interested in blocking targeting for certain mobs: - if ( ! Conf.safeZoneNerfedCreatureTypes.contains(MiscUtil.creatureTypeFromEntity(event.getEntity()))) - { - return; - } + if ( ! Conf.safeZoneNerfedCreatureTypes.contains(MiscUtil.creatureTypeFromEntity(event.getEntity()))) return; - // in case the target is in a safe zone. - if (Board.getFactionAt(new FLocation(target.getLocation())).noMonstersInTerritory()) - { - event.setCancelled(true); - } + FLocation floc = new FLocation(target.getLocation()); + Faction faction = Board.getFactionAt(floc); + + if (faction.getFlag(FactionFlag.MONSTERS)) return; + + event.setCancelled(true); } @Override @@ -444,10 +336,12 @@ public class FactionsEntityListener extends EntityListener { if (event.isCancelled()) return; - if (stopEndermanBlockManipulation(event.getBlock().getLocation())) - { - event.setCancelled(true); - } + FLocation floc = new FLocation(event.getBlock()); + Faction faction = Board.getFactionAt(floc); + + if (faction.getFlag(FactionFlag.ENDERGRIEF)) return; + + event.setCancelled(true); } @Override @@ -455,13 +349,15 @@ public class FactionsEntityListener extends EntityListener { if (event.isCancelled()) return; - if (stopEndermanBlockManipulation(event.getLocation())) - { - event.setCancelled(true); - } + FLocation floc = new FLocation(event.getLocation()); + Faction faction = Board.getFactionAt(floc); + + if (faction.getFlag(FactionFlag.ENDERGRIEF)) return; + + event.setCancelled(true); } - private boolean stopEndermanBlockManipulation(Location loc) + /*private boolean stopEndermanBlockManipulation(Location loc) { if (loc == null) { @@ -505,5 +401,5 @@ public class FactionsEntityListener extends EntityListener } return false; - } + }*/ } diff --git a/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java index f2a9f5c3..34e1b616 100644 --- a/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -28,10 +28,8 @@ import com.massivecraft.factions.FLocation; import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.Faction; -import com.massivecraft.factions.Factions; import com.massivecraft.factions.P; import com.massivecraft.factions.integration.SpoutFeatures; -import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Rel; import com.massivecraft.factions.zcore.util.TextUtil; @@ -257,40 +255,6 @@ public class FactionsPlayerListener extends PlayerListener { me.attemptClaim(me.getAutoClaimFor(), player.getLocation(), true); } - else if (me.isAutoSafeClaimEnabled()) - { - if ( ! Permission.MANAGE_SAFE_ZONE.has(player)) - { - me.setIsAutoSafeClaimEnabled(false); - } - else - { - FLocation playerFlocation = new FLocation(me); - - if (!Board.getFactionAt(playerFlocation).isSafeZone()) - { - Board.setFactionAt(Factions.i.getSafeZone(), playerFlocation); - me.msg("This land is now a safe zone."); - } - } - } - else if (me.isAutoWarClaimEnabled()) - { - if ( ! Permission.MANAGE_WAR_ZONE.has(player)) - { - me.setIsAutoWarClaimEnabled(false); - } - else - { - FLocation playerFlocation = new FLocation(me); - - if (!Board.getFactionAt(playerFlocation).isWarZone()) - { - Board.setFactionAt(Factions.i.getWarZone(), playerFlocation); - me.msg("This land is now a war zone."); - } - } - } } @Override @@ -324,6 +288,8 @@ public class FactionsPlayerListener extends PlayerListener } } + + // TODO: Improve with the... system for... Permissions public static boolean playerCanUseItemHere(Player player, Location location, Material material, boolean justCheck) { FPlayer me = FPlayers.i.get(player); @@ -344,37 +310,6 @@ public class FactionsPlayerListener extends PlayerListener return true; // Item isn't one we're preventing for offline factions. } - if (otherFaction.isNone()) - { - if (!Conf.wildernessDenyUseage || Conf.worldsNoWildernessProtection.contains(location.getWorld().getName())) - return true; // This is not faction territory. Use whatever you like here. - - if (!justCheck) - me.msg("You can't use %s in the wilderness.", TextUtil.getMaterialName(material)); - - return false; - } - else if (otherFaction.isSafeZone()) - { - if (!Conf.safeZoneDenyUseage || Permission.MANAGE_SAFE_ZONE.has(player)) - return true; - - if (!justCheck) - me.msg("You can't use %s in a safe zone.", TextUtil.getMaterialName(material)); - - return false; - } - else if (otherFaction.isWarZone()) - { - if (!Conf.warZoneDenyUseage || Permission.MANAGE_WAR_ZONE.has(player)) - return true; - - if (!justCheck) - me.msg("You can't use %s in a war zone.", TextUtil.getMaterialName(material)); - - return false; - } - Faction myFaction = me.getFaction(); Rel rel = myFaction.getRelationTo(otherFaction); diff --git a/src/com/massivecraft/factions/struct/FactionFlag.java b/src/com/massivecraft/factions/struct/FactionFlag.java index 453e4576..4bf59a77 100644 --- a/src/com/massivecraft/factions/struct/FactionFlag.java +++ b/src/com/massivecraft/factions/struct/FactionFlag.java @@ -56,7 +56,9 @@ public enum FactionFlag */ public boolean getDefault() { - return Conf.factionFlagDefaults.get(this); + Boolean ret = Conf.factionFlagDefaults.get(this); + if (ret == null) return this.defaultDefaultValue; + return ret; } /** @@ -66,7 +68,9 @@ public enum FactionFlag */ public boolean isChangeable() { - return Conf.factionFlagIsChangeable.get(this); + Boolean ret = Conf.factionFlagIsChangeable.get(this); + if (ret == null) return this.defaultDefaultChangeable; + return ret; } public static FactionFlag parse(String str) diff --git a/src/com/massivecraft/factions/struct/Permission.java b/src/com/massivecraft/factions/struct/Permission.java index 66c36f61..a4df4210 100644 --- a/src/com/massivecraft/factions/struct/Permission.java +++ b/src/com/massivecraft/factions/struct/Permission.java @@ -6,8 +6,6 @@ import com.massivecraft.factions.P; public enum Permission { - MANAGE_SAFE_ZONE("managesafezone"), - MANAGE_WAR_ZONE("managewarzone"), OWNERSHIP_BYPASS("ownershipbypass"), LEADER("leader"), AUTOCLAIM("autoclaim"), diff --git a/src/com/massivecraft/factions/struct/Rel.java b/src/com/massivecraft/factions/struct/Rel.java index ae8aea1f..e82c9a69 100644 --- a/src/com/massivecraft/factions/struct/Rel.java +++ b/src/com/massivecraft/factions/struct/Rel.java @@ -6,13 +6,13 @@ import com.massivecraft.factions.Conf; public enum Rel { - LEADER (70, "leader"), - OFFICER(60, "officer"), - MEMBER (50, "member"), - ALLY (40, "ally"), - TRUCE (30, "truce"), - NEUTRAL(20, "neutral"), - ENEMY (10, "enemy"), + LEADER (70, "leader"), + OFFICER (60, "officer"), + MEMBER (50, "member"), + ALLY (40, "ally"), + TRUCE (30, "truce"), + NEUTRAL (20, "neutral"), + ENEMY (10, "enemy"), ; public final int value; @@ -87,6 +87,8 @@ public enum Rel return Conf.colorAlly; else if (this == NEUTRAL) return Conf.colorNeutral; + else if (this == TRUCE) + return Conf.colorTruce; else return Conf.colorEnemy; } @@ -107,6 +109,7 @@ public enum Rel } // TODO: ADD TRUCE!!!! + // TODO.... or remove it... public double getRelationCost() { if (this == ENEMY) @@ -129,6 +132,8 @@ public enum Rel return Conf.territoryEnemyDenyBuild; else if (this == ALLY) return Conf.territoryAllyDenyBuild; + else if (this == TRUCE) + return Conf.territoryTruceDenyBuild; else return Conf.territoryDenyBuild; } @@ -138,6 +143,8 @@ public enum Rel return Conf.territoryEnemyDenyBuildWhenOffline; else if (this == ALLY) return Conf.territoryAllyDenyBuildWhenOffline; + else if (this == TRUCE) + return Conf.territoryTruceDenyBuildWhenOffline; else return Conf.territoryDenyBuildWhenOffline; } @@ -155,6 +162,8 @@ public enum Rel return Conf.territoryEnemyPainBuild; else if (this == ALLY) return Conf.territoryAllyPainBuild; + else if (this == TRUCE) + return Conf.territoryTrucePainBuild; else return Conf.territoryPainBuild; } @@ -164,6 +173,8 @@ public enum Rel return Conf.territoryEnemyPainBuildWhenOffline; else if (this == ALLY) return Conf.territoryAllyPainBuildWhenOffline; + else if (this == TRUCE) + return Conf.territoryTrucePainBuildWhenOffline; else return Conf.territoryPainBuildWhenOffline; } @@ -178,6 +189,8 @@ public enum Rel return Conf.territoryEnemyDenyUseage; else if (this == ALLY) return Conf.territoryAllyDenyUseage; + else if (this == TRUCE) + return Conf.territoryTruceDenyUseage; else return Conf.territoryDenyUseage; } diff --git a/src/com/massivecraft/factions/util/RelationUtil.java b/src/com/massivecraft/factions/util/RelationUtil.java index 746acfd5..7c0f9f49 100644 --- a/src/com/massivecraft/factions/util/RelationUtil.java +++ b/src/com/massivecraft/factions/util/RelationUtil.java @@ -2,10 +2,10 @@ package com.massivecraft.factions.util; import org.bukkit.ChatColor; -import com.massivecraft.factions.Conf; import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.Faction; import com.massivecraft.factions.iface.RelationParticipator; +import com.massivecraft.factions.struct.FactionFlag; import com.massivecraft.factions.struct.Rel; import com.massivecraft.factions.zcore.util.TextUtil; @@ -90,9 +90,9 @@ public class RelationUtil return Rel.MEMBER; } - if (!ignorePeaceful && (fme.isPeaceful() || fthat.isPeaceful())) + if (!ignorePeaceful && (fme.getFlag(FactionFlag.PEACEFUL) || fthat.getFlag(FactionFlag.PEACEFUL))) { - return Rel.NEUTRAL; + return Rel.TRUCE; } if (fme.getRelationWish(fthat).value >= fthat.getRelationWish(fme).value) @@ -121,8 +121,9 @@ public class RelationUtil public static ChatColor getColorOfThatToMe(RelationParticipator that, RelationParticipator me) { - Faction thatFaction = getFaction(that); - if (thatFaction != null) + //Faction thatFaction = getFaction(that); + // TODO: Add special colors to zone as a feature to replace this one + /*if (thatFaction != null) { if (thatFaction.isPeaceful() && thatFaction != getFaction(me)) { @@ -138,7 +139,7 @@ public class RelationUtil { return Conf.colorWar; } - } + }*/ return getRelationTo(that, me).getColor(); }