Simplify RegionSystem
Dieser Commit ist enthalten in:
Ursprung
828fb025aa
Commit
97d626fcb3
@ -47,16 +47,12 @@ public class CommandFire extends RegionToggleCommand {
|
||||
|
||||
@EventHandler
|
||||
public void onFireDamage(BlockBurnEvent e) {
|
||||
Region.getRegion(e.getBlock().getLocation(), region -> {
|
||||
if (region.isFire()) e.setCancelled(true);
|
||||
});
|
||||
if (Region.getRegion(e.getBlock().getLocation()).isFire()) e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onFireSpread(BlockSpreadEvent e){
|
||||
Region.getRegion(e.getBlock().getLocation(), region -> {
|
||||
if (region.isFire()) e.setCancelled(true);
|
||||
});
|
||||
if (Region.getRegion(e.getBlock().getLocation()).isFire()) e.setCancelled(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27,6 +27,8 @@ import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||
|
||||
import java.sql.Ref;
|
||||
|
||||
public class CommandFreeze extends RegionToggleCommand {
|
||||
|
||||
@Override
|
||||
@ -50,78 +52,56 @@ public class CommandFreeze extends RegionToggleCommand {
|
||||
|
||||
@EventHandler
|
||||
public void onEntitySpawn(EntitySpawnEvent e) {
|
||||
Region.getRegion(e.getLocation(), region -> {
|
||||
if (region.isFreeze()) e.setCancelled(true);
|
||||
});
|
||||
if (Region.getRegion(e.getLocation()).isFreeze()) e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockCanBuild(BlockCanBuildEvent e) {
|
||||
if (!e.isBuildable()) return;
|
||||
Region.getRegion(e.getBlock().getLocation(), region -> {
|
||||
if (!region.isFreeze()) {
|
||||
return;
|
||||
}
|
||||
if (e.getMaterial() == Material.TNT) {
|
||||
e.setBuildable(false);
|
||||
e.getBlock().setType(Material.TNT, false);
|
||||
}
|
||||
});
|
||||
if (!Region.getRegion(e.getBlock().getLocation()).isFreeze()) return;
|
||||
if (e.getMaterial() == Material.TNT) {
|
||||
e.setBuildable(false);
|
||||
e.getBlock().setType(Material.TNT, false);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityChangeBlock(EntityChangeBlockEvent e) {
|
||||
Region.getRegion(e.getBlock().getLocation(), region -> {
|
||||
if (region.isFreeze()) e.setCancelled(true);
|
||||
});
|
||||
if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPhysicsEvent(BlockPhysicsEvent e){
|
||||
Region.getRegion(e.getBlock().getLocation(), region -> {
|
||||
if (region.isFreeze()) e.setCancelled(true);
|
||||
});
|
||||
if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPistonExtend(BlockPistonExtendEvent e){
|
||||
Region.getRegion(e.getBlock().getLocation(), region -> {
|
||||
if (region.isFreeze()) e.setCancelled(true);
|
||||
});
|
||||
if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPistonRetract(BlockPistonRetractEvent e){
|
||||
Region.getRegion(e.getBlock().getLocation(), region -> {
|
||||
if (region.isFreeze()) e.setCancelled(true);
|
||||
});
|
||||
if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockGrow(BlockGrowEvent e){
|
||||
Region.getRegion(e.getBlock().getLocation(), region -> {
|
||||
if (region.isFreeze()) e.setCancelled(true);
|
||||
});
|
||||
if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onRedstoneEvent(BlockRedstoneEvent e){
|
||||
Region.getRegion(e.getBlock().getLocation(), region -> {
|
||||
if (region.isFreeze()) e.setNewCurrent(e.getOldCurrent());
|
||||
});
|
||||
if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setNewCurrent(e.getOldCurrent());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockDispense(BlockDispenseEvent e){
|
||||
Region.getRegion(e.getBlock().getLocation(), region -> {
|
||||
if (region.isFreeze()) e.setCancelled(true);
|
||||
});
|
||||
if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryMoveEvent(InventoryMoveItemEvent e){
|
||||
Region.getRegion(e.getDestination().getLocation(), region -> {
|
||||
if (region.isFreeze()) e.setCancelled(true);
|
||||
});
|
||||
if (Region.getRegion(e.getDestination().getLocation()).isFreeze()) e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -73,17 +73,6 @@ public class Region {
|
||||
return GlobalRegion.getInstance();
|
||||
}
|
||||
|
||||
public static void getRegion(Location location, Consumer<Region> regionConsumer) {
|
||||
boolean b = true;
|
||||
for (Region region : regions) {
|
||||
if (region.inRegion(location)) {
|
||||
regionConsumer.accept(region);
|
||||
b = false;
|
||||
}
|
||||
}
|
||||
if (b) regionConsumer.accept(GlobalRegion.getInstance());
|
||||
}
|
||||
|
||||
private final String name;
|
||||
private final int minX;
|
||||
private final int minY;
|
||||
@ -228,31 +217,16 @@ public class Region {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fastreset() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTestblock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetTestblock(Schematic schem) throws IOException, NoClipboardException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasProtection() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void protect(Schematic schem) throws IOException, NoClipboardException {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class Prototype{
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren