In the middle of refactoring to merged role and relation as one enum
This commit is contained in:
parent
4f7fd6dd96
commit
d280f9409d
@ -12,7 +12,7 @@ import java.util.TreeMap;
|
|||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
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.util.AsciiCompass;
|
||||||
import com.massivecraft.factions.zcore.util.DiscUtil;
|
import com.massivecraft.factions.zcore.util.DiscUtil;
|
||||||
|
|
||||||
@ -213,7 +213,7 @@ public class Board
|
|||||||
{
|
{
|
||||||
FLocation flocationHere = topLeft.getRelative(dx, dz);
|
FLocation flocationHere = topLeft.getRelative(dx, dz);
|
||||||
Faction factionHere = getFactionAt(flocationHere);
|
Faction factionHere = getFactionAt(flocationHere);
|
||||||
Relation relation = faction.getRelationTo(factionHere);
|
Rel relation = faction.getRelationTo(factionHere);
|
||||||
if (factionHere.isNone())
|
if (factionHere.isNone())
|
||||||
{
|
{
|
||||||
row += ChatColor.GRAY+"-";
|
row += ChatColor.GRAY+"-";
|
||||||
@ -232,11 +232,11 @@ public class Board
|
|||||||
||
|
||
|
||||||
factionHere == factionLoc
|
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()))
|
if (!fList.containsKey(factionHere.getTag()))
|
||||||
|
@ -15,8 +15,7 @@ import com.massivecraft.factions.integration.SpoutFeatures;
|
|||||||
import com.massivecraft.factions.integration.Worldguard;
|
import com.massivecraft.factions.integration.Worldguard;
|
||||||
import com.massivecraft.factions.struct.ChatMode;
|
import com.massivecraft.factions.struct.ChatMode;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.struct.Relation;
|
import com.massivecraft.factions.struct.Rel;
|
||||||
import com.massivecraft.factions.struct.Role;
|
|
||||||
import com.massivecraft.factions.util.RelationUtil;
|
import com.massivecraft.factions.util.RelationUtil;
|
||||||
import com.massivecraft.factions.zcore.persist.PlayerEntity;
|
import com.massivecraft.factions.zcore.persist.PlayerEntity;
|
||||||
import com.nijikokun.register.payment.Method.MethodAccount;
|
import com.nijikokun.register.payment.Method.MethodAccount;
|
||||||
@ -50,9 +49,9 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FIELD: role
|
// FIELD: role
|
||||||
private Role role;
|
private Rel role;
|
||||||
public Role getRole() { return this.role; }
|
public Rel getRole() { return this.role; }
|
||||||
public void setRole(Role role) { this.role = role; SpoutFeatures.updateAppearances(this.getPlayer()); }
|
public void setRole(Rel role) { this.role = role; SpoutFeatures.updateAppearances(this.getPlayer()); }
|
||||||
|
|
||||||
// FIELD: title
|
// FIELD: title
|
||||||
private String title;
|
private String title;
|
||||||
@ -179,7 +178,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
|
|
||||||
this.factionId = "0"; // The default neutral faction
|
this.factionId = "0"; // The default neutral faction
|
||||||
this.chatMode = ChatMode.PUBLIC;
|
this.chatMode = ChatMode.PUBLIC;
|
||||||
this.role = Role.NORMAL;
|
this.role = Rel.MEMBER;
|
||||||
this.title = "";
|
this.title = "";
|
||||||
this.autoClaimFor = null;
|
this.autoClaimFor = null;
|
||||||
|
|
||||||
@ -400,18 +399,18 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Relation getRelationTo(RelationParticipator rp)
|
public Rel getRelationTo(RelationParticipator rp)
|
||||||
{
|
{
|
||||||
return RelationUtil.getRelationTo(this, rp);
|
return RelationUtil.getRelationTo(this, rp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Relation getRelationTo(RelationParticipator rp, boolean ignorePeaceful)
|
public Rel getRelationTo(RelationParticipator rp, boolean ignorePeaceful)
|
||||||
{
|
{
|
||||||
return RelationUtil.getRelationTo(this, rp, ignorePeaceful);
|
return RelationUtil.getRelationTo(this, rp, ignorePeaceful);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Relation getRelationToLocation()
|
public Rel getRelationToLocation()
|
||||||
{
|
{
|
||||||
return Board.getFactionAt(new FLocation(this)).getRelationTo(this);
|
return Board.getFactionAt(new FLocation(this)).getRelationTo(this);
|
||||||
}
|
}
|
||||||
@ -540,17 +539,17 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
|
|
||||||
public boolean isInAllyTerritory()
|
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()
|
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()
|
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()
|
public void sendFactionHereMessage()
|
||||||
@ -577,7 +576,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
Faction myFaction = this.getFaction();
|
Faction myFaction = this.getFaction();
|
||||||
boolean perm = myFaction.isPermanent();
|
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("<b>You must give the admin role to someone else first.");
|
msg("<b>You must give the admin role to someone else first.");
|
||||||
return;
|
return;
|
||||||
@ -664,9 +663,9 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
{
|
{
|
||||||
error = P.p.txt.parse("%s<i> already own this land.", forFaction.describeTo(this, true));
|
error = P.p.txt.parse("%s<i> 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("<b>You must be <h>%s<b> to claim land.", Role.MODERATOR.toString());
|
error = P.p.txt.parse("<b>You must be <h>%s<b> to claim land.", Rel.OFFICER.toString());
|
||||||
}
|
}
|
||||||
else if (forFaction.getFPlayers().size() < Conf.claimsRequireMinFactionMembers)
|
else if (forFaction.getFPlayers().size() < Conf.claimsRequireMinFactionMembers)
|
||||||
{
|
{
|
||||||
@ -684,7 +683,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
{
|
{
|
||||||
error = P.p.txt.parse("<b>You can't claim more land! You need more power!");
|
error = P.p.txt.parse("<b>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("<b>You can't claim the land of your allies.");
|
error = P.p.txt.parse("<b>You can't claim the land of your allies.");
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,7 @@ import com.massivecraft.factions.iface.EconomyParticipator;
|
|||||||
import com.massivecraft.factions.iface.RelationParticipator;
|
import com.massivecraft.factions.iface.RelationParticipator;
|
||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.struct.Relation;
|
import com.massivecraft.factions.struct.Rel;
|
||||||
import com.massivecraft.factions.struct.Role;
|
|
||||||
import com.massivecraft.factions.util.*;
|
import com.massivecraft.factions.util.*;
|
||||||
import com.massivecraft.factions.zcore.persist.Entity;
|
import com.massivecraft.factions.zcore.persist.Entity;
|
||||||
import com.nijikokun.register.payment.Method.MethodAccount;
|
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
|
public class Faction extends Entity implements EconomyParticipator
|
||||||
{
|
{
|
||||||
// FIELD: relationWish
|
// FIELD: relationWish
|
||||||
private Map<String, Relation> relationWish;
|
private Map<String, Rel> relationWish;
|
||||||
|
|
||||||
// FIELD: claimOwnership
|
// FIELD: claimOwnership
|
||||||
private Map<FLocation, Set<String>> claimOwnership = new ConcurrentHashMap<FLocation, Set<String>>();
|
private Map<FLocation, Set<String>> claimOwnership = new ConcurrentHashMap<FLocation, Set<String>>();
|
||||||
@ -141,7 +140,7 @@ public class Faction extends Entity implements EconomyParticipator
|
|||||||
|
|
||||||
public Faction()
|
public Faction()
|
||||||
{
|
{
|
||||||
this.relationWish = new HashMap<String, Relation>();
|
this.relationWish = new HashMap<String, Rel>();
|
||||||
this.invites = new HashSet<String>();
|
this.invites = new HashSet<String>();
|
||||||
this.open = Conf.newFactionsDefaultOpen;
|
this.open = Conf.newFactionsDefaultOpen;
|
||||||
this.tag = "???";
|
this.tag = "???";
|
||||||
@ -210,13 +209,13 @@ public class Faction extends Entity implements EconomyParticipator
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Relation getRelationTo(RelationParticipator rp)
|
public Rel getRelationTo(RelationParticipator rp)
|
||||||
{
|
{
|
||||||
return RelationUtil.getRelationTo(this, rp);
|
return RelationUtil.getRelationTo(this, rp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Relation getRelationTo(RelationParticipator rp, boolean ignorePeaceful)
|
public Rel getRelationTo(RelationParticipator rp, boolean ignorePeaceful)
|
||||||
{
|
{
|
||||||
return RelationUtil.getRelationTo(this, rp, ignorePeaceful);
|
return RelationUtil.getRelationTo(this, rp, ignorePeaceful);
|
||||||
}
|
}
|
||||||
@ -227,18 +226,18 @@ public class Faction extends Entity implements EconomyParticipator
|
|||||||
return RelationUtil.getColorOfThatToMe(this, rp);
|
return RelationUtil.getColorOfThatToMe(this, rp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Relation getRelationWish(Faction otherFaction)
|
public Rel getRelationWish(Faction otherFaction)
|
||||||
{
|
{
|
||||||
if (this.relationWish.containsKey(otherFaction.getId()))
|
if (this.relationWish.containsKey(otherFaction.getId()))
|
||||||
{
|
{
|
||||||
return this.relationWish.get(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());
|
this.relationWish.remove(otherFaction.getId());
|
||||||
}
|
}
|
||||||
@ -355,7 +354,7 @@ public class Faction extends Entity implements EconomyParticipator
|
|||||||
|
|
||||||
for (FPlayer fplayer : FPlayers.i.get())
|
for (FPlayer fplayer : FPlayers.i.get())
|
||||||
{
|
{
|
||||||
if (fplayer.getFaction() == this && fplayer.getRole() == Role.ADMIN)
|
if (fplayer.getFaction() == this && fplayer.getRole() == Rel.LEADER)
|
||||||
{
|
{
|
||||||
return fplayer;
|
return fplayer;
|
||||||
}
|
}
|
||||||
@ -363,7 +362,7 @@ public class Faction extends Entity implements EconomyParticipator
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<FPlayer> getFPlayersWhereRole(Role role)
|
public ArrayList<FPlayer> getFPlayersWhereRole(Rel role)
|
||||||
{
|
{
|
||||||
ArrayList<FPlayer> ret = new ArrayList<FPlayer>();
|
ArrayList<FPlayer> ret = new ArrayList<FPlayer>();
|
||||||
if ( ! this.isNormal()) return ret;
|
if ( ! this.isNormal()) return ret;
|
||||||
@ -595,7 +594,7 @@ public class Faction extends Entity implements EconomyParticipator
|
|||||||
fplayer.getFaction() == this
|
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())
|
Permission.OWNERSHIP_BYPASS.has(fplayer.getPlayer())
|
||||||
)
|
)
|
||||||
|
@ -3,7 +3,7 @@ package com.massivecraft.factions.cmd;
|
|||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
import com.massivecraft.factions.FPlayers;
|
import com.massivecraft.factions.FPlayers;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.struct.Role;
|
import com.massivecraft.factions.struct.Rel;
|
||||||
|
|
||||||
public class CmdAdmin extends FCommand
|
public class CmdAdmin extends FCommand
|
||||||
{
|
{
|
||||||
@ -42,8 +42,8 @@ public class CmdAdmin extends FCommand
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fme.setRole(Role.MODERATOR);
|
fme.setRole(Rel.OFFICER);
|
||||||
fyou.setRole(Role.ADMIN);
|
fyou.setRole(Rel.LEADER);
|
||||||
|
|
||||||
// Inform all players
|
// Inform all players
|
||||||
for (FPlayer fplayer : FPlayers.i.getOnline())
|
for (FPlayer fplayer : FPlayers.i.getOnline())
|
||||||
|
@ -8,8 +8,7 @@ import com.massivecraft.factions.FPlayers;
|
|||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.struct.Role;
|
import com.massivecraft.factions.struct.Rel;
|
||||||
|
|
||||||
|
|
||||||
public class CmdCreate extends FCommand
|
public class CmdCreate extends FCommand
|
||||||
{
|
{
|
||||||
@ -67,7 +66,7 @@ public class CmdCreate extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
faction.setTag(tag);
|
faction.setTag(tag);
|
||||||
fme.setRole(Role.ADMIN);
|
fme.setRole(Rel.LEADER);
|
||||||
fme.setFaction(faction);
|
fme.setFaction(faction);
|
||||||
|
|
||||||
for (FPlayer follower : FPlayers.i.getOnline())
|
for (FPlayer follower : FPlayers.i.getOnline())
|
||||||
|
@ -7,8 +7,7 @@ import com.massivecraft.factions.P;
|
|||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.struct.Role;
|
import com.massivecraft.factions.struct.Rel;
|
||||||
|
|
||||||
|
|
||||||
public class CmdDisband extends FCommand
|
public class CmdDisband extends FCommand
|
||||||
{
|
{
|
||||||
@ -40,7 +39,7 @@ public class CmdDisband extends FCommand
|
|||||||
|
|
||||||
if (isMyFaction)
|
if (isMyFaction)
|
||||||
{
|
{
|
||||||
if ( ! assertMinRole(Role.ADMIN)) return;
|
if ( ! assertMinRole(Rel.LEADER)) return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -14,8 +14,7 @@ import com.massivecraft.factions.FPlayer;
|
|||||||
import com.massivecraft.factions.FPlayers;
|
import com.massivecraft.factions.FPlayers;
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.struct.Relation;
|
import com.massivecraft.factions.struct.Rel;
|
||||||
import com.massivecraft.factions.struct.Role;
|
|
||||||
import com.massivecraft.factions.zcore.util.SmokeUtil;
|
import com.massivecraft.factions.zcore.util.SmokeUtil;
|
||||||
|
|
||||||
public class CmdHome extends FCommand
|
public class CmdHome extends FCommand
|
||||||
@ -56,7 +55,7 @@ public class CmdHome extends FCommand
|
|||||||
|
|
||||||
if ( ! myFaction.hasHome())
|
if ( ! myFaction.hasHome())
|
||||||
{
|
{
|
||||||
fme.msg("<b>You faction does not have a home. " + (fme.getRole().value < Role.MODERATOR.value ? "<i> Ask your leader to:" : "<i>You should:"));
|
fme.msg("<b>You faction does not have a home. " + (fme.getRole().isLessThan(Rel.OFFICER) ? "<i> Ask your leader to:" : "<i>You should:"));
|
||||||
fme.sendMessage(p.cmdBase.cmdSethome.getUseageTemplate());
|
fme.sendMessage(p.cmdBase.cmdSethome.getUseageTemplate());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -105,7 +104,7 @@ public class CmdHome extends FCommand
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
FPlayer fp = FPlayers.i.get(p);
|
FPlayer fp = FPlayers.i.get(p);
|
||||||
if (fme.getRelationTo(fp) != Relation.ENEMY)
|
if (fme.getRelationTo(fp) != Rel.ENEMY)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Location l = p.getLocation();
|
Location l = p.getLocation();
|
||||||
|
@ -2,7 +2,7 @@ package com.massivecraft.factions.cmd;
|
|||||||
|
|
||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.struct.Role;
|
import com.massivecraft.factions.struct.Rel;
|
||||||
|
|
||||||
public class CmdMod extends FCommand
|
public class CmdMod extends FCommand
|
||||||
{
|
{
|
||||||
@ -42,16 +42,16 @@ public class CmdMod extends FCommand
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (you.getRole() == Role.MODERATOR)
|
if (you.getRole() == Rel.OFFICER)
|
||||||
{
|
{
|
||||||
// Revoke
|
// Revoke
|
||||||
you.setRole(Role.NORMAL);
|
you.setRole(Rel.MEMBER);
|
||||||
myFaction.msg("%s<i> is no longer moderator in your faction.", you.describeTo(myFaction, true));
|
myFaction.msg("%s<i> is no longer moderator in your faction.", you.describeTo(myFaction, true));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Give
|
// Give
|
||||||
you.setRole(Role.MODERATOR);
|
you.setRole(Rel.OFFICER);
|
||||||
myFaction.msg("%s<i> was promoted to moderator in your faction.", you.describeTo(myFaction, true));
|
myFaction.msg("%s<i> was promoted to moderator in your faction.", you.describeTo(myFaction, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import com.massivecraft.factions.FLocation;
|
|||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.struct.Role;
|
import com.massivecraft.factions.struct.Rel;
|
||||||
|
|
||||||
|
|
||||||
public class CmdOwner extends FCommand
|
public class CmdOwner extends FCommand
|
||||||
@ -52,7 +52,7 @@ public class CmdOwner extends FCommand
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! hasBypass && !assertMinRole(Conf.ownedAreasModeratorsCanSet ? Role.MODERATOR : Role.ADMIN))
|
if ( ! hasBypass && !assertMinRole(Conf.ownedAreasModeratorsCanSet ? Rel.OFFICER : Rel.LEADER))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import com.massivecraft.factions.struct.Relation;
|
import com.massivecraft.factions.struct.Rel;
|
||||||
|
|
||||||
public class CmdRelationAlly extends FRelationCommand
|
public class CmdRelationAlly extends FRelationCommand
|
||||||
{
|
{
|
||||||
public CmdRelationAlly()
|
public CmdRelationAlly()
|
||||||
{
|
{
|
||||||
aliases.add("ally");
|
aliases.add("ally");
|
||||||
targetRelation = Relation.ALLY;
|
targetRelation = Rel.ALLY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import com.massivecraft.factions.struct.Relation;
|
import com.massivecraft.factions.struct.Rel;
|
||||||
|
|
||||||
public class CmdRelationEnemy extends FRelationCommand
|
public class CmdRelationEnemy extends FRelationCommand
|
||||||
{
|
{
|
||||||
public CmdRelationEnemy()
|
public CmdRelationEnemy()
|
||||||
{
|
{
|
||||||
aliases.add("enemy");
|
aliases.add("enemy");
|
||||||
targetRelation = Relation.ENEMY;
|
targetRelation = Rel.ENEMY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import com.massivecraft.factions.struct.Relation;
|
import com.massivecraft.factions.struct.Rel;
|
||||||
|
|
||||||
public class CmdRelationNeutral extends FRelationCommand
|
public class CmdRelationNeutral extends FRelationCommand
|
||||||
{
|
{
|
||||||
public CmdRelationNeutral()
|
public CmdRelationNeutral()
|
||||||
{
|
{
|
||||||
aliases.add("neutral");
|
aliases.add("neutral");
|
||||||
targetRelation = Relation.NEUTRAL;
|
targetRelation = Rel.NEUTRAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import com.massivecraft.factions.Conf;
|
|||||||
import com.massivecraft.factions.FLocation;
|
import com.massivecraft.factions.FLocation;
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.struct.Role;
|
import com.massivecraft.factions.struct.Rel;
|
||||||
|
|
||||||
public class CmdSethome extends FCommand
|
public class CmdSethome extends FCommand
|
||||||
{
|
{
|
||||||
@ -40,7 +40,7 @@ public class CmdSethome extends FCommand
|
|||||||
// Can the player set the home for this faction?
|
// Can the player set the home for this faction?
|
||||||
if (faction == myFaction)
|
if (faction == myFaction)
|
||||||
{
|
{
|
||||||
if ( ! Permission.SETHOME_ANY.has(sender) && ! assertMinRole(Role.MODERATOR)) return;
|
if ( ! Permission.SETHOME_ANY.has(sender) && ! assertMinRole(Rel.OFFICER)) return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -8,7 +8,7 @@ import com.massivecraft.factions.FPlayer;
|
|||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.struct.Role;
|
import com.massivecraft.factions.struct.Rel;
|
||||||
|
|
||||||
public class CmdShow extends FCommand
|
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 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;
|
if ( ! payForCommand(Conf.econCostShow, "to show faction information", "for showing faction information")) return;
|
||||||
|
|
||||||
Collection<FPlayer> admins = faction.getFPlayersWhereRole(Role.ADMIN);
|
Collection<FPlayer> admins = faction.getFPlayersWhereRole(Rel.LEADER);
|
||||||
Collection<FPlayer> mods = faction.getFPlayersWhereRole(Role.MODERATOR);
|
Collection<FPlayer> mods = faction.getFPlayersWhereRole(Rel.OFFICER);
|
||||||
Collection<FPlayer> normals = faction.getFPlayersWhereRole(Role.NORMAL);
|
Collection<FPlayer> normals = faction.getFPlayersWhereRole(Rel.MEMBER);
|
||||||
|
|
||||||
msg(p.txt.titleize(faction.getTag(fme)));
|
msg(p.txt.titleize(faction.getTag(fme)));
|
||||||
msg("<a>Description: <i>%s", faction.getDescription());
|
msg("<a>Description: <i>%s", faction.getDescription());
|
||||||
@ -98,11 +98,11 @@ public class CmdShow extends FCommand
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
listpart = otherFaction.getTag(fme)+p.txt.parse("<i>")+", ";
|
listpart = otherFaction.getTag(fme)+p.txt.parse("<i>")+", ";
|
||||||
if (otherFaction.getRelationTo(faction).isAlly())
|
if (otherFaction.getRelationTo(faction) == Rel.ALLY)
|
||||||
{
|
{
|
||||||
allyList += listpart;
|
allyList += listpart;
|
||||||
}
|
}
|
||||||
else if (otherFaction.getRelationTo(faction).isEnemy())
|
else if (otherFaction.getRelationTo(faction) == Rel.ENEMY)
|
||||||
{
|
{
|
||||||
enemyList += listpart;
|
enemyList += listpart;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import com.massivecraft.factions.integration.Econ;
|
|||||||
import com.massivecraft.factions.FLocation;
|
import com.massivecraft.factions.FLocation;
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.struct.Role;
|
import com.massivecraft.factions.struct.Rel;
|
||||||
|
|
||||||
public class CmdUnclaim extends FCommand
|
public class CmdUnclaim extends FCommand
|
||||||
{
|
{
|
||||||
@ -74,7 +74,7 @@ public class CmdUnclaim extends FCommand
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! assertMinRole(Role.MODERATOR))
|
if ( ! assertMinRole(Rel.OFFICER))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ import com.massivecraft.factions.FPlayers;
|
|||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
import com.massivecraft.factions.P;
|
import com.massivecraft.factions.P;
|
||||||
import com.massivecraft.factions.struct.Role;
|
import com.massivecraft.factions.struct.Rel;
|
||||||
import com.massivecraft.factions.zcore.MCommand;
|
import com.massivecraft.factions.zcore.MCommand;
|
||||||
|
|
||||||
|
|
||||||
@ -101,13 +101,13 @@ public abstract class FCommand extends MCommand<P>
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.senderMustBeModerator && ! fplayer.getRole().isAtLeast(Role.MODERATOR))
|
if (this.senderMustBeModerator && ! fplayer.getRole().isAtLeast(Rel.OFFICER))
|
||||||
{
|
{
|
||||||
sender.sendMessage(p.txt.parse("<b>Only faction moderators can %s.", this.getHelpShort()));
|
sender.sendMessage(p.txt.parse("<b>Only faction moderators can %s.", this.getHelpShort()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.senderMustBeAdmin && ! fplayer.getRole().isAtLeast(Role.ADMIN))
|
if (this.senderMustBeAdmin && ! fplayer.getRole().isAtLeast(Rel.LEADER))
|
||||||
{
|
{
|
||||||
sender.sendMessage(p.txt.parse("<b>Only faction admins can %s.", this.getHelpShort()));
|
sender.sendMessage(p.txt.parse("<b>Only faction admins can %s.", this.getHelpShort()));
|
||||||
return false;
|
return false;
|
||||||
@ -132,7 +132,7 @@ public abstract class FCommand extends MCommand<P>
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean assertMinRole(Role role)
|
public boolean assertMinRole(Rel role)
|
||||||
{
|
{
|
||||||
if (me == null) return true;
|
if (me == null) return true;
|
||||||
|
|
||||||
@ -285,16 +285,16 @@ public abstract class FCommand extends MCommand<P>
|
|||||||
return false;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (you.getRole().equals(Role.ADMIN))
|
if (you.getRole().equals(Rel.LEADER))
|
||||||
{
|
{
|
||||||
i.sendMessage(p.txt.parse("<b>Only the faction admin can do that."));
|
i.sendMessage(p.txt.parse("<b>Only the faction admin can do that."));
|
||||||
}
|
}
|
||||||
else if (i.getRole().equals(Role.MODERATOR))
|
else if (i.getRole().equals(Rel.OFFICER))
|
||||||
{
|
{
|
||||||
if ( i == you )
|
if ( i == you )
|
||||||
{
|
{
|
||||||
|
@ -6,11 +6,11 @@ import com.massivecraft.factions.Conf;
|
|||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
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 abstract class FRelationCommand extends FCommand
|
||||||
{
|
{
|
||||||
public Relation targetRelation;
|
public Rel targetRelation;
|
||||||
|
|
||||||
public FRelationCommand()
|
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;
|
if ( ! payForCommand(targetRelation.getRelationCost(), "to change a relation wish", "for changing a relation wish")) return;
|
||||||
|
|
||||||
myFaction.setRelationWish(them, targetRelation);
|
myFaction.setRelationWish(them, targetRelation);
|
||||||
Relation currentRelation = myFaction.getRelationTo(them, true);
|
Rel currentRelation = myFaction.getRelationTo(them, true);
|
||||||
ChatColor currentRelationColor = currentRelation.getColor();
|
ChatColor currentRelationColor = currentRelation.getColor();
|
||||||
if (targetRelation.value == currentRelation.value)
|
if (targetRelation.value == currentRelation.value)
|
||||||
{
|
{
|
||||||
@ -63,13 +63,13 @@ public abstract class FRelationCommand extends FCommand
|
|||||||
myFaction.msg(currentRelationColor+them.getTag()+"<i> were informed that you wish to be "+targetRelation.getColor()+targetRelation);
|
myFaction.msg(currentRelationColor+them.getTag()+"<i> were informed that you wish to be "+targetRelation.getColor()+targetRelation);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! targetRelation.isNeutral() && them.isPeaceful())
|
if ( targetRelation != Rel.NEUTRAL && them.isPeaceful())
|
||||||
{
|
{
|
||||||
them.msg("<i>This will have no effect while your faction is peaceful.");
|
them.msg("<i>This will have no effect while your faction is peaceful.");
|
||||||
myFaction.msg("<i>This will have no effect while their faction is peaceful.");
|
myFaction.msg("<i>This will have no effect while their faction is peaceful.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! targetRelation.isNeutral() && myFaction.isPeaceful())
|
if ( targetRelation != Rel.NEUTRAL && myFaction.isPeaceful())
|
||||||
{
|
{
|
||||||
them.msg("<i>This will have no effect while their faction is peaceful.");
|
them.msg("<i>This will have no effect while their faction is peaceful.");
|
||||||
myFaction.msg("<i>This will have no effect while your faction is peaceful.");
|
myFaction.msg("<i>This will have no effect while your faction is peaceful.");
|
||||||
|
@ -2,15 +2,15 @@ package com.massivecraft.factions.iface;
|
|||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
import com.massivecraft.factions.struct.Relation;
|
import com.massivecraft.factions.struct.Rel;
|
||||||
|
|
||||||
public interface RelationParticipator
|
public interface RelationParticipator
|
||||||
{
|
{
|
||||||
public String describeTo(RelationParticipator that);
|
public String describeTo(RelationParticipator that);
|
||||||
public String describeTo(RelationParticipator that, boolean ucfirst);
|
public String describeTo(RelationParticipator that, boolean ucfirst);
|
||||||
|
|
||||||
public Relation getRelationTo(RelationParticipator that);
|
public Rel getRelationTo(RelationParticipator that);
|
||||||
public Relation getRelationTo(RelationParticipator that, boolean ignorePeaceful);
|
public Rel getRelationTo(RelationParticipator that, boolean ignorePeaceful);
|
||||||
|
|
||||||
public ChatColor getColorTo(RelationParticipator to);
|
public ChatColor getColorTo(RelationParticipator to);
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ import com.massivecraft.factions.Factions;
|
|||||||
import com.massivecraft.factions.P;
|
import com.massivecraft.factions.P;
|
||||||
import com.massivecraft.factions.iface.EconomyParticipator;
|
import com.massivecraft.factions.iface.EconomyParticipator;
|
||||||
import com.massivecraft.factions.struct.Permission;
|
import com.massivecraft.factions.struct.Permission;
|
||||||
import com.massivecraft.factions.struct.Role;
|
import com.massivecraft.factions.struct.Rel;
|
||||||
import com.massivecraft.factions.util.RelationUtil;
|
import com.massivecraft.factions.util.RelationUtil;
|
||||||
|
|
||||||
public class Econ
|
public class Econ
|
||||||
@ -107,7 +107,7 @@ public class Econ
|
|||||||
if (i == fI && fI == fYou) return true;
|
if (i == fI && fI == fYou) return true;
|
||||||
|
|
||||||
// Factions can be controlled by members that are moderators... or any member if any member can withdraw.
|
// 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! ;,,;
|
// Otherwise you may not! ;,,;
|
||||||
i.msg("<h>%s<i> lack permission to controll <h>%s's<i> money.", i.describeTo(i, true), you.describeTo(i));
|
i.msg("<h>%s<i> lack permission to controll <h>%s's<i> money.", i.describeTo(i, true), you.describeTo(i));
|
||||||
|
46
src/com/massivecraft/factions/struct/FactionFlag.java
Normal file
46
src/com/massivecraft/factions/struct/FactionFlag.java
Normal file
@ -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;
|
||||||
|
}
|
||||||
|
}
|
17
src/com/massivecraft/factions/struct/FactionPlayerPerm.java
Normal file
17
src/com/massivecraft/factions/struct/FactionPlayerPerm.java
Normal file
@ -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,
|
||||||
|
}
|
119
src/com/massivecraft/factions/struct/Rel.java
Normal file
119
src/com/massivecraft/factions/struct/Rel.java
Normal file
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -5,17 +5,18 @@ import org.bukkit.ChatColor;
|
|||||||
import com.massivecraft.factions.Conf;
|
import com.massivecraft.factions.Conf;
|
||||||
|
|
||||||
|
|
||||||
public enum Relation
|
public enum RelationDEPR
|
||||||
{
|
{
|
||||||
MEMBER(3, "member"),
|
MEMBER(3, "member"),
|
||||||
ALLY(2, "ally"),
|
ALLY(2, "ally"),
|
||||||
NEUTRAL(1, "neutral"),
|
NEUTRAL(1, "neutral"),
|
||||||
ENEMY(0, "enemy");
|
ENEMY(0, "enemy"),
|
||||||
|
;
|
||||||
|
|
||||||
public final int value;
|
public final int value;
|
||||||
public final String nicename;
|
public final String nicename;
|
||||||
|
|
||||||
private Relation(final int value, final String nicename)
|
private RelationDEPR(final int value, final String nicename)
|
||||||
{
|
{
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.nicename = nicename;
|
this.nicename = nicename;
|
@ -2,7 +2,7 @@ package com.massivecraft.factions.struct;
|
|||||||
|
|
||||||
import com.massivecraft.factions.Conf;
|
import com.massivecraft.factions.Conf;
|
||||||
|
|
||||||
public enum Role
|
public enum RoleDEPR
|
||||||
{
|
{
|
||||||
ADMIN(2, "admin"),
|
ADMIN(2, "admin"),
|
||||||
MODERATOR(1, "moderator"),
|
MODERATOR(1, "moderator"),
|
||||||
@ -11,7 +11,7 @@ public enum Role
|
|||||||
public final int value;
|
public final int value;
|
||||||
public final String nicename;
|
public final String nicename;
|
||||||
|
|
||||||
private Role(final int value, final String nicename)
|
private RoleDEPR(final int value, final String nicename)
|
||||||
{
|
{
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.nicename = nicename;
|
this.nicename = nicename;
|
@ -6,7 +6,7 @@ import com.massivecraft.factions.Conf;
|
|||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
import com.massivecraft.factions.Faction;
|
import com.massivecraft.factions.Faction;
|
||||||
import com.massivecraft.factions.iface.RelationParticipator;
|
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;
|
import com.massivecraft.factions.zcore.util.TextUtil;
|
||||||
|
|
||||||
public class RelationUtil
|
public class RelationUtil
|
||||||
@ -62,32 +62,32 @@ public class RelationUtil
|
|||||||
return describeThatToMe(that, me, false);
|
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);
|
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);
|
Faction fthat = getFaction(that);
|
||||||
if (fthat == null) return Relation.NEUTRAL; // ERROR
|
if (fthat == null) return Rel.NEUTRAL; // ERROR
|
||||||
|
|
||||||
Faction fme = getFaction(me);
|
Faction fme = getFaction(me);
|
||||||
if (fme == null) return Relation.NEUTRAL; // ERROR
|
if (fme == null) return Rel.NEUTRAL; // ERROR
|
||||||
|
|
||||||
if (!fthat.isNormal() || !fme.isNormal())
|
if (!fthat.isNormal() || !fme.isNormal())
|
||||||
{
|
{
|
||||||
return Relation.NEUTRAL;
|
return Rel.NEUTRAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fthat.equals(fme))
|
if (fthat.equals(fme))
|
||||||
{
|
{
|
||||||
return Relation.MEMBER;
|
return Rel.MEMBER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ignorePeaceful && (fme.isPeaceful() || fthat.isPeaceful()))
|
if (!ignorePeaceful && (fme.isPeaceful() || fthat.isPeaceful()))
|
||||||
{
|
{
|
||||||
return Relation.NEUTRAL;
|
return Rel.NEUTRAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fme.getRelationWish(fthat).value >= fthat.getRelationWish(fme).value)
|
if (fme.getRelationWish(fthat).value >= fthat.getRelationWish(fme).value)
|
||||||
|
Loading…
Reference in New Issue
Block a user