Fixed possible NPE in getPrefix()

This commit is contained in:
Jerome van der Sar 2013-12-01 15:18:05 +01:00
parent 9405604efc
commit ee39e89093
3 changed files with 37 additions and 35 deletions

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Sun Dec 01 13:41:29 CET 2013
build.number=646
#Sun Dec 01 15:18:04 CET 2013
build.number=647

View File

@ -54,7 +54,7 @@ public class Command_list extends TFM_Command
final List<String> names = new ArrayList<String>();
for (Player player : server.getOnlinePlayers())
{
boolean userSuperadmin = TFM_SuperadminList.isUserSuperadmin(player);
final boolean userSuperadmin = TFM_SuperadminList.isUserSuperadmin(player);
if (listFilter == ListFilter.ADMINS && !userSuperadmin)
{
@ -66,7 +66,7 @@ public class Command_list extends TFM_Command
if (userSuperadmin)
{
final TFM_Superadmin entry = TFM_SuperadminList.getAdminEntry(player.getName());
if (entry == null)
if (entry == null || !entry.isActivated())
{
prefix = ChatColor.GOLD + "[SA]";
}

View File

@ -421,35 +421,31 @@ public class TFM_Util
return "an " + ChatColor.YELLOW + ChatColor.UNDERLINE + "impostor" + ChatColor.RESET + ChatColor.AQUA + "!";
}
TFM_Superadmin entry = TFM_SuperadminList.getAdminEntry(sender.getName());
final TFM_Superadmin entry = TFM_SuperadminList.getAdminEntry(sender.getName());
if (entry != null)
if (entry != null && entry.isActivated())
{
if (entry.isActivated())
String loginMessage = entry.getCustomLoginMessage();
if (loginMessage != null)
{
String loginMessage = entry.getCustomLoginMessage();
if (!loginMessage.isEmpty())
{
return ChatColor.translateAlternateColorCodes('&', loginMessage);
}
}
if (loginMessage != null)
{
if (!loginMessage.isEmpty())
{
return ChatColor.translateAlternateColorCodes('&', loginMessage);
}
}
if (!entry.isSeniorAdmin() && entry.isTelnetAdmin())
{
return "a " + ChatColor.DARK_GREEN + "Super Telnet Admin" + ChatColor.AQUA + ".";
}
if (entry.isSeniorAdmin())
{
return "a " + ChatColor.LIGHT_PURPLE + "Senior Admin" + ChatColor.AQUA + ".";
}
else
{
return "a " + ChatColor.GOLD + "Super Admin" + ChatColor.AQUA + ".";
}
if (entry.isSeniorAdmin())
{
return "a " + ChatColor.LIGHT_PURPLE + "Senior Admin" + ChatColor.AQUA + ".";
}
else if (entry.isTelnetAdmin())
{
return "a " + ChatColor.DARK_GREEN + "Super Telnet Admin" + ChatColor.AQUA + ".";
}
else
{
return "a " + ChatColor.GOLD + "Super Admin" + ChatColor.AQUA + ".";
}
}
@ -759,7 +755,7 @@ public class TFM_Util
public static void downloadFile(String url, File output, boolean verbose) throws java.lang.Exception
{
URL website = new URL(url);
final URL website = new URL(url);
ReadableByteChannel rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(output);
fos.getChannel().transferFrom(rbc, 0, 1 << 24);
@ -794,19 +790,25 @@ public class TFM_Util
}
else
{
TFM_Superadmin entry = TFM_SuperadminList.getAdminEntry(sender.getName());
if (!entry.isSeniorAdmin() && entry.isTelnetAdmin())
{
prefix = ChatColor.DARK_GREEN + "(STA)";
final TFM_Superadmin entry = TFM_SuperadminList.getAdminEntry(sender.getName());
if (entry == null) {
return "";
}
else if (TFM_SuperadminList.isSeniorAdmin(sender))
if (entry.isSeniorAdmin())
{
prefix = ChatColor.LIGHT_PURPLE + "(SrA)";
}
else if (entry.isTelnetAdmin())
{
prefix = ChatColor.DARK_GREEN + "(STA)";
}
else
{
prefix = ChatColor.GOLD + "(SA)";
}
if (DEVELOPERS.contains(sender.getName()))
{
prefix = ChatColor.DARK_PURPLE + "(Dev)";