From 841e354d3572d11c00675c09ab9a864637ffd605 Mon Sep 17 00:00:00 2001 From: ZeroEpoch1969 <13510767+ZeroEpoch1969@users.noreply.github.com> Date: Sun, 11 Aug 2019 14:12:53 -0700 Subject: [PATCH] fix titles not showing up in login messages --- .../command/Command_myadmin.java | 2 +- .../totalfreedommod/rank/RankManager.java | 24 ++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_myadmin.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_myadmin.java index b9ac68a8..0b3da351 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_myadmin.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_myadmin.java @@ -150,7 +150,7 @@ public class Command_myadmin extends FreedomCommand FUtil.adminAction(sender.getName(), "Setting personal login message" + (init == null ? "" : " for " + targetPlayer.getName()), false); target.setLoginMessage(msg); msg((init == null ? "Your" : targetPlayer.getName() + "'s") + " login message is now: "); - msg("> " + ChatColor.AQUA + (msg.contains("%name%") ? "" : target.getName() + " is ") + FUtil.colorize(msg).replace("%name%", targetPlayer.getName()).replace("%rank%", target.getRank().getName()).replace("%coloredrank%", target.getRank().getColoredName())); + msg("> " + ChatColor.AQUA + (msg.contains("%name%") ? "" : target.getName() + " is ") + FUtil.colorize(msg).replace("%name%", targetPlayer.getName()).replace("%rank%", plugin.rm.getDisplay(target).getName()).replace("%coloredrank%", plugin.rm.getDisplay(target).getColoredName())); plugin.al.save(); plugin.al.updateTables(); return true; diff --git a/src/main/java/me/totalfreedom/totalfreedommod/rank/RankManager.java b/src/main/java/me/totalfreedom/totalfreedommod/rank/RankManager.java index 19313334..97ce3fb2 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/rank/RankManager.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/rank/RankManager.java @@ -81,6 +81,28 @@ public class RankManager extends FreedomService return getRank(player); } + public Displayable getDisplay(Admin admin) + { + // If the player's an owner, display that + if (ConfigEntry.SERVER_OWNERS.getList().contains(admin.getName())) + { + return Title.OWNER; + } + + // Developers always show up + if (FUtil.DEVELOPERS.contains(admin.getName())) + { + return Title.DEVELOPER; + } + + if (ConfigEntry.SERVER_EXECUTIVES.getList().contains(admin.getName())) + { + return Title.EXECUTIVE; + } + + return admin.getRank(); + } + public Rank getRank(CommandSender sender) { if (sender instanceof Player) @@ -218,7 +240,7 @@ public class RankManager extends FreedomService Admin admin = plugin.al.getAdmin(player); if (admin.hasLoginMessage()) { - loginMsg = ChatUtils.colorize(admin.getLoginMessage()).replace("%rank%", admin.getRank().getName()).replace("%coloredrank%", admin.getRank().getColoredName()); + loginMsg = ChatUtils.colorize(admin.getLoginMessage()).replace("%rank%", plugin.rm.getDisplay(admin).getName()).replace("%coloredrank%", plugin.rm.getDisplay(admin).getColoredName()); } } FUtil.bcastMsg(ChatColor.AQUA + (loginMsg.contains("%name%") ? "" : player.getName() + " is ") + FUtil.colorize(loginMsg).replace("%name%", player.getName()));