Fixed null pointers for getUUID

This commit is contained in:
boy0001 2014-12-23 02:39:17 +11:00
parent d0876c60b0
commit e0adcb3b60
6 changed files with 27 additions and 3 deletions

View File

@ -63,6 +63,10 @@ import java.util.UUID;
} else { } else {
uuid = UUIDHandler.getUUID(args[1]); 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.denied.contains(uuid)) {
if (plot.owner == uuid) { if (plot.owner == uuid) {
PlayerFunctions.sendMessage(plr, C.ALREADY_OWNER); PlayerFunctions.sendMessage(plr, C.ALREADY_OWNER);

View File

@ -62,6 +62,10 @@ import java.util.UUID;
} else { } else {
uuid = UUIDHandler.getUUID(args[1]); 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.helpers.contains(uuid)) {
if (plot.owner == uuid) { if (plot.owner == uuid) {
PlayerFunctions.sendMessage(plr, C.ALREADY_OWNER); PlayerFunctions.sendMessage(plr, C.ALREADY_OWNER);

View File

@ -219,7 +219,7 @@ import java.util.UUID;
private String getPlayerName(final UUID uuid) { private String getPlayerName(final UUID uuid) {
if (uuid == null) { if (uuid == null) {
return uuid.toString(); return "unknown";
} }
if (uuid.equals(DBFunc.everyone) || uuid.toString().equalsIgnoreCase(DBFunc.everyone.toString())) { if (uuid.equals(DBFunc.everyone) || uuid.toString().equalsIgnoreCase(DBFunc.everyone.toString())) {
return "everyone"; return "everyone";

View File

@ -71,7 +71,15 @@ import java.util.UUID;
for (final PlotId id : plots) { for (final PlotId id : plots) {
final Plot current = PlotMain.getPlots(world).get(id); 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); PlotMain.updatePlot(current);
DBFunc.setOwner(current, current.owner); DBFunc.setOwner(current, current.owner);

View File

@ -63,6 +63,10 @@ import java.util.UUID;
} else { } else {
uuid = UUIDHandler.getUUID(args[1]); 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.trusted.contains(uuid)) {
if (plot.owner == uuid) { if (plot.owner == uuid) {
PlayerFunctions.sendMessage(plr, C.ALREADY_OWNER); PlayerFunctions.sendMessage(plr, C.ALREADY_OWNER);

View File

@ -51,7 +51,11 @@ public class list extends SubCommand {
* String name = Bukkit.getOfflinePlayer(id).getName(); if (name == * String name = Bukkit.getOfflinePlayer(id).getName(); if (name ==
* null) { return "none"; } return name; * null) { return "none"; } return name;
*/ */
return UUIDHandler.getName(id); String name = UUIDHandler.getName(id);
if (name == null) {
return "unknown";
}
return name;
} }
@Override @Override