Files
src
build.gradle
config.yml
plugin.yml
Code
9 627
src/main/java/com/playerbots/PlayerBots.java
package com.playerbots;
import com.playerbots.bot.BotManager;
import com.playerbots.commands.BotCommand;
import com.playerbots.listeners.BotListener;
import org.bukkit.plugin.java.JavaPlugin;
public class PlayerBots extends JavaPlugin {
private BotManager botManager;
private boolean protocolLibEnabled = false;
@Override
public void onEnable() {
saveDefaultConfig();
// Check for ProtocolLib
if (getServer().getPluginManager().getPlugin("ProtocolLib") != null) {
protocolLibEnabled = true;
getLogger().info("ProtocolLib detected! Full fake player support enabled.");
} else {
getLogger().warning("ProtocolLib not found. Bots will be physical entities but won't appear in tab list.");
getLogger().warning("Install ProtocolLib for full fake player functionality.");
}
// Initialize managers
botManager = new BotManager(this);
// Register commands
getCommand("bot").setExecutor(new BotCommand(this));
// Register listeners
getServer().getPluginManager().registerEvents(new BotListener(this), this);
// Load bots from config
botManager.loadBotsFromConfig();
getLogger().info("PlayerBots has been enabled!");
}
@Override
public void onDisable() {
if (botManager != null) {
botManager.removeAllBots();
}
getLogger().info("PlayerBots has been disabled!");
}
public BotManager getBotManager() {
return botManager;
}
public boolean isProtocolLibEnabled() {
return protocolLibEnabled;
}
public String getMessage(String key) {
return getConfig().getString("messages." + key, "&cMessage not found: " + key)
.replace("&", "§");
}
}