mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-29 16:46:46 +01:00
Add support for data value ranges in blocks.yml
For example `Block_1|0-5`
This commit is contained in:
parent
75cbfa1b1c
commit
a80cdaff71
@ -68,19 +68,40 @@ public class CustomBlockConfig extends ConfigLoader {
|
|||||||
Material blockMaterial = Material.matchMaterial(blockInfo[0]);
|
Material blockMaterial = Material.matchMaterial(blockInfo[0]);
|
||||||
|
|
||||||
if (blockMaterial == null) {
|
if (blockMaterial == null) {
|
||||||
plugin.getLogger().warning("Invalid material name. This item will be skipped. - " + blockInfo[0]);
|
plugin.getLogger().warning("Invalid material name. [" + blockInfo[0] + "] This item will be skipped. - " + blockName);
|
||||||
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 startData = Byte.valueOf(dataInfo[0]);
|
||||||
|
byte endData = Byte.valueOf(dataInfo[1]);
|
||||||
|
|
||||||
|
for (byte blockData = startData; blockData <= endData; blockData++) {
|
||||||
|
MaterialData blockMaterialData = new MaterialData(blockMaterial, blockData);
|
||||||
|
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");
|
||||||
@ -103,4 +124,3 @@ 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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user