Skip to content

Commit

Permalink
fix: 保護の作成可能条件が間違っているのを修正
Browse files Browse the repository at this point in the history
  • Loading branch information
rito528 committed Feb 11, 2025
1 parent 308e699 commit d657d1b
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ class BukkitRegionOperations[F[_]: Sync](
player: Player,
shape: SubjectiveRegionShape
): F[RegionCreationResult] = {
val selection = WorldEditWrapper.getSelection(player)
for {
regionCount <- regionCountRepository(player).get
world <- Sync[F].delay(player.getWorld)
Expand All @@ -104,14 +103,17 @@ class BukkitRegionOperations[F[_]: Sync](
Sync[F].pure(RegionCreationResult.Error)
} else {
Sync[F].delay {
wgManager.getApplicableRegions(selection)
val maxRegionCount = WorldGuardWrapper.getWorldMaxRegion(world)
val regionCountPerPlayer = WorldGuardWrapper.getNumberOfRegions(player, world)
val selection = WorldEditWrapper.getSelection(player)
val applicableRegions = wgManager.getApplicableRegions(selection)

if (maxRegionCount >= 0 && regionCountPerPlayer >= maxRegionCount) {
RegionCreationResult.Error
} else {
val maxRegionCountPerWorld = WorldGuardWrapper.getWorldMaxRegion(world)
val regionCountPerPlayer = WorldGuardWrapper.getNumberOfRegions(player, world)
if (
regionCountPerPlayer < maxRegionCountPerWorld && applicableRegions.size() == 0
) {
RegionCreationResult.Success
} else {
RegionCreationResult.Error
}
}
}
Expand Down

0 comments on commit d657d1b

Please sign in to comment.