Add support for data value ranges in blocks.yml

For example `Block_1|0-5`
This commit is contained in:
TfT_02 2014-06-09 13:40:29 +02:00
parent 001ea19b1c
commit 44a4448527

View File

@ -72,15 +72,36 @@ public class CustomBlockConfig extends ConfigLoader {
continue; continue;
} }
byte blockData = (blockInfo.length == 2) ? Byte.valueOf(blockInfo[1]) : 0; if (blockInfo.length == 2) {
MaterialData blockMaterialData = new MaterialData(blockMaterial, blockData); String[] dataInfo = blockInfo[1].split("[-]");
if (dataInfo.length == 2) {
byte startByte = Byte.valueOf(dataInfo[0]);
byte endByte = Byte.valueOf(dataInfo[1]);
for (byte i = startByte; i < endByte; i++) {
MaterialData blockMaterialData = new MaterialData(blockMaterial, i);
loadBlock(skillType, blockList, blockName, blockMaterialData);
}
return;
}
}
byte blockData = (blockInfo.length == 2) ? Byte.valueOf(blockInfo[1]) : 0;
MaterialData blockMaterialData = new MaterialData(blockMaterial, blockData);
loadBlock(skillType, blockList, blockName, blockMaterialData);
}
}
private void loadBlock(String skillType, List<MaterialData> blockList, String blockName, MaterialData blockMaterialData) {
if (blockList != null) { if (blockList != null) {
blockList.add(blockMaterialData); blockList.add(blockMaterialData);
} }
if (skillType.equals("Ability_Blocks")) { if (skillType.equals("Ability_Blocks")) {
continue; return;
} }
int xp = config.getInt(skillType + "." + blockName + ".XP_Gain"); int xp = config.getInt(skillType + "." + blockName + ".XP_Gain");
@ -102,5 +123,4 @@ public class CustomBlockConfig extends ConfigLoader {
customBlockMap.put(blockMaterialData, new CustomBlock(xp, config.getBoolean(skillType + "." + blockName + ".Double_Drops_Enabled"), smeltingXp)); customBlockMap.put(blockMaterialData, new CustomBlock(xp, config.getBoolean(skillType + "." + blockName + ".Double_Drops_Enabled"), smeltingXp));
} }
}
} }