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 } /**