Fixed hologram bug
This commit is contained in:
@@ -18,6 +18,7 @@ import com.willfp.ecocrates.converters.impl.SpecializedCratesConverter
|
||||
import com.willfp.ecocrates.crate.CrateKeyListener
|
||||
import com.willfp.ecocrates.crate.Crates
|
||||
import com.willfp.ecocrates.crate.placed.CrateDisplay
|
||||
import com.willfp.ecocrates.crate.placed.HologramBugFixer
|
||||
import com.willfp.ecocrates.crate.placed.PlacedCrates
|
||||
import com.willfp.ecocrates.display.KeyDisplay
|
||||
import com.willfp.ecocrates.reward.Rewards
|
||||
@@ -110,7 +111,8 @@ class EcoCratesPlugin : EcoPlugin() {
|
||||
override fun loadListeners(): List<Listener> {
|
||||
return listOf(
|
||||
PlacedCrateListener(this),
|
||||
CrateKeyListener()
|
||||
CrateKeyListener(),
|
||||
HologramBugFixer
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.willfp.ecocrates.crate.placed
|
||||
|
||||
import org.bukkit.event.EventHandler
|
||||
import org.bukkit.event.Listener
|
||||
import org.bukkit.event.world.ChunkUnloadEvent
|
||||
|
||||
object HologramBugFixer: Listener {
|
||||
@EventHandler
|
||||
fun handle(event: ChunkUnloadEvent) {
|
||||
val chunk = event.chunk
|
||||
for (crate in PlacedCrates.values()) {
|
||||
if (crate.location.chunk == chunk) {
|
||||
crate.handleChunkUnload()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ class PlacedCrate(
|
||||
blockLocation: Location
|
||||
) {
|
||||
// Center the location, they're mutable because bukkit is bad at designing APIs.
|
||||
private val location = blockLocation.clone().apply {
|
||||
val location = blockLocation.clone().apply {
|
||||
x += 0.5
|
||||
y += 0.5
|
||||
z += 0.5
|
||||
@@ -42,6 +42,10 @@ class PlacedCrate(
|
||||
item?.remove()
|
||||
}
|
||||
|
||||
internal fun handleChunkUnload() {
|
||||
hologram.remove()
|
||||
}
|
||||
|
||||
private fun tickHolograms(tick: Int) {
|
||||
var frameToShow: HologramFrame? = null
|
||||
|
||||
|
||||
Reference in New Issue
Block a user