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

148 lines
4.1 KiB
Java
Raw Normal View History

package com.massivecraft.factions;
import java.util.Collections;
import java.util.Set;
import org.bukkit.ChatColor;
2013-04-22 09:41:48 +02:00
import com.massivecraft.factions.entity.MConf;
2017-03-06 20:23:03 +01:00
import com.massivecraft.massivecore.Colorized;
import com.massivecraft.massivecore.Named;
import com.massivecraft.massivecore.collections.MassiveSet;
2013-04-22 09:41:48 +02:00
2017-03-06 20:23:03 +01:00
public enum Rel implements Colorized, Named
{
2013-04-14 21:20:34 +02:00
// -------------------------------------------- //
// ENUM
// -------------------------------------------- //
ENEMY(
"an enemy", "enemies", "an enemy faction", "enemy factions",
"Enemy"
2017-03-06 20:23:03 +01:00
) { @Override public ChatColor getColor() { return MConf.get().colorEnemy; } },
NEUTRAL(
"someone neutral to you", "those neutral to you", "a neutral faction", "neutral factions",
"Neutral"
2017-03-06 20:23:03 +01:00
) { @Override public ChatColor getColor() { return MConf.get().colorNeutral; } },
TRUCE(
"someone in truce with you", "those in truce with you", "a faction in truce", "factions in truce",
"Truce"
2017-03-06 20:23:03 +01:00
) { @Override public ChatColor getColor() { return MConf.get().colorTruce; } },
ALLY(
"an ally", "allies", "an allied faction", "allied factions",
"Ally"
2017-03-06 20:23:03 +01:00
) { @Override public ChatColor getColor() { return MConf.get().colorAlly; } },
RECRUIT(
"a recruit in your faction", "recruits in your faction", "", "",
"Recruit"
2017-03-06 20:23:03 +01:00
) { @Override public String getPrefix() { return MConf.get().prefixRecruit; } },
MEMBER(
"a member in your faction", "members in your faction", "your faction", "your factions",
"Member"
2017-03-06 20:23:03 +01:00
) { @Override public String getPrefix() { return MConf.get().prefixMember; } },
OFFICER(
"an officer in your faction", "officers in your faction", "", "",
"Officer", "Moderator"
2017-03-06 20:23:03 +01:00
) { @Override public String getPrefix() { return MConf.get().prefixOfficer; } },
LEADER(
"your faction leader", "your faction leader", "", "",
"Leader", "Admin", "Owner"
2017-03-06 20:23:03 +01:00
) { @Override public String getPrefix() { return MConf.get().prefixLeader; } },
2013-04-14 21:20:34 +02:00
// END OF LIST
;
2013-04-14 21:20:34 +02:00
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
public int getValue() { return this.ordinal(); }
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; }
private final Set<String> names;
public Set<String> getNames() { return this.names; }
2017-03-06 20:23:03 +01:00
@Override public String getName() { return this.getNames().iterator().next(); }
2013-04-14 21:20:34 +02:00
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
2017-03-06 20:23:03 +01:00
Rel(String descPlayerOne, String descPlayerMany, String descFactionOne, String descFactionMany, String... names)
{
2011-10-24 11:07:06 +02:00
this.descPlayerOne = descPlayerOne;
this.descPlayerMany = descPlayerMany;
this.descFactionOne = descFactionOne;
this.descFactionMany = descFactionMany;
this.names = Collections.unmodifiableSet(new MassiveSet<String>(names));
}
2017-03-06 20:23:03 +01:00
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public ChatColor getColor()
{
return MConf.get().colorMember;
}
2013-04-14 21:20:34 +02:00
// -------------------------------------------- //
// UTIL
// -------------------------------------------- //
public boolean isAtLeast(Rel rel)
{
return this.getValue() >= rel.getValue();
}
public boolean isAtMost(Rel rel)
{
return this.getValue() <= rel.getValue();
}
public boolean isLessThan(Rel rel)
{
return this.getValue() < rel.getValue();
}
2011-10-24 11:07:06 +02:00
public boolean isMoreThan(Rel rel)
{
return this.getValue() > rel.getValue();
2011-10-24 11:07:06 +02:00
}
public boolean isRank()
{
return this.isAtLeast(Rel.RECRUIT);
}
// Used for friendly fire.
public boolean isFriend()
{
return this.isAtLeast(TRUCE);
}
public String getPrefix()
{
return "";
}
}