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