From 2d74426b115c9975e9b37466d889b3a7b98c2ea2 Mon Sep 17 00:00:00 2001 From: tastybento Date: Sat, 4 Aug 2018 16:35:23 -0700 Subject: [PATCH] Better handling for when a warp sign is removed --- .../java/bentobox/addon/warps/WarpPanelManager.java | 1 + .../java/bentobox/addon/warps/WarpSignsManager.java | 4 ++-- .../bentobox/addon/warps/commands/WarpCommand.java | 12 ++++++------ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/bentobox/addon/warps/WarpPanelManager.java b/src/main/java/bentobox/addon/warps/WarpPanelManager.java index 5bd16ee..234423e 100644 --- a/src/main/java/bentobox/addon/warps/WarpPanelManager.java +++ b/src/main/java/bentobox/addon/warps/WarpPanelManager.java @@ -37,6 +37,7 @@ public class WarpPanelManager { .name(addon.getPlugin().getPlayers().getName(warpOwner)) .description(getSign(world, warpOwner)) .clickHandler((panel, clicker, click, slot) -> { { + clicker.closeInventory(); addon.getWarpSignsManager().warpPlayer(world, clicker, warpOwner); return true; } diff --git a/src/main/java/bentobox/addon/warps/WarpSignsManager.java b/src/main/java/bentobox/addon/warps/WarpSignsManager.java index bed7a7a..69d5c62 100644 --- a/src/main/java/bentobox/addon/warps/WarpSignsManager.java +++ b/src/main/java/bentobox/addon/warps/WarpSignsManager.java @@ -346,8 +346,8 @@ public class WarpSignsManager { final Location warpSpot = getWarp(world, owner); // Check if the warp spot is safe if (warpSpot == null) { - user.sendMessage("warps.error.NotReadyYet"); - addon.getLogger().warning("Null warp found, owned by " + addon.getPlugin().getPlayers().getName(owner)); + user.sendMessage("warps.error.does-not-exist"); + addon.getWarpSignsManager().removeWarp(world, owner); return; } // Find out if island is locked diff --git a/src/main/java/bentobox/addon/warps/commands/WarpCommand.java b/src/main/java/bentobox/addon/warps/commands/WarpCommand.java index 9e7fb1d..2720d26 100644 --- a/src/main/java/bentobox/addon/warps/commands/WarpCommand.java +++ b/src/main/java/bentobox/addon/warps/commands/WarpCommand.java @@ -18,11 +18,11 @@ import world.bentobox.bentobox.api.user.User; */ public class WarpCommand extends CompositeCommand { - private Warp plugin; + private Warp addon; public WarpCommand(Warp plugin, CompositeCommand bsbIslandCmd) { super(bsbIslandCmd, "warp"); - this.plugin = plugin; + this.addon = plugin; } @Override @@ -36,10 +36,10 @@ public class WarpCommand extends CompositeCommand { @Override public Optional> tabComplete(User user, String alias, List args) { List options = new ArrayList<>(); - final Set warpList = plugin.getWarpSignsManager().listWarps(getWorld()); + final Set warpList = addon.getWarpSignsManager().listWarps(getWorld()); for (UUID warp : warpList) { - options.add(plugin.getPlugin().getPlayers().getName(warp)); + options.add(addon.getPlugin().getPlayers().getName(warp)); } return Optional.of(options); @@ -49,7 +49,7 @@ public class WarpCommand extends CompositeCommand { public boolean execute(User user, String label, List args) { if (args.size() == 1) { // Warp somewhere command - Set warpList = plugin.getWarpSignsManager().listWarps(getWorld()); + Set warpList = addon.getWarpSignsManager().listWarps(getWorld()); if (warpList.isEmpty()) { user.sendMessage("warps.error.no-warps-yet"); user.sendMessage("warps.warpTip"); @@ -63,7 +63,7 @@ public class WarpCommand extends CompositeCommand { return false; } else { // Warp exists! - plugin.getWarpSignsManager().warpPlayer(getWorld(), user, foundWarp); + addon.getWarpSignsManager().warpPlayer(getWorld(), user, foundWarp); return true; } }