From aec59a5cfa2ca1fc975037e13159b1060e10a425 Mon Sep 17 00:00:00 2001 From: batchprogrammer314 Date: Tue, 31 Aug 2021 11:32:09 -0500 Subject: [PATCH] no need for mobtarget boolean --- src/main/java/net/nuggetmc/tplus/bot/Bot.java | 7 +----- .../bot/agent/legacyagent/LegacyAgent.java | 22 ++----------------- .../tplus/command/commands/BotCommand.java | 16 +------------- 3 files changed, 4 insertions(+), 41 deletions(-) diff --git a/src/main/java/net/nuggetmc/tplus/bot/Bot.java b/src/main/java/net/nuggetmc/tplus/bot/Bot.java index 6f192af..2fe4eb3 100644 --- a/src/main/java/net/nuggetmc/tplus/bot/Bot.java +++ b/src/main/java/net/nuggetmc/tplus/bot/Bot.java @@ -75,8 +75,6 @@ public class Bot extends EntityPlayer { private byte noFallTicks; private final Vector offset; - - public static boolean mobTargeting; private Bot(MinecraftServer minecraftServer, WorldServer worldServer, GameProfile profile, PlayerInteractManager manager) { super(minecraftServer, worldServer, profile, manager); @@ -121,11 +119,8 @@ public class Bot extends EntityPlayer { bot.getBukkitEntity().setNoDamageTicks(0); Bukkit.getOnlinePlayers().forEach(p -> ((CraftPlayer) p).getHandle().playerConnection.sendPacket( new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, bot))); - if(mobTargeting) - nmsWorld.addPlayerJoin(bot); - else - nmsWorld.addEntity(bot); + nmsWorld.addEntity(bot); bot.renderAll(); TerminatorPlus.getInstance().getManager().add(bot); diff --git a/src/main/java/net/nuggetmc/tplus/bot/agent/legacyagent/LegacyAgent.java b/src/main/java/net/nuggetmc/tplus/bot/agent/legacyagent/LegacyAgent.java index a4d74a8..c440573 100644 --- a/src/main/java/net/nuggetmc/tplus/bot/agent/legacyagent/LegacyAgent.java +++ b/src/main/java/net/nuggetmc/tplus/bot/agent/legacyagent/LegacyAgent.java @@ -1157,16 +1157,7 @@ public class LegacyAgent extends Agent { } case NEAREST_HOSTILE: { - World world = null; - for(World wld : Bukkit.getWorlds()) - { - if(((CraftWorld)wld).getHandle() == bot.getWorld()) - { - world = wld; - break; - } - } - for (LivingEntity entity : world.getLivingEntities()) { + for (LivingEntity entity : bot.getBukkitEntity().getWorld().getLivingEntities()) { if (entity instanceof Monster && validateCloserEntity(entity, loc, result)) { result = entity; } @@ -1176,16 +1167,7 @@ public class LegacyAgent extends Agent { } case NEAREST_MOB: { - World world = null; - for(World wld : Bukkit.getWorlds()) - { - if(((CraftWorld)wld).getHandle() == bot.getWorld()) - { - world = wld; - break; - } - } - for (LivingEntity entity : world.getLivingEntities()) { + for (LivingEntity entity : bot.getBukkitEntity().getWorld().getLivingEntities()) { if (entity instanceof Mob && validateCloserEntity(entity, loc, result)) { result = entity; } diff --git a/src/main/java/net/nuggetmc/tplus/command/commands/BotCommand.java b/src/main/java/net/nuggetmc/tplus/command/commands/BotCommand.java index b55e7e5..f1ecd41 100644 --- a/src/main/java/net/nuggetmc/tplus/command/commands/BotCommand.java +++ b/src/main/java/net/nuggetmc/tplus/command/commands/BotCommand.java @@ -328,7 +328,7 @@ public class BotCommand extends CommandInstance { String extra = ChatColor.GRAY + " [" + ChatColor.YELLOW + "/bot settings" + ChatColor.GRAY + "]"; - if (arg1 == null || (!arg1.equals("setgoal") && !arg1.equals("mobtarget"))) { + if (arg1 == null || (!arg1.equals("setgoal"))) { sender.sendMessage(ChatUtils.LINE); sender.sendMessage(ChatColor.GOLD + "Bot Settings" + extra); sender.sendMessage(ChatUtils.BULLET_FORMATTED + ChatColor.YELLOW + "setgoal" + ChatUtils.BULLET_FORMATTED + "Set the global bot target selection method."); @@ -336,20 +336,6 @@ public class BotCommand extends CommandInstance { sender.sendMessage(ChatUtils.LINE); return; } - - if(arg1.equals("mobtarget")) - { - if(arg2 == null || (!arg2.equals("true") && !arg2.equals("false"))) - { - sender.sendMessage(ChatUtils.LINE); - sender.sendMessage(ChatColor.GOLD + "Only true or false is accepted"); - sender.sendMessage(ChatUtils.LINE); - return; - } - Bot.mobTargeting = Boolean.parseBoolean(arg2); - sender.sendMessage("Mob targeting has been set to " + ChatColor.BLUE + arg2 + ChatColor.RESET + "."); - return; - } EnumTargetGoal goal = EnumTargetGoal.from(arg2 == null ? "" : arg2);