improve bot options? mabe mabe
This commit is contained in:
@@ -23,15 +23,13 @@ public class Bot {
|
||||
|
||||
@Getter private final String host;
|
||||
@Getter private final int port;
|
||||
private final String _username;
|
||||
@Getter private final boolean kaboom;
|
||||
@Getter private final String serverName;
|
||||
@Getter @Setter private boolean useCore;
|
||||
@Getter @Setter private boolean useChat;
|
||||
@Getter private final boolean hasEssentials;
|
||||
@Getter private final List<Bot> allBots;
|
||||
|
||||
@Getter private final Configuration.BotOption options;
|
||||
|
||||
@Getter private final Configuration config;
|
||||
|
||||
@Getter private List<Bot> allBots;
|
||||
|
||||
@Getter private String username;
|
||||
|
||||
@Getter public Session session;
|
||||
@@ -65,16 +63,14 @@ public class Bot {
|
||||
@Getter private MazePlugin maze;
|
||||
@Getter private ExploitsPlugin exploits;
|
||||
|
||||
public Bot (String host, int port, String _username, boolean kaboom, String serverName, boolean useCore, boolean useChat, boolean hasEssentials, List<Bot> allBots, Configuration config) {
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
this._username = _username;
|
||||
this.kaboom = kaboom;
|
||||
this.serverName = serverName;
|
||||
this.useCore = useCore;
|
||||
this.useChat = useChat;
|
||||
this.hasEssentials = hasEssentials;
|
||||
public Bot (Configuration.BotOption botOption, List<Bot> allBots, Configuration config) {
|
||||
this.host = botOption.host;
|
||||
this.port = botOption.port;
|
||||
|
||||
this.options = botOption;
|
||||
|
||||
this.allBots = allBots;
|
||||
|
||||
this.config = config;
|
||||
|
||||
ConsolePlugin.addListener(new ConsolePlugin.Listener() {
|
||||
@@ -111,6 +107,8 @@ public class Bot {
|
||||
}
|
||||
|
||||
public void reconnect () {
|
||||
final String _username = options.username();
|
||||
|
||||
if (_username == null) username = RandomStringUtils.randomAlphabetic(8);
|
||||
else username = _username;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public class Configuration {
|
||||
|
||||
@Getter public List<String> trusted = new ArrayList<>();
|
||||
@Getter public SelfCare selfCare = new SelfCare();
|
||||
@Getter public Bots[] bots = new Bots[]{};
|
||||
@Getter public BotOption[] bots = new BotOption[]{};
|
||||
|
||||
public static class Core {
|
||||
@Getter public int layers = 3;
|
||||
@@ -73,7 +73,7 @@ public class Configuration {
|
||||
@Getter public int positionPacketsPerSecond = 10;
|
||||
}
|
||||
|
||||
public static class Bots {
|
||||
public static class BotOption {
|
||||
@Getter public String host;
|
||||
@Getter public int port;
|
||||
@Getter public String username;
|
||||
|
||||
@@ -48,7 +48,7 @@ public class Main {
|
||||
|
||||
final Configuration config = _config;
|
||||
|
||||
Configuration.Bots[] botsOptions = config.bots();
|
||||
Configuration.BotOption[] botsOptions = config.bots();
|
||||
|
||||
// idk if these should be here lol, but it is just the discord stuff
|
||||
JDA jda = null;
|
||||
@@ -64,17 +64,8 @@ public class Main {
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
for (Configuration.Bots botOption : botsOptions) {
|
||||
final String host = botOption.host();
|
||||
final int port = botOption.port();
|
||||
final String username = botOption.username();
|
||||
final boolean kaboom = botOption.kaboom();
|
||||
final String serverName = botOption.serverName();
|
||||
final boolean useCore = botOption.useCore();
|
||||
final boolean useChat = botOption.useChat();
|
||||
final boolean hasEssentials = botOption.hasEssentials();
|
||||
|
||||
final Bot bot = new Bot(host, port, username, kaboom, serverName, useCore, useChat, hasEssentials, allBots, config);
|
||||
for (Configuration.BotOption botOption : botsOptions) {
|
||||
final Bot bot = new Bot(botOption, allBots, config);
|
||||
allBots.add(bot);
|
||||
}
|
||||
|
||||
|
||||
@@ -181,7 +181,7 @@ public class ChatPlugin extends SessionAdapter {
|
||||
}
|
||||
|
||||
public void tellraw (Component component, String targets) {
|
||||
if (bot.useChat()) {
|
||||
if (bot.options().useChat()) {
|
||||
if (!targets.equals("@a")) return; // worst fix of all time!1!
|
||||
|
||||
final String stringified = ComponentUtilities.stringifyMotd(component).replace("§", "&");
|
||||
|
||||
@@ -54,7 +54,7 @@ public class CorePlugin extends PositionPlugin.PositionListener {
|
||||
|
||||
public CorePlugin (Bot bot) {
|
||||
this.bot = bot;
|
||||
this.kaboom = bot.kaboom();
|
||||
this.kaboom = bot.options().kaboom();
|
||||
|
||||
bot.position().addListener(this);
|
||||
|
||||
@@ -78,7 +78,7 @@ public class CorePlugin extends PositionPlugin.PositionListener {
|
||||
public void run (String command) {
|
||||
if (!ready) return;
|
||||
|
||||
if (bot.useCore()) {
|
||||
if (bot.options().useCore()) {
|
||||
bot.session().send(new ServerboundSetCommandBlockPacket(
|
||||
absoluteCorePosition(),
|
||||
command,
|
||||
|
||||
@@ -92,24 +92,24 @@ public class SelfCarePlugin extends SessionAdapter {
|
||||
|
||||
if (selfCares.gamemode() && gamemode != GameMode.CREATIVE) bot.chat().send("/minecraft:gamemode creative @s[type=player]");
|
||||
else if (selfCares.op() && permissionLevel < 2) bot.chat().send("/minecraft:op @s[type=player]");
|
||||
else if (selfCares.cspy() && !cspy && bot.kaboom()) bot.chat().send("/commandspy:commandspy on");
|
||||
else if (selfCares.prefix() && !prefix && bot.kaboom()) bot.chat().send("/extras:prefix &8[&eChomeNS Bot&8]");
|
||||
else if (selfCares.username() && !username && bot.kaboom()) bot.chat().send("/extras:username " + bot.username());
|
||||
else if (selfCares.cspy() && !cspy && bot.options().kaboom()) bot.chat().send("/commandspy:commandspy on");
|
||||
else if (selfCares.prefix() && !prefix && bot.options().kaboom()) bot.chat().send("/extras:prefix &8[&eChomeNS Bot&8]");
|
||||
else if (selfCares.username() && !username && bot.options().kaboom()) bot.chat().send("/extras:username " + bot.username());
|
||||
else if (selfCares.icu().enabled() && positionPacketsPerSecond > selfCares.icu().positionPacketsPerSecond()) bot.core().run("essentials:sudo * icu stop");
|
||||
else if (selfCares.vanish() && !vanish && !visibility && bot.hasEssentials()) {
|
||||
if (bot.useChat()) bot.chat().send("/essentials:vanish enable");
|
||||
else if (selfCares.vanish() && !vanish && !visibility && bot.options().hasEssentials()) {
|
||||
if (bot.options().useChat()) bot.chat().send("/essentials:vanish enable");
|
||||
else bot.core().run("essentials:vanish " + bot.username() + " enable");
|
||||
}
|
||||
else if (selfCares.nickname() && !nickname && bot.hasEssentials()) {
|
||||
if (bot.useChat()) bot.chat().send("/essentials:nickname off");
|
||||
else if (selfCares.nickname() && !nickname && bot.options().hasEssentials()) {
|
||||
if (bot.options().useChat()) bot.chat().send("/essentials:nickname off");
|
||||
else bot.core().run("essentials:nickname " + bot.username() + " off");
|
||||
}
|
||||
else if (selfCares.socialspy() && !socialspy && bot.hasEssentials()) {
|
||||
if (bot.useChat()) bot.chat().send("/essentials:socialspy enable");
|
||||
else if (selfCares.socialspy() && !socialspy && bot.options().hasEssentials()) {
|
||||
if (bot.options().useChat()) bot.chat().send("/essentials:socialspy enable");
|
||||
else bot.core().run("essentials:socialspy " + bot.username() + " enable");
|
||||
}
|
||||
else if (selfCares.mute() && muted && bot.hasEssentials()) {
|
||||
if (bot.useChat()) bot.chat().send("/essentials:mute " + bot.username());
|
||||
else if (selfCares.mute() && muted && bot.options().hasEssentials()) {
|
||||
if (bot.options().useChat()) bot.chat().send("/essentials:mute " + bot.username());
|
||||
else bot.core().run("essentials:mute " + bot.username());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class TrustedPlugin extends PlayersPlugin.PlayerListener {
|
||||
final Component component = Component.translatable(
|
||||
"[%s] [%s] %s",
|
||||
Component.text("ChomeNS Bot").color(NamedTextColor.YELLOW),
|
||||
Component.text(this.bot.serverName()).color(NamedTextColor.GRAY),
|
||||
Component.text(this.bot.options().serverName()).color(NamedTextColor.GRAY),
|
||||
message.color(NamedTextColor.WHITE)
|
||||
).color(NamedTextColor.DARK_GRAY);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user