package nautilus.game.arcade.ore; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilBlock; import mineplex.core.explosion.ExplosionEvent; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.event.block.BlockBreakEvent; public class OreHider { private NautHashMap _hidden = new NautHashMap(); private boolean _visible = false; public void AddOre(Location loc, Material type) { boolean visible = false; for (Block block : UtilBlock.getSurrounding(loc.getBlock(), false)) { if (!block.getType().isOccluding()) { visible = true; break; } } if (visible) { loc.getBlock().setType(type); } else { _hidden.put(loc.getBlock().getLocation(), type); } } public void BlockBreak(BlockBreakEvent event) { for (Block block : UtilBlock.getSurrounding(event.getBlock(), false)) { if (_hidden.containsKey(block.getLocation())) { block.setType(_hidden.remove(block.getLocation())); } } } public void Explosion(ExplosionEvent event) { for (Block cur : event.GetBlocks()) { for (Block block : UtilBlock.getSurrounding(cur, false)) { if (_hidden.containsKey(block.getLocation())) { block.setType(_hidden.remove(block.getLocation())); } } } } public void ToggleVisibility() { if (!_visible) { for (Location loc : _hidden.keySet()) { loc.getBlock().setType(_hidden.get(loc)); } } else { for (Location loc : _hidden.keySet()) { loc.getBlock().setType(Material.STONE); } } _visible = !_visible; } public NautHashMap GetHiddenOre() { return _hidden; } }