Optimize FreezeListener
Dieser Commit ist enthalten in:
Ursprung
9e8372a318
Commit
2a0dbaa049
@ -21,7 +21,7 @@ public class FreezeListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onEntitySpawn(EntitySpawnEvent e) {
|
||||
if (Region.getRegion(e.getLocation()).getPlain(Flag.FREEZE, FreezeMode.class) == FreezeMode.INACTIVE) {
|
||||
if (Region.getRegion(e.getLocation()).get(Flag.FREEZE) == FreezeMode.INACTIVE) {
|
||||
return;
|
||||
}
|
||||
e.setCancelled(true);
|
||||
@ -35,7 +35,8 @@ public class FreezeListener implements Listener {
|
||||
@EventHandler
|
||||
public void onBlockCanBuild(BlockCanBuildEvent e) {
|
||||
if (!e.isBuildable()) return;
|
||||
if (Region.getRegion(e.getBlock().getLocation()).getPlain(Flag.FREEZE, FreezeMode.class) == FreezeMode.INACTIVE) return;
|
||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.INACTIVE)
|
||||
return;
|
||||
if (e.getMaterial() == Material.TNT) {
|
||||
e.setBuildable(false);
|
||||
e.getBlock().setType(Material.TNT, false);
|
||||
@ -44,42 +45,58 @@ public class FreezeListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onEntityChangeBlock(EntityChangeBlockEvent e) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).getPlain(Flag.FREEZE, FreezeMode.class) == FreezeMode.ACTIVE) e.setCancelled(true);
|
||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPhysicsEvent(BlockPhysicsEvent e) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).getPlain(Flag.FREEZE, FreezeMode.class) == FreezeMode.ACTIVE) e.setCancelled(true);
|
||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPistonExtend(BlockPistonExtendEvent e) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).getPlain(Flag.FREEZE, FreezeMode.class) == FreezeMode.ACTIVE) e.setCancelled(true);
|
||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPistonRetract(BlockPistonRetractEvent e) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).getPlain(Flag.FREEZE, FreezeMode.class) == FreezeMode.ACTIVE) e.setCancelled(true);
|
||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockGrow(BlockGrowEvent e) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).getPlain(Flag.FREEZE, FreezeMode.class) == FreezeMode.ACTIVE) e.setCancelled(true);
|
||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onRedstoneEvent(BlockRedstoneEvent e) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).getPlain(Flag.FREEZE, FreezeMode.class) == FreezeMode.ACTIVE) e.setNewCurrent(e.getOldCurrent());
|
||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
||||
e.setNewCurrent(e.getOldCurrent());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockDispense(BlockDispenseEvent e) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).getPlain(Flag.FREEZE, FreezeMode.class) == FreezeMode.ACTIVE) e.setCancelled(true);
|
||||
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryMoveEvent(InventoryMoveItemEvent e) {
|
||||
if (Region.getRegion(e.getDestination().getLocation()).getPlain(Flag.FREEZE, FreezeMode.class) == FreezeMode.ACTIVE) e.setCancelled(true);
|
||||
if (Region.getRegion(e.getDestination().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class RamUsage implements Listener {
|
||||
long presumableFreeMemory = Runtime.getRuntime().maxMemory() - allocatedMemory;
|
||||
double percentageFree = presumableFreeMemory / (double) Runtime.getRuntime().maxMemory();
|
||||
bossBar.setProgress(1 - percentageFree);
|
||||
}, 1, 1);
|
||||
}, 20, 20);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -59,9 +59,8 @@ public class FlagStorage {
|
||||
return flags.put(flagType, value) != value;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends Enum<T> & Flag.Value<T>> Flag.Value<T> get(final Flag flagType) {
|
||||
return (Flag.Value<T>) flags.get(flagType);
|
||||
public Flag.Value<?> get(final Flag flagType) {
|
||||
return flags.get(flagType);
|
||||
}
|
||||
|
||||
private void readKeys() {
|
||||
|
@ -51,8 +51,12 @@ public class Region {
|
||||
private static final List<Region> REGION_LIST = new ArrayList<>();
|
||||
|
||||
public static Region getRegion(Location location) {
|
||||
String s = Thread.currentThread().getStackTrace()[2].toString();
|
||||
if (!s.contains("sidebar")) {
|
||||
System.out.println(s +" " + location);
|
||||
}
|
||||
for (Region region : REGION_LIST) {
|
||||
if (region.inRegion(location, RegionType.NORMAL, RegionExtensionType.NORMAL)) {
|
||||
if (region.inRegion(location, region.minPoint, region.maxPoint)) {
|
||||
return region;
|
||||
}
|
||||
}
|
||||
@ -276,7 +280,7 @@ public class Region {
|
||||
setLinkedRegion(region -> region.flagStorage.set(flagType, value));
|
||||
}
|
||||
|
||||
public <T extends Enum<T> & Flag.Value<T>> Flag.Value<T> get(Flag flagType) {
|
||||
public Flag.Value<?> get(Flag flagType) {
|
||||
return flagStorage.get(flagType);
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,6 @@ import yapion.hierarchy.output.FileOutput;
|
||||
import yapion.hierarchy.types.YAPIONObject;
|
||||
import yapion.hierarchy.types.YAPIONType;
|
||||
import yapion.parser.YAPIONParser;
|
||||
import yapion.serializing.YAPIONDeserializer;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren