From bbf1bef888527d3e19fa846d4f6772abfd2648eb Mon Sep 17 00:00:00 2001 From: ementalo Date: Mon, 2 May 2011 22:51:57 +0000 Subject: [trunk]fix nullpointer on mails after you clear them git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1323 e251c2fe-e539-e718-e476-b85c1f46cddb --- .../src/com/earth2me/essentials/Essentials.java | 28 +++++++++++++--------- Essentials/src/com/earth2me/essentials/User.java | 1 - 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index 94e9f73bb..b905e6a89 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -56,15 +56,15 @@ public class Essentials extends JavaPlugin { return settings; } - + public void setupForTesting() throws IOException, InvalidDescriptionException { File dataFolder = File.createTempFile("essentialstest", ""); dataFolder.delete(); dataFolder.mkdir(); - logger.log(Level.INFO,"Using temp folder for testing:"); - logger.log(Level.INFO,dataFolder.toString()); - this.initialize(null, null, new PluginDescriptionFile(new FileReader(new File("src"+File.separator+"plugin.yml"))), dataFolder, null, null); + logger.log(Level.INFO, "Using temp folder for testing:"); + logger.log(Level.INFO, dataFolder.toString()); + this.initialize(null, null, new PluginDescriptionFile(new FileReader(new File("src" + File.separator + "plugin.yml"))), dataFolder, null, null); settings = new Settings(dataFolder); } @@ -78,7 +78,8 @@ public class Essentials extends JavaPlugin { setStatic(); EssentialsUpgrade upgrade = new EssentialsUpgrade(this.getDescription().getVersion(), this); - if (newWorldsLoaded) { + if (newWorldsLoaded) + { logger.log(Level.SEVERE, "New worlds have been loaded while upgrading files. The server will stop now, please restart it."); try { @@ -355,9 +356,12 @@ public class Essentials extends JavaPlugin if (user != null && !getSettings().isCommandDisabled("mail") && !commandLabel.equals("mail") && user.isAuthorized("essentials.mail")) { List mail = user.getMails(); - if (!mail.isEmpty()) + if (mail != null) { - user.sendMessage(ChatColor.RED + "You have " + mail.size() + " messages!§f Type §7/mail read§f to view your mail."); + if (mail.size() > 0) + { + user.sendMessage(ChatColor.RED + "You have " + mail.size() + " messages!§f Type §7/mail read§f to view your mail."); + } } } @@ -606,12 +610,14 @@ public class Essentials extends JavaPlugin } return null; } - - public void setIConomyFallback(boolean iConomyFallback) { + + public void setIConomyFallback(boolean iConomyFallback) + { this.iConomyFallback = iConomyFallback; } - - public boolean isIConomyFallbackEnabled() { + + public boolean isIConomyFallbackEnabled() + { return iConomyFallback; } } diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java index 4ca4b21d2..b3c7cce38 100644 --- a/Essentials/src/com/earth2me/essentials/User.java +++ b/Essentials/src/com/earth2me/essentials/User.java @@ -1,7 +1,6 @@ package com.earth2me.essentials; import com.earth2me.essentials.commands.IEssentialsCommand; -import java.text.DecimalFormat; import java.util.Calendar; import java.util.GregorianCalendar; import java.util.logging.Logger; -- cgit v1.2.3