From f417b54f21302967a53f0383e1ac6ecd991f179f Mon Sep 17 00:00:00 2001 From: Kory Date: Sun, 17 Sep 2023 12:30:53 +0900 Subject: [PATCH] =?UTF-8?q?fix(build):=20`org.bukkit.Material`=20=E3=81=AB?= =?UTF-8?q?=E5=AF=BE=E3=81=99=E3=82=8B=20`match`=20=E5=BC=8F=E3=82=92=20`i?= =?UTF-8?q?f`=20=E5=BC=8F=E3=81=AB=E7=BD=AE=E3=81=8D=E6=8F=9B=E3=81=88?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit これでコンパイル時間が大幅に短縮される (2000秒 -> 110秒)。詳細は #2226 を参照のこと。 --- .../invlistener/OnClickTitleMenu.scala | 300 ++++++++---------- .../seichiskill/BlockSearching.scala | 20 +- .../seichiassist/seichiskill/SkillRange.scala | 18 +- .../unchama/seichiassist/util/BreakUtil.scala | 66 ++-- 4 files changed, 188 insertions(+), 216 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/listener/invlistener/OnClickTitleMenu.scala b/src/main/scala/com/github/unchama/seichiassist/listener/invlistener/OnClickTitleMenu.scala index c2df181fc7..bcb60755ee 100644 --- a/src/main/scala/com/github/unchama/seichiassist/listener/invlistener/OnClickTitleMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/listener/invlistener/OnClickTitleMenu.scala @@ -76,187 +76,165 @@ object OnClickTitleMenu { view.getTitle match { case MenuType.HEAD.invName => event.setCancelled(true) - mat match { - case Material.WATER_BUCKET => - clickedSound(player, Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1.0f) - - val id = current.getItemMeta.getDisplayName.toInt - val length = Nicknames - .getCombinedNicknameFor(id, pd.settings.nickname.id2, pd.settings.nickname.id3) - .getOrElse("") - .length - if (length > MAX_LENGTH) { - player.sendMessage(LENGTH_LIMIT_EXCEEDED) - } else { - pd.updateNickname(id1 = id) - player.sendMessage( - "前パーツ「" + Nicknames - .getHeadPartFor(pd.settings.nickname.id1) - .getOrElse("") + "」をセットしました。" - ) - } - - case Material.GRASS => - // unselect - clickedSound(player, Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1.0f) - pd.updateNickname(id1 = 0) - player.sendMessage("前パーツの選択を解除しました。") - - case Material.BARRIER => - clickedSound(player, Sound.BLOCK_FENCE_GATE_OPEN, 0.1f) - ioCanOpenNicknameMenu.open(NickNameMenu).apply(player).unsafeRunAsyncAndForget() - - case _ if isSkull && isApplicableAsNextPageButton(current) => - // 次ページ - clickedSound(player, Sound.BLOCK_FENCE_GATE_OPEN, 0.1f) - val uuid = player.getUniqueId - val menuType = MenuInventoryData.MenuType.HEAD - MenuInventoryData.setHeadingIndex( - uuid, - menuType, - MenuInventoryData.getHeadingIndex(uuid, menuType).get + PER_PAGE + if (mat == Material.WATER_BUCKET) { + clickedSound(player, Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1.0f) + + val id = current.getItemMeta.getDisplayName.toInt + val length = Nicknames + .getCombinedNicknameFor(id, pd.settings.nickname.id2, pd.settings.nickname.id3) + .getOrElse("") + .length + if (length > MAX_LENGTH) { + player.sendMessage(LENGTH_LIMIT_EXCEEDED) + } else { + pd.updateNickname(id1 = id) + player.sendMessage( + "前パーツ「" + Nicknames + .getHeadPartFor(pd.settings.nickname.id1) + .getOrElse("") + "」をセットしました。" ) - player.openInventory(MenuInventoryData.computeHeadPartCustomMenu(player)) - - case _ => + } + } else if (mat == Material.GRASS) { + // unselect + clickedSound(player, Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1.0f) + pd.updateNickname(id1 = 0) + player.sendMessage("前パーツの選択を解除しました。") + } else if (mat == Material.BARRIER) { + clickedSound(player, Sound.BLOCK_FENCE_GATE_OPEN, 0.1f) + ioCanOpenNicknameMenu.open(NickNameMenu).apply(player).unsafeRunAsyncAndForget() + } else if (isSkull && isApplicableAsNextPageButton(current)) { + // 次ページ + clickedSound(player, Sound.BLOCK_FENCE_GATE_OPEN, 0.1f) + val uuid = player.getUniqueId + val menuType = MenuInventoryData.MenuType.HEAD + MenuInventoryData.setHeadingIndex( + uuid, + menuType, + MenuInventoryData.getHeadingIndex(uuid, menuType).get + PER_PAGE + ) + player.openInventory(MenuInventoryData.computeHeadPartCustomMenu(player)) } case MenuType.MIDDLE.invName => event.setCancelled(true) - mat match { - case Material.MILK_BUCKET => - clickedSound(player, Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1.0f) - - val id = current.getItemMeta.getDisplayName.toInt - val length = Nicknames - .getCombinedNicknameFor(pd.settings.nickname.id1, id, pd.settings.nickname.id3) - .getOrElse("") - .length - if (length > MAX_LENGTH) { - player.sendMessage(LENGTH_LIMIT_EXCEEDED) - } else { - pd.updateNickname(id2 = id) - player.sendMessage( - "中パーツ「" + Nicknames - .getMiddlePartFor(pd.settings.nickname.id2) - .getOrElse("") + "」をセットしました。" - ) - } - case Material.GRASS => - clickedSound(player, Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1.0f) - pd.updateNickname(id2 = 0) - player.sendMessage("中パーツの選択を解除しました。") - - case Material.BARRIER => - clickedSound(player, Sound.BLOCK_FENCE_GATE_OPEN, 0.1f) - ioCanOpenNicknameMenu.open(NickNameMenu).apply(player).unsafeRunAsyncAndForget() - - case _ if isSkull && isApplicableAsNextPageButton(current) => - clickedSound(player, Sound.BLOCK_FENCE_GATE_OPEN, 0.1f) - val uuid = player.getUniqueId - val menuType = MenuInventoryData.MenuType.MIDDLE - MenuInventoryData.setHeadingIndex( - uuid, - menuType, - MenuInventoryData.getHeadingIndex(uuid, menuType).get + PER_PAGE + if (mat == Material.MILK_BUCKET) { + clickedSound(player, Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1.0f) + + val id = current.getItemMeta.getDisplayName.toInt + val length = Nicknames + .getCombinedNicknameFor(pd.settings.nickname.id1, id, pd.settings.nickname.id3) + .getOrElse("") + .length + if (length > MAX_LENGTH) { + player.sendMessage(LENGTH_LIMIT_EXCEEDED) + } else { + pd.updateNickname(id2 = id) + player.sendMessage( + "中パーツ「" + Nicknames + .getMiddlePartFor(pd.settings.nickname.id2) + .getOrElse("") + "」をセットしました。" ) - player.openInventory(MenuInventoryData.computeMiddlePartCustomMenu(player)) - - case _ => + } + } else if (mat == Material.GRASS) { + clickedSound(player, Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1.0f) + pd.updateNickname(id2 = 0) + player.sendMessage("中パーツの選択を解除しました。") + } else if (mat == Material.BARRIER) { + clickedSound(player, Sound.BLOCK_FENCE_GATE_OPEN, 0.1f) + ioCanOpenNicknameMenu.open(NickNameMenu).apply(player).unsafeRunAsyncAndForget() + } else if (isSkull && isApplicableAsNextPageButton(current)) { + clickedSound(player, Sound.BLOCK_FENCE_GATE_OPEN, 0.1f) + val uuid = player.getUniqueId + val menuType = MenuInventoryData.MenuType.MIDDLE + MenuInventoryData.setHeadingIndex( + uuid, + menuType, + MenuInventoryData.getHeadingIndex(uuid, menuType).get + PER_PAGE + ) + player.openInventory(MenuInventoryData.computeMiddlePartCustomMenu(player)) } case MenuType.TAIL.invName => event.setCancelled(true) - mat match { - case Material.LAVA_BUCKET => - clickedSound(player, Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1.0f) - - val id = current.getItemMeta.getDisplayName.toInt - val length = Nicknames - .getCombinedNicknameFor(pd.settings.nickname.id1, pd.settings.nickname.id2, id) - .getOrElse("") - .length - if (length > MAX_LENGTH) { - player.sendMessage(LENGTH_LIMIT_EXCEEDED) - } else { - pd.updateNickname(id3 = id) - player.sendMessage( - "後パーツ「" + Nicknames - .getTailPartFor(pd.settings.nickname.id3) - .getOrElse("") + "」をセットしました。" - ) - } - - case Material.GRASS => - clickedSound(player, Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1.0f) - pd.updateNickname(id3 = 0) - player.sendMessage("後パーツの選択を解除しました。") - - case Material.BARRIER => - clickedSound(player, Sound.BLOCK_FENCE_GATE_OPEN, 0.1f) - ioCanOpenNicknameMenu.open(NickNameMenu).apply(player).unsafeRunAsyncAndForget() - case _ if isSkull && isApplicableAsNextPageButton(current) => - clickedSound(player, Sound.BLOCK_FENCE_GATE_OPEN, 0.1f) - val uuid = player.getUniqueId - val menuType = MenuInventoryData.MenuType.TAIL - MenuInventoryData.setHeadingIndex( - uuid, - menuType, - MenuInventoryData.getHeadingIndex(uuid, menuType).get + PER_PAGE + if (mat == Material.LAVA_BUCKET) { + clickedSound(player, Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1.0f) + + val id = current.getItemMeta.getDisplayName.toInt + val length = Nicknames + .getCombinedNicknameFor(pd.settings.nickname.id1, pd.settings.nickname.id2, id) + .getOrElse("") + .length + if (length > MAX_LENGTH) { + player.sendMessage(LENGTH_LIMIT_EXCEEDED) + } else { + pd.updateNickname(id3 = id) + player.sendMessage( + "後パーツ「" + Nicknames + .getTailPartFor(pd.settings.nickname.id3) + .getOrElse("") + "」をセットしました。" ) - player.openInventory(MenuInventoryData.computeTailPartCustomMenu(player)) - - case _ => + } + } else if (mat == Material.GRASS) { + clickedSound(player, Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1.0f) + pd.updateNickname(id3 = 0) + player.sendMessage("後パーツの選択を解除しました。") + } else if (mat == Material.BARRIER) { + clickedSound(player, Sound.BLOCK_FENCE_GATE_OPEN, 0.1f) + ioCanOpenNicknameMenu.open(NickNameMenu).apply(player).unsafeRunAsyncAndForget() + } else if (isSkull && isApplicableAsNextPageButton(current)) { + clickedSound(player, Sound.BLOCK_FENCE_GATE_OPEN, 0.1f) + val uuid = player.getUniqueId + val menuType = MenuInventoryData.MenuType.TAIL + MenuInventoryData.setHeadingIndex( + uuid, + menuType, + MenuInventoryData.getHeadingIndex(uuid, menuType).get + PER_PAGE + ) + player.openInventory(MenuInventoryData.computeTailPartCustomMenu(player)) } case MenuType.SHOP.invName => event.setCancelled(true) - mat match { + if (mat == Material.EMERALD_ORE) { // 実績ポイント最新化 - case Material.EMERALD_ORE => - clickedSound(player, Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1.0f) - pd.recalculateAchievePoint() - pd.samepageflag = true - player.openInventory(MenuInventoryData.computePartsShopMenu(player)) - + clickedSound(player, Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1.0f) + pd.recalculateAchievePoint() + pd.samepageflag = true + player.openInventory(MenuInventoryData.computePartsShopMenu(player)) + } else if (mat == Material.BEDROCK) { // 購入処理 - case Material.BEDROCK => - clickedSound(player, Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1.0f) - - val num = current.getItemMeta.getDisplayName.toInt - val isHead = num < 9900 - val required = if (isHead) 20 else 35 - val getPart = if (isHead) { num => Nicknames.getHeadPartFor(num) } - else { num => Nicknames.getMiddlePartFor(num) } - - if (pd.achievePoint.left >= required) { - pd.TitleFlags.addOne(num) - pd.consumeAchievePoint(required) - player.sendMessage("パーツ「" + getPart(num).getOrElse("") + "」を購入しました。") - pd.samepageflag = true - player.openInventory(MenuInventoryData.computePartsShopMenu(player)) - } else { - player.sendMessage("実績ポイントが不足しています。") - } - - case Material.BARRIER => - clickedSound(player, Sound.BLOCK_FENCE_GATE_OPEN, 0.1f) - ioCanOpenNicknameMenu.open(NickNameMenu).apply(player).unsafeRunAsyncAndForget() - - case _ if isSkull && isApplicableAsNextPageButton(current) => - clickedSound(player, Sound.BLOCK_FENCE_GATE_OPEN, 0.1f) - val uuid = player.getUniqueId - val menuType = MenuInventoryData.MenuType.SHOP - MenuInventoryData.setHeadingIndex( - uuid, - menuType, - MenuInventoryData.getHeadingIndex(uuid, menuType).get + PER_PAGE - ) + clickedSound(player, Sound.BLOCK_STONE_BUTTON_CLICK_ON, 1.0f) + + val num = current.getItemMeta.getDisplayName.toInt + val isHead = num < 9900 + val required = if (isHead) 20 else 35 + val getPart = if (isHead) { num => Nicknames.getHeadPartFor(num) } + else { num => Nicknames.getMiddlePartFor(num) } + + if (pd.achievePoint.left >= required) { + pd.TitleFlags.addOne(num) + pd.consumeAchievePoint(required) + player.sendMessage("パーツ「" + getPart(num).getOrElse("") + "」を購入しました。") + pd.samepageflag = true player.openInventory(MenuInventoryData.computePartsShopMenu(player)) - - case _ => + } else { + player.sendMessage("実績ポイントが不足しています。") + } + } else if (mat == Material.BARRIER) { + clickedSound(player, Sound.BLOCK_FENCE_GATE_OPEN, 0.1f) + ioCanOpenNicknameMenu.open(NickNameMenu).apply(player).unsafeRunAsyncAndForget() + } else if (isSkull && isApplicableAsNextPageButton(current)) { + clickedSound(player, Sound.BLOCK_FENCE_GATE_OPEN, 0.1f) + val uuid = player.getUniqueId + val menuType = MenuInventoryData.MenuType.SHOP + MenuInventoryData.setHeadingIndex( + uuid, + menuType, + MenuInventoryData.getHeadingIndex(uuid, menuType).get + PER_PAGE + ) + player.openInventory(MenuInventoryData.computePartsShopMenu(player)) } // それ以外のインベントリの名前だった場合何もしない! diff --git a/src/main/scala/com/github/unchama/seichiassist/seichiskill/BlockSearching.scala b/src/main/scala/com/github/unchama/seichiassist/seichiskill/BlockSearching.scala index 44b4a50511..725d2633d8 100644 --- a/src/main/scala/com/github/unchama/seichiassist/seichiskill/BlockSearching.scala +++ b/src/main/scala/com/github/unchama/seichiassist/seichiskill/BlockSearching.scala @@ -38,17 +38,17 @@ object BlockSearching { case XYZTuple(x, y, z) => val targetBlock = referencePoint.getRelative(x, y, z) - if (BreakUtil.canBreakWithSkill(player, targetBlock, lockedBlocks)) - targetBlock.getType match { - case Material.LAVA => - lavaBlocks.add(targetBlock) - case Material.WATER => - waterBlocks.add(targetBlock) - case _ => - MaterialSets - .refineBlock(targetBlock, MaterialSets.materials) - .foreach(b => solidBlocks.add(b)) + if (BreakUtil.canBreakWithSkill(player, targetBlock, lockedBlocks)) { + if (targetBlock.getType == Material.LAVA) { + lavaBlocks.add(targetBlock) + } else if (targetBlock.getType == Material.WATER) { + waterBlocks.add(targetBlock) + } else { + MaterialSets + .refineBlock(targetBlock, MaterialSets.materials) + .foreach(b => solidBlocks.add(b)) } + } } Result(solidBlocks.toList, waterBlocks.toList, lavaBlocks.toList) diff --git a/src/main/scala/com/github/unchama/seichiassist/seichiskill/SkillRange.scala b/src/main/scala/com/github/unchama/seichiassist/seichiskill/SkillRange.scala index c96a2f96f4..ecea76246f 100644 --- a/src/main/scala/com/github/unchama/seichiassist/seichiskill/SkillRange.scala +++ b/src/main/scala/com/github/unchama/seichiassist/seichiskill/SkillRange.scala @@ -41,24 +41,22 @@ object AssaultSkillRange { } case class Water(effectChunkSize: XYZTuple) extends AssaultSkillRange { - override val blockMaterialConversion: Material => Material = { - case Material.WATER => Material.ICE - case x => x + override val blockMaterialConversion: Material => Material = { m => + if (m == Material.WATER) Material.ICE else m } } case class Lava(effectChunkSize: XYZTuple) extends AssaultSkillRange { - override val blockMaterialConversion: Material => Material = { - case Material.LAVA => Material.MAGMA_BLOCK - case x => x + override val blockMaterialConversion: Material => Material = { m => + if (m == Material.LAVA) Material.MAGMA_BLOCK else m } } case class Liquid(effectChunkSize: XYZTuple) extends AssaultSkillRange { - override val blockMaterialConversion: Material => Material = { - case Material.WATER => Material.ICE - case Material.LAVA => Material.MAGMA_BLOCK - case x => x + override val blockMaterialConversion: Material => Material = { m => + if (m == Material.WATER) Material.ICE + else if (m == Material.LAVA) Material.MAGMA_BLOCK + else m } } diff --git a/src/main/scala/com/github/unchama/seichiassist/util/BreakUtil.scala b/src/main/scala/com/github/unchama/seichiassist/util/BreakUtil.scala index e908a77173..6cc14cae23 100644 --- a/src/main/scala/com/github/unchama/seichiassist/util/BreakUtil.scala +++ b/src/main/scala/com/github/unchama/seichiassist/util/BreakUtil.scala @@ -122,26 +122,26 @@ object BreakUtil { } def isProtectedChest(player: Player, checkTarget: Block): Boolean = { - checkTarget.getType match { - case Material.CHEST | Material.TRAPPED_CHEST => - if ( - !SeichiAssist - .instance - .breakSkillTargetConfigSystem - .api - .breakSkillTargetConfig(player, BreakSkillTargetConfigKey.Chest) - .unsafeRunSync() - ) { - ActionBarMessageEffect(s"${RED}スキルでのチェスト破壊は無効化されています").run(player).unsafeRunSync() - true - } else if (!player.getWorld.isSeichi) { - ActionBarMessageEffect(s"${RED}スキルでのチェスト破壊は整地ワールドでのみ有効です").run(player).unsafeRunSync() - true - } else { - false - } - case _ => false - } + if ( + checkTarget.getType == Material.CHEST || checkTarget.getType == Material.TRAPPED_CHEST + ) { + if ( + !SeichiAssist + .instance + .breakSkillTargetConfigSystem + .api + .breakSkillTargetConfig(player, BreakSkillTargetConfigKey.Chest) + .unsafeRunSync() + ) { + ActionBarMessageEffect(s"${RED}スキルでのチェスト破壊は無効化されています").run(player).unsafeRunSync() + true + } else if (!player.getWorld.isSeichi) { + ActionBarMessageEffect(s"${RED}スキルでのチェスト破壊は整地ワールドでのみ有効です").run(player).unsafeRunSync() + true + } else { + false + } + } else false } /** @@ -205,10 +205,10 @@ object BreakUtil { def totalBreakCount(materials: Seq[Material]): Long = materials .filter(MaterialSets.materialsToCountBlockBreak.contains) - .map { + .map { m => // 氷塊とマグマブロックの整地量を2倍 - case Material.PACKED_ICE | Material.MAGMA_BLOCK => 2L - case _ => 1L + if (m == Material.PACKED_ICE || m == Material.MAGMA_BLOCK) 2L + else 1L } .sum @@ -237,13 +237,11 @@ object BreakUtil { val seq: Seq[(Location, Material)] = targetBlocks .toSeq .filter { block => - block.getType match { - case Material.AIR => - if (SeichiAssist.DEBUG) - Bukkit.getLogger.warning(s"AIRの破壊が${block.getLocation.toString}にて試行されました。") - false - case _ => true - } + if (block.getType == Material.AIR) { + if (SeichiAssist.DEBUG) + Bukkit.getLogger.warning(s"AIRの破壊が${block.getLocation.toString}にて試行されました。") + false + } else true } .map(block => (block.getLocation.clone(), block.getType)) @@ -360,11 +358,9 @@ object BreakUtil { * ref: [バージョン1.12.x時の最新記事アーカイブ](https://minecraft.fandom.com/wiki/Solid_block?oldid=1132868) */ private def isAffectedByGravity(material: Material): Boolean = { - material match { - case Material.BEDROCK => false - case m if MaterialSets.fluidMaterials.contains(m) || m.isSolid => true - case _ => false - } + if (material == Material.BEDROCK) false + else if (MaterialSets.fluidMaterials.contains(material)) true + else material.isSolid } /**