From e0adcb3b60efd4e699327e23d17db6d954d5a73d Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 23 Dec 2014 02:39:17 +1100 Subject: [PATCH] Fixed null pointers for getUUID --- .../com/intellectualcrafters/plot/commands/Denied.java | 4 ++++ .../intellectualcrafters/plot/commands/Helpers.java | 4 ++++ .../com/intellectualcrafters/plot/commands/Info.java | 2 +- .../intellectualcrafters/plot/commands/SetOwner.java | 10 +++++++++- .../intellectualcrafters/plot/commands/Trusted.java | 4 ++++ .../com/intellectualcrafters/plot/commands/list.java | 6 +++++- 6 files changed, 27 insertions(+), 3 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java index ccb7f7185..bf9e8fe2e 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java @@ -63,6 +63,10 @@ import java.util.UUID; } else { uuid = UUIDHandler.getUUID(args[1]); } + if (uuid == null) { + PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[1]); + return false; + } if (!plot.denied.contains(uuid)) { if (plot.owner == uuid) { PlayerFunctions.sendMessage(plr, C.ALREADY_OWNER); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java index 2a298b3dd..32503280c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java @@ -62,6 +62,10 @@ import java.util.UUID; } else { uuid = UUIDHandler.getUUID(args[1]); } + if (uuid == null) { + PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[1]); + return false; + } if (!plot.helpers.contains(uuid)) { if (plot.owner == uuid) { PlayerFunctions.sendMessage(plr, C.ALREADY_OWNER); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java index 2d3012df3..3db811c69 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java @@ -219,7 +219,7 @@ import java.util.UUID; private String getPlayerName(final UUID uuid) { if (uuid == null) { - return uuid.toString(); + return "unknown"; } if (uuid.equals(DBFunc.everyone) || uuid.toString().equalsIgnoreCase(DBFunc.everyone.toString())) { return "everyone"; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java index ff6ddc91a..b790d5e54 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java @@ -71,7 +71,15 @@ import java.util.UUID; for (final PlotId id : plots) { final Plot current = PlotMain.getPlots(world).get(id); - current.owner = getUUID(args[0]); + + UUID uuid = getUUID(args[0]); + + if (uuid == null) { + PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[1]); + return false; + } + + current.owner = uuid; PlotMain.updatePlot(current); DBFunc.setOwner(current, current.owner); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java index e221ebe9c..b07c697eb 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java @@ -63,6 +63,10 @@ import java.util.UUID; } else { uuid = UUIDHandler.getUUID(args[1]); } + if (uuid == null) { + PlayerFunctions.sendMessage(plr, C.INVALID_PLAYER, args[1]); + return false; + } if (!plot.trusted.contains(uuid)) { if (plot.owner == uuid) { PlayerFunctions.sendMessage(plr, C.ALREADY_OWNER); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java index 33fb952ea..7e0e4dd06 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java @@ -51,7 +51,11 @@ public class list extends SubCommand { * String name = Bukkit.getOfflinePlayer(id).getName(); if (name == * null) { return "none"; } return name; */ - return UUIDHandler.getName(id); + String name = UUIDHandler.getName(id); + if (name == null) { + return "unknown"; + } + return name; } @Override