mirror of
https://github.com/plexusorg/Plex.git
synced 2025-06-29 14:56:43 +00:00
Major changes
- Convert prefixes to Component - Styling improvements to the list command - Fix tab completing on plex command - Allow console to check ranks of other players - Add coloring in tab for admins - Add color field to ranks and titles - Fix debug logging not working
This commit is contained in:
@ -12,6 +12,8 @@ import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.SneakyThrows;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.json.JSONTokener;
|
||||
@ -88,9 +90,9 @@ public class RankManager
|
||||
}
|
||||
}
|
||||
|
||||
public String getPrefix(PlexPlayer player)
|
||||
public Component getPrefix(PlexPlayer player)
|
||||
{
|
||||
if (!player.getPrefix().isEmpty())
|
||||
if (Component.IS_NOT_EMPTY.test(player.getPrefix()))
|
||||
{
|
||||
return player.getPrefix();
|
||||
}
|
||||
@ -110,7 +112,7 @@ public class RankManager
|
||||
{
|
||||
return player.getRankFromString().getPrefix();
|
||||
}
|
||||
return "";
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getLoginMessage(PlexPlayer player)
|
||||
@ -138,6 +140,27 @@ public class RankManager
|
||||
return "";
|
||||
}
|
||||
|
||||
public NamedTextColor getColor(PlexPlayer player)
|
||||
{
|
||||
if (Plex.get().config.contains("titles.owners") && Plex.get().config.getStringList("titles.owners").contains(player.getName()))
|
||||
{
|
||||
return Title.OWNER.getColor();
|
||||
}
|
||||
if (PlexUtils.DEVELOPERS.contains(player.getUuid())) // don't remove or we will front door ur mother
|
||||
{
|
||||
return Title.DEV.getColor();
|
||||
}
|
||||
if (Plex.get().config.contains("titles.masterbuilders") && Plex.get().config.getStringList("titles.masterbuilders").contains(player.getName()))
|
||||
{
|
||||
return Title.MASTER_BUILDER.getColor();
|
||||
}
|
||||
if (Plex.get().getSystem().equalsIgnoreCase("ranks") && isAdmin(player))
|
||||
{
|
||||
return player.getRankFromString().getColor();
|
||||
}
|
||||
return NamedTextColor.WHITE;
|
||||
}
|
||||
|
||||
public boolean isAdmin(PlexPlayer plexPlayer)
|
||||
{
|
||||
return !plexPlayer.getRank().isEmpty() && plexPlayer.getRankFromString().isAtLeast(Rank.ADMIN);
|
||||
|
@ -1,22 +1,21 @@
|
||||
package dev.plex.rank.enums;
|
||||
|
||||
import dev.plex.util.PlexUtils;
|
||||
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 net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.json.JSONObject;
|
||||
|
||||
@Getter
|
||||
public enum Rank
|
||||
{
|
||||
IMPOSTOR(-1, ChatColor.AQUA + "an " + ChatColor.YELLOW + "Impostor", "Impostor", "&8[&eImp&8]"),
|
||||
NONOP(0, "a " + ChatColor.WHITE + "Non-Op", "Non-Op", ""),
|
||||
OP(1, "an " + ChatColor.GREEN + "Operator", "Operator", "&8[&aOP&8]"),
|
||||
ADMIN(2, "an " + ChatColor.DARK_GREEN + "Admin", "Admin", "&8[&2Admin&8]"),
|
||||
SENIOR_ADMIN(3, "a " + ChatColor.GOLD + "Senior Admin", "Senior Admin", "&8[&6SrA&8]"),
|
||||
EXECUTIVE(4, "an " + ChatColor.RED + "Executive", "Executive", "&8[&cExec&8]");
|
||||
IMPOSTOR(-1, "<aqua>an <yellow>Impostor", "Impostor", "<dark_gray>[<yellow>Imp<dark_gray>]", NamedTextColor.YELLOW),
|
||||
NONOP(0, "a <white>Non-Op", "Non-Op", "", NamedTextColor.WHITE),
|
||||
OP(1, "an <green>Op", "Operator", "<dark_gray>[<green>OP<dark_gray>]", NamedTextColor.GREEN),
|
||||
ADMIN(2, "an <dark_green>Admin", "Admin", "<dark_gray>[<green>Admin<dark_gray>]", NamedTextColor.DARK_GREEN),
|
||||
SENIOR_ADMIN(3, "a <gold>Senior Admin", "Senior Admin", "<dark_gray>[<gold>SrA<dark_gray>]", NamedTextColor.GOLD),
|
||||
EXECUTIVE(4, "an <red>Executive", "Executive", "<dark_gray>[<red>Exec<dark_gray>]", NamedTextColor.RED);
|
||||
|
||||
private final int level;
|
||||
|
||||
@ -29,12 +28,16 @@ public enum Rank
|
||||
@Setter
|
||||
private String prefix;
|
||||
|
||||
Rank(int level, String loginMessage, String readable, String prefix)
|
||||
@Getter
|
||||
private NamedTextColor color;
|
||||
|
||||
Rank(int level, String loginMessage, String readable, String prefix, NamedTextColor color)
|
||||
{
|
||||
this.level = level;
|
||||
this.loginMessage = loginMessage;
|
||||
this.readable = readable;
|
||||
this.prefix = prefix;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public boolean isAtLeast(Rank rank)
|
||||
@ -42,9 +45,9 @@ public enum Rank
|
||||
return this.level >= rank.getLevel();
|
||||
}
|
||||
|
||||
public String getPrefix()
|
||||
public Component getPrefix()
|
||||
{
|
||||
return PlexUtils.colorize(this.prefix);
|
||||
return MiniMessage.miniMessage().deserialize(this.prefix);
|
||||
}
|
||||
|
||||
public JSONObject toJSON()
|
||||
|
@ -2,17 +2,17 @@ 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 net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.json.JSONObject;
|
||||
|
||||
@Getter
|
||||
public enum Title
|
||||
{
|
||||
MASTER_BUILDER(0, ChatColor.AQUA + "a " + ChatColor.DARK_AQUA + "Master Builder", "Master Builder", "&8[&3Master Builder&8]"),
|
||||
DEV(1, ChatColor.AQUA + "a " + ChatColor.DARK_PURPLE + "Developer", "Developer", "&8[&5Developer&8]"),
|
||||
OWNER(2, ChatColor.AQUA + "an " + ChatColor.BLUE + "Owner", "Owner", "&8[&9Owner&8]");
|
||||
MASTER_BUILDER(0, "<aqua>a <dark_aqua>Master Builder", "Master Builder", "<dark_gray>[<dark_aqua>Master Builder<dark_gray>]", NamedTextColor.DARK_AQUA),
|
||||
DEV(1, "<aqua>a <dark_purple>Developer", "Developer", "<dark_gray>[<dark_purple>Developer<dark_gray>]", NamedTextColor.DARK_PURPLE),
|
||||
OWNER(2, "<aqua>an <blue>Owner", "Owner", "<dark_gray>[<blue>Owner<dark_gray>]", NamedTextColor.BLUE);
|
||||
|
||||
private final int level;
|
||||
|
||||
@ -25,17 +25,21 @@ public enum Title
|
||||
@Setter
|
||||
private String prefix;
|
||||
|
||||
Title(int level, String loginMessage, String readable, String prefix)
|
||||
@Getter
|
||||
private NamedTextColor color;
|
||||
|
||||
Title(int level, String loginMessage, String readable, String prefix, NamedTextColor color)
|
||||
{
|
||||
this.level = level;
|
||||
this.loginMessage = loginMessage;
|
||||
this.readable = readable;
|
||||
this.prefix = prefix;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public String getPrefix()
|
||||
public Component getPrefix()
|
||||
{
|
||||
return MiniMessage.miniMessage().serialize(LegacyComponentSerializer.legacyAmpersand().deserialize(this.prefix));
|
||||
return MiniMessage.miniMessage().deserialize(this.prefix);
|
||||
}
|
||||
|
||||
public JSONObject toJSON()
|
||||
|
Reference in New Issue
Block a user