From b0102801114e0c4373ba6a91d9b8961cdffdc822 Mon Sep 17 00:00:00 2001 From: Ruakij Date: Mon, 10 May 2021 14:23:53 +0200 Subject: [PATCH] Fixed player being removed from ignoreList directly after teleport. --- .../listener/OnCustomPlayerMove.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/listener/OnCustomPlayerMove.java b/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/listener/OnCustomPlayerMove.java index 44a9063..5d4a7e8 100644 --- a/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/listener/OnCustomPlayerMove.java +++ b/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/listener/OnCustomPlayerMove.java @@ -6,6 +6,7 @@ import eu.ruekov.ruakij.LinkedBeaconTeleporters.customPlayerMoveEvent.CustomPlay import eu.ruekov.ruakij.LinkedBeaconTeleporters.customPlayerMoveEvent.CustomPlayerMoveEventListener; import eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter.LinkedBeaconTeleporter; import eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter.LinkedBeaconTeleporterBlock; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Player; @@ -29,10 +30,18 @@ public class OnCustomPlayerMove implements CustomPlayerMoveEventListener { Player p = e.player(); UUID uuid = p.getUniqueId(); - // If player found in ignoreList, remove - // FIXME: Will remove player from list, even though he should be ignored :/ - if(playerBeaconLocation.containsKey(uuid)) - playerBeaconLocation.remove(uuid); + // If player found in ignoreList, check if he stepped out of the Beacon-light + if(playerBeaconLocation.containsKey(uuid)) { + LinkedBeaconTeleporterBlock lbtBlock = playerBeaconLocation.get(uuid); + Location lbtBlockLoc = lbtBlock.block().getLocation(); + Location pLoc = p.getLocation(); + if(lbtBlockLoc.getBlockX() != pLoc.getBlockX() || lbtBlockLoc.getBlockZ() != pLoc.getBlockZ()){ + playerBeaconLocation.remove(uuid); + } + else + // Player still on beacon, ignore + return; + } // Check if player is on-top of a beacon Block block = Function.searchForMaterial(