diff --git a/build.gradle.kts b/build.gradle.kts index 221f1cb..09eee3f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,7 @@ plugins { } group = "net.azisaba" -version = "1.15.2+6.17.0" +version = "1.15.2+6.17.1" java { toolchain.languageVersion.set(JavaLanguageVersion.of(8)) 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 91a9a11..bbf6a5a 100644 --- a/src/main/java/com/github/mori01231/lifecore/command/LifeCoreUtilCommand.kt +++ b/src/main/java/com/github/mori01231/lifecore/command/LifeCoreUtilCommand.kt @@ -438,6 +438,18 @@ class LifeCoreUtilCommand(val plugin: LifeCore) : TabExecutor { MapUtil.initializeMapRenderer((player as 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 909fd38..8ccb24b 100644 --- a/src/main/java/com/github/mori01231/lifecore/util/MapUtil.kt +++ b/src/main/java/com/github/mori01231/lifecore/util/MapUtil.kt @@ -46,7 +46,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 } @@ -59,7 +60,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) }