Skip to content

Commit

Permalink
Fixed improper rendering on teleportation
Browse files Browse the repository at this point in the history
- Removed unnecessary PlayerChangedWorldEvent listener (PlayerTeleportEvent also gets called)
- Fixed ImageRenderer#onPlayerTeleport()

> Related to #24
  • Loading branch information
josemmo committed Jan 16, 2022
1 parent 2b2086d commit 9c96c78
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -425,16 +425,16 @@ public void onPlayerRespawn(@NotNull PlayerRespawnEvent event) {
onPlayerLocationChange(event.getPlayer(), event.getPlayer().getLocation());
}

@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerChangedWorld(@NotNull PlayerChangedWorldEvent event) {
onPlayerLocationChange(event.getPlayer(), event.getPlayer().getLocation());
}

@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerTeleport(@NotNull PlayerTeleportEvent event) {
if (event.getTo() == null) return;
if (event.getFrom().getChunk().equals(event.getTo().getChunk())) return;
onPlayerLocationChange(event.getPlayer(), event.getTo());

// Wait until next server tick before handling location change
// This is necessary as teleport events get fired *before* teleporting the player
Bukkit.getScheduler().runTask(plugin, () -> {
onPlayerLocationChange(event.getPlayer(), event.getTo());
});
}

@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
Expand Down

0 comments on commit 9c96c78

Please sign in to comment.