Fixed a neophyte bug

Custom login messages would be the same for anyone who logs in after the player with the same rank
This commit is contained in:
unknown 2013-12-03 20:50:20 +01:00
parent 75bc17cd8f
commit 34d15d4c96
3 changed files with 37 additions and 39 deletions

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit! #Build Number for ANT. Do not edit!
#Tue Dec 03 14:18:20 CET 2013 #Tue Dec 03 20:42:40 CET 2013
build.number=666 build.number=667

View File

@ -691,7 +691,7 @@ public class TFM_PlayerListener implements Listener
if (impostor || TFM_SuperadminList.isUserSuperadmin(player)) if (impostor || TFM_SuperadminList.isUserSuperadmin(player))
{ {
TFM_Util.bcastMsg(ChatColor.AQUA + player.getName() + " is " + TFM_PlayerRank.fromSender(player).getLoginMessage()); TFM_Util.bcastMsg(ChatColor.AQUA + player.getName() + " is " + TFM_PlayerRank.getLoginMessage(player));
if (impostor) if (impostor)
{ {
@ -720,7 +720,7 @@ public class TFM_PlayerListener implements Listener
} }
else if (TFM_Util.DEVELOPERS.contains(player.getName())) else if (TFM_Util.DEVELOPERS.contains(player.getName()))
{ {
TFM_Util.bcastMsg(ChatColor.AQUA + player.getName() + " is " + TFM_PlayerRank.fromSender(player).getLoginMessage()); TFM_Util.bcastMsg(ChatColor.AQUA + player.getName() + " is " + TFM_PlayerRank.getLoginMessage(player));
} }
if (TFM_ConfigEntry.ADMIN_ONLY_MODE.getBoolean()) if (TFM_ConfigEntry.ADMIN_ONLY_MODE.getBoolean())

View File

@ -7,6 +7,7 @@ import org.bukkit.entity.Player;
public enum TFM_PlayerRank public enum TFM_PlayerRank
{ {
DEVELOPER(ChatColor.DARK_PURPLE + "Developer", ChatColor.DARK_PURPLE + "[Dev]"),
IMPOSTOR("an " + ChatColor.YELLOW + ChatColor.UNDERLINE + "Impostor", ChatColor.YELLOW.toString() + ChatColor.UNDERLINE + "[IMP]"), IMPOSTOR("an " + ChatColor.YELLOW + ChatColor.UNDERLINE + "Impostor", ChatColor.YELLOW.toString() + ChatColor.UNDERLINE + "[IMP]"),
NON_OP("a " + ChatColor.GREEN + "Non-OP", ChatColor.GREEN.toString()), NON_OP("a " + ChatColor.GREEN + "Non-OP", ChatColor.GREEN.toString()),
OP("an " + ChatColor.RED + "OP", ChatColor.RED + "[OP]"), OP("an " + ChatColor.RED + "OP", ChatColor.RED + "[OP]"),
@ -24,6 +25,32 @@ public enum TFM_PlayerRank
this.prefix = prefix; this.prefix = prefix;
} }
public static String getLoginMessage(CommandSender sender)
{
if (!(sender instanceof Player))
{
return fromSender(sender).getLoginMessage();
}
final TFM_Superadmin entry = TFM_SuperadminList.getAdminEntry((Player) sender);
if (entry == null)
{
return fromSender(sender).getLoginMessage();
}
final String loginMessage = entry.getCustomLoginMessage();
if (loginMessage != null && !loginMessage.isEmpty())
{
return ChatColor.translateAlternateColorCodes('&', loginMessage);
}
else
{
return fromSender(sender).getLoginMessage();
}
}
public static TFM_PlayerRank fromSender(CommandSender sender) public static TFM_PlayerRank fromSender(CommandSender sender)
{ {
if (!(sender instanceof Player)) if (!(sender instanceof Player))
@ -36,6 +63,12 @@ public enum TFM_PlayerRank
return IMPOSTOR; return IMPOSTOR;
} }
if (DEVELOPERS.contains(sender.getName()))
{
return DEVELOPER;
}
final TFM_Superadmin entry = TFM_SuperadminList.getAdminEntry((Player) sender); final TFM_Superadmin entry = TFM_SuperadminList.getAdminEntry((Player) sender);
final TFM_PlayerRank rank; final TFM_PlayerRank rank;
@ -59,20 +92,6 @@ public enum TFM_PlayerRank
{ {
rank = SUPER; rank = SUPER;
} }
final String loginMessage = entry.getCustomLoginMessage();
if (loginMessage != null && !loginMessage.isEmpty())
{
rank.setLoginMessage(ChatColor.translateAlternateColorCodes('&', loginMessage));
}
else
{
if (DEVELOPERS.contains(sender.getName()))
{
rank.setLoginMessage("a " + ChatColor.DARK_PURPLE + "Developer");
}
}
} }
else else
{ {
@ -85,18 +104,7 @@ public enum TFM_PlayerRank
rank = NON_OP; rank = NON_OP;
} }
if (DEVELOPERS.contains(sender.getName()))
{
rank.setLoginMessage("a " + ChatColor.DARK_PURPLE + "Developer");
}
} }
if (DEVELOPERS.contains(sender.getName()))
{
rank.setPrefix(ChatColor.DARK_PURPLE + "[Dev]");
}
return rank; return rank;
} }
@ -105,16 +113,6 @@ public enum TFM_PlayerRank
return prefix; return prefix;
} }
public void setPrefix(String prefix)
{
this.prefix = prefix;
}
public void setLoginMessage(String rank)
{
this.loginMessage = rank;
}
public String getLoginMessage() public String getLoginMessage()
{ {
return loginMessage; return loginMessage;