Factions3/src/com/massivecraft/factions/Rel.java

166 lines
4.1 KiB
Java
Raw Normal View History

package com.massivecraft.factions;
import org.bukkit.ChatColor;
public enum Rel
{
2013-04-14 21:20:34 +02:00
// -------------------------------------------- //
// ENUM
// -------------------------------------------- //
LEADER (70, "your faction leader", "your faction leader", "", ""),
OFFICER (60, "an officer in your faction", "officers in your faction", "", ""),
MEMBER (50, "a member in your faction", "members in your faction", "your faction", "your factions"),
RECRUIT (45, "a recruit in your faction", "recruits in your faction", "", ""),
2011-10-24 11:07:06 +02:00
ALLY (40, "an ally", "allies", "an allied faction", "allied factions"),
TRUCE (30, "someone in truce with you", "those in truce with you", "a faction in truce", "factions in truce"),
NEUTRAL (20, "someone neutral to you", "those neutral to you", "a neutral faction", "neutral factions"),
ENEMY (10, "an enemy", "enemies", "an enemy faction", "enemy factions"),
2013-04-14 21:20:34 +02:00
// END OF LIST
;
2013-04-14 21:20:34 +02:00
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
2011-10-24 11:07:06 +02:00
private final int value;
private final String descPlayerOne;
public String getDescPlayerOne() { return this.descPlayerOne; }
2011-10-24 11:07:06 +02:00
private final String descPlayerMany;
public String getDescPlayerMany() { return this.descPlayerMany; }
private final String descFactionOne;
public String getDescFactionOne() { return this.descFactionOne; }
private final String descFactionMany;
public String getDescFactionMany() { return this.descFactionMany; }
2013-04-14 21:20:34 +02:00
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
2011-10-24 11:07:06 +02:00
private Rel(final int value, final String descPlayerOne, final String descPlayerMany, final String descFactionOne, final String descFactionMany)
{
this.value = value;
2011-10-24 11:07:06 +02:00
this.descPlayerOne = descPlayerOne;
this.descPlayerMany = descPlayerMany;
this.descFactionOne = descFactionOne;
this.descFactionMany = descFactionMany;
}
2013-04-14 21:20:34 +02:00
// -------------------------------------------- //
// UTIL
// -------------------------------------------- //
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 == 'r') return RECRUIT;
if (c == 'a') return ALLY;
if (c == 't') return TRUCE;
if (c == 'n') return NEUTRAL;
if (c == 'e') return ENEMY;
return null;
}
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;
}
2011-10-24 11:07:06 +02:00
public boolean isMoreThan(Rel rel)
{
return this.value > rel.value;
}
public ChatColor getColor()
{
if (this.isAtLeast(RECRUIT))
2013-04-09 13:15:25 +02:00
return ConfServer.colorMember;
else if (this == ALLY)
2013-04-09 13:15:25 +02:00
return ConfServer.colorAlly;
else if (this == NEUTRAL)
2013-04-09 13:15:25 +02:00
return ConfServer.colorNeutral;
2011-10-23 22:08:57 +02:00
else if (this == TRUCE)
2013-04-09 13:15:25 +02:00
return ConfServer.colorTruce;
else
2013-04-09 13:15:25 +02:00
return ConfServer.colorEnemy;
}
public String getPrefix()
{
if (this == LEADER)
{
2013-04-09 13:15:25 +02:00
return ConfServer.prefixLeader;
}
if (this == OFFICER)
{
2013-04-09 13:15:25 +02:00
return ConfServer.prefixOfficer;
}
if (this == MEMBER)
{
2013-04-09 13:15:25 +02:00
return ConfServer.prefixMember;
}
if (this == RECRUIT)
{
2013-04-09 13:15:25 +02:00
return ConfServer.prefixRecruit;
}
return "";
}
// TODO: ADD TRUCE!!!!
2011-10-23 22:08:57 +02:00
// TODO.... or remove it...
public double getRelationCost()
{
if (this == ENEMY)
2013-04-09 13:15:25 +02:00
return ConfServer.econCostEnemy;
else if (this == ALLY)
2013-04-09 13:15:25 +02:00
return ConfServer.econCostAlly;
2011-10-24 11:07:06 +02:00
else if (this == TRUCE)
2013-04-09 13:15:25 +02:00
return ConfServer.econCostTruce;
else
2013-04-09 13:15:25 +02:00
return ConfServer.econCostNeutral;
}
}