added readme and refactored NPC to Bot because bot sounds cooler and NPC sounds too much like Citizens and citizens yuck amirite

This commit is contained in:
batchprogrammer314
2021-06-27 00:26:45 -05:00
parent 19abd19a9d
commit 30e8ee3f82
5 changed files with 43 additions and 43 deletions

View File

@@ -0,0 +1,48 @@
package net.nuggetmc.ai.bot;
import net.minecraft.server.v1_16_R3.PlayerConnection;
import net.nuggetmc.ai.PlayerAI;
import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import java.util.HashSet;
import java.util.Set;
public class BotManager implements Listener {
private final PlayerAI plugin;
private final Set<Bot> bots = new HashSet<>();
public Set<Bot> fetch() {
return bots;
}
public void add(Bot bot) {
bots.add(bot);
}
public BotManager(PlayerAI plugin) {
this.plugin = plugin;
}
public void reset() {
for (Bot bot : bots) {
bot.despawn();
}
bots.clear();
}
@EventHandler
public void onJoin(PlayerJoinEvent event) {
PlayerConnection connection = ((CraftPlayer) event.getPlayer()).getHandle().playerConnection;
for (Bot bot : bots) {
bot.render(connection, true);
}
}
}