Removed totem code

This commit is contained in:
David Berdik 2019-07-08 17:25:50 -04:00
parent 118285d85f
commit 46478b62da
4 changed files with 2 additions and 260 deletions

View File

@ -25,7 +25,6 @@ import net.theprogrammersworld.herobrine.AI.cores.RandomSound;
import net.theprogrammersworld.herobrine.AI.cores.Signs; import net.theprogrammersworld.herobrine.AI.cores.Signs;
import net.theprogrammersworld.herobrine.AI.cores.SoundF; import net.theprogrammersworld.herobrine.AI.cores.SoundF;
import net.theprogrammersworld.herobrine.AI.cores.Temple; import net.theprogrammersworld.herobrine.AI.cores.Temple;
import net.theprogrammersworld.herobrine.AI.cores.Totem;
import net.theprogrammersworld.herobrine.misc.ItemName; import net.theprogrammersworld.herobrine.misc.ItemName;
import net.theprogrammersworld.herobrine.nms.entity.MobType; import net.theprogrammersworld.herobrine.nms.entity.MobType;
@ -45,12 +44,11 @@ public class AICore {
public static boolean isTarget = false; public static boolean isTarget = false;
public static int ticksToEnd = 0; public static int ticksToEnd = 0;
public static boolean isDiscCalled = false; public static boolean isDiscCalled = false;
public static boolean isTotemCalled = false;
public static int _ticks = 0; public static int _ticks = 0;
private ArrayList<Core> allCores = new ArrayList<Core>(Arrays.asList(new Core[] { private ArrayList<Core> allCores = new ArrayList<Core>(Arrays.asList(new Core[] {
new Attack(), new Book(), new BuildStuff(), new BuryPlayer(), new DestroyTorches(), new Graveyard(), 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 Haunt(), new Pyramid(), new Signs(), new SoundF(), new Heads(), new RandomSound(),
new RandomSound(), new RandomExplosion(), new Burn(), new Curse(), new Temple() new RandomExplosion(), new Burn(), new Curse(), new Temple()
})); }));
private Core.CoreType currentCore = Core.CoreType.ANY; private Core.CoreType currentCore = Core.CoreType.ANY;
private ResetLimits resetLimits; private ResetLimits resetLimits;
@ -233,21 +231,6 @@ public class AICore {
EntityPlayer pcon = ((CraftPlayer) p).getHandle(); EntityPlayer pcon = ((CraftPlayer) p).getHandle();
pcon.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER, Herobrine.herobrineNPC.getNMSEntity())); 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() { private void pyramidInterval() {
if ((Herobrine.getPluginCore().getConfigDB().BuildPyramids) && new Random().nextBoolean() && (Bukkit.getServer().getOnlinePlayers().size() > 0)) { if ((Herobrine.getPluginCore().getConfigDB().BuildPyramids) && new Random().nextBoolean() && (Bukkit.getServer().getOnlinePlayers().size() > 0)) {

View File

@ -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.");
}
}

View File

@ -30,11 +30,9 @@ public class ConfigDB {
public boolean DestroyTorches = true; public boolean DestroyTorches = true;
public int DestroyTorchesRadius = 5; public int DestroyTorchesRadius = 5;
public int ShowInterval = 144000; public int ShowInterval = 144000;
public boolean TotemExplodes = true;
public boolean OnlyWalkingMode = false; public boolean OnlyWalkingMode = false;
public boolean BuildStuff = true; public boolean BuildStuff = true;
public boolean PlaceSigns = true; public boolean PlaceSigns = true;
public boolean UseTotem = true;
public boolean WriteBooks = true; public boolean WriteBooks = true;
public boolean Killable = false; public boolean Killable = false;
public boolean UsePotionEffects = true; public boolean UsePotionEffects = true;
@ -186,11 +184,9 @@ public class ConfigDB {
this.config.set("config.DestroyTorches", Boolean.valueOf(true)); this.config.set("config.DestroyTorches", Boolean.valueOf(true));
this.config.set("config.DestroyTorchesRadius", Integer.valueOf(5)); this.config.set("config.DestroyTorchesRadius", Integer.valueOf(5));
this.config.set("config.Worlds", this.useWorlds); 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.OnlyWalkingMode", Boolean.valueOf(false));
this.config.set("config.BuildStuff", Boolean.valueOf(true)); this.config.set("config.BuildStuff", Boolean.valueOf(true));
this.config.set("config.PlaceSigns", 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.WriteBooks", Boolean.valueOf(true));
this.config.set("config.Killable", Boolean.valueOf(false)); this.config.set("config.Killable", Boolean.valueOf(false));
this.config.set("config.UsePotionEffects", Boolean.valueOf(true)); 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.log.info("[Herobrine] Configuration file updating to Herobrine v" + pluginVersionNumber);
this.config.set("config.Worlds", this.useWorlds); 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 (!this.config.contains("config.OnlyWalkingMode")) {
if (!hasUpdated) { if (!hasUpdated) {
hasUpdated = true; hasUpdated = true;
@ -295,7 +284,6 @@ public class ConfigDB {
this.config.set("config.BuildStuff", Boolean.valueOf(true)); this.config.set("config.BuildStuff", Boolean.valueOf(true));
this.config.set("config.PlaceSigns", 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.WriteBooks", Boolean.valueOf(true));
this.config.set("config.Killable", Boolean.valueOf(false)); this.config.set("config.Killable", Boolean.valueOf(false));
this.config.set("config.Messages", this.useMessages); this.config.set("config.Messages", this.useMessages);
@ -545,11 +533,9 @@ public class ConfigDB {
this.DestroyTorches = this.config.getBoolean("config.DestroyTorches"); this.DestroyTorches = this.config.getBoolean("config.DestroyTorches");
this.DestroyTorchesRadius = this.config.getInt("config.DestroyTorchesRadius"); this.DestroyTorchesRadius = this.config.getInt("config.DestroyTorchesRadius");
this.useWorlds = this.config.getStringList("config.Worlds"); this.useWorlds = this.config.getStringList("config.Worlds");
this.TotemExplodes = this.config.getBoolean("config.TotemExplodes");
this.OnlyWalkingMode = this.config.getBoolean("config.OnlyWalkingMode"); this.OnlyWalkingMode = this.config.getBoolean("config.OnlyWalkingMode");
this.BuildStuff = this.config.getBoolean("config.BuildStuff"); this.BuildStuff = this.config.getBoolean("config.BuildStuff");
this.PlaceSigns = this.config.getBoolean("config.PlaceSigns"); this.PlaceSigns = this.config.getBoolean("config.PlaceSigns");
this.UseTotem = this.config.getBoolean("config.UseTotem");
this.WriteBooks = this.config.getBoolean("config.WriteBooks"); this.WriteBooks = this.config.getBoolean("config.WriteBooks");
this.Killable = this.config.getBoolean("config.Killable"); this.Killable = this.config.getBoolean("config.Killable");
this.UsePotionEffects = this.config.getBoolean("config.UsePotionEffects"); this.UsePotionEffects = this.config.getBoolean("config.UsePotionEffects");

View File

@ -3,130 +3,18 @@ package net.theprogrammersworld.herobrine.listeners;
import java.util.ArrayList; import java.util.ArrayList;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import net.theprogrammersworld.herobrine.Herobrine; import net.theprogrammersworld.herobrine.Herobrine;
import net.theprogrammersworld.herobrine.AI.AICore;
import net.theprogrammersworld.herobrine.AI.Core; import net.theprogrammersworld.herobrine.AI.Core;
import net.theprogrammersworld.herobrine.AI.cores.Heads; import net.theprogrammersworld.herobrine.AI.cores.Heads;
public class BlockListener implements Listener { 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 @EventHandler
public void onBlockBreak(final BlockBreakEvent event) { public void onBlockBreak(final BlockBreakEvent event) {
if (event.getBlock().getWorld() == Bukkit.getServer() if (event.getBlock().getWorld() == Bukkit.getServer()