Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
ad4e5bbb26
Commit
509aa79979
@ -31,11 +31,16 @@ import de.steamwar.bausystem.region.flags.flagvalues.TNTMode;
|
||||
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockExplodeEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
@Linked(LinkageType.LISTENER)
|
||||
@ -44,10 +49,9 @@ public class TNTListener implements Listener {
|
||||
@LinkedInstance
|
||||
public CustomScriptManager customScriptManager;
|
||||
|
||||
@EventHandler
|
||||
public void onExplode(EntityExplodeEvent event) {
|
||||
private void explode(List<Block> blockList, Location location, EventType eventType, Event event) {
|
||||
AtomicBoolean inBuild = new AtomicBoolean();
|
||||
event.blockList().removeIf(block -> {
|
||||
blockList.removeIf(block -> {
|
||||
Region region = Region.getRegion(block.getLocation());
|
||||
TNTMode value = region.getPlain(Flag.TNT);
|
||||
if (value == TNTMode.ALLOW) {
|
||||
@ -66,12 +70,22 @@ public class TNTListener implements Listener {
|
||||
return value == TNTMode.DENY;
|
||||
});
|
||||
if (inBuild.get()) {
|
||||
Region region = Region.getRegion(event.getLocation());
|
||||
Region region = Region.getRegion(location);
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (region.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)) {
|
||||
customScriptManager.callEvent(EventType.TNTExplodeInBuild, player, event);
|
||||
customScriptManager.callEvent(eventType, player, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockExplode(BlockExplodeEvent event) {
|
||||
explode(event.blockList(), event.getBlock().getLocation(), null, null);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onExplode(EntityExplodeEvent event) {
|
||||
explode(event.blockList(), event.getLocation(), EventType.TNTExplodeInBuild, event);
|
||||
}
|
||||
}
|
||||
|
@ -249,9 +249,8 @@ public class CustomScriptManager implements Listener {
|
||||
}
|
||||
|
||||
public void callEvent(EventType eventType, Player p, Event e) {
|
||||
if (!eventType.getEventType().equals(e.getClass())) {
|
||||
return;
|
||||
}
|
||||
if (eventType == null) return;
|
||||
if (!eventType.getEventType().equals(e.getClass())) return;
|
||||
|
||||
List<CustomScript.CustomEvent> customEvents = playerMap.getOrDefault(p, new ArrayList<>()).stream().filter(CustomScript.CustomEvent.class::isInstance).map(CustomScript.CustomEvent.class::cast).collect(Collectors.toList());
|
||||
for (CustomScript.CustomEvent customEvent : customEvents) {
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren