2013-04-09 13:24:55 +02:00
|
|
|
package com.massivecraft.factions;
|
2011-10-23 17:30:41 +02:00
|
|
|
|
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
|
2013-04-22 09:41:48 +02:00
|
|
|
import com.massivecraft.factions.entity.MConf;
|
|
|
|
|
2011-10-23 17:30:41 +02:00
|
|
|
|
|
|
|
public enum Rel
|
|
|
|
{
|
2013-04-14 21:20:34 +02:00
|
|
|
// -------------------------------------------- //
|
|
|
|
// ENUM
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
2013-04-19 08:20:38 +02:00
|
|
|
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
|
2011-10-23 17:30:41 +02:00
|
|
|
;
|
|
|
|
|
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; }
|
2013-04-19 08:20:38 +02:00
|
|
|
|
|
|
|
// 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-23 17:30:41 +02:00
|
|
|
|
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
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
2013-04-19 08:20:38 +02:00
|
|
|
private Rel(final int value, final boolean friend, final String descPlayerOne, final String descPlayerMany, final String descFactionOne, final String descFactionMany)
|
2011-10-23 17:30:41 +02:00
|
|
|
{
|
|
|
|
this.value = value;
|
2013-04-19 08:20:38 +02:00
|
|
|
this.friend = friend;
|
2011-10-24 11:07:06 +02:00
|
|
|
this.descPlayerOne = descPlayerOne;
|
|
|
|
this.descPlayerMany = descPlayerMany;
|
|
|
|
this.descFactionOne = descFactionOne;
|
|
|
|
this.descFactionMany = descFactionMany;
|
2011-10-23 17:30:41 +02:00
|
|
|
}
|
|
|
|
|
2013-04-14 21:20:34 +02:00
|
|
|
// -------------------------------------------- //
|
|
|
|
// UTIL
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
2011-10-23 17:30:41 +02:00
|
|
|
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;
|
2013-01-06 21:44:29 +01:00
|
|
|
if (c == 'r') return RECRUIT;
|
2011-10-23 17:30:41 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2011-10-23 17:30:41 +02:00
|
|
|
public ChatColor getColor()
|
|
|
|
{
|
2013-01-06 21:44:29 +01:00
|
|
|
if (this.isAtLeast(RECRUIT))
|
2013-04-22 09:41:48 +02:00
|
|
|
return MConf.get().colorMember;
|
2011-10-23 17:30:41 +02:00
|
|
|
else if (this == ALLY)
|
2013-04-22 09:41:48 +02:00
|
|
|
return MConf.get().colorAlly;
|
2011-10-23 17:30:41 +02:00
|
|
|
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;
|
2011-10-23 17:30:41 +02:00
|
|
|
else
|
2013-04-22 09:41:48 +02:00
|
|
|
return MConf.get().colorEnemy;
|
2011-10-23 17:30:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getPrefix()
|
|
|
|
{
|
|
|
|
if (this == LEADER)
|
|
|
|
{
|
2013-04-22 09:51:19 +02:00
|
|
|
return MConf.get().prefixLeader;
|
2011-10-23 17:30:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (this == OFFICER)
|
|
|
|
{
|
2013-04-22 09:51:19 +02:00
|
|
|
return MConf.get().prefixOfficer;
|
2011-10-23 17:30:41 +02:00
|
|
|
}
|
|
|
|
|
2013-01-06 21:44:29 +01:00
|
|
|
if (this == MEMBER)
|
|
|
|
{
|
2013-04-22 09:51:19 +02:00
|
|
|
return MConf.get().prefixMember;
|
2013-01-06 21:44:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (this == RECRUIT)
|
|
|
|
{
|
2013-04-22 09:51:19 +02:00
|
|
|
return MConf.get().prefixRecruit;
|
2013-01-06 21:44:29 +01:00
|
|
|
}
|
|
|
|
|
2011-10-23 17:30:41 +02:00
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|