From dbefe038129f09c1f10a89a72460bde5ab6bd56d Mon Sep 17 00:00:00 2001 From: acrylic-style Date: Tue, 30 Jul 2024 19:54:05 +0900 Subject: [PATCH] fix: backup & restore ender too --- build.gradle.kts | 2 +- .../lifecore/command/TownServerCommand.kt | 9 +++++++-- .../lifecore/listener/PlayerJoinListener.java | 16 ++++++++++++---- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 98a5e72..845e495 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,7 @@ plugins { } group = "net.azisaba" -version = "1.15.2+6.16.6" +version = "1.15.2+6.16.7" java { toolchain.languageVersion.set(JavaLanguageVersion.of(8)) diff --git a/src/main/java/com/github/mori01231/lifecore/command/TownServerCommand.kt b/src/main/java/com/github/mori01231/lifecore/command/TownServerCommand.kt index b551d0d..019173b 100644 --- a/src/main/java/com/github/mori01231/lifecore/command/TownServerCommand.kt +++ b/src/main/java/com/github/mori01231/lifecore/command/TownServerCommand.kt @@ -11,11 +11,16 @@ class TownServerCommand(private val plugin: LifeCore) : TransferCommand(plugin, override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array): Boolean { val player = sender as? Player ?: return false if (plugin.config.getBoolean("enable-backup-item-tag", true)) { - val size = player.inventory.size - for (i in 0.. { @@ -61,10 +65,14 @@ public void onPlayerJoin(PlayerJoinEvent e) { // restore item tags if (plugin.getConfig().getBoolean("enable-backup-item-tag", true)) { - int size = player.getInventory().getSize(); - for (int i = 0; i < size; i++) { + int inventorySize = player.getInventory().getSize(); + for (int i = 0; i < inventorySize; i++) { player.getInventory().setItem(i, ItemUtil.restoreTag(player.getInventory().getItem(i))); } + int enderSize = player.getEnderChest().getSize(); + for (int i = 0; i < enderSize; i++) { + player.getEnderChest().setItem(i, ItemUtil.restoreTag(player.getEnderChest().getItem(i))); + } } }, 20 * 10); // 10 seconds }