diff options
author | snowleo <schneeleo@gmail.com> | 2011-11-18 20:15:26 +0100 |
---|---|---|
committer | snowleo <schneeleo@gmail.com> | 2011-11-18 20:15:26 +0100 |
commit | 85ef892f0e2ed41834f7af4b13db81aaeaa34f3b (patch) | |
tree | 2b279b9ce62aea4565b1315dd6056a116db5108f | |
parent | 11f02fb947180278aa39a1402e76f88ad9f1d25c (diff) | |
download | Essentials-85ef892f0e2ed41834f7af4b13db81aaeaa34f3b.tar Essentials-85ef892f0e2ed41834f7af4b13db81aaeaa34f3b.tar.gz Essentials-85ef892f0e2ed41834f7af4b13db81aaeaa34f3b.tar.lz Essentials-85ef892f0e2ed41834f7af4b13db81aaeaa34f3b.tar.xz Essentials-85ef892f0e2ed41834f7af4b13db81aaeaa34f3b.zip |
Null checks
3 files changed, 12 insertions, 9 deletions
diff --git a/Essentials/src/com/earth2me/essentials/ManagedFile.java b/Essentials/src/com/earth2me/essentials/ManagedFile.java index 673d8d835..9176024ae 100644 --- a/Essentials/src/com/earth2me/essentials/ManagedFile.java +++ b/Essentials/src/com/earth2me/essentials/ManagedFile.java @@ -129,12 +129,12 @@ public class ManagedFile try { String hash = reader.readLine(); - if (hash.matches("#[a-f0-9]{32}")) + if (hash != null && hash.matches("#[a-f0-9]{32}")) { hash = hash.substring(1); bais.reset(); final String versionline = reader.readLine(); - if (versionline.matches("#version: .+")) + if (versionline != null && versionline.matches("#version: .+")) { final String versioncheck = versionline.substring(10); if (!versioncheck.equalsIgnoreCase(version)) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java b/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java index 5ea0c3c85..6420bb196 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java @@ -101,6 +101,9 @@ public class Commandhelp extends EssentialsCommand while (bufferedReader.ready()) { final String line = bufferedReader.readLine(); + if (line == null) { + break; + } retval.add(line.replace('&', 'ยง')); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java b/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java index cbbf6a558..dce5faf41 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java @@ -55,7 +55,7 @@ public class Commandwarp extends EssentialsCommand { if (args.length < 2 || args[0].matches("[0-9]+")) { - warpList(null, args); + warpList(sender, args); throw new NoChargeException(); } User otherUser = ess.getUser(server.getPlayer(args[1])); @@ -68,7 +68,7 @@ public class Commandwarp extends EssentialsCommand } - private void warpList(User user, String[] args) throws Exception + private void warpList(CommandSender sender, String[] args) throws Exception { Warps warps = ess.getWarps(); if (warps.isEmpty()) @@ -77,13 +77,13 @@ public class Commandwarp extends EssentialsCommand } final List<String> warpNameList = new ArrayList<String>(warps.getWarpNames()); - if (user != null) + if (sender instanceof User) { final Iterator<String> iterator = warpNameList.iterator(); while (iterator.hasNext()) { final String warpName = iterator.next(); - if (ess.getSettings().getPerWarpPermission() && !user.isAuthorized("essentials.warp." + warpName)) + if (ess.getSettings().getPerWarpPermission() && !((User)sender).isAuthorized("essentials.warp." + warpName)) { iterator.remove(); } @@ -100,11 +100,11 @@ public class Commandwarp extends EssentialsCommand if (warpNameList.size() > WARPS_PER_PAGE) { - user.sendMessage(Util.format("warpsCount", warpNameList.size(), page, (int)Math.ceil(warpNameList.size() / (double)WARPS_PER_PAGE))); - user.sendMessage(warpList); + sender.sendMessage(Util.format("warpsCount", warpNameList.size(), page, (int)Math.ceil(warpNameList.size() / (double)WARPS_PER_PAGE))); + sender.sendMessage(warpList); } else { - user.sendMessage(Util.format("warps", warpList)); + sender.sendMessage(Util.format("warps", warpList)); } } |