From 9828bd7f404b70fc482bcf1a24323a6992d0ae0a Mon Sep 17 00:00:00 2001 From: SenseiKiwi Date: Sat, 15 Jun 2013 11:30:05 -0400 Subject: [PATCH] Fixed duplicate custom dungeon listing Removed a line in CommandEndDungeonCreation that inserted a new dungeon directly into DungeonHelper.customDungeons. This had a chance of causing a duplicate listing. registerCustomDungeon() was already being invoked before and if reading tags from the file name failed, the dungeon would get added twice. This could explain some of the buggy dungeon listing that would appear during testing. --- .../mod_pocketDim/commands/CommandEndDungeonCreation.java | 1 - StevenDimDoors/mod_pocketDim/helpers/DungeonHelper.java | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/StevenDimDoors/mod_pocketDim/commands/CommandEndDungeonCreation.java b/StevenDimDoors/mod_pocketDim/commands/CommandEndDungeonCreation.java index 891155a..37192c9 100644 --- a/StevenDimDoors/mod_pocketDim/commands/CommandEndDungeonCreation.java +++ b/StevenDimDoors/mod_pocketDim/commands/CommandEndDungeonCreation.java @@ -63,7 +63,6 @@ public class CommandEndDungeonCreation extends CommandBase { DungeonGenerator newDungeon = mod_pocketDim.dungeonHelper.exportDungeon(player.worldObj, x, y, z, properties.CustomSchematicDirectory + "/" + var2[0] + ".schematic"); player.sendChatToPlayer("created dungeon schematic in " + properties.CustomSchematicDirectory + "/" + var2[0]+".schematic"); - mod_pocketDim.dungeonHelper.customDungeons.add(newDungeon); if (mod_pocketDim.dungeonHelper.customDungeonStatus.containsKey(player.worldObj.provider.dimensionId) && !player.worldObj.isRemote) { diff --git a/StevenDimDoors/mod_pocketDim/helpers/DungeonHelper.java b/StevenDimDoors/mod_pocketDim/helpers/DungeonHelper.java index 6711eba..5ab4174 100644 --- a/StevenDimDoors/mod_pocketDim/helpers/DungeonHelper.java +++ b/StevenDimDoors/mod_pocketDim/helpers/DungeonHelper.java @@ -31,6 +31,7 @@ public class DungeonHelper private static final String SCHEMATIC_FILE_EXTENSION = ".schematic"; private static final int DEFAULT_DUNGEON_WEIGHT = 100; + private static final int MAX_DUNGEON_WEIGHT = 10000; //Used to prevent overflows and math breaking down private static final String HUB_DUNGEON_TYPE = "Hub"; private static final String TRAP_DUNGEON_TYPE = "Trap"; @@ -125,7 +126,7 @@ public class DungeonHelper try { int weight = Integer.parseInt(dungeonData[3]); - if (weight < 0) + if (weight < 0 || weight > MAX_DUNGEON_WEIGHT) return false; } catch (NumberFormatException e) @@ -158,6 +159,7 @@ public class DungeonHelper dungeonTypeMapping.get(dungeonType).add(generator); weightedDungeonGenList.add(generator); registeredDungeons.add(generator); + customDungeons.add(generator); System.out.println("Imported " + name); } else