From 0326a6e938a20e540be39a78cc163ec08f64c71c Mon Sep 17 00:00:00 2001 From: Brettflan Date: Tue, 11 Oct 2011 20:14:59 -0500 Subject: [PATCH] Fixed ownerlist command (though not sure just why it was failing as written, I need to investigate further), working on restructuring and fixing ownership handling for block placement/destruction/interaction/usage. Will finish that up in the next day or two. --- plugin.yml | 2 +- src/com/massivecraft/factions/Faction.java | 8 +-- .../factions/cmd/CmdOwnerList.java | 2 +- .../factions/struct/Relation.java | 63 ++++--------------- 4 files changed, 16 insertions(+), 59 deletions(-) diff --git a/plugin.yml b/plugin.yml index 9249d2d8..a17ee15a 100644 --- a/plugin.yml +++ b/plugin.yml @@ -127,7 +127,7 @@ permissions: factions.managewarzone: description: claim land as a war zone and build/destroy within war zones factions.map: - description: show territory map, set optional auto update + description: show the territory map, and set optional auto update factions.mod: description: give or revoke moderator rights factions.noboom: diff --git a/src/com/massivecraft/factions/Faction.java b/src/com/massivecraft/factions/Faction.java index 3e0b3dac..26c21e47 100644 --- a/src/com/massivecraft/factions/Faction.java +++ b/src/com/massivecraft/factions/Faction.java @@ -582,14 +582,8 @@ public class Faction extends Entity public boolean playerHasOwnershipRights(FPlayer fplayer, FLocation loc) { - // different faction? - if (fplayer.getFactionId() != this.getId()) - { - return false; - } - // sufficient role to bypass ownership? - if (fplayer.getRole().isAtLeast(Conf.ownedAreaModeratorsBypass ? Role.MODERATOR : Role.ADMIN)) + if (fplayer.getFaction() == this && fplayer.getRole().isAtLeast(Conf.ownedAreaModeratorsBypass ? Role.MODERATOR : Role.ADMIN)) { return true; } diff --git a/src/com/massivecraft/factions/cmd/CmdOwnerList.java b/src/com/massivecraft/factions/cmd/CmdOwnerList.java index 3f8d8c75..f7c39efc 100644 --- a/src/com/massivecraft/factions/cmd/CmdOwnerList.java +++ b/src/com/massivecraft/factions/cmd/CmdOwnerList.java @@ -44,7 +44,7 @@ public class CmdOwnerList extends FCommand FLocation flocation = new FLocation(fme); - if (Board.getIdAt(flocation) != myFaction.getId()) + if (Board.getFactionAt(flocation) != myFaction) { if (!hasBypass) { diff --git a/src/com/massivecraft/factions/struct/Relation.java b/src/com/massivecraft/factions/struct/Relation.java index 87d786de..b7021a66 100644 --- a/src/com/massivecraft/factions/struct/Relation.java +++ b/src/com/massivecraft/factions/struct/Relation.java @@ -26,25 +26,24 @@ public enum Relation return this.nicename; } - // TODO: Insane way to use enums!!!? public boolean isMember() { - return this.value == MEMBER.value; + return this == MEMBER; } public boolean isAlly() { - return this.value == ALLY.value; + return this == ALLY; } public boolean isNeutral() { - return this.value == NEUTRAL.value; + return this == NEUTRAL; } public boolean isEnemy() { - return this.value == ENEMY.value; + return this == ENEMY; } public boolean isAtLeast(Relation relation) @@ -60,123 +59,87 @@ public enum Relation public ChatColor getColor() { if (this.value == MEMBER.value) - { return Conf.colorMember; - } else if (this.value == ALLY.value) - { return Conf.colorAlly; - } else if (this.value == NEUTRAL.value) - { return Conf.colorNeutral; - } else - { return Conf.colorEnemy; - } } // return appropriate Conf setting for DenyBuild based on this relation and their online status public boolean confDenyBuild(boolean online) { + if (isMember()) + return false; + if (online) { if (isEnemy()) - { return Conf.territoryEnemyDenyBuild; - } else if (isAlly()) - { return Conf.territoryAllyDenyBuild; - } else - { return Conf.territoryDenyBuild; - } } else { if (isEnemy()) - { return Conf.territoryEnemyDenyBuildWhenOffline; - } else if (isAlly()) - { return Conf.territoryAllyDenyBuildWhenOffline; - } else - { return Conf.territoryDenyBuildWhenOffline; - } } } // return appropriate Conf setting for PainBuild based on this relation and their online status public boolean confPainBuild(boolean online) { + if (isMember()) + return false; + if (online) { if (isEnemy()) - { return Conf.territoryEnemyPainBuild; - } else if (isAlly()) - { return Conf.territoryAllyPainBuild; - } else - { return Conf.territoryPainBuild; - } } else { if (isEnemy()) - { return Conf.territoryEnemyPainBuildWhenOffline; - } else if (isAlly()) - { return Conf.territoryAllyPainBuildWhenOffline; - } else - { return Conf.territoryPainBuildWhenOffline; - } } } // return appropriate Conf setting for DenyUseage based on this relation public boolean confDenyUseage() { - if (isEnemy()) - { + if (isMember()) + return false; + else if (isEnemy()) return Conf.territoryEnemyDenyUseage; - } else if (isAlly()) - { return Conf.territoryAllyDenyUseage; - } else - { return Conf.territoryDenyUseage; - } } public double getRelationCost() { if (isEnemy()) - { return Conf.econCostEnemy; - } else if (isAlly()) - { return Conf.econCostAlly; - } else - { return Conf.econCostNeutral; - } } }