From 82f17b89b6f4de359f2ff43953150aad1b742570 Mon Sep 17 00:00:00 2001 From: RoboMWM Date: Sat, 22 Sep 2018 12:30:49 -0700 Subject: [PATCH] Have CheckForPortalTrapTask check metadata existence first If a player logs out then logs back in, and the task in the PlayerJoinEvent rescues him first and the player has sat in the rescue location for over 10 ticks (which should be within another portal), then this task will also attempt to rescue the player. Because it was using metadata in the log message though, it failed but also printed a stacktrace since the player's metadata was already removed. --- .../ryanhamshire/GriefPrevention/CheckForPortalTrapTask.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/ryanhamshire/GriefPrevention/CheckForPortalTrapTask.java b/src/main/java/me/ryanhamshire/GriefPrevention/CheckForPortalTrapTask.java index e98decf..324be29 100644 --- a/src/main/java/me/ryanhamshire/GriefPrevention/CheckForPortalTrapTask.java +++ b/src/main/java/me/ryanhamshire/GriefPrevention/CheckForPortalTrapTask.java @@ -49,9 +49,9 @@ class CheckForPortalTrapTask extends BukkitRunnable @Override public void run() { - if(player.isOnline() && player.getPortalCooldown() >= 10) + if(player.isOnline() && player.getPortalCooldown() >= 10 && player.hasMetadata("GP_PORTALRESCUE")) { - instance.AddLogEntry("Rescued " + player.getName() + " from a nether portal.\nTeleported from " + player.getLocation().toString() + " to " + ((Location)player.getMetadata("GP_PORTALRESCUE").get(0).value()).toString(), CustomLogEntryTypes.Debug); + instance.AddLogEntry("Rescued " + player.getName() + " from a nether portal.\nTeleported from " + player.getLocation().toString() + " to " + returnLocation.toString(), CustomLogEntryTypes.Debug); player.teleport(returnLocation); player.removeMetadata("GP_PORTALRESCUE", instance); }