2015-11-15 23:32:04 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.rank;
|
2015-10-19 17:43:46 +00:00
|
|
|
|
2016-03-06 15:56:15 +00:00
|
|
|
import lombok.Getter;
|
2015-10-19 17:43:46 +00:00
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
|
2016-05-12 19:40:39 +00:00
|
|
|
public enum Rank implements Displayable
|
2015-10-19 17:43:46 +00:00
|
|
|
{
|
|
|
|
|
2016-05-12 19:40:39 +00:00
|
|
|
IMPOSTOR("an", "Impostor", Type.PLAYER, "Imp", ChatColor.YELLOW),
|
2018-05-24 23:25:22 +00:00
|
|
|
NON_OP("a", "Non-Op", Type.PLAYER, "", ChatColor.WHITE),
|
|
|
|
OP("an", "Op", Type.PLAYER, "OP", ChatColor.GREEN),
|
2016-05-12 19:40:39 +00:00
|
|
|
SUPER_ADMIN("a", "Super Admin", Type.ADMIN, "SA", ChatColor.AQUA),
|
|
|
|
TELNET_ADMIN("a", "Telnet Admin", Type.ADMIN, "STA", ChatColor.DARK_GREEN),
|
|
|
|
SENIOR_ADMIN("a", "Senior Admin", Type.ADMIN, "SrA", ChatColor.GOLD),
|
|
|
|
TELNET_CONSOLE("the", "Console", Type.ADMIN_CONSOLE, "Console", ChatColor.DARK_PURPLE),
|
|
|
|
SENIOR_CONSOLE("the", "Console", Type.ADMIN_CONSOLE, "Console", ChatColor.DARK_PURPLE);
|
2016-03-06 15:56:15 +00:00
|
|
|
@Getter
|
|
|
|
private final Type type;
|
|
|
|
@Getter
|
|
|
|
private final String name;
|
2018-04-19 14:29:19 +00:00
|
|
|
@Getter
|
|
|
|
private final String abbr;
|
2016-03-06 15:56:15 +00:00
|
|
|
private final String determiner;
|
|
|
|
@Getter
|
|
|
|
private final String tag;
|
|
|
|
@Getter
|
2016-05-12 19:40:39 +00:00
|
|
|
private final String coloredTag;
|
|
|
|
@Getter
|
2016-03-06 15:56:15 +00:00
|
|
|
private final ChatColor color;
|
2015-10-19 17:43:46 +00:00
|
|
|
|
2016-05-12 19:40:39 +00:00
|
|
|
private Rank(String determiner, String name, Type type, String abbr, ChatColor color)
|
2016-03-06 15:56:15 +00:00
|
|
|
{
|
|
|
|
this.type = type;
|
|
|
|
this.name = name;
|
2018-04-19 14:29:19 +00:00
|
|
|
this.abbr = abbr;
|
2016-03-06 15:56:15 +00:00
|
|
|
this.determiner = determiner;
|
2016-05-12 19:40:39 +00:00
|
|
|
this.tag = abbr.isEmpty() ? "" : "[" + abbr + "]";
|
2018-05-24 23:25:22 +00:00
|
|
|
this.coloredTag = abbr.isEmpty() ? "" : ChatColor.DARK_GRAY + "[" + color + abbr + ChatColor.DARK_GRAY + "]" + color;
|
2016-03-06 15:56:15 +00:00
|
|
|
this.color = color;
|
|
|
|
}
|
2015-10-19 17:43:46 +00:00
|
|
|
|
2016-03-06 15:56:15 +00:00
|
|
|
@Override
|
|
|
|
public String getColoredName()
|
|
|
|
{
|
2016-05-12 19:40:39 +00:00
|
|
|
return color + name;
|
2016-03-06 15:56:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getColoredLoginMessage()
|
|
|
|
{
|
2016-05-12 19:40:39 +00:00
|
|
|
return determiner + " " + color + ChatColor.ITALIC + name;
|
2016-03-06 15:56:15 +00:00
|
|
|
}
|
|
|
|
|
2018-04-19 14:29:19 +00:00
|
|
|
@Override
|
|
|
|
public String getAbbr()
|
|
|
|
{
|
|
|
|
return abbr;
|
|
|
|
}
|
|
|
|
|
2016-03-06 15:56:15 +00:00
|
|
|
public boolean isConsole()
|
|
|
|
{
|
|
|
|
return getType() == Type.ADMIN_CONSOLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getLevel()
|
|
|
|
{
|
|
|
|
return ordinal();
|
|
|
|
}
|
|
|
|
|
2016-05-12 19:40:39 +00:00
|
|
|
public boolean isAtLeast(Rank rank)
|
2016-03-06 15:56:15 +00:00
|
|
|
{
|
2016-05-12 19:40:39 +00:00
|
|
|
if (getLevel() < rank.getLevel())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!hasConsoleVariant() || !rank.hasConsoleVariant())
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return getConsoleVariant().getLevel() >= rank.getConsoleVariant().getLevel();
|
2016-03-06 15:56:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isAdmin()
|
|
|
|
{
|
|
|
|
return getType() == Type.ADMIN || getType() == Type.ADMIN_CONSOLE;
|
|
|
|
}
|
|
|
|
|
2016-05-12 19:40:39 +00:00
|
|
|
public boolean hasConsoleVariant()
|
2016-03-06 15:56:15 +00:00
|
|
|
{
|
|
|
|
return getConsoleVariant() != null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Rank getConsoleVariant()
|
|
|
|
{
|
|
|
|
switch (this)
|
|
|
|
{
|
|
|
|
case TELNET_ADMIN:
|
|
|
|
case TELNET_CONSOLE:
|
|
|
|
return TELNET_CONSOLE;
|
|
|
|
case SENIOR_ADMIN:
|
|
|
|
case SENIOR_CONSOLE:
|
|
|
|
return SENIOR_CONSOLE;
|
|
|
|
default:
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Rank findRank(String string)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
return Rank.valueOf(string.toUpperCase());
|
|
|
|
}
|
|
|
|
catch (Exception ignored)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
return Rank.NON_OP;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static enum Type
|
|
|
|
{
|
|
|
|
|
|
|
|
PLAYER,
|
|
|
|
ADMIN,
|
|
|
|
ADMIN_CONSOLE;
|
|
|
|
|
|
|
|
public boolean isAdmin()
|
|
|
|
{
|
|
|
|
return this != PLAYER;
|
|
|
|
}
|
|
|
|
}
|
2015-10-19 17:43:46 +00:00
|
|
|
|
|
|
|
}
|