Properly remove wander waypoint marker

This commit is contained in:
fullwall 2020-01-12 00:33:43 +09:00
parent a0e3b23bc3
commit 41f4c6e1b4

View File

@ -32,8 +32,8 @@ import net.citizensnpcs.util.Messages;
import net.citizensnpcs.util.Util;
/**
* A wandering waypoint provider that wanders between either a box centered at the current location or inside a region
* defined by a list of boxes.
* A wandering waypoint provider that wanders between either a box centered at
* the current location or inside a region defined by a list of boxes.
*/
public class WanderWaypointProvider
implements WaypointProvider, Supplier<PhTreeSolid<Boolean>>, Function<NPC, Location> {
@ -184,7 +184,8 @@ public class WanderWaypointProvider
@EventHandler(ignoreCancelled = true)
public void onPlayerInteract(PlayerInteractEvent event) {
if (!event.getPlayer().equals(sender) || event.getAction() == Action.PHYSICAL || !npc.isSpawned()
|| event.getPlayer().getWorld() != npc.getEntity().getWorld() || Util.isOffHand(event))
|| !editingRegions || event.getPlayer().getWorld() != npc.getEntity().getWorld()
|| Util.isOffHand(event))
return;
if (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_AIR) {
if (event.getClickedBlock() == null)
@ -209,6 +210,7 @@ public class WanderWaypointProvider
if (!event.getRightClicked().hasMetadata("wandermarker"))
return;
regionCentres.remove(event.getRightClicked().getMetadata("wandermarker").get(0).value());
markers.removeMarker((Location) event.getRightClicked().getMetadata("wandermarker").get(0).value());
Messaging.sendTr(sender, Messages.WANDER_WAYPOINTS_REMOVED_REGION,
formatLoc((Location) event.getRightClicked().getMetadata("wandermarker").get(0).value()),
regionCentres.size());