mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Fixed null pointers for getName
This commit is contained in:
parent
e0adcb3b60
commit
5c4f1332d6
@ -31,6 +31,7 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@ -228,7 +229,11 @@ import java.util.UUID;
|
||||
* OfflinePlayer plr = Bukkit.getOfflinePlayer(uuid); if (plr.getName()
|
||||
* == null) { return "unknown"; } return plr.getName();
|
||||
*/
|
||||
return UUIDHandler.getName(uuid);
|
||||
String name = UUIDHandler.getName(uuid);
|
||||
if (name == null) {
|
||||
return "unknown";
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
private Biome getBiomeAt(final Plot plot) {
|
||||
|
@ -47,10 +47,6 @@ public class list extends SubCommand {
|
||||
if (id == null) {
|
||||
return "none";
|
||||
}
|
||||
/*
|
||||
* String name = Bukkit.getOfflinePlayer(id).getName(); if (name ==
|
||||
* null) { return "none"; } return name;
|
||||
*/
|
||||
String name = UUIDHandler.getName(id);
|
||||
if (name == null) {
|
||||
return "unknown";
|
||||
|
@ -30,6 +30,7 @@ import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
@ -68,8 +69,15 @@ import java.util.UUID;
|
||||
return PlotMain.getWorldSettings(world);
|
||||
}
|
||||
|
||||
public static String getName(final UUID uuid) {
|
||||
return UUIDHandler.getName(uuid);
|
||||
private static String getName(final UUID id) {
|
||||
if (id == null) {
|
||||
return "none";
|
||||
}
|
||||
String name = UUIDHandler.getName(id);
|
||||
if (name == null) {
|
||||
return "unknown";
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
public static UUID getUUID(final String name) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.intellectualcrafters.plot.object;
|
||||
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@ -12,6 +13,7 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created 2014-11-18 for PlotSquared
|
||||
@ -40,8 +42,16 @@ public class InfoInventory implements InventoryHolder {
|
||||
return this.inventory;
|
||||
}
|
||||
|
||||
public String getName(UUID uuid) {
|
||||
String name = UUIDHandler.getName(this.plot.getOwner());
|
||||
if (name == null) {
|
||||
return "unknown";
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
public InfoInventory build() {
|
||||
final ItemStack generalInfo = getItem(Material.EMERALD, "&cPlot Info", "&cID: &6" + this.plot.getId().toString(), "&cOwner: &6" + UUIDHandler.getName(this.plot.getOwner()), "&cAlias: &6" + this.plot.settings.getAlias(), "&cBiome: &6" + this.plot.settings.getBiome().toString().replaceAll("_", "").toLowerCase(), "&cCan Build: &6" + this.plot.hasRights(this.player), "&cIs Denied: &6" + this.plot.deny_entry(this.player));
|
||||
final ItemStack generalInfo = getItem(Material.EMERALD, "&cPlot Info", "&cID: &6" + this.plot.getId().toString(), "&cOwner: &6" + getName(this.plot.getOwner()), "&cAlias: &6" + this.plot.settings.getAlias(), "&cBiome: &6" + this.plot.settings.getBiome().toString().replaceAll("_", "").toLowerCase(), "&cCan Build: &6" + this.plot.hasRights(this.player), "&cIs Denied: &6" + this.plot.deny_entry(this.player));
|
||||
final ItemStack helpers = getItem(Material.EMERALD, "&cHelpers", "&cAmount: &6" + this.plot.helpers.size(), "&8Click to view a list of the plot helpers");
|
||||
final ItemStack trusted = getItem(Material.EMERALD, "&cTrusted", "&cAmount: &6" + this.plot.trusted.size(), "&8Click to view a list of trusted players");
|
||||
final ItemStack denied = getItem(Material.EMERALD, "&cDenied", "&cAmount: &6" + this.plot.denied.size(), "&8Click to view a list of denied players");
|
||||
|
@ -251,7 +251,10 @@ import java.util.UUID;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void setSign(final World world, final String name, final Plot p) {
|
||||
public static void setSign(final World world, String name, final Plot p) {
|
||||
if (name == null) {
|
||||
name = "unknown";
|
||||
}
|
||||
final PlotManager manager = PlotMain.getPlotManager(world);
|
||||
final PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||
final Location loc = manager.getSignLoc(world, plotworld, p);
|
||||
|
Loading…
Reference in New Issue
Block a user