diff --git a/src/net/theprogrammersworld/herobrine/AI/cores/Heads.java b/src/net/theprogrammersworld/herobrine/AI/cores/Heads.java index 0b78dbf..58fe20f 100644 --- a/src/net/theprogrammersworld/herobrine/AI/cores/Heads.java +++ b/src/net/theprogrammersworld/herobrine/AI/cores/Heads.java @@ -3,18 +3,18 @@ package net.theprogrammersworld.herobrine.AI.cores; import java.util.ArrayList; import java.util.Random; -import net.theprogrammersworld.herobrine.Herobrine; -import net.theprogrammersworld.herobrine.AI.AICore; -import net.theprogrammersworld.herobrine.AI.Core; -import net.theprogrammersworld.herobrine.AI.CoreResult; -import net.theprogrammersworld.herobrine.misc.BlockChanger; - import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Player; +import net.theprogrammersworld.herobrine.Herobrine; +import net.theprogrammersworld.herobrine.AI.AICore; +import net.theprogrammersworld.herobrine.AI.Core; +import net.theprogrammersworld.herobrine.AI.CoreResult; +import net.theprogrammersworld.herobrine.misc.BlockChanger; + public class Heads extends Core { private boolean isCalled; @@ -23,21 +23,23 @@ public class Heads extends Core { public Heads() { super(CoreType.HEADS, AppearType.NORMAL); isCalled = false; - headList = new ArrayList(); + headList = new ArrayList<>(); } @SuppressWarnings("deprecation") @Override public CoreResult callCore(final Object[] data) { if (isCalled) { - return new CoreResult(false, "This player is already being haunted by heads. Please wait until they disappear."); + return new CoreResult(false, + "This player is already being haunted by heads. Please wait until they disappear."); } if (!Bukkit.getPlayer((String) data[0]).isOnline()) { return new CoreResult(false, "This player cannot be haunted by heads because they are not online."); } final Player player = Bukkit.getServer().getPlayer((String) data[0]); if (!Herobrine.getPluginCore().getSupport().checkBuild(player.getLocation())) { - return new CoreResult(false, player.getDisplayName() + " cannot be haunted by heads because they are in a protected area."); + return new CoreResult(false, + player.getDisplayName() + " cannot be haunted by heads because they are in a protected area."); } if (Herobrine.getPluginCore().getConfigDB().UseHeads) { final Location loc = player.getLocation(); @@ -55,7 +57,7 @@ public class Heads extends Core { y = loc.getWorld().getHighestBlockYAt(px + x, pz + z) + 1; } final Block block = loc.getWorld().getBlockAt(px + x, y, pz + z); - if (loc.getBlock().getType() == Material.AIR) { + if (loc.getBlock().getType().equals(Material.AIR)) { BlockChanger.PlaceSkull(block.getLocation(), "Herobrine"); headList.add(block); } diff --git a/src/net/theprogrammersworld/herobrine/listeners/BlockListener.java b/src/net/theprogrammersworld/herobrine/listeners/BlockListener.java index dccc4c4..5ec1f14 100644 --- a/src/net/theprogrammersworld/herobrine/listeners/BlockListener.java +++ b/src/net/theprogrammersworld/herobrine/listeners/BlockListener.java @@ -41,6 +41,24 @@ public class BlockListener implements Listener { && (block.getWorld().getBlockAt(blockloc.getBlockX() + 1, blockloc.getBlockY(), blockloc.getBlockZ()).getType() == Material.REDSTONE_TORCH_ON) && (block.getWorld().getBlockAt(blockloc.getBlockX() - 1, blockloc.getBlockY(), blockloc.getBlockZ()).getType() == Material.REDSTONE_TORCH_ON) && Herobrine.getPluginCore().getConfigDB().UseTotem && !AICore.isTotemCalled) { + if(!Herobrine.getPluginCore().getSupport().checkBuild(blockloc)) { + event.getPlayer().sendMessage("§c[Herobrine] You can't summon the Herobrine in you can't break zone!"); + return; + } + block.getWorld().getBlockAt(blockloc.getBlockX(), blockloc.getBlockY() , blockloc.getBlockZ()).setType(Material.AIR); + block.getWorld().getBlockAt(blockloc.getBlockX(), blockloc.getBlockY() - 1, blockloc.getBlockZ()).setType(Material.AIR); + block.getWorld().getBlockAt(blockloc.getBlockX() - 1, blockloc.getBlockY() - 1, blockloc.getBlockZ()).setType(Material.AIR); + block.getWorld().getBlockAt(blockloc.getBlockX() - 1, blockloc.getBlockY() - 1, blockloc.getBlockZ() - 1).setType(Material.AIR); + block.getWorld().getBlockAt(blockloc.getBlockX() - 1, blockloc.getBlockY() - 1, blockloc.getBlockZ() + 1).setType(Material.AIR); + block.getWorld().getBlockAt(blockloc.getBlockX() + 1, blockloc.getBlockY() - 1, blockloc.getBlockZ()).setType(Material.AIR); + block.getWorld().getBlockAt(blockloc.getBlockX() + 1, blockloc.getBlockY() - 1, blockloc.getBlockZ() - 1).setType(Material.AIR); + block.getWorld().getBlockAt(blockloc.getBlockX() + 1, blockloc.getBlockY() - 1, blockloc.getBlockZ() + 1).setType(Material.AIR); + block.getWorld().getBlockAt(blockloc.getBlockX(), blockloc.getBlockY() - 1, blockloc.getBlockZ() - 1).setType(Material.AIR); + block.getWorld().getBlockAt(blockloc.getBlockX(), blockloc.getBlockY() - 1, blockloc.getBlockZ() + 1).setType(Material.AIR); + block.getWorld().getBlockAt(blockloc.getBlockX(), blockloc.getBlockY(), blockloc.getBlockZ() + 1).setType(Material.AIR); + block.getWorld().getBlockAt(blockloc.getBlockX(), blockloc.getBlockY(), blockloc.getBlockZ() - 1).setType(Material.AIR); + block.getWorld().getBlockAt(blockloc.getBlockX() + 1, blockloc.getBlockY(), blockloc.getBlockZ()).setType(Material.AIR); + block.getWorld().getBlockAt(blockloc.getBlockX() - 1, blockloc.getBlockY(), blockloc.getBlockZ()).setType(Material.AIR); Herobrine.getPluginCore().getAICore().playerCallTotem(event.getPlayer()); } }