From 4a4db675f13feb982ec2befa78591c141460a0e8 Mon Sep 17 00:00:00 2001 From: gmcferrin Date: Wed, 9 Jan 2013 23:07:32 -0500 Subject: [PATCH] More OCD. --- .../nossr50/datatypes/PlayerProfile.java | 2 +- .../BlockStoreConversionZDirectory.java | 10 +++--- .../java/com/gmail/nossr50/util/Misc.java | 2 +- .../java/com/gmail/nossr50/util/Page.java | 6 ++-- .../util/blockmeta/HashChunkletManager.java | 16 +++++----- .../blockmeta/PrimitiveChunkletStore.java | 12 +++---- .../blockmeta/PrimitiveExChunkletStore.java | 26 +++++++-------- .../blockmeta/chunkmeta/HashChunkManager.java | 32 +++++++++---------- .../chunkmeta/PrimitiveChunkStore.java | 18 +++++------ .../PrimitiveExChunkletStoreTest.java | 8 ++--- 10 files changed, 66 insertions(+), 66 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java b/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java index bb03f5836..aad5ad144 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java +++ b/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java @@ -931,7 +931,7 @@ public class PlayerProfile { skills.put(skillType, 0); else //do them all { - for(SkillType skill : SkillType.values()) //iterate over all items in the enumeration + for (SkillType skill : SkillType.values()) //iterate over all items in the enumeration { if (skill != SkillType.ALL) // skip the "all" value skills.put(skill, 0); diff --git a/src/main/java/com/gmail/nossr50/runnables/blockstoreconversion/BlockStoreConversionZDirectory.java b/src/main/java/com/gmail/nossr50/runnables/blockstoreconversion/BlockStoreConversionZDirectory.java index 794dd471d..42b021e15 100755 --- a/src/main/java/com/gmail/nossr50/runnables/blockstoreconversion/BlockStoreConversionZDirectory.java +++ b/src/main/java/com/gmail/nossr50/runnables/blockstoreconversion/BlockStoreConversionZDirectory.java @@ -106,11 +106,11 @@ public class BlockStoreConversionZDirectory implements Runnable { this.zPos = this.cz * 16; for (this.x = 0; this.x < 16; this.x++) { - for(this.z = 0; this.z < 16; this.z++) { + for (this.z = 0; this.z < 16; this.z++) { this.cxPos = this.xPos + this.x; this.czPos = this.zPos + this.z; - for(this.y2 = (64 * this.y); this.y2 < (64 * this.y + 64); this.y2++) { + for (this.y2 = (64 * this.y); this.y2 < (64 * this.y + 64); this.y2++) { try { if (!this.manager.isTrue(this.cxPos, this.y2, this.czPos, this.world)) continue; @@ -128,8 +128,8 @@ public class BlockStoreConversionZDirectory implements Runnable { this.newManager.setFalse(this.cx * 16, 0, this.cz * 16, this.world); this.currentChunk = (PrimitiveChunkStore) this.newManager.store.get(this.chunkName); - for(this.x = 0; this.x < 16; this.x++) { - for(this.z = 0; this.z < 16; this.z++) { + for (this.x = 0; this.x < 16; this.x++) { + for (this.z = 0; this.z < 16; this.z++) { if (this.primitiveChunklet != null) this.oldArray = this.primitiveChunklet.store[x][z]; if (this.primitiveExChunklet != null) @@ -149,7 +149,7 @@ public class BlockStoreConversionZDirectory implements Runnable { this.manager.unloadChunk(this.cx, this.cz, this.world); this.newManager.unloadChunk(this.cx, this.cz, this.world); - for(File yFile : dataDir.listFiles()) { + for (File yFile : dataDir.listFiles()) { if (!yFile.exists()) continue; diff --git a/src/main/java/com/gmail/nossr50/util/Misc.java b/src/main/java/com/gmail/nossr50/util/Misc.java index b127ca6c0..31f2aac4a 100644 --- a/src/main/java/com/gmail/nossr50/util/Misc.java +++ b/src/main/java/com/gmail/nossr50/util/Misc.java @@ -249,7 +249,7 @@ public class Misc { * @param quantity The amount of items to drop */ public static void randomDropItems(Location location, ItemStack is, int chance, int quantity) { - for(int i = 0; i < quantity; i++) { + for (int i = 0; i < quantity; i++) { randomDropItem(location, is, chance); } } diff --git a/src/main/java/com/gmail/nossr50/util/Page.java b/src/main/java/com/gmail/nossr50/util/Page.java index ed7c488e0..83e7ef5d6 100644 --- a/src/main/java/com/gmail/nossr50/util/Page.java +++ b/src/main/java/com/gmail/nossr50/util/Page.java @@ -50,7 +50,7 @@ public class Page { public static void clearChat(Player player) { - for(int x = 0; x < 20; x++) + for (int x = 0; x < 20; x++) { player.sendMessage(""); } @@ -70,14 +70,14 @@ public class Page { if (args.length > 1 && Misc.isInt(args[1]) && Misc.getInt(args[1]) <= Page.getTotalPageNumber(address)) { Page.clearChat(player); - for(String target : Page.grabPageContents(capitalized+" Guide", address, Misc.getInt(args[1]))) + for (String target : Page.grabPageContents(capitalized+" Guide", address, Misc.getInt(args[1]))) { player.sendMessage(target); } } else if (args.length == 1) { Page.clearChat(player); - for(String target : Page.grabPageContents(capitalized+" Guide", address, 1)) + for (String target : Page.grabPageContents(capitalized+" Guide", address, 1)) { player.sendMessage(target); } diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java b/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java index d28531a5a..8acfea1c3 100644 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/HashChunkletManager.java @@ -61,7 +61,7 @@ public class HashChunkletManager implements ChunkletManager { File czDir = new File(cxDir, "" + cz); if (!czDir.exists()) return; - for(int y = 0; y < 4; y++) { + for (int y = 0; y < 4; y++) { File yFile = new File(czDir, "" + y); if (!yFile.exists()) { continue; @@ -78,7 +78,7 @@ public class HashChunkletManager implements ChunkletManager { public void unloadChunk(int cx, int cz, World world) { File dataDir = new File(world.getWorldFolder(), "mcmmo_data"); - for(int y = 0; y < 4; y++) { + for (int y = 0; y < 4; y++) { if (store.containsKey(world.getName() + "," + cx + "," + cz + "," + y)) { File cxDir = new File(dataDir, "" + cx); if (!cxDir.exists()) cxDir.mkdir(); @@ -110,7 +110,7 @@ public class HashChunkletManager implements ChunkletManager { if (!dataDir.exists()) dataDir.mkdirs(); - for(String key : store.keySet()) { + for (String key : store.keySet()) { String[] info = key.split(","); if (worldName.equals(info[0])) { File cxDir = new File(dataDir, "" + info[1]); @@ -130,7 +130,7 @@ public class HashChunkletManager implements ChunkletManager { String worldName = world.getName(); - for(String key : store.keySet()) { + for (String key : store.keySet()) { String tempWorldName = key.split(",")[0]; if (tempWorldName.equals(worldName)) { store.remove(key); @@ -141,14 +141,14 @@ public class HashChunkletManager implements ChunkletManager { @Override public void loadWorld(World world) { - //for(Chunk chunk : world.getLoadedChunks()) { + //for (Chunk chunk : world.getLoadedChunks()) { // this.chunkLoaded(chunk.getX(), chunk.getZ(), world); //} } @Override public void saveAll() { - for(World world : Bukkit.getWorlds()) { + for (World world : Bukkit.getWorlds()) { saveWorld(world); } } @@ -156,7 +156,7 @@ public class HashChunkletManager implements ChunkletManager { @Override public void unloadAll() { saveAll(); - for(World world : Bukkit.getWorlds()) { + for (World world : Bukkit.getWorlds()) { unloadWorld(world); } } @@ -253,7 +253,7 @@ public class HashChunkletManager implements ChunkletManager { @Override public void cleanUp() { - for(String key : store.keySet()) { + for (String key : store.keySet()) { if (store.get(key).isEmpty()) { String[] info = key.split(","); File dataDir = new File(Bukkit.getWorld(info[0]).getWorldFolder(), "mcmmo_data"); diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/PrimitiveChunkletStore.java b/src/main/java/com/gmail/nossr50/util/blockmeta/PrimitiveChunkletStore.java index 1bcb2b309..64a149049 100644 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/PrimitiveChunkletStore.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/PrimitiveChunkletStore.java @@ -23,9 +23,9 @@ public class PrimitiveChunkletStore implements ChunkletStore { @Override public boolean isEmpty() { - for(int x = 0; x < 16; x++) { - for(int z = 0; z < 16; z++) { - for(int y = 0; y < 64; y++) { + for (int x = 0; x < 16; x++) { + for (int z = 0; z < 16; z++) { + for (int y = 0; y < 64; y++) { if (store[x][z][y]) return false; } } @@ -35,9 +35,9 @@ public class PrimitiveChunkletStore implements ChunkletStore { @Override public void copyFrom(ChunkletStore otherStore) { - for(int x = 0; x < 16; x++) { - for(int z = 0; z < 16; z++) { - for(int y = 0; y < 64; y++) { + for (int x = 0; x < 16; x++) { + for (int z = 0; z < 16; z++) { + for (int y = 0; y < 64; y++) { store[x][z][y] = otherStore.isTrue(x, y, z); } } diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/PrimitiveExChunkletStore.java b/src/main/java/com/gmail/nossr50/util/blockmeta/PrimitiveExChunkletStore.java index 8cc3bcb42..6644fdd9a 100644 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/PrimitiveExChunkletStore.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/PrimitiveExChunkletStore.java @@ -28,9 +28,9 @@ public class PrimitiveExChunkletStore implements ChunkletStore, Externalizable { @Override public boolean isEmpty() { - for(int x = 0; x < 16; x++) { - for(int z = 0; z < 16; z++) { - for(int y = 0; y < 64; y++) { + for (int x = 0; x < 16; x++) { + for (int z = 0; z < 16; z++) { + for (int y = 0; y < 64; y++) { if (store[x][z][y]) return false; } } @@ -40,9 +40,9 @@ public class PrimitiveExChunkletStore implements ChunkletStore, Externalizable { @Override public void copyFrom(ChunkletStore otherStore) { - for(int x = 0; x < 16; x++) { - for(int z = 0; z < 16; z++) { - for(int y = 0; y < 64; y++) { + for (int x = 0; x < 16; x++) { + for (int z = 0; z < 16; z++) { + for (int y = 0; y < 64; y++) { store[x][z][y] = otherStore.isTrue(x, y, z); } } @@ -54,13 +54,13 @@ public class PrimitiveExChunkletStore implements ChunkletStore, Externalizable { byte[] buffer = new byte[2304]; // 2304 is 16*16*9 int bufferIndex = 0; - for(int x = 0; x < 16; x++) { - for(int z = 0; z < 16; z++) { - for(int y = 0; y < 64; y++) { + for (int x = 0; x < 16; x++) { + for (int z = 0; z < 16; z++) { + for (int y = 0; y < 64; y++) { if (store[x][z][y]) { byte[] temp = constructColumn(x, z); - for(int i = 0; i < 9; i++) { + for (int i = 0; i < 9; i++) { buffer[bufferIndex] = temp[i]; bufferIndex++; } @@ -86,8 +86,8 @@ public class PrimitiveExChunkletStore implements ChunkletStore, Externalizable { int z = addressByteZ(temp[0]); boolean[] yColumn = new boolean[64]; - for(int i = 0; i < 8; i++) { - for(int j = 0; j < 8; j++) { + for (int i = 0; i < 8; i++) { + for (int j = 0; j < 8; j++) { yColumn[j + (i * 8)] = (temp[i + 1] & (1 << j)) != 0; } } @@ -132,7 +132,7 @@ public class PrimitiveExChunkletStore implements ChunkletStore, Externalizable { int subColumnIndex = 8 * i; int subColumnEnd = subColumnIndex + 8; - for(int y = subColumnIndex; y < subColumnEnd; y++) { + for (int y = subColumnIndex; y < subColumnEnd; y++) { if (store[x][z][y]) { yCompressed |= 1 << (y % 8); } diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java index bbe641270..4795cfa17 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/HashChunkManager.java @@ -172,7 +172,7 @@ public class HashChunkManager implements ChunkManager { if (mobs.isEmpty() && pets.isEmpty()) return; - for(LivingEntity entity : world.getLivingEntities()) { + for (LivingEntity entity : world.getLivingEntities()) { if (mobs.contains(entity.getUniqueId())) addSpawnedMob(entity); @@ -192,14 +192,14 @@ public class HashChunkManager implements ChunkManager { if (store.containsKey(world.getName() + "," + cx + "," + cz)) { store.remove(world.getName() + "," + cx + "," + cz); - for(Entity entity : spawnedMobs) { + for (Entity entity : spawnedMobs) { if (!isEntityInChunk(entity, cx, cz, world)) continue; mobsToRemove.add(entity); } - for(Entity entity : spawnedPets) { + for (Entity entity : spawnedPets) { if (!isEntityInChunk(entity, cx, cz, world)) continue; @@ -222,7 +222,7 @@ public class HashChunkManager implements ChunkManager { boolean unloaded = false; if (!store.containsKey(world.getName() + "," + cx + "," + cz)) { List tempSpawnedMobs = new ArrayList(spawnedMobs); - for(Entity entity : tempSpawnedMobs) { + for (Entity entity : tempSpawnedMobs) { if (!isEntityInChunk(entity, cx, cz, world)) continue; @@ -233,7 +233,7 @@ public class HashChunkManager implements ChunkManager { if (!unloaded) { List tempSpawnedPets = new ArrayList(spawnedPets); - for(Entity entity : tempSpawnedPets) { + for (Entity entity : tempSpawnedPets) { if (!isEntityInChunk(entity, cx, cz, world)) continue; @@ -253,7 +253,7 @@ public class HashChunkManager implements ChunkManager { ChunkStore out = store.get(world.getName() + "," + cx + "," + cz); List tempSpawnedMobs = new ArrayList(spawnedMobs); - for(Entity entity : tempSpawnedMobs) { + for (Entity entity : tempSpawnedMobs) { if (!isEntityInChunk(entity, cx, cz, world)) continue; @@ -261,7 +261,7 @@ public class HashChunkManager implements ChunkManager { } List tempSpawnedPets = new ArrayList(spawnedPets); - for(Entity entity : tempSpawnedPets) { + for (Entity entity : tempSpawnedPets) { if (!isEntityInChunk(entity, cx, cz, world)) continue; @@ -319,7 +319,7 @@ public class HashChunkManager implements ChunkManager { String worldName = world.getName(); List keys = new ArrayList(store.keySet()); - for(String key : keys) { + for (String key : keys) { String[] info = key.split(","); if (worldName.equals(info[0])) { int cx = 0; @@ -337,7 +337,7 @@ public class HashChunkManager implements ChunkManager { } List tempSpawnedMobs = new ArrayList(spawnedMobs); - for(Entity entity : tempSpawnedMobs) { + for (Entity entity : tempSpawnedMobs) { World entityWorld = entity.getWorld(); if (world != entityWorld) @@ -350,7 +350,7 @@ public class HashChunkManager implements ChunkManager { } List tempSpawnedPets = new ArrayList(spawnedPets); - for(Entity entity : tempSpawnedPets) { + for (Entity entity : tempSpawnedPets) { World entityWorld = entity.getWorld(); if (world != entityWorld) @@ -372,7 +372,7 @@ public class HashChunkManager implements ChunkManager { String worldName = world.getName(); List keys = new ArrayList(store.keySet()); - for(String key : keys) { + for (String key : keys) { String[] info = key.split(","); if (worldName.equals(info[0])) { int cx = 0; @@ -392,7 +392,7 @@ public class HashChunkManager implements ChunkManager { safeToRemoveMobs = false; List tempSpawnedMobs = new ArrayList(spawnedMobs); - for(Entity entity : tempSpawnedMobs) { + for (Entity entity : tempSpawnedMobs) { World entityWorld = entity.getWorld(); if (world != entityWorld) @@ -405,7 +405,7 @@ public class HashChunkManager implements ChunkManager { } List tempSpawnedPets = new ArrayList(spawnedPets); - for(Entity entity : tempSpawnedPets) { + for (Entity entity : tempSpawnedPets) { World entityWorld = entity.getWorld(); if (world != entityWorld) @@ -431,7 +431,7 @@ public class HashChunkManager implements ChunkManager { public synchronized void saveAll() { closeAll(); - for(World world : Bukkit.getWorlds()) { + for (World world : Bukkit.getWorlds()) { saveWorld(world); } } @@ -440,7 +440,7 @@ public class HashChunkManager implements ChunkManager { public synchronized void unloadAll() { closeAll(); - for(World world : Bukkit.getWorlds()) { + for (World world : Bukkit.getWorlds()) { unloadWorld(world); } } @@ -564,7 +564,7 @@ public class HashChunkManager implements ChunkManager { boolean conversionSet = false; - for(BlockStoreConversionZDirectory converter : this.converters) { + for (BlockStoreConversionZDirectory converter : this.converters) { if (converter == null) continue; diff --git a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/PrimitiveChunkStore.java b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/PrimitiveChunkStore.java index e8a6dd202..245e48f78 100755 --- a/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/PrimitiveChunkStore.java +++ b/src/main/java/com/gmail/nossr50/util/blockmeta/chunkmeta/PrimitiveChunkStore.java @@ -82,9 +82,9 @@ public class PrimitiveChunkStore implements ChunkStore { @Override public boolean isEmpty() { - for(int x = 0; x < 16; x++) { - for(int z = 0; z < 16; z++) { - for(int y = 0; y < this.worldHeight; y++) { + for (int x = 0; x < 16; x++) { + for (int z = 0; z < 16; z++) { + for (int y = 0; y < this.worldHeight; y++) { if (store[x][z][y]) return false; } } @@ -94,9 +94,9 @@ public class PrimitiveChunkStore implements ChunkStore { @Override public void copyFrom(ChunkletStore otherStore) { - for(int x = 0; x < 16; x++) { - for(int z = 0; z < 16; z++) { - for(int y = 0; y < this.worldHeight; y++) { + for (int x = 0; x < 16; x++) { + for (int z = 0; z < 16; z++) { + for (int y = 0; y < this.worldHeight; y++) { store[x][z][y] = otherStore.isTrue(x, y, z); } } @@ -223,9 +223,9 @@ public class PrimitiveChunkStore implements ChunkStore { private void fixArray() { boolean[][][] temp = this.store; this.store = new boolean[16][16][this.worldHeight]; - for(int x = 0; x < 16; x++) { - for(int z = 0; z < 16; z++) { - for(int y = 0; y < this.worldHeight; y++) { + for (int x = 0; x < 16; x++) { + for (int z = 0; z < 16; z++) { + for (int y = 0; y < this.worldHeight; y++) { try { store[x][z][y] = temp[x][y][z]; } diff --git a/src/test/java/com/gmail/nossr50/util/blockmeta/PrimitiveExChunkletStoreTest.java b/src/test/java/com/gmail/nossr50/util/blockmeta/PrimitiveExChunkletStoreTest.java index d0599bfa1..ea47ead79 100644 --- a/src/test/java/com/gmail/nossr50/util/blockmeta/PrimitiveExChunkletStoreTest.java +++ b/src/test/java/com/gmail/nossr50/util/blockmeta/PrimitiveExChunkletStoreTest.java @@ -10,8 +10,8 @@ public class PrimitiveExChunkletStoreTest { @Before public void populateAddresses() { - for(int x = 0; x < 16; x++) { - for(int z = 0; z < 16; z++) { + for (int x = 0; x < 16; x++) { + for (int z = 0; z < 16; z++) { addresses[x][z] = PrimitiveExChunkletStore.makeAddressByte(x, z); } } @@ -25,8 +25,8 @@ public class PrimitiveExChunkletStoreTest { @Test public void addressReverseTest() { - for(int x = 0; x < 16; x++) { - for(int z = 0; z < 16; z++) { + for (int x = 0; x < 16; x++) { + for (int z = 0; z < 16; z++) { assertEquals(x, PrimitiveExChunkletStore.addressByteX(addresses[x][z])); assertEquals(z, PrimitiveExChunkletStore.addressByteZ(addresses[x][z])); }