diff --git a/src/com/massivecraft/factions/Board.java b/src/com/massivecraft/factions/Board.java index 195cbbc5..339a3f43 100644 --- a/src/com/massivecraft/factions/Board.java +++ b/src/com/massivecraft/factions/Board.java @@ -12,7 +12,7 @@ import java.util.TreeMap; import org.bukkit.ChatColor; import com.google.gson.reflect.TypeToken; -import com.massivecraft.factions.struct.Relation; +import com.massivecraft.factions.struct.Rel; import com.massivecraft.factions.util.AsciiCompass; import com.massivecraft.factions.zcore.util.DiscUtil; @@ -213,7 +213,7 @@ public class Board { FLocation flocationHere = topLeft.getRelative(dx, dz); Faction factionHere = getFactionAt(flocationHere); - Relation relation = faction.getRelationTo(factionHere); + Rel relation = faction.getRelationTo(factionHere); if (factionHere.isNone()) { row += ChatColor.GRAY+"-"; @@ -232,11 +232,11 @@ public class Board || factionHere == factionLoc || - relation.isAtLeast(Relation.ALLY) + relation.isAtLeast(Rel.ALLY) || - (Conf.showNeutralFactionsOnMap && relation.equals(Relation.NEUTRAL)) + (Conf.showNeutralFactionsOnMap && relation.equals(Rel.NEUTRAL)) || - (Conf.showEnemyFactionsOnMap && relation.equals(Relation.ENEMY)) + (Conf.showEnemyFactionsOnMap && relation.equals(Rel.ENEMY)) ) { if (!fList.containsKey(factionHere.getTag())) diff --git a/src/com/massivecraft/factions/FPlayer.java b/src/com/massivecraft/factions/FPlayer.java index 52b28f4a..1e7f7777 100644 --- a/src/com/massivecraft/factions/FPlayer.java +++ b/src/com/massivecraft/factions/FPlayer.java @@ -15,8 +15,7 @@ import com.massivecraft.factions.integration.SpoutFeatures; import com.massivecraft.factions.integration.Worldguard; import com.massivecraft.factions.struct.ChatMode; import com.massivecraft.factions.struct.Permission; -import com.massivecraft.factions.struct.Relation; -import com.massivecraft.factions.struct.Role; +import com.massivecraft.factions.struct.Rel; import com.massivecraft.factions.util.RelationUtil; import com.massivecraft.factions.zcore.persist.PlayerEntity; import com.nijikokun.register.payment.Method.MethodAccount; @@ -50,9 +49,9 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator } // FIELD: role - private Role role; - public Role getRole() { return this.role; } - public void setRole(Role role) { this.role = role; SpoutFeatures.updateAppearances(this.getPlayer()); } + private Rel role; + public Rel getRole() { return this.role; } + public void setRole(Rel role) { this.role = role; SpoutFeatures.updateAppearances(this.getPlayer()); } // FIELD: title private String title; @@ -179,7 +178,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator this.factionId = "0"; // The default neutral faction this.chatMode = ChatMode.PUBLIC; - this.role = Role.NORMAL; + this.role = Rel.MEMBER; this.title = ""; this.autoClaimFor = null; @@ -400,18 +399,18 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator } @Override - public Relation getRelationTo(RelationParticipator rp) + public Rel getRelationTo(RelationParticipator rp) { return RelationUtil.getRelationTo(this, rp); } @Override - public Relation getRelationTo(RelationParticipator rp, boolean ignorePeaceful) + public Rel getRelationTo(RelationParticipator rp, boolean ignorePeaceful) { return RelationUtil.getRelationTo(this, rp, ignorePeaceful); } - public Relation getRelationToLocation() + public Rel getRelationToLocation() { return Board.getFactionAt(new FLocation(this)).getRelationTo(this); } @@ -540,17 +539,17 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator public boolean isInAllyTerritory() { - return Board.getFactionAt(new FLocation(this)).getRelationTo(this).isAlly(); + return Board.getFactionAt(new FLocation(this)).getRelationTo(this) == Rel.ALLY; } public boolean isInNeutralTerritory() { - return Board.getFactionAt(new FLocation(this)).getRelationTo(this).isNeutral(); + return Board.getFactionAt(new FLocation(this)).getRelationTo(this) == Rel.NEUTRAL; } public boolean isInEnemyTerritory() { - return Board.getFactionAt(new FLocation(this)).getRelationTo(this).isEnemy(); + return Board.getFactionAt(new FLocation(this)).getRelationTo(this) == Rel.ENEMY; } public void sendFactionHereMessage() @@ -577,7 +576,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator Faction myFaction = this.getFaction(); boolean perm = myFaction.isPermanent(); - if (!perm && this.getRole() == Role.ADMIN && myFaction.getFPlayers().size() > 1) + if (!perm && this.getRole() == Rel.LEADER && myFaction.getFPlayers().size() > 1) { msg("You must give the admin role to someone else first."); return; @@ -664,9 +663,9 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator { error = P.p.txt.parse("%s already own this land.", forFaction.describeTo(this, true)); } - else if (this.getRole().value < Role.MODERATOR.value) + else if ( ! this.getRole().isAtLeast(Rel.OFFICER)) { - error = P.p.txt.parse("You must be %s to claim land.", Role.MODERATOR.toString()); + error = P.p.txt.parse("You must be %s to claim land.", Rel.OFFICER.toString()); } else if (forFaction.getFPlayers().size() < Conf.claimsRequireMinFactionMembers) { @@ -684,7 +683,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator { error = P.p.txt.parse("You can't claim more land! You need more power!"); } - else if (currentFaction.getRelationTo(forFaction) == Relation.ALLY) + else if (currentFaction.getRelationTo(forFaction) == Rel.ALLY) { error = P.p.txt.parse("You can't claim the land of your allies."); } diff --git a/src/com/massivecraft/factions/Faction.java b/src/com/massivecraft/factions/Faction.java index 32546978..26dcee35 100644 --- a/src/com/massivecraft/factions/Faction.java +++ b/src/com/massivecraft/factions/Faction.java @@ -12,8 +12,7 @@ import com.massivecraft.factions.iface.EconomyParticipator; import com.massivecraft.factions.iface.RelationParticipator; import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.struct.Permission; -import com.massivecraft.factions.struct.Relation; -import com.massivecraft.factions.struct.Role; +import com.massivecraft.factions.struct.Rel; import com.massivecraft.factions.util.*; import com.massivecraft.factions.zcore.persist.Entity; import com.nijikokun.register.payment.Method.MethodAccount; @@ -22,7 +21,7 @@ import com.nijikokun.register.payment.Method.MethodAccount; public class Faction extends Entity implements EconomyParticipator { // FIELD: relationWish - private Map relationWish; + private Map relationWish; // FIELD: claimOwnership private Map> claimOwnership = new ConcurrentHashMap>(); @@ -141,7 +140,7 @@ public class Faction extends Entity implements EconomyParticipator public Faction() { - this.relationWish = new HashMap(); + this.relationWish = new HashMap(); this.invites = new HashSet(); this.open = Conf.newFactionsDefaultOpen; this.tag = "???"; @@ -210,13 +209,13 @@ public class Faction extends Entity implements EconomyParticipator } @Override - public Relation getRelationTo(RelationParticipator rp) + public Rel getRelationTo(RelationParticipator rp) { return RelationUtil.getRelationTo(this, rp); } @Override - public Relation getRelationTo(RelationParticipator rp, boolean ignorePeaceful) + public Rel getRelationTo(RelationParticipator rp, boolean ignorePeaceful) { return RelationUtil.getRelationTo(this, rp, ignorePeaceful); } @@ -227,18 +226,18 @@ public class Faction extends Entity implements EconomyParticipator return RelationUtil.getColorOfThatToMe(this, rp); } - public Relation getRelationWish(Faction otherFaction) + public Rel getRelationWish(Faction otherFaction) { if (this.relationWish.containsKey(otherFaction.getId())) { return this.relationWish.get(otherFaction.getId()); } - return Relation.NEUTRAL; + return Rel.NEUTRAL; } - public void setRelationWish(Faction otherFaction, Relation relation) + public void setRelationWish(Faction otherFaction, Rel relation) { - if (this.relationWish.containsKey(otherFaction.getId()) && relation.equals(Relation.NEUTRAL)) + if (this.relationWish.containsKey(otherFaction.getId()) && relation.equals(Rel.NEUTRAL)) { this.relationWish.remove(otherFaction.getId()); } @@ -355,7 +354,7 @@ public class Faction extends Entity implements EconomyParticipator for (FPlayer fplayer : FPlayers.i.get()) { - if (fplayer.getFaction() == this && fplayer.getRole() == Role.ADMIN) + if (fplayer.getFaction() == this && fplayer.getRole() == Rel.LEADER) { return fplayer; } @@ -363,7 +362,7 @@ public class Faction extends Entity implements EconomyParticipator return null; } - public ArrayList getFPlayersWhereRole(Role role) + public ArrayList getFPlayersWhereRole(Rel role) { ArrayList ret = new ArrayList(); if ( ! this.isNormal()) return ret; @@ -595,7 +594,7 @@ public class Faction extends Entity implements EconomyParticipator fplayer.getFaction() == this && ( - fplayer.getRole().isAtLeast(Conf.ownedAreaModeratorsBypass ? Role.MODERATOR : Role.ADMIN) + fplayer.getRole().isAtLeast(Conf.ownedAreaModeratorsBypass ? Rel.OFFICER : Rel.LEADER) || Permission.OWNERSHIP_BYPASS.has(fplayer.getPlayer()) ) diff --git a/src/com/massivecraft/factions/cmd/CmdAdmin.java b/src/com/massivecraft/factions/cmd/CmdAdmin.java index 2431ef35..48e2202c 100644 --- a/src/com/massivecraft/factions/cmd/CmdAdmin.java +++ b/src/com/massivecraft/factions/cmd/CmdAdmin.java @@ -3,7 +3,7 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.struct.Permission; -import com.massivecraft.factions.struct.Role; +import com.massivecraft.factions.struct.Rel; public class CmdAdmin extends FCommand { @@ -42,8 +42,8 @@ public class CmdAdmin extends FCommand return; } - fme.setRole(Role.MODERATOR); - fyou.setRole(Role.ADMIN); + fme.setRole(Rel.OFFICER); + fyou.setRole(Rel.LEADER); // Inform all players for (FPlayer fplayer : FPlayers.i.getOnline()) diff --git a/src/com/massivecraft/factions/cmd/CmdCreate.java b/src/com/massivecraft/factions/cmd/CmdCreate.java index 965616eb..5550ca9f 100644 --- a/src/com/massivecraft/factions/cmd/CmdCreate.java +++ b/src/com/massivecraft/factions/cmd/CmdCreate.java @@ -8,8 +8,7 @@ import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.Faction; import com.massivecraft.factions.Factions; import com.massivecraft.factions.struct.Permission; -import com.massivecraft.factions.struct.Role; - +import com.massivecraft.factions.struct.Rel; public class CmdCreate extends FCommand { @@ -67,7 +66,7 @@ public class CmdCreate extends FCommand } faction.setTag(tag); - fme.setRole(Role.ADMIN); + fme.setRole(Rel.LEADER); fme.setFaction(faction); for (FPlayer follower : FPlayers.i.getOnline()) diff --git a/src/com/massivecraft/factions/cmd/CmdDisband.java b/src/com/massivecraft/factions/cmd/CmdDisband.java index b3cc410b..09269933 100644 --- a/src/com/massivecraft/factions/cmd/CmdDisband.java +++ b/src/com/massivecraft/factions/cmd/CmdDisband.java @@ -7,8 +7,7 @@ import com.massivecraft.factions.P; import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.integration.SpoutFeatures; import com.massivecraft.factions.struct.Permission; -import com.massivecraft.factions.struct.Role; - +import com.massivecraft.factions.struct.Rel; public class CmdDisband extends FCommand { @@ -40,7 +39,7 @@ public class CmdDisband extends FCommand if (isMyFaction) { - if ( ! assertMinRole(Role.ADMIN)) return; + if ( ! assertMinRole(Rel.LEADER)) return; } else { diff --git a/src/com/massivecraft/factions/cmd/CmdHome.java b/src/com/massivecraft/factions/cmd/CmdHome.java index 6f6034cf..74e37f3c 100644 --- a/src/com/massivecraft/factions/cmd/CmdHome.java +++ b/src/com/massivecraft/factions/cmd/CmdHome.java @@ -14,8 +14,7 @@ import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.Faction; import com.massivecraft.factions.struct.Permission; -import com.massivecraft.factions.struct.Relation; -import com.massivecraft.factions.struct.Role; +import com.massivecraft.factions.struct.Rel; import com.massivecraft.factions.zcore.util.SmokeUtil; public class CmdHome extends FCommand @@ -56,7 +55,7 @@ public class CmdHome extends FCommand if ( ! myFaction.hasHome()) { - fme.msg("You faction does not have a home. " + (fme.getRole().value < Role.MODERATOR.value ? " Ask your leader to:" : "You should:")); + fme.msg("You faction does not have a home. " + (fme.getRole().isLessThan(Rel.OFFICER) ? " Ask your leader to:" : "You should:")); fme.sendMessage(p.cmdBase.cmdSethome.getUseageTemplate()); return; } @@ -105,7 +104,7 @@ public class CmdHome extends FCommand continue; FPlayer fp = FPlayers.i.get(p); - if (fme.getRelationTo(fp) != Relation.ENEMY) + if (fme.getRelationTo(fp) != Rel.ENEMY) continue; Location l = p.getLocation(); diff --git a/src/com/massivecraft/factions/cmd/CmdMod.java b/src/com/massivecraft/factions/cmd/CmdMod.java index 77d1dba0..55715763 100644 --- a/src/com/massivecraft/factions/cmd/CmdMod.java +++ b/src/com/massivecraft/factions/cmd/CmdMod.java @@ -2,7 +2,7 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.struct.Permission; -import com.massivecraft.factions.struct.Role; +import com.massivecraft.factions.struct.Rel; public class CmdMod extends FCommand { @@ -42,16 +42,16 @@ public class CmdMod extends FCommand return; } - if (you.getRole() == Role.MODERATOR) + if (you.getRole() == Rel.OFFICER) { // Revoke - you.setRole(Role.NORMAL); + you.setRole(Rel.MEMBER); myFaction.msg("%s is no longer moderator in your faction.", you.describeTo(myFaction, true)); } else { // Give - you.setRole(Role.MODERATOR); + you.setRole(Rel.OFFICER); myFaction.msg("%s was promoted to moderator in your faction.", you.describeTo(myFaction, true)); } } diff --git a/src/com/massivecraft/factions/cmd/CmdOwner.java b/src/com/massivecraft/factions/cmd/CmdOwner.java index 8d81ab42..28a3acec 100644 --- a/src/com/massivecraft/factions/cmd/CmdOwner.java +++ b/src/com/massivecraft/factions/cmd/CmdOwner.java @@ -6,7 +6,7 @@ import com.massivecraft.factions.FLocation; import com.massivecraft.factions.Faction; import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.struct.Permission; -import com.massivecraft.factions.struct.Role; +import com.massivecraft.factions.struct.Rel; public class CmdOwner extends FCommand @@ -52,7 +52,7 @@ public class CmdOwner extends FCommand return; } - if ( ! hasBypass && !assertMinRole(Conf.ownedAreasModeratorsCanSet ? Role.MODERATOR : Role.ADMIN)) + if ( ! hasBypass && !assertMinRole(Conf.ownedAreasModeratorsCanSet ? Rel.OFFICER : Rel.LEADER)) { return; } diff --git a/src/com/massivecraft/factions/cmd/CmdRelationAlly.java b/src/com/massivecraft/factions/cmd/CmdRelationAlly.java index c8814fa8..5b93fcb6 100644 --- a/src/com/massivecraft/factions/cmd/CmdRelationAlly.java +++ b/src/com/massivecraft/factions/cmd/CmdRelationAlly.java @@ -1,12 +1,12 @@ package com.massivecraft.factions.cmd; -import com.massivecraft.factions.struct.Relation; +import com.massivecraft.factions.struct.Rel; public class CmdRelationAlly extends FRelationCommand { public CmdRelationAlly() { aliases.add("ally"); - targetRelation = Relation.ALLY; + targetRelation = Rel.ALLY; } } diff --git a/src/com/massivecraft/factions/cmd/CmdRelationEnemy.java b/src/com/massivecraft/factions/cmd/CmdRelationEnemy.java index 11882bf0..46e7a7e6 100644 --- a/src/com/massivecraft/factions/cmd/CmdRelationEnemy.java +++ b/src/com/massivecraft/factions/cmd/CmdRelationEnemy.java @@ -1,12 +1,12 @@ package com.massivecraft.factions.cmd; -import com.massivecraft.factions.struct.Relation; +import com.massivecraft.factions.struct.Rel; public class CmdRelationEnemy extends FRelationCommand { public CmdRelationEnemy() { aliases.add("enemy"); - targetRelation = Relation.ENEMY; + targetRelation = Rel.ENEMY; } } diff --git a/src/com/massivecraft/factions/cmd/CmdRelationNeutral.java b/src/com/massivecraft/factions/cmd/CmdRelationNeutral.java index 03b40e19..d683d5e4 100644 --- a/src/com/massivecraft/factions/cmd/CmdRelationNeutral.java +++ b/src/com/massivecraft/factions/cmd/CmdRelationNeutral.java @@ -1,12 +1,12 @@ package com.massivecraft.factions.cmd; -import com.massivecraft.factions.struct.Relation; +import com.massivecraft.factions.struct.Rel; public class CmdRelationNeutral extends FRelationCommand { public CmdRelationNeutral() { aliases.add("neutral"); - targetRelation = Relation.NEUTRAL; + targetRelation = Rel.NEUTRAL; } } diff --git a/src/com/massivecraft/factions/cmd/CmdSethome.java b/src/com/massivecraft/factions/cmd/CmdSethome.java index b6536b68..522025c9 100644 --- a/src/com/massivecraft/factions/cmd/CmdSethome.java +++ b/src/com/massivecraft/factions/cmd/CmdSethome.java @@ -5,7 +5,7 @@ import com.massivecraft.factions.Conf; import com.massivecraft.factions.FLocation; import com.massivecraft.factions.Faction; import com.massivecraft.factions.struct.Permission; -import com.massivecraft.factions.struct.Role; +import com.massivecraft.factions.struct.Rel; public class CmdSethome extends FCommand { @@ -40,7 +40,7 @@ public class CmdSethome extends FCommand // Can the player set the home for this faction? if (faction == myFaction) { - if ( ! Permission.SETHOME_ANY.has(sender) && ! assertMinRole(Role.MODERATOR)) return; + if ( ! Permission.SETHOME_ANY.has(sender) && ! assertMinRole(Rel.OFFICER)) return; } else { diff --git a/src/com/massivecraft/factions/cmd/CmdShow.java b/src/com/massivecraft/factions/cmd/CmdShow.java index b7626306..789dcccb 100644 --- a/src/com/massivecraft/factions/cmd/CmdShow.java +++ b/src/com/massivecraft/factions/cmd/CmdShow.java @@ -8,7 +8,7 @@ import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.Faction; import com.massivecraft.factions.Factions; import com.massivecraft.factions.struct.Permission; -import com.massivecraft.factions.struct.Role; +import com.massivecraft.factions.struct.Rel; public class CmdShow extends FCommand { @@ -43,9 +43,9 @@ public class CmdShow extends FCommand // if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay if ( ! payForCommand(Conf.econCostShow, "to show faction information", "for showing faction information")) return; - Collection admins = faction.getFPlayersWhereRole(Role.ADMIN); - Collection mods = faction.getFPlayersWhereRole(Role.MODERATOR); - Collection normals = faction.getFPlayersWhereRole(Role.NORMAL); + Collection admins = faction.getFPlayersWhereRole(Rel.LEADER); + Collection mods = faction.getFPlayersWhereRole(Rel.OFFICER); + Collection normals = faction.getFPlayersWhereRole(Rel.MEMBER); msg(p.txt.titleize(faction.getTag(fme))); msg("Description: %s", faction.getDescription()); @@ -98,11 +98,11 @@ public class CmdShow extends FCommand continue; } listpart = otherFaction.getTag(fme)+p.txt.parse("")+", "; - if (otherFaction.getRelationTo(faction).isAlly()) + if (otherFaction.getRelationTo(faction) == Rel.ALLY) { allyList += listpart; } - else if (otherFaction.getRelationTo(faction).isEnemy()) + else if (otherFaction.getRelationTo(faction) == Rel.ENEMY) { enemyList += listpart; } diff --git a/src/com/massivecraft/factions/cmd/CmdUnclaim.java b/src/com/massivecraft/factions/cmd/CmdUnclaim.java index 22a2478d..f0436f28 100644 --- a/src/com/massivecraft/factions/cmd/CmdUnclaim.java +++ b/src/com/massivecraft/factions/cmd/CmdUnclaim.java @@ -6,7 +6,7 @@ import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.FLocation; import com.massivecraft.factions.Faction; import com.massivecraft.factions.struct.Permission; -import com.massivecraft.factions.struct.Role; +import com.massivecraft.factions.struct.Rel; public class CmdUnclaim extends FCommand { @@ -74,7 +74,7 @@ public class CmdUnclaim extends FCommand return; } - if ( ! assertMinRole(Role.MODERATOR)) + if ( ! assertMinRole(Rel.OFFICER)) { return; } diff --git a/src/com/massivecraft/factions/cmd/FCommand.java b/src/com/massivecraft/factions/cmd/FCommand.java index 5863cbf6..89518137 100644 --- a/src/com/massivecraft/factions/cmd/FCommand.java +++ b/src/com/massivecraft/factions/cmd/FCommand.java @@ -12,7 +12,7 @@ import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.Faction; import com.massivecraft.factions.Factions; import com.massivecraft.factions.P; -import com.massivecraft.factions.struct.Role; +import com.massivecraft.factions.struct.Rel; import com.massivecraft.factions.zcore.MCommand; @@ -101,13 +101,13 @@ public abstract class FCommand extends MCommand

return false; } - if (this.senderMustBeModerator && ! fplayer.getRole().isAtLeast(Role.MODERATOR)) + if (this.senderMustBeModerator && ! fplayer.getRole().isAtLeast(Rel.OFFICER)) { sender.sendMessage(p.txt.parse("Only faction moderators can %s.", this.getHelpShort())); return false; } - if (this.senderMustBeAdmin && ! fplayer.getRole().isAtLeast(Role.ADMIN)) + if (this.senderMustBeAdmin && ! fplayer.getRole().isAtLeast(Rel.LEADER)) { sender.sendMessage(p.txt.parse("Only faction admins can %s.", this.getHelpShort())); return false; @@ -132,7 +132,7 @@ public abstract class FCommand extends MCommand

return true; } - public boolean assertMinRole(Role role) + public boolean assertMinRole(Rel role) { if (me == null) return true; @@ -285,16 +285,16 @@ public abstract class FCommand extends MCommand

return false; } - if (i.getRole().value > you.getRole().value || i.getRole().equals(Role.ADMIN) ) + if (i.getRole().value > you.getRole().value || i.getRole().equals(Rel.LEADER) ) { return true; } - if (you.getRole().equals(Role.ADMIN)) + if (you.getRole().equals(Rel.LEADER)) { i.sendMessage(p.txt.parse("Only the faction admin can do that.")); } - else if (i.getRole().equals(Role.MODERATOR)) + else if (i.getRole().equals(Rel.OFFICER)) { if ( i == you ) { diff --git a/src/com/massivecraft/factions/cmd/FRelationCommand.java b/src/com/massivecraft/factions/cmd/FRelationCommand.java index e2636faa..00ba67ba 100644 --- a/src/com/massivecraft/factions/cmd/FRelationCommand.java +++ b/src/com/massivecraft/factions/cmd/FRelationCommand.java @@ -6,11 +6,11 @@ import com.massivecraft.factions.Conf; import com.massivecraft.factions.Faction; import com.massivecraft.factions.integration.SpoutFeatures; import com.massivecraft.factions.struct.Permission; -import com.massivecraft.factions.struct.Relation; +import com.massivecraft.factions.struct.Rel; public abstract class FRelationCommand extends FCommand { - public Relation targetRelation; + public Rel targetRelation; public FRelationCommand() { @@ -49,7 +49,7 @@ public abstract class FRelationCommand extends FCommand if ( ! payForCommand(targetRelation.getRelationCost(), "to change a relation wish", "for changing a relation wish")) return; myFaction.setRelationWish(them, targetRelation); - Relation currentRelation = myFaction.getRelationTo(them, true); + Rel currentRelation = myFaction.getRelationTo(them, true); ChatColor currentRelationColor = currentRelation.getColor(); if (targetRelation.value == currentRelation.value) { @@ -63,13 +63,13 @@ public abstract class FRelationCommand extends FCommand myFaction.msg(currentRelationColor+them.getTag()+" were informed that you wish to be "+targetRelation.getColor()+targetRelation); } - if ( ! targetRelation.isNeutral() && them.isPeaceful()) + if ( targetRelation != Rel.NEUTRAL && them.isPeaceful()) { 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.isNeutral() && myFaction.isPeaceful()) + if ( targetRelation != Rel.NEUTRAL && myFaction.isPeaceful()) { 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/iface/RelationParticipator.java b/src/com/massivecraft/factions/iface/RelationParticipator.java index b46b6f3b..b7229011 100644 --- a/src/com/massivecraft/factions/iface/RelationParticipator.java +++ b/src/com/massivecraft/factions/iface/RelationParticipator.java @@ -2,15 +2,15 @@ package com.massivecraft.factions.iface; import org.bukkit.ChatColor; -import com.massivecraft.factions.struct.Relation; +import com.massivecraft.factions.struct.Rel; public interface RelationParticipator { public String describeTo(RelationParticipator that); public String describeTo(RelationParticipator that, boolean ucfirst); - public Relation getRelationTo(RelationParticipator that); - public Relation getRelationTo(RelationParticipator that, boolean ignorePeaceful); + public Rel getRelationTo(RelationParticipator that); + public Rel getRelationTo(RelationParticipator that, boolean ignorePeaceful); public ChatColor getColorTo(RelationParticipator to); } diff --git a/src/com/massivecraft/factions/integration/Econ.java b/src/com/massivecraft/factions/integration/Econ.java index 342bb2a3..9f640bfe 100644 --- a/src/com/massivecraft/factions/integration/Econ.java +++ b/src/com/massivecraft/factions/integration/Econ.java @@ -17,7 +17,7 @@ import com.massivecraft.factions.Factions; import com.massivecraft.factions.P; import com.massivecraft.factions.iface.EconomyParticipator; import com.massivecraft.factions.struct.Permission; -import com.massivecraft.factions.struct.Role; +import com.massivecraft.factions.struct.Rel; import com.massivecraft.factions.util.RelationUtil; public class Econ @@ -107,7 +107,7 @@ public class Econ if (i == fI && fI == fYou) return true; // Factions can be controlled by members that are moderators... or any member if any member can withdraw. - if (you instanceof Faction && fI == fYou && (Conf.bankMembersCanWithdraw || ((FPlayer)i).getRole().value >= Role.MODERATOR.value)) return true; + if (you instanceof Faction && fI == fYou && (Conf.bankMembersCanWithdraw || ((FPlayer)i).getRole().isAtLeast(Rel.OFFICER))) return true; // Otherwise you may not! ;,,; i.msg("%s lack permission to controll %s's money.", i.describeTo(i, true), you.describeTo(i)); diff --git a/src/com/massivecraft/factions/struct/FactionFlag.java b/src/com/massivecraft/factions/struct/FactionFlag.java new file mode 100644 index 00000000..dd25a5d6 --- /dev/null +++ b/src/com/massivecraft/factions/struct/FactionFlag.java @@ -0,0 +1,46 @@ +package com.massivecraft.factions.struct; + +/** + * Flags that describe the nature of a faction and it's territory. + * Can monsters spawn there? May fire spread etc? Is the faction permanent? + * These flags have nothing to do with player-permission. + * + * The flags are either true or false. + */ +public enum FactionFlag +{ + // Faction flags + PERMANENT, + PEACEFUL, // This faction is friends with everyone + INFPOWER, // This faction has infinite power: TODO: Add faction has enough method. Replace the permanentpower level + + // (Faction) Territory flags + POWERLOSS, // Regardless of death-reason players loose power on death IF powerloss is true in this territory + PVP, + FRIENDLYFIRE, // Can members/allies/friends damage eachother in this territory? + MONSTERS, + EXPLOSIONS, + FIRESPREAD, + LIGHTNING, + ; + + /** + * The state for newly created factions. + */ + public boolean getDefault() + { + // Use config file for this later. + return true; + } + + /** + * Is this flag changeable by the faction leaders or not? + * The normal faction members can never change these flags. + * Note that server operators and admin bypassers can change all flags. + */ + public boolean isChangeable() + { + // TODO: Use config file + return true; + } +} diff --git a/src/com/massivecraft/factions/struct/FactionPlayerPerm.java b/src/com/massivecraft/factions/struct/FactionPlayerPerm.java new file mode 100644 index 00000000..e62b6fe2 --- /dev/null +++ b/src/com/massivecraft/factions/struct/FactionPlayerPerm.java @@ -0,0 +1,17 @@ +package com.massivecraft.factions.struct; + +/** + * Permissions that you (a player) may or may not have in the territory of a certain faction. + * + * You need a certain rel to be able + */ +public enum FactionPlayerPerm +{ + BUILD, // This player can build in the faction + PAINBUILD, // This player can build in the faction BUT will take damage each time. This is overridden by BUILD if player has both + DOOR, + WORKBENCH, + CONTAINER, + BUTTON, + LEVER, +} diff --git a/src/com/massivecraft/factions/struct/Rel.java b/src/com/massivecraft/factions/struct/Rel.java new file mode 100644 index 00000000..60db842a --- /dev/null +++ b/src/com/massivecraft/factions/struct/Rel.java @@ -0,0 +1,119 @@ +package com.massivecraft.factions.struct; + +import org.bukkit.ChatColor; + +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"), + ; + + public final int value; + public final String nicename; + + private Rel(final int value, final String nicename) + { + this.value = value; + this.nicename = nicename; + } + + public static Rel parse(String str) + { + if (str == null || str.length() < 1) return null; + + str = str.toLowerCase(); + + // These are to allow conversion from the old system. + if (str.equals("admin")) + { + return LEADER; + } + + if (str.equals("moderator")) + { + return OFFICER; + } + + if (str.equals("normal")) + { + return MEMBER; + } + + // This is how we check: Based on first char. + char c = str.charAt(0); + if (c == 'l') return LEADER; + if (c == 'o') return OFFICER; + if (c == 'm') return MEMBER; + if (c == 'a') return ALLY; + if (c == 't') return TRUCE; + if (c == 'n') return NEUTRAL; + if (c == 'e') return ENEMY; + return null; + } + + @Override + public String toString() + { + return this.nicename; + } + + public boolean isAtLeast(Rel rel) + { + return this.value >= rel.value; + } + + public boolean isAtMost(Rel rel) + { + return this.value <= rel.value; + } + + public boolean isLessThan(Rel rel) + { + return this.value < rel.value; + } + + public ChatColor getColor() + { + if (this == MEMBER) + return Conf.colorMember; + else if (this == ALLY) + return Conf.colorAlly; + else if (this == NEUTRAL) + return Conf.colorNeutral; + else + return Conf.colorEnemy; + } + + public String getPrefix() + { + if (this == LEADER) + { + return Conf.prefixAdmin; + } + + if (this == OFFICER) + { + return Conf.prefixMod; + } + + return ""; + } + + // TODO: ADD TRUCE!!!! + public double getRelationCost() + { + if (this == ENEMY) + return Conf.econCostEnemy; + else if (this == ALLY) + return Conf.econCostAlly; + else + return Conf.econCostNeutral; + } +} diff --git a/src/com/massivecraft/factions/struct/Relation.java b/src/com/massivecraft/factions/struct/RelationDEPR.java similarity index 96% rename from src/com/massivecraft/factions/struct/Relation.java rename to src/com/massivecraft/factions/struct/RelationDEPR.java index c84989ff..634c3387 100644 --- a/src/com/massivecraft/factions/struct/Relation.java +++ b/src/com/massivecraft/factions/struct/RelationDEPR.java @@ -5,17 +5,18 @@ import org.bukkit.ChatColor; import com.massivecraft.factions.Conf; -public enum Relation +public enum RelationDEPR { MEMBER(3, "member"), ALLY(2, "ally"), NEUTRAL(1, "neutral"), - ENEMY(0, "enemy"); + ENEMY(0, "enemy"), + ; public final int value; public final String nicename; - private Relation(final int value, final String nicename) + private RelationDEPR(final int value, final String nicename) { this.value = value; this.nicename = nicename; diff --git a/src/com/massivecraft/factions/struct/Role.java b/src/com/massivecraft/factions/struct/RoleDEPR.java similarity index 89% rename from src/com/massivecraft/factions/struct/Role.java rename to src/com/massivecraft/factions/struct/RoleDEPR.java index 08af23c9..0aacf731 100644 --- a/src/com/massivecraft/factions/struct/Role.java +++ b/src/com/massivecraft/factions/struct/RoleDEPR.java @@ -2,7 +2,7 @@ package com.massivecraft.factions.struct; import com.massivecraft.factions.Conf; -public enum Role +public enum RoleDEPR { ADMIN(2, "admin"), MODERATOR(1, "moderator"), @@ -11,7 +11,7 @@ public enum Role public final int value; public final String nicename; - private Role(final int value, final String nicename) + private RoleDEPR(final int value, final String nicename) { this.value = value; this.nicename = nicename; diff --git a/src/com/massivecraft/factions/util/RelationUtil.java b/src/com/massivecraft/factions/util/RelationUtil.java index b574ea81..2036fdbb 100644 --- a/src/com/massivecraft/factions/util/RelationUtil.java +++ b/src/com/massivecraft/factions/util/RelationUtil.java @@ -6,7 +6,7 @@ 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.Relation; +import com.massivecraft.factions.struct.Rel; import com.massivecraft.factions.zcore.util.TextUtil; public class RelationUtil @@ -62,32 +62,32 @@ public class RelationUtil return describeThatToMe(that, me, false); } - public static Relation getRelationTo(RelationParticipator me, RelationParticipator that) + public static Rel getRelationTo(RelationParticipator me, RelationParticipator that) { return getRelationTo(that, me, false); } - public static Relation getRelationTo(RelationParticipator me, RelationParticipator that, boolean ignorePeaceful) + public static Rel getRelationTo(RelationParticipator me, RelationParticipator that, boolean ignorePeaceful) { Faction fthat = getFaction(that); - if (fthat == null) return Relation.NEUTRAL; // ERROR + if (fthat == null) return Rel.NEUTRAL; // ERROR Faction fme = getFaction(me); - if (fme == null) return Relation.NEUTRAL; // ERROR + if (fme == null) return Rel.NEUTRAL; // ERROR if (!fthat.isNormal() || !fme.isNormal()) { - return Relation.NEUTRAL; + return Rel.NEUTRAL; } if (fthat.equals(fme)) { - return Relation.MEMBER; + return Rel.MEMBER; } if (!ignorePeaceful && (fme.isPeaceful() || fthat.isPeaceful())) { - return Relation.NEUTRAL; + return Rel.NEUTRAL; } if (fme.getRelationWish(fthat).value >= fthat.getRelationWish(fme).value) diff --git a/src/com/massivecraft/factions/zcore/util/TextUtil.java b/src/com/massivecraft/factions/zcore/util/TextUtil.java index a4caee9d..e2a0dfba 100644 --- a/src/com/massivecraft/factions/zcore/util/TextUtil.java +++ b/src/com/massivecraft/factions/zcore/util/TextUtil.java @@ -314,7 +314,7 @@ public class TextUtil { return candidate; } - if (lendiff < best ||best == 0) + if (lendiff < best || best == 0) { best = lendiff; ret = candidate;