forked from SteamWar/SteamWar
Fix TNTListener action bar message showing for WindCharge
Remove OtherTNTListener and merge into TNTListener
This commit is contained in:
+12
-3
@@ -26,8 +26,10 @@ import de.steamwar.bausystem.region.flags.Flag;
|
|||||||
import de.steamwar.bausystem.region.flags.TNTMode;
|
import de.steamwar.bausystem.region.flags.TNTMode;
|
||||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.TNTPrimed;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@@ -39,11 +41,14 @@ import java.util.List;
|
|||||||
@Linked
|
@Linked
|
||||||
public class TNTListener implements Listener, ScoreboardElement {
|
public class TNTListener implements Listener, ScoreboardElement {
|
||||||
|
|
||||||
private void explode(List<Block> blockList) {
|
private void explode(List<Block> blockList, boolean destroy) {
|
||||||
blockList.removeIf(block -> {
|
blockList.removeIf(block -> {
|
||||||
Region region = Region.getRegion(block.getLocation());
|
Region region = Region.getRegion(block.getLocation());
|
||||||
TNTMode value = region.getFlags().get(Flag.TNT).getWithDefault();
|
TNTMode value = region.getFlags().get(Flag.TNT).getWithDefault();
|
||||||
if (value == TNTMode.ALLOW) {
|
if (value == TNTMode.ALLOW) {
|
||||||
|
if (destroy && block.getType() != Material.TNT) {
|
||||||
|
block.setType(Material.AIR);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
} else if (value == TNTMode.ONLY_TB) {
|
} else if (value == TNTMode.ONLY_TB) {
|
||||||
if (region.getBuildArea().inRegion(block.getLocation(), true)) {
|
if (region.getBuildArea().inRegion(block.getLocation(), true)) {
|
||||||
@@ -57,12 +62,16 @@ public class TNTListener implements Listener, ScoreboardElement {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockExplode(BlockExplodeEvent event) {
|
public void onBlockExplode(BlockExplodeEvent event) {
|
||||||
explode(event.blockList());
|
explode(event.blockList(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public void onExplode(EntityExplodeEvent event) {
|
public void onExplode(EntityExplodeEvent event) {
|
||||||
explode(event.blockList());
|
if (!(event.getEntity() instanceof TNTPrimed)) {
|
||||||
|
event.blockList().clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
explode(event.blockList(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
-45
@@ -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 <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user