From 2424bd430d56bd176f653a12aaf9e2cfaa1c36b6 Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Fri, 28 Nov 2025 12:13:06 +0100 Subject: [PATCH] Fix TNTListener action bar message showing for WindCharge Remove OtherTNTListener and merge into TNTListener --- .../features/region/TNTListener.java | 15 +++++-- .../features/world/OtherTNTListener.java | 45 ------------------- 2 files changed, 12 insertions(+), 48 deletions(-) delete mode 100644 BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/OtherTNTListener.java diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTListener.java index a8676ae2..22eabcaa 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTListener.java @@ -26,8 +26,10 @@ import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.TNTMode; import de.steamwar.bausystem.utils.ScoreboardElement; import de.steamwar.linkage.Linked; +import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Player; +import org.bukkit.entity.TNTPrimed; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -39,11 +41,14 @@ import java.util.List; @Linked public class TNTListener implements Listener, ScoreboardElement { - private void explode(List blockList) { + private void explode(List blockList, boolean destroy) { blockList.removeIf(block -> { Region region = Region.getRegion(block.getLocation()); TNTMode value = region.getFlags().get(Flag.TNT).getWithDefault(); if (value == TNTMode.ALLOW) { + if (destroy && block.getType() != Material.TNT) { + block.setType(Material.AIR); + } return false; } else if (value == TNTMode.ONLY_TB) { if (region.getBuildArea().inRegion(block.getLocation(), true)) { @@ -57,12 +62,16 @@ public class TNTListener implements Listener, ScoreboardElement { @EventHandler public void onBlockExplode(BlockExplodeEvent event) { - explode(event.blockList()); + explode(event.blockList(), false); } @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onExplode(EntityExplodeEvent event) { - explode(event.blockList()); + if (!(event.getEntity() instanceof TNTPrimed)) { + event.blockList().clear(); + return; + } + explode(event.blockList(), true); } @Override diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/OtherTNTListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/OtherTNTListener.java deleted file mode 100644 index 3d2d9d8d..00000000 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/OtherTNTListener.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2025 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.world; - -import de.steamwar.linkage.Linked; -import org.bukkit.Material; -import org.bukkit.entity.TNTPrimed; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.EntityExplodeEvent; - -@Linked -public class OtherTNTListener implements Listener { - - @EventHandler(priority = EventPriority.MONITOR) - public void onExplosion(EntityExplodeEvent e) { - if (!(e instanceof TNTPrimed)) return; - e.blockList().removeIf(block -> { - if(block.getType() == Material.TNT) { - return false; - } else { - block.setType(Material.AIR); - return true; - } - }); - } -}