diff --git a/build.gradle.kts b/build.gradle.kts index d933b1d..91b4b7b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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)) diff --git a/src/main/java/com/github/mori01231/lifecore/command/LifeCoreUtilCommand.kt b/src/main/java/com/github/mori01231/lifecore/command/LifeCoreUtilCommand.kt index 2ab0da6..d6e8e70 100644 --- a/src/main/java/com/github/mori01231/lifecore/command/LifeCoreUtilCommand.kt +++ b/src/main/java/com/github/mori01231/lifecore/command/LifeCoreUtilCommand.kt @@ -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) { + 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().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) { val item = (player as Player).inventory.itemInMainHand 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 044d0f5..934a2d7 100644 --- a/src/main/java/com/github/mori01231/lifecore/util/MapUtil.kt +++ b/src/main/java/com/github/mori01231/lifecore/util/MapUtil.kt @@ -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 } @@ -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) }