From 46478b62daf2d84e1b796544114d3701a7a3fc45 Mon Sep 17 00:00:00 2001 From: David Berdik Date: Mon, 8 Jul 2019 17:25:50 -0400 Subject: [PATCH] Removed totem code --- .../herobrine/AI/AICore.java | 21 +--- .../herobrine/AI/cores/Totem.java | 115 ------------------ .../herobrine/ConfigDB.java | 14 --- .../herobrine/listeners/BlockListener.java | 112 ----------------- 4 files changed, 2 insertions(+), 260 deletions(-) delete mode 100644 src/net/theprogrammersworld/herobrine/AI/cores/Totem.java diff --git a/src/net/theprogrammersworld/herobrine/AI/AICore.java b/src/net/theprogrammersworld/herobrine/AI/AICore.java index 88c3761..d99ac84 100644 --- a/src/net/theprogrammersworld/herobrine/AI/AICore.java +++ b/src/net/theprogrammersworld/herobrine/AI/AICore.java @@ -25,7 +25,6 @@ import net.theprogrammersworld.herobrine.AI.cores.RandomSound; import net.theprogrammersworld.herobrine.AI.cores.Signs; import net.theprogrammersworld.herobrine.AI.cores.SoundF; import net.theprogrammersworld.herobrine.AI.cores.Temple; -import net.theprogrammersworld.herobrine.AI.cores.Totem; import net.theprogrammersworld.herobrine.misc.ItemName; import net.theprogrammersworld.herobrine.nms.entity.MobType; @@ -45,12 +44,11 @@ public class AICore { public static boolean isTarget = false; public static int ticksToEnd = 0; public static boolean isDiscCalled = false; - public static boolean isTotemCalled = false; public static int _ticks = 0; private ArrayList allCores = new ArrayList(Arrays.asList(new Core[] { new Attack(), new Book(), new BuildStuff(), new BuryPlayer(), new DestroyTorches(), new Graveyard(), - new Haunt(), new Pyramid(), new Signs(), new SoundF(), new Totem(), new Heads(), - new RandomSound(), new RandomExplosion(), new Burn(), new Curse(), new Temple() + new Haunt(), new Pyramid(), new Signs(), new SoundF(), new Heads(), new RandomSound(), + new RandomExplosion(), new Burn(), new Curse(), new Temple() })); private Core.CoreType currentCore = Core.CoreType.ANY; private ResetLimits resetLimits; @@ -233,21 +231,6 @@ public class AICore { EntityPlayer pcon = ((CraftPlayer) p).getHandle(); pcon.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER, Herobrine.herobrineNPC.getNMSEntity())); } - - public void playerCallTotem(final Player player) { - final String playername = player.getName(); - final Location loc = player.getLocation(); - AICore.isTotemCalled = true; - cancelTarget(Core.CoreType.ANY, true); - Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(AICore.plugin, new Runnable() { - @Override - public void run() { - AICore.this.cancelTarget(Core.CoreType.ANY, true); - final Object[] data = { loc, playername }; - AICore.this.getCore(Core.CoreType.TOTEM).runCore(data); - } - }, 40L); - } private void pyramidInterval() { if ((Herobrine.getPluginCore().getConfigDB().BuildPyramids) && new Random().nextBoolean() && (Bukkit.getServer().getOnlinePlayers().size() > 0)) { diff --git a/src/net/theprogrammersworld/herobrine/AI/cores/Totem.java b/src/net/theprogrammersworld/herobrine/AI/cores/Totem.java deleted file mode 100644 index 56eef5e..0000000 --- a/src/net/theprogrammersworld/herobrine/AI/cores/Totem.java +++ /dev/null @@ -1,115 +0,0 @@ -package net.theprogrammersworld.herobrine.AI.cores; - -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.AI.Message; - -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; - -public class Totem extends Core { - - public Totem() { - super(CoreType.TOTEM, AppearType.APPEAR); - } - - @Override - public CoreResult callCore(final Object[] data) { - return TotemCall((Location) data[0], (String) data[1]); - } - - public CoreResult TotemCall(final Location loc, final String caller) { - AICore.isTotemCalled = false; - loc.getWorld().strikeLightning(loc); - if (Herobrine.getPluginCore().getConfigDB().TotemExplodes) { - loc.getWorld().createExplosion(loc, 5.0f); - } - if (Bukkit.getServer().getPlayer(caller) != null) { - if (Bukkit.getServer().getPlayer(caller).isOnline()) { - Herobrine.getPluginCore().getAICore().setCoreTypeNow(CoreType.TOTEM); - Herobrine.getPluginCore().getAICore().setAttackTarget(Bukkit.getServer().getPlayer(caller)); - final Player player = Bukkit.getServer().getPlayer(caller); - for (Player oplayer : Bukkit.getOnlinePlayers()) { - Location ploc = oplayer.getLocation(); - if ( - (oplayer.getName() != player.getName()) && - ((ploc.getX() + 10.0) > loc.getX()) && - ((ploc.getX() - 10.0) < loc.getX()) && - ((ploc.getZ() + 10.0) > loc.getZ()) && - ((ploc.getZ() - 10.0) < loc.getZ()) - ) { - Message.sendRandomMessage(oplayer); - if (Herobrine.getPluginCore().getConfigDB().UsePotionEffects) { - oplayer.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 1000, 1)); - oplayer.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 1000, 1)); - oplayer.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 1000, 1)); - } - } - } - } else { - boolean hasTarget = false; - Player target = null; - for (Player oplayer : Bukkit.getOnlinePlayers()) { - if (!hasTarget) { - Location ploc = oplayer.getLocation(); - if (((ploc.getX() + 10.0) > loc.getX()) && ((ploc.getX() - 10.0) < loc.getX()) && ((ploc.getZ() + 10.0) > loc.getZ()) && ((ploc.getZ() - 10.0) < loc.getZ())) { - hasTarget = true; - target = oplayer; - } - } - } - if (hasTarget) { - Herobrine.getPluginCore().getAICore().cancelTarget(CoreType.TOTEM, true); - Herobrine.getPluginCore().getAICore().setAttackTarget(target); - final Player player = target; - for (Player oplayer : Bukkit.getOnlinePlayers()) { - Location ploc = oplayer.getLocation(); - if ((oplayer.getName() != player.getName()) && ((ploc.getX() + 20.0) > loc.getX()) && ((ploc.getX() - 20.0) < loc.getX()) && ((ploc.getZ() + 20.0) > loc.getZ()) - && ((ploc.getZ() - 20.0) < loc.getZ())) { - Message.sendRandomMessage(oplayer); - oplayer.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 1000, 1)); - oplayer.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 1000, 1)); - oplayer.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 1000, 1)); - } - } - } - } - } else { - boolean hasTarget = false; - Player target = null; - for (Player oplayer : Bukkit.getOnlinePlayers()) { - if (!hasTarget) { - Location ploc = oplayer.getLocation(); - if (((ploc.getX() + 20.0) > loc.getX()) && ((ploc.getX() - 20.0) < loc.getX()) && ((ploc.getZ() + 20.0) > loc.getZ()) && ((ploc.getZ() - 20.0) < loc.getZ())) { - hasTarget = true; - target = oplayer; - } - } - } - if (hasTarget) { - Herobrine.getPluginCore().getAICore().cancelTarget(CoreType.TOTEM, true); - Herobrine.getPluginCore().getAICore().setAttackTarget(target); - final Player player = target; - for (Player oplayer : Bukkit.getOnlinePlayers()) { - if (oplayer.getEntityId() != Herobrine.herobrineEntityID) { - Location ploc = oplayer.getLocation(); - if ((oplayer.getName() != player.getName()) && ((ploc.getX() + 20.0) > loc.getX()) && ((ploc.getX() - 20.0) < loc.getX()) && ((ploc.getZ() + 20.0) > loc.getZ()) - && ((ploc.getZ() - 20.0) < loc.getZ())) { - Message.sendRandomMessage(oplayer); - oplayer.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 1000, 1)); - oplayer.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 1000, 1)); - oplayer.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 1000, 1)); - } - } - } - } - } - return new CoreResult(false, "Totem called."); - } - -} \ No newline at end of file diff --git a/src/net/theprogrammersworld/herobrine/ConfigDB.java b/src/net/theprogrammersworld/herobrine/ConfigDB.java index b02f4a5..c4b1f42 100644 --- a/src/net/theprogrammersworld/herobrine/ConfigDB.java +++ b/src/net/theprogrammersworld/herobrine/ConfigDB.java @@ -30,11 +30,9 @@ public class ConfigDB { public boolean DestroyTorches = true; public int DestroyTorchesRadius = 5; public int ShowInterval = 144000; - public boolean TotemExplodes = true; public boolean OnlyWalkingMode = false; public boolean BuildStuff = true; public boolean PlaceSigns = true; - public boolean UseTotem = true; public boolean WriteBooks = true; public boolean Killable = false; public boolean UsePotionEffects = true; @@ -186,11 +184,9 @@ public class ConfigDB { this.config.set("config.DestroyTorches", Boolean.valueOf(true)); this.config.set("config.DestroyTorchesRadius", Integer.valueOf(5)); this.config.set("config.Worlds", this.useWorlds); - this.config.set("config.TotemExplodes", Boolean.valueOf(true)); this.config.set("config.OnlyWalkingMode", Boolean.valueOf(false)); this.config.set("config.BuildStuff", Boolean.valueOf(true)); this.config.set("config.PlaceSigns", Boolean.valueOf(true)); - this.config.set("config.UseTotem", Boolean.valueOf(true)); this.config.set("config.WriteBooks", Boolean.valueOf(true)); this.config.set("config.Killable", Boolean.valueOf(false)); this.config.set("config.UsePotionEffects", Boolean.valueOf(true)); @@ -261,13 +257,6 @@ public class ConfigDB { this.log.info("[Herobrine] Configuration file updating to Herobrine v" + pluginVersionNumber); this.config.set("config.Worlds", this.useWorlds); } - if (!this.config.contains("config.TotemExplodes")) { - if (!hasUpdated) { - this.log.info("[Herobrine] Configuration file updating to Herobrine v" + pluginVersionNumber); - } - hasUpdated = true; - this.config.set("config.TotemExplodes", Boolean.valueOf(true)); - } if (!this.config.contains("config.OnlyWalkingMode")) { if (!hasUpdated) { hasUpdated = true; @@ -295,7 +284,6 @@ public class ConfigDB { this.config.set("config.BuildStuff", Boolean.valueOf(true)); this.config.set("config.PlaceSigns", Boolean.valueOf(true)); - this.config.set("config.UseTotem", Boolean.valueOf(true)); this.config.set("config.WriteBooks", Boolean.valueOf(true)); this.config.set("config.Killable", Boolean.valueOf(false)); this.config.set("config.Messages", this.useMessages); @@ -545,11 +533,9 @@ public class ConfigDB { this.DestroyTorches = this.config.getBoolean("config.DestroyTorches"); this.DestroyTorchesRadius = this.config.getInt("config.DestroyTorchesRadius"); this.useWorlds = this.config.getStringList("config.Worlds"); - this.TotemExplodes = this.config.getBoolean("config.TotemExplodes"); this.OnlyWalkingMode = this.config.getBoolean("config.OnlyWalkingMode"); this.BuildStuff = this.config.getBoolean("config.BuildStuff"); this.PlaceSigns = this.config.getBoolean("config.PlaceSigns"); - this.UseTotem = this.config.getBoolean("config.UseTotem"); this.WriteBooks = this.config.getBoolean("config.WriteBooks"); this.Killable = this.config.getBoolean("config.Killable"); this.UsePotionEffects = this.config.getBoolean("config.UsePotionEffects"); diff --git a/src/net/theprogrammersworld/herobrine/listeners/BlockListener.java b/src/net/theprogrammersworld/herobrine/listeners/BlockListener.java index b1b6ae5..41148a3 100644 --- a/src/net/theprogrammersworld/herobrine/listeners/BlockListener.java +++ b/src/net/theprogrammersworld/herobrine/listeners/BlockListener.java @@ -3,130 +3,18 @@ package net.theprogrammersworld.herobrine.listeners; import java.util.ArrayList; import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.block.BlockIgniteEvent; import org.bukkit.event.block.BlockPlaceEvent; import net.theprogrammersworld.herobrine.Herobrine; -import net.theprogrammersworld.herobrine.AI.AICore; import net.theprogrammersworld.herobrine.AI.Core; import net.theprogrammersworld.herobrine.AI.cores.Heads; public class BlockListener implements Listener { - @EventHandler - public void onBlockIgnite(final BlockIgniteEvent event) { - if (event.getBlock() != null) { - final Block blockt = event.getBlock(); - final Location blockloc = blockt.getLocation(); - if (event.getPlayer() != null) { - blockloc.setY(blockloc.getY() - 1.0); - final Block block = blockloc.getWorld().getBlockAt(blockloc); - if ((block.getType() == Material.NETHERRACK) - && (block.getWorld() - .getBlockAt(blockloc.getBlockX(), blockloc.getBlockY() - 1, blockloc.getBlockZ()) - .getType() == Material.NETHERRACK) - && (block.getWorld() - .getBlockAt(blockloc.getBlockX() - 1, blockloc.getBlockY() - 1, blockloc.getBlockZ()) - .getType() == Material.GOLD_BLOCK) - && (block.getWorld() - .getBlockAt(blockloc.getBlockX() - 1, blockloc.getBlockY() - 1, - blockloc.getBlockZ() - 1) - .getType() == Material.GOLD_BLOCK) - && (block.getWorld() - .getBlockAt(blockloc.getBlockX() - 1, blockloc.getBlockY() - 1, - blockloc.getBlockZ() + 1) - .getType() == Material.GOLD_BLOCK) - && (block.getWorld() - .getBlockAt(blockloc.getBlockX() + 1, blockloc.getBlockY() - 1, blockloc.getBlockZ()) - .getType() == Material.GOLD_BLOCK) - && (block.getWorld() - .getBlockAt(blockloc.getBlockX() + 1, blockloc.getBlockY() - 1, - blockloc.getBlockZ() - 1) - .getType() == Material.GOLD_BLOCK) - && (block.getWorld() - .getBlockAt(blockloc.getBlockX() + 1, blockloc.getBlockY() - 1, - blockloc.getBlockZ() + 1) - .getType() == Material.GOLD_BLOCK) - && (block.getWorld() - .getBlockAt(blockloc.getBlockX(), blockloc.getBlockY() - 1, blockloc.getBlockZ() - 1) - .getType() == Material.GOLD_BLOCK) - && (block.getWorld() - .getBlockAt(blockloc.getBlockX(), blockloc.getBlockY() - 1, blockloc.getBlockZ() + 1) - .getType() == Material.GOLD_BLOCK) - && (block.getWorld() - .getBlockAt(blockloc.getBlockX(), blockloc.getBlockY(), blockloc.getBlockZ() + 1) - .getType() == Material.matchMaterial("REDSTONE_TORCH_ON")) - && (block.getWorld() - .getBlockAt(blockloc.getBlockX(), blockloc.getBlockY(), blockloc.getBlockZ() - 1) - .getType() == Material.matchMaterial("REDSTONE_TORCH_ON")) - && (block.getWorld() - .getBlockAt(blockloc.getBlockX() + 1, blockloc.getBlockY(), blockloc.getBlockZ()) - .getType() == Material.matchMaterial("REDSTONE_TORCH_ON")) - && (block.getWorld() - .getBlockAt(blockloc.getBlockX() - 1, blockloc.getBlockY(), blockloc.getBlockZ()) - .getType() == Material.matchMaterial("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 protect zone!"); - // Add:Summon control. - return; - } - // There is remove Totem - // I like disable explosion because that is missing protect - // So i choose remove the totem - // This can deleted - 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()); - } - } - } - if (event.getBlock().getWorld() == Bukkit.getServer() - .getWorld(Herobrine.getPluginCore().getConfigDB().HerobrineWorldName)) { - event.setCancelled(true); - } - } - @EventHandler public void onBlockBreak(final BlockBreakEvent event) { if (event.getBlock().getWorld() == Bukkit.getServer()