Cleanup our iterators.

This commit is contained in:
gmcferrin 2013-01-09 22:18:41 -05:00
parent 6cc2fc7a6e
commit 75a5ffcb10
6 changed files with 12 additions and 31 deletions

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.config;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@ -50,10 +49,8 @@ public class TreasuresConfig extends ConfigLoader{
Map<String, Treasure> treasures = new HashMap<String, Treasure>();
ConfigurationSection treasureSection = config.getConfigurationSection("Treasures");
Set<String> treasureConfigSet = treasureSection.getKeys(false);
Iterator<String> iterator = treasureConfigSet.iterator();
while (iterator.hasNext()) {
String treasureName = iterator.next();
for (String treasureName : treasureConfigSet) {
// Validate all the things!
List<String> reason = new ArrayList<String>();
@ -191,11 +188,8 @@ public class TreasuresConfig extends ConfigLoader{
List<String> excavationTreasures = config.getStringList("Excavation.Treasure");
List<String> fishingTreasures = config.getStringList("Fishing.Treasure");
// Iterator<String> treasureIterator = treasures.keySet().iterator();
Iterator<Entry<String,Treasure>> treasureIterator = treasures.entrySet().iterator();
while (treasureIterator.hasNext()) {
Entry<String,Treasure> nextEntry = treasureIterator.next();
for (Entry<String,Treasure> nextEntry : treasures.entrySet()) {
String treasureKey = nextEntry.getKey();
Treasure treasure = nextEntry.getValue();

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.config.mods;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
@ -54,11 +53,8 @@ public class CustomArmorConfig extends ConfigLoader{
return;
Set<String> armorConfigSet = armorSection.getKeys(false);
Iterator<String> iterator = armorConfigSet.iterator();
while (iterator.hasNext()) {
String armorName = iterator.next();
for (String armorName : armorConfigSet) {
int id = config.getInt(armorType + "." + armorName + ".ID", 0);
boolean repairable = config.getBoolean(armorType + "." + armorName + ".Repairable");
int repairID = config.getInt(armorType + "." + armorName + ".Repair_Material_ID", 0);

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.config.mods;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
@ -54,11 +53,8 @@ public class CustomBlocksConfig extends ConfigLoader {
return;
Set<String> skillConfigSet = skillSection.getKeys(false);
Iterator<String> iterator = skillConfigSet.iterator();
while (iterator.hasNext()) {
String blockName = iterator.next();
for (String blockName : skillConfigSet) {
int id = config.getInt(skillType + "." + blockName + ".ID", 0);
byte data = (byte) config.getInt(skillType + "." + blockName + ".Data_Value", 0);
int xp = config.getInt(skillType + "." + blockName + ".XP_Gain", 0);

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.config.mods;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
@ -58,11 +57,8 @@ public class CustomToolsConfig extends ConfigLoader {
return;
Set<String> toolConfigSet = toolSection.getKeys(false);
Iterator<String> iterator = toolConfigSet.iterator();
while (iterator.hasNext()) {
String toolName = iterator.next();
for (String toolName : toolConfigSet) {
int id = config.getInt(toolType + "." + toolName + ".ID", 0);
double multiplier = config.getDouble(toolType + "." + toolName + ".XP_Modifier", 1.0);
boolean abilityEnabled = config.getBoolean(toolType + "." + toolName + ".Ability_Enabled", true);

View File

@ -33,8 +33,8 @@ public class ChunkletUnloader implements Runnable {
@Override
public void run() {
for (Iterator<Entry<Chunk, Integer>> it = unloadedChunks.entrySet().iterator() ; it.hasNext() ; ) {
Entry<Chunk, Integer> entry = it.next();
for (Iterator<Entry<Chunk, Integer>> unloadedChunkIterator = unloadedChunks.entrySet().iterator() ; unloadedChunkIterator.hasNext() ; ) {
Entry<Chunk, Integer> entry = unloadedChunkIterator.next();
Chunk chunk = entry.getKey();
if (!chunk.isLoaded()) {
@ -46,7 +46,7 @@ public class ChunkletUnloader implements Runnable {
continue;
mcMMO.placeStore.unloadChunk(chunk.getX(), chunk.getZ(), chunk.getWorld());
it.remove();
unloadedChunkIterator.remove();
continue;
}
@ -54,7 +54,7 @@ public class ChunkletUnloader implements Runnable {
}
else {
//Just remove the entry if the chunk has been reloaded.
it.remove();
unloadedChunkIterator.remove();
}
}
}

View File

@ -38,12 +38,11 @@ public class HashChunkManager implements ChunkManager {
public synchronized void closeAll() {
for (UUID uid : regionFiles.keySet()) {
HashMap<Long, mcMMOSimpleRegionFile> worldRegions = regionFiles.get(uid);
Iterator<mcMMOSimpleRegionFile> itr = worldRegions.values().iterator();
while (itr.hasNext()) {
mcMMOSimpleRegionFile rf = itr.next();
for (Iterator<mcMMOSimpleRegionFile> worldRegionIterator = worldRegions.values().iterator(); worldRegionIterator.hasNext();) {
mcMMOSimpleRegionFile rf = worldRegionIterator.next();
if (rf != null) {
rf.close();
itr.remove();
worldRegionIterator.remove();
}
}
}