SteamWar/BauSystem2.0
Archiviert
12
0

Closes: #126
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2022-08-28 13:53:30 +02:00
Ursprung 509aa79979
Commit f854f4896f

Datei anzeigen

@ -5,23 +5,36 @@ import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.region.flags.flagvalues.ProtectMode; import de.steamwar.bausystem.region.flags.flagvalues.ProtectMode;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockExplodeEvent;
import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityExplodeEvent;
import java.util.List;
@Linked(LinkageType.LISTENER) @Linked(LinkageType.LISTENER)
public class ProtectListener implements Listener { public class ProtectListener implements Listener {
@EventHandler private void explode(List<Block> blockList, Location location) {
public void onExplode(EntityExplodeEvent event) { Region region = Region.getRegion(location);
Region region = Region.getRegion(event.getLocation());
if (region.getFloorLevel() == 0) { if (region.getFloorLevel() == 0) {
return; return;
} }
if (region.getPlain(Flag.PROTECT, ProtectMode.class) == ProtectMode.INACTIVE) { if (region.getPlain(Flag.PROTECT, ProtectMode.class) == ProtectMode.INACTIVE) {
return; return;
} }
event.blockList().removeIf(block -> block.getY() < region.getFloorLevel()); blockList.removeIf(block -> block.getY() < region.getFloorLevel());
} }
@EventHandler
public void onBlockExplode(BlockExplodeEvent event) {
explode(event.blockList(), event.getBlock().getLocation());
}
@EventHandler
public void onExplode(EntityExplodeEvent event) {
explode(event.blockList(), event.getLocation());
}
} }