Skip to content

Commit

Permalink
Semi alpha 1.14 update - Remove blocktype entirely (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
RoboMWM committed Jun 22, 2019
1 parent 5c6d261 commit f00ecfd
Show file tree
Hide file tree
Showing 14 changed files with 136 additions and 586 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<!-- Project properties. -->
<groupId>com.extrahardmode</groupId>
<artifactId>ExtraHardMode</artifactId>
<version>3.13.2</version>
<version>3.14.alpha</version>
<name>ExtraHardMode</name>
<description>New game rules and mechanics for Minecraft.</description>
<url>http://dev.bukkit.org/projects/fun-hard-mode</url>
Expand Down
39 changes: 19 additions & 20 deletions src/main/java/com/extrahardmode/config/EHMConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@
import com.extrahardmode.service.IoHelper;
import com.extrahardmode.service.config.*;
import com.extrahardmode.service.config.customtypes.BlockRelationsList;
import com.extrahardmode.service.config.customtypes.BlockType;
import com.extrahardmode.service.config.customtypes.BlockTypeList;
import com.extrahardmode.service.config.customtypes.PotionEffectHolder;
import org.apache.commons.lang.Validate;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
Expand Down Expand Up @@ -474,27 +473,27 @@ public void loadNodes()
obj = PotionEffectHolder.loadFromConfig(section);
break;
}
case BLOCKTYPE:
case MATERIAL:
{
if (mConfig.getString(node.getPath()) != null)
obj = BlockType.loadFromConfig(mConfig.getString(node.getPath()));
obj = Material.matchMaterial(mConfig.getString(node.getPath()));
break;
}
case BLOCKTYPE_LIST:
case MATERIAL_LIST:
{
List<Material> materialList = new ArrayList<>();
if (mConfig.get(node.getPath()) instanceof List)
{
List<String> list = mConfig.getStringList(node.getPath());
BlockTypeList blocks = new BlockTypeList();
for (String str : list)
{
BlockType block = BlockType.loadFromConfig(str);
if (block != null)
blocks.add(block);
Material material = Material.matchMaterial(str);
if (material != null)
materialList.add(material);
}
obj = blocks;
obj = materialList;
} else if (mConfig.isSet(node.getPath()))
obj = BlockTypeList.EMPTY_LIST;
obj = materialList; //obj = BlockTypeList.EMPTY_LIST; //No idea why this is empty but ok?
break;
}
case BLOCK_RELATION_LIST:
Expand Down Expand Up @@ -568,22 +567,22 @@ private void saveNodes()
//Custom writing code for our custom objects
switch (node.getVarType())
{
case BLOCKTYPE:
case MATERIAL:
{
if (value instanceof BlockType)
if (value instanceof Material)
{
outConfig.set(node.getPath(), ((BlockType) value).saveToString());
outConfig.set(node.getPath(), ((Material)value).name());
break;
}
}
case BLOCKTYPE_LIST:
case MATERIAL_LIST:
{
if (value instanceof BlockTypeList)
if (value instanceof ArrayList)
{
List<String> blockStrings = new ArrayList<String>();
for (BlockType blockType : ((BlockTypeList) value).toArray())
blockStrings.add(blockType.saveToString());
outConfig.set(node.getPath(), blockStrings);
List<String> materialStrings = new ArrayList<>();
for (Material material : (ArrayList<Material>)value)
materialStrings.add(material.name());
outConfig.set(node.getPath(), materialStrings);
break;
}
}
Expand Down
75 changes: 38 additions & 37 deletions src/main/java/com/extrahardmode/config/RootNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
import com.extrahardmode.service.config.ConfigNode;
import com.extrahardmode.service.config.MultiWorldConfig;
import com.extrahardmode.service.config.customtypes.BlockRelationsList;
import com.extrahardmode.service.config.customtypes.BlockType;
import com.extrahardmode.service.config.customtypes.BlockTypeList;
import com.extrahardmode.service.config.customtypes.PotionEffectHolder;
import org.bukkit.Material;
import org.bukkit.potion.PotionEffectType;
Expand Down Expand Up @@ -96,7 +94,7 @@ public enum RootNode implements ConfigNode
*/
SUPER_HARD_STONE("World Rules.Mining.Inhibit Tunneling.Enable", VarType.BOOLEAN, true,
"If hardened blocks can only be broken by specific tools"),
SUPER_HARD_BLOCKS("World Rules.Mining.Inhibit Tunneling.Hardened Blocks", VarType.BLOCKTYPE_LIST, new DefaultHardBlocks(),
SUPER_HARD_BLOCKS("World Rules.Mining.Inhibit Tunneling.Hardened Blocks", VarType.MATERIAL_LIST, new DefaultHardBlocks(),
"These blocks will be treated as hardened"),
/**
* If ore placement next to stone blocks should be blocked to prevent tunneling
Expand All @@ -111,7 +109,7 @@ public enum RootNode implements ConfigNode
/**
* whether stone is hardened to encourage cave exploration over tunneling
*/
SUPER_HARD_STONE_TOOLS("World Rules.Mining.Inhibit Tunneling.Amount of Stone Tool Can Mine (Tool@Blocks)", VarType.BLOCKTYPE_LIST, new DefaultToolDurabilities(),
SUPER_HARD_STONE_TOOLS("World Rules.Mining.Inhibit Tunneling.Amount of Stone Tool Can Mine (Tool@Blocks)", VarType.MATERIAL_LIST, new DefaultToolDurabilities(),
"List of tools that can mine stone. If a tool isn't in the list it can't mine stone.",
"F.e. DIAMOND_PICKAXE@100 = Mine 100 stone blocks -> pick broken"),
/**
Expand All @@ -128,7 +126,7 @@ public enum RootNode implements ConfigNode
/**
* These Blocks will turn surrounding stone into cobblestone
*/
SUPER_HARD_STONE_ORE_BLOCKS("World Rules.Mining.Breaking Blocks Softens Surrounding Stone.Blocks (Block@id,id2)", VarType.BLOCKTYPE_LIST, new DefaultPhysicsBlocks(),
SUPER_HARD_STONE_ORE_BLOCKS("World Rules.Mining.Breaking Blocks Softens Surrounding Stone.Blocks (Block@id,id2)", VarType.MATERIAL_LIST, new DefaultPhysicsBlocks(),
"Ore blocks that will soften surrounding stone blocks."),
/**
* Stone Blocks and their counter respective cobblestone blocks
Expand Down Expand Up @@ -276,9 +274,9 @@ public enum RootNode implements ConfigNode
/**
* List of items that count as tools
*/
PLAYER_DEATH_TOOLS_LIST("Player.Death.Loose Items On Death.Tools", VarType.BLOCKTYPE_LIST, new DefaultValuableTools(),
PLAYER_DEATH_TOOLS_LIST("Player.Death.Loose Items On Death.Tools", VarType.MATERIAL_LIST, new DefaultValuableTools(),
"Tool settings apply only to these tools"),
PLAYER_DEATH_ITEMS_BLACKLIST("Player.Death.Loose Items On Death.Blacklisted Items", VarType.BLOCKTYPE_LIST, BlockTypeList.EMPTY_LIST,
PLAYER_DEATH_ITEMS_BLACKLIST("Player.Death.Loose Items On Death.Blacklisted Items", VarType.MATERIAL_LIST, new ArrayList<Material>(),
"These items will never be removed on death."),
/**
* Enable custom Health
Expand Down Expand Up @@ -887,7 +885,7 @@ public enum RootNode implements ConfigNode
/**
* which materials beyond sand and gravel should be subject to gravity
*/
MORE_FALLING_BLOCKS("Additional Falling Blocks.Enabled Blocks", VarType.BLOCKTYPE_LIST, new DefaultFallingBlocks()),
MORE_FALLING_BLOCKS("Additional Falling Blocks.Enabled Blocks", VarType.MATERIAL_LIST, new DefaultFallingBlocks()),

/**
* ##############################
Expand Down Expand Up @@ -1376,9 +1374,9 @@ public Object getValueToDisable()
obj = Collections.emptyList();
break;
}
case BLOCKTYPE_LIST:
case MATERIAL_LIST:
{
obj = BlockTypeList.EMPTY_LIST;
obj = new ArrayList<Material>();
break;
}
case BLOCK_RELATION_LIST:
Expand Down Expand Up @@ -1437,60 +1435,63 @@ public Object get()
/**
* Default list of falling blocks.
*/
private static class DefaultFallingBlocks extends BlockTypeList
private static class DefaultFallingBlocks extends ArrayList<Material>
{
/**
* Constructor.
*/
public DefaultFallingBlocks()
{
super();
this.add(new BlockType(Material.DIRT));
this.add(new BlockType(Material.GRASS));
this.add(new BlockType(Material.COBBLESTONE));
this.add(new BlockType(Material.MOSSY_COBBLESTONE));
this.add(new BlockType(Material.STONE_SLAB));
this.add(new BlockType(Material.COBBLESTONE_SLAB));
this.add(new BlockType(Material.MYCELIUM));
this.add(Material.DIRT);
this.add(Material.GRASS);
this.add(Material.COBBLESTONE);
this.add(Material.MOSSY_COBBLESTONE);
this.add(Material.STONE_SLAB);
this.add(Material.COBBLESTONE_SLAB);
this.add(Material.MYCELIUM);
}
}


/**
* Default list of falling blocks.
*/
private static class DefaultPhysicsBlocks extends BlockTypeList
private static class DefaultPhysicsBlocks extends ArrayList<Material>
{
/**
* Constructor.
*/
public DefaultPhysicsBlocks()
{
super();
this.add(new BlockType(Material.COAL_ORE));
this.add(new BlockType(Material.IRON_ORE));
this.add(new BlockType(Material.GOLD_ORE));
this.add(new BlockType(Material.LAPIS_ORE));
this.add(new BlockType(Material.REDSTONE_ORE));
this.add(new BlockType(Material.EMERALD_ORE));
this.add(new BlockType(Material.DIAMOND_ORE));
this.add(Material.COAL_ORE);
this.add(Material.IRON_ORE);
this.add(Material.GOLD_ORE);
this.add(Material.LAPIS_ORE);
this.add(Material.REDSTONE_ORE);
this.add(Material.EMERALD_ORE);
this.add(Material.DIAMOND_ORE);
}
}


//TODO: fix, somehow
/**
* Default list of tool durabilities
*/
private static class DefaultToolDurabilities extends BlockTypeList
private static class DefaultToolDurabilities extends ArrayList<Material>
{
/**
* Constructor.
*/
public DefaultToolDurabilities()
{
super();
this.add(new BlockType(Material.IRON_PICKAXE, (short) 32));
this.add(new BlockType(Material.DIAMOND_PICKAXE, (short) 64));
//this.add(new BlockType(Material.IRON_PICKAXE, (short) 32));
//this.add(new BlockType(Material.DIAMOND_PICKAXE, (short) 64));
this.add(Material.IRON_PICKAXE);
this.add(Material.DIAMOND_PICKAXE);
}
}

Expand All @@ -1506,31 +1507,31 @@ private static class DefaultStoneBlocks extends BlockRelationsList
public DefaultStoneBlocks()
{
super();
this.add(new BlockType(Material.STONE), new BlockType(Material.COBBLESTONE));
this.add(Material.STONE, Material.COBBLESTONE);
}
}


private static class DefaultValuableTools extends BlockTypeList
private static class DefaultValuableTools extends ArrayList<Material>
{
public DefaultValuableTools()
{
super();
this.add(new BlockType(Material.DIAMOND_AXE));
this.add(new BlockType(Material.DIAMOND_SWORD));
this.add(new BlockType(Material.DIAMOND_PICKAXE));
this.add(new BlockType(Material.DIAMOND_SHOVEL));
this.add(Material.DIAMOND_AXE);
this.add(Material.DIAMOND_SWORD);
this.add(Material.DIAMOND_PICKAXE);
this.add(Material.DIAMOND_SHOVEL);

}
}


private static class DefaultHardBlocks extends BlockTypeList
private static class DefaultHardBlocks extends ArrayList<Material>
{
public DefaultHardBlocks()
{
super();
this.add(new BlockType(Material.STONE));
this.add(Material.STONE);

}
}
Expand Down
Loading

0 comments on commit f00ecfd

Please sign in to comment.