-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix holograms disappearing when changing world/moving away from them
- Loading branch information
Showing
4 changed files
with
27 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
plugin/src/main/java/me/glicz/holograms/listener/PlayerChunkLoadListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package me.glicz.holograms.listener; | ||
|
||
import io.papermc.paper.event.packet.PlayerChunkLoadEvent; | ||
import me.glicz.holograms.GlitchHologramsAPI; | ||
import org.bukkit.Location; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
|
||
public class PlayerChunkLoadListener implements Listener { | ||
@EventHandler | ||
public void onPlayerChunkLoad(PlayerChunkLoadEvent e) { | ||
GlitchHologramsAPI.get().getRegisteredHolograms().forEach(hologram -> { | ||
if (!hologram.viewers().contains(e.getPlayer())) return; | ||
|
||
Location location = hologram.location(); | ||
if (e.getChunk().getX() == location.getBlockX() >> 4 && e.getChunk().getZ() == location.getBlockZ() >> 4) { | ||
hologram.show(e.getPlayer()); | ||
} | ||
}); | ||
} | ||
} |