mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2025-06-29 19:46:42 +00:00
1.16, overhaul of player data
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.rank;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
public interface Displayable
|
||||
{
|
||||
@ -13,12 +13,15 @@ public interface Displayable
|
||||
|
||||
public ChatColor getColor();
|
||||
|
||||
public org.bukkit.ChatColor getTeamColor();
|
||||
|
||||
public String getColoredName();
|
||||
|
||||
public String getColoredTag();
|
||||
|
||||
public String getColoredLoginMessage();
|
||||
|
||||
|
||||
public boolean hasTeam();
|
||||
|
||||
}
|
||||
|
@ -1,19 +1,19 @@
|
||||
package me.totalfreedom.totalfreedommod.rank;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.bukkit.ChatColor;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
public enum Rank implements Displayable
|
||||
{
|
||||
|
||||
IMPOSTOR("an", "Impostor", Type.PLAYER, "Imp", ChatColor.YELLOW, false),
|
||||
NON_OP("a", "Non-Op", Type.PLAYER, "", ChatColor.WHITE, false),
|
||||
OP("an", "Operator", Type.PLAYER, "OP", ChatColor.GREEN, false),
|
||||
SUPER_ADMIN("a", "Super Admin", Type.ADMIN, "SA", ChatColor.AQUA, true),
|
||||
TELNET_ADMIN("a", "Telnet Admin", Type.ADMIN, "STA", ChatColor.DARK_GREEN, true),
|
||||
SENIOR_ADMIN("a", "Senior Admin", Type.ADMIN, "SrA", ChatColor.GOLD, true),
|
||||
TELNET_CONSOLE("the", "Console", Type.ADMIN_CONSOLE, "Console", ChatColor.DARK_PURPLE, false),
|
||||
SENIOR_CONSOLE("the", "Console", Type.ADMIN_CONSOLE, "Console", ChatColor.DARK_PURPLE, false);
|
||||
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),
|
||||
SUPER_ADMIN("a", "Super Admin", Type.ADMIN, "SA", ChatColor.AQUA, org.bukkit.ChatColor.AQUA, true),
|
||||
TELNET_ADMIN("a", "Telnet Admin", Type.ADMIN, "STA", ChatColor.DARK_GREEN, org.bukkit.ChatColor.DARK_GREEN, true),
|
||||
SENIOR_ADMIN("a", "Senior Admin", Type.ADMIN, "SrA", ChatColor.GOLD, org.bukkit.ChatColor.GOLD, true),
|
||||
TELNET_CONSOLE("the", "Console", Type.ADMIN_CONSOLE, "Console", ChatColor.DARK_PURPLE, null, false),
|
||||
SENIOR_CONSOLE("the", "Console", Type.ADMIN_CONSOLE, "Console", ChatColor.DARK_PURPLE, null, false);
|
||||
@Getter
|
||||
private final Type type;
|
||||
@Getter
|
||||
@ -28,9 +28,11 @@ public enum Rank implements Displayable
|
||||
@Getter
|
||||
private final ChatColor color;
|
||||
@Getter
|
||||
private final org.bukkit.ChatColor teamColor;
|
||||
@Getter
|
||||
private final boolean hasTeam;
|
||||
|
||||
private Rank(String determiner, String name, Type type, String abbr, ChatColor color, Boolean hasTeam)
|
||||
private Rank(String determiner, String name, Type type, String abbr, ChatColor color, org.bukkit.ChatColor teamColor, Boolean hasTeam)
|
||||
{
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
@ -39,6 +41,7 @@ public enum Rank implements Displayable
|
||||
this.tag = abbr.isEmpty() ? "" : "[" + abbr + "]";
|
||||
this.coloredTag = abbr.isEmpty() ? "" : ChatColor.DARK_GRAY + "[" + color + abbr + ChatColor.DARK_GRAY + "]" + color;
|
||||
this.color = color;
|
||||
this.teamColor = teamColor;
|
||||
this.hasTeam = hasTeam;
|
||||
}
|
||||
|
||||
|
@ -5,10 +5,8 @@ import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.pravian.aero.util.ChatUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
@ -81,11 +79,17 @@ public class RankManager extends FreedomService
|
||||
}
|
||||
|
||||
// Master builders show up if they are not admins
|
||||
if (plugin.mbl.isMasterBuilder(player) && !plugin.al.isAdmin(player))
|
||||
if (plugin.pl.getData(player).isMasterBuilder() && !plugin.al.isAdmin(player))
|
||||
{
|
||||
return Title.MASTER_BUILDER;
|
||||
}
|
||||
|
||||
PlayerData playerData = plugin.pl.getData(player);
|
||||
if (!plugin.al.isAdmin(player) && playerData.isDonator())
|
||||
{
|
||||
return Title.DONATOR;
|
||||
}
|
||||
|
||||
return getRank(player);
|
||||
}
|
||||
|
||||
@ -145,7 +149,7 @@ public class RankManager extends FreedomService
|
||||
|
||||
public Rank getRank(Player player)
|
||||
{
|
||||
if (plugin.al.isAdminImpostor(player) || plugin.pv.isPlayerImpostor(player) || plugin.mbl.isMasterBuilderImpostor(player))
|
||||
if (plugin.al.isAdminImpostor(player) || plugin.pl.isPlayerImpostor(player))
|
||||
{
|
||||
return Rank.IMPOSTOR;
|
||||
}
|
||||
@ -159,6 +163,20 @@ public class RankManager extends FreedomService
|
||||
return player.isOp() ? Rank.OP : Rank.NON_OP;
|
||||
}
|
||||
|
||||
public String getTag(Player player, String defaultTag)
|
||||
{
|
||||
String tag = defaultTag;
|
||||
|
||||
PlayerData playerData = plugin.pl.getData(player);
|
||||
String t = playerData.getTag();
|
||||
if (t != null && !t.isEmpty())
|
||||
{
|
||||
tag = t;
|
||||
}
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
public void updateDisplay(Player player)
|
||||
{
|
||||
if (!player.isOnline())
|
||||
@ -166,18 +184,19 @@ public class RankManager extends FreedomService
|
||||
return;
|
||||
}
|
||||
FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||
if (plugin.al.isAdmin(player))
|
||||
PlayerData data = plugin.pl.getData(player);
|
||||
Displayable display = getDisplay(player);
|
||||
if (plugin.al.isAdmin(player) || data.isMasterBuilder() || data.isDonator() || FUtil.isDeveloper(player.getName()))
|
||||
{
|
||||
Displayable display = getDisplay(player);
|
||||
fPlayer.setTag(display.getColoredTag());
|
||||
String displayName = display.getColor() + player.getName();
|
||||
player.setPlayerListName(StringUtils.substring(displayName, 0, 16));
|
||||
player.setPlayerListName(displayName);
|
||||
}
|
||||
else
|
||||
{
|
||||
fPlayer.setTag(null);
|
||||
player.setPlayerListName(null);
|
||||
}
|
||||
fPlayer.setTag(getTag(player, display.getColoredTag()));
|
||||
updatePlayerTeam(player);
|
||||
plugin.pem.setPermissions(player);
|
||||
}
|
||||
@ -186,9 +205,8 @@ public class RankManager extends FreedomService
|
||||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
//plugin.pl.getData(player);
|
||||
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||
VPlayer target = plugin.pv.getVerificationPlayer(player);
|
||||
PlayerData target = plugin.pl.getData(player);
|
||||
|
||||
// Unban admins
|
||||
boolean isAdmin = plugin.al.isAdmin(player);
|
||||
@ -213,7 +231,7 @@ public class RankManager extends FreedomService
|
||||
}
|
||||
|
||||
// Handle impostors
|
||||
boolean isImpostor = plugin.al.isAdminImpostor(player) || plugin.pv.isPlayerImpostor(player) || plugin.mbl.isMasterBuilderImpostor(player);
|
||||
boolean isImpostor = plugin.al.isAdminImpostor(player) || plugin.pl.isPlayerImpostor(player);
|
||||
if (isImpostor)
|
||||
{
|
||||
FUtil.bcastMsg(ChatColor.AQUA + player.getName() + " is " + Rank.IMPOSTOR.getColoredLoginMessage());
|
||||
@ -221,11 +239,7 @@ public class RankManager extends FreedomService
|
||||
{
|
||||
FUtil.bcastMsg("Warning: " + player.getName() + " has been flagged as an admin impostor and has been frozen!", ChatColor.RED);
|
||||
}
|
||||
else if (plugin.mbl.isMasterBuilderImpostor(player))
|
||||
{
|
||||
FUtil.bcastMsg("Warning: " + player.getName() + " has been flagged as a Master Builder impostor and has been frozen!", ChatColor.RED);
|
||||
}
|
||||
else if (plugin.pv.isPlayerImpostor(player))
|
||||
else if (plugin.pl.isPlayerImpostor(player))
|
||||
{
|
||||
FUtil.bcastMsg("Warning: " + player.getName() + " has been flagged as a player impostor and has been frozen!", ChatColor.RED);
|
||||
}
|
||||
@ -240,7 +254,7 @@ public class RankManager extends FreedomService
|
||||
}
|
||||
|
||||
// Set display
|
||||
if (isAdmin || FUtil.DEVELOPERS.contains(player.getName()) || plugin.mbl.isMasterBuilder(player))
|
||||
if (isAdmin || FUtil.DEVELOPERS.contains(player.getName()) || plugin.pl.getData(player).isMasterBuilder() || plugin.pl.getData(player).isDonator())
|
||||
{
|
||||
final Displayable display = getDisplay(player);
|
||||
|
||||
@ -249,11 +263,11 @@ public class RankManager extends FreedomService
|
||||
updateDisplay(player);
|
||||
}
|
||||
|
||||
if (!plugin.pv.isPlayerImpostor(player) && target.getEnabled())
|
||||
if (!plugin.pl.isPlayerImpostor(player) && target.hasVerification())
|
||||
{
|
||||
if (target.getTag() != null)
|
||||
{
|
||||
plugin.pl.getPlayer(player).setTag(FUtil.colorize(target.getTag()));
|
||||
plugin.pl.getData(player).setTag(FUtil.colorize(target.getTag()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -282,25 +296,27 @@ public class RankManager extends FreedomService
|
||||
|
||||
public void updatePlayerTeam(Player player)
|
||||
{
|
||||
FLog.info("Updating team data...");
|
||||
Displayable display = getDisplay(player);
|
||||
Scoreboard scoreboard = server.getScoreboardManager().getMainScoreboard();
|
||||
Team team = scoreboard.getPlayerTeam(player);
|
||||
if (team != null && !display.hasTeam())
|
||||
if (!display.hasTeam())
|
||||
{
|
||||
FLog.info("Removing from team");
|
||||
team.removePlayer(player);
|
||||
if (team != null)
|
||||
{
|
||||
team.removePlayer(player);
|
||||
}
|
||||
return;
|
||||
}
|
||||
team = scoreboard.getTeam(display.toString());
|
||||
String name = StringUtils.substring(display.toString(), 0, 16);
|
||||
team = scoreboard.getTeam(name);
|
||||
if (team == null)
|
||||
{
|
||||
FLog.info("Creating team...");
|
||||
team = scoreboard.registerNewTeam(display.toString());
|
||||
FLog.info("Created team " + team.getName());
|
||||
team.setColor(display.getColor());
|
||||
team = scoreboard.registerNewTeam(name);
|
||||
team.setColor(display.getTeamColor());
|
||||
}
|
||||
if (!team.hasPlayer(player))
|
||||
{
|
||||
team.addPlayer(player);
|
||||
}
|
||||
team.addPlayer(player);
|
||||
FLog.info("Added player to team");
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,18 @@
|
||||
package me.totalfreedom.totalfreedommod.rank;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.bukkit.ChatColor;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
public enum Title implements Displayable
|
||||
{
|
||||
|
||||
MASTER_BUILDER("a", "Master Builder", ChatColor.DARK_AQUA, "MB", false),
|
||||
VERIFIED_ADMIN("a", "Verified Admin", ChatColor.LIGHT_PURPLE, "VA", false),
|
||||
ASSISTANT_EXECUTIVE("an", "Assistant Executive", ChatColor.RED, "Asst Exec", false),
|
||||
EXECUTIVE("an", "Executive", ChatColor.RED, "Exec", true),
|
||||
DEVELOPER("a", "Developer", ChatColor.DARK_PURPLE, "Dev", true),
|
||||
OWNER("the", "Owner", ChatColor.DARK_RED, "Owner", true);
|
||||
DONATOR("a", "Very Important Person", ChatColor.of("#ff5600"), org.bukkit.ChatColor.LIGHT_PURPLE, "VIP", true), // turn to orange in 1.16
|
||||
MASTER_BUILDER("a", "Master Builder", ChatColor.DARK_AQUA, org.bukkit.ChatColor.DARK_AQUA, "MB", true),
|
||||
VERIFIED_ADMIN("a", "Verified Admin", ChatColor.LIGHT_PURPLE, org.bukkit.ChatColor.LIGHT_PURPLE, "VA", false),
|
||||
ASSISTANT_EXECUTIVE("an", "Assistant Executive", ChatColor.RED, org.bukkit.ChatColor.RED, "Asst Exec", true),
|
||||
EXECUTIVE("an", "Executive", ChatColor.RED, org.bukkit.ChatColor.RED, "Exec", true),
|
||||
DEVELOPER("a", "Developer", ChatColor.DARK_PURPLE, org.bukkit.ChatColor.DARK_PURPLE, "Dev", true),
|
||||
OWNER("the", "Owner", ChatColor.of("#ff0000"), org.bukkit.ChatColor.DARK_RED, "Owner", true);
|
||||
|
||||
private final String determiner;
|
||||
@Getter
|
||||
@ -25,9 +26,11 @@ public enum Title implements Displayable
|
||||
@Getter
|
||||
private final ChatColor color;
|
||||
@Getter
|
||||
private final org.bukkit.ChatColor teamColor;
|
||||
@Getter
|
||||
private final boolean hasTeam;
|
||||
|
||||
private Title(String determiner, String name, ChatColor color, String tag, Boolean hasTeam)
|
||||
private Title(String determiner, String name, ChatColor color, org.bukkit.ChatColor teamColor, String tag, Boolean hasTeam)
|
||||
{
|
||||
this.determiner = determiner;
|
||||
this.name = name;
|
||||
@ -35,6 +38,7 @@ public enum Title implements Displayable
|
||||
this.abbr = tag;
|
||||
this.tag = "[" + tag + "]";
|
||||
this.color = color;
|
||||
this.teamColor = teamColor;
|
||||
this.hasTeam = hasTeam;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user