From 7d62907204c6c80b96d90bfc3206d6864bbe74ca Mon Sep 17 00:00:00 2001 From: rito528 <39003544+rito528@users.noreply.github.com> Date: Sun, 17 Sep 2023 00:29:59 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=E3=82=B3=E3=83=B3=E3=83=91=E3=82=A4?= =?UTF-8?q?=E3=83=AB=E3=82=A8=E3=83=A9=E3=83=BC=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../menus/gridregion/GridRegionMenu.scala | 16 +++---- .../BukkitStaticGachaPrizeFactory.scala | 2 +- .../bukkit/BukkitRegionOperations.scala | 44 ++++++------------- .../MebiusCommandExecutorProvider.scala | 9 ---- .../util/external/WorldEditWrapper.scala | 4 +- .../util/external/WorldGuardWrapper.scala | 3 +- 6 files changed, 25 insertions(+), 53 deletions(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/menus/gridregion/GridRegionMenu.scala b/src/main/scala/com/github/unchama/seichiassist/menus/gridregion/GridRegionMenu.scala index ed58f828e9..9e619a26db 100644 --- a/src/main/scala/com/github/unchama/seichiassist/menus/gridregion/GridRegionMenu.scala +++ b/src/main/scala/com/github/unchama/seichiassist/menus/gridregion/GridRegionMenu.scala @@ -80,7 +80,7 @@ object GridRegionMenu extends Menu { for { currentLengthChangePerClick <- gridRegionAPI.lengthChangePerClick(player) } yield { - val iconItemStack = new IconItemStackBuilder(Material.STAINED_GLASS_PANE, 1) + val iconItemStack = new IconItemStackBuilder(Material.GLASS_PANE) .title(s"${GREEN}拡張単位の変更") .lore( List( @@ -169,9 +169,7 @@ object GridRegionMenu extends Menu { } Button( - new IconItemStackBuilder( - Material.STAINED_GLASS_PANE, - stainedGlassPaneDurability.toShort + new IconItemStackBuilder(Material.GLASS_PANE ).title(s"$DARK_GREEN${relativeDirectionString}ユニット増やす/減らす").lore(lore).build(), LeftClickButtonEffect(updateCurrentRegionShapeTo(expandedShape)), RightClickButtonEffect(updateCurrentRegionShapeTo(contractedShape)) @@ -194,7 +192,7 @@ object GridRegionMenu extends Menu { } val resetSettingButton: Button = { - val itemStack = new IconItemStackBuilder(Material.STAINED_GLASS_PANE, 4) + val itemStack = new IconItemStackBuilder(Material.GLASS_PANE) .title(s"${RED}全設定リセット") .lore(List(s"$RED${UNDERLINE}取り扱い注意!!")) .build() @@ -228,7 +226,7 @@ object GridRegionMenu extends Menu { s"${GRAY}保護ユニット上限値:$RED${gridRegionAPI.regionUnitLimit(worldName).limit}" ) - val itemStack = new IconItemStackBuilder(Material.STAINED_GLASS_PANE, 11) + val itemStack = new IconItemStackBuilder(Material.GLASS_PANE) .title(s"${DARK_GREEN}設定") .lore(lore) .build() @@ -245,7 +243,7 @@ object GridRegionMenu extends Menu { canCreateRegionResult match { case RegionCreationResult.Success => Button( - new IconItemStackBuilder(Material.WOOL, 11) + new IconItemStackBuilder(Material.LIGHT_BLUE_WOOL) .title(s"${GREEN}保護作成") .lore(List(s"${DARK_GREEN}保護作成可能です", s"$RED${UNDERLINE}クリックで作成")) .build(), @@ -257,14 +255,14 @@ object GridRegionMenu extends Menu { ) case RegionCreationResult.WorldProhibitsRegionCreation => Button( - new IconItemStackBuilder(Material.WOOL, 14) + new IconItemStackBuilder(Material.RED_WOOL) .title(s"${RED}保護作成") .lore(List(s"$RED${UNDERLINE}このワールドでは保護を作成できません")) .build() ) case RegionCreationResult.Error => Button( - new IconItemStackBuilder(Material.WOOL, 1) + new IconItemStackBuilder(Material.RED_WOOL) .title(s"${RED}以下の原因により保護の作成できません") .lore( List( diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/bukkit/factories/BukkitStaticGachaPrizeFactory.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/bukkit/factories/BukkitStaticGachaPrizeFactory.scala index 6ee0fde628..89ebf4f10f 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/bukkit/factories/BukkitStaticGachaPrizeFactory.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/bukkit/factories/BukkitStaticGachaPrizeFactory.scala @@ -28,7 +28,7 @@ object BukkitStaticGachaPrizeFactory extends StaticGachaPrizeFactory[ItemStack] setItemMeta(meta) } - override val expBottle: ItemStack = new ItemStack(Material.EXP_BOTTLE, 20) + override val expBottle: ItemStack = new ItemStack(Material.EXPERIENCE_BOTTLE, 20) override val mineHeadItem: ItemStack = new ItemStack(Material.CARROT_ON_A_STICK, 1, 1.toShort).tap { itemStack => diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/gridregion/bukkit/BukkitRegionOperations.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/gridregion/bukkit/BukkitRegionOperations.scala index 9ab2c05318..05b9a52c70 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/gridregion/bukkit/BukkitRegionOperations.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/gridregion/bukkit/BukkitRegionOperations.scala @@ -8,6 +8,8 @@ import com.github.unchama.seichiassist.subsystems.gridregion.domain.CardinalDire import com.github.unchama.seichiassist.subsystems.gridregion.domain.HorizontalAxisAlignedSubjectiveDirection.Ahead import com.github.unchama.seichiassist.subsystems.gridregion.domain._ import com.github.unchama.util.external.{WorldEditWrapper, WorldGuardWrapper} +import com.sk89q.worldedit.math.BlockVector3 +import com.sk89q.worldguard.protection.regions.{ProtectedCuboidRegion, ProtectedRegion} import org.bukkit.Location import org.bukkit.entity.Player @@ -72,21 +74,12 @@ class BukkitRegionOperations[F[_]: Sync]( override def tryCreatingSelectedWorldGuardRegion(player: Player): F[Unit] = for { regionCount <- regionCountRepository(player).get + wgManager = WorldGuardWrapper.getRegionManager(player.getWorld) + selection = WorldEditWrapper.getSelection(player) + regionName = s"${player.getName}_${regionCount.value}" + region = new ProtectedCuboidRegion(regionName, BlockVector3.at(selection.getBlockX, 0, selection.getBlockZ), BlockVector3.at(selection.getBlockX, 255, selection.getBlockZ)) regionCreateResult <- Sync[F].delay { - WorldEditWrapper - .getSelection(player) - .map { selection => - val regionName = s"${player.getName}_${regionCount.value}" - - WorldGuardWrapper.tryCreateRegion( - regionName, - player, - player.getWorld, - selection.getNativeMinimumPoint.toBlockVector, - selection.getNativeMaximumPoint.toBlockVector - ) - } - .getOrElse(()) + wgManager.addRegion(region) } _ <- regionCountRepository(player).update(_.increment) } yield regionCreateResult @@ -103,27 +96,18 @@ class BukkitRegionOperations[F[_]: Sync]( result <- if (!SeichiAssist.seichiAssistConfig.isGridProtectionEnabled(world)) { Sync[F].pure(RegionCreationResult.WorldProhibitsRegionCreation) - } else if (selection.isEmpty || wgManager.isEmpty) { + } else if (regionCount.value >= WorldGuardWrapper.getWorldMaxRegion(player.getWorld)) { Sync[F].pure(RegionCreationResult.Error) } else { Sync[F].delay { - val regions = WorldGuardWrapper.getApplicableRegionCount( - world, - s"${player.getName}_${regionCount.value}", - selection.get.getNativeMinimumPoint.toBlockVector, - selection.get.getNativeMaximumPoint.toBlockVector - ) - if (regions != 0) { + wgManager.getApplicableRegions(selection) + val maxRegionCount = WorldGuardWrapper.getWorldMaxRegion(world) + val regionCountPerPlayer = WorldGuardWrapper.getNumberOfRegions(player, world) + + if (maxRegionCount >= 0 && regionCountPerPlayer >= maxRegionCount) { RegionCreationResult.Error } else { - val maxRegionCount = WorldGuardWrapper.getMaxRegionCount(player, world) - val regionCountPerPlayer = WorldGuardWrapper.getRegionCountOfPlayer(player, world) - - if (maxRegionCount >= 0 && regionCountPerPlayer >= maxRegionCount) { - RegionCreationResult.Error - } else { - RegionCreationResult.Success - } + RegionCreationResult.Success } } } diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/mebius/bukkit/command/MebiusCommandExecutorProvider.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/mebius/bukkit/command/MebiusCommandExecutorProvider.scala index b5f424f851..b5b9b3b232 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/mebius/bukkit/command/MebiusCommandExecutorProvider.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/mebius/bukkit/command/MebiusCommandExecutorProvider.scala @@ -111,21 +111,12 @@ class MebiusCommandExecutorProvider( val convertExecutor: ContextualExecutor = playerCommandBuilder.buildWith { context => val mainHand = context.sender.getInventory.getItemInMainHand -<<<<<<< HEAD - BukkitMebiusItemStackCodec.decodeMebiusProperty(mainHand) match { - case Some(property) => - if (property.level.isMaximum) { - val newProperty = property.toggleForcedMaterial - val newItem = - BukkitMebiusItemStackCodec.materialize(newProperty, mainHand.getDurability) -======= BukkitMebiusItemStackCodec.decodeMebiusProperty(mainHand) match { case Some(property) => if (property.level.isMaximum) { val newProperty = property.toggleForcedMaterial val newItem = BukkitMebiusItemStackCodec.materialize(newProperty) ->>>>>>> 39af292b1 (tidy up 1.18) val newMaterialName = newProperty.forcedMaterial match { case MebiusForcedMaterial.None => "ダイヤモンド" diff --git a/src/main/scala/com/github/unchama/util/external/WorldEditWrapper.scala b/src/main/scala/com/github/unchama/util/external/WorldEditWrapper.scala index 15812be9e3..ad926ede93 100644 --- a/src/main/scala/com/github/unchama/util/external/WorldEditWrapper.scala +++ b/src/main/scala/com/github/unchama/util/external/WorldEditWrapper.scala @@ -1,7 +1,7 @@ package com.github.unchama.util.external import com.sk89q.worldedit.bukkit.WorldEditPlugin -import com.sk89q.worldedit.bukkit.selections.Selection +import com.sk89q.worldedit.math.BlockVector3 import org.bukkit.entity.Player object WorldEditWrapper { @@ -14,6 +14,6 @@ object WorldEditWrapper { /** * @return `player`が選択している範囲 */ - def getSelection(player: Player): Option[Selection] = Option(plugin.getSelection(player)) + def getSelection(player: Player): BlockVector3 = plugin.getSession(player).getPlacementPosition(plugin.wrapPlayer(player)) } diff --git a/src/main/scala/com/github/unchama/util/external/WorldGuardWrapper.scala b/src/main/scala/com/github/unchama/util/external/WorldGuardWrapper.scala index 8263051150..00745d4be4 100644 --- a/src/main/scala/com/github/unchama/util/external/WorldGuardWrapper.scala +++ b/src/main/scala/com/github/unchama/util/external/WorldGuardWrapper.scala @@ -1,10 +1,9 @@ package com.github.unchama.util.external import com.sk89q.worldedit.bukkit.BukkitAdapter -import com.sk89q.worldguard.{LocalPlayer, WorldGuard} import com.sk89q.worldguard.protection.managers.RegionManager import com.sk89q.worldguard.protection.regions.{ProtectedCuboidRegion, ProtectedRegion} -import com.sk89q.worldguard.protection.util.DomainInputResolver +import com.sk89q.worldguard.{LocalPlayer, WorldGuard} import org.bukkit.entity.Player import org.bukkit.{Location, World}