Fixes potential null bugs
This commit is contained in:
parent
85334079da
commit
6d788b6f66
|
@ -18,7 +18,7 @@ import world.bentobox.warps.commands.WarpsCommand;
|
|||
import world.bentobox.warps.config.Settings;
|
||||
|
||||
/**
|
||||
* Addin to BSkyBlock that enables welcome warp signs
|
||||
* Addin to BentoBox that enables welcome warp signs
|
||||
* @author tastybento
|
||||
*
|
||||
*/
|
||||
|
@ -32,6 +32,11 @@ public class Warp extends Addon {
|
|||
*/
|
||||
private static final String LEVEL_ADDON_NAME = "Level";
|
||||
|
||||
/**
|
||||
* Permission prefix for non-game world operation
|
||||
*/
|
||||
public static final String WELCOME_WARP_SIGNS = "welcomewarpsigns";
|
||||
|
||||
/**
|
||||
* Warp panel Manager
|
||||
*/
|
||||
|
@ -220,8 +225,8 @@ public class Warp extends Addon {
|
|||
// Parse keys
|
||||
if (metaData.containsKey("world")) {
|
||||
world = Bukkit.getWorld((String)metaData.get("world"));
|
||||
if (world == null) return null;
|
||||
}
|
||||
if (world == null) return null;
|
||||
if (metaData.containsKey("uuid")) {
|
||||
try {
|
||||
uuid = UUID.fromString((String)metaData.get("uuid"));
|
||||
|
@ -234,11 +239,11 @@ public class Warp extends Addon {
|
|||
case "getSortedWarps":
|
||||
return getWarpSignsManager().getSortedWarps(world);
|
||||
case "getWarp":
|
||||
return getWarpSignsManager().getWarp(world, uuid);
|
||||
return uuid == null ? null : getWarpSignsManager().getWarp(world, uuid);
|
||||
case "getWarpMap":
|
||||
return getWarpSignsManager().getWarpMap(world);
|
||||
case "hasWarp":
|
||||
return getWarpSignsManager().hasWarp(world, uuid);
|
||||
return uuid == null ? null : getWarpSignsManager().hasWarp(world, uuid);
|
||||
case "listWarps":
|
||||
return getWarpSignsManager().listWarps(world);
|
||||
default:
|
||||
|
|
|
@ -65,7 +65,7 @@ public class WarpSignsListener implements Listener {
|
|||
if (list.containsValue(s.getLocation())) {
|
||||
// Welcome sign detected - check to see if it is
|
||||
// this player's sign
|
||||
String reqPerm = inWorld ? addon.getPermPrefix(e.getBlock().getWorld()) + "mod.removesign" : "welcomewarpsigns.mod.removesign";
|
||||
String reqPerm = inWorld ? addon.getPermPrefix(e.getBlock().getWorld()) + "mod.removesign" : Warp.WELCOME_WARP_SIGNS + ".mod.removesign";
|
||||
if ((list.containsKey(user.getUniqueId()) && list.get(user.getUniqueId()).equals(s.getLocation()))
|
||||
|| user.isOp() || user.hasPermission(reqPerm)) {
|
||||
addon.getWarpSignsManager().removeWarp(s.getLocation());
|
||||
|
@ -160,7 +160,7 @@ public class WarpSignsListener implements Listener {
|
|||
* @return true if player does not have the required perms, false otherwise
|
||||
*/
|
||||
private boolean noPerms(User user, World world, boolean inWorld) {
|
||||
String permReq = inWorld ? addon.getPermPrefix(world) + "island.addwarp" : "welcomewarpsigns.addwarp";
|
||||
String permReq = inWorld ? addon.getPermPrefix(world) + "island.addwarp" : Warp.WELCOME_WARP_SIGNS + ".addwarp";
|
||||
if (!(user.hasPermission(permReq))) {
|
||||
user.sendMessage("warps.error.no-permission");
|
||||
user.sendMessage("general.errors.no-permission", "[permission]", permReq);
|
||||
|
|
|
@ -31,7 +31,7 @@ public class WarpCommand extends CompositeCommand {
|
|||
public WarpCommand(Warp addon) {
|
||||
super(addon.getSettings().getWarpCommand());
|
||||
this.addon = addon;
|
||||
perm = "welcomewarpsigns";
|
||||
perm = Warp.WELCOME_WARP_SIGNS;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue