2013-04-09 13:24:55 +02:00
|
|
|
package com.massivecraft.factions;
|
2011-10-23 17:30:41 +02:00
|
|
|
|
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;
|
2016-02-02 19:03:11 +01:00
|
|
|
import com.massivecraft.massivecore.collections.MassiveSet;
|
2017-03-24 13:05:58 +01:00
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.Set;
|
2013-04-22 09:41:48 +02:00
|
|
|
|
2017-03-11 20:27:40 +01:00
|
|
|
public enum Rel implements Colorized, Named, PermissionIdentifiable
|
2011-10-23 17:30:41 +02:00
|
|
|
{
|
2013-04-14 21:20:34 +02:00
|
|
|
// -------------------------------------------- //
|
|
|
|
// ENUM
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
2016-02-02 19:03:11 +01:00
|
|
|
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; } },
|
|
|
|
|
2016-02-02 19:03:11 +01:00
|
|
|
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; } },
|
|
|
|
|
2016-02-02 19:03:11 +01:00
|
|
|
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; } },
|
|
|
|
|
2016-02-02 19:03:11 +01:00
|
|
|
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; } },
|
|
|
|
|
2017-03-11 20:27:40 +01:00
|
|
|
FACTION(
|
|
|
|
"someone in your faction", "a faction member", "faction members",
|
|
|
|
"Faction"
|
|
|
|
) { @Override public ChatColor getColor() { return MConf.get().colorMember; } },
|
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
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
2016-02-02 19:03:11 +01:00
|
|
|
public int getValue() { return this.ordinal(); }
|
2013-04-19 08:20:38 +02:00
|
|
|
|
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; }
|
|
|
|
|
2016-02-02 19:03:11 +01:00
|
|
|
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(); }
|
2016-02-02 19:03:11 +01:00
|
|
|
|
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-23 17:30:41 +02:00
|
|
|
{
|
2011-10-24 11:07:06 +02:00
|
|
|
this.descPlayerOne = descPlayerOne;
|
|
|
|
this.descPlayerMany = descPlayerMany;
|
|
|
|
this.descFactionOne = descFactionOne;
|
|
|
|
this.descFactionMany = descFactionMany;
|
2017-03-24 14:03:29 +01:00
|
|
|
this.names = Collections.unmodifiableSet(new MassiveSet<>(names));
|
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 boolean isAtLeast(Rel rel)
|
|
|
|
{
|
2016-02-02 19:03:11 +01:00
|
|
|
return this.getValue() >= rel.getValue();
|
2011-10-23 17:30:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isAtMost(Rel rel)
|
|
|
|
{
|
2016-02-02 19:03:11 +01:00
|
|
|
return this.getValue() <= rel.getValue();
|
2011-10-23 17:30:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isLessThan(Rel rel)
|
|
|
|
{
|
2016-02-02 19:03:11 +01:00
|
|
|
return this.getValue() < rel.getValue();
|
2011-10-23 17:30:41 +02:00
|
|
|
}
|
|
|
|
|
2011-10-24 11:07:06 +02:00
|
|
|
public boolean isMoreThan(Rel rel)
|
|
|
|
{
|
2016-02-02 19:03:11 +01:00
|
|
|
return this.getValue() > rel.getValue();
|
2011-10-24 11:07:06 +02:00
|
|
|
}
|
|
|
|
|
2016-02-02 19:03:11 +01:00
|
|
|
// Used for friendly fire.
|
|
|
|
public boolean isFriend()
|
|
|
|
{
|
|
|
|
return this.isAtLeast(TRUCE);
|
|
|
|
}
|
|
|
|
|
2017-03-11 20:27:40 +01:00
|
|
|
@Override
|
|
|
|
public String getPermissibleId()
|
2011-10-23 17:30:41 +02:00
|
|
|
{
|
2017-03-11 20:27:40 +01:00
|
|
|
return this.getName().toLowerCase();
|
2011-10-23 17:30:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|