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

133 lines
3.5 KiB
Java
Raw Normal View History

package com.massivecraft.factions;
import org.bukkit.ChatColor;
2013-04-22 09:41:48 +02:00
import com.massivecraft.factions.entity.MConf;
public enum Rel
{
2013-04-14 21:20:34 +02:00
// -------------------------------------------- //
// ENUM
// -------------------------------------------- //
LEADER (70, true, "your faction leader", "your faction leader", "", ""),
OFFICER (60, true, "an officer in your faction", "officers in your faction", "", ""),
MEMBER (50, true, "a member in your faction", "members in your faction", "your faction", "your factions"),
RECRUIT (45, true, "a recruit in your faction", "recruits in your faction", "", ""),
ALLY (40, true, "an ally", "allies", "an allied faction", "allied factions"),
TRUCE (30, true, "someone in truce with you", "those in truce with you", "a faction in truce", "factions in truce"),
NEUTRAL (20, false, "someone neutral to you", "those neutral to you", "a neutral faction", "neutral factions"),
ENEMY (10, false, "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
// -------------------------------------------- //
2013-04-25 16:54:55 +02:00
// TODO: Are not enums sorted without this?
2011-10-24 11:07:06 +02:00
private final int value;
2013-04-25 16:54:55 +02:00
public int getValue() { return this.value; }
// Used for friendly fire.
private final boolean friend;
public boolean isFriend() { return this.friend; }
2011-10-24 11:07:06 +02:00
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
// -------------------------------------------- //
private Rel(final int value, final boolean friend, final String descPlayerOne, final String descPlayerMany, final String descFactionOne, final String descFactionMany)
{
this.value = value;
this.friend = friend;
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 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 boolean isRank()
{
return this.isAtLeast(Rel.RECRUIT);
}
public ChatColor getColor()
{
if (this.isAtLeast(RECRUIT))
2013-04-22 09:41:48 +02:00
return MConf.get().colorMember;
else if (this == ALLY)
2013-04-22 09:41:48 +02:00
return MConf.get().colorAlly;
else if (this == NEUTRAL)
2013-04-22 09:41:48 +02:00
return MConf.get().colorNeutral;
2011-10-23 22:08:57 +02:00
else if (this == TRUCE)
2013-04-22 09:41:48 +02:00
return MConf.get().colorTruce;
else
2013-04-22 09:41:48 +02:00
return MConf.get().colorEnemy;
}
public String getPrefix()
{
if (this == LEADER)
{
return MConf.get().prefixLeader;
}
if (this == OFFICER)
{
return MConf.get().prefixOfficer;
}
if (this == MEMBER)
{
return MConf.get().prefixMember;
}
if (this == RECRUIT)
{
return MConf.get().prefixRecruit;
}
return "";
}
}