Spawn bots at location feature
This commit is contained in:
@@ -10,6 +10,10 @@ import java.util.Set;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public interface BotManager {
|
public interface BotManager {
|
||||||
|
Location getSpawnLoc();
|
||||||
|
|
||||||
|
void setSpawnLoc(Location loc);
|
||||||
|
|
||||||
Set<Terminator> fetch();
|
Set<Terminator> fetch();
|
||||||
|
|
||||||
Agent getAgent();
|
Agent getAgent();
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ public class BotManagerImpl implements BotManager, Listener {
|
|||||||
public boolean joinMessages = false;
|
public boolean joinMessages = false;
|
||||||
private boolean mobTarget = false;
|
private boolean mobTarget = false;
|
||||||
private boolean addPlayerList = false;
|
private boolean addPlayerList = false;
|
||||||
|
private Location spawnLoc;
|
||||||
|
|
||||||
public BotManagerImpl() {
|
public BotManagerImpl() {
|
||||||
this.agent = new LegacyAgent(this, TerminatorPlus.getInstance());
|
this.agent = new LegacyAgent(this, TerminatorPlus.getInstance());
|
||||||
@@ -43,6 +44,16 @@ public class BotManagerImpl implements BotManager, Listener {
|
|||||||
this.numberFormat = NumberFormat.getInstance(Locale.US);
|
this.numberFormat = NumberFormat.getInstance(Locale.US);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Location getSpawnLoc() {
|
||||||
|
return spawnLoc;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setSpawnLoc(Location loc) {
|
||||||
|
spawnLoc = loc;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Terminator> fetch() {
|
public Set<Terminator> fetch() {
|
||||||
return bots;
|
return bots;
|
||||||
@@ -110,7 +121,18 @@ public class BotManagerImpl implements BotManager, Listener {
|
|||||||
|
|
||||||
skinName = skinName == null ? name : skinName;
|
skinName = skinName == null ? name : skinName;
|
||||||
|
|
||||||
createBots(sender.getLocation(), name, MojangAPI.getSkin(skinName), n, network);
|
if (spawnLoc != null) {
|
||||||
|
sender.sendMessage("The spawn location is "
|
||||||
|
+ ChatColor.BLUE + String.format("(%s, %s, %s)", spawnLoc.getX(), spawnLoc.getY(), spawnLoc.getZ()) + ChatColor.RESET
|
||||||
|
+ ". This will be reset to the player location next time.");
|
||||||
|
Location loc = sender.getLocation().clone();
|
||||||
|
loc.setX(spawnLoc.getX());
|
||||||
|
loc.setY(spawnLoc.getY());
|
||||||
|
loc.setZ(spawnLoc.getZ());
|
||||||
|
createBots(loc, name, MojangAPI.getSkin(skinName), n, network);
|
||||||
|
spawnLoc = null;
|
||||||
|
} else
|
||||||
|
createBots(sender.getLocation(), name, MojangAPI.getSkin(skinName), n, network);
|
||||||
|
|
||||||
sender.sendMessage("Process completed (" + ChatColor.RED + ((System.currentTimeMillis() - timestamp) / 1000D) + "s" + ChatColor.RESET + ").");
|
sender.sendMessage("Process completed (" + ChatColor.RED + ((System.currentTimeMillis() - timestamp) / 1000D) + "s" + ChatColor.RESET + ").");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -286,10 +286,11 @@ public class BotCommand extends CommandInstance {
|
|||||||
|
|
||||||
String extra = ChatColor.GRAY + " [" + ChatColor.YELLOW + "/bot settings" + ChatColor.GRAY + "]";
|
String extra = ChatColor.GRAY + " [" + ChatColor.YELLOW + "/bot settings" + ChatColor.GRAY + "]";
|
||||||
|
|
||||||
if (arg1 == null || ((!arg1.equalsIgnoreCase("setgoal")) && !arg1.equalsIgnoreCase("mobtarget") && !arg1.equalsIgnoreCase("playertarget")
|
if (arg1 == null || (!arg1.equalsIgnoreCase("spawnloc") && !arg1.equalsIgnoreCase("setgoal") && !arg1.equalsIgnoreCase("mobtarget") && !arg1.equalsIgnoreCase("playertarget")
|
||||||
&& !arg1.equalsIgnoreCase("addplayerlist") && !arg1.equalsIgnoreCase("region"))) {
|
&& !arg1.equalsIgnoreCase("addplayerlist") && !arg1.equalsIgnoreCase("region"))) {
|
||||||
sender.sendMessage(ChatUtils.LINE);
|
sender.sendMessage(ChatUtils.LINE);
|
||||||
sender.sendMessage(ChatColor.GOLD + "Bot Settings" + extra);
|
sender.sendMessage(ChatColor.GOLD + "Bot Settings" + extra);
|
||||||
|
sender.sendMessage(ChatUtils.BULLET_FORMATTED + ChatColor.YELLOW + "spawnloc" + ChatUtils.BULLET_FORMATTED + "Set the location where the bots should spawn. This will be reset after a spawn command is executed.");
|
||||||
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 + "setgoal" + ChatUtils.BULLET_FORMATTED + "Set the global bot target selection method.");
|
||||||
sender.sendMessage(ChatUtils.BULLET_FORMATTED + ChatColor.YELLOW + "mobtarget" + ChatUtils.BULLET_FORMATTED + "Allow all bots to be targeted by hostile mobs.");
|
sender.sendMessage(ChatUtils.BULLET_FORMATTED + ChatColor.YELLOW + "mobtarget" + ChatUtils.BULLET_FORMATTED + "Allow all bots to be targeted by hostile mobs.");
|
||||||
sender.sendMessage(ChatUtils.BULLET_FORMATTED + ChatColor.YELLOW + "playertarget" + ChatUtils.BULLET_FORMATTED + "Sets a player name for spawned bots to focus on if the goal is PLAYER.");
|
sender.sendMessage(ChatUtils.BULLET_FORMATTED + ChatColor.YELLOW + "playertarget" + ChatUtils.BULLET_FORMATTED + "Sets a player name for spawned bots to focus on if the goal is PLAYER.");
|
||||||
@@ -299,7 +300,38 @@ public class BotCommand extends CommandInstance {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg1.equalsIgnoreCase("setgoal")) {
|
if (arg1.equalsIgnoreCase("spawnloc")) {
|
||||||
|
if (arg2 == null) {
|
||||||
|
if (manager.getSpawnLoc() == null)
|
||||||
|
sender.sendMessage("No custom spawn location has been set. The bots will spawn at the player location.");
|
||||||
|
else {
|
||||||
|
Location loc = manager.getSpawnLoc();
|
||||||
|
sender.sendMessage("The next spawn location will be at " + ChatColor.BLUE + String.format("(%s, %s, %s)", loc.getX(), loc.getY(), loc.getZ()) + ChatColor.RESET + ".");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (arg2.equalsIgnoreCase("clear")) {
|
||||||
|
manager.setSpawnLoc(null);
|
||||||
|
sender.sendMessage("The spawn location has been reset to the player location.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (args.size() != 4) {
|
||||||
|
sender.sendMessage("Incorrect argument size. Correct syntax: " + ChatColor.YELLOW + "/bot settings spawnloc <x> <y> <z>" + ChatColor.RESET);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
double x, y, z;
|
||||||
|
try {
|
||||||
|
x = Double.parseDouble(args.get(1));
|
||||||
|
y = Double.parseDouble(args.get(2));
|
||||||
|
z = Double.parseDouble(args.get(3));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
sender.sendMessage("The block coordinates must be doubles!");
|
||||||
|
sender.sendMessage("Correct syntax: " + ChatColor.YELLOW + "/bot settings spawnloc <x> <y> <z>" + ChatColor.RESET);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
manager.setSpawnLoc(new Location(null, x, y, z));
|
||||||
|
sender.sendMessage("The next spawn location has been set to " + ChatColor.BLUE + String.format("(%s, %s, %s)", x, y, z) + ChatColor.RESET + ".");
|
||||||
|
} else if (arg1.equalsIgnoreCase("setgoal")) {
|
||||||
if (arg2 == null) {
|
if (arg2 == null) {
|
||||||
sender.sendMessage("The global bot goal is currently " + ChatColor.BLUE + agent.getTargetType() + ChatColor.RESET + ".");
|
sender.sendMessage("The global bot goal is currently " + ChatColor.BLUE + agent.getTargetType() + ChatColor.RESET + ".");
|
||||||
return;
|
return;
|
||||||
@@ -439,6 +471,7 @@ public class BotCommand extends CommandInstance {
|
|||||||
// lookall
|
// lookall
|
||||||
|
|
||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
|
output.add("spawnloc");
|
||||||
output.add("setgoal");
|
output.add("setgoal");
|
||||||
output.add("mobtarget");
|
output.add("mobtarget");
|
||||||
output.add("playertarget");
|
output.add("playertarget");
|
||||||
|
|||||||
Reference in New Issue
Block a user