diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java index ba3fb9d4f9..08ff697ebc 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java @@ -73,7 +73,9 @@ public class CraftChunk implements Chunk { } Entity[] entities = new Entity[count]; for (int i = 0; i < 8; i++) { - for (net.minecraft.server.Entity entity : (net.minecraft.server.Entity[])chunk.m[i].toArray()) { + for (Object obj : (net.minecraft.server.Entity[])chunk.m[i].toArray()) { + if (!(obj instanceof net.minecraft.server.Entity)) continue; + net.minecraft.server.Entity entity = (net.minecraft.server.Entity) obj; entities[index++] = entity.getBukkitEntity(); } } @@ -84,7 +86,9 @@ public class CraftChunk implements Chunk { int index = 0; net.minecraft.server.Chunk chunk = getHandle(); BlockState[] entities = new BlockState[chunk.l.size()]; - for (ChunkPosition position : (ChunkPosition[])chunk.l.keySet().toArray()) { + for (Object obj : chunk.l.keySet().toArray()) { + if (!(obj instanceof ChunkPosition)) continue; + ChunkPosition position = (ChunkPosition) obj; entities[index++] = worldServer.getWorld().getBlockAt(position.a, position.b, position.c).getState(); } return entities; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java index da71e4f076..854cc9c4ab 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -118,7 +118,7 @@ public final class CraftServer implements Server { found = player; delta = curDelta; } - if(curDelta == 0) break; + if (curDelta == 0) break; } } return found; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 194873650c..2dda576593 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -155,7 +155,7 @@ public class CraftWorld implements World { net.minecraft.server.Chunk chunk = null; - if(provider.c == null) { + if (provider.c == null) { chunk = provider.b; } else { chunk = provider.c.b(x, z); @@ -169,7 +169,7 @@ public class CraftWorld implements World { } public boolean refreshChunk(int x, int z) { - if(!isChunkLoaded(x, z)) { + if (!isChunkLoaded(x, z)) { return false; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index d6d1ebfb6c..14c6231467 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -92,7 +92,7 @@ public class CraftBlock implements Block { } public void setData(final byte data, boolean applyPhysics) { - if(applyPhysics) { + if (applyPhysics) { chunk.getHandle().d.c(x, y, z, data); } else { chunk.getHandle().d.d(x, y, z, data); @@ -128,7 +128,7 @@ public class CraftBlock implements Block { } public boolean setTypeId(final int type, final boolean applyPhysics) { - if(applyPhysics) { + if (applyPhysics) { return setTypeId(type); } else { return chunk.getHandle().d.setTypeId(x, y, z, type); @@ -136,7 +136,7 @@ public class CraftBlock implements Block { } public boolean setTypeIdAndData(final int type, final byte data, final boolean applyPhysics) { - if(applyPhysics) { + if (applyPhysics) { return chunk.getHandle().d.b(x, y, z, type, data); } else { return chunk.getHandle().d.setTypeIdAndData(x, y, z, type, data); @@ -383,12 +383,12 @@ public class CraftBlock implements Block { int power = 0; BlockRedstoneWire wire = (BlockRedstoneWire) net.minecraft.server.Block.REDSTONE_WIRE; net.minecraft.server.World world = chunk.getHandle().d; - if((face == BlockFace.DOWN || face == BlockFace.SELF) && world.i(x, y - 1, z, 0)) power = wire.g(world, x, y - 1, z, power); - if((face == BlockFace.UP || face == BlockFace.SELF) && world.i(x, y + 1, z, 1)) power = wire.g(world, x, y + 1, z, power); - if((face == BlockFace.EAST || face == BlockFace.SELF) && world.i(x, y, z - 1, 2)) power = wire.g(world, x, y, z - 1, power); - if((face == BlockFace.WEST || face == BlockFace.SELF) && world.i(x, y, z + 1, 3)) power = wire.g(world, x, y, z + 1, power); - if((face == BlockFace.NORTH || face == BlockFace.SELF) && world.i(x - 1, y, z, 4)) power = wire.g(world, x - 1, y, z, power); - if((face == BlockFace.SOUTH || face == BlockFace.SELF) && world.i(x + 1, y, z, 5)) power = wire.g(world, x + 1, y, z, power); + if ((face == BlockFace.DOWN || face == BlockFace.SELF) && world.i(x, y - 1, z, 0)) power = wire.g(world, x, y - 1, z, power); + if ((face == BlockFace.UP || face == BlockFace.SELF) && world.i(x, y + 1, z, 1)) power = wire.g(world, x, y + 1, z, power); + if ((face == BlockFace.EAST || face == BlockFace.SELF) && world.i(x, y, z - 1, 2)) power = wire.g(world, x, y, z - 1, power); + if ((face == BlockFace.WEST || face == BlockFace.SELF) && world.i(x, y, z + 1, 3)) power = wire.g(world, x, y, z + 1, power); + if ((face == BlockFace.NORTH || face == BlockFace.SELF) && world.i(x - 1, y, z, 4)) power = wire.g(world, x - 1, y, z, power); + if ((face == BlockFace.SOUTH || face == BlockFace.SELF) && world.i(x + 1, y, z, 5)) power = wire.g(world, x + 1, y, z, power); return face == BlockFace.SELF ? power - 1 : power; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index bdaefb3f84..1bd194d86b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -61,7 +61,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } public double getEyeHeight(boolean ignoreSneaking) { - if(ignoreSneaking) { + if (ignoreSneaking) { return 1.62D; } else { if (isSneaking()) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVehicle.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVehicle.java index cec4bc3df3..20c52a9d55 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVehicle.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVehicle.java @@ -19,7 +19,7 @@ public abstract class CraftVehicle extends CraftEntity implements Vehicle { } public boolean setPassenger(Entity passenger) { - if(passenger instanceof CraftEntity){ + if (passenger instanceof CraftEntity){ ((CraftEntity)passenger).getHandle().setPassengerOf(getHandle()); return true; } else { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/scheduler/CraftFuture.java b/paper-server/src/main/java/org/bukkit/craftbukkit/scheduler/CraftFuture.java index 0952a2caa9..ca596fefe4 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/scheduler/CraftFuture.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/scheduler/CraftFuture.java @@ -25,7 +25,7 @@ public class CraftFuture<T> implements Runnable, Future<T> { public void run() { synchronized(this) { - if(cancelled) { + if (cancelled) { return; } running = true; @@ -51,7 +51,7 @@ public class CraftFuture<T> implements Runnable, Future<T> { public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { synchronized(this) { - if(isDone()) { + if (isDone()) { return getResult(); } this.wait(TimeUnit.MILLISECONDS.convert(timeout, unit)); @@ -60,10 +60,10 @@ public class CraftFuture<T> implements Runnable, Future<T> { } public T getResult() throws ExecutionException { - if(cancelled) { + if (cancelled) { throw new CancellationException(); } - if(e!=null) { + if (e!=null) { throw new ExecutionException(e); } return returnStore.getObject(); @@ -83,14 +83,14 @@ public class CraftFuture<T> implements Runnable, Future<T> { public boolean cancel(boolean mayInterruptIfRunning) { synchronized(this) { - if(cancelled) { + if (cancelled) { return false; } cancelled = true; - if(taskId!=-1) { + if (taskId!=-1) { craftScheduler.cancelTask(taskId); } - if(!running && !done) { + if (!running && !done) { return true; } else { return false; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/LongHashtable.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/LongHashtable.java index 1dffee0795..bb46c621ac 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/LongHashtable.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/LongHashtable.java @@ -13,9 +13,9 @@ public class LongHashtable<V> extends LongHash public void put(int msw, int lsw, V value) { put(toLong(msw, lsw), value); - if(value instanceof Chunk) { + if (value instanceof Chunk) { Chunk c = (Chunk)value; - if(msw != c.j || lsw != c.k) { + if (msw != c.j || lsw != c.k) { MinecraftServer.a.info("Chunk (" + c.j + ", " + c.k +") stored at (" + msw + ", " + lsw + ")"); Throwable x = new Throwable(); x.fillInStackTrace(); @@ -26,9 +26,9 @@ public class LongHashtable<V> extends LongHash public V get(int msw, int lsw) { V value = get(toLong(msw, lsw)); - if(value instanceof Chunk) { + if (value instanceof Chunk) { Chunk c = (Chunk)value; - if(msw != c.j || lsw != c.k) { + if (msw != c.j || lsw != c.k) { MinecraftServer.a.info("Chunk (" + c.j + ", " + c.k +") stored at (" + msw + ", " + lsw + ")"); Throwable x = new Throwable(); x.fillInStackTrace(); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/SoftMap.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/SoftMap.java index 1b8f6c47bc..29d6f76f22 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/SoftMap.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/SoftMap.java @@ -100,13 +100,13 @@ public class SoftMap<K,V> { private V fastGet(K key) { SoftMapReference<K,V> ref = map.get(key); - if(ref==null) { + if (ref==null) { return null; } V value = ref.get(); - if(value!=null) { + if (value!=null) { strongReferenceQueue.addFirst(value); - if(strongReferenceQueue.size() > strongReferenceSize) { + if (strongReferenceQueue.size() > strongReferenceSize) { strongReferenceQueue.removeLast(); } } @@ -146,7 +146,7 @@ public class SoftMap<K,V> { private void fastPut(K key, V value) { map.put(key, new SoftMapReference<K,V>(key, value, queue)); strongReferenceQueue.addFirst(value); - if(strongReferenceQueue.size() > strongReferenceSize) { + if (strongReferenceQueue.size() > strongReferenceSize) { strongReferenceQueue.removeLast(); } } @@ -167,7 +167,7 @@ public class SoftMap<K,V> { public V remove(K key) { emptyQueue(); SoftMapReference<K,V> ref = map.remove(key); - if(ref != null) { + if (ref != null) { return ref.get(); } return null;