diff options
author | snowleo <schneeleo@gmail.com> | 2011-11-29 00:30:06 +0100 |
---|---|---|
committer | snowleo <schneeleo@gmail.com> | 2011-11-29 00:30:06 +0100 |
commit | 4bacdb327a79bfa0c497b60d3487db3bcaca1ddb (patch) | |
tree | 3006ad03cbb96e9bc58bfbffa4112360144e13f3 | |
parent | 91cdff955ab8a8af0ff52474ea5de9584d6377c7 (diff) | |
download | Essentials-4bacdb327a79bfa0c497b60d3487db3bcaca1ddb.tar Essentials-4bacdb327a79bfa0c497b60d3487db3bcaca1ddb.tar.gz Essentials-4bacdb327a79bfa0c497b60d3487db3bcaca1ddb.tar.lz Essentials-4bacdb327a79bfa0c497b60d3487db3bcaca1ddb.tar.xz Essentials-4bacdb327a79bfa0c497b60d3487db3bcaca1ddb.zip |
Fix NPE when reading old player files
-rw-r--r-- | Essentials/src/com/earth2me/essentials/EssentialsConf.java | 24 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/UserMap.java | 7 |
2 files changed, 21 insertions, 10 deletions
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsConf.java b/Essentials/src/com/earth2me/essentials/EssentialsConf.java index b07c9710f..8b8b79279 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsConf.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsConf.java @@ -232,21 +232,25 @@ public class EssentialsConf extends Configuration Material.valueOf(getString(path + ".type", "AIR")), getInt(path + ".amount", 1), (short)getInt(path + ".damage", 0)); - List<String> enchants = getKeys(path + ".enchant"); - for (String enchant : enchants) + final List<String> enchants = getKeys(path + ".enchant"); + if (enchants != null) { - Enchantment enchantment = Enchantment.getByName(enchant.toUpperCase(Locale.ENGLISH)); - if (enchantment == null) { - continue; + for (String enchant : enchants) + { + final Enchantment enchantment = Enchantment.getByName(enchant.toUpperCase(Locale.ENGLISH)); + if (enchantment == null) + { + continue; + } + final int level = getInt(path + ".enchant." + enchant, enchantment.getStartLevel()); + stack.addUnsafeEnchantment(enchantment, level); } - int level = getInt(path+ ".enchant."+enchant, enchantment.getStartLevel()); - stack.addUnsafeEnchantment(enchantment, level); } return stack; /* - * , - * (byte)getInt(path + ".data", 0) - */ + * , + * (byte)getInt(path + ".data", 0) + */ } public void setProperty(final String path, final ItemStack stack) diff --git a/Essentials/src/com/earth2me/essentials/UserMap.java b/Essentials/src/com/earth2me/essentials/UserMap.java index c30d97214..8ac2c4a12 100644 --- a/Essentials/src/com/earth2me/essentials/UserMap.java +++ b/Essentials/src/com/earth2me/essentials/UserMap.java @@ -4,11 +4,14 @@ import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.collect.ConcurrentHashMultiset; +import com.google.common.util.concurrent.UncheckedExecutionException; import java.io.File; import java.util.Collections; import java.util.Locale; import java.util.Set; import java.util.concurrent.ExecutionException; +import java.util.logging.Level; +import java.util.logging.Logger; import org.bukkit.entity.Player; @@ -67,6 +70,10 @@ public class UserMap extends CacheLoader<String, User> implements IConf { throw new NullPointerException(); } + catch (UncheckedExecutionException ex) + { + throw new NullPointerException(); + } } @Override |