From acb439e3d9d9e3098181328a983e4d4a119e46e7 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 21 Dec 2021 22:01:59 +0100 Subject: [PATCH] Limit block breaking to team area Signed-off-by: Lixfel --- .../de/steamwar/fightsystem/listener/TeamArea.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/TeamArea.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/TeamArea.java index 75a1fd8..383acf2 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/TeamArea.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/TeamArea.java @@ -34,6 +34,7 @@ import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; @@ -77,6 +78,16 @@ public class TeamArea implements Listener { FightSystem.getMessage().sendPrefixless("NO_BLOCK_PLACE", player, ChatMessageType.ACTION_BAR); } + @EventHandler + public void blockBreak(BlockBreakEvent event) { + Block block = event.getBlock(); + if(Config.BlueExtendRegion.inRegion(block) || Config.RedExtendRegion.inRegion(block)) + return; + + event.setCancelled(true); + FightSystem.getMessage().sendPrefixless("NO_BLOCK_BREAK", event.getPlayer(), ChatMessageType.ACTION_BAR); + } + private void checkInTeamRegion(PlayerMoveEvent event, FightTeam team, Player player, FightTeam playerTeam) { boolean spectator = player.getGameMode() == GameMode.SPECTATOR; if(!spectator && playerTeam != null && playerTeam.canPlayerEntern(player))