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;
|
2020-06-30 07:25:38 +00:00
|
|
|
import net.md_5.bungee.api.ChatColor;
|
2015-10-19 17:43:46 +00:00
|
|
|
|
2016-05-12 19:40:39 +00:00
|
|
|
public enum Rank implements Displayable
|
2015-10-19 17:43:46 +00:00
|
|
|
{
|
2020-06-30 07:25:38 +00:00
|
|
|
IMPOSTOR("an", "Impostor", Type.PLAYER, "Imp", ChatColor.YELLOW, null, false),
|
|
|
|
NON_OP("a", "Non-Op", Type.PLAYER, "", ChatColor.WHITE, null, false),
|
|
|
|
OP("an", "Operator", Type.PLAYER, "OP", ChatColor.GREEN, null, false),
|
2020-09-28 02:51:15 +00:00
|
|
|
NEW_ADMIN("a", "Moderator", Type.STAFF, "Mod", ChatColor.DARK_GREEN, org.bukkit.ChatColor.DARK_GREEN, true),
|
|
|
|
SENIOR_ADMIN("an", "Administrator", Type.STAFF, "Admin", ChatColor.GOLD, org.bukkit.ChatColor.GOLD, true),
|
|
|
|
NEW_ADMIN_CONSOLE("the", "Console", Type.STAFF_CONSOLE, "Console", ChatColor.DARK_PURPLE, null, false),
|
|
|
|
SENIOR_CONSOLE("the", "Console", Type.STAFF_CONSOLE, "Console", ChatColor.DARK_PURPLE, null, false);
|
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;
|
2020-05-29 10:14:21 +00:00
|
|
|
@Getter
|
2020-06-30 07:25:38 +00:00
|
|
|
private final org.bukkit.ChatColor teamColor;
|
|
|
|
@Getter
|
2020-05-29 10:14:21 +00:00
|
|
|
private final boolean hasTeam;
|
2015-10-19 17:43:46 +00:00
|
|
|
|
2020-08-15 16:35:48 +00:00
|
|
|
Rank(String determiner, String name, Type type, String abbr, ChatColor color, org.bukkit.ChatColor teamColor, Boolean hasTeam)
|
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;
|
2020-06-30 07:25:38 +00:00
|
|
|
this.teamColor = teamColor;
|
2020-05-29 10:14:21 +00:00
|
|
|
this.hasTeam = hasTeam;
|
2016-03-06 15:56:15 +00:00
|
|
|
}
|
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()
|
|
|
|
{
|
2020-07-09 22:18:29 +00:00
|
|
|
return determiner + " " + color + name;
|
2016-03-06 15:56:15 +00:00
|
|
|
}
|
|
|
|
|
2020-05-29 10:14:21 +00:00
|
|
|
@Override
|
|
|
|
public boolean hasTeam()
|
|
|
|
{
|
|
|
|
return hasTeam;
|
|
|
|
}
|
|
|
|
|
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()
|
|
|
|
{
|
2020-08-15 22:42:46 +00:00
|
|
|
return getType() == Type.STAFF_CONSOLE;
|
2016-03-06 15:56:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2020-08-15 16:35:48 +00:00
|
|
|
public boolean isStaff()
|
2016-03-06 15:56:15 +00:00
|
|
|
{
|
2020-08-15 22:42:46 +00:00
|
|
|
return getType() == Type.STAFF || getType() == Type.STAFF_CONSOLE;
|
2016-03-06 15:56:15 +00:00
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
2020-09-28 02:51:15 +00:00
|
|
|
case NEW_ADMIN:
|
|
|
|
case NEW_ADMIN_CONSOLE:
|
|
|
|
return NEW_ADMIN_CONSOLE;
|
|
|
|
case SENIOR_ADMIN:
|
|
|
|
case SENIOR_CONSOLE:
|
|
|
|
return SENIOR_CONSOLE;
|
2016-03-06 15:56:15 +00:00
|
|
|
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,
|
2020-08-15 22:42:46 +00:00
|
|
|
STAFF,
|
|
|
|
STAFF_CONSOLE;
|
2016-03-06 15:56:15 +00:00
|
|
|
|
2020-08-15 16:35:48 +00:00
|
|
|
public boolean isStaff()
|
2016-03-06 15:56:15 +00:00
|
|
|
{
|
|
|
|
return this != PLAYER;
|
|
|
|
}
|
|
|
|
}
|
2020-08-15 16:35:48 +00:00
|
|
|
}
|