added single player target
This commit is contained in:
@@ -11,6 +11,8 @@ import org.bukkit.inventory.EquipmentSlot;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public interface Terminator {
|
public interface Terminator {
|
||||||
|
|
||||||
String getBotName();
|
String getBotName();
|
||||||
@@ -110,4 +112,8 @@ public interface Terminator {
|
|||||||
void renderBot(Object packetListener, boolean login);
|
void renderBot(Object packetListener, boolean login);
|
||||||
|
|
||||||
void setOnFirePackets(boolean onFire);
|
void setOnFirePackets(boolean onFire);
|
||||||
|
|
||||||
|
UUID getTargetPlayer();
|
||||||
|
|
||||||
|
void setTargetPlayer(UUID target);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,9 +11,10 @@ public enum EnumTargetGoal {
|
|||||||
NEAREST_BOT("Locate the nearest bot."),
|
NEAREST_BOT("Locate the nearest bot."),
|
||||||
NEAREST_BOT_DIFFER("Locate the nearest bot with a different username."),
|
NEAREST_BOT_DIFFER("Locate the nearest bot with a different username."),
|
||||||
NEAREST_BOT_DIFFER_ALPHA("Locate the nearest bot with a different username after filtering out non-alpha characters."),
|
NEAREST_BOT_DIFFER_ALPHA("Locate the nearest bot with a different username after filtering out non-alpha characters."),
|
||||||
|
PLAYER("Target a single player. Defaults to NEAREST_VULNERABLE_PLAYER if no player found."),
|
||||||
NONE("No target goal.");
|
NONE("No target goal.");
|
||||||
|
|
||||||
private static final Map<String, EnumTargetGoal> VALUES = new HashMap<String, EnumTargetGoal>() {
|
private static final Map<String, EnumTargetGoal> VALUES = new HashMap<>() {
|
||||||
{
|
{
|
||||||
this.put("none", NONE);
|
this.put("none", NONE);
|
||||||
this.put("nearestvulnerableplayer", NEAREST_VULNERABLE_PLAYER);
|
this.put("nearestvulnerableplayer", NEAREST_VULNERABLE_PLAYER);
|
||||||
|
|||||||
@@ -1115,10 +1115,12 @@ public class LegacyAgent extends Agent {
|
|||||||
this.goal = goal;
|
this.goal = goal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LivingEntity locateTarget(Terminator bot, Location loc) {
|
public LivingEntity locateTarget(Terminator bot, Location loc, EnumTargetGoal... targetGoal) {
|
||||||
LivingEntity result = null;
|
LivingEntity result = null;
|
||||||
|
|
||||||
switch (goal) {
|
EnumTargetGoal g = goal;
|
||||||
|
if (targetGoal.length > 0) g = targetGoal[0];
|
||||||
|
switch (g) {
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
@@ -1205,6 +1207,15 @@ public class LegacyAgent extends Agent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case PLAYER: { //Target a single player. Defaults to NEAREST_VULNERABLE_PLAYER if no player found.
|
||||||
|
if (bot.getTargetPlayer() != null) {
|
||||||
|
Player player = Bukkit.getPlayer(bot.getTargetPlayer());
|
||||||
|
if (player != null) {
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return locateTarget(bot, loc, EnumTargetGoal.NEAREST_VULNERABLE_PLAYER);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public class Bot extends ServerPlayer implements Terminator {
|
|||||||
private byte jumpTicks;
|
private byte jumpTicks;
|
||||||
private byte noFallTicks;
|
private byte noFallTicks;
|
||||||
private boolean ignoredByMobs = true;
|
private boolean ignoredByMobs = true;
|
||||||
|
private UUID targetPlayer = null;
|
||||||
private Bot(MinecraftServer minecraftServer, ServerLevel worldServer, GameProfile profile) {
|
private Bot(MinecraftServer minecraftServer, ServerLevel worldServer, GameProfile profile) {
|
||||||
super(minecraftServer, worldServer, profile, null);
|
super(minecraftServer, worldServer, profile, null);
|
||||||
|
|
||||||
@@ -373,6 +373,16 @@ public class Bot extends ServerPlayer implements Terminator {
|
|||||||
//sendPacket(new ClientboundSetEntityDataPacket(getId(), entityData, false));
|
//sendPacket(new ClientboundSetEntityDataPacket(getId(), entityData, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UUID getTargetPlayer() {
|
||||||
|
return targetPlayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setTargetPlayer(UUID target) {
|
||||||
|
this.targetPlayer = target;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isBotOnFire() {
|
public boolean isBotOnFire() {
|
||||||
return fireTicks != 0;
|
return fireTicks != 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user