Plex/src/main/java/dev/plex/rank/enums/Rank.java

61 lines
1.9 KiB
Java
Raw Normal View History

2021-01-03 07:21:15 +00:00
package dev.plex.rank.enums;
import lombok.Getter;
import lombok.Setter;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.json.JSONObject;
2022-01-04 03:04:39 +00:00
@Getter
public enum Rank
{
2022-03-19 19:37:11 +00:00
IMPOSTOR(-1, "<aqua>an <yellow>Impostor<reset>", "Impostor", "<dark_gray>[<yellow>Imp<dark_gray>]", NamedTextColor.YELLOW),
NONOP(0, "a <white>Non-Op<reset>", "Non-Op", "", NamedTextColor.WHITE),
OP(1, "an <green>Op<reset>", "Operator", "<dark_gray>[<green>OP<dark_gray>]", NamedTextColor.GREEN),
ADMIN(2, "an <dark_green>Admin<reset>", "Admin", "<dark_gray>[<green>Admin<dark_gray>]", NamedTextColor.DARK_GREEN),
SENIOR_ADMIN(3, "a <gold>Senior Admin<reset>", "Senior Admin", "<dark_gray>[<gold>SrA<dark_gray>]", NamedTextColor.GOLD),
EXECUTIVE(4, "an <red>Executive<reset>", "Executive", "<dark_gray>[<red>Exec<dark_gray>]", NamedTextColor.RED);
private final int level;
@Setter
private final String loginMessage;
@Setter
private final String readable;
@Setter
private final String prefix;
@Getter
private final NamedTextColor color;
Rank(int level, String loginMessage, String readable, String prefix, NamedTextColor color)
{
this.level = level;
2020-10-28 03:49:56 +00:00
this.loginMessage = loginMessage;
this.readable = readable;
this.prefix = prefix;
this.color = color;
}
public boolean isAtLeast(Rank rank)
{
return this.level >= rank.getLevel();
}
public Component getPrefix()
{
return MiniMessage.miniMessage().deserialize(this.prefix);
}
public JSONObject toJSON()
2020-11-06 01:29:38 +00:00
{
JSONObject object = new JSONObject();
object.put("prefix", this.prefix);
object.put("loginMessage", this.loginMessage);
return new JSONObject().put(this.name(), object);
}
}