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
  • Loading branch information
acrylic-style committed Sep 1, 2024
2 parents d78ac7d + bb41481 commit 088a7b5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 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 = "1.20.2+6.17.0"
version = "1.20.2+6.17.1"

java {
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,18 @@ class LifeCoreUtilCommand(val plugin: LifeCore) : TabExecutor {
MapUtil.initializeMapRenderer(player, player.inventory.itemInMainHand)
}
},
ResetMapId("地図IDをリセットします") {
override fun execute(plugin: LifeCore, player: CommandSender, args: Array<String>) {
player as Player
val meta = player.inventory.itemInMainHand.itemMeta as? MapMeta? ?: return player.sendMessage("this is not a map")
val mapView = meta.mapView ?: return player.sendMessage("mapView is null")
if (mapView.renderers.isEmpty() || mapView.renderers.filterIsInstance<CraftMapRenderer>().isNotEmpty()) {
return player.sendMessage("renderers[0] is an instance of CraftMapRenderer or is null")
}
meta.mapView = Bukkit.createMap(player.world)
player.inventory.setItemInMainHand(player.inventory.itemInMainHand.apply { itemMeta = meta })
}
},
FixItem("displayタグを修正します") {
override fun execute(plugin: LifeCore, player: CommandSender, args: Array<String>) {
val item = (player as Player).inventory.itemInMainHand
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/com/github/mori01231/lifecore/util/MapUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ object MapUtil {
if (item.type != Material.FILLED_MAP) return
val meta = item.itemMeta as? MapMeta? ?: return
val mapView = meta.mapView ?: return
if (mapView.renderers.getOrNull(0) !is CraftMapRenderer) {
val hasRenderer = mapView.renderers.isNotEmpty()
if (hasRenderer && mapView.renderers[0] !is CraftMapRenderer) {
if (mapView is CraftMapView) mapView.render(player as CraftPlayer)
return
}
Expand All @@ -71,7 +72,9 @@ object MapUtil {
} catch (_: Exception) {
return
}
mapView.removeRenderer(mapView.renderers[0])
if (hasRenderer) {
mapView.removeRenderer(mapView.renderers[0])
}
mapView.addRenderer(SerializedMapDataRenderer(serializedMapData))
if (mapView is CraftMapView) mapView.render(player as CraftPlayer)
}
Expand Down

0 comments on commit 088a7b5

Please sign in to comment.