diff --git a/build.gradle.kts b/build.gradle.kts index 0b6f844..78a07de 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,7 +10,7 @@ plugins { } group = "net.azisaba" -version = "6.18.2+1.21.1" +version = "6.18.4+1.21.1" java { toolchain.languageVersion.set(JavaLanguageVersion.of(21)) diff --git a/src/main/java/com/github/mori01231/lifecore/LifeCore.kt b/src/main/java/com/github/mori01231/lifecore/LifeCore.kt index cc7c34b..b122bd2 100644 --- a/src/main/java/com/github/mori01231/lifecore/LifeCore.kt +++ b/src/main/java/com/github/mori01231/lifecore/LifeCore.kt @@ -332,6 +332,7 @@ class LifeCore : JavaPlugin() { pm.registerEvents(PicksawItemListener(dataLoader), this) pm.registerEvents(BlockListener, this) pm.registerEvents(MapListScreen.EventListener, this) + pm.registerEvents(PlayerQuitListener, this) // Items pm.registerEvents(OreOnlyItemListener(), this) diff --git a/src/main/java/com/github/mori01231/lifecore/listener/PlayerQuitListener.kt b/src/main/java/com/github/mori01231/lifecore/listener/PlayerQuitListener.kt new file mode 100644 index 0000000..6ff2c81 --- /dev/null +++ b/src/main/java/com/github/mori01231/lifecore/listener/PlayerQuitListener.kt @@ -0,0 +1,18 @@ +package com.github.mori01231.lifecore.listener + +import com.github.mori01231.lifecore.LifeCore +import com.github.mori01231.lifecore.util.MapUtil +import org.bukkit.Bukkit +import org.bukkit.event.EventHandler +import org.bukkit.event.Listener +import org.bukkit.event.player.PlayerQuitEvent +import org.bukkit.plugin.java.JavaPlugin + +object PlayerQuitListener : Listener { + @EventHandler + fun onPlayerQuit(e: PlayerQuitEvent) { + Bukkit.getScheduler().runTaskAsynchronously(JavaPlugin.getPlugin(LifeCore::class.java), Runnable { + MapUtil.renderedMapViews.removeIf { it.first == e.player.uniqueId } + }) + } +} diff --git a/src/main/java/com/github/mori01231/lifecore/listener/PromptSignListener.kt b/src/main/java/com/github/mori01231/lifecore/listener/PromptSignListener.kt index fdc5cad..d64ee1a 100644 --- a/src/main/java/com/github/mori01231/lifecore/listener/PromptSignListener.kt +++ b/src/main/java/com/github/mori01231/lifecore/listener/PromptSignListener.kt @@ -9,6 +9,6 @@ import org.bukkit.event.Listener object PromptSignListener : Listener { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) fun onSign(e: AsyncPreSignChangeEvent) { - PromptSign.awaitingSign[e.player.uniqueId]?.invoke(e.lines.toList()) + PromptSign.awaitingSign.remove(e.player.uniqueId)?.invoke(e.lines.toList()) } } diff --git a/src/main/java/com/github/mori01231/lifecore/util/MapUtil.kt b/src/main/java/com/github/mori01231/lifecore/util/MapUtil.kt index 6d4c90e..e5797a9 100644 --- a/src/main/java/com/github/mori01231/lifecore/util/MapUtil.kt +++ b/src/main/java/com/github/mori01231/lifecore/util/MapUtil.kt @@ -22,6 +22,7 @@ import org.bukkit.map.MapRenderer import org.bukkit.map.MapView import org.bukkit.plugin.java.JavaPlugin import java.util.Collections +import java.util.UUID object MapUtil { private fun convertCanvasToSerializable(canvas: MapCanvas) = @@ -57,7 +58,7 @@ object MapUtil { return null } - private val renderedMapViews = Collections.synchronizedList(mutableListOf>()) + val renderedMapViews = Collections.synchronizedList(mutableListOf>()) fun initializeMapRenderer(player: Player, item: ItemStack) { if (item.type != Material.FILLED_MAP) return @@ -66,8 +67,8 @@ object MapUtil { val hasRenderer = mapView.renderers.isNotEmpty() if (hasRenderer && mapView.renderers[0] !is CraftMapRenderer) { if (mapView is CraftMapView) { - if (renderedMapViews.contains(player to mapView)) return - renderedMapViews.add(player to mapView) + if (renderedMapViews.contains(player.uniqueId to mapView.id)) return + renderedMapViews.add(player.uniqueId to mapView.id) Bukkit.getScheduler().runTask(JavaPlugin.getPlugin(LifeCore::class.java), Runnable { mapView.render(player as CraftPlayer) })