refactored almost everything into the API module, and left NMS stuff in plugin module, and performance improvements
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
package net.nuggetmc.tplus.api;
|
||||
|
||||
public interface AIManager {
|
||||
void clearSession();
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package net.nuggetmc.tplus.api;
|
||||
|
||||
import net.nuggetmc.tplus.api.agent.Agent;
|
||||
import net.nuggetmc.tplus.api.agent.legacyagent.ai.NeuralNetwork;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface BotManager {
|
||||
Set<Terminator> fetch();
|
||||
|
||||
Agent getAgent();
|
||||
|
||||
void add(Terminator bot);
|
||||
|
||||
Terminator getFirst(String name);
|
||||
|
||||
List<String> fetchNames();
|
||||
|
||||
void createBots(Player sender, String name, String skinName, int n);
|
||||
|
||||
void createBots(Player sender, String name, String skinName, int n, NeuralNetwork network);
|
||||
|
||||
Set<Terminator> createBots(Location loc, String name, String[] skin, List<NeuralNetwork> networks);
|
||||
|
||||
Set<Terminator> createBots(Location loc, String name, String[] skin, int n, NeuralNetwork network);
|
||||
|
||||
void remove(Terminator bot);
|
||||
|
||||
void reset();
|
||||
|
||||
/**
|
||||
* Get a bot from a Player object
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
* @deprecated Use {@link #getBot(UUID)} instead as this may no longer work
|
||||
*/
|
||||
@Deprecated
|
||||
Terminator getBot(Player player);
|
||||
|
||||
Terminator getBot(UUID uuid);
|
||||
|
||||
Terminator getBot(int entityId);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package net.nuggetmc.tplus.api;
|
||||
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
/**
|
||||
* This class serves as a bridge between the API and internal code that interacts with NMS.
|
||||
*/
|
||||
public interface InternalBridge {
|
||||
void sendBlockDestructionPacket(short entityId, int x, int y, int z, int progress);
|
||||
|
||||
Sound breakBlockSound(Block block);
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
package net.nuggetmc.tplus.api;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.nuggetmc.tplus.api.agent.legacyagent.ai.NeuralNetwork;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
@@ -15,8 +15,12 @@ public interface Terminator {
|
||||
|
||||
String getBotName();
|
||||
|
||||
int getId();
|
||||
|
||||
GameProfile getGameProfile();
|
||||
|
||||
LivingEntity getBukkitEntity();
|
||||
|
||||
NeuralNetwork getNeuralNetwork();
|
||||
|
||||
void setNeuralNetwork(NeuralNetwork neuralNetwork);
|
||||
@@ -25,6 +29,8 @@ public interface Terminator {
|
||||
|
||||
Location getLocation();
|
||||
|
||||
boolean isAlive();
|
||||
|
||||
float getHealth();
|
||||
|
||||
float getMaxHealth();
|
||||
@@ -41,6 +47,10 @@ public interface Terminator {
|
||||
|
||||
boolean isInWater();
|
||||
|
||||
boolean isOnGround();
|
||||
|
||||
void setXRot(float pitch);
|
||||
|
||||
void jump(Vector velocity);
|
||||
|
||||
void jump();
|
||||
@@ -49,6 +59,8 @@ public interface Terminator {
|
||||
|
||||
void look(BlockFace face);
|
||||
|
||||
void faceLocation(Location location);
|
||||
|
||||
void attack(Entity target);
|
||||
|
||||
void attemptBlockPlace(Location loc, Material type, boolean down);
|
||||
@@ -88,4 +100,8 @@ public interface Terminator {
|
||||
int getAliveTicks();
|
||||
|
||||
boolean tickDelay(int ticks);
|
||||
|
||||
void renderBot(Object packetListener, boolean login);
|
||||
|
||||
void setOnFirePackets(boolean onFire);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package net.nuggetmc.tplus.api;
|
||||
|
||||
public class TerminatorPlusAPI {
|
||||
private static InternalBridge internalBridge;
|
||||
private static BotManager botManager;
|
||||
|
||||
public static InternalBridge getInternalBridge() {
|
||||
return internalBridge;
|
||||
}
|
||||
|
||||
public static void setInternalBridge(InternalBridge internalBridge) {
|
||||
TerminatorPlusAPI.internalBridge = internalBridge;
|
||||
}
|
||||
|
||||
public static BotManager getBotManager() {
|
||||
return botManager;
|
||||
}
|
||||
|
||||
public static void setBotManager(BotManager botManager) {
|
||||
TerminatorPlusAPI.botManager = botManager;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
package net.nuggetmc.tplus.bot.agent;
|
||||
package net.nuggetmc.tplus.api.agent;
|
||||
|
||||
import net.nuggetmc.tplus.TerminatorPlus;
|
||||
import net.nuggetmc.tplus.bot.Bot;
|
||||
import net.nuggetmc.tplus.bot.BotManager;
|
||||
import net.nuggetmc.tplus.bot.event.BotDamageByPlayerEvent;
|
||||
import net.nuggetmc.tplus.bot.event.BotDeathEvent;
|
||||
import net.nuggetmc.tplus.bot.event.BotFallDamageEvent;
|
||||
import net.nuggetmc.tplus.bot.event.BotKilledByPlayerEvent;
|
||||
import net.nuggetmc.tplus.api.BotManager;
|
||||
import net.nuggetmc.tplus.api.Terminator;
|
||||
import net.nuggetmc.tplus.api.event.BotDamageByPlayerEvent;
|
||||
import net.nuggetmc.tplus.api.event.BotDeathEvent;
|
||||
import net.nuggetmc.tplus.api.event.BotFallDamageEvent;
|
||||
import net.nuggetmc.tplus.api.event.BotKilledByPlayerEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
@@ -18,7 +18,7 @@ import java.util.Set;
|
||||
|
||||
public abstract class Agent {
|
||||
|
||||
protected final TerminatorPlus plugin;
|
||||
protected final Plugin plugin;
|
||||
protected final BotManager manager;
|
||||
protected final BukkitScheduler scheduler;
|
||||
protected final Set<BukkitRunnable> taskList;
|
||||
@@ -29,8 +29,8 @@ public abstract class Agent {
|
||||
|
||||
protected boolean drops;
|
||||
|
||||
public Agent(BotManager manager) {
|
||||
this.plugin = TerminatorPlus.getInstance();
|
||||
public Agent(BotManager manager, Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
this.manager = manager;
|
||||
this.scheduler = Bukkit.getScheduler();
|
||||
this.taskList = new HashSet<>();
|
||||
@@ -67,17 +67,20 @@ public abstract class Agent {
|
||||
|
||||
protected abstract void tick();
|
||||
|
||||
public void onFallDamage(BotFallDamageEvent event) { }
|
||||
public void onFallDamage(BotFallDamageEvent event) {
|
||||
}
|
||||
|
||||
public void onPlayerDamage(BotDamageByPlayerEvent event) { }
|
||||
public void onPlayerDamage(BotDamageByPlayerEvent event) {
|
||||
}
|
||||
|
||||
public void onBotDeath(BotDeathEvent event) { }
|
||||
public void onBotDeath(BotDeathEvent event) {
|
||||
}
|
||||
|
||||
public void onBotKilledByPlayer(BotKilledByPlayerEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
scheduler.runTaskAsynchronously(plugin, () -> {
|
||||
Bot bot = manager.getBot(player);
|
||||
Terminator bot = manager.getBot(player);
|
||||
|
||||
if (bot != null) {
|
||||
bot.incrementKills();
|
||||
@@ -1,13 +1,14 @@
|
||||
package net.nuggetmc.tplus.bot.agent.botagent;
|
||||
package net.nuggetmc.tplus.api.agent.botagent;
|
||||
|
||||
import net.nuggetmc.tplus.bot.Bot;
|
||||
import net.nuggetmc.tplus.bot.BotManager;
|
||||
import net.nuggetmc.tplus.bot.agent.Agent;
|
||||
import net.nuggetmc.tplus.utils.MathUtils;
|
||||
import net.nuggetmc.tplus.utils.PlayerUtils;
|
||||
import net.nuggetmc.tplus.api.BotManager;
|
||||
import net.nuggetmc.tplus.api.Terminator;
|
||||
import net.nuggetmc.tplus.api.agent.Agent;
|
||||
import net.nuggetmc.tplus.api.utils.MathUtils;
|
||||
import net.nuggetmc.tplus.api.utils.PlayerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Set;
|
||||
@@ -22,19 +23,19 @@ public class BotAgent extends Agent {
|
||||
|
||||
private int count;
|
||||
|
||||
public BotAgent(BotManager manager) {
|
||||
super(manager);
|
||||
public BotAgent(BotManager manager, Plugin plugin) {
|
||||
super(manager, plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tick() {
|
||||
Set<Bot> bots = manager.fetch();
|
||||
Set<Terminator> bots = manager.fetch();
|
||||
count = bots.size();
|
||||
bots.forEach(this::tickBot);
|
||||
}
|
||||
|
||||
// This is where the code starts to get spicy
|
||||
private void tickBot(Bot bot) {
|
||||
private void tickBot(Terminator bot) {
|
||||
if (!bot.isAlive()) return;
|
||||
|
||||
Location loc = bot.getLocation();
|
||||
@@ -90,13 +91,14 @@ public class BotAgent extends Agent {
|
||||
if (bot.tickDelay(3)) attack(bot, player, loc);
|
||||
}
|
||||
|
||||
private void attack(Bot bot, Player player, Location loc) {
|
||||
if (PlayerUtils.isInvincible(player.getGameMode()) || player.getNoDamageTicks() >= 5 || loc.distance(player.getLocation()) >= 4) return;
|
||||
private void attack(Terminator bot, Player player, Location loc) {
|
||||
if (PlayerUtils.isInvincible(player.getGameMode()) || player.getNoDamageTicks() >= 5 || loc.distance(player.getLocation()) >= 4)
|
||||
return;
|
||||
|
||||
bot.attack(player);
|
||||
}
|
||||
|
||||
private void move(Bot bot, Player player, Location loc, Location target) {
|
||||
private void move(Terminator bot, Player player, Location loc, Location target) {
|
||||
Vector vel = target.toVector().subtract(loc.toVector()).normalize();
|
||||
|
||||
if (bot.tickDelay(5)) bot.faceLocation(player.getLocation());
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.nuggetmc.tplus.bot.agent.botagent;
|
||||
package net.nuggetmc.tplus.api.agent.botagent;
|
||||
|
||||
import net.nuggetmc.tplus.bot.Bot;
|
||||
import net.nuggetmc.tplus.api.Terminator;
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class BotSituation {
|
||||
@@ -11,7 +11,7 @@ public class BotSituation {
|
||||
* aboveGround
|
||||
*/
|
||||
|
||||
public BotSituation(Bot bot, Location target) {
|
||||
public BotSituation(Terminator bot, Location target) {
|
||||
Location loc = bot.getLocation();
|
||||
|
||||
this.disp = VerticalDisplacement.fetch(loc.getBlockY(), target.getBlockY());
|
||||
@@ -1,4 +1,4 @@
|
||||
package net.nuggetmc.tplus.bot.agent.botagent;
|
||||
package net.nuggetmc.tplus.api.agent.botagent;
|
||||
|
||||
public enum VerticalDisplacement {
|
||||
AT,
|
||||
@@ -1,4 +1,4 @@
|
||||
package net.nuggetmc.tplus.bot.agent.legacyagent;
|
||||
package net.nuggetmc.tplus.api.agent.legacyagent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -1,29 +1,23 @@
|
||||
package net.nuggetmc.tplus.bot.agent.legacyagent;
|
||||
package net.nuggetmc.tplus.api.agent.legacyagent;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.protocol.game.ClientboundBlockDestructionPacket;
|
||||
import net.nuggetmc.tplus.bot.Bot;
|
||||
import net.nuggetmc.tplus.bot.BotManager;
|
||||
import net.nuggetmc.tplus.bot.agent.Agent;
|
||||
import net.nuggetmc.tplus.api.BotManager;
|
||||
import net.nuggetmc.tplus.api.Terminator;
|
||||
import net.nuggetmc.tplus.api.TerminatorPlusAPI;
|
||||
import net.nuggetmc.tplus.api.agent.Agent;
|
||||
import net.nuggetmc.tplus.api.agent.legacyagent.ai.BotData;
|
||||
import net.nuggetmc.tplus.api.agent.legacyagent.ai.BotNode;
|
||||
import net.nuggetmc.tplus.api.agent.legacyagent.ai.NeuralNetwork;
|
||||
import net.nuggetmc.tplus.bot.event.BotDamageByPlayerEvent;
|
||||
import net.nuggetmc.tplus.bot.event.BotDeathEvent;
|
||||
import net.nuggetmc.tplus.bot.event.BotFallDamageEvent;
|
||||
import net.nuggetmc.tplus.utils.MathUtils;
|
||||
import net.nuggetmc.tplus.utils.PlayerUtils;
|
||||
import net.nuggetmc.tplus.api.event.BotDamageByPlayerEvent;
|
||||
import net.nuggetmc.tplus.api.event.BotDeathEvent;
|
||||
import net.nuggetmc.tplus.api.event.BotFallDamageEvent;
|
||||
import net.nuggetmc.tplus.api.utils.MathUtils;
|
||||
import net.nuggetmc.tplus.api.utils.PlayerUtils;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Boat;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Mob;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@@ -31,72 +25,70 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
// Yes, this code is very unoptimized, I know.
|
||||
public class LegacyAgent extends Agent {
|
||||
|
||||
private static final Pattern NAME_PATTERN = Pattern.compile("[^A-Za-z]+");
|
||||
public final Set<Terminator> noFace = new HashSet<>();
|
||||
public final Set<LivingEntity> noJump = new HashSet<>();
|
||||
public final Set<Terminator> slow = new HashSet<>();
|
||||
private final LegacyBlockCheck blockCheck;
|
||||
|
||||
private EnumTargetGoal goal;
|
||||
|
||||
public boolean offsets = true;
|
||||
|
||||
public LegacyAgent(BotManager manager) {
|
||||
super(manager);
|
||||
|
||||
this.goal = EnumTargetGoal.NEAREST_VULNERABLE_PLAYER;
|
||||
this.blockCheck = new LegacyBlockCheck(this);
|
||||
}
|
||||
|
||||
private final Map<Player, BukkitRunnable> miningAnim = new HashMap<>();
|
||||
private final Map<LivingEntity, BukkitRunnable> miningAnim = new HashMap<>();
|
||||
private final Set<Boat> boats = new HashSet<>();
|
||||
|
||||
private final Map<Player, Location> btList = new HashMap<>();
|
||||
private final Map<Player, Boolean> btCheck = new HashMap<>();
|
||||
private final Map<Player, Location> towerList = new HashMap<>();
|
||||
|
||||
private final Set<Bot> boatCooldown = new HashSet<>();
|
||||
private final Map<LivingEntity, Location> btList = new HashMap<>();
|
||||
private final Map<LivingEntity, Boolean> btCheck = new HashMap<>();
|
||||
private final Map<LivingEntity, Location> towerList = new HashMap<>();
|
||||
private final Set<Terminator> boatCooldown = new HashSet<>();
|
||||
private final Map<Block, Short> crackList = new HashMap<>();
|
||||
private final Map<BukkitRunnable, Byte> mining = new HashMap<>();
|
||||
private final Set<Terminator> fallDamageCooldown = new HashSet<>();
|
||||
public boolean offsets = true;
|
||||
private EnumTargetGoal goal;
|
||||
|
||||
private final Set<Bot> fallDamageCooldown = new HashSet<>();
|
||||
public LegacyAgent(BotManager manager, Plugin plugin) {
|
||||
super(manager, plugin);
|
||||
|
||||
public final Set<Bot> noFace = new HashSet<>();
|
||||
public final Set<Player> noJump = new HashSet<>();
|
||||
this.goal = EnumTargetGoal.NEAREST_VULNERABLE_PLAYER;
|
||||
this.blockCheck = new LegacyBlockCheck(this, plugin);
|
||||
}
|
||||
|
||||
public final Set<Bot> slow = new HashSet<>();
|
||||
private static boolean checkSideBreak(Material type) {
|
||||
return !LegacyMats.BREAK.contains(type);// && !LegacyMats.LEAVES.contains(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tick() {
|
||||
manager.fetch().forEach(this::tickBot);
|
||||
}
|
||||
|
||||
private void center(Bot bot) {
|
||||
private void center(Terminator bot) {
|
||||
if (bot == null || !bot.isAlive()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Player botPlayer = bot.getBukkitEntity();
|
||||
final LivingEntity botEntity = bot.getBukkitEntity();
|
||||
|
||||
Location prev = null;
|
||||
if (btList.containsKey(botPlayer)) {
|
||||
prev = btList.get(botPlayer);
|
||||
if (btList.containsKey(botEntity)) {
|
||||
prev = btList.get(botEntity);
|
||||
}
|
||||
|
||||
Location loc = botPlayer.getLocation();
|
||||
Location loc = botEntity.getLocation();
|
||||
|
||||
if (prev != null) {
|
||||
if (loc.getBlockX() == prev.getBlockX() && loc.getBlockZ() == prev.getBlockZ()) {
|
||||
btCheck.put(botPlayer, true);
|
||||
btCheck.put(botEntity, true);
|
||||
} else {
|
||||
btCheck.put(botPlayer, false);
|
||||
btCheck.put(botEntity, false);
|
||||
}
|
||||
}
|
||||
|
||||
btList.put(botPlayer, loc);
|
||||
btList.put(botEntity, loc);
|
||||
}
|
||||
|
||||
private void tickBot(Bot bot) {
|
||||
private void tickBot(Terminator bot) {
|
||||
if (!bot.isAlive()) {
|
||||
return;
|
||||
}
|
||||
@@ -118,7 +110,7 @@ public class LegacyAgent extends Agent {
|
||||
fallDamageCheck(bot);
|
||||
miscellaneousChecks(bot, livingTarget);
|
||||
|
||||
Player botPlayer = bot.getBukkitEntity();
|
||||
LivingEntity botPlayer = bot.getBukkitEntity();
|
||||
Location target = offsets ? livingTarget.getLocation().add(bot.getOffset()) : livingTarget.getLocation();
|
||||
|
||||
boolean ai = bot.hasNeuralNetwork();
|
||||
@@ -190,14 +182,12 @@ public class LegacyAgent extends Agent {
|
||||
case 2:
|
||||
if (!waterGround) move(bot, livingTarget, loc, target, ai);
|
||||
}
|
||||
}
|
||||
|
||||
else if (LegacyMats.WATER.contains(loc.getBlock().getType())) {
|
||||
} else if (LegacyMats.WATER.contains(loc.getBlock().getType())) {
|
||||
swim(bot, target, botPlayer, livingTarget, LegacyMats.WATER.contains(loc.clone().add(0, -1, 0).getBlock().getType()));
|
||||
}
|
||||
}
|
||||
|
||||
private void move(Bot bot, LivingEntity livingTarget, Location loc, Location target, boolean ai) {
|
||||
private void move(Terminator bot, LivingEntity livingTarget, Location loc, Location target, boolean ai) {
|
||||
Vector position = loc.toVector();
|
||||
Vector vel = target.toVector().subtract(position).normalize();
|
||||
|
||||
@@ -259,9 +249,7 @@ public class LegacyAgent extends Agent {
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
} else {
|
||||
boolean left = network.check(BotNode.LEFT);
|
||||
boolean right = network.check(BotNode.RIGHT);
|
||||
|
||||
@@ -294,7 +282,7 @@ public class LegacyAgent extends Agent {
|
||||
bot.jump(vel);
|
||||
}
|
||||
|
||||
private void fallDamageCheck(Bot bot) {
|
||||
private void fallDamageCheck(Terminator bot) {
|
||||
if (bot.isFalling()) {
|
||||
bot.look(BlockFace.DOWN);
|
||||
|
||||
@@ -319,7 +307,7 @@ public class LegacyAgent extends Agent {
|
||||
|
||||
@Override
|
||||
public void onPlayerDamage(BotDamageByPlayerEvent event) {
|
||||
Bot bot = event.getBot();
|
||||
Terminator bot = event.getBot();
|
||||
Location loc = bot.getLocation();
|
||||
Player player = event.getPlayer();
|
||||
|
||||
@@ -333,7 +321,7 @@ public class LegacyAgent extends Agent {
|
||||
|
||||
@Override
|
||||
public void onFallDamage(BotFallDamageEvent event) {
|
||||
Bot bot = event.getBot();
|
||||
Terminator bot = event.getBot();
|
||||
World world = bot.getBukkitEntity().getWorld();
|
||||
|
||||
bot.look(BlockFace.DOWN);
|
||||
@@ -380,8 +368,10 @@ public class LegacyAgent extends Agent {
|
||||
}
|
||||
}
|
||||
|
||||
private void swim(Bot bot, Location loc, Player playerNPC, LivingEntity target, boolean anim) {
|
||||
playerNPC.setSneaking(false);
|
||||
private void swim(Terminator bot, Location loc, LivingEntity playerNPC, LivingEntity target, boolean anim) {
|
||||
if (playerNPC instanceof Player) {
|
||||
((Player) playerNPC).setSneaking(false);
|
||||
}
|
||||
|
||||
Location at = bot.getLocation();
|
||||
|
||||
@@ -412,8 +402,8 @@ public class LegacyAgent extends Agent {
|
||||
bot.addVelocity(vector);
|
||||
}
|
||||
|
||||
private void stopMining(Bot bot) {
|
||||
Player playerNPC = bot.getBukkitEntity();
|
||||
private void stopMining(Terminator bot) {
|
||||
LivingEntity playerNPC = bot.getBukkitEntity();
|
||||
if (miningAnim.containsKey(playerNPC)) {
|
||||
BukkitRunnable task = miningAnim.get(playerNPC);
|
||||
if (task != null) {
|
||||
@@ -423,7 +413,7 @@ public class LegacyAgent extends Agent {
|
||||
}
|
||||
}
|
||||
|
||||
private byte checkSide(Bot npc, LivingEntity target, Player playerNPC) { // make it so they don't jump when checking side
|
||||
private byte checkSide(Terminator npc, LivingEntity target, LivingEntity playerNPC) { // make it so they don't jump when checking side
|
||||
Location a = playerNPC.getEyeLocation();
|
||||
Location b = target.getLocation().add(0, 1, 0);
|
||||
|
||||
@@ -444,8 +434,8 @@ public class LegacyAgent extends Agent {
|
||||
}
|
||||
}
|
||||
|
||||
private LegacyLevel checkNearby(LivingEntity target, Bot npc) {
|
||||
Player player = npc.getBukkitEntity();
|
||||
private LegacyLevel checkNearby(LivingEntity target, Terminator npc) {
|
||||
LivingEntity player = npc.getBukkitEntity();
|
||||
|
||||
npc.faceLocation(target.getLocation());
|
||||
|
||||
@@ -508,11 +498,7 @@ public class LegacyAgent extends Agent {
|
||||
return level;
|
||||
}
|
||||
|
||||
private static boolean checkSideBreak(Material type) {
|
||||
return !LegacyMats.BREAK.contains(type);// && !LegacyMats.LEAVES.contains(type);
|
||||
}
|
||||
|
||||
private boolean checkUp(Bot npc, LivingEntity target, Player playerNPC, Location loc, boolean c) {
|
||||
private boolean checkUp(Terminator npc, LivingEntity target, LivingEntity playerNPC, Location loc, boolean c) {
|
||||
Location a = playerNPC.getLocation();
|
||||
Location b = target.getLocation();
|
||||
|
||||
@@ -650,9 +636,10 @@ public class LegacyAgent extends Agent {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean checkDown(Bot npc, Player player, Location loc, boolean c) { // possibly a looser check for c
|
||||
private boolean checkDown(Terminator npc, LivingEntity player, Location loc, boolean c) { // possibly a looser check for c
|
||||
|
||||
if (LegacyUtils.checkFreeSpace(npc.getLocation(), loc) || LegacyUtils.checkFreeSpace(player.getEyeLocation(), loc)) return false;
|
||||
if (LegacyUtils.checkFreeSpace(npc.getLocation(), loc) || LegacyUtils.checkFreeSpace(player.getEyeLocation(), loc))
|
||||
return false;
|
||||
|
||||
if (c && npc.getLocation().getBlockY() > loc.getBlockY() + 1) {
|
||||
Block block = npc.getLocation().add(0, -1, 0).getBlock();
|
||||
@@ -661,9 +648,7 @@ public class LegacyAgent extends Agent {
|
||||
downMine(npc, player, block);
|
||||
preBreak(npc, player, block, LegacyLevel.BELOW);
|
||||
return true;
|
||||
}
|
||||
|
||||
else {
|
||||
} else {
|
||||
Location a = loc.clone();
|
||||
Location b = player.getLocation();
|
||||
|
||||
@@ -684,7 +669,7 @@ public class LegacyAgent extends Agent {
|
||||
}
|
||||
}
|
||||
|
||||
private void downMine(Bot npc, Player player, Block block) {
|
||||
private void downMine(Terminator npc, LivingEntity player, Block block) {
|
||||
if (!LegacyMats.NO_CRACK.contains(block.getType())) {
|
||||
Location locBlock = player.getLocation();
|
||||
locBlock.setX(locBlock.getBlockX() + 0.5);
|
||||
@@ -719,7 +704,7 @@ public class LegacyAgent extends Agent {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkFence(Bot bot, Block block, Player player) {
|
||||
private boolean checkFence(Terminator bot, Block block, LivingEntity player) {
|
||||
if (LegacyMats.FENCE.contains(block.getType())) {
|
||||
preBreak(bot, player, block, LegacyLevel.AT_D);
|
||||
return true;
|
||||
@@ -728,7 +713,7 @@ public class LegacyAgent extends Agent {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean checkAt(Bot bot, Block block, Player player) {
|
||||
private boolean checkAt(Terminator bot, Block block, LivingEntity player) {
|
||||
if (LegacyMats.BREAK.contains(block.getType())) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -737,7 +722,7 @@ public class LegacyAgent extends Agent {
|
||||
}
|
||||
}
|
||||
|
||||
private void preBreak(Bot bot, Player player, Block block, LegacyLevel level) {
|
||||
private void preBreak(Terminator bot, LivingEntity player, Block block, LegacyLevel level) {
|
||||
Material item;
|
||||
Material type = block.getType();
|
||||
|
||||
@@ -780,7 +765,7 @@ public class LegacyAgent extends Agent {
|
||||
blockBreakEffect(player, block, level);
|
||||
}
|
||||
|
||||
private void blockBreakEffect(Player player, Block block, LegacyLevel level) {
|
||||
private void blockBreakEffect(LivingEntity player, Block block, LegacyLevel level) {
|
||||
|
||||
if (LegacyMats.NO_CRACK.contains(block.getType())) return;
|
||||
|
||||
@@ -832,26 +817,10 @@ public class LegacyAgent extends Agent {
|
||||
|
||||
// wow this repeated code is so bad lmao
|
||||
|
||||
if (player.isDead()) {
|
||||
if (player.isDead() || (!block.equals(cur) || block.getType() != cur.getType())) {
|
||||
this.cancel();
|
||||
|
||||
ClientboundBlockDestructionPacket crack = new ClientboundBlockDestructionPacket(crackList.get(block), new BlockPos(block.getX(), block.getY(), block.getZ()), -1);
|
||||
for (Player all : Bukkit.getOnlinePlayers()) {
|
||||
((CraftPlayer) all).getHandle().connection.send(crack);
|
||||
}
|
||||
|
||||
crackList.remove(block);
|
||||
mining.remove(this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!block.equals(cur) || block.getType() != cur.getType()) {
|
||||
this.cancel();
|
||||
|
||||
ClientboundBlockDestructionPacket crack = new ClientboundBlockDestructionPacket(crackList.get(block), new BlockPos(block.getX(), block.getY(), block.getZ()), -1);
|
||||
for (Player all : Bukkit.getOnlinePlayers()) {
|
||||
((CraftPlayer) all).getHandle().connection.send(crack);
|
||||
}
|
||||
TerminatorPlusAPI.getInternalBridge().sendBlockDestructionPacket(crackList.get(block), block.getX(), block.getY(), block.getZ(), -1);
|
||||
|
||||
crackList.remove(block);
|
||||
mining.remove(this);
|
||||
@@ -863,13 +832,12 @@ public class LegacyAgent extends Agent {
|
||||
if (i == 9) {
|
||||
this.cancel();
|
||||
|
||||
ClientboundBlockDestructionPacket crack = new ClientboundBlockDestructionPacket(crackList.get(block), new BlockPos(block.getX(), block.getY(), block.getZ()), -1);
|
||||
for (Player all : Bukkit.getOnlinePlayers()) {
|
||||
((CraftPlayer) all).getHandle().connection.send(crack);
|
||||
}
|
||||
TerminatorPlusAPI.getInternalBridge().sendBlockDestructionPacket(crackList.get(block), block.getX(), block.getY(), block.getZ(), -1);
|
||||
|
||||
|
||||
if (sound != null) {
|
||||
for (Player all : Bukkit.getOnlinePlayers()) all.playSound(block.getLocation(), sound, SoundCategory.BLOCKS, 1, 1);
|
||||
for (Player all : Bukkit.getOnlinePlayers())
|
||||
all.playSound(block.getLocation(), sound, SoundCategory.BLOCKS, 1, 1);
|
||||
}
|
||||
|
||||
block.breakNaturally();
|
||||
@@ -888,15 +856,14 @@ public class LegacyAgent extends Agent {
|
||||
}
|
||||
|
||||
if (sound != null) {
|
||||
for (Player all : Bukkit.getOnlinePlayers()) all.playSound(block.getLocation(), sound, SoundCategory.BLOCKS, (float) 0.3, 1);
|
||||
for (Player all : Bukkit.getOnlinePlayers())
|
||||
all.playSound(block.getLocation(), sound, SoundCategory.BLOCKS, (float) 0.3, 1);
|
||||
}
|
||||
|
||||
if (block.getType() == Material.BARRIER || block.getType() == Material.BEDROCK || block.getType() == Material.END_PORTAL_FRAME) return;
|
||||
if (block.getType() == Material.BARRIER || block.getType() == Material.BEDROCK || block.getType() == Material.END_PORTAL_FRAME)
|
||||
return;
|
||||
|
||||
ClientboundBlockDestructionPacket crack = new ClientboundBlockDestructionPacket(crackList.get(block), new BlockPos(block.getX(), block.getY(), block.getZ()), i);
|
||||
for (Player all : Bukkit.getOnlinePlayers()) {
|
||||
((CraftPlayer) all).getHandle().connection.send(crack);
|
||||
}
|
||||
TerminatorPlusAPI.getInternalBridge().sendBlockDestructionPacket(crackList.get(block), block.getX(), block.getY(), block.getZ(), i);
|
||||
|
||||
mining.put(this, (byte) (i + 1));
|
||||
}
|
||||
@@ -909,7 +876,7 @@ public class LegacyAgent extends Agent {
|
||||
}
|
||||
}
|
||||
|
||||
private void placeWaterDown(Bot bot, World world, Location loc) {
|
||||
private void placeWaterDown(Terminator bot, World world, Location loc) {
|
||||
if (loc.getBlock().getType() == Material.WATER) return;
|
||||
|
||||
bot.look(BlockFace.DOWN);
|
||||
@@ -930,8 +897,8 @@ public class LegacyAgent extends Agent {
|
||||
}, 5);
|
||||
}
|
||||
|
||||
private void miscellaneousChecks(Bot bot, LivingEntity target) {
|
||||
Player botPlayer = bot.getBukkitEntity();
|
||||
private void miscellaneousChecks(Terminator bot, LivingEntity target) {
|
||||
LivingEntity botPlayer = bot.getBukkitEntity();
|
||||
World world = botPlayer.getWorld();
|
||||
String worldName = world.getName();
|
||||
Location loc = bot.getLocation();
|
||||
@@ -1076,7 +1043,7 @@ public class LegacyAgent extends Agent {
|
||||
}
|
||||
}
|
||||
|
||||
private void resetHand(Bot npc, LivingEntity target, Player playerNPC) {
|
||||
private void resetHand(Terminator npc, LivingEntity target, LivingEntity playerNPC) {
|
||||
if (!noFace.contains(npc)) { // LESSLAG if there is no if statement here
|
||||
npc.faceLocation(target.getLocation());
|
||||
}
|
||||
@@ -1094,7 +1061,7 @@ public class LegacyAgent extends Agent {
|
||||
npc.setItem(null);
|
||||
}
|
||||
|
||||
private boolean onBoat(Player player) {
|
||||
private boolean onBoat(LivingEntity player) {
|
||||
Set<Boat> cache = new HashSet<>();
|
||||
|
||||
boolean check = false;
|
||||
@@ -1118,8 +1085,9 @@ public class LegacyAgent extends Agent {
|
||||
return check;
|
||||
}
|
||||
|
||||
private void attack(Bot bot, LivingEntity target, Location loc) {
|
||||
if ((target instanceof Player && PlayerUtils.isInvincible(((Player) target).getGameMode())) || target.getNoDamageTicks() >= 5 || loc.distance(target.getLocation()) >= 4) return;
|
||||
private void attack(Terminator bot, LivingEntity target, Location loc) {
|
||||
if ((target instanceof Player && PlayerUtils.isInvincible(((Player) target).getGameMode())) || target.getNoDamageTicks() >= 5 || loc.distance(target.getLocation()) >= 4)
|
||||
return;
|
||||
|
||||
bot.attack(target);
|
||||
}
|
||||
@@ -1128,7 +1096,7 @@ public class LegacyAgent extends Agent {
|
||||
this.goal = goal;
|
||||
}
|
||||
|
||||
public LivingEntity locateTarget(Bot bot, Location loc) {
|
||||
public LivingEntity locateTarget(Terminator bot, Location loc) {
|
||||
LivingEntity result = null;
|
||||
|
||||
switch (goal) {
|
||||
@@ -1176,9 +1144,9 @@ public class LegacyAgent extends Agent {
|
||||
}
|
||||
|
||||
case NEAREST_BOT: {
|
||||
for (Bot otherBot : manager.fetch()) {
|
||||
for (Terminator otherBot : manager.fetch()) {
|
||||
if (bot != otherBot) {
|
||||
Player player = otherBot.getBukkitEntity();
|
||||
LivingEntity player = otherBot.getBukkitEntity();
|
||||
|
||||
if (validateCloserEntity(player, loc, result)) {
|
||||
result = player;
|
||||
@@ -1190,13 +1158,13 @@ public class LegacyAgent extends Agent {
|
||||
}
|
||||
|
||||
case NEAREST_BOT_DIFFER: {
|
||||
String name = bot.getName().getString();
|
||||
String name = bot.getBotName();
|
||||
|
||||
for (Bot otherBot : manager.fetch()) {
|
||||
for (Terminator otherBot : manager.fetch()) {
|
||||
if (bot != otherBot) {
|
||||
Player player = otherBot.getBukkitEntity();
|
||||
LivingEntity player = otherBot.getBukkitEntity();
|
||||
|
||||
if (!name.equals(otherBot.getName()) && validateCloserEntity(player, loc, result)) {
|
||||
if (!name.equals(otherBot.getBotName()) && validateCloserEntity(player, loc, result)) {
|
||||
result = player;
|
||||
}
|
||||
}
|
||||
@@ -1206,13 +1174,13 @@ public class LegacyAgent extends Agent {
|
||||
}
|
||||
|
||||
case NEAREST_BOT_DIFFER_ALPHA: {
|
||||
String name = bot.getName().getString().replaceAll("[^A-Za-z]+", "");
|
||||
String name = NAME_PATTERN.matcher(bot.getBotName()).replaceAll("");
|
||||
|
||||
for (Bot otherBot : manager.fetch()) {
|
||||
for (Terminator otherBot : manager.fetch()) {
|
||||
if (bot != otherBot) {
|
||||
Player player = otherBot.getBukkitEntity();
|
||||
LivingEntity player = otherBot.getBukkitEntity();
|
||||
|
||||
if (!name.equals(otherBot.getName().getString().replaceAll("[^A-Za-z]+", "")) && validateCloserEntity(player, loc, result)) {
|
||||
if (!name.equals(NAME_PATTERN.matcher(otherBot.getBotName()).replaceAll("")) && validateCloserEntity(player, loc, result)) {
|
||||
result = player;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
package net.nuggetmc.tplus.bot.agent.legacyagent;
|
||||
package net.nuggetmc.tplus.api.agent.legacyagent;
|
||||
|
||||
import net.nuggetmc.tplus.TerminatorPlus;
|
||||
import net.nuggetmc.tplus.bot.Bot;
|
||||
import net.nuggetmc.tplus.api.Terminator;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
@@ -15,17 +15,18 @@ import java.util.Set;
|
||||
|
||||
public class LegacyBlockCheck {
|
||||
|
||||
private final TerminatorPlus plugin;
|
||||
private final Plugin plugin;
|
||||
private final LegacyAgent agent;
|
||||
|
||||
public LegacyBlockCheck(LegacyAgent agent) {
|
||||
this.plugin = TerminatorPlus.getInstance();
|
||||
public LegacyBlockCheck(LegacyAgent agent, Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
this.agent = agent;
|
||||
}
|
||||
|
||||
private void placeFinal(Bot bot, Player player, Location loc) {
|
||||
private void placeFinal(Terminator bot, LivingEntity player, Location loc) {
|
||||
if (loc.getBlock().getType() != Material.COBBLESTONE) {
|
||||
for (Player all : Bukkit.getOnlinePlayers()) all.playSound(loc, Sound.BLOCK_STONE_PLACE, SoundCategory.BLOCKS, 1, 1);
|
||||
for (Player all : Bukkit.getOnlinePlayers())
|
||||
all.playSound(loc, Sound.BLOCK_STONE_PLACE, SoundCategory.BLOCKS, 1, 1);
|
||||
bot.setItem(new ItemStack(Material.COBBLESTONE));
|
||||
loc.getBlock().setType(Material.COBBLESTONE);
|
||||
|
||||
@@ -36,7 +37,7 @@ public class LegacyBlockCheck {
|
||||
}
|
||||
}
|
||||
|
||||
public void placeBlock(Bot bot, Player player, Block block) {
|
||||
public void placeBlock(Terminator bot, LivingEntity player, Block block) {
|
||||
|
||||
Location loc = block.getLocation();
|
||||
|
||||
@@ -116,23 +117,26 @@ public class LegacyBlockCheck {
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
||||
Block b2 = loc.clone().add(0, -1, 0).getBlock();
|
||||
if (LegacyMats.SPAWN.contains(b2.getType())) {
|
||||
for (Player all : Bukkit.getOnlinePlayers()) all.playSound(loc, Sound.BLOCK_STONE_PLACE, SoundCategory.BLOCKS, 1, 1);
|
||||
for (Player all : Bukkit.getOnlinePlayers())
|
||||
all.playSound(loc, Sound.BLOCK_STONE_PLACE, SoundCategory.BLOCKS, 1, 1);
|
||||
placeFinal(bot, player, b2.getLocation());
|
||||
}
|
||||
}, 1);
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
||||
for (Player all : Bukkit.getOnlinePlayers()) all.playSound(loc, Sound.BLOCK_STONE_PLACE, SoundCategory.BLOCKS, 1, 1);
|
||||
for (Player all : Bukkit.getOnlinePlayers())
|
||||
all.playSound(loc, Sound.BLOCK_STONE_PLACE, SoundCategory.BLOCKS, 1, 1);
|
||||
placeFinal(bot, player, block.getLocation());
|
||||
}, 3);
|
||||
return;
|
||||
}
|
||||
|
||||
for (Player all : Bukkit.getOnlinePlayers()) all.playSound(loc, Sound.BLOCK_STONE_PLACE, SoundCategory.BLOCKS, 1, 1);
|
||||
for (Player all : Bukkit.getOnlinePlayers())
|
||||
all.playSound(loc, Sound.BLOCK_STONE_PLACE, SoundCategory.BLOCKS, 1, 1);
|
||||
placeFinal(bot, player, block.getLocation());
|
||||
}
|
||||
|
||||
public void clutch(Bot bot, LivingEntity target) {
|
||||
public void clutch(Terminator bot, LivingEntity target) {
|
||||
Location botLoc = bot.getLocation();
|
||||
|
||||
Material type = botLoc.clone().add(0, -1, 0).getBlock().getType();
|
||||
@@ -181,7 +185,8 @@ public class LegacyBlockCheck {
|
||||
|
||||
bot.punch();
|
||||
bot.sneak();
|
||||
for (Player all : Bukkit.getOnlinePlayers()) all.playSound(loc, Sound.BLOCK_STONE_PLACE, SoundCategory.BLOCKS, 1, 1);
|
||||
for (Player all : Bukkit.getOnlinePlayers())
|
||||
all.playSound(loc, Sound.BLOCK_STONE_PLACE, SoundCategory.BLOCKS, 1, 1);
|
||||
bot.setItem(new ItemStack(Material.COBBLESTONE));
|
||||
loc.getBlock().setType(Material.COBBLESTONE);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package net.nuggetmc.tplus.bot.agent.legacyagent;
|
||||
package net.nuggetmc.tplus.api.agent.legacyagent;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package net.nuggetmc.tplus.bot.agent.legacyagent;
|
||||
package net.nuggetmc.tplus.api.agent.legacyagent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
@@ -1,4 +1,4 @@
|
||||
package net.nuggetmc.tplus.bot.agent.legacyagent;
|
||||
package net.nuggetmc.tplus.api.agent.legacyagent;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
package net.nuggetmc.tplus.bot.agent.legacyagent;
|
||||
package net.nuggetmc.tplus.api.agent.legacyagent;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.nuggetmc.tplus.api.TerminatorPlusAPI;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.CraftWorld;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class LegacyUtils {
|
||||
@@ -36,12 +32,6 @@ public class LegacyUtils {
|
||||
}
|
||||
|
||||
public static Sound breakBlockSound(Block block) {
|
||||
Level nmsWorld = ((CraftWorld) block.getWorld()).getHandle();
|
||||
BlockState blockState = nmsWorld.getBlockState(new BlockPos(block.getX(), block.getY(), block.getZ()));
|
||||
net.minecraft.world.level.block.Block nmsBlock = blockState.getBlock();
|
||||
|
||||
SoundType soundEffectType = nmsBlock.getSoundType(blockState);
|
||||
|
||||
return Sound.valueOf( soundEffectType.getBreakSound().getLocation().getPath().replace(".", "_").toUpperCase());
|
||||
return TerminatorPlusAPI.getInternalBridge().breakBlockSound(block);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package net.nuggetmc.tplus.bot.agent.legacyagent;
|
||||
package net.nuggetmc.tplus.api.agent.legacyagent;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.nuggetmc.tplus.api.agent.legacyagent.ai;
|
||||
|
||||
import net.nuggetmc.tplus.api.Terminator;
|
||||
import net.nuggetmc.tplus.utils.MathUtils;
|
||||
import net.nuggetmc.tplus.api.utils.MathUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
@@ -1,25 +1,20 @@
|
||||
package net.nuggetmc.tplus.bot.agent.legacyagent.ai;
|
||||
package net.nuggetmc.tplus.api.agent.legacyagent.ai;
|
||||
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.nuggetmc.tplus.TerminatorPlus;
|
||||
import net.nuggetmc.tplus.api.AIManager;
|
||||
import net.nuggetmc.tplus.api.BotManager;
|
||||
import net.nuggetmc.tplus.api.Terminator;
|
||||
import net.nuggetmc.tplus.api.agent.legacyagent.ai.BotDataType;
|
||||
import net.nuggetmc.tplus.api.agent.legacyagent.ai.BotNode;
|
||||
import net.nuggetmc.tplus.api.agent.legacyagent.ai.NeuralNetwork;
|
||||
import net.nuggetmc.tplus.bot.Bot;
|
||||
import net.nuggetmc.tplus.bot.BotManager;
|
||||
import net.nuggetmc.tplus.bot.agent.legacyagent.EnumTargetGoal;
|
||||
import net.nuggetmc.tplus.bot.agent.legacyagent.LegacyAgent;
|
||||
import net.nuggetmc.tplus.command.commands.AICommand;
|
||||
import net.nuggetmc.tplus.utils.ChatUtils;
|
||||
import net.nuggetmc.tplus.utils.MathUtils;
|
||||
import net.nuggetmc.tplus.utils.MojangAPI;
|
||||
import net.nuggetmc.tplus.utils.PlayerUtils;
|
||||
import net.nuggetmc.tplus.api.agent.legacyagent.EnumTargetGoal;
|
||||
import net.nuggetmc.tplus.api.agent.legacyagent.LegacyAgent;
|
||||
import net.nuggetmc.tplus.api.utils.ChatUtils;
|
||||
import net.nuggetmc.tplus.api.utils.MathUtils;
|
||||
import net.nuggetmc.tplus.api.utils.MojangAPI;
|
||||
import net.nuggetmc.tplus.api.utils.PlayerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
@@ -36,9 +31,9 @@ public class IntelligenceAgent {
|
||||
* default anchor location, /ai relocateanchor
|
||||
*/
|
||||
|
||||
private final TerminatorPlus plugin;
|
||||
private final Plugin plugin;
|
||||
private final BotManager manager;
|
||||
private final AICommand aiManager;
|
||||
private final AIManager aiManager;
|
||||
private final BukkitScheduler scheduler;
|
||||
|
||||
private LegacyAgent agent;
|
||||
@@ -51,7 +46,7 @@ public class IntelligenceAgent {
|
||||
private final String botSkin;
|
||||
private final int cutoff;
|
||||
|
||||
private final Map<String, Bot> bots;
|
||||
private final Map<String, Terminator> bots;
|
||||
|
||||
private int populationSize;
|
||||
private int generation;
|
||||
@@ -61,9 +56,9 @@ public class IntelligenceAgent {
|
||||
private final Set<CommandSender> users;
|
||||
private final Map<Integer, Set<Map<BotNode, Map<BotDataType, Double>>>> genProfiles;
|
||||
|
||||
public IntelligenceAgent(AICommand aiManager, int populationSize, String name, String skin) {
|
||||
this.plugin = TerminatorPlus.getInstance();
|
||||
this.manager = plugin.getManager();
|
||||
public IntelligenceAgent(AIManager aiManager, int populationSize, String name, String skin, Plugin plugin, BotManager manager) {
|
||||
this.plugin = plugin;
|
||||
this.manager = manager;
|
||||
this.aiManager = aiManager;
|
||||
this.scheduler = Bukkit.getScheduler();
|
||||
this.name = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss").format(Calendar.getInstance().getTime());
|
||||
@@ -126,7 +121,7 @@ public class IntelligenceAgent {
|
||||
Location loc = PlayerUtils.findAbove(primary.getLocation(), 20);
|
||||
|
||||
scheduler.runTask(plugin, () -> {
|
||||
Set<Bot> bots;
|
||||
Set<Terminator> bots;
|
||||
|
||||
if (loadedProfiles == null) {
|
||||
bots = manager.createBots(loc, botName, skinData, populationSize, NeuralNetwork.RANDOM);
|
||||
@@ -145,7 +140,7 @@ public class IntelligenceAgent {
|
||||
}
|
||||
|
||||
bots.forEach(bot -> {
|
||||
String name = bot.getName().getString();
|
||||
String name = bot.getBotName();
|
||||
|
||||
while (this.bots.containsKey(name)) {
|
||||
name += "_";
|
||||
@@ -249,7 +244,7 @@ public class IntelligenceAgent {
|
||||
}
|
||||
|
||||
private int aliveCount() {
|
||||
return (int) bots.values().stream().filter(LivingEntity::isAlive).count();
|
||||
return (int) bots.values().stream().filter(Terminator::isAlive).count();
|
||||
}
|
||||
|
||||
private void close() {
|
||||
@@ -331,7 +326,7 @@ public class IntelligenceAgent {
|
||||
if (!bots.isEmpty()) {
|
||||
print("Removing all cached bots...");
|
||||
|
||||
bots.values().forEach(Bot::removeVisually);
|
||||
bots.values().forEach(Terminator::removeVisually);
|
||||
bots.clear();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package net.nuggetmc.tplus.api.agent.legacyagent.ai;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.nuggetmc.tplus.utils.MathUtils;
|
||||
import net.nuggetmc.tplus.utils.ChatUtils;
|
||||
import net.nuggetmc.tplus.api.utils.ChatUtils;
|
||||
import net.nuggetmc.tplus.api.utils.MathUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
package net.nuggetmc.tplus.bot.event;
|
||||
package net.nuggetmc.tplus.api.event;
|
||||
|
||||
import net.nuggetmc.tplus.bot.Bot;
|
||||
import net.nuggetmc.tplus.api.Terminator;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class BotDamageByPlayerEvent {
|
||||
|
||||
private final Bot bot;
|
||||
private final Terminator bot;
|
||||
private final Player player;
|
||||
|
||||
private float damage;
|
||||
|
||||
private boolean cancelled;
|
||||
|
||||
public BotDamageByPlayerEvent(Bot bot, Player player, float damage) {
|
||||
public BotDamageByPlayerEvent(Terminator bot, Player player, float damage) {
|
||||
this.bot = bot;
|
||||
this.player = player;
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
public Bot getBot() {
|
||||
public Terminator getBot() {
|
||||
return bot;
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
package net.nuggetmc.tplus.bot.event;
|
||||
package net.nuggetmc.tplus.api.event;
|
||||
|
||||
import net.nuggetmc.tplus.bot.Bot;
|
||||
import net.nuggetmc.tplus.api.Terminator;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
|
||||
public class BotDeathEvent extends EntityDeathEvent {
|
||||
|
||||
private final Bot bot;
|
||||
private final Terminator bot;
|
||||
|
||||
public BotDeathEvent(EntityDeathEvent event, Bot bot) {
|
||||
public BotDeathEvent(EntityDeathEvent event, Terminator bot) {
|
||||
super(event.getEntity(), event.getDrops(), event.getDroppedExp());
|
||||
this.bot = bot;
|
||||
}
|
||||
|
||||
public Bot getBot() {
|
||||
public Terminator getBot() {
|
||||
return bot;
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,26 @@
|
||||
package net.nuggetmc.tplus.bot.event;
|
||||
package net.nuggetmc.tplus.api.event;
|
||||
|
||||
import net.nuggetmc.tplus.bot.Bot;
|
||||
import net.nuggetmc.tplus.api.Terminator;
|
||||
|
||||
public class BotFallDamageEvent {
|
||||
|
||||
private final Bot bot;
|
||||
private final Terminator bot;
|
||||
|
||||
private boolean cancelled;
|
||||
|
||||
public BotFallDamageEvent(Bot bot) {
|
||||
public BotFallDamageEvent(Terminator bot) {
|
||||
this.bot = bot;
|
||||
}
|
||||
|
||||
public Bot getBot() {
|
||||
public Terminator getBot() {
|
||||
return bot;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.nuggetmc.tplus.bot.event;
|
||||
package net.nuggetmc.tplus.api.event;
|
||||
|
||||
import net.nuggetmc.tplus.bot.Bot;
|
||||
import net.nuggetmc.tplus.api.Terminator;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class BotKilledByPlayerEvent {
|
||||
@@ -8,15 +8,15 @@ public class BotKilledByPlayerEvent {
|
||||
// eventually also call this event for deaths from other damage causes within combat time
|
||||
// (like hitting the ground too hard)
|
||||
|
||||
private final Bot bot;
|
||||
private final Terminator bot;
|
||||
private final Player player;
|
||||
|
||||
public BotKilledByPlayerEvent(Bot bot, Player player) {
|
||||
public BotKilledByPlayerEvent(Terminator bot, Player player) {
|
||||
this.bot = bot;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public Bot getBot() {
|
||||
public Terminator getBot() {
|
||||
return bot;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package net.nuggetmc.tplus.utils;
|
||||
package net.nuggetmc.tplus.api.utils;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@@ -1,4 +1,4 @@
|
||||
package net.nuggetmc.tplus.utils;
|
||||
package net.nuggetmc.tplus.api.utils;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package net.nuggetmc.tplus.bot;
|
||||
package net.nuggetmc.tplus.api.utils;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import net.nuggetmc.tplus.utils.MojangAPI;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package net.nuggetmc.tplus.api.utils;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.permissions.ServerOperator;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class DebugLogUtils {
|
||||
public static final String PREFIX = ChatColor.YELLOW + "[DEBUG] " + ChatColor.RESET;
|
||||
|
||||
public static void log(Object... objects) {
|
||||
String[] values = fromStringArray(objects);
|
||||
String message = PREFIX + String.join(" ", values);
|
||||
|
||||
Bukkit.getConsoleSender().sendMessage(message);
|
||||
Bukkit.getOnlinePlayers().stream().filter(ServerOperator::isOp).forEach(p -> p.sendMessage(message));
|
||||
}
|
||||
|
||||
public static String[] fromStringArray(Object[] objects) {
|
||||
return Arrays.stream(objects).map(String::valueOf).toArray(String[]::new);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package net.nuggetmc.tplus.utils;
|
||||
package net.nuggetmc.tplus.api.utils;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package net.nuggetmc.tplus.utils;
|
||||
package net.nuggetmc.tplus.api.utils;
|
||||
|
||||
import net.nuggetmc.tplus.api.Terminator;
|
||||
import org.bukkit.util.NumberConversions;
|
||||
@@ -1,4 +1,4 @@
|
||||
package net.nuggetmc.tplus.utils;
|
||||
package net.nuggetmc.tplus.api.utils;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.nuggetmc.tplus.utils;
|
||||
package net.nuggetmc.tplus.api.utils;
|
||||
|
||||
import net.nuggetmc.tplus.TerminatorPlus;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.json.simple.JSONArray;
|
||||
@@ -15,12 +15,12 @@ import java.util.Set;
|
||||
|
||||
public class PlayerUtils {
|
||||
|
||||
private static final Set<String> USERNAME_CACHE = new HashSet<>();
|
||||
|
||||
public static boolean isInvincible(GameMode mode) {
|
||||
return mode != GameMode.SURVIVAL && mode != GameMode.ADVENTURE && mode != null;
|
||||
}
|
||||
|
||||
private static final Set<String> USERNAME_CACHE = new HashSet<>();
|
||||
|
||||
public static String randomName() {
|
||||
if (USERNAME_CACHE.isEmpty()) {
|
||||
fillUsernameCache();
|
||||
@@ -30,7 +30,7 @@ public class PlayerUtils {
|
||||
}
|
||||
|
||||
public static void fillUsernameCache() {
|
||||
String file = TerminatorPlus.getInstance().getServer().getWorldContainer().getAbsolutePath();
|
||||
String file = Bukkit.getServer().getWorldContainer().getAbsolutePath();
|
||||
file = file.substring(0, file.length() - 1) + "usercache.json";
|
||||
|
||||
JSONParser parser = new JSONParser();
|
||||
@@ -44,10 +44,8 @@ public class PlayerUtils {
|
||||
|
||||
USERNAME_CACHE.add(username);
|
||||
}
|
||||
}
|
||||
|
||||
catch (IOException | ParseException e) {
|
||||
Debugger.log("Failed to fetch from the usercache.");
|
||||
} catch (IOException | ParseException e) {
|
||||
DebugLogUtils.log("Failed to fetch from the usercache.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package net.nuggetmc.tplus.utils;
|
||||
package net.nuggetmc.tplus.api.utils;
|
||||
|
||||
public class Singularity {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package net.nuggetmc.tplus;
|
||||
|
||||
import net.nuggetmc.tplus.bot.BotManager;
|
||||
import net.nuggetmc.tplus.api.TerminatorPlusAPI;
|
||||
import net.nuggetmc.tplus.bot.BotManagerImpl;
|
||||
import net.nuggetmc.tplus.bridge.InternalBridgeImpl;
|
||||
import net.nuggetmc.tplus.command.CommandHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@@ -12,7 +14,7 @@ public class TerminatorPlus extends JavaPlugin {
|
||||
private static TerminatorPlus instance;
|
||||
private static String version;
|
||||
|
||||
private BotManager manager;
|
||||
private BotManagerImpl manager;
|
||||
private CommandHandler handler;
|
||||
|
||||
public static TerminatorPlus getInstance() {
|
||||
@@ -23,7 +25,7 @@ public class TerminatorPlus extends JavaPlugin {
|
||||
return version;
|
||||
}
|
||||
|
||||
public BotManager getManager() {
|
||||
public BotManagerImpl getManager() {
|
||||
return manager;
|
||||
}
|
||||
|
||||
@@ -37,9 +39,12 @@ public class TerminatorPlus extends JavaPlugin {
|
||||
version = getDescription().getVersion();
|
||||
|
||||
// Create Instances
|
||||
this.manager = new BotManager();
|
||||
this.manager = new BotManagerImpl();
|
||||
this.handler = new CommandHandler(this);
|
||||
|
||||
TerminatorPlusAPI.setBotManager(manager);
|
||||
TerminatorPlusAPI.setInternalBridge(new InternalBridgeImpl());
|
||||
|
||||
// Register event listeners
|
||||
this.registerEvents(manager);
|
||||
}
|
||||
|
||||
@@ -25,12 +25,12 @@ import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.nuggetmc.tplus.TerminatorPlus;
|
||||
import net.nuggetmc.tplus.api.Terminator;
|
||||
import net.nuggetmc.tplus.api.agent.Agent;
|
||||
import net.nuggetmc.tplus.api.agent.legacyagent.ai.NeuralNetwork;
|
||||
import net.nuggetmc.tplus.bot.agent.Agent;
|
||||
import net.nuggetmc.tplus.bot.event.BotDamageByPlayerEvent;
|
||||
import net.nuggetmc.tplus.bot.event.BotFallDamageEvent;
|
||||
import net.nuggetmc.tplus.bot.event.BotKilledByPlayerEvent;
|
||||
import net.nuggetmc.tplus.utils.*;
|
||||
import net.nuggetmc.tplus.api.event.BotDamageByPlayerEvent;
|
||||
import net.nuggetmc.tplus.api.event.BotFallDamageEvent;
|
||||
import net.nuggetmc.tplus.api.event.BotKilledByPlayerEvent;
|
||||
import net.nuggetmc.tplus.api.utils.*;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
@@ -71,6 +71,7 @@ public class Bot extends ServerPlayer implements Terminator {
|
||||
private byte groundTicks;
|
||||
private byte jumpTicks;
|
||||
private byte noFallTicks;
|
||||
|
||||
private Bot(MinecraftServer minecraftServer, ServerLevel worldServer, GameProfile profile) {
|
||||
super(minecraftServer, worldServer, profile);
|
||||
|
||||
@@ -175,6 +176,14 @@ public class Bot extends ServerPlayer implements Terminator {
|
||||
render(connection, getRenderPackets(), login);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderBot(Object packetListener, boolean login) {
|
||||
if (!(packetListener instanceof ServerGamePacketListenerImpl)) {
|
||||
throw new IllegalArgumentException("packetListener must be a instance of ServerGamePacketListenerImpl");
|
||||
}
|
||||
render((ServerGamePacketListenerImpl) packetListener, login);
|
||||
}
|
||||
|
||||
private Packet<?>[] getRenderPackets() {
|
||||
return new Packet[]{
|
||||
new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, this),
|
||||
@@ -336,6 +345,7 @@ public class Bot extends ServerPlayer implements Terminator {
|
||||
fireTicks = 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnFirePackets(boolean onFire) {
|
||||
//entityData.set(new EntityDataAccessor<>(0, EntityDataSerializers.BYTE), onFire ? (byte) 1 : (byte) 0);
|
||||
//sendPacket(new ClientboundSetEntityDataPacket(getId(), entityData, false));
|
||||
@@ -667,6 +677,7 @@ public class Bot extends ServerPlayer implements Terminator {
|
||||
return getBukkitEntity().getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void faceLocation(Location loc) {
|
||||
look(loc.toVector().subtract(getLocation().toVector()), false);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package net.nuggetmc.tplus.bot;
|
||||
|
||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||
import net.nuggetmc.tplus.bot.agent.Agent;
|
||||
import net.nuggetmc.tplus.bot.agent.legacyagent.LegacyAgent;
|
||||
import net.nuggetmc.tplus.TerminatorPlus;
|
||||
import net.nuggetmc.tplus.api.BotManager;
|
||||
import net.nuggetmc.tplus.api.Terminator;
|
||||
import net.nuggetmc.tplus.api.agent.Agent;
|
||||
import net.nuggetmc.tplus.api.agent.legacyagent.LegacyAgent;
|
||||
import net.nuggetmc.tplus.api.agent.legacyagent.ai.NeuralNetwork;
|
||||
import net.nuggetmc.tplus.bot.event.BotDeathEvent;
|
||||
import net.nuggetmc.tplus.utils.MojangAPI;
|
||||
import net.nuggetmc.tplus.api.event.BotDeathEvent;
|
||||
import net.nuggetmc.tplus.api.utils.MojangAPI;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Entity;
|
||||
@@ -23,35 +26,38 @@ import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class BotManager implements Listener {
|
||||
public class BotManagerImpl implements BotManager, Listener {
|
||||
|
||||
private final Agent agent;
|
||||
private final Set<Bot> bots;
|
||||
private final Set<Terminator> bots;
|
||||
private final NumberFormat numberFormat;
|
||||
|
||||
public boolean joinMessages = false;
|
||||
|
||||
public BotManager() {
|
||||
this.agent = new LegacyAgent(this);
|
||||
public BotManagerImpl() {
|
||||
this.agent = new LegacyAgent(this, TerminatorPlus.getInstance());
|
||||
this.bots = ConcurrentHashMap.newKeySet(); //should fix concurrentmodificationexception
|
||||
this.numberFormat = NumberFormat.getInstance(Locale.US);
|
||||
}
|
||||
|
||||
public Set<Bot> fetch() {
|
||||
@Override
|
||||
public Set<Terminator> fetch() {
|
||||
return bots;
|
||||
}
|
||||
|
||||
public void add(Bot bot) {
|
||||
@Override
|
||||
public void add(Terminator bot) {
|
||||
if (joinMessages) {
|
||||
Bukkit.broadcastMessage(ChatColor.YELLOW + (bot.getName() + " joined the game"));
|
||||
Bukkit.broadcastMessage(ChatColor.YELLOW + (bot.getBotName() + " joined the game"));
|
||||
}
|
||||
|
||||
bots.add(bot);
|
||||
}
|
||||
|
||||
public Bot getFirst(String name) {
|
||||
for (Bot bot : bots) {
|
||||
if (name.equals(bot.getName())) {
|
||||
@Override
|
||||
public Terminator getFirst(String name) {
|
||||
for (Terminator bot : bots) {
|
||||
if (name.equals(bot.getBotName())) {
|
||||
return bot;
|
||||
}
|
||||
}
|
||||
@@ -59,18 +65,26 @@ public class BotManager implements Listener {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> fetchNames() {
|
||||
return bots.stream().map(Bot::getName).map(component -> component.getString()).collect(Collectors.toList());
|
||||
//return bots.stream().map(Bot::getBotName).map(component -> component.getString()).collect(Collectors.toList());
|
||||
return bots.stream().map(terminator -> {
|
||||
if (terminator instanceof Bot bot) return bot.getName().getString();
|
||||
else return terminator.getBotName();
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Agent getAgent() {
|
||||
return agent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createBots(Player sender, String name, String skinName, int n) {
|
||||
createBots(sender, name, skinName, n, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createBots(Player sender, String name, String skinName, int n, NeuralNetwork network) {
|
||||
long timestamp = System.currentTimeMillis();
|
||||
|
||||
@@ -88,7 +102,8 @@ public class BotManager implements Listener {
|
||||
sender.sendMessage("Process completed (" + ChatColor.RED + ((System.currentTimeMillis() - timestamp) / 1000D) + "s" + ChatColor.RESET + ").");
|
||||
}
|
||||
|
||||
public Set<Bot> createBots(Location loc, String name, String[] skin, int n, NeuralNetwork network) {
|
||||
@Override
|
||||
public Set<Terminator> createBots(Location loc, String name, String[] skin, int n, NeuralNetwork network) {
|
||||
List<NeuralNetwork> networks = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
@@ -98,8 +113,9 @@ public class BotManager implements Listener {
|
||||
return createBots(loc, name, skin, networks);
|
||||
}
|
||||
|
||||
public Set<Bot> createBots(Location loc, String name, String[] skin, List<NeuralNetwork> networks) {
|
||||
Set<Bot> bots = new HashSet<>();
|
||||
@Override
|
||||
public Set<Terminator> createBots(Location loc, String name, String[] skin, List<NeuralNetwork> networks) {
|
||||
Set<Terminator> bots = new HashSet<>();
|
||||
World world = loc.getWorld();
|
||||
|
||||
int n = networks.size();
|
||||
@@ -138,39 +154,38 @@ public class BotManager implements Listener {
|
||||
return new Vector(Math.random() - 0.5, 0.5, Math.random() - 0.5).normalize();
|
||||
}
|
||||
|
||||
public void remove(Bot bot) {
|
||||
@Override
|
||||
public void remove(Terminator bot) {
|
||||
bots.remove(bot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
if (!bots.isEmpty()) {
|
||||
bots.forEach(Bot::removeVisually);
|
||||
bots.forEach(Terminator::removeVisually);
|
||||
bots.clear(); // Not always necessary, but a good security measure
|
||||
}
|
||||
|
||||
agent.stopAllTasks();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a bot from a Player object
|
||||
* @param player
|
||||
* @deprecated Use {@link #getBot(UUID)} instead as this may no longer work
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public Bot getBot(Player player) { // potentially memory intensive
|
||||
|
||||
@Override
|
||||
public Terminator getBot(Player player) { // potentially memory intensive
|
||||
int id = player.getEntityId();
|
||||
return getBot(id);
|
||||
}
|
||||
|
||||
public Bot getBot(UUID uuid) {
|
||||
@Override
|
||||
public Terminator getBot(UUID uuid) {
|
||||
Entity entity = Bukkit.getEntity(uuid);
|
||||
if (entity == null) return null;
|
||||
return getBot(entity.getEntityId());
|
||||
}
|
||||
|
||||
public Bot getBot(int entityId) {
|
||||
for (Bot bot : bots) {
|
||||
@Override
|
||||
public Terminator getBot(int entityId) {
|
||||
for (Terminator bot : bots) {
|
||||
if (bot.getId() == entityId) {
|
||||
return bot;
|
||||
}
|
||||
@@ -181,13 +196,13 @@ public class BotManager implements Listener {
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent event) {
|
||||
ServerGamePacketListenerImpl connection = ((CraftPlayer) event.getPlayer()).getHandle().connection;
|
||||
bots.forEach(bot -> bot.render(connection, true));
|
||||
bots.forEach(bot -> bot.renderBot(connection, true));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDeath(EntityDeathEvent event) {
|
||||
LivingEntity bukkitEntity = event.getEntity();
|
||||
Bot bot = getBot(bukkitEntity.getEntityId());
|
||||
Terminator bot = getBot(bukkitEntity.getEntityId());
|
||||
if (bot != null) {
|
||||
agent.onBotDeath(new BotDeathEvent(event, bot));
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package net.nuggetmc.tplus.bridge;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.protocol.game.ClientboundBlockDestructionPacket;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.SoundType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.nuggetmc.tplus.api.InternalBridge;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class InternalBridgeImpl implements InternalBridge {
|
||||
@Override
|
||||
public void sendBlockDestructionPacket(short entityId, int x, int y, int z, int progress) {
|
||||
ClientboundBlockDestructionPacket crack = new ClientboundBlockDestructionPacket(entityId, new BlockPos(x, y, z), progress);
|
||||
for (Player all : Bukkit.getOnlinePlayers()) {
|
||||
((CraftPlayer) all).getHandle().connection.send(crack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sound breakBlockSound(Block block) {
|
||||
Level nmsWorld = ((CraftWorld) block.getWorld()).getHandle();
|
||||
BlockState blockState = nmsWorld.getBlockState(new BlockPos(block.getX(), block.getY(), block.getZ()));
|
||||
net.minecraft.world.level.block.Block nmsBlock = blockState.getBlock();
|
||||
|
||||
SoundType soundEffectType = nmsBlock.getSoundType(blockState);
|
||||
|
||||
return Sound.valueOf(soundEffectType.getBreakSound().getLocation().getPath().replace(".", "_").toUpperCase());
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,13 @@ package net.nuggetmc.tplus.command;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import net.nuggetmc.tplus.TerminatorPlus;
|
||||
import net.nuggetmc.tplus.api.utils.ChatUtils;
|
||||
import net.nuggetmc.tplus.api.utils.DebugLogUtils;
|
||||
import net.nuggetmc.tplus.command.annotation.Command;
|
||||
import net.nuggetmc.tplus.command.annotation.Require;
|
||||
import net.nuggetmc.tplus.command.commands.AICommand;
|
||||
import net.nuggetmc.tplus.command.commands.BotCommand;
|
||||
import net.nuggetmc.tplus.command.commands.MainCommand;
|
||||
import net.nuggetmc.tplus.utils.ChatUtils;
|
||||
import net.nuggetmc.tplus.utils.Debugger;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.SimpleCommandMap;
|
||||
@@ -62,7 +62,7 @@ public class CommandHandler {
|
||||
try {
|
||||
method.setAccessible(true);
|
||||
} catch (SecurityException e) {
|
||||
Debugger.log("Failed to access method " + method.getName() + ".");
|
||||
DebugLogUtils.log("Failed to access method " + method.getName() + ".");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package net.nuggetmc.tplus.command;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.nuggetmc.tplus.api.utils.ChatUtils;
|
||||
import net.nuggetmc.tplus.command.annotation.Arg;
|
||||
import net.nuggetmc.tplus.command.annotation.OptArg;
|
||||
import net.nuggetmc.tplus.command.annotation.TextArg;
|
||||
import net.nuggetmc.tplus.command.exception.ArgCountException;
|
||||
import net.nuggetmc.tplus.command.exception.ArgParseException;
|
||||
import net.nuggetmc.tplus.command.exception.NonPlayerException;
|
||||
import net.nuggetmc.tplus.utils.ChatUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.defaults.BukkitCommand;
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
package net.nuggetmc.tplus.command.commands;
|
||||
|
||||
import net.nuggetmc.tplus.TerminatorPlus;
|
||||
import net.nuggetmc.tplus.bot.Bot;
|
||||
import net.nuggetmc.tplus.bot.BotManager;
|
||||
import net.nuggetmc.tplus.bot.agent.legacyagent.ai.IntelligenceAgent;
|
||||
import net.nuggetmc.tplus.api.AIManager;
|
||||
import net.nuggetmc.tplus.api.Terminator;
|
||||
import net.nuggetmc.tplus.api.agent.legacyagent.ai.IntelligenceAgent;
|
||||
import net.nuggetmc.tplus.api.agent.legacyagent.ai.NeuralNetwork;
|
||||
import net.nuggetmc.tplus.api.utils.ChatUtils;
|
||||
import net.nuggetmc.tplus.api.utils.MathUtils;
|
||||
import net.nuggetmc.tplus.bot.BotManagerImpl;
|
||||
import net.nuggetmc.tplus.command.CommandHandler;
|
||||
import net.nuggetmc.tplus.command.CommandInstance;
|
||||
import net.nuggetmc.tplus.command.annotation.Arg;
|
||||
import net.nuggetmc.tplus.command.annotation.Autofill;
|
||||
import net.nuggetmc.tplus.command.annotation.Command;
|
||||
import net.nuggetmc.tplus.command.annotation.OptArg;
|
||||
import net.nuggetmc.tplus.utils.ChatUtils;
|
||||
import net.nuggetmc.tplus.utils.MathUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -22,7 +23,7 @@ import org.bukkit.scheduler.BukkitScheduler;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AICommand extends CommandInstance {
|
||||
public class AICommand extends CommandInstance implements AIManager {
|
||||
|
||||
/*
|
||||
* ideas
|
||||
@@ -31,7 +32,7 @@ public class AICommand extends CommandInstance {
|
||||
*/
|
||||
|
||||
private final TerminatorPlus plugin;
|
||||
private final BotManager manager;
|
||||
private final BotManagerImpl manager;
|
||||
private final BukkitScheduler scheduler;
|
||||
|
||||
private IntelligenceAgent agent;
|
||||
@@ -69,7 +70,7 @@ public class AICommand extends CommandInstance {
|
||||
|
||||
sender.sendMessage("Starting a new session...");
|
||||
|
||||
agent = new IntelligenceAgent(this, populationSize, name, skin);
|
||||
agent = new IntelligenceAgent(this, populationSize, name, skin, plugin, plugin.getManager());
|
||||
agent.addUser(sender);
|
||||
}
|
||||
|
||||
@@ -94,6 +95,7 @@ public class AICommand extends CommandInstance {
|
||||
scheduler.runTaskLater(plugin, () -> sender.sendMessage("The session " + ChatColor.YELLOW + name + ChatColor.RESET + " has been closed."), 10);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearSession() {
|
||||
if (agent != null) {
|
||||
agent.stop();
|
||||
@@ -115,7 +117,7 @@ public class AICommand extends CommandInstance {
|
||||
|
||||
scheduler.runTaskAsynchronously(plugin, () -> {
|
||||
try {
|
||||
Bot bot = manager.getFirst(name);
|
||||
Terminator bot = manager.getFirst(name);
|
||||
|
||||
if (bot == null) {
|
||||
sender.sendMessage("Could not find bot " + ChatColor.GREEN + name + ChatColor.RESET + "!");
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
package net.nuggetmc.tplus.command.commands;
|
||||
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.nuggetmc.tplus.TerminatorPlus;
|
||||
import net.nuggetmc.tplus.bot.Bot;
|
||||
import net.nuggetmc.tplus.bot.BotManager;
|
||||
import net.nuggetmc.tplus.bot.agent.legacyagent.EnumTargetGoal;
|
||||
import net.nuggetmc.tplus.bot.agent.legacyagent.LegacyAgent;
|
||||
import net.nuggetmc.tplus.api.Terminator;
|
||||
import net.nuggetmc.tplus.api.agent.legacyagent.EnumTargetGoal;
|
||||
import net.nuggetmc.tplus.api.agent.legacyagent.LegacyAgent;
|
||||
import net.nuggetmc.tplus.api.utils.ChatUtils;
|
||||
import net.nuggetmc.tplus.bot.BotManagerImpl;
|
||||
import net.nuggetmc.tplus.command.CommandHandler;
|
||||
import net.nuggetmc.tplus.command.CommandInstance;
|
||||
import net.nuggetmc.tplus.command.annotation.Arg;
|
||||
import net.nuggetmc.tplus.command.annotation.Autofill;
|
||||
import net.nuggetmc.tplus.command.annotation.Command;
|
||||
import net.nuggetmc.tplus.command.annotation.OptArg;
|
||||
import net.nuggetmc.tplus.utils.ChatUtils;
|
||||
import net.nuggetmc.tplus.utils.Debugger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@@ -20,6 +19,7 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.util.Vector;
|
||||
@@ -31,11 +31,11 @@ public class BotCommand extends CommandInstance {
|
||||
|
||||
private final TerminatorPlus plugin;
|
||||
private final CommandHandler handler;
|
||||
private final BotManager manager;
|
||||
private final BotManagerImpl manager;
|
||||
private final LegacyAgent agent;
|
||||
private final BukkitScheduler scheduler;
|
||||
private final DecimalFormat formatter;
|
||||
|
||||
private final Map<String, ItemStack[]> armorTiers;
|
||||
private AICommand aiManager;
|
||||
|
||||
public BotCommand(CommandHandler handler, String name, String description, String... aliases) {
|
||||
@@ -92,8 +92,6 @@ public class BotCommand extends CommandInstance {
|
||||
sender.sendMessage("Successfully set the default item to " + ChatColor.YELLOW + item.getType() + ChatColor.RESET + " for all current bots.");
|
||||
}
|
||||
|
||||
private final Map<String, ItemStack[]> armorTiers;
|
||||
|
||||
private void armorTierSetup() {
|
||||
armorTiers.put("leather", new ItemStack[]{
|
||||
new ItemStack(Material.LEATHER_BOOTS),
|
||||
@@ -156,14 +154,17 @@ public class BotCommand extends CommandInstance {
|
||||
ItemStack[] armor = armorTiers.get(tier);
|
||||
|
||||
manager.fetch().forEach(bot -> {
|
||||
bot.getBukkitEntity().getInventory().setArmorContents(armor);
|
||||
bot.getBukkitEntity().updateInventory();
|
||||
if (bot.getBukkitEntity() instanceof Player) {
|
||||
Player botPlayer = (Player) bot.getBukkitEntity();
|
||||
botPlayer.getInventory().setArmorContents(armor);
|
||||
botPlayer.updateInventory();
|
||||
|
||||
// packet sending to ensure
|
||||
bot.setItem(armor[0], EquipmentSlot.FEET);
|
||||
bot.setItem(armor[1], EquipmentSlot.LEGS);
|
||||
bot.setItem(armor[2], EquipmentSlot.CHEST);
|
||||
bot.setItem(armor[3], EquipmentSlot.HEAD);
|
||||
}
|
||||
});
|
||||
|
||||
sender.sendMessage("Successfully set the armor tier to " + ChatColor.YELLOW + tier + ChatColor.RESET + " for all current bots.");
|
||||
@@ -189,7 +190,7 @@ public class BotCommand extends CommandInstance {
|
||||
|
||||
scheduler.runTaskAsynchronously(plugin, () -> {
|
||||
try {
|
||||
Bot bot = manager.getFirst(name);
|
||||
Terminator bot = manager.getFirst(name);
|
||||
|
||||
if (bot == null) {
|
||||
sender.sendMessage("Could not find bot " + ChatColor.GREEN + name + ChatColor.RESET + "!");
|
||||
@@ -207,7 +208,7 @@ public class BotCommand extends CommandInstance {
|
||||
* neural network values (network name if loaded, otherwise RANDOM)
|
||||
*/
|
||||
|
||||
String botName = bot.getName().getString();
|
||||
String botName = bot.getBotName();
|
||||
String world = ChatColor.YELLOW + bot.getBukkitEntity().getWorld().getName();
|
||||
Location loc = bot.getLocation();
|
||||
String strLoc = ChatColor.YELLOW + formatter.format(loc.getBlockX()) + ", " + formatter.format(loc.getBlockY()) + ", " + formatter.format(loc.getBlockZ());
|
||||
@@ -220,9 +221,7 @@ public class BotCommand extends CommandInstance {
|
||||
sender.sendMessage(ChatUtils.BULLET_FORMATTED + "Position: " + strLoc);
|
||||
sender.sendMessage(ChatUtils.BULLET_FORMATTED + "Velocity: " + strVel);
|
||||
sender.sendMessage(ChatUtils.LINE);
|
||||
}
|
||||
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage(ChatUtils.EXCEPTION_MESSAGE);
|
||||
}
|
||||
});
|
||||
@@ -307,9 +306,7 @@ public class BotCommand extends CommandInstance {
|
||||
|
||||
if (args.length == 2) {
|
||||
output.add("setgoal");
|
||||
}
|
||||
|
||||
else if (args.length == 3) {
|
||||
} else if (args.length == 3) {
|
||||
if (args[1].equalsIgnoreCase("setgoal")) {
|
||||
Arrays.stream(EnumTargetGoal.values()).forEach(goal -> output.add(goal.name().replace("_", "").toLowerCase()));
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@ import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.hover.content.Text;
|
||||
import net.nuggetmc.tplus.TerminatorPlus;
|
||||
import net.nuggetmc.tplus.api.utils.ChatUtils;
|
||||
import net.nuggetmc.tplus.command.CommandHandler;
|
||||
import net.nuggetmc.tplus.command.CommandInstance;
|
||||
import net.nuggetmc.tplus.command.annotation.Command;
|
||||
import net.nuggetmc.tplus.utils.ChatUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
package net.nuggetmc.tplus.utils;
|
||||
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.nuggetmc.tplus.TerminatorPlus;
|
||||
import net.nuggetmc.tplus.bot.Bot;
|
||||
import net.nuggetmc.tplus.bot.agent.Agent;
|
||||
import net.nuggetmc.tplus.bot.agent.legacyagent.LegacyAgent;
|
||||
import net.nuggetmc.tplus.bot.agent.legacyagent.ai.IntelligenceAgent;
|
||||
import net.nuggetmc.tplus.api.Terminator;
|
||||
import net.nuggetmc.tplus.api.agent.Agent;
|
||||
import net.nuggetmc.tplus.api.agent.legacyagent.LegacyAgent;
|
||||
import net.nuggetmc.tplus.api.agent.legacyagent.ai.IntelligenceAgent;
|
||||
import net.nuggetmc.tplus.api.agent.legacyagent.ai.NeuralNetwork;
|
||||
import net.nuggetmc.tplus.api.utils.DebugLogUtils;
|
||||
import net.nuggetmc.tplus.api.utils.MathUtils;
|
||||
import net.nuggetmc.tplus.api.utils.MojangAPI;
|
||||
import net.nuggetmc.tplus.api.utils.PlayerUtils;
|
||||
import net.nuggetmc.tplus.bot.Bot;
|
||||
import net.nuggetmc.tplus.command.commands.AICommand;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -23,28 +27,15 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class Debugger {
|
||||
|
||||
private static final String PREFIX = ChatColor.YELLOW + "[DEBUG] " + ChatColor.RESET;
|
||||
|
||||
private final CommandSender sender;
|
||||
|
||||
public Debugger(CommandSender sender) {
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
public static void log(Object... objects) {
|
||||
String[] values = formStringArray(objects);
|
||||
String message = PREFIX + String.join(" ", values);
|
||||
|
||||
Bukkit.getConsoleSender().sendMessage(message);
|
||||
Bukkit.getOnlinePlayers().stream().filter(ServerOperator::isOp).forEach(p -> p.sendMessage(message));
|
||||
}
|
||||
|
||||
private static String[] formStringArray(Object[] objects) {
|
||||
return Arrays.stream(objects).map(String::valueOf).toArray(String[]::new);
|
||||
}
|
||||
|
||||
private void print(Object... objects) {
|
||||
sender.sendMessage(PREFIX + String.join(" ", formStringArray(objects)));
|
||||
sender.sendMessage(DebugLogUtils.PREFIX + String.join(" ", DebugLogUtils.fromStringArray(objects)));
|
||||
}
|
||||
|
||||
public void execute(String cmd) {
|
||||
@@ -60,9 +51,7 @@ public class Debugger {
|
||||
Statement statement = new Statement(this, name, args);
|
||||
print("Running the expression \"" + ChatColor.AQUA + cmd + ChatColor.RESET + "\"...");
|
||||
statement.execute();
|
||||
}
|
||||
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
print("Error: the expression \"" + ChatColor.AQUA + cmd + ChatColor.RESET + "\" failed to execute.");
|
||||
print(e.toString());
|
||||
}
|
||||
@@ -80,11 +69,13 @@ public class Debugger {
|
||||
|
||||
try {
|
||||
obj = Double.parseDouble(value);
|
||||
} catch (NumberFormatException ignored) { }
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
|
||||
try {
|
||||
obj = Integer.parseInt(value);
|
||||
} catch (NumberFormatException ignored) { }
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
|
||||
if (value.equalsIgnoreCase("true") || value.equalsIgnoreCase("false")) {
|
||||
obj = Boolean.parseBoolean(value);
|
||||
@@ -222,7 +213,7 @@ public class Debugger {
|
||||
|
||||
public void tpall() {
|
||||
Player player = (Player) sender;
|
||||
TerminatorPlus.getInstance().getManager().fetch().stream().filter(LivingEntity::isAlive).forEach(bot -> bot.getBukkitEntity().teleport(player));
|
||||
TerminatorPlus.getInstance().getManager().fetch().stream().filter(Terminator::isAlive).forEach(bot -> bot.getBukkitEntity().teleport(player));
|
||||
}
|
||||
|
||||
public void viewsession() {
|
||||
@@ -244,9 +235,7 @@ public class Debugger {
|
||||
LegacyAgent legacyAgent = (LegacyAgent) agent;
|
||||
legacyAgent.offsets = b;
|
||||
|
||||
print("Bot target offsets are now "
|
||||
+ (legacyAgent.offsets ? ChatColor.GREEN + "ENABLED" : ChatColor.RED + "DISABLED")
|
||||
+ ChatColor.RESET + ".");
|
||||
print("Bot target offsets are now " + (legacyAgent.offsets ? ChatColor.GREEN + "ENABLED" : ChatColor.RED + "DISABLED") + ChatColor.RESET + ".");
|
||||
}
|
||||
|
||||
public void confuse(int n) {
|
||||
@@ -269,12 +258,7 @@ public class Debugger {
|
||||
}
|
||||
|
||||
public void dreamsmp() {
|
||||
spawnBots(Arrays.asList(
|
||||
"Dream", "GeorgeNotFound", "Callahan", "Sapnap", "awesamdude", "Ponk", "BadBoyHalo", "TommyInnit", "Tubbo_", "ItsFundy", "Punz",
|
||||
"Purpled", "WilburSoot", "Jschlatt", "Skeppy", "The_Eret", "JackManifoldTV", "Nihachu", "Quackity", "KarlJacobs", "HBomb94",
|
||||
"Technoblade", "Antfrost", "Ph1LzA", "ConnorEatsPants", "CaptainPuffy", "Vikkstar123", "LazarCodeLazar", "Ranboo", "FoolishG",
|
||||
"hannahxxrose", "Slimecicle", "Michaelmcchill"
|
||||
));
|
||||
spawnBots(Arrays.asList("Dream", "GeorgeNotFound", "Callahan", "Sapnap", "awesamdude", "Ponk", "BadBoyHalo", "TommyInnit", "Tubbo_", "ItsFundy", "Punz", "Purpled", "WilburSoot", "Jschlatt", "Skeppy", "The_Eret", "JackManifoldTV", "Nihachu", "Quackity", "KarlJacobs", "HBomb94", "Technoblade", "Antfrost", "Ph1LzA", "ConnorEatsPants", "CaptainPuffy", "Vikkstar123", "LazarCodeLazar", "Ranboo", "FoolishG", "hannahxxrose", "Slimecicle", "Michaelmcchill"));
|
||||
}
|
||||
|
||||
private void spawnBots(List<String> players) {
|
||||
@@ -319,9 +303,7 @@ public class Debugger {
|
||||
|
||||
print("Done.");
|
||||
});
|
||||
}
|
||||
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
print(e);
|
||||
}
|
||||
});
|
||||
@@ -352,14 +334,14 @@ public class Debugger {
|
||||
}
|
||||
|
||||
public void tp() {
|
||||
Bot bot = MathUtils.getRandomSetElement(TerminatorPlus.getInstance().getManager().fetch().stream().filter(LivingEntity::isAlive).collect(Collectors.toSet()));
|
||||
Terminator bot = MathUtils.getRandomSetElement(TerminatorPlus.getInstance().getManager().fetch().stream().filter(Terminator::isAlive).collect(Collectors.toSet()));
|
||||
|
||||
if (bot == null) {
|
||||
print("Failed to locate a bot.");
|
||||
return;
|
||||
}
|
||||
|
||||
print("Located bot", (ChatColor.GREEN.toString() + bot.getName() + ChatColor.RESET.toString() + "."));
|
||||
print("Located bot", (ChatColor.GREEN + bot.getBotName() + ChatColor.RESET + "."));
|
||||
|
||||
if (sender instanceof Player) {
|
||||
print("Teleporting...");
|
||||
@@ -386,9 +368,9 @@ public class Debugger {
|
||||
}
|
||||
|
||||
public void hideNametags() { // this works for some reason
|
||||
Set<Bot> bots = TerminatorPlus.getInstance().getManager().fetch();
|
||||
Set<Terminator> bots = TerminatorPlus.getInstance().getManager().fetch();
|
||||
|
||||
for (Bot bot : bots) {
|
||||
for (Terminator bot : bots) {
|
||||
Location loc = bot.getLocation();
|
||||
World world = loc.getWorld();
|
||||
|
||||
@@ -409,9 +391,9 @@ public class Debugger {
|
||||
}
|
||||
|
||||
public void sit() {
|
||||
Set<Bot> bots = TerminatorPlus.getInstance().getManager().fetch();
|
||||
Set<Terminator> bots = TerminatorPlus.getInstance().getManager().fetch();
|
||||
|
||||
for (Bot bot : bots) {
|
||||
for (Terminator bot : bots) {
|
||||
Location loc = bot.getLocation();
|
||||
World world = loc.getWorld();
|
||||
|
||||
@@ -440,7 +422,7 @@ public class Debugger {
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
for (Bot bot : TerminatorPlus.getInstance().getManager().fetch()) {
|
||||
for (Terminator bot : TerminatorPlus.getInstance().getManager().fetch()) {
|
||||
bot.faceLocation(player.getEyeLocation());
|
||||
}
|
||||
}
|
||||
@@ -451,8 +433,6 @@ public class Debugger {
|
||||
boolean b = agent.isEnabled();
|
||||
agent.setEnabled(!b);
|
||||
|
||||
print("The Bot Agent is now "
|
||||
+ (b ? ChatColor.RED + "DISABLED" : ChatColor.GREEN + "ENABLED")
|
||||
+ ChatColor.RESET + ".");
|
||||
print("The Bot Agent is now " + (b ? ChatColor.RED + "DISABLED" : ChatColor.GREEN + "ENABLED") + ChatColor.RESET + ".");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user