Skip to content

Commit

Permalink
Merge branch 'master' into ver/1.20.2
Browse files Browse the repository at this point in the history
# Conflicts:
#	build.gradle.kts
#	src/main/java/com/github/mori01231/lifecore/util/MapUtil.kt
  • Loading branch information
acrylic-style committed Nov 9, 2024
2 parents edc0add + 46a61b2 commit f8c7be8
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugins {
}

group = "net.azisaba"
version = "6.18.2+1.20.2"
version = "6.18.4+1.20.2"

java {
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/github/mori01231/lifecore/LifeCore.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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 }
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}
7 changes: 4 additions & 3 deletions src/main/java/com/github/mori01231/lifecore/util/MapUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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) =
Expand Down Expand Up @@ -57,7 +58,7 @@ object MapUtil {
return null
}

private val renderedMapViews = Collections.synchronizedList(mutableListOf<Pair<Player, CraftMapView>>())
val renderedMapViews = Collections.synchronizedList(mutableListOf<Pair<UUID, Int>>())

fun initializeMapRenderer(player: Player, item: ItemStack) {
if (item.type != Material.FILLED_MAP) return
Expand All @@ -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)
})
Expand Down

0 comments on commit f8c7be8

Please sign in to comment.