Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
509aa79979
Commit
f854f4896f
@ -5,23 +5,36 @@ import de.steamwar.bausystem.linkage.Linked;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
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.Listener;
|
||||
import org.bukkit.event.block.BlockExplodeEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Linked(LinkageType.LISTENER)
|
||||
public class ProtectListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onExplode(EntityExplodeEvent event) {
|
||||
Region region = Region.getRegion(event.getLocation());
|
||||
private void explode(List<Block> blockList, Location location) {
|
||||
Region region = Region.getRegion(location);
|
||||
if (region.getFloorLevel() == 0) {
|
||||
return;
|
||||
}
|
||||
if (region.getPlain(Flag.PROTECT, ProtectMode.class) == ProtectMode.INACTIVE) {
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren