added mob target command
This commit is contained in:
@@ -46,5 +46,8 @@ public interface BotManager {
|
||||
|
||||
Terminator getBot(int entityId);
|
||||
|
||||
boolean isMobTarget();
|
||||
|
||||
void setMobTarget(boolean mobTarget);
|
||||
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class BotManagerImpl implements BotManager, Listener {
|
||||
private final NumberFormat numberFormat;
|
||||
|
||||
public boolean joinMessages = false;
|
||||
|
||||
private boolean mobTarget = false;
|
||||
public BotManagerImpl() {
|
||||
this.agent = new LegacyAgent(this, TerminatorPlus.getInstance());
|
||||
this.bots = ConcurrentHashMap.newKeySet(); //should fix concurrentmodificationexception
|
||||
@@ -139,6 +139,7 @@ public class BotManagerImpl implements BotManager, Listener {
|
||||
} else if (i > 1) {
|
||||
bot.setVelocity(randomVelocity().multiply(f));
|
||||
}
|
||||
bot.setIgnoredByMobs(!mobTarget);
|
||||
|
||||
bots.add(bot);
|
||||
i++;
|
||||
@@ -194,6 +195,16 @@ public class BotManagerImpl implements BotManager, Listener {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMobTarget() {
|
||||
return mobTarget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMobTarget(boolean mobTarget) {
|
||||
this.mobTarget = mobTarget;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent event) {
|
||||
ServerGamePacketListenerImpl connection = ((CraftPlayer) event.getPlayer()).getHandle().connection;
|
||||
|
||||
@@ -267,15 +267,16 @@ public class BotCommand extends CommandInstance {
|
||||
|
||||
String extra = ChatColor.GRAY + " [" + ChatColor.YELLOW + "/bot settings" + ChatColor.GRAY + "]";
|
||||
|
||||
if (arg1 == null || (!arg1.equals("setgoal"))) {
|
||||
if (arg1 == null || ((!arg1.equals("setgoal")) && !arg1.equals("mobtarget"))) {
|
||||
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.");
|
||||
sender.sendMessage(ChatUtils.BULLET_FORMATTED + ChatColor.YELLOW + "mobtarget" + ChatUtils.BULLET_FORMATTED + "Allow all future bots spawned to be targetted by hostile mobs.");
|
||||
sender.sendMessage(ChatUtils.BULLET_FORMATTED + ChatColor.YELLOW + "mobtarget" + ChatUtils.BULLET_FORMATTED + "Allow all future bots spawned to be targeted by hostile mobs.");
|
||||
sender.sendMessage(ChatUtils.LINE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (arg1.equalsIgnoreCase("setgoal")) {
|
||||
EnumTargetGoal goal = EnumTargetGoal.from(arg2 == null ? "" : arg2);
|
||||
|
||||
if (goal == null) {
|
||||
@@ -286,10 +287,13 @@ public class BotCommand extends CommandInstance {
|
||||
sender.sendMessage(ChatUtils.LINE);
|
||||
return;
|
||||
}
|
||||
|
||||
agent.setTargetType(goal);
|
||||
|
||||
sender.sendMessage("The global bot goal has been set to " + ChatColor.BLUE + goal.name() + ChatColor.RESET + ".");
|
||||
} else if (arg1.equalsIgnoreCase("mobtarget")) {
|
||||
manager.setMobTarget(!manager.isMobTarget());
|
||||
sender.sendMessage("Mob targeting is now " + (manager.isMobTarget() ? ChatColor.GREEN + "enabled" : ChatColor.RED + "disabled") + ChatColor.RESET + ". (for all future bots)");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Autofill
|
||||
|
||||
Reference in New Issue
Block a user