mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-02 08:39:49 +01:00
Cleanup our iterators.
This commit is contained in:
parent
6cc2fc7a6e
commit
75a5ffcb10
@ -2,7 +2,6 @@ package com.gmail.nossr50.config;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
@ -50,10 +49,8 @@ public class TreasuresConfig extends ConfigLoader{
|
|||||||
Map<String, Treasure> treasures = new HashMap<String, Treasure>();
|
Map<String, Treasure> treasures = new HashMap<String, Treasure>();
|
||||||
ConfigurationSection treasureSection = config.getConfigurationSection("Treasures");
|
ConfigurationSection treasureSection = config.getConfigurationSection("Treasures");
|
||||||
Set<String> treasureConfigSet = treasureSection.getKeys(false);
|
Set<String> treasureConfigSet = treasureSection.getKeys(false);
|
||||||
Iterator<String> iterator = treasureConfigSet.iterator();
|
|
||||||
|
|
||||||
while (iterator.hasNext()) {
|
for (String treasureName : treasureConfigSet) {
|
||||||
String treasureName = iterator.next();
|
|
||||||
|
|
||||||
// Validate all the things!
|
// Validate all the things!
|
||||||
List<String> reason = new ArrayList<String>();
|
List<String> reason = new ArrayList<String>();
|
||||||
@ -191,11 +188,8 @@ public class TreasuresConfig extends ConfigLoader{
|
|||||||
|
|
||||||
List<String> excavationTreasures = config.getStringList("Excavation.Treasure");
|
List<String> excavationTreasures = config.getStringList("Excavation.Treasure");
|
||||||
List<String> fishingTreasures = config.getStringList("Fishing.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()) {
|
for (Entry<String,Treasure> nextEntry : treasures.entrySet()) {
|
||||||
Entry<String,Treasure> nextEntry = treasureIterator.next();
|
|
||||||
String treasureKey = nextEntry.getKey();
|
String treasureKey = nextEntry.getKey();
|
||||||
Treasure treasure = nextEntry.getValue();
|
Treasure treasure = nextEntry.getValue();
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ package com.gmail.nossr50.config.mods;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@ -54,11 +53,8 @@ public class CustomArmorConfig extends ConfigLoader{
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
Set<String> armorConfigSet = armorSection.getKeys(false);
|
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);
|
int id = config.getInt(armorType + "." + armorName + ".ID", 0);
|
||||||
boolean repairable = config.getBoolean(armorType + "." + armorName + ".Repairable");
|
boolean repairable = config.getBoolean(armorType + "." + armorName + ".Repairable");
|
||||||
int repairID = config.getInt(armorType + "." + armorName + ".Repair_Material_ID", 0);
|
int repairID = config.getInt(armorType + "." + armorName + ".Repair_Material_ID", 0);
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.gmail.nossr50.config.mods;
|
package com.gmail.nossr50.config.mods;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@ -54,11 +53,8 @@ public class CustomBlocksConfig extends ConfigLoader {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
Set<String> skillConfigSet = skillSection.getKeys(false);
|
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);
|
int id = config.getInt(skillType + "." + blockName + ".ID", 0);
|
||||||
byte data = (byte) config.getInt(skillType + "." + blockName + ".Data_Value", 0);
|
byte data = (byte) config.getInt(skillType + "." + blockName + ".Data_Value", 0);
|
||||||
int xp = config.getInt(skillType + "." + blockName + ".XP_Gain", 0);
|
int xp = config.getInt(skillType + "." + blockName + ".XP_Gain", 0);
|
||||||
|
@ -2,7 +2,6 @@ package com.gmail.nossr50.config.mods;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@ -58,11 +57,8 @@ public class CustomToolsConfig extends ConfigLoader {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
Set<String> toolConfigSet = toolSection.getKeys(false);
|
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);
|
int id = config.getInt(toolType + "." + toolName + ".ID", 0);
|
||||||
double multiplier = config.getDouble(toolType + "." + toolName + ".XP_Modifier", 1.0);
|
double multiplier = config.getDouble(toolType + "." + toolName + ".XP_Modifier", 1.0);
|
||||||
boolean abilityEnabled = config.getBoolean(toolType + "." + toolName + ".Ability_Enabled", true);
|
boolean abilityEnabled = config.getBoolean(toolType + "." + toolName + ".Ability_Enabled", true);
|
||||||
|
@ -33,8 +33,8 @@ public class ChunkletUnloader implements Runnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for (Iterator<Entry<Chunk, Integer>> it = unloadedChunks.entrySet().iterator() ; it.hasNext() ; ) {
|
for (Iterator<Entry<Chunk, Integer>> unloadedChunkIterator = unloadedChunks.entrySet().iterator() ; unloadedChunkIterator.hasNext() ; ) {
|
||||||
Entry<Chunk, Integer> entry = it.next();
|
Entry<Chunk, Integer> entry = unloadedChunkIterator.next();
|
||||||
Chunk chunk = entry.getKey();
|
Chunk chunk = entry.getKey();
|
||||||
|
|
||||||
if (!chunk.isLoaded()) {
|
if (!chunk.isLoaded()) {
|
||||||
@ -46,7 +46,7 @@ public class ChunkletUnloader implements Runnable {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
mcMMO.placeStore.unloadChunk(chunk.getX(), chunk.getZ(), chunk.getWorld());
|
mcMMO.placeStore.unloadChunk(chunk.getX(), chunk.getZ(), chunk.getWorld());
|
||||||
it.remove();
|
unloadedChunkIterator.remove();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ public class ChunkletUnloader implements Runnable {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//Just remove the entry if the chunk has been reloaded.
|
//Just remove the entry if the chunk has been reloaded.
|
||||||
it.remove();
|
unloadedChunkIterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,12 +38,11 @@ public class HashChunkManager implements ChunkManager {
|
|||||||
public synchronized void closeAll() {
|
public synchronized void closeAll() {
|
||||||
for (UUID uid : regionFiles.keySet()) {
|
for (UUID uid : regionFiles.keySet()) {
|
||||||
HashMap<Long, mcMMOSimpleRegionFile> worldRegions = regionFiles.get(uid);
|
HashMap<Long, mcMMOSimpleRegionFile> worldRegions = regionFiles.get(uid);
|
||||||
Iterator<mcMMOSimpleRegionFile> itr = worldRegions.values().iterator();
|
for (Iterator<mcMMOSimpleRegionFile> worldRegionIterator = worldRegions.values().iterator(); worldRegionIterator.hasNext();) {
|
||||||
while (itr.hasNext()) {
|
mcMMOSimpleRegionFile rf = worldRegionIterator.next();
|
||||||
mcMMOSimpleRegionFile rf = itr.next();
|
|
||||||
if (rf != null) {
|
if (rf != null) {
|
||||||
rf.close();
|
rf.close();
|
||||||
itr.remove();
|
worldRegionIterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user