From 62146480db28cbc8fb88cf04fe21003d6237cc31 Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 19 Aug 2013 15:12:08 -0400 Subject: [PATCH] Hardcoding this is a bad idea. --- .../gmail/nossr50/skills/mining/BlastMining.java | 16 ---------------- .../nossr50/skills/mining/MiningManager.java | 5 +---- .../java/com/gmail/nossr50/util/BlockUtils.java | 12 ++++++++++-- 3 files changed, 11 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/mining/BlastMining.java b/src/main/java/com/gmail/nossr50/skills/mining/BlastMining.java index 05617872d..2a0d1dea2 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/BlastMining.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/BlastMining.java @@ -1,9 +1,5 @@ package com.gmail.nossr50.skills.mining; -import java.util.HashSet; - -import org.bukkit.Material; - import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.Config; @@ -88,16 +84,4 @@ public class BlastMining { public static int detonatorID = Config.getInstance().getDetonatorItemID(); public final static int MAXIMUM_REMOTE_DETONATION_DISTANCE = 100; - - protected static HashSet generateTransparentBlockList() { - HashSet transparentBlocks = new HashSet(); - - for (Material material : Material.values()) { - if (material.isTransparent()) { - transparentBlocks.add((byte) material.getId()); - } - } - - return transparentBlocks; - } } diff --git a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java index 57480c16f..b7b7dc3fc 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java @@ -1,7 +1,6 @@ package com.gmail.nossr50.skills.mining; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; import org.bukkit.Material; @@ -93,9 +92,7 @@ public class MiningManager extends SkillManager { */ public void remoteDetonation() { Player player = getPlayer(); - - HashSet transparentBlocks = BlastMining.generateTransparentBlockList(); - Block targetBlock = player.getTargetBlock(transparentBlocks, BlastMining.MAXIMUM_REMOTE_DETONATION_DISTANCE); + Block targetBlock = player.getTargetBlock(BlockUtils.getTransparentBlocks(), BlastMining.MAXIMUM_REMOTE_DETONATION_DISTANCE); if (targetBlock.getType() != Material.TNT || !SkillUtils.blockBreakSimulate(targetBlock, player, true) || !blastMiningCooldownOver()) { return; diff --git a/src/main/java/com/gmail/nossr50/util/BlockUtils.java b/src/main/java/com/gmail/nossr50/util/BlockUtils.java index 7a10cfe2f..c67e605bd 100644 --- a/src/main/java/com/gmail/nossr50/util/BlockUtils.java +++ b/src/main/java/com/gmail/nossr50/util/BlockUtils.java @@ -1,9 +1,9 @@ package com.gmail.nossr50.util; -import java.util.Arrays; import java.util.HashSet; import org.bukkit.CropState; +import org.bukkit.Material; import org.bukkit.NetherWartsState; import org.bukkit.block.BlockState; import org.bukkit.material.CocoaPlant; @@ -323,6 +323,14 @@ public final class BlockUtils { * @return HashSet with the IDs of every transparent block */ public static HashSet getTransparentBlocks() { - return new HashSet(Arrays.asList((byte) 0, (byte) 6, (byte) 18, (byte) 20, (byte) 27, (byte) 28, (byte) 31, (byte) 32, (byte) 32, (byte) 34, (byte) 37, (byte) 38, (byte) 39, (byte) 40, (byte) 50, (byte) 51, (byte) 52, (byte) 53, (byte) 55, (byte) 59, (byte) 63, (byte) 64, (byte) 65, (byte) 66, (byte) 67, (byte) 68, (byte) 69, (byte) 70, (byte) 71, (byte) 72, (byte) 75, (byte) 76, (byte) 77, (byte) 78, (byte) 79, (byte) 81, (byte) 83, (byte) 85, (byte) 92, (byte) 93, (byte) 94, (byte) 96, (byte) 101, (byte) 102, (byte) 104, (byte) 105, (byte) 106, (byte) 107, (byte) 108, (byte) 109, (byte) 111, (byte) 113, (byte) 114, (byte) 115, (byte) 119, (byte) 126, (byte) 128, (byte) 131, (byte) 132, (byte) 134, (byte) 135, (byte) 136, (byte) 139, (byte) 141, (byte) 142, (byte) 143, (byte) 145, (byte) 147, (byte) 148, (byte) 149, (byte) 150, (byte) 151, (byte) 156, (byte) 157, (byte) 171)); + HashSet transparentBlocks = new HashSet(); + + for (Material material : Material.values()) { + if (material.isTransparent()) { + transparentBlocks.add((byte) material.getId()); + } + } + + return transparentBlocks; } }