de-lombokify !!!

105 files woah
this takes some time because this is a big project
i didn't make any like `getWhatever` function i just made stuff public because i am too lazy
This commit is contained in:
Chayapak 2023-07-02 09:27:14 +07:00
parent df66e94680
commit 5eadb1c868
105 changed files with 1033 additions and 1014 deletions

View file

@ -6,7 +6,6 @@ plugins {
id 'java' id 'java'
id 'java-library' id 'java-library'
id 'maven-publish' id 'maven-publish'
id 'io.freefair.lombok' version '8.0.1'
id 'com.github.johnrengelman.shadow' version '8.1.1' id 'com.github.johnrengelman.shadow' version '8.1.1'
} }

View file

@ -11,8 +11,6 @@ import com.github.steveice10.packetlib.tcp.TcpClientSession;
import land.chipmunk.chayapak.chomens_bot.plugins.*; import land.chipmunk.chayapak.chomens_bot.plugins.*;
import land.chipmunk.chayapak.chomens_bot.util.ComponentUtilities; import land.chipmunk.chayapak.chomens_bot.util.ComponentUtilities;
import land.chipmunk.chayapak.chomens_bot.util.RandomStringUtilities; import land.chipmunk.chayapak.chomens_bot.util.RandomStringUtilities;
import lombok.Getter;
import lombok.Setter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -23,56 +21,56 @@ import java.util.concurrent.TimeUnit;
public class Bot { public class Bot {
private final ArrayList<Listener> listeners = new ArrayList<>(); private final ArrayList<Listener> listeners = new ArrayList<>();
@Getter private final String host; public final String host;
@Getter private final int port; public final int port;
@Getter private final Configuration.BotOption options; public final Configuration.BotOption options;
@Getter private final Configuration config; public final Configuration config;
@Getter private List<Bot> bots; public final List<Bot> bots;
@Getter private String username; public String username;
@Getter private GameProfile profile; public GameProfile profile;
@Getter public Session session; public Session session;
@Getter private boolean loggedIn = false; public boolean loggedIn = false;
@Getter private final ExecutorService executorService = Main.executorService; public final ExecutorService executorService = Main.executorService;
@Getter private final ScheduledExecutorService executor = Main.executor; public final ScheduledExecutorService executor = Main.executor;
@Getter @Setter private ConsolePlugin console; public ConsolePlugin console;
@Getter @Setter private LoggerPlugin logger; // in ConsolePlugin public LoggerPlugin logger; // in ConsolePlugin
@Getter @Setter private DiscordPlugin discord; // same for this one too public DiscordPlugin discord; // same for this one too
@Getter private TickPlugin tick; public TickPlugin tick;
@Getter private ChatPlugin chat; public ChatPlugin chat;
@Getter private PositionPlugin position; public PositionPlugin position;
@Getter private SelfCarePlugin selfCare; public SelfCarePlugin selfCare;
@Getter private CorePlugin core; public CorePlugin core;
@Getter private TeamPlugin team; public TeamPlugin team;
@Getter private PlayersPlugin players; public PlayersPlugin players;
@Getter private TabCompletePlugin tabComplete; public TabCompletePlugin tabComplete;
@Getter private CommandHandlerPlugin commandHandler; public CommandHandlerPlugin commandHandler;
@Getter private ChatCommandHandlerPlugin chatCommandHandler; public ChatCommandHandlerPlugin chatCommandHandler;
@Getter private HashingPlugin hashing; public HashingPlugin hashing;
@Getter private BossbarManagerPlugin bossbar; public BossbarManagerPlugin bossbar;
@Getter private MusicPlayerPlugin music; public MusicPlayerPlugin music;
@Getter private TPSPlugin tps; public TPSPlugin tps;
@Getter private EvalPlugin eval; public EvalPlugin eval;
@Getter private TrustedPlugin trusted; public TrustedPlugin trusted;
@Getter private BruhifyPlugin bruhify; public BruhifyPlugin bruhify;
@Getter private GrepLogPlugin grepLog; public GrepLogPlugin grepLog;
@Getter private CloopPlugin cloop; public CloopPlugin cloop;
@Getter private MazePlugin maze; public MazePlugin maze;
@Getter private ExploitsPlugin exploits; public ExploitsPlugin exploits;
@Getter private FilterPlugin filter; public FilterPlugin filter;
@Getter private CommandSuggestionPlugin commandSuggestion; public CommandSuggestionPlugin commandSuggestion;
@Getter private MailPlugin mail; public MailPlugin mail;
@Getter private PacketSnifferPlugin packetSniffer; public PacketSnifferPlugin packetSniffer;
@Getter private VoiceChatPlugin voiceChat; public VoiceChatPlugin voiceChat;
public Bot (Configuration.BotOption botOption, List<Bot> bots, Configuration config) { public Bot (Configuration.BotOption botOption, List<Bot> bots, Configuration config) {
this.host = botOption.host; this.host = botOption.host;
@ -132,7 +130,7 @@ public class Bot {
listener.connecting(); listener.connecting();
} }
final String _username = options.username(); final String _username = options.username;
if (_username == null) username = RandomStringUtilities.generate(8); if (_username == null) username = RandomStringUtilities.generate(8);
else username = _username; else username = _username;
@ -195,7 +193,7 @@ public class Bot {
public void disconnected(DisconnectedEvent disconnectedEvent) { public void disconnected(DisconnectedEvent disconnectedEvent) {
loggedIn = false; loggedIn = false;
int reconnectDelay = options.reconnectDelay(); int reconnectDelay = options.reconnectDelay;
final String stringMessage = ComponentUtilities.stringify(disconnectedEvent.getReason()); final String stringMessage = ComponentUtilities.stringify(disconnectedEvent.getReason());

View file

@ -1,138 +1,135 @@
package land.chipmunk.chayapak.chomens_bot; package land.chipmunk.chayapak.chomens_bot;
import lombok.Getter;
import lombok.Setter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public class Configuration { public class Configuration {
@Getter public List<String> prefixes; public List<String> prefixes;
@Getter public List<String> commandSpyPrefixes; public List<String> commandSpyPrefixes;
@Getter public ConsolePrefixes consolePrefixes = new ConsolePrefixes(); public ConsolePrefixes consolePrefixes = new ConsolePrefixes();
@Getter public Keys keys = new Keys(); public Keys keys = new Keys();
@Getter public String weatherApiKey; public String weatherApiKey;
@Getter public Core core = new Core(); public Core core = new Core();
@Getter public Discord discord = new Discord(); public Discord discord = new Discord();
@Getter public ColorPalette colorPalette = new ColorPalette(); public ColorPalette colorPalette = new ColorPalette();
@Getter public String ownerName = "chayapak"; // mabe mabe public String ownerName = "chayapak"; // mabe mabe
@Getter public List<String> trusted = new ArrayList<>(); public List<String> trusted = new ArrayList<>();
@Getter public SelfCare selfCare = new SelfCare(); public SelfCare selfCare = new SelfCare();
@Getter public Eval eval = new Eval(); public Eval eval = new Eval();
@Getter public BotOption[] bots = new BotOption[]{}; public BotOption[] bots = new BotOption[]{};
public static class ConsolePrefixes { public static class ConsolePrefixes {
@Getter public String normalCommandsPrefix; public String normalCommandsPrefix;
@Getter public String consoleServerPrefix; public String consoleServerPrefix;
} }
public static class Keys { public static class Keys {
@Getter public String normalKey; public String normalKey;
@Getter public String ownerKey; public String ownerKey;
} }
public static class Core { public static class Core {
@Getter public Position start = new Position(); public Position start = new Position();
@Getter public Position end = new Position(); public Position end = new Position();
@Getter public int refillInterval = (60 * 5) * 1000; // 5 minutes public int refillInterval = (60 * 5) * 1000; // 5 minutes
@Getter public String customName = "{\"text\":\"@\"}"; public String customName = "{\"text\":\"@\"}";
} }
public static class Position { public static class Position {
@Getter public int x = 0; public int x = 0;
@Getter public int y = 0; public int y = 0;
@Getter public int z = 0; public int z = 0;
} }
public static class ColorPalette { public static class ColorPalette {
@Getter public String primary = "yellow"; public String primary = "yellow";
@Getter public String secondary = "gold"; public String secondary = "gold";
@Getter public String defaultColor = "white"; public String defaultColor = "white";
@Getter public String username = "gold"; public String username = "gold";
@Getter public String uuid = "aqua"; public String uuid = "aqua";
@Getter public String string = "aqua"; public String string = "aqua";
@Getter public String number = "gold"; public String number = "gold";
@Getter public String ownerName = "green"; public String ownerName = "green";
} }
public static class Discord { public static class Discord {
@Getter public boolean enabled = true; public boolean enabled = true;
@Getter public String prefix = "default!"; public String prefix = "default!";
@Getter public String token; public String token;
@Getter public Map<String, String> servers = new HashMap<>(); public Map<String, String> servers = new HashMap<>();
@Getter public EmbedColors embedColors = new EmbedColors(); public EmbedColors embedColors = new EmbedColors();
@Getter public String trustedRoleName = "Trusted"; public String trustedRoleName = "Trusted";
@Getter public String adminRoleName = "Admin"; public String adminRoleName = "Admin";
@Getter public String statusMessage = "Gay Sex"; public String statusMessage = "Gay Sex";
@Getter public String inviteLink = "https://discord.gg/xdgCkUyaA4"; public String inviteLink = "https://discord.gg/xdgCkUyaA4";
} }
public static class EmbedColors { public static class EmbedColors {
@Getter public String normal = "#FFFF00"; public String normal = "#FFFF00";
@Getter public String error = "#FF0000"; public String error = "#FF0000";
} }
public static class SelfCare { public static class SelfCare {
@Getter public boolean op = true; public boolean op = true;
@Getter public boolean gamemode = true; public boolean gamemode = true;
@Getter public boolean endCredits = true; public boolean endCredits = true;
@Getter public boolean vanish = true; public boolean vanish = true;
@Getter public boolean nickname = true; public boolean nickname = true;
@Getter public boolean socialspy = true; public boolean socialspy = true;
@Getter public boolean mute = true; public boolean mute = true;
@Getter public boolean cspy = true; public boolean cspy = true;
@Getter public Icu icu = new Icu(); public Icu icu = new Icu();
public static class Icu { public static class Icu {
@Getter public boolean enabled = true; public boolean enabled = true;
@Getter public int positionPacketsPerSecond = 10; public int positionPacketsPerSecond = 10;
} }
@Getter public Prefix prefix = new Prefix(); public Prefix prefix = new Prefix();
public static class Prefix { public static class Prefix {
@Getter public boolean enabled = true; public boolean enabled = true;
@Getter public String prefix = "&8[&eChomeNS Bot&8]"; public String prefix = "&8[&eChomeNS Bot&8]";
} }
@Getter public boolean username = true; public boolean username = true;
} }
public static class Eval { public static class Eval {
@Getter public String address = "ws://localhost:3069"; public String address = "ws://localhost:3069";
} }
public static class BotOption { public static class BotOption {
@Getter public String host; public String host;
@Getter public int port; public int port;
@Getter public String username; public String username;
@Getter public boolean kaboom = false; public boolean kaboom = false;
@Getter public boolean creayun = false; public boolean creayun = false;
@Getter public String serverName; public String serverName;
@Getter @Setter public boolean useCore = true; public boolean useCore = true;
@Getter @Setter public boolean useChat = false; public boolean useChat = false;
@Getter public boolean hasEssentials = true; public boolean hasEssentials = true;
@Getter public int reconnectDelay = 2000; public int reconnectDelay = 2000;
@Getter public boolean removeNamespaces = false; public boolean removeNamespaces = false;
@Getter public int chatQueueDelay = 125; public int chatQueueDelay = 125;
@Getter public CoreRateLimit coreRateLimit = new CoreRateLimit(); public CoreRateLimit coreRateLimit = new CoreRateLimit();
public static class CoreRateLimit { public static class CoreRateLimit {
@Getter public int limit = 0; public int limit = 0;
@Getter public int reset = 0; public int reset = 0;
} }
} }
} }

View file

@ -57,12 +57,12 @@ public class Main {
final Configuration config = _config; final Configuration config = _config;
Configuration.BotOption[] botsOptions = config.bots(); Configuration.BotOption[] botsOptions = config.bots;
// idk if these should be here lol, but it is just the discord stuff // idk if these should be here lol, but it is just the discord stuff
JDA jda = null; JDA jda = null;
if (config.discord().enabled()) { if (config.discord.enabled) {
JDABuilder builder = JDABuilder.createDefault(config.discord().token()); JDABuilder builder = JDABuilder.createDefault(config.discord.token);
try { try {
jda = builder.build(); jda = builder.build();
jda.awaitReady(); jda.awaitReady();
@ -73,7 +73,7 @@ public class Main {
} catch (InterruptedException ignored) { } catch (InterruptedException ignored) {
System.exit(1); System.exit(1);
} }
jda.getPresence().setPresence(Activity.playing(config.discord().statusMessage()), false); jda.getPresence().setPresence(Activity.playing(config.discord.statusMessage), false);
} }
for (Configuration.BotOption botOption : botsOptions) { for (Configuration.BotOption botOption : botsOptions) {

View file

@ -29,7 +29,7 @@ public class CreayunChatParser implements ChatParser {
public PlayerMessage parse (Component message) { public PlayerMessage parse (Component message) {
final String stringified = ComponentUtilities.stringify(message); final String stringified = ComponentUtilities.stringify(message);
if (bot.options().creayun()) return null; if (bot.options.creayun) return null;
final Matcher matcher = PATTERN.matcher(stringified); final Matcher matcher = PATTERN.matcher(stringified);
@ -37,7 +37,7 @@ public class CreayunChatParser implements ChatParser {
final String displayName = matcher.group(1); final String displayName = matcher.group(1);
final String contents = matcher.group(2); final String contents = matcher.group(2);
MutablePlayerListEntry sender = bot.players().getEntry(displayName); MutablePlayerListEntry sender = bot.players.getEntry(displayName);
if (sender == null) sender = new MutablePlayerListEntry(new GameProfile(new UUID(0L, 0L), displayName), GameMode.SURVIVAL, 0, Component.text(displayName), 0L, null, new byte[0], true); if (sender == null) sender = new MutablePlayerListEntry(new GameProfile(new UUID(0L, 0L), displayName), GameMode.SURVIVAL, 0, Component.text(displayName), 0L, null, new byte[0], true);
return new PlayerMessage(sender, Component.text(displayName), Component.text(contents)); return new PlayerMessage(sender, Component.text(displayName), Component.text(contents));

View file

@ -43,8 +43,8 @@ public class KaboomChatParser implements ChatParser {
return null; return null;
} }
MutablePlayerListEntry sender = bot.players().getEntry(Component.empty().append(prefix).append(displayName)); MutablePlayerListEntry sender = bot.players.getEntry(Component.empty().append(prefix).append(displayName));
if (sender == null) sender = bot.players().getEntry(prefix.append(displayName)); // old if (sender == null) sender = bot.players.getEntry(prefix.append(displayName)); // old
if (sender == null) sender = new MutablePlayerListEntry(new GameProfile(new UUID(0L, 0L), null), GameMode.SURVIVAL, 0, displayName, 0L, null, new byte[0], true); // new and currently using if (sender == null) sender = new MutablePlayerListEntry(new GameProfile(new UUID(0L, 0L), null), GameMode.SURVIVAL, 0, displayName, 0L, null, new byte[0], true); // new and currently using
return new PlayerMessage(sender, displayName, contents); return new PlayerMessage(sender, displayName, contents);

View file

@ -47,10 +47,10 @@ public class MinecraftChatParser implements ChatParser {
if (hoverEvent != null && hoverEvent.action().equals(HoverEvent.Action.SHOW_ENTITY)) { if (hoverEvent != null && hoverEvent.action().equals(HoverEvent.Action.SHOW_ENTITY)) {
HoverEvent.ShowEntity entityInfo = (HoverEvent.ShowEntity) hoverEvent.value(); HoverEvent.ShowEntity entityInfo = (HoverEvent.ShowEntity) hoverEvent.value();
final UUID senderUUID = entityInfo.id(); final UUID senderUUID = entityInfo.id();
sender = bot.players().getEntry(senderUUID); sender = bot.players.getEntry(senderUUID);
} else { } else {
final String stringUsername = ComponentUtilities.stringify(senderComponent); final String stringUsername = ComponentUtilities.stringify(senderComponent);
sender = bot.players().getEntry(stringUsername); sender = bot.players.getEntry(stringUsername);
} }
if (sender == null) return null; if (sender == null) return null;

View file

@ -39,10 +39,10 @@ public class U203aChatParser implements ChatParser {
if (hoverEvent != null && hoverEvent.action().equals(HoverEvent.Action.SHOW_ENTITY)) { if (hoverEvent != null && hoverEvent.action().equals(HoverEvent.Action.SHOW_ENTITY)) {
HoverEvent.ShowEntity entityInfo = (HoverEvent.ShowEntity) hoverEvent.value(); HoverEvent.ShowEntity entityInfo = (HoverEvent.ShowEntity) hoverEvent.value();
final UUID senderUUID = entityInfo.id(); final UUID senderUUID = entityInfo.id();
sender = bot.players().getEntry(senderUUID); sender = bot.players.getEntry(senderUUID);
} else { } else {
final String stringUsername = ComponentUtilities.stringify(senderComponent); final String stringUsername = ComponentUtilities.stringify(senderComponent);
sender = bot.players().getEntry(stringUsername); sender = bot.players.getEntry(stringUsername);
} }
if (sender == null) return null; if (sender == null) return null;

View file

@ -40,7 +40,7 @@ public class CommandSpyParser implements ChatParser {
final Component command = children.get(1); final Component command = children.get(1);
final String stringUsername = ComponentUtilities.stringify(username); final String stringUsername = ComponentUtilities.stringify(username);
MutablePlayerListEntry sender = bot.players().getEntry(stringUsername); MutablePlayerListEntry sender = bot.players.getEntry(stringUsername);
if (sender == null) return null; if (sender == null) return null;

View file

@ -1,14 +1,13 @@
package land.chipmunk.chayapak.chomens_bot.command; package land.chipmunk.chayapak.chomens_bot.command;
import lombok.Getter;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
public abstract class Command { public abstract class Command {
@Getter private final String name; public final String name;
@Getter private final String description; public final String description;
@Getter private final String[] usages; public final String[] usages;
@Getter private final String[] aliases; public final String[] aliases;
@Getter private final TrustLevel trustLevel; public final TrustLevel trustLevel;
public Command ( public Command (
String name, String name,

View file

@ -2,20 +2,19 @@ package land.chipmunk.chayapak.chomens_bot.command;
import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.Bot;
import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry; import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry;
import lombok.Getter;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
public class CommandContext { public class CommandContext {
@Getter private final Bot bot; public final Bot bot;
@Getter private final String prefix; public final String prefix;
@Getter private final MutablePlayerListEntry sender; public final MutablePlayerListEntry sender;
@Getter private final String hash; public final String hash;
@Getter private final String ownerHash; public final String ownerHash;
@Getter private final boolean inGame; public final boolean inGame;
public CommandContext(Bot bot, String prefix, MutablePlayerListEntry sender, String hash, String ownerHash, boolean inGame) { public CommandContext(Bot bot, String prefix, MutablePlayerListEntry sender, String hash, String ownerHash, boolean inGame) {
this.bot = bot; this.bot = bot;

View file

@ -9,18 +9,18 @@ public class ConsoleCommandContext extends CommandContext {
private final Bot bot; private final Bot bot;
public ConsoleCommandContext (Bot bot, String prefix) { public ConsoleCommandContext (Bot bot, String prefix) {
super(bot, prefix, bot.players().getBotEntry() /* real */, null, null, false); super(bot, prefix, bot.players.getBotEntry() /* real */, null, null, false);
this.bot = bot; this.bot = bot;
} }
@Override @Override
public void sendOutput (Component component) { public void sendOutput (Component component) {
final String message = ComponentUtilities.stringifyAnsi(component); final String message = ComponentUtilities.stringifyAnsi(component);
bot.logger().info(message); bot.logger.info(message);
} }
@Override @Override
public Component displayName () { public Component displayName () {
return sender().displayName().color(NamedTextColor.YELLOW); return sender.displayName.color(NamedTextColor.YELLOW);
} }
} }

View file

@ -49,7 +49,7 @@ public class DiscordCommandContext extends CommandContext {
final String output = ComponentUtilities.stringifyAnsi(component); final String output = ComponentUtilities.stringifyAnsi(component);
final EmbedBuilder builder = new EmbedBuilder(); final EmbedBuilder builder = new EmbedBuilder();
builder.setTitle("Output"); builder.setTitle("Output");
builder.setColor(Color.decode(bot.config().discord().embedColors().normal())); builder.setColor(Color.decode(bot.config.discord.embedColors.normal));
builder.setDescription("```ansi\n" + CodeBlockUtilities.escape(output.replace("\u001b[9", "\u001b[3")) + "\n```"); builder.setDescription("```ansi\n" + CodeBlockUtilities.escape(output.replace("\u001b[9", "\u001b[3")) + "\n```");
final MessageEmbed embed = builder.build(); final MessageEmbed embed = builder.build();

View file

@ -1,14 +1,13 @@
package land.chipmunk.chayapak.chomens_bot.command; package land.chipmunk.chayapak.chomens_bot.command;
import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry; import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry;
import lombok.Getter;
import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.Bot;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
public class PlayerCommandContext extends CommandContext { public class PlayerCommandContext extends CommandContext {
@Getter private final String playerName; public final String playerName;
@Getter private final String selector; public final String selector;
private final Bot bot; private final Bot bot;
@ -21,11 +20,11 @@ public class PlayerCommandContext extends CommandContext {
@Override @Override
public void sendOutput (Component message) { public void sendOutput (Component message) {
bot.chat().tellraw(message, selector); bot.chat.tellraw(message, selector);
} }
@Override @Override
public Component displayName () { public Component displayName () {
return sender().displayName(); return sender.displayName;
} }
} }

View file

@ -23,10 +23,10 @@ public class BotUserCommand extends Command {
@Override @Override
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot;
final String username = bot.username(); final String username = bot.username;
final String uuid = bot.profile().getIdAsString(); final String uuid = bot.profile.getIdAsString();
return Component.translatable( return Component.translatable(
"The bot's username is: %s and the UUID is: %s", "The bot's username is: %s and the UUID is: %s",
@ -42,7 +42,7 @@ public class BotUserCommand extends Command {
.clickEvent( .clickEvent(
ClickEvent.copyToClipboard(username) ClickEvent.copyToClipboard(username)
) )
.color(ColorUtilities.getColorByString(bot.config().colorPalette().username())), .color(ColorUtilities.getColorByString(bot.config.colorPalette.username)),
Component Component
.text(uuid) .text(uuid)
.hoverEvent( .hoverEvent(
@ -55,7 +55,7 @@ public class BotUserCommand extends Command {
.clickEvent( .clickEvent(
ClickEvent.copyToClipboard(uuid) ClickEvent.copyToClipboard(uuid)
) )
.color(ColorUtilities.getColorByString(bot.config().colorPalette().uuid())) .color(ColorUtilities.getColorByString(bot.config.colorPalette.uuid))
).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
} }
} }

View file

@ -21,36 +21,36 @@ public class BotVisibilityCommand extends Command {
@Override @Override
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot;
if (args.length == 0) { if (args.length == 0) {
final boolean visibility = bot.selfCare().visibility(); final boolean visibility = bot.selfCare.visibility;
bot.selfCare().visibility(!visibility); bot.selfCare.visibility = !visibility;
final NamedTextColor greenOrGold = bot.selfCare().visibility() ? NamedTextColor.GREEN : NamedTextColor.GOLD; final NamedTextColor greenOrGold = bot.selfCare.visibility ? NamedTextColor.GREEN : NamedTextColor.GOLD;
final String visibleOrInvisible = bot.selfCare().visibility() ? "visible" : "invisible"; final String visibleOrInvisible = bot.selfCare.visibility ? "visible" : "invisible";
final String disableOrEnable = bot.selfCare().visibility() ? "disable" : "enable"; final String disableOrEnable = bot.selfCare.visibility ? "disable" : "enable";
bot.chat().send("/essentials:vanish " + disableOrEnable); bot.chat.send("/essentials:vanish " + disableOrEnable);
return Component.empty() return Component.empty()
.append(Component.text("The bot's visibility is now ")) .append(Component.text("The bot's visibility is now "))
.append(Component.text(visibleOrInvisible).color(greenOrGold)); .append(Component.text(visibleOrInvisible).color(greenOrGold));
} else { } else {
switch (args[0]) { switch (args[0]) {
case "on", "true" -> { case "on", "true" -> {
bot.selfCare().visibility(true); bot.selfCare.visibility = true;
bot.chat().send("/essentials:vanish disable"); bot.chat.send("/essentials:vanish disable");
return Component.empty() return Component.empty()
.append(Component.text("The bot's visibility is now ")) .append(Component.text("The bot's visibility is now "))
.append(Component.text("visible").color(NamedTextColor.GREEN)) .append(Component.text("visible").color(NamedTextColor.GREEN))
.color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
} }
case "off", "false" -> { case "off", "false" -> {
bot.selfCare().visibility(false); bot.selfCare.visibility = false;
bot.chat().send("/essentials:vanish enable"); bot.chat.send("/essentials:vanish enable");
return Component.empty() return Component.empty()
.append(Component.text("The bot's visibility is now ")) .append(Component.text("The bot's visibility is now "))
.append(Component.text("invisible").color(NamedTextColor.GOLD)) .append(Component.text("invisible").color(NamedTextColor.GOLD))
.color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
} }
default -> { default -> {
return Component.text("Invalid argument").color(NamedTextColor.RED); return Component.text("Invalid argument").color(NamedTextColor.RED);

View file

@ -22,12 +22,12 @@ public class BruhifyCommand extends Command {
@Override @Override
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot;
if (args.length == 0) { if (args.length == 0) {
bot.bruhify().bruhifyText(""); bot.bruhify.bruhifyText = "";
} else { } else {
bot.bruhify().bruhifyText(String.join(" ", args)); bot.bruhify.bruhifyText = String.join(" ", args);
} }
return null; return null;

View file

@ -25,16 +25,16 @@ public class ClearChatCommand extends Command {
@Override @Override
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot;
if (args.length > 0) { if (args.length > 0) {
final MutablePlayerListEntry entry = bot.players().getEntry(String.join(" ", args)); final MutablePlayerListEntry entry = bot.players.getEntry(String.join(" ", args));
if (entry == null) return Component.text("Invalid player name").color(NamedTextColor.RED); if (entry == null) return Component.text("Invalid player name").color(NamedTextColor.RED);
final UUID uuid = entry.profile().getId(); final UUID uuid = entry.profile.getId();
bot.chat().tellraw( bot.chat.tellraw(
Component.empty() Component.empty()
.append(Component.text("\n".repeat(1000))) .append(Component.text("\n".repeat(1000)))
.append( .append(
@ -46,7 +46,7 @@ public class ClearChatCommand extends Command {
uuid uuid
); );
} else { } else {
bot.chat().tellraw( bot.chat.tellraw(
Component.empty() Component.empty()
.append(Component.text("\n".repeat(1000))) .append(Component.text("\n".repeat(1000)))
.append(Component.text("The chat has been cleared").color(NamedTextColor.DARK_GREEN)) .append(Component.text("The chat has been cleared").color(NamedTextColor.DARK_GREEN))

View file

@ -46,9 +46,9 @@ public class ClearChatQueueCommand extends Command {
@Override @Override
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot;
bot.chat().clearQueue(); bot.chat.clearQueue();
return null; return null;
} }

View file

@ -27,7 +27,7 @@ public class CloopCommand extends Command {
@Override @Override
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot;
switch (args[0]) { switch (args[0]) {
case "add" -> { case "add" -> {
@ -42,42 +42,42 @@ public class CloopCommand extends Command {
final String command = String.join(" ", Arrays.copyOfRange(args, 2, args.length)); final String command = String.join(" ", Arrays.copyOfRange(args, 2, args.length));
bot.cloop().add(interval, command); bot.cloop.add(interval, command);
return Component.translatable( return Component.translatable(
"Added %s with interval %s to the cloops", "Added %s with interval %s to the cloops",
Component.text(command).color(ColorUtilities.getColorByString(bot.config().colorPalette().string())), Component.text(command).color(ColorUtilities.getColorByString(bot.config.colorPalette.string)),
Component.text(interval).color(ColorUtilities.getColorByString(bot.config().colorPalette().number())) Component.text(interval).color(ColorUtilities.getColorByString(bot.config.colorPalette.number))
).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
} }
case "remove" -> { case "remove" -> {
try { try {
final int index = Integer.parseInt(args[1]); final int index = Integer.parseInt(args[1]);
bot.cloop().remove(index); bot.cloop.remove(index);
return Component.translatable( return Component.translatable(
"Removed cloop %s", "Removed cloop %s",
Component.text(index).color(ColorUtilities.getColorByString(bot.config().colorPalette().number())) Component.text(index).color(ColorUtilities.getColorByString(bot.config.colorPalette.number))
).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
} catch (IndexOutOfBoundsException | IllegalArgumentException | NullPointerException ignored) { } catch (IndexOutOfBoundsException | IllegalArgumentException | NullPointerException ignored) {
return Component.text("Invalid index").color(NamedTextColor.RED); return Component.text("Invalid index").color(NamedTextColor.RED);
} }
} }
case "clear" -> { case "clear" -> {
bot.cloop().clear(); bot.cloop.clear();
return Component.text("Cleared all cloops").color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); return Component.text("Cleared all cloops").color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
} }
case "list" -> { case "list" -> {
final List<Component> cloopsComponent = new ArrayList<>(); final List<Component> cloopsComponent = new ArrayList<>();
int index = 0; int index = 0;
for (CommandLoop command : bot.cloop().loops()) { for (CommandLoop command : bot.cloop.loops) {
cloopsComponent.add( cloopsComponent.add(
Component.translatable( Component.translatable(
"%s %s (%s)", "%s %s (%s)",
Component.text(index).color(ColorUtilities.getColorByString(bot.config().colorPalette().number())), Component.text(index).color(ColorUtilities.getColorByString(bot.config.colorPalette.number)),
Component.text(command.command()).color(ColorUtilities.getColorByString(bot.config().colorPalette().string())), Component.text(command.command()).color(ColorUtilities.getColorByString(bot.config.colorPalette.string)),
Component.text(command.interval()).color(ColorUtilities.getColorByString(bot.config().colorPalette().number())) Component.text(command.interval()).color(ColorUtilities.getColorByString(bot.config.colorPalette.number))
).color(NamedTextColor.DARK_GRAY) ).color(NamedTextColor.DARK_GRAY)
); );
index++; index++;
@ -86,7 +86,7 @@ public class CloopCommand extends Command {
return Component.empty() return Component.empty()
.append(Component.text("Cloops ").color(NamedTextColor.GREEN)) .append(Component.text("Cloops ").color(NamedTextColor.GREEN))
.append(Component.text("(").color(NamedTextColor.DARK_GRAY)) .append(Component.text("(").color(NamedTextColor.DARK_GRAY))
.append(Component.text(bot.cloop().loops().size()).color(NamedTextColor.GRAY)) .append(Component.text(bot.cloop.loops.size()).color(NamedTextColor.GRAY))
.append(Component.text(")").color(NamedTextColor.DARK_GRAY)) .append(Component.text(")").color(NamedTextColor.DARK_GRAY))
.append(Component.newline()) .append(Component.newline())
.append( .append(

View file

@ -26,9 +26,9 @@ public class CommandBlockCommand extends Command {
@Override @Override
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot;
final CompletableFuture<CompoundTag> future = bot.core().runTracked(String.join(" ", args)); final CompletableFuture<CompoundTag> future = bot.core.runTracked(String.join(" ", args));
if (future == null) return null; if (future == null) return null;

View file

@ -23,11 +23,11 @@ public class CreatorCommand extends Command {
@Override @Override
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot;
return Component.empty() return Component.empty()
.append(Component.text("ChomeNS Bot ").color(ColorUtilities.getColorByString(bot.config().colorPalette().primary()))) .append(Component.text("ChomeNS Bot ").color(ColorUtilities.getColorByString(bot.config.colorPalette.primary)))
.append(Component.text("is created by ").color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor()))) .append(Component.text("is created by ").color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)))
.append(Component.text("chayapak").color(ColorUtilities.getColorByString(bot.config().colorPalette().ownerName()))); .append(Component.text("chayapak").color(ColorUtilities.getColorByString(bot.config.colorPalette.ownerName)));
} }
} }

View file

@ -22,11 +22,11 @@ public class DiscordCommand extends Command {
@Override @Override
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot;
final String link = bot.config().discord().inviteLink(); final String link = bot.config.discord.inviteLink;
return Component.empty() return Component.empty()
.append(Component.text("The Discord invite is ").color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor()))) .append(Component.text("The Discord invite is ").color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)))
.append( .append(
Component Component
.text(link) .text(link)

View file

@ -19,9 +19,9 @@ public class EchoCommand extends Command {
@Override @Override
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot;
bot.chat().send(String.join(" ", args)); bot.chat.send(String.join(" ", args));
return null; return null;
} }

View file

@ -19,9 +19,9 @@ public class EndCommand extends Command {
@Override @Override
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot;
bot.session().disconnect("End command"); bot.session.disconnect("End command");
return null; return null;
} }

View file

@ -27,15 +27,15 @@ public class EvalCommand extends Command {
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
if (args.length < 1) return Component.text("Not enough arguments").color(NamedTextColor.RED); if (args.length < 1) return Component.text("Not enough arguments").color(NamedTextColor.RED);
final Bot bot = context.bot(); final Bot bot = context.bot;
if (!bot.eval().connected()) return Component.text("Eval server is not online").color(NamedTextColor.RED); if (!bot.eval.connected) return Component.text("Eval server is not online").color(NamedTextColor.RED);
switch (args[0]) { switch (args[0]) {
case "run" -> { case "run" -> {
final String command = String.join(" ", Arrays.copyOfRange(args, 1, args.length)); final String command = String.join(" ", Arrays.copyOfRange(args, 1, args.length));
final CompletableFuture<EvalOutput> future = bot.eval().run(command); final CompletableFuture<EvalOutput> future = bot.eval.run(command);
future.thenApply((output) -> { future.thenApply((output) -> {
if (output.isError()) context.sendOutput(Component.text(output.output()).color(NamedTextColor.RED)); if (output.isError()) context.sendOutput(Component.text(output.output()).color(NamedTextColor.RED));
@ -45,9 +45,9 @@ public class EvalCommand extends Command {
}); });
} }
case "reset" -> { case "reset" -> {
bot.eval().reset(); bot.eval.reset();
return Component.text("Reset the eval context").color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); return Component.text("Reset the eval context").color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
} }
default -> { default -> {
return Component.text("Invalid argument").color(NamedTextColor.RED); return Component.text("Invalid argument").color(NamedTextColor.RED);

View file

@ -38,7 +38,7 @@ public class FilterCommand extends Command {
// most of these codes are from cloop and greplog // most of these codes are from cloop and greplog
public Component execute(CommandContext context, String[] _args, String[] fullArgs) { public Component execute(CommandContext context, String[] _args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot;
boolean ignoreCase = false; boolean ignoreCase = false;
boolean regex = false; boolean regex = false;
@ -68,42 +68,42 @@ public class FilterCommand extends Command {
case "add" -> { case "add" -> {
final String player = String.join(" ", Arrays.copyOfRange(args, 1, args.length)); final String player = String.join(" ", Arrays.copyOfRange(args, 1, args.length));
bot.filter().add(player, regex, ignoreCase); bot.filter.add(player, regex, ignoreCase);
return Component.translatable( return Component.translatable(
"Added %s to the filters", "Added %s to the filters",
Component.text(player).color(ColorUtilities.getColorByString(bot.config().colorPalette().username())) Component.text(player).color(ColorUtilities.getColorByString(bot.config.colorPalette.username))
).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
} }
case "remove" -> { case "remove" -> {
try { try {
final int index = Integer.parseInt(args[1]); final int index = Integer.parseInt(args[1]);
final FilteredPlayer removed = bot.filter().remove(index); final FilteredPlayer removed = bot.filter.remove(index);
return Component.translatable( return Component.translatable(
"Removed %s from the filters", "Removed %s from the filters",
Component.text(removed.playerName).color(ColorUtilities.getColorByString(bot.config().colorPalette().username())) Component.text(removed.playerName).color(ColorUtilities.getColorByString(bot.config.colorPalette.username))
).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
} catch (IndexOutOfBoundsException | IllegalArgumentException | NullPointerException ignored) { } catch (IndexOutOfBoundsException | IllegalArgumentException | NullPointerException ignored) {
return Component.text("Invalid index").color(NamedTextColor.RED); return Component.text("Invalid index").color(NamedTextColor.RED);
} }
} }
case "clear" -> { case "clear" -> {
bot.filter().clear(); bot.filter.clear();
return Component.text("Cleared the filter").color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); return Component.text("Cleared the filter").color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
} }
case "list" -> { case "list" -> {
final List<Component> filtersComponents = new ArrayList<>(); final List<Component> filtersComponents = new ArrayList<>();
int index = 0; int index = 0;
for (JsonElement playerElement : FilterPlugin.filteredPlayers()) { for (JsonElement playerElement : FilterPlugin.filteredPlayers) {
final FilteredPlayer player = gson.fromJson(playerElement, FilteredPlayer.class); final FilteredPlayer player = gson.fromJson(playerElement, FilteredPlayer.class);
filtersComponents.add( filtersComponents.add(
Component.translatable( Component.translatable(
"%s %s", "%s %s",
Component.text(index).color(ColorUtilities.getColorByString(bot.config().colorPalette().number())), Component.text(index).color(ColorUtilities.getColorByString(bot.config.colorPalette.number)),
Component.text(player.playerName).color(ColorUtilities.getColorByString(bot.config().colorPalette().username())) Component.text(player.playerName).color(ColorUtilities.getColorByString(bot.config.colorPalette.username))
).color(NamedTextColor.DARK_GRAY) ).color(NamedTextColor.DARK_GRAY)
); );
@ -113,7 +113,7 @@ public class FilterCommand extends Command {
return Component.empty() return Component.empty()
.append(Component.text("Filtered players ").color(NamedTextColor.GREEN)) .append(Component.text("Filtered players ").color(NamedTextColor.GREEN))
.append(Component.text("(").color(NamedTextColor.DARK_GRAY)) .append(Component.text("(").color(NamedTextColor.DARK_GRAY))
.append(Component.text(FilterPlugin.filteredPlayers().size()).color(NamedTextColor.GRAY)) .append(Component.text(FilterPlugin.filteredPlayers.size()).color(NamedTextColor.GRAY))
.append(Component.text(")").color(NamedTextColor.DARK_GRAY)) .append(Component.text(")").color(NamedTextColor.DARK_GRAY))
.append(Component.newline()) .append(Component.newline())
.append( .append(

View file

@ -21,7 +21,7 @@ public class GenerateMazeCommand extends Command {
@Override @Override
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot;
try { try {
final int x = Integer.parseInt(args[0]); final int x = Integer.parseInt(args[0]);
@ -37,7 +37,7 @@ public class GenerateMazeCommand extends Command {
generator.generateMaze(); generator.generateMaze();
bot.maze().generate(generator, x, y, z); bot.maze.generate(generator, x, y, z);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
return Component.text("Invalid position/size").color(NamedTextColor.RED); return Component.text("Invalid position/size").color(NamedTextColor.RED);
} }

View file

@ -28,7 +28,7 @@ public class GrepLogCommand extends Command {
@Override @Override
public Component execute(CommandContext context, String[] _args, String[] fullArgs) { public Component execute(CommandContext context, String[] _args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot;
String[] args = _args; String[] args = _args;
@ -36,13 +36,13 @@ public class GrepLogCommand extends Command {
boolean regex = false; boolean regex = false;
if (_args[0].equals("stop")) { if (_args[0].equals("stop")) {
bot.grepLog().thread().interrupt(); bot.grepLog.thread.interrupt();
bot.grepLog().thread(null); bot.grepLog.thread = null;
return Component.text("Log query stopped"); return Component.text("Log query stopped");
} }
if (bot.grepLog().thread() != null) return Component.text("Another query is already running").color(NamedTextColor.RED); if (bot.grepLog.thread != null) return Component.text("Another query is already running").color(NamedTextColor.RED);
// this is a mess // this is a mess
if (_args[0].equals("-ignorecase")) { if (_args[0].equals("-ignorecase")) {
@ -61,7 +61,7 @@ public class GrepLogCommand extends Command {
args = Arrays.copyOfRange(_args, 2, _args.length); args = Arrays.copyOfRange(_args, 2, _args.length);
} }
bot.grepLog().query(String.join(" ", args), regex, ignoreCase); bot.grepLog.query(String.join(" ", args), regex, ignoreCase);
return null; return null;
} }

View file

@ -32,7 +32,7 @@ public class HelpCommand extends Command {
@Override @Override
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
this.bot = context.bot(); this.bot = context.bot;
this.context = context; this.context = context;
if (args.length == 0) { if (args.length == 0) {
@ -66,10 +66,10 @@ public class HelpCommand extends Command {
List<String> commandNames = new ArrayList<>(); List<String> commandNames = new ArrayList<>();
for (Command command : bot.commandHandler().commands()) { for (Command command : bot.commandHandler.commands) {
if (command.trustLevel() != trustLevel) continue; if (command.trustLevel != trustLevel) continue;
commandNames.add(command.name()); commandNames.add(command.name);
} }
Collections.sort(commandNames); Collections.sort(commandNames);
@ -99,39 +99,39 @@ public class HelpCommand extends Command {
} }
public Component sendUsages (CommandContext context, String[] args) { public Component sendUsages (CommandContext context, String[] args) {
final Bot bot = context.bot(); final Bot bot = context.bot;
final String prefix = context.prefix(); final String prefix = context.prefix;
for (Command command : bot.commandHandler().commands()) { for (Command command : bot.commandHandler.commands) {
if (!command.name().equals(args[0]) && !Arrays.stream(command.aliases()).toList().contains(args[0])) continue; if (!command.name.equals(args[0]) && !Arrays.stream(command.aliases).toList().contains(args[0])) continue;
final String commandName = command.name(); final String commandName = command.name;
final List<Component> usages = new ArrayList<>(); final List<Component> usages = new ArrayList<>();
usages.add( usages.add(
Component.empty() Component.empty()
.append(Component.text(prefix + commandName).color(ColorUtilities.getColorByString(bot.config().colorPalette().secondary()))) .append(Component.text(prefix + commandName).color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary)))
.append(Component.text( .append(Component.text(
(command.aliases().length > 0 && !command.aliases()[0].equals("")) ? (command.aliases.length > 0 && !command.aliases[0].equals("")) ?
" (" + String.join(", ", command.aliases()) + ")" : " (" + String.join(", ", command.aliases) + ")" :
"" ""
)) ))
.append(Component.text(" - " + command.description()).color(NamedTextColor.GRAY)) .append(Component.text(" - " + command.description)).color(NamedTextColor.GRAY)
); );
usages.add( usages.add(
Component.empty() Component.empty()
.append(Component.text("Trust level: ").color(NamedTextColor.GREEN)) .append(Component.text("Trust level: ").color(NamedTextColor.GREEN))
.append(Component.text(command.trustLevel().name()).color(NamedTextColor.YELLOW)) .append(Component.text(command.trustLevel.name()).color(NamedTextColor.YELLOW))
); );
for (String usage : command.usages()) { for (String usage : command.usages) {
usages.add( usages.add(
Component.empty() Component.empty()
.append(Component.text(prefix + commandName).color(ColorUtilities.getColorByString(bot.config().colorPalette().secondary()))) .append(Component.text(prefix + commandName).color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary)))
.append(Component.text(" ")) .append(Component.text(" "))
.append(Component.text(usage).color(ColorUtilities.getColorByString(bot.config().colorPalette().string()))) .append(Component.text(usage).color(ColorUtilities.getColorByString(bot.config.colorPalette.string)))
); );
} }

View file

@ -24,20 +24,20 @@ public class KickCommand extends Command {
@Override @Override
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot;
final MutablePlayerListEntry entry = bot.players().getEntry(String.join(" ", args)); final MutablePlayerListEntry entry = bot.players.getEntry(String.join(" ", args));
if (entry == null) return Component.text("Invalid player name").color(NamedTextColor.RED); if (entry == null) return Component.text("Invalid player name").color(NamedTextColor.RED);
final String name = entry.profile().getName(); final String name = entry.profile.getName();
final UUID uuid = entry.profile().getId(); final UUID uuid = entry.profile.getId();
bot.exploits().kick(uuid); bot.exploits.kick(uuid);
return Component.empty() return Component.empty()
.append(Component.text("Kicking player ")) .append(Component.text("Kicking player "))
.append(Component.text(name).color(ColorUtilities.getColorByString(bot.config().colorPalette().username()))) .append(Component.text(name).color(ColorUtilities.getColorByString(bot.config.colorPalette.username)))
.color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
} }
} }

View file

@ -28,9 +28,9 @@ public class ListCommand extends Command {
@Override @Override
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot;
final List<MutablePlayerListEntry> list = bot.players().list(); final List<MutablePlayerListEntry> list = bot.players.list;
final List<Component> playersComponent = new ArrayList<>(); final List<Component> playersComponent = new ArrayList<>();
@ -38,32 +38,32 @@ public class ListCommand extends Command {
playersComponent.add( playersComponent.add(
Component.translatable( Component.translatable(
"%s %s", "%s %s",
entry.displayName() == null ? entry.displayName == null ?
Component.text(entry.profile().getName()).color(ColorUtilities.getColorByString(bot.config().colorPalette().username())) : Component.text(entry.profile.getName()).color(ColorUtilities.getColorByString(bot.config.colorPalette.username)) :
entry.displayName() entry.displayName
.hoverEvent( .hoverEvent(
HoverEvent.showText( HoverEvent.showText(
Component Component
.text(entry.profile().getName()) .text(entry.profile.getName())
.append(Component.newline()) .append(Component.newline())
.append(Component.text("Click here to copy the username to your clipboard").color(NamedTextColor.GREEN)) .append(Component.text("Click here to copy the username to your clipboard").color(NamedTextColor.GREEN))
) )
) )
.clickEvent( .clickEvent(
ClickEvent.copyToClipboard(entry.profile().getName()) ClickEvent.copyToClipboard(entry.profile.getName())
) )
.color(NamedTextColor.WHITE), .color(NamedTextColor.WHITE),
Component Component
.text(entry.profile().getIdAsString()) .text(entry.profile.getIdAsString())
.hoverEvent( .hoverEvent(
HoverEvent.showText( HoverEvent.showText(
Component.text("Click here to copy the UUID to your clipboard").color(NamedTextColor.GREEN) Component.text("Click here to copy the UUID to your clipboard").color(NamedTextColor.GREEN)
) )
) )
.clickEvent( .clickEvent(
ClickEvent.copyToClipboard(entry.profile().getIdAsString()) ClickEvent.copyToClipboard(entry.profile.getIdAsString())
) )
.color(ColorUtilities.getColorByString(bot.config().colorPalette().uuid())) .color(ColorUtilities.getColorByString(bot.config.colorPalette.uuid))
).color(NamedTextColor.DARK_GRAY) ).color(NamedTextColor.DARK_GRAY)
); );
} }

View file

@ -45,59 +45,62 @@ public class MailCommand extends Command {
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
if (args.length < 1) return Component.text("Not enough arguments").color(NamedTextColor.RED); if (args.length < 1) return Component.text("Not enough arguments").color(NamedTextColor.RED);
final Bot bot = context.bot(); final Bot bot = context.bot;
final MutablePlayerListEntry sender = context.sender(); final MutablePlayerListEntry sender = context.sender;
final Gson gson = new Gson(); final Gson gson = new Gson();
// kinda messy ngl // kinda messy ngl
bot.executorService().submit(() -> { bot.executorService.submit(() -> {
switch (args[0]) { switch (args[0]) {
case "send" -> { case "send" -> {
int senderMailsSentTotal = 0; int senderMailsSentTotal = 0;
for (JsonElement mailElement : MailPlugin.mails()) { for (JsonElement mailElement : MailPlugin.mails) {
final Mail mail = gson.fromJson(mailElement, Mail.class); final Mail mail = gson.fromJson(mailElement, Mail.class);
if (mail.sentBy() == null) continue; if (mail.sentBy == null) continue;
if (!mail.sentBy().equals(sender.profile().getName())) continue; if (!mail.sentBy.equals(sender.profile.getName())) continue;
senderMailsSentTotal++; senderMailsSentTotal++;
} }
if (senderMailsSentTotal > 256) context.sendOutput(Component.text("You are sending too much mails!").color(NamedTextColor.RED)); if (senderMailsSentTotal > 256) context.sendOutput(Component.text("You are sending too much mails!").color(NamedTextColor.RED));
bot.mail().send( bot.mail.send(
new Mail( new Mail(
sender.profile().getName(), sender.profile.getName(),
args[1], args[1],
Instant.now().toEpochMilli(), Instant.now().toEpochMilli(),
bot.host() + ":" + bot.port(), bot.host + ":" + bot.port,
String.join(" ", Arrays.copyOfRange(args, 2, args.length)) String.join(" ", Arrays.copyOfRange(args, 2, args.length))
) )
); );
context.sendOutput(Component.text("Mail sent!").color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor()))); context.sendOutput(Component.text("Mail sent!").color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)));
} }
case "sendselecteditem" -> { case "sendselecteditem" -> {
int senderMailsSentTotal = 0; int senderMailsSentTotal = 0;
for (JsonElement mailElement : MailPlugin.mails()) { for (JsonElement mailElement : MailPlugin.mails) {
final Mail mail = gson.fromJson(mailElement, Mail.class); final Mail mail = gson.fromJson(mailElement, Mail.class);
if (!mail.sentTo().equals(sender.profile().getName())) continue; if (!mail.sentTo.equals(sender.profile.getName())) continue;
senderMailsSentTotal++; senderMailsSentTotal++;
} }
if (senderMailsSentTotal > 256) context.sendOutput(Component.text("You are sending too much mails!").color(NamedTextColor.RED)); if (senderMailsSentTotal > 256) context.sendOutput(Component.text("You are sending too much mails!").color(NamedTextColor.RED));
final CompletableFuture<CompoundTag> future = bot.core().runTracked( final CompletableFuture<CompoundTag> future = bot.core.runTracked(
"minecraft:data get entity " + "minecraft:data get entity " +
UUIDUtilities.selector(sender.profile().getId()) + UUIDUtilities.selector(sender.profile.getId()) +
" SelectedItem.tag.message" " SelectedItem.tag.message"
); );
if (future == null) context.sendOutput(Component.text("There was an error while sending your mail").color(NamedTextColor.RED)); if (future == null) {
context.sendOutput(Component.text("There was an error while sending your mail").color(NamedTextColor.RED));
return;
}
future.thenApply(tags -> { future.thenApply(tags -> {
if (!tags.contains("LastOutput") || !(tags.get("LastOutput") instanceof StringTag)) return tags; if (!tags.contains("LastOutput") || !(tags.get("LastOutput") instanceof StringTag)) return tags;
@ -123,18 +126,18 @@ public class MailCommand extends Command {
return tags; return tags;
} }
bot.mail().send( bot.mail.send(
new Mail( new Mail(
sender.profile().getName(), sender.profile.getName(),
args[1], args[1],
Instant.now().toEpochMilli(), Instant.now().toEpochMilli(),
bot.host() + ":" + bot.port(), bot.host + ":" + bot.port,
value.substring(1).substring(0, value.length() - 2) value.substring(1).substring(0, value.length() - 2)
) )
); );
context.sendOutput( context.sendOutput(
Component.text("Mail sent!").color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())) Component.text("Mail sent!").color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor))
); );
return tags; return tags;
@ -144,10 +147,10 @@ public class MailCommand extends Command {
// TODO: use less for loops? // TODO: use less for loops?
int senderMailSize = 0; int senderMailSize = 0;
for (JsonElement mailElement : MailPlugin.mails()) { for (JsonElement mailElement : MailPlugin.mails) {
final Mail mail = gson.fromJson(mailElement, Mail.class); final Mail mail = gson.fromJson(mailElement, Mail.class);
if (!mail.sentTo().equals(sender.profile().getName())) continue; if (!mail.sentTo.equals(sender.profile.getName())) continue;
senderMailSize++; senderMailSize++;
} }
@ -156,13 +159,13 @@ public class MailCommand extends Command {
final List<Component> mailsComponent = new ArrayList<>(); final List<Component> mailsComponent = new ArrayList<>();
int i = 1; int i = 1;
for (JsonElement mailElement : MailPlugin.mails()) { for (JsonElement mailElement : MailPlugin.mails) {
final Mail mail = gson.fromJson(mailElement, Mail.class); final Mail mail = gson.fromJson(mailElement, Mail.class);
if (!mail.sentTo().equals(sender.profile().getName())) continue; if (!mail.sentTo.equals(sender.profile.getName())) continue;
final DateTimeFormatter formatter = DateTimeFormat.forPattern("MMMM d, YYYY, hh:mm:ss a Z"); final DateTimeFormatter formatter = DateTimeFormat.forPattern("MMMM d, YYYY, hh:mm:ss a Z");
final String formattedTime = formatter.print(mail.timeSent()); final String formattedTime = formatter.print(mail.timeSent);
mailsComponent.add( mailsComponent.add(
Component.translatable( Component.translatable(
@ -170,10 +173,10 @@ public class MailCommand extends Command {
%s %s Sent by: %s %s %s %s Sent by: %s %s
Contents: Contents:
%s""", %s""",
Component.text(i).color(ColorUtilities.getColorByString(bot.config().colorPalette().number())), Component.text(i).color(ColorUtilities.getColorByString(bot.config.colorPalette.number)),
Component.text("-").color(NamedTextColor.DARK_GRAY), Component.text("-").color(NamedTextColor.DARK_GRAY),
Component.text(mail.sentBy()).color(ColorUtilities.getColorByString(bot.config().colorPalette().username())), Component.text(mail.sentBy).color(ColorUtilities.getColorByString(bot.config.colorPalette.username)),
Component Component
.text("[Hover here for more info]") .text("[Hover here for more info]")
.color(NamedTextColor.GREEN) .color(NamedTextColor.GREEN)
@ -183,12 +186,12 @@ public class MailCommand extends Command {
""" """
Time sent: %s Time sent: %s
Server: %s""", Server: %s""",
Component.text(formattedTime).color(ColorUtilities.getColorByString(bot.config().colorPalette().string())), Component.text(formattedTime).color(ColorUtilities.getColorByString(bot.config.colorPalette.string)),
Component.text(mail.server()).color(ColorUtilities.getColorByString(bot.config().colorPalette().string())) Component.text(mail.server).color(ColorUtilities.getColorByString(bot.config.colorPalette.string))
).color(NamedTextColor.GREEN) ).color(NamedTextColor.GREEN)
) )
), ),
Component.text(mail.contents()).color(NamedTextColor.WHITE) Component.text(mail.contents).color(NamedTextColor.WHITE)
).color(NamedTextColor.GREEN) ).color(NamedTextColor.GREEN)
); );
@ -203,22 +206,22 @@ public class MailCommand extends Command {
.append(Component.newline()) .append(Component.newline())
.append(Component.join(JoinConfiguration.newlines(), mailsComponent)); .append(Component.join(JoinConfiguration.newlines(), mailsComponent));
if (context.inGame()) { if (context.inGame) {
bot.chat().tellraw( bot.chat.tellraw(
component, component,
context.sender().profile().getId() context.sender.profile.getId()
); );
} else { } else {
context.sendOutput(component); context.sendOutput(component);
} }
for (JsonElement mailElement : MailPlugin.mails().deepCopy()) { for (JsonElement mailElement : MailPlugin.mails.deepCopy()) {
final Mail mail = gson.fromJson(mailElement, Mail.class); final Mail mail = gson.fromJson(mailElement, Mail.class);
if (mail.sentTo().equals(sender.profile().getName())) MailPlugin.mails().remove(mailElement); if (mail.sentTo.equals(sender.profile.getName())) MailPlugin.mails.remove(mailElement);
} }
PersistentDataUtilities.put("mails", MailPlugin.mails()); PersistentDataUtilities.put("mails", MailPlugin.mails);
} }
default -> context.sendOutput(Component.text("Invalid argument").color(NamedTextColor.RED)); default -> context.sendOutput(Component.text("Invalid argument").color(NamedTextColor.RED));
} }

View file

@ -72,7 +72,7 @@ public class MusicCommand extends Command {
} }
public Component play (CommandContext context, String[] args) { public Component play (CommandContext context, String[] args) {
final MusicPlayerPlugin player = context.bot().music(); final MusicPlayerPlugin player = context.bot.music;
String _path; String _path;
Path path; Path path;
@ -131,15 +131,15 @@ public class MusicCommand extends Command {
} }
public Component stop (CommandContext context) { public Component stop (CommandContext context) {
final Bot bot = context.bot(); final Bot bot = context.bot;
bot.music().stopPlaying(); bot.music.stopPlaying();
bot.music().songQueue().clear(); bot.music.songQueue.clear();
return Component.text("Cleared the song queue").color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); return Component.text("Cleared the song queue").color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
} }
public Component loop (CommandContext context, String[] args) { public Component loop (CommandContext context, String[] args) {
final Bot bot = context.bot(); final Bot bot = context.bot;
if (args.length < 2) return Component.text("Invalid argument").color(NamedTextColor.RED); if (args.length < 2) return Component.text("Invalid argument").color(NamedTextColor.RED);
@ -151,7 +151,7 @@ public class MusicCommand extends Command {
Component.empty() Component.empty()
.append(Component.text("Looping is now ")) .append(Component.text("Looping is now "))
.append(Component.text("disabled").color(NamedTextColor.RED)) .append(Component.text("disabled").color(NamedTextColor.RED))
.color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())) .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor))
); );
} }
case "current" -> { case "current" -> {
@ -159,28 +159,28 @@ public class MusicCommand extends Command {
context.sendOutput( context.sendOutput(
Component.empty() Component.empty()
.append(Component.text("Now looping ")) .append(Component.text("Now looping "))
.append(bot.music().currentSong().name.color(ColorUtilities.getColorByString(bot.config().colorPalette().secondary()))) .append(bot.music.currentSong.name.color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary)))
.color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())) .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor))
); );
} }
case "all" -> { case "all" -> {
loop = Loop.ALL; loop = Loop.ALL;
context.sendOutput(Component.text("Now looping every song").color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor()))); context.sendOutput(Component.text("Now looping every song").color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)));
} }
default -> { default -> {
return Component.text("Invalid argument").color(NamedTextColor.RED); return Component.text("Invalid argument").color(NamedTextColor.RED);
} }
} }
bot.music().loop(loop); bot.music.loop = loop;
return null; return null;
} }
public Component list (CommandContext context, String[] args) { public Component list (CommandContext context, String[] args) {
final Bot bot = context.bot(); final Bot bot = context.bot;
final String prefix = context.prefix(); final String prefix = context.prefix;
final Path _path = Path.of(root.toString(), String.join(" ", Arrays.copyOfRange(args, 1, args.length))); final Path _path = Path.of(root.toString(), String.join(" ", Arrays.copyOfRange(args, 1, args.length)));
final Path path = (args.length < 2) ? root : _path; final Path path = (args.length < 2) ? root : _path;
@ -213,11 +213,11 @@ public class MusicCommand extends Command {
final String joinedPath = (args.length < 2) ? filename : Paths.get(location.getFileName().toString(), filename).toString(); final String joinedPath = (args.length < 2) ? filename : Paths.get(location.getFileName().toString(), filename).toString();
fullList.add( fullList.add(
Component Component
.text(filename, (i++ & 1) == 0 ? ColorUtilities.getColorByString(bot.config().colorPalette().primary()) : ColorUtilities.getColorByString(bot.config().colorPalette().secondary())) .text(filename, (i++ & 1) == 0 ? ColorUtilities.getColorByString(bot.config.colorPalette.primary) : ColorUtilities.getColorByString(bot.config.colorPalette.secondary))
.clickEvent( .clickEvent(
ClickEvent.suggestCommand( ClickEvent.suggestCommand(
prefix + prefix +
name() + name +
(file.isFile() ? " play " : " list ") + (file.isFile() ? " play " : " list ") +
joinedPath joinedPath
) )
@ -244,15 +244,15 @@ public class MusicCommand extends Command {
} }
public Component skip (CommandContext context) { public Component skip (CommandContext context) {
final Bot bot = context.bot(); final Bot bot = context.bot;
final MusicPlayerPlugin music = bot.music(); final MusicPlayerPlugin music = bot.music;
if (music.currentSong() == null) return Component.text("No song is currently playing").color(NamedTextColor.RED); if (music.currentSong == null) return Component.text("No song is currently playing").color(NamedTextColor.RED);
context.sendOutput( context.sendOutput(
Component.empty() Component.empty()
.append(Component.text("Skipping ")) .append(Component.text("Skipping "))
.append(music.currentSong().name.color(ColorUtilities.getColorByString(bot.config().colorPalette().secondary()))) .append(music.currentSong.name.color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary)))
.color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())) .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor))
); );
music.skip(); music.skip();
@ -261,25 +261,25 @@ public class MusicCommand extends Command {
} }
public Component nowplaying (CommandContext context) { public Component nowplaying (CommandContext context) {
final Bot bot = context.bot(); final Bot bot = context.bot;
final Song song = bot.music().currentSong(); final Song song = bot.music.currentSong;
if (song == null) return Component.text("No song is currently playing").color(NamedTextColor.RED); if (song == null) return Component.text("No song is currently playing").color(NamedTextColor.RED);
return Component.empty() return Component.empty()
.append(Component.text("Now playing ")) .append(Component.text("Now playing "))
.append(song.name.color(ColorUtilities.getColorByString(bot.config().colorPalette().secondary()))) .append(song.name.color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary)))
.color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
} }
public Component queue (CommandContext context) { public Component queue (CommandContext context) {
final Bot bot = context.bot(); final Bot bot = context.bot;
final List<Song> queue = bot.music().songQueue(); final List<Song> queue = bot.music.songQueue;
final List<Component> queueWithNames = new ArrayList<>(); final List<Component> queueWithNames = new ArrayList<>();
int i = 0; int i = 0;
for (Song song : queue) { for (Song song : queue) {
queueWithNames.add( queueWithNames.add(
song.name.color((i++ & 1) == 0 ? ColorUtilities.getColorByString(bot.config().colorPalette().primary()) : ColorUtilities.getColorByString(bot.config().colorPalette().secondary())) song.name.color((i++ & 1) == 0 ? ColorUtilities.getColorByString(bot.config.colorPalette.primary) : ColorUtilities.getColorByString(bot.config.colorPalette.secondary))
); );
} }
@ -290,8 +290,8 @@ public class MusicCommand extends Command {
// lazy fix for java using "goto" as keyword real // lazy fix for java using "goto" as keyword real
public Component goTo (CommandContext context, String[] args) { public Component goTo (CommandContext context, String[] args) {
final Bot bot = context.bot(); final Bot bot = context.bot;
final Song currentSong = bot.music().currentSong(); final Song currentSong = bot.music.currentSong;
final long milliseconds; final long milliseconds;
try { try {
@ -309,7 +309,7 @@ public class MusicCommand extends Command {
} }
public Component pitch (CommandContext context, String[] args) { public Component pitch (CommandContext context, String[] args) {
final Bot bot = context.bot(); final Bot bot = context.bot;
float pitch; float pitch;
try { try {
@ -318,16 +318,16 @@ public class MusicCommand extends Command {
return Component.text("Invalid pitch").color(NamedTextColor.RED); return Component.text("Invalid pitch").color(NamedTextColor.RED);
} }
bot.music().pitch(pitch); bot.music.pitch = pitch;
return Component.empty() return Component.empty()
.append(Component.text("Set the pitch to ")) .append(Component.text("Set the pitch to "))
.append(Component.text(pitch).color(ColorUtilities.getColorByString(bot.config().colorPalette().number()))) .append(Component.text(pitch).color(ColorUtilities.getColorByString(bot.config.colorPalette.number)))
.color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
} }
public Component speed (CommandContext context, String[] args) { public Component speed (CommandContext context, String[] args) {
final Bot bot = context.bot(); final Bot bot = context.bot;
float speed; float speed;
try { try {
@ -336,17 +336,17 @@ public class MusicCommand extends Command {
return Component.text("Invalid speed").color(NamedTextColor.RED); return Component.text("Invalid speed").color(NamedTextColor.RED);
} }
bot.music().speed(speed); bot.music.speed = speed;
return Component.empty() return Component.empty()
.append(Component.text("Set the speed to ")) .append(Component.text("Set the speed to "))
.append(Component.text(speed).color(ColorUtilities.getColorByString(bot.config().colorPalette().number()))) .append(Component.text(speed).color(ColorUtilities.getColorByString(bot.config.colorPalette.number)))
.color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
} }
public Component pause (CommandContext context) { public Component pause (CommandContext context) {
final Bot bot = context.bot(); final Bot bot = context.bot;
final Song currentSong = bot.music().currentSong(); final Song currentSong = bot.music.currentSong;
if (currentSong == null) return Component.text("No song is currently playing").color(NamedTextColor.RED); if (currentSong == null) return Component.text("No song is currently playing").color(NamedTextColor.RED);
@ -360,8 +360,8 @@ public class MusicCommand extends Command {
} }
public Component info (CommandContext context) { public Component info (CommandContext context) {
final Bot bot = context.bot(); final Bot bot = context.bot;
final Song currentSong = bot.music().currentSong(); final Song currentSong = bot.music.currentSong;
if (currentSong == null) return Component.text("No song is currently playing").color(NamedTextColor.RED); if (currentSong == null) return Component.text("No song is currently playing").color(NamedTextColor.RED);

View file

@ -24,10 +24,10 @@ public class NetMessageCommand extends Command {
@Override @Override
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot;
final List<Bot> bots = bot.bots(); final List<Bot> bots = bot.bots;
final String hostAndPort = bot.host() + ":" + bot.port(); final String hostAndPort = bot.host + ":" + bot.port;
final Component component = Component.translatable( final Component component = Component.translatable(
"[%s]%s%s%s %s", "[%s]%s%s%s %s",
@ -44,14 +44,14 @@ public class NetMessageCommand extends Command {
) )
), ),
Component.text(" "), Component.text(" "),
context.sender().displayName().color(NamedTextColor.GRAY), context.sender.displayName == null ? Component.text(context.sender.profile.getName()) : context.sender.displayName.color(NamedTextColor.GRAY),
Component.text(" "), Component.text(" "),
Component.text(String.join(" ", args)).color(NamedTextColor.GRAY) Component.text(String.join(" ", args)).color(NamedTextColor.GRAY)
).color(NamedTextColor.DARK_GRAY); ).color(NamedTextColor.DARK_GRAY);
for (Bot eachBot : bots) { for (Bot eachBot : bots) {
if (!eachBot.loggedIn()) continue; if (!eachBot.loggedIn) continue;
eachBot.chat().tellraw(component); eachBot.chat.tellraw(component);
} }
return null; return null;

View file

@ -23,22 +23,22 @@ public class RandomTeleportCommand extends Command {
@Override @Override
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot;
final MutablePlayerListEntry sender = context.sender(); final MutablePlayerListEntry sender = context.sender;
final int positionX = MathUtilities.between(1_000, 1_000_000); final int positionX = MathUtilities.between(1_000, 1_000_000);
final int positionZ = MathUtilities.between(1_000, 1_000_000); final int positionZ = MathUtilities.between(1_000, 1_000_000);
final String stringPosition = positionX + " 100 " + positionZ; // very 100 y final String stringPosition = positionX + " 100 " + positionZ; // very 100 y
bot.core().run("essentials:teleport " + sender.profile().getIdAsString() + " " + stringPosition); bot.core.run("essentials:teleport " + sender.profile.getIdAsString() + " " + stringPosition);
return Component.empty() return Component.empty()
.append(Component.text("Teleporting ")) .append(Component.text("Teleporting "))
.append(Component.text(sender.profile().getName()).color(ColorUtilities.getColorByString(bot.config().colorPalette().username()))) .append(Component.text(sender.profile.getName()).color(ColorUtilities.getColorByString(bot.config.colorPalette.username)))
.append(Component.text(" to ").color(NamedTextColor.WHITE)) .append(Component.text(" to ").color(NamedTextColor.WHITE))
.append(Component.text(stringPosition).color(NamedTextColor.GREEN)) .append(Component.text(stringPosition).color(NamedTextColor.GREEN))
.append(Component.text("...").color(NamedTextColor.WHITE)) .append(Component.text("...").color(NamedTextColor.WHITE))
.color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
} }
} }

View file

@ -19,10 +19,10 @@ public class RefillCoreCommand extends Command {
@Override @Override
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot;
bot.core().reset(); bot.core.reset();
bot.core().refill(); bot.core.refill();
return null; return null;
} }

View file

@ -15,9 +15,6 @@ import org.joda.time.DateTimeZone;
import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter; import org.joda.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
public class SeenCommand extends Command { public class SeenCommand extends Command {
public SeenCommand () { public SeenCommand () {
super( super(
@ -31,19 +28,19 @@ public class SeenCommand extends Command {
@Override @Override
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot;
final String player = String.join(" ", args); final String player = String.join(" ", args);
for (Bot eachBot : bot.bots()) { for (Bot eachBot : bot.bots) {
if (eachBot.players().getEntry(player) != null) return Component.empty() if (eachBot.players.getEntry(player) != null) return Component.empty()
.append(Component.text(player)) .append(Component.text(player))
.append(Component.text(" is currently online on ")) .append(Component.text(" is currently online on "))
.append(Component.text(eachBot.host() + ":" + eachBot.port())) .append(Component.text(eachBot.host + ":" + eachBot.port))
.color(NamedTextColor.RED); .color(NamedTextColor.RED);
} }
final JsonElement playerElement = PlayersPlugin.playersObject().get(player); final JsonElement playerElement = PlayersPlugin.playersObject.get(player);
if (playerElement == null) return Component.translatable( if (playerElement == null) return Component.translatable(
"%s was never seen", "%s was never seen",
Component.text(player) Component.text(player)
@ -60,9 +57,9 @@ public class SeenCommand extends Command {
return Component.translatable( return Component.translatable(
"%s was last seen at %s on %s", "%s was last seen at %s on %s",
Component.text(player).color(ColorUtilities.getColorByString(bot.config().colorPalette().username())), Component.text(player).color(ColorUtilities.getColorByString(bot.config.colorPalette.username)),
Component.text(formattedTime).color(ColorUtilities.getColorByString(bot.config().colorPalette().string())), Component.text(formattedTime).color(ColorUtilities.getColorByString(bot.config.colorPalette.string)),
Component.text(server).color(ColorUtilities.getColorByString(bot.config().colorPalette().string())) Component.text(server).color(ColorUtilities.getColorByString(bot.config.colorPalette.string))
).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
} }
} }

View file

@ -25,7 +25,7 @@ public class ServerEvalCommand extends Command {
@Override @Override
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
try { try {
final Bot bot = context.bot(); final Bot bot = context.bot;
final Globals globals = JsePlatform.standardGlobals(); final Globals globals = JsePlatform.standardGlobals();

View file

@ -33,7 +33,7 @@ public class ServerInfoCommand extends Command {
@Override @Override
public Component execute(CommandContext context, String[] args, String[] fullArgs) throws UnknownHostException { public Component execute(CommandContext context, String[] args, String[] fullArgs) throws UnknownHostException {
final Bot bot = context.bot(); final Bot bot = context.bot;
// totallynotskidded from extras' serverinfo // totallynotskidded from extras' serverinfo
final Component component; final Component component;
@ -65,7 +65,7 @@ public class ServerInfoCommand extends Command {
file.close(); file.close();
} catch (IOException ignored) {} } catch (IOException ignored) {}
final TextColor color = ColorUtilities.getColorByString(bot.config().colorPalette().string()); final TextColor color = ColorUtilities.getColorByString(bot.config.colorPalette.string);
final String[] lines = builder.toString().split("\n"); final String[] lines = builder.toString().split("\n");
final Optional<String> modelName = Arrays.stream(lines) final Optional<String> modelName = Arrays.stream(lines)
@ -98,7 +98,7 @@ public class ServerInfoCommand extends Command {
Component.text(heapUsage.getUsed() / 1024L / 1024L), Component.text(heapUsage.getUsed() / 1024L / 1024L),
Component.text(heapUsage.getMax() / 1024L / 1024L) Component.text(heapUsage.getMax() / 1024L / 1024L)
).color(color) ).color(color)
).color(ColorUtilities.getColorByString(bot.config().colorPalette().secondary())); ).color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary));
return component; return component;
} }

View file

@ -21,10 +21,10 @@ public class SudoAllCommand extends Command {
@Override @Override
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot;
for (MutablePlayerListEntry entry : bot.players().list()) { for (MutablePlayerListEntry entry : bot.players.list) {
bot.core().run("essentials:sudo " + entry.profile().getName() + " " + String.join(" ", args)); bot.core.run("essentials:sudo " + entry.profile.getName() + " " + String.join(" ", args));
} }
return null; return null;

View file

@ -21,22 +21,22 @@ public class TPSBarCommand extends Command {
@Override @Override
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot;
switch (args[0]) { switch (args[0]) {
case "on" -> { case "on" -> {
bot.tps().on(); bot.tps.on();
return Component.empty() return Component.empty()
.append(Component.text("TPSBar is now ")) .append(Component.text("TPSBar is now "))
.append(Component.text("enabled").color(NamedTextColor.GREEN)) .append(Component.text("enabled").color(NamedTextColor.GREEN))
.color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
} }
case "off" -> { case "off" -> {
bot.tps().off(); bot.tps.off();
return Component.empty() return Component.empty()
.append(Component.text("TPSBar is now ")) .append(Component.text("TPSBar is now "))
.append(Component.text("disabled").color(NamedTextColor.RED)) .append(Component.text("disabled").color(NamedTextColor.RED))
.color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
} }
default -> { default -> {
return Component.text("Invalid argument").color(NamedTextColor.RED); return Component.text("Invalid argument").color(NamedTextColor.RED);

View file

@ -21,9 +21,9 @@ public class TestCommand extends Command {
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
return Component.translatable( return Component.translatable(
"Hello, World! Username: %s, Sender UUID: %s, Prefix: %s, Args: %s", "Hello, World! Username: %s, Sender UUID: %s, Prefix: %s, Args: %s",
Component.text(context.sender().profile().getName()), Component.text(context.sender.profile.getName()),
Component.text(context.sender().profile().getIdAsString()), Component.text(context.sender.profile.getIdAsString()),
Component.text(context.prefix()), Component.text(context.prefix),
Component.text(String.join(", ", args)) Component.text(String.join(", ", args))
).color(NamedTextColor.GREEN); ).color(NamedTextColor.GREEN);
} }

View file

@ -25,7 +25,7 @@ public class TimeCommand extends Command {
@Override @Override
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot;
final String timezone = args[0]; final String timezone = args[0];
@ -43,8 +43,8 @@ public class TimeCommand extends Command {
return Component.translatable( return Component.translatable(
"The current time for %s is: %s", "The current time for %s is: %s",
Component.text(timezone).color(ColorUtilities.getColorByString(bot.config().colorPalette().string())), Component.text(timezone).color(ColorUtilities.getColorByString(bot.config.colorPalette.string)),
Component.text(formattedTime).color(NamedTextColor.GREEN) Component.text(formattedTime).color(NamedTextColor.GREEN)
).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
} }
} }

View file

@ -30,7 +30,7 @@ public class TranslateCommand extends Command {
@Override @Override
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot;
final String from = args[0]; final String from = args[0];
final String to = args[1]; final String to = args[1];
@ -39,7 +39,7 @@ public class TranslateCommand extends Command {
final Gson gson = new Gson(); final Gson gson = new Gson();
bot.executorService().submit(() -> { bot.executorService.submit(() -> {
try { try {
final URL url = new URL("https://translate.google.com/translate_a/single?client=at&dt=t&dt=rm&dj=1"); final URL url = new URL("https://translate.google.com/translate_a/single?client=at&dt=t&dt=rm&dj=1");
@ -71,7 +71,7 @@ public class TranslateCommand extends Command {
"Result: %s", "Result: %s",
Component.text(output).color(NamedTextColor.GREEN) Component.text(output).color(NamedTextColor.GREEN)
) )
.color(ColorUtilities.getColorByString(bot.config().colorPalette().secondary())) .color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary))
); );
} catch (Exception e) { } catch (Exception e) {
context.sendOutput(Component.text(e.toString()).color(NamedTextColor.RED)); context.sendOutput(Component.text(e.toString()).color(NamedTextColor.RED));

View file

@ -24,15 +24,15 @@ public class UUIDCommand extends Command {
@Override @Override
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot;
if (args.length > 0) { if (args.length > 0) {
final MutablePlayerListEntry entry = bot.players().getEntry(String.join(" ", args)); final MutablePlayerListEntry entry = bot.players.getEntry(String.join(" ", args));
if (entry == null) return Component.text("Invalid player name").color(NamedTextColor.RED); if (entry == null) return Component.text("Invalid player name").color(NamedTextColor.RED);
final String name = entry.profile().getName(); final String name = entry.profile.getName();
final String uuid = entry.profile().getIdAsString(); final String uuid = entry.profile.getIdAsString();
return Component.translatable( return Component.translatable(
"%s's UUID: %s", "%s's UUID: %s",
@ -47,12 +47,12 @@ public class UUIDCommand extends Command {
.clickEvent( .clickEvent(
ClickEvent.copyToClipboard(uuid) ClickEvent.copyToClipboard(uuid)
) )
.color(ColorUtilities.getColorByString(bot.config().colorPalette().uuid())) .color(ColorUtilities.getColorByString(bot.config.colorPalette.uuid))
).color(NamedTextColor.GREEN); ).color(NamedTextColor.GREEN);
} else { } else {
final MutablePlayerListEntry entry = context.sender(); final MutablePlayerListEntry entry = context.sender;
final String uuid = entry.profile().getIdAsString(); final String uuid = entry.profile.getIdAsString();
return Component.translatable( return Component.translatable(
"Your UUID: %s", "Your UUID: %s",
@ -66,7 +66,7 @@ public class UUIDCommand extends Command {
.clickEvent( .clickEvent(
ClickEvent.copyToClipboard(uuid) ClickEvent.copyToClipboard(uuid)
) )
.color(ColorUtilities.getColorByString(bot.config().colorPalette().uuid())) .color(ColorUtilities.getColorByString(bot.config.colorPalette.uuid))
).color(NamedTextColor.GREEN); ).color(NamedTextColor.GREEN);
} }
} }

View file

@ -24,7 +24,7 @@ public class UptimeCommand extends Command {
@Override @Override
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot;
final long uptime = ManagementFactory.getRuntimeMXBean().getUptime() / 1000; final long uptime = ManagementFactory.getRuntimeMXBean().getUptime() / 1000;
@ -42,6 +42,6 @@ public class UptimeCommand extends Command {
Component.text(minutes), Component.text(minutes),
Component.text(seconds) Component.text(seconds)
).color(NamedTextColor.GREEN) ).color(NamedTextColor.GREEN)
).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
} }
} }

View file

@ -31,13 +31,13 @@ public class UrbanCommand extends Command {
} }
public Component execute (CommandContext context, String[] args, String[] fullArgs) { public Component execute (CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot;
final String term = String.join(" ", args); final String term = String.join(" ", args);
final Gson gson = new Gson(); final Gson gson = new Gson();
bot.executorService().submit(() -> { bot.executorService.submit(() -> {
try { try {
final URL url = new URL( final URL url = new URL(
"https://api.urbandictionary.com/v0/define?term=" + "https://api.urbandictionary.com/v0/define?term=" +
@ -80,8 +80,8 @@ public class UrbanCommand extends Command {
.clickEvent( .clickEvent(
ClickEvent ClickEvent
.suggestCommand( .suggestCommand(
context.prefix() + context.prefix +
name() + name +
" " + " " +
splittedDefinition[i] splittedDefinition[i]
) )

View file

@ -21,8 +21,8 @@ public class ValidateCommand extends Command {
public Component execute(CommandContext context, String[] args, String[] fullArgs) { public Component execute(CommandContext context, String[] args, String[] fullArgs) {
final String hash = fullArgs[0]; final String hash = fullArgs[0];
if (hash.equals(context.hash())) return Component.text("Valid hash").color(NamedTextColor.GREEN); if (hash.equals(context.hash)) return Component.text("Valid hash").color(NamedTextColor.GREEN);
else if (hash.equals(context.ownerHash())) return Component.text("Valid OwnerHash").color(NamedTextColor.GREEN); else if (hash.equals(context.ownerHash)) return Component.text("Valid OwnerHash").color(NamedTextColor.GREEN);
return null; return null;
} }

View file

@ -31,7 +31,7 @@ public class WeatherCommand extends Command {
} }
public Component execute (CommandContext context, String[] args, String[] fullArgs) { public Component execute (CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot;
final String location = String.join(" ", args); final String location = String.join(" ", args);
@ -39,7 +39,7 @@ public class WeatherCommand extends Command {
try { try {
final URL url = new URL( final URL url = new URL(
"https://api.weatherapi.com/v1/current.json?key=" + bot.config().weatherApiKey() + "&q=" + "https://api.weatherapi.com/v1/current.json?key=" + bot.config.weatherApiKey + "&q=" +
URLEncoder.encode( URLEncoder.encode(
location, location,
StandardCharsets.UTF_8 StandardCharsets.UTF_8
@ -61,12 +61,12 @@ public class WeatherCommand extends Command {
return Component.translatable( return Component.translatable(
"Weather forecast for %s, %s:\n%s, feels like %s\nTime: %s", "Weather forecast for %s, %s:\n%s, feels like %s\nTime: %s",
Component.text(jsonObject.get("location").getAsJsonObject().get("name").getAsString()).color(ColorUtilities.getColorByString(bot.config().colorPalette().string())), Component.text(jsonObject.get("location").getAsJsonObject().get("name").getAsString()).color(ColorUtilities.getColorByString(bot.config.colorPalette.string)),
Component.text(jsonObject.get("location").getAsJsonObject().get("country").getAsString()).color(ColorUtilities.getColorByString(bot.config().colorPalette().string())), Component.text(jsonObject.get("location").getAsJsonObject().get("country").getAsString()).color(ColorUtilities.getColorByString(bot.config.colorPalette.string)),
Component.text(jsonObject.get("current").getAsJsonObject().get("temp_c").getAsString() + "°C").color(ColorUtilities.getColorByString(bot.config().colorPalette().secondary())), Component.text(jsonObject.get("current").getAsJsonObject().get("temp_c").getAsString() + "°C").color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary)),
Component.text(jsonObject.get("current").getAsJsonObject().get("feelslike_c").getAsString() + "°C").color(NamedTextColor.GREEN), Component.text(jsonObject.get("current").getAsJsonObject().get("feelslike_c").getAsString() + "°C").color(NamedTextColor.GREEN),
Component.text(time).color(ColorUtilities.getColorByString(bot.config().colorPalette().string())) Component.text(time).color(ColorUtilities.getColorByString(bot.config.colorPalette.string))
).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
} catch (Exception e) { } catch (Exception e) {
return Component.text("Location \"" + location + "\" not found").color(NamedTextColor.RED); return Component.text("Location \"" + location + "\" not found").color(NamedTextColor.RED);
} }

View file

@ -27,13 +27,13 @@ public class WikipediaCommand extends Command {
} }
public Component execute (CommandContext context, String[] args, String[] fullArgs) { public Component execute (CommandContext context, String[] args, String[] fullArgs) {
final Bot bot = context.bot(); final Bot bot = context.bot;
final String page = String.join(" ", args); final String page = String.join(" ", args);
final Gson gson = new Gson(); final Gson gson = new Gson();
bot.executorService().submit(() -> { bot.executorService.submit(() -> {
try { try {
final URL url = new URL( final URL url = new URL(
"https://en.wikipedia.org/api/rest_v1/page/summary/" + "https://en.wikipedia.org/api/rest_v1/page/summary/" +

View file

@ -2,12 +2,10 @@ package land.chipmunk.chayapak.chomens_bot.data;
import com.github.steveice10.mc.protocol.data.game.BossBarColor; import com.github.steveice10.mc.protocol.data.game.BossBarColor;
import com.github.steveice10.mc.protocol.data.game.BossBarDivision; import com.github.steveice10.mc.protocol.data.game.BossBarDivision;
import lombok.AllArgsConstructor;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import java.util.UUID; import java.util.UUID;
@AllArgsConstructor
public class BossBar { public class BossBar {
public UUID uuid; public UUID uuid;
@ -15,5 +13,19 @@ public class BossBar {
public BossBarColor color; public BossBarColor color;
public BossBarDivision division; public BossBarDivision division;
public float health; public float health;
public BossBar (
UUID uuid,
Component title,
BossBarColor color,
BossBarDivision division,
float health
) {
this.uuid = uuid;
this.title = title;
this.color = color;
this.division = division;
this.health = health;
}
} }

View file

@ -47,7 +47,7 @@ public class BotBossBar extends BossBar {
this.title = title; this.title = title;
bot.core().run("minecraft:bossbar set " + id + " name " + GsonComponentSerializer.gson().serialize(title)); bot.core.run("minecraft:bossbar set " + id + " name " + GsonComponentSerializer.gson().serialize(title));
} }
public void setColor (BossBarColor color) { public void setColor (BossBarColor color) {
@ -58,7 +58,7 @@ public class BotBossBar extends BossBar {
this.color = color; this.color = color;
bot.core().run("minecraft:bossbar set " + id + " color " + (color == BossBarColor.LIME ? "green" : color.name().toLowerCase())); bot.core.run("minecraft:bossbar set " + id + " color " + (color == BossBarColor.LIME ? "green" : color.name().toLowerCase()));
} }
public void setPlayers (String players) { public void setPlayers (String players) {
@ -66,7 +66,7 @@ public class BotBossBar extends BossBar {
this.players = players; this.players = players;
bot.core().run("minecraft:bossbar set " + id + " players " + players); bot.core.run("minecraft:bossbar set " + id + " players " + players);
} }
public void setDivision (BossBarDivision division) { public void setDivision (BossBarDivision division) {
@ -87,7 +87,7 @@ public class BotBossBar extends BossBar {
case NOTCHES_10 -> division = "notched_10"; case NOTCHES_10 -> division = "notched_10";
} }
bot.core().run("minecraft:bossbar set " + id + " style " + division); bot.core.run("minecraft:bossbar set " + id + " style " + division);
} }
public void setValue (int value) { public void setValue (int value) {
@ -98,7 +98,7 @@ public class BotBossBar extends BossBar {
this.value = value; this.value = value;
bot.core().run("minecraft:bossbar set " + id + " value " + value); bot.core.run("minecraft:bossbar set " + id + " value " + value);
} }
public void setVisible (boolean visible) { public void setVisible (boolean visible) {
@ -106,7 +106,7 @@ public class BotBossBar extends BossBar {
this.visible = visible; this.visible = visible;
bot.core().run("minecraft:bossbar set " + id + " visible " + visible); bot.core.run("minecraft:bossbar set " + id + " visible " + visible);
} }
public void setMax (long max) { public void setMax (long max) {
@ -117,6 +117,6 @@ public class BotBossBar extends BossBar {
this.max = max; this.max = max;
bot.core().run("minecraft:bossbar set " + id + " max " + max); bot.core.run("minecraft:bossbar set " + id + " max " + max);
} }
} }

View file

@ -1,11 +1,8 @@
package land.chipmunk.chayapak.chomens_bot.data; package land.chipmunk.chayapak.chomens_bot.data;
import lombok.AllArgsConstructor;
import lombok.Getter;
@AllArgsConstructor public record CommandLoop (
public class CommandLoop { String command,
@Getter private String command; int interval
@Getter private int interval; ) {}
}

View file

@ -1,10 +1,6 @@
package land.chipmunk.chayapak.chomens_bot.data; package land.chipmunk.chayapak.chomens_bot.data;
import lombok.AllArgsConstructor; public record EvalOutput (
import lombok.Getter; boolean isError,
String output
@AllArgsConstructor ) {}
public class EvalOutput {
@Getter private final boolean isError;
@Getter private final String output;
}

View file

@ -1,10 +1,17 @@
package land.chipmunk.chayapak.chomens_bot.data; package land.chipmunk.chayapak.chomens_bot.data;
import lombok.AllArgsConstructor;
@AllArgsConstructor
public class FilteredPlayer { public class FilteredPlayer {
public String playerName; public String playerName;
public boolean regex; public boolean regex;
public boolean ignoreCase; public boolean ignoreCase;
public FilteredPlayer (
String playerName,
boolean regex,
boolean ignoreCase
) {
this.playerName = playerName;
this.regex = regex;
this.ignoreCase = ignoreCase;
}
} }

View file

@ -1,13 +1,23 @@
package land.chipmunk.chayapak.chomens_bot.data; package land.chipmunk.chayapak.chomens_bot.data;
import lombok.AllArgsConstructor;
import lombok.Getter;
@AllArgsConstructor
public class Mail { public class Mail {
@Getter private String sentBy; public String sentBy;
@Getter private String sentTo; public String sentTo;
@Getter private long timeSent; public long timeSent;
@Getter private String server; public String server;
@Getter private String contents; public String contents;
public Mail (
String sentBy,
String sentTo,
long timeSent,
String server,
String contents
) {
this.sentBy = sentBy;
this.sentTo = sentTo;
this.timeSent = timeSent;
this.server = server;
this.contents = contents;
}
} }

View file

@ -1,9 +1,6 @@
package land.chipmunk.chayapak.chomens_bot.data; package land.chipmunk.chayapak.chomens_bot.data;
import lombok.AllArgsConstructor; public record Rotation (
float yaw,
@AllArgsConstructor float pitch
public class Rotation { ) {}
public float yaw;
public float pitch;
}

View file

@ -3,21 +3,38 @@ package land.chipmunk.chayapak.chomens_bot.data;
import com.github.steveice10.mc.protocol.data.game.scoreboard.CollisionRule; import com.github.steveice10.mc.protocol.data.game.scoreboard.CollisionRule;
import com.github.steveice10.mc.protocol.data.game.scoreboard.NameTagVisibility; import com.github.steveice10.mc.protocol.data.game.scoreboard.NameTagVisibility;
import com.github.steveice10.mc.protocol.data.game.scoreboard.TeamColor; import com.github.steveice10.mc.protocol.data.game.scoreboard.TeamColor;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
@AllArgsConstructor
public class Team { public class Team {
@Getter @Setter private String teamName; public String teamName;
@Getter @Setter private Component displayName; public Component displayName;
@Getter @Setter private boolean friendlyFire; public boolean friendlyFire;
@Getter @Setter private boolean seeFriendlyInvisibles; public boolean seeFriendlyInvisibles;
@Getter @Setter private NameTagVisibility nametagVisibility; public NameTagVisibility nametagVisibility;
@Getter @Setter private CollisionRule collisionRule; public CollisionRule collisionRule;
@Getter @Setter private TeamColor color; public TeamColor color;
@Getter @Setter private Component prefix; public Component prefix;
@Getter @Setter private Component suffix; public Component suffix;
public Team (
String teamName,
Component displayName,
boolean friendlyFire,
boolean seeFriendlyInvisibles,
NameTagVisibility nametagVisibility,
CollisionRule collisionRule,
TeamColor color,
Component prefix,
Component suffix
) {
this.teamName = teamName;
this.displayName = displayName;
this.friendlyFire = friendlyFire;
this.seeFriendlyInvisibles = seeFriendlyInvisibles;
this.nametagVisibility = nametagVisibility;
this.collisionRule = collisionRule;
this.color = color;
this.prefix = prefix;
this.suffix = suffix;
}
} }

View file

@ -3,23 +3,39 @@ package land.chipmunk.chayapak.chomens_bot.data.chat;
import com.github.steveice10.mc.auth.data.GameProfile; import com.github.steveice10.mc.auth.data.GameProfile;
import com.github.steveice10.mc.protocol.data.game.PlayerListEntry; import com.github.steveice10.mc.protocol.data.game.PlayerListEntry;
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode; import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
import lombok.AllArgsConstructor;
import lombok.Data;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import java.security.PublicKey; import java.security.PublicKey;
@Data
@AllArgsConstructor
public class MutablePlayerListEntry { public class MutablePlayerListEntry {
private GameProfile profile; public GameProfile profile;
private GameMode gamemode; public GameMode gamemode;
private int latency; public int latency;
private Component displayName; public Component displayName;
private long expiresAt; public long expiresAt;
private PublicKey publicKey; public PublicKey publicKey;
private byte[] keySignature; public byte[] keySignature;
private boolean listed; public boolean listed;
public MutablePlayerListEntry (
GameProfile profile,
GameMode gamemode,
int latency,
Component displayName,
long expiresAt,
PublicKey publicKey,
byte[] keySignature,
boolean listed
) {
this.profile = profile;
this.gamemode = gamemode;
this.latency = latency;
this.displayName = displayName;
this.expiresAt = expiresAt;
this.publicKey = publicKey;
this.keySignature = keySignature;
this.listed = listed;
}
public MutablePlayerListEntry (PlayerListEntry entry) { public MutablePlayerListEntry (PlayerListEntry entry) {
this(entry.getProfile(), entry.getGameMode(), entry.getLatency(), entry.getDisplayName(), entry.getExpiresAt(), entry.getPublicKey(), entry.getKeySignature(), entry.isListed()); this(entry.getProfile(), entry.getGameMode(), entry.getLatency(), entry.getDisplayName(), entry.getExpiresAt(), entry.getPublicKey(), entry.getKeySignature(), entry.isListed());

View file

@ -1,13 +1,19 @@
package land.chipmunk.chayapak.chomens_bot.data.chat; package land.chipmunk.chayapak.chomens_bot.data.chat;
import lombok.AllArgsConstructor;
import lombok.Data;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
@Data
@AllArgsConstructor
public class PlayerMessage { public class PlayerMessage {
private MutablePlayerListEntry sender; public final MutablePlayerListEntry sender;
private Component displayName; public final Component displayName;
private Component contents; public final Component contents;
public PlayerMessage (
MutablePlayerListEntry sender,
Component displayName,
Component contents
) {
this.sender = sender;
this.displayName = displayName;
this.contents = contents;
}
} }

View file

@ -1,19 +1,10 @@
package land.chipmunk.chayapak.chomens_bot.data.voiceChat; package land.chipmunk.chayapak.chomens_bot.data.voiceChat;
import land.chipmunk.chayapak.chomens_bot.util.FriendlyByteBuf; import land.chipmunk.chayapak.chomens_bot.util.FriendlyByteBuf;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.UUID; import java.util.UUID;
@AllArgsConstructor public record ClientGroup(UUID id, String name, boolean hasPassword, boolean persistent, GroupType type) {
public class ClientGroup {
@Getter private final UUID id;
@Getter private final String name;
@Getter private final boolean hasPassword;
@Getter private final boolean persistent;
@Getter private final GroupType type;
public static ClientGroup fromBytes(FriendlyByteBuf buf) { public static ClientGroup fromBytes(FriendlyByteBuf buf) {
return new ClientGroup( return new ClientGroup(
buf.readUUID(), buf.readUUID(),

View file

@ -1,13 +1,5 @@
package land.chipmunk.chayapak.chomens_bot.data.voiceChat; package land.chipmunk.chayapak.chomens_bot.data.voiceChat;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.net.SocketAddress; import java.net.SocketAddress;
@AllArgsConstructor public record RawUdpPacket(byte[] data, SocketAddress socketAddress, long timestamp) {}
public class RawUdpPacket {
@Getter private final byte[] data;
@Getter private final SocketAddress socketAddress;
@Getter private final long timestamp;
}

View file

@ -9,8 +9,6 @@ import land.chipmunk.chayapak.chomens_bot.data.BossBar;
import land.chipmunk.chayapak.chomens_bot.data.BotBossBar; import land.chipmunk.chayapak.chomens_bot.data.BotBossBar;
import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry; import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry;
import land.chipmunk.chayapak.chomens_bot.util.ComponentUtilities; import land.chipmunk.chayapak.chomens_bot.util.ComponentUtilities;
import lombok.Getter;
import lombok.Setter;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import java.util.HashMap; import java.util.HashMap;
@ -21,19 +19,19 @@ import java.util.UUID;
public class BossbarManagerPlugin extends Bot.Listener { public class BossbarManagerPlugin extends Bot.Listener {
private final Bot bot; private final Bot bot;
@Getter private final Map<UUID, BossBar> serverBossBars = new HashMap<>(); public final Map<UUID, BossBar> serverBossBars = new HashMap<>();
private final Map<UUID, BotBossBar> bossBars = new HashMap<>(); private final Map<UUID, BotBossBar> bossBars = new HashMap<>();
@Getter @Setter private boolean enabled = true; public boolean enabled = true;
@Getter @Setter private String bossBarPrefix = "chomens_bot:"; public String bossBarPrefix = "chomens_bot:";
public BossbarManagerPlugin (Bot bot) { public BossbarManagerPlugin (Bot bot) {
this.bot = bot; this.bot = bot;
bot.addListener(this); bot.addListener(this);
bot.players().addListener(new PlayersPlugin.Listener() { bot.players.addListener(new PlayersPlugin.Listener() {
@Override @Override
public void playerJoined(MutablePlayerListEntry target) { public void playerJoined(MutablePlayerListEntry target) {
BossbarManagerPlugin.this.playerJoined(); BossbarManagerPlugin.this.playerJoined();
@ -47,7 +45,7 @@ public class BossbarManagerPlugin extends Bot.Listener {
} }
public void packetReceived(ClientboundBossEventPacket packet) { public void packetReceived(ClientboundBossEventPacket packet) {
if (!enabled || !bot.options().useCore()) return; if (!enabled || !bot.options.useCore) return;
try { try {
switch (packet.getAction()) { switch (packet.getAction()) {
@ -157,7 +155,7 @@ public class BossbarManagerPlugin extends Bot.Listener {
} }
public void add (String name, BotBossBar bossBar) { public void add (String name, BotBossBar bossBar) {
if (!enabled || !bot.options().useCore()) return; if (!enabled || !bot.options.useCore) return;
bossBar.id = bossBarPrefix + name; bossBar.id = bossBarPrefix + name;
@ -184,17 +182,17 @@ public class BossbarManagerPlugin extends Bot.Listener {
case NOTCHES_10 -> division = "notched_10"; case NOTCHES_10 -> division = "notched_10";
} }
bot.core().run("minecraft:bossbar add " + name + " " + stringifiedName); bot.core.run("minecraft:bossbar add " + name + " " + stringifiedName);
bot.core().run(prefix + "players " + bossBar.players); bot.core.run(prefix + "players " + bossBar.players);
bot.core().run(prefix + "color " + (bossBar.color == BossBarColor.LIME ? "green" : bossBar.color.name().toLowerCase())); bot.core.run(prefix + "color " + (bossBar.color == BossBarColor.LIME ? "green" : bossBar.color.name().toLowerCase()));
bot.core().run(prefix + "visible " + bossBar.visible); bot.core.run(prefix + "visible " + bossBar.visible);
bot.core().run(prefix + "style " + division); bot.core.run(prefix + "style " + division);
bot.core().run(prefix + "max " + bossBar.max); bot.core.run(prefix + "max " + bossBar.max);
bot.core().run(prefix + "value " + bossBar.value); bot.core.run(prefix + "value " + bossBar.value);
} }
public void remove (String name) { public void remove (String name) {
if (!enabled || !bot.options().useCore()) return; if (!enabled || !bot.options.useCore) return;
final Map<UUID, BotBossBar> mapCopy = new HashMap<>(bossBars); final Map<UUID, BotBossBar> mapCopy = new HashMap<>(bossBars);
@ -202,7 +200,7 @@ public class BossbarManagerPlugin extends Bot.Listener {
if (bossBar.getValue().id.equals(bossBarPrefix + name)) bossBars.remove(bossBar.getValue().uuid); if (bossBar.getValue().id.equals(bossBarPrefix + name)) bossBars.remove(bossBar.getValue().uuid);
} }
bot.core().run("minecraft:bossbar remove " + bossBarPrefix + name); bot.core.run("minecraft:bossbar remove " + bossBarPrefix + name);
} }
public BotBossBar get (String name) { public BotBossBar get (String name) {

View file

@ -2,20 +2,18 @@ package land.chipmunk.chayapak.chomens_bot.plugins;
import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.Bot;
import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities; import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities;
import lombok.Getter;
import lombok.Setter;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.TextColor; import net.kyori.adventure.text.format.TextColor;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
public class BruhifyPlugin { public class BruhifyPlugin {
@Getter @Setter private String bruhifyText = ""; public String bruhifyText = "";
private int startHue = 0; private int startHue = 0;
public BruhifyPlugin (Bot bot) { public BruhifyPlugin (Bot bot) {
bot.executor().scheduleAtFixedRate(() -> { bot.executor.scheduleAtFixedRate(() -> {
if (bruhifyText.equals("")) return; if (bruhifyText.equals("")) return;
int hue = startHue; int hue = startHue;
@ -30,7 +28,7 @@ public class BruhifyPlugin {
hue = (hue + increment) % 360; hue = (hue + increment) % 360;
} }
bot.chat().actionBar(component); bot.chat.actionBar(component);
startHue = (startHue + increment) % 360; startHue = (startHue + increment) % 360;
}, 50, 100, TimeUnit.MILLISECONDS); }, 50, 100, TimeUnit.MILLISECONDS);

View file

@ -5,7 +5,6 @@ import land.chipmunk.chayapak.chomens_bot.data.chat.PlayerMessage;
import land.chipmunk.chayapak.chomens_bot.command.PlayerCommandContext; import land.chipmunk.chayapak.chomens_bot.command.PlayerCommandContext;
import land.chipmunk.chayapak.chomens_bot.util.ComponentUtilities; import land.chipmunk.chayapak.chomens_bot.util.ComponentUtilities;
import land.chipmunk.chayapak.chomens_bot.util.UUIDUtilities; import land.chipmunk.chayapak.chomens_bot.util.UUIDUtilities;
import lombok.Getter;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import java.util.List; import java.util.List;
@ -13,16 +12,16 @@ import java.util.List;
public class ChatCommandHandlerPlugin extends ChatPlugin.Listener { public class ChatCommandHandlerPlugin extends ChatPlugin.Listener {
public final Bot bot; public final Bot bot;
@Getter private final List<String> prefixes; public final List<String> prefixes;
@Getter private final List<String> commandSpyPrefixes; public final List<String> commandSpyPrefixes;
public ChatCommandHandlerPlugin(Bot bot) { public ChatCommandHandlerPlugin(Bot bot) {
this.bot = bot; this.bot = bot;
this.prefixes = bot.config().prefixes(); this.prefixes = bot.config.prefixes;
this.commandSpyPrefixes = bot.config().commandSpyPrefixes(); this.commandSpyPrefixes = bot.config.commandSpyPrefixes;
bot.chat().addListener(this); bot.chat.addListener(this);
} }
@Override @Override
@ -33,11 +32,11 @@ public class ChatCommandHandlerPlugin extends ChatPlugin.Listener {
private void listener (PlayerMessage message, boolean cspy) { private void listener (PlayerMessage message, boolean cspy) {
try { try {
if (message.sender().profile().getId().equals(bot.profile().getId())) return; if (message.sender.profile.getId().equals(bot.profile.getId())) return;
} catch (Exception ignored) {} // kinda sus ngl } catch (Exception ignored) {} // kinda sus ngl
final Component displayNameComponent = message.displayName(); final Component displayNameComponent = message.displayName;
final Component messageComponent = message.contents(); final Component messageComponent = message.contents;
if (displayNameComponent == null || messageComponent == null) return; if (displayNameComponent == null || messageComponent == null) return;
final String displayName = ComponentUtilities.stringify(displayNameComponent); final String displayName = ComponentUtilities.stringify(displayNameComponent);
@ -54,11 +53,11 @@ public class ChatCommandHandlerPlugin extends ChatPlugin.Listener {
final String commandString = contents.substring(prefix.length()); final String commandString = contents.substring(prefix.length());
final String selector = cspy ? UUIDUtilities.selector(message.sender().profile().getId()) : "@a"; final String selector = cspy ? UUIDUtilities.selector(message.sender.profile.getId()) : "@a";
final PlayerCommandContext context = new PlayerCommandContext(bot, displayName, prefix, selector, message.sender(), bot.hashing().hash(), bot.hashing().ownerHash()); final PlayerCommandContext context = new PlayerCommandContext(bot, displayName, prefix, selector, message.sender, bot.hashing.hash, bot.hashing.ownerHash);
final Component output = bot.commandHandler().executeCommand(commandString, context, true, false, false, null); final Component output = bot.commandHandler.executeCommand(commandString, context, true, false, false, null);
if (output != null) { if (output != null) {
context.sendOutput(output); context.sendOutput(output);

View file

@ -19,8 +19,6 @@ import land.chipmunk.chayapak.chomens_bot.data.chat.PlayerMessage;
import land.chipmunk.chayapak.chomens_bot.util.ComponentUtilities; import land.chipmunk.chayapak.chomens_bot.util.ComponentUtilities;
import land.chipmunk.chayapak.chomens_bot.util.IllegalCharactersUtilities; import land.chipmunk.chayapak.chomens_bot.util.IllegalCharactersUtilities;
import land.chipmunk.chayapak.chomens_bot.util.UUIDUtilities; import land.chipmunk.chayapak.chomens_bot.util.UUIDUtilities;
import lombok.Getter;
import lombok.Setter;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TranslatableComponent; import net.kyori.adventure.text.TranslatableComponent;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
@ -43,14 +41,14 @@ public class ChatPlugin extends Bot.Listener {
private final List<String> queue = new ArrayList<>(); private final List<String> queue = new ArrayList<>();
@Getter @Setter private int queueDelay; public int queueDelay;
private final List<Listener> listeners = new ArrayList<>(); private final List<Listener> listeners = new ArrayList<>();
public ChatPlugin (Bot bot) { public ChatPlugin (Bot bot) {
this.bot = bot; this.bot = bot;
queueDelay = bot.options().chatQueueDelay(); queueDelay = bot.options.chatQueueDelay;
this.commandSpyParser = new CommandSpyParser(bot); this.commandSpyParser = new CommandSpyParser(bot);
@ -62,7 +60,7 @@ public class ChatPlugin extends Bot.Listener {
chatParsers.add(new U203aChatParser(bot)); chatParsers.add(new U203aChatParser(bot));
chatParsers.add(new CreayunChatParser(bot)); chatParsers.add(new CreayunChatParser(bot));
bot.executor().scheduleAtFixedRate(this::sendChatTick, 0, queueDelay, TimeUnit.MILLISECONDS); bot.executor.scheduleAtFixedRate(this::sendChatTick, 0, queueDelay, TimeUnit.MILLISECONDS);
} }
@Override @Override
@ -121,7 +119,7 @@ public class ChatPlugin extends Bot.Listener {
public void packetReceived (ClientboundPlayerChatPacket packet) { public void packetReceived (ClientboundPlayerChatPacket packet) {
final UUID senderUUID = packet.getSender(); final UUID senderUUID = packet.getSender();
final MutablePlayerListEntry entry = bot.players().getEntry(senderUUID); final MutablePlayerListEntry entry = bot.players.getEntry(senderUUID);
if (entry == null) return; if (entry == null) return;
@ -144,11 +142,11 @@ public class ChatPlugin extends Bot.Listener {
if (translation.equals("chat.type.team.text") || translation.equals("chat.type.team.sent")) { // ohio if (translation.equals("chat.type.team.text") || translation.equals("chat.type.team.sent")) { // ohio
component = component.args( component = component.args(
Component.empty(), // TODO: fix team name.,., Component.empty(), // TODO: fix team name.,.,
playerMessage.displayName(), playerMessage.displayName,
playerMessage.contents() playerMessage.contents
); );
} else { } else {
component = component.args(playerMessage.displayName(), playerMessage.contents()); component = component.args(playerMessage.displayName, playerMessage.contents);
} }
listener.systemMessageReceived(component); listener.systemMessageReceived(component);
@ -196,7 +194,7 @@ public class ChatPlugin extends Bot.Listener {
if (parsed == null) continue; if (parsed == null) continue;
final PlayerMessage playerMessage = new PlayerMessage(parsed.sender(), packet.getName(), parsed.contents()); final PlayerMessage playerMessage = new PlayerMessage(parsed.sender, packet.getName(), parsed.contents);
for (Listener listener : listeners) { for (Listener listener : listeners) {
listener.playerMessageReceived(playerMessage); listener.playerMessageReceived(playerMessage);
@ -205,7 +203,7 @@ public class ChatPlugin extends Bot.Listener {
} else { } else {
if (parsedFromMessage == null) return; if (parsedFromMessage == null) return;
final PlayerMessage playerMessage = new PlayerMessage(parsedFromMessage.sender(), packet.getName(), parsedFromMessage.contents()); final PlayerMessage playerMessage = new PlayerMessage(parsedFromMessage.sender, packet.getName(), parsedFromMessage.contents);
for (Listener listener : listeners) { for (Listener listener : listeners) {
listener.playerMessageReceived(playerMessage); listener.playerMessageReceived(playerMessage);
@ -227,7 +225,7 @@ public class ChatPlugin extends Bot.Listener {
final String[] splittedSpace = removedMessage.split("\\s+"); // [minecraft:test, arg1, arg2, ...] final String[] splittedSpace = removedMessage.split("\\s+"); // [minecraft:test, arg1, arg2, ...]
final String[] splittedColon = splittedSpace[0].split(":"); // [minecraft, test] final String[] splittedColon = splittedSpace[0].split(":"); // [minecraft, test]
if (bot.options().removeNamespaces() && splittedColon.length >= 2) { if (bot.options.removeNamespaces && splittedColon.length >= 2) {
removedMessage = String.join(":", Arrays.copyOfRange(splittedColon, 1, splittedColon.length)); removedMessage = String.join(":", Arrays.copyOfRange(splittedColon, 1, splittedColon.length));
if (splittedSpace.length > 1) { if (splittedSpace.length > 1) {
@ -236,7 +234,7 @@ public class ChatPlugin extends Bot.Listener {
} }
} }
bot.session().send(new ServerboundChatCommandPacket( bot.session.send(new ServerboundChatCommandPacket(
removedMessage, removedMessage,
Instant.now().toEpochMilli(), Instant.now().toEpochMilli(),
0L, 0L,
@ -245,7 +243,7 @@ public class ChatPlugin extends Bot.Listener {
new BitSet() new BitSet()
)); ));
} else { } else {
bot.session().send(new ServerboundChatPacket( bot.session.send(new ServerboundChatPacket(
message, message,
Instant.now().toEpochMilli(), Instant.now().toEpochMilli(),
0L, 0L,
@ -290,13 +288,13 @@ public class ChatPlugin extends Bot.Listener {
} }
public void tellraw (Component component, String targets) { public void tellraw (Component component, String targets) {
if (bot.options().useChat()) { if (bot.options.useChat) {
if (!targets.equals("@a")) return; // worst fix of all time!1! if (!targets.equals("@a")) return; // worst fix of all time!1!
final String stringified = ComponentUtilities.stringifyMotd(component).replace("§", "&"); final String stringified = ComponentUtilities.stringifyMotd(component).replace("§", "&");
send(stringified); send(stringified);
} else { } else {
bot.core().run("minecraft:tellraw " + targets + " " + GsonComponentSerializer.gson().serialize(component)); bot.core.run("minecraft:tellraw " + targets + " " + GsonComponentSerializer.gson().serialize(component));
} }
} }
@ -305,8 +303,8 @@ public class ChatPlugin extends Bot.Listener {
public void tellraw (Component component) { tellraw(component, "@a"); } public void tellraw (Component component) { tellraw(component, "@a"); }
public void actionBar (Component component, String targets) { public void actionBar (Component component, String targets) {
if (bot.options().useChat()) return; if (bot.options.useChat) return;
bot.core().run("minecraft:title " + targets + " actionbar " + GsonComponentSerializer.gson().serialize(component)); bot.core.run("minecraft:title " + targets + " actionbar " + GsonComponentSerializer.gson().serialize(component));
} }
public void actionBar (Component component, UUID uuid) { actionBar(component, UUIDUtilities.selector(uuid)); } public void actionBar (Component component, UUID uuid) { actionBar(component, UUIDUtilities.selector(uuid)); }

View file

@ -2,7 +2,6 @@ package land.chipmunk.chayapak.chomens_bot.plugins;
import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.Bot;
import land.chipmunk.chayapak.chomens_bot.data.CommandLoop; import land.chipmunk.chayapak.chomens_bot.data.CommandLoop;
import lombok.Getter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -12,20 +11,19 @@ import java.util.concurrent.TimeUnit;
public class CloopPlugin { public class CloopPlugin {
private final Bot bot; private final Bot bot;
// too lazy to use executor
private final List<ScheduledFuture<?>> loopTasks = new ArrayList<>(); private final List<ScheduledFuture<?>> loopTasks = new ArrayList<>();
@Getter private final List<CommandLoop> loops = new ArrayList<>(); public final List<CommandLoop> loops = new ArrayList<>();
public CloopPlugin (Bot bot) { public CloopPlugin (Bot bot) {
this.bot = bot; this.bot = bot;
} }
public void add (int interval, String command) { public void add (int interval, String command) {
Runnable loopTask = () -> bot.core().run(command); Runnable loopTask = () -> bot.core.run(command);
loops.add(new CommandLoop(command, interval)); // mabe,.,.. loops.add(new CommandLoop(command, interval)); // mabe,.,..
// should i use 50 or 0? // should i use 50 or 0?
loopTasks.add(bot.executor().scheduleAtFixedRate(loopTask, 0, interval, TimeUnit.MILLISECONDS)); loopTasks.add(bot.executor.scheduleAtFixedRate(loopTask, 0, interval, TimeUnit.MILLISECONDS));
} }
public void remove (int index) { public void remove (int index) {

View file

@ -6,8 +6,6 @@ import land.chipmunk.chayapak.chomens_bot.command.CommandContext;
import land.chipmunk.chayapak.chomens_bot.command.TrustLevel; import land.chipmunk.chayapak.chomens_bot.command.TrustLevel;
import land.chipmunk.chayapak.chomens_bot.commands.*; import land.chipmunk.chayapak.chomens_bot.commands.*;
import land.chipmunk.chayapak.chomens_bot.util.ExceptionUtilities; import land.chipmunk.chayapak.chomens_bot.util.ExceptionUtilities;
import lombok.Getter;
import lombok.Setter;
import net.dv8tion.jda.api.entities.Member; import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Role; import net.dv8tion.jda.api.entities.Role;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent; import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
@ -22,9 +20,9 @@ import java.util.List;
public class CommandHandlerPlugin { public class CommandHandlerPlugin {
private final Bot bot; private final Bot bot;
@Getter private final List<Command> commands = new ArrayList<>(); public final List<Command> commands = new ArrayList<>();
@Getter @Setter private boolean disabled = false; public boolean disabled = false;
public CommandHandlerPlugin (Bot bot) { public CommandHandlerPlugin (Bot bot) {
this.bot = bot; this.bot = bot;
@ -97,18 +95,18 @@ public class CommandHandlerPlugin {
if (command == null && !inGame) return Component.text("Unknown command: " + commandName).color(NamedTextColor.RED); if (command == null && !inGame) return Component.text("Unknown command: " + commandName).color(NamedTextColor.RED);
else if (command == null) return null; else if (command == null) return null;
final TrustLevel trustLevel = command.trustLevel(); final TrustLevel trustLevel = command.trustLevel;
final String[] fullArgs = Arrays.copyOfRange(splitInput, 1, splitInput.length); final String[] fullArgs = Arrays.copyOfRange(splitInput, 1, splitInput.length);
// TODO: improve these minimum args and maximum args stuff, the current one really sucks.,., // TODO: improve these minimum args and maximum args stuff, the current one really sucks.,.,
final int shortestUsageIndex = getShortestUsageIndex(command.usages()); final int shortestUsageIndex = getShortestUsageIndex(command.usages);
final int longestUsageIndex = getLongestUsageIndex(command.usages()); final int longestUsageIndex = getLongestUsageIndex(command.usages);
final String shortestUsage = shortestUsageIndex == 0 && command.usages().length == 0 ? "" : command.usages()[shortestUsageIndex]; final String shortestUsage = shortestUsageIndex == 0 && command.usages.length == 0 ? "" : command.usages[shortestUsageIndex];
final String longestUsage = longestUsageIndex == 0 && command.usages().length == 0 ? "" : command.usages()[longestUsageIndex]; final String longestUsage = longestUsageIndex == 0 && command.usages.length == 0 ? "" : command.usages[longestUsageIndex];
final int minimumArgs = getMinimumArgs(shortestUsage, inGame, command.trustLevel()); final int minimumArgs = getMinimumArgs(shortestUsage, inGame, command.trustLevel);
final int maximumArgs = getMaximumArgs(longestUsage, inGame, command.trustLevel()); final int maximumArgs = getMaximumArgs(longestUsage, inGame, command.trustLevel);
if (fullArgs.length < minimumArgs) return Component.text("Excepted minimum of " + minimumArgs + " argument(s), got " + fullArgs.length).color(NamedTextColor.RED); if (fullArgs.length < minimumArgs) return Component.text("Excepted minimum of " + minimumArgs + " argument(s), got " + fullArgs.length).color(NamedTextColor.RED);
if (fullArgs.length > maximumArgs && !longestUsage.contains("{")) return Component.text("Too many arguments, expected " + maximumArgs + " max").color(NamedTextColor.RED); if (fullArgs.length > maximumArgs && !longestUsage.contains("{")) return Component.text("Too many arguments, expected " + maximumArgs + " max").color(NamedTextColor.RED);
@ -119,7 +117,7 @@ public class CommandHandlerPlugin {
final String[] args = Arrays.copyOfRange(splitInput, (trustLevel != TrustLevel.PUBLIC && inGame) ? 2 : 1, splitInput.length); final String[] args = Arrays.copyOfRange(splitInput, (trustLevel != TrustLevel.PUBLIC && inGame) ? 2 : 1, splitInput.length);
if (command.trustLevel() != TrustLevel.PUBLIC && !console) { if (command.trustLevel != TrustLevel.PUBLIC && !console) {
if (discord) { if (discord) {
final Member member = event.getMember(); final Member member = event.getMember();
@ -127,29 +125,29 @@ public class CommandHandlerPlugin {
final List<Role> roles = member.getRoles(); final List<Role> roles = member.getRoles();
final String trustedRoleName = bot.config().discord().trustedRoleName(); final String trustedRoleName = bot.config.discord.trustedRoleName;
final String adminRoleName = bot.config().discord().adminRoleName(); final String adminRoleName = bot.config.discord.adminRoleName;
if ( if (
command.trustLevel() == TrustLevel.TRUSTED && command.trustLevel == TrustLevel.TRUSTED &&
roles.stream().noneMatch(role -> role.getName().equalsIgnoreCase(trustedRoleName)) && roles.stream().noneMatch(role -> role.getName().equalsIgnoreCase(trustedRoleName)) &&
roles.stream().noneMatch(role -> role.getName().equalsIgnoreCase(adminRoleName)) roles.stream().noneMatch(role -> role.getName().equalsIgnoreCase(adminRoleName))
) return Component.text("You're not in the trusted role!").color(NamedTextColor.RED); ) return Component.text("You're not in the trusted role!").color(NamedTextColor.RED);
if ( if (
command.trustLevel() == TrustLevel.OWNER && command.trustLevel == TrustLevel.OWNER &&
roles.stream().noneMatch(role -> role.getName().equalsIgnoreCase(adminRoleName)) roles.stream().noneMatch(role -> role.getName().equalsIgnoreCase(adminRoleName))
) return Component.text("You're not in the admin role!").color(NamedTextColor.RED); ) return Component.text("You're not in the admin role!").color(NamedTextColor.RED);
} else { } else {
if ( if (
command.trustLevel() == TrustLevel.TRUSTED && command.trustLevel == TrustLevel.TRUSTED &&
!userHash.equals(bot.hashing().hash()) && !userHash.equals(bot.hashing.hash) &&
!userHash.equals(bot.hashing().ownerHash()) !userHash.equals(bot.hashing.ownerHash)
) return Component.text("Invalid hash").color(NamedTextColor.RED); ) return Component.text("Invalid hash").color(NamedTextColor.RED);
if ( if (
command.trustLevel() == TrustLevel.OWNER && command.trustLevel == TrustLevel.OWNER &&
!userHash.equals(bot.hashing().ownerHash()) !userHash.equals(bot.hashing.ownerHash)
) return Component.text("Invalid OwnerHash").color(NamedTextColor.RED); ) return Component.text("Invalid OwnerHash").color(NamedTextColor.RED);
} }
} }
@ -161,7 +159,7 @@ public class CommandHandlerPlugin {
final String stackTrace = ExceptionUtilities.getStacktrace(e); final String stackTrace = ExceptionUtilities.getStacktrace(e);
if (inGame) { if (inGame) {
if (bot.options().useChat() || !bot.options().useCore()) return Component.text(e.toString()).color(NamedTextColor.RED); if (bot.options.useChat || !bot.options.useCore) return Component.text(e.toString()).color(NamedTextColor.RED);
return Component return Component
.text("An error occurred while trying to execute the command, hover here for stacktrace", NamedTextColor.RED) .text("An error occurred while trying to execute the command, hover here for stacktrace", NamedTextColor.RED)
.hoverEvent( .hoverEvent(
@ -181,8 +179,8 @@ public class CommandHandlerPlugin {
for (Command command : commands) { for (Command command : commands) {
if ( if (
( (
command.name().equals(searchTerm.toLowerCase()) || command.name.equals(searchTerm.toLowerCase()) ||
Arrays.stream(command.aliases()).toList().contains(searchTerm.toLowerCase()) Arrays.stream(command.aliases).toList().contains(searchTerm.toLowerCase())
) && ) &&
!searchTerm.equals("") // ig yup !searchTerm.equals("") // ig yup
) { ) {

View file

@ -2,8 +2,6 @@ package land.chipmunk.chayapak.chomens_bot.plugins;
import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.Bot;
import land.chipmunk.chayapak.chomens_bot.command.Command; import land.chipmunk.chayapak.chomens_bot.command.Command;
import lombok.Getter;
import lombok.Setter;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.JoinConfiguration; import net.kyori.adventure.text.JoinConfiguration;
import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.TextComponent;
@ -14,11 +12,11 @@ import java.util.List;
public class CommandSuggestionPlugin extends ChatPlugin.Listener { public class CommandSuggestionPlugin extends ChatPlugin.Listener {
private final Bot bot; private final Bot bot;
@Getter @Setter private String id = "chomens_bot_command_suggestion"; public String id = "chomens_bot_command_suggestion";
public CommandSuggestionPlugin (Bot bot) { public CommandSuggestionPlugin (Bot bot) {
this.bot = bot; this.bot = bot;
bot.chat().addListener(this); bot.chat.addListener(this);
} }
@Override @Override
@ -47,13 +45,13 @@ public class CommandSuggestionPlugin extends ChatPlugin.Listener {
output.add(Component.text(id)); output.add(Component.text(id));
output.add(Component.text(transactionId)); output.add(Component.text(transactionId));
for (Command command : bot.commandHandler().commands()) { for (Command command : bot.commandHandler.commands) {
if (!command.name().startsWith(input)) continue; if (!command.name.startsWith(input)) continue;
output.add(Component.text(command.name())); output.add(Component.text(command.name));
} }
bot.chat().tellraw(Component.join(JoinConfiguration.noSeparators(), output), player); bot.chat.tellraw(Component.join(JoinConfiguration.noSeparators(), output), player);
} catch (Exception ignored) {} } catch (Exception ignored) {}
} }
} }

View file

@ -5,7 +5,6 @@ import land.chipmunk.chayapak.chomens_bot.Configuration;
import land.chipmunk.chayapak.chomens_bot.Main; import land.chipmunk.chayapak.chomens_bot.Main;
import land.chipmunk.chayapak.chomens_bot.command.ConsoleCommandContext; import land.chipmunk.chayapak.chomens_bot.command.ConsoleCommandContext;
import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities; import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities;
import lombok.Getter;
import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.JDA;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.NamedTextColor;
@ -19,12 +18,12 @@ import java.util.List;
public class ConsolePlugin { public class ConsolePlugin {
private final List<Bot> allBots; private final List<Bot> allBots;
@Getter public final LineReader reader; public final LineReader reader;
@Getter private String consoleServer = "all"; public String consoleServer = "all";
@Getter private String prefix; public String prefix;
@Getter private String consoleServerPrefix; public String consoleServerPrefix;
private static final List<Listener> listeners = new ArrayList<>(); private static final List<Listener> listeners = new ArrayList<>();
@ -35,12 +34,12 @@ public class ConsolePlugin {
reader.option(LineReader.Option.DISABLE_EVENT_EXPANSION, true); reader.option(LineReader.Option.DISABLE_EVENT_EXPANSION, true);
for (Bot bot : allBots) { for (Bot bot : allBots) {
prefix = bot.config().consolePrefixes().normalCommandsPrefix(); prefix = bot.config.consolePrefixes.normalCommandsPrefix;
consoleServerPrefix = bot.config().consolePrefixes().consoleServerPrefix(); consoleServerPrefix = bot.config.consolePrefixes.consoleServerPrefix;
bot.console(this); bot.console = this;
bot.logger(new LoggerPlugin(bot)); bot.logger = new LoggerPlugin(bot);
} }
new DiscordPlugin(discordConfig, jda); new DiscordPlugin(discordConfig, jda);
@ -77,18 +76,18 @@ public class ConsolePlugin {
final List<String> servers = new ArrayList<>(); final List<String> servers = new ArrayList<>();
for (Bot bot : allBots) { for (Bot bot : allBots) {
servers.add(bot.host() + ":" + bot.port()); servers.add(bot.host + ":" + bot.port);
} }
for (Bot bot : allBots) { for (Bot bot : allBots) {
if (args.length == 0) { if (args.length == 0) {
bot.logger().info("No server specified"); bot.logger.info("No server specified");
return; return;
} }
if (String.join(" ", args).equalsIgnoreCase("all")) { if (String.join(" ", args).equalsIgnoreCase("all")) {
consoleServer = "all"; consoleServer = "all";
bot.logger().info("Set the console server to all servers"); bot.logger.info("Set the console server to all servers");
return; return;
} }
try { try {
@ -97,9 +96,9 @@ public class ConsolePlugin {
.filter(server -> server.toLowerCase().contains(String.join(" ", args))) .filter(server -> server.toLowerCase().contains(String.join(" ", args)))
.toArray(String[]::new)[0]; .toArray(String[]::new)[0];
bot.logger().info("Set the console server to " + String.join(", ", consoleServer)); bot.logger.info("Set the console server to " + String.join(", ", consoleServer));
} catch (ArrayIndexOutOfBoundsException e) { } catch (ArrayIndexOutOfBoundsException e) {
bot.logger().info("Invalid server: " + String.join(" ", args)); bot.logger.info("Invalid server: " + String.join(" ", args));
} }
} }
} }
@ -108,14 +107,14 @@ public class ConsolePlugin {
} }
for (Bot bot : allBots) { for (Bot bot : allBots) {
final String hostAndPort = bot.host() + ":" + bot.port(); final String hostAndPort = bot.host + ":" + bot.port;
if (!hostAndPort.equals(consoleServer) && !consoleServer.equals("all")) continue; if (!hostAndPort.equals(consoleServer) && !consoleServer.equals("all")) continue;
if (line.startsWith(prefix)) { if (line.startsWith(prefix)) {
final ConsoleCommandContext context = new ConsoleCommandContext(bot, prefix); final ConsoleCommandContext context = new ConsoleCommandContext(bot, prefix);
final Component output = bot.commandHandler().executeCommand(line.substring(prefix.length()), context, false, false, true, null); final Component output = bot.commandHandler.executeCommand(line.substring(prefix.length()), context, false, false, true, null);
if (output != null) { if (output != null) {
context.sendOutput(output); context.sendOutput(output);
@ -124,11 +123,11 @@ public class ConsolePlugin {
continue; continue;
} }
bot.chat().tellraw( bot.chat.tellraw(
Component.translatable( Component.translatable(
"[%s] %s %s", "[%s] %s %s",
Component.text(bot.username() + " Console").color(NamedTextColor.GRAY), Component.text(bot.username + " Console").color(NamedTextColor.GRAY),
Component.text(bot.config().ownerName()).color(ColorUtilities.getColorByString(bot.config().colorPalette().ownerName())), Component.text(bot.config.ownerName).color(ColorUtilities.getColorByString(bot.config.colorPalette.ownerName)),
Component.text(line).color(NamedTextColor.GRAY) Component.text(line).color(NamedTextColor.GRAY)
).color(NamedTextColor.DARK_GRAY) ).color(NamedTextColor.DARK_GRAY)
); );

View file

@ -5,7 +5,6 @@ import com.github.steveice10.mc.protocol.data.game.entity.object.Direction;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerAction; import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerAction;
import com.github.steveice10.mc.protocol.data.game.level.block.BlockChangeEntry; import com.github.steveice10.mc.protocol.data.game.level.block.BlockChangeEntry;
import com.github.steveice10.mc.protocol.data.game.level.block.BlockEntityInfo;
import com.github.steveice10.mc.protocol.data.game.level.block.CommandBlockMode; import com.github.steveice10.mc.protocol.data.game.level.block.CommandBlockMode;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundBlockUpdatePacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundBlockUpdatePacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundLevelChunkWithLightPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundLevelChunkWithLightPacket;
@ -23,7 +22,6 @@ import com.github.steveice10.packetlib.Session;
import com.github.steveice10.packetlib.event.session.DisconnectedEvent; import com.github.steveice10.packetlib.event.session.DisconnectedEvent;
import com.github.steveice10.packetlib.packet.Packet; import com.github.steveice10.packetlib.packet.Packet;
import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.Bot;
import lombok.Getter;
import org.cloudburstmc.math.vector.Vector3i; import org.cloudburstmc.math.vector.Vector3i;
import java.util.ArrayList; import java.util.ArrayList;
@ -37,9 +35,9 @@ import java.util.concurrent.TimeUnit;
public class CorePlugin extends PositionPlugin.Listener { public class CorePlugin extends PositionPlugin.Listener {
private final Bot bot; private final Bot bot;
@Getter private final List<Listener> listeners = new ArrayList<>(); private final List<Listener> listeners = new ArrayList<>();
@Getter private boolean ready = false; public boolean ready = false;
private ScheduledFuture<?> refillTask; private ScheduledFuture<?> refillTask;
@ -56,30 +54,30 @@ public class CorePlugin extends PositionPlugin.Listener {
private final boolean kaboom; private final boolean kaboom;
@Getter private int commandsPerSecond = 0; private int commandsPerSecond = 0;
public CorePlugin (Bot bot) { public CorePlugin (Bot bot) {
this.bot = bot; this.bot = bot;
this.kaboom = bot.options().kaboom(); this.kaboom = bot.options.kaboom;
this.fromSize = Vector3i.from( this.fromSize = Vector3i.from(
bot.config().core().start().x(), bot.config.core.start.x,
bot.config().core().start().y(), bot.config.core.start.y,
bot.config().core().start().z() bot.config.core.start.z
); );
this.toSize = Vector3i.from( this.toSize = Vector3i.from(
bot.config().core().end().x(), bot.config.core.end.x,
bot.config().core().end().y(), bot.config.core.end.y,
bot.config().core().end().z() bot.config.core.end.z
); );
bot.position().addListener(this); bot.position.addListener(this);
if (hasRateLimit() && hasReset()) { if (hasRateLimit() && hasReset()) {
bot.executor().scheduleAtFixedRate( bot.executor.scheduleAtFixedRate(
() -> commandsPerSecond = 0, () -> commandsPerSecond = 0,
0, 0,
bot.options().coreRateLimit().reset(), bot.options.coreRateLimit.reset,
TimeUnit.MILLISECONDS TimeUnit.MILLISECONDS
); );
} }
@ -105,19 +103,19 @@ public class CorePlugin extends PositionPlugin.Listener {
} }
public boolean hasRateLimit () { public boolean hasRateLimit () {
return bot.options().coreRateLimit().limit() > 0; return bot.options.coreRateLimit.limit > 0;
} }
public boolean hasReset () { public boolean hasReset () {
return bot.options().coreRateLimit().reset() > 0; return bot.options.coreRateLimit.reset > 0;
} }
public boolean isRateLimited () { public boolean isRateLimited () {
return commandsPerSecond > bot.options().coreRateLimit().limit(); return commandsPerSecond > bot.options.coreRateLimit.limit;
} }
private void forceRun (String command) { private void forceRun (String command) {
bot.session().send(new ServerboundSetCommandBlockPacket( bot.session.send(new ServerboundSetCommandBlockPacket(
block, block,
command, command,
kaboom ? CommandBlockMode.AUTO : CommandBlockMode.REDSTONE, kaboom ? CommandBlockMode.AUTO : CommandBlockMode.REDSTONE,
@ -132,21 +130,21 @@ public class CorePlugin extends PositionPlugin.Listener {
public void run (String command) { public void run (String command) {
if (!ready || command.length() > 32767) return; if (!ready || command.length() > 32767) return;
if (bot.options().useCore()) { if (bot.options.useCore) {
if (isRateLimited() && hasRateLimit()) return; if (isRateLimited() && hasRateLimit()) return;
forceRun(command); forceRun(command);
if (hasRateLimit()) commandsPerSecond++; if (hasRateLimit()) commandsPerSecond++;
} else if (command.length() < 256) { } else if (command.length() < 256) {
bot.chat().send("/" + command); bot.chat.send("/" + command);
} }
} }
public CompletableFuture<CompoundTag> runTracked (String command) { public CompletableFuture<CompoundTag> runTracked (String command) {
run(command); run(command);
if (!bot.options().useCore()) return null; if (!bot.options.useCore) return null;
final int transactionId = nextTransactionId++; final int transactionId = nextTransactionId++;
@ -154,15 +152,15 @@ public class CorePlugin extends PositionPlugin.Listener {
final CompletableFuture<CompoundTag> future = new CompletableFuture<>(); final CompletableFuture<CompoundTag> future = new CompletableFuture<>();
transactions.put(transactionId, future); transactions.put(transactionId, future);
final Runnable afterTick = () -> bot.session().send(new ServerboundBlockEntityTagQuery(transactionId, block)); final Runnable afterTick = () -> bot.session.send(new ServerboundBlockEntityTagQuery(transactionId, block));
bot.executor().schedule(afterTick, 50, TimeUnit.MILLISECONDS); bot.executor.schedule(afterTick, 50, TimeUnit.MILLISECONDS);
return future; return future;
} }
public void runPlaceBlock (String command) { public void runPlaceBlock (String command) {
if (!ready || !bot.options().useCore()) return; if (!ready || !bot.options.useCore) return;
final CompoundTag tag = new CompoundTag(""); final CompoundTag tag = new CompoundTag("");
final CompoundTag blockEntityTag = new CompoundTag("BlockEntityTag"); final CompoundTag blockEntityTag = new CompoundTag("BlockEntityTag");
@ -172,12 +170,12 @@ public class CorePlugin extends PositionPlugin.Listener {
tag.put(blockEntityTag); tag.put(blockEntityTag);
final Vector3i temporaryBlockPosition = Vector3i.from( final Vector3i temporaryBlockPosition = Vector3i.from(
bot.position().position().getX(), bot.position.position.getX(),
bot.position().position().getY() - 1, bot.position.position.getY() - 1,
bot.position().position().getZ() bot.position.position.getZ()
); );
final Session session = bot.session(); final Session session = bot.session;
session.send(new ServerboundSetCreativeModeSlotPacket(36, new ItemStack(kaboom ? 492 /* repeating command block id */ : 373 /* command block id */, 64, tag))); session.send(new ServerboundSetCreativeModeSlotPacket(36, new ItemStack(kaboom ? 492 /* repeating command block id */ : 373 /* command block id */, 64, tag)));
session.send(new ServerboundPlayerActionPacket(PlayerAction.START_DIGGING, temporaryBlockPosition, Direction.NORTH, 0)); session.send(new ServerboundPlayerActionPacket(PlayerAction.START_DIGGING, temporaryBlockPosition, Direction.NORTH, 0));
session.send(new ServerboundUseItemOnPacket(temporaryBlockPosition, Direction.UP, Hand.MAIN_HAND, 0.5f, 0.5f, 0.5f, false, 1)); session.send(new ServerboundUseItemOnPacket(temporaryBlockPosition, Direction.UP, Hand.MAIN_HAND, 0.5f, 0.5f, 0.5f, false, 1));
@ -275,15 +273,15 @@ public class CorePlugin extends PositionPlugin.Listener {
@Override @Override
public void positionChange (Vector3i position) { public void positionChange (Vector3i position) {
from = Vector3i.from( from = Vector3i.from(
fromSize.getX() + bot.position().position().getX(), fromSize.getX() + bot.position.position.getX(),
fromSize.getY(), fromSize.getY(),
fromSize.getZ() + bot.position().position().getZ() fromSize.getZ() + bot.position.position.getZ()
); );
to = Vector3i.from( to = Vector3i.from(
toSize.getX() + bot.position().position().getX(), toSize.getX() + bot.position.position.getX(),
toSize.getY(), toSize.getY(),
toSize.getZ() + bot.position().position().getZ() toSize.getZ() + bot.position.position.getZ()
); );
reset(); reset();
@ -292,7 +290,7 @@ public class CorePlugin extends PositionPlugin.Listener {
if (!ready) { if (!ready) {
ready = true; ready = true;
refillTask = bot.executor().scheduleAtFixedRate(this::refill, 0, bot.config().core().refillInterval(), TimeUnit.MILLISECONDS); refillTask = bot.executor.scheduleAtFixedRate(this::refill, 0, bot.config.core.refillInterval, TimeUnit.MILLISECONDS);
for (Listener listener : listeners) listener.ready(); for (Listener listener : listeners) listener.ready();
} }
} }
@ -315,10 +313,10 @@ public class CorePlugin extends PositionPlugin.Listener {
to.getY(), to.getY(),
to.getZ(), to.getZ(),
bot.config().core().customName() bot.config.core.customName
); );
// bot.chat().send(command); // bot.chat.send(command);
runPlaceBlock(command); runPlaceBlock(command);
} }

View file

@ -9,7 +9,6 @@ import land.chipmunk.chayapak.chomens_bot.command.DiscordCommandContext;
import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities; import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities;
import land.chipmunk.chayapak.chomens_bot.util.ComponentUtilities; import land.chipmunk.chayapak.chomens_bot.util.ComponentUtilities;
import land.chipmunk.chayapak.chomens_bot.util.CodeBlockUtilities; import land.chipmunk.chayapak.chomens_bot.util.CodeBlockUtilities;
import lombok.Getter;
import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.entities.*; import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent; import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
@ -30,34 +29,34 @@ import java.util.List;
// please ignore my ohio code // please ignore my ohio code
// also this is one of the classes which has >100 lines or actually >300 LMAO // also this is one of the classes which has >100 lines or actually >300 LMAO
public class DiscordPlugin { public class DiscordPlugin {
@Getter private JDA jda; public JDA jda;
public final Map<String, String> servers; public final Map<String, String> servers;
public final String prefix; public final String prefix;
public DiscordPlugin (Configuration config, JDA jda) { public DiscordPlugin (Configuration config, JDA jda) {
final Configuration.Discord options = config.discord(); final Configuration.Discord options = config.discord;
this.prefix = options.prefix(); this.prefix = options.prefix;
this.servers = options.servers(); this.servers = options.servers;
this.jda = jda; this.jda = jda;
if (jda == null) return; if (jda == null) return;
for (Bot bot : Main.bots) { for (Bot bot : Main.bots) {
final String channelId = servers.get(bot.host() + ":" + bot.port()); final String channelId = servers.get(bot.host + ":" + bot.port);
bot.addListener(new Bot.Listener() { bot.addListener(new Bot.Listener() {
@Override @Override
public void loadedPlugins() { public void loadedPlugins() {
bot.tick().addListener(new TickPlugin.Listener() { bot.tick.addListener(new TickPlugin.Listener() {
@Override @Override
public void onTick() { public void onTick() {
onDiscordTick(channelId); onDiscordTick(channelId);
} }
}); });
bot.chat().addListener(new ChatPlugin.Listener() { bot.chat.addListener(new ChatPlugin.Listener() {
@Override @Override
public void systemMessageReceived (Component component) { public void systemMessageReceived (Component component) {
final String content = ComponentUtilities.stringifyAnsi(component); final String content = ComponentUtilities.stringifyAnsi(component);
@ -71,8 +70,8 @@ public class DiscordPlugin {
sendMessageInstantly( sendMessageInstantly(
String.format( String.format(
"Connecting to: `%s:%s`", "Connecting to: `%s:%s`",
bot.host(), bot.host,
bot.port() bot.port
), ),
channelId channelId
); );
@ -83,8 +82,8 @@ public class DiscordPlugin {
sendMessageInstantly( sendMessageInstantly(
String.format( String.format(
"Successfully connected to: `%s:%s`", "Successfully connected to: `%s:%s`",
bot.host(), bot.host,
bot.port() bot.port
), ),
channelId channelId
); );
@ -110,7 +109,7 @@ public class DiscordPlugin {
if ( if (
!event.getChannel().getId().equals(channelId) || !event.getChannel().getId().equals(channelId) ||
event.getAuthor().getId().equals(jda.getSelfUser().getId()) || event.getAuthor().getId().equals(jda.getSelfUser().getId()) ||
!bot.loggedIn() !bot.loggedIn
) return; ) return;
final Message messageEvent = event.getMessage(); final Message messageEvent = event.getMessage();
@ -119,7 +118,7 @@ public class DiscordPlugin {
if (message.startsWith(prefix)) { if (message.startsWith(prefix)) {
final DiscordCommandContext context = new DiscordCommandContext(bot, prefix, event, null, null); final DiscordCommandContext context = new DiscordCommandContext(bot, prefix, event, null, null);
final Component output = bot.commandHandler().executeCommand(message.substring(prefix.length()), context, false, true, false, event); final Component output = bot.commandHandler.executeCommand(message.substring(prefix.length()), context, false, true, false, event);
if (output != null) { if (output != null) {
context.sendOutput(output); context.sendOutput(output);
@ -155,7 +154,7 @@ public class DiscordPlugin {
%s""", %s""",
embed.getTitle() == null ? embed.getTitle() == null ?
Component.text("No title").color(NamedTextColor.GRAY) : Component.text("No title").color(NamedTextColor.GRAY) :
Component.text(embed.getTitle()).color(ColorUtilities.getColorByString(bot.config().colorPalette().string())), Component.text(embed.getTitle()).color(ColorUtilities.getColorByString(bot.config.colorPalette.string)),
embed.getDescription() == null ? embed.getDescription() == null ?
Component.text("No description").color(NamedTextColor.GRAY) : Component.text("No description").color(NamedTextColor.GRAY) :
Component.text(embed.getDescription()).color(NamedTextColor.WHITE) Component.text(embed.getDescription()).color(NamedTextColor.WHITE)
@ -250,7 +249,7 @@ public class DiscordPlugin {
if (nameComponent.color() == null) nameComponent = nameComponent.color(NamedTextColor.RED); if (nameComponent.color() == null) nameComponent = nameComponent.color(NamedTextColor.RED);
final String discordUrl = config.discord().inviteLink(); final String discordUrl = config.discord.inviteLink;
final Component discordComponent = Component.empty() final Component discordComponent = Component.empty()
.append(Component.text("ChomeNS ").color(NamedTextColor.YELLOW)) .append(Component.text("ChomeNS ").color(NamedTextColor.YELLOW))
@ -280,11 +279,11 @@ public class DiscordPlugin {
messageComponent messageComponent
).color(NamedTextColor.DARK_GRAY); ).color(NamedTextColor.DARK_GRAY);
bot.chat().tellraw(component); bot.chat.tellraw(component);
} }
}); });
bot.discord(this); bot.discord = this;
} }
} }

View file

@ -4,7 +4,6 @@ import io.socket.client.IO;
import io.socket.client.Socket; import io.socket.client.Socket;
import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.Bot;
import land.chipmunk.chayapak.chomens_bot.data.EvalOutput; import land.chipmunk.chayapak.chomens_bot.data.EvalOutput;
import lombok.Getter;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -13,7 +12,7 @@ import java.util.concurrent.CompletableFuture;
public class EvalPlugin { public class EvalPlugin {
public static final String BRIDGE_PREFIX = "function:"; public static final String BRIDGE_PREFIX = "function:";
@Getter private boolean connected = false; public boolean connected = false;
private Socket socket = null; private Socket socket = null;
@ -23,7 +22,7 @@ public class EvalPlugin {
public EvalPlugin (Bot bot) { public EvalPlugin (Bot bot) {
try { try {
socket = IO.socket(bot.config().eval().address()); socket = IO.socket(bot.config.eval.address);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -45,13 +44,13 @@ public class EvalPlugin {
socket.on(BRIDGE_PREFIX + "chat", (args) -> { socket.on(BRIDGE_PREFIX + "chat", (args) -> {
final String message = (String) args[0]; final String message = (String) args[0];
bot.chat().send(message); bot.chat.send(message);
}); });
socket.on(BRIDGE_PREFIX + "core", (args) -> { socket.on(BRIDGE_PREFIX + "core", (args) -> {
final String command = (String) args[0]; final String command = (String) args[0];
bot.core().run(command); bot.core.run(command);
}); });
socket.connect(); socket.connect();

View file

@ -9,7 +9,6 @@ import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry;
import land.chipmunk.chayapak.chomens_bot.data.chat.PlayerMessage; import land.chipmunk.chayapak.chomens_bot.data.chat.PlayerMessage;
import land.chipmunk.chayapak.chomens_bot.util.PersistentDataUtilities; import land.chipmunk.chayapak.chomens_bot.util.PersistentDataUtilities;
import land.chipmunk.chayapak.chomens_bot.util.UUIDUtilities; import land.chipmunk.chayapak.chomens_bot.util.UUIDUtilities;
import lombok.Getter;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.NamedTextColor;
@ -19,7 +18,7 @@ import java.util.regex.Pattern;
public class FilterPlugin extends PlayersPlugin.Listener { public class FilterPlugin extends PlayersPlugin.Listener {
private final Bot bot; private final Bot bot;
@Getter private static JsonArray filteredPlayers = new JsonArray(); public static JsonArray filteredPlayers = new JsonArray();
private final Gson gson = new Gson(); private final Gson gson = new Gson();
@ -32,9 +31,9 @@ public class FilterPlugin extends PlayersPlugin.Listener {
public FilterPlugin (Bot bot) { public FilterPlugin (Bot bot) {
this.bot = bot; this.bot = bot;
bot.players().addListener(this); bot.players.addListener(this);
bot.chat().addListener(new ChatPlugin.Listener() { bot.chat.addListener(new ChatPlugin.Listener() {
@Override @Override
public void commandSpyMessageReceived(PlayerMessage message) { public void commandSpyMessageReceived(PlayerMessage message) {
FilterPlugin.this.commandSpyMessageReceived(message); FilterPlugin.this.commandSpyMessageReceived(message);
@ -46,7 +45,7 @@ public class FilterPlugin extends PlayersPlugin.Listener {
} }
}); });
bot.executor().scheduleAtFixedRate(this::kick, 0, 10, TimeUnit.SECONDS); bot.executor.scheduleAtFixedRate(this::kick, 0, 10, TimeUnit.SECONDS);
} }
private FilteredPlayer getPlayer (String name) { private FilteredPlayer getPlayer (String name) {
@ -64,7 +63,7 @@ public class FilterPlugin extends PlayersPlugin.Listener {
try { try {
pattern = Pattern.compile(_filteredPlayer.playerName); pattern = Pattern.compile(_filteredPlayer.playerName);
} catch (Exception e) { } catch (Exception e) {
bot.chat().tellraw(Component.text(e.toString()).color(NamedTextColor.RED)); bot.chat.tellraw(Component.text(e.toString()).color(NamedTextColor.RED));
} }
} }
@ -94,50 +93,50 @@ public class FilterPlugin extends PlayersPlugin.Listener {
@Override @Override
public void playerJoined (MutablePlayerListEntry target) { public void playerJoined (MutablePlayerListEntry target) {
final FilteredPlayer player = getPlayer(target.profile().getName()); final FilteredPlayer player = getPlayer(target.profile.getName());
if (player == null) return; if (player == null) return;
deOp(target); deOp(target);
mute(target); mute(target);
bot.exploits().kick(target.profile().getId()); bot.exploits.kick(target.profile.getId());
} }
public void commandSpyMessageReceived (PlayerMessage message) { public void commandSpyMessageReceived (PlayerMessage message) {
final FilteredPlayer player = getPlayer(message.sender().profile().getName()); final FilteredPlayer player = getPlayer(message.sender.profile.getName());
if (player == null) return; if (player == null) return;
deOp(message.sender()); deOp(message.sender);
} }
public void playerMessageReceived (PlayerMessage message) { public void playerMessageReceived (PlayerMessage message) {
if (message.sender().profile().getName() == null) return; if (message.sender.profile.getName() == null) return;
final FilteredPlayer player = getPlayer(message.sender().profile().getName()); final FilteredPlayer player = getPlayer(message.sender.profile.getName());
if (player == null) return; if (player == null) return;
deOp(message.sender()); deOp(message.sender);
mute(message.sender()); mute(message.sender);
} }
private void mute (MutablePlayerListEntry target) { private void mute (MutablePlayerListEntry target) {
bot.core().run("essentials:mute " + target.profile().getIdAsString() + " 10y"); bot.core.run("essentials:mute " + target.profile.getIdAsString() + " 10y");
} }
private void deOp (MutablePlayerListEntry target) { private void deOp (MutablePlayerListEntry target) {
bot.core().run("minecraft:execute run deop " + UUIDUtilities.selector(target.profile().getId())); bot.core.run("minecraft:execute run deop " + UUIDUtilities.selector(target.profile.getId()));
} }
public void kick () { public void kick () {
for (MutablePlayerListEntry target : bot.players().list()) { for (MutablePlayerListEntry target : bot.players.list) {
final FilteredPlayer player = getPlayer(target.profile().getName()); final FilteredPlayer player = getPlayer(target.profile.getName());
if (player == null) continue; if (player == null) continue;
bot.exploits().kick(target.profile().getId()); bot.exploits.kick(target.profile.getId());
} }
} }
@ -146,7 +145,7 @@ public class FilterPlugin extends PlayersPlugin.Listener {
PersistentDataUtilities.put("filters", filteredPlayers); PersistentDataUtilities.put("filters", filteredPlayers);
final MutablePlayerListEntry target = bot.players().getEntry(playerName); // fix not working for regex and ignorecase final MutablePlayerListEntry target = bot.players.getEntry(playerName); // fix not working for regex and ignorecase
if (target == null) return; if (target == null) return;

View file

@ -3,8 +3,6 @@ package land.chipmunk.chayapak.chomens_bot.plugins;
import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.Bot;
import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities; import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities;
import land.chipmunk.chayapak.chomens_bot.util.FileLoggerUtilities; import land.chipmunk.chayapak.chomens_bot.util.FileLoggerUtilities;
import lombok.Getter;
import lombok.Setter;
import net.dv8tion.jda.api.entities.TextChannel; import net.dv8tion.jda.api.entities.TextChannel;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.NamedTextColor;
@ -19,7 +17,7 @@ import java.util.zip.GZIPInputStream;
public class GrepLogPlugin { public class GrepLogPlugin {
private final Bot bot; private final Bot bot;
@Getter @Setter private Thread thread = null; public Thread thread = null;
public GrepLogPlugin (Bot bot) { public GrepLogPlugin (Bot bot) {
this.bot = bot; this.bot = bot;
@ -56,7 +54,7 @@ public class GrepLogPlugin {
try { try {
pattern = Pattern.compile(query); pattern = Pattern.compile(query);
} catch (Exception e) { } catch (Exception e) {
bot.chat().tellraw(Component.text(e.toString()).color(NamedTextColor.RED)); bot.chat.tellraw(Component.text(e.toString()).color(NamedTextColor.RED));
} }
} }
} else { } else {
@ -68,11 +66,11 @@ public class GrepLogPlugin {
@Override @Override
public void run() { public void run() {
bot.chat().tellraw( bot.chat.tellraw(
Component.translatable( Component.translatable(
"Collecting %s in logs...", "Collecting %s in logs...",
Component.text(query).color(ColorUtilities.getColorByString(bot.config().colorPalette().secondary())) Component.text(query).color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary))
).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())) ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor))
); );
final File[] fileList = FileLoggerUtilities.logDir.listFiles(); final File[] fileList = FileLoggerUtilities.logDir.listFiles();
@ -160,7 +158,7 @@ public class GrepLogPlugin {
private void finish () { private void finish () {
if (results.toString().split("\n").length < 100) { // ig lazy fix for removing \n lol if (results.toString().split("\n").length < 100) { // ig lazy fix for removing \n lol
bot.chat().tellraw( bot.chat.tellraw(
Component.empty() Component.empty()
.append(Component.text("Log query output for \"")) .append(Component.text("Log query output for \""))
.append(Component.text(query)) .append(Component.text(query))
@ -168,17 +166,17 @@ public class GrepLogPlugin {
.append(Component.newline()) .append(Component.newline())
.append(Component.text(results.toString())) .append(Component.text(results.toString()))
); );
} else if (bot.config().discord().enabled()) { } else if (bot.config.discord.enabled) {
bot.chat().tellraw( bot.chat.tellraw(
Component.translatable( Component.translatable(
"Log query for \"%s\" finished, found %s matches. Results were sent in Discord", "Log query for \"%s\" finished, found %s matches. Results were sent in Discord",
Component.text(query).color(ColorUtilities.getColorByString(bot.config().colorPalette().string())), Component.text(query).color(ColorUtilities.getColorByString(bot.config.colorPalette.string)),
Component.text(matches).color(ColorUtilities.getColorByString(bot.config().colorPalette().number())) Component.text(matches).color(ColorUtilities.getColorByString(bot.config.colorPalette.number))
) )
); );
final String channelId = bot.discord().servers.get(bot.host() + ":" + bot.port()); final String channelId = bot.discord.servers.get(bot.host + ":" + bot.port);
final TextChannel logChannel = bot.discord().jda().getTextChannelById(channelId); final TextChannel logChannel = bot.discord.jda.getTextChannelById(channelId);
if (logChannel == null) return; if (logChannel == null) return;

View file

@ -2,22 +2,21 @@ package land.chipmunk.chayapak.chomens_bot.plugins;
import com.google.common.hash.Hashing; import com.google.common.hash.Hashing;
import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.Bot;
import lombok.Getter;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
public class HashingPlugin { public class HashingPlugin {
private final Bot bot; private final Bot bot;
@Getter private String hash; public String hash;
@Getter private String ownerHash; public String ownerHash;
private long lastTime; private long lastTime;
public HashingPlugin (Bot bot) { public HashingPlugin (Bot bot) {
this.bot = bot; this.bot = bot;
bot.tick().addListener(new TickPlugin.Listener() { bot.tick.addListener(new TickPlugin.Listener() {
@Override @Override
public void onTick() { public void onTick() {
update(); update();
@ -32,8 +31,8 @@ public class HashingPlugin {
if (time == lastTime) return; if (time == lastTime) return;
lastTime = time; lastTime = time;
final String normalHashKey = bot.config().keys().normalKey(); final String normalHashKey = bot.config.keys.normalKey;
final String ownerHashKey = bot.config().keys().ownerKey(); final String ownerHashKey = bot.config.keys.ownerKey;
final String hashValue = time + normalHashKey; final String hashValue = time + normalHashKey;
hash = Hashing.sha256() hash = Hashing.sha256()

View file

@ -5,8 +5,6 @@ import com.github.steveice10.packetlib.event.session.DisconnectedEvent;
import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.Bot;
import land.chipmunk.chayapak.chomens_bot.util.FileLoggerUtilities; import land.chipmunk.chayapak.chomens_bot.util.FileLoggerUtilities;
import land.chipmunk.chayapak.chomens_bot.util.ComponentUtilities; import land.chipmunk.chayapak.chomens_bot.util.ComponentUtilities;
import lombok.Getter;
import lombok.Setter;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.NamedTextColor;
@ -18,7 +16,7 @@ public class LoggerPlugin extends ChatPlugin.Listener {
private boolean addedListener = false; private boolean addedListener = false;
@Getter @Setter private boolean logToConsole = true; public boolean logToConsole = true;
private final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm:ss"); private final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm:ss");
@ -31,8 +29,8 @@ public class LoggerPlugin extends ChatPlugin.Listener {
log( log(
String.format( String.format(
"Connecting to: %s:%s", "Connecting to: %s:%s",
bot.host(), bot.host,
bot.port() bot.port
) )
); );
} }
@ -42,20 +40,20 @@ public class LoggerPlugin extends ChatPlugin.Listener {
log( log(
String.format( String.format(
"Successfully connected to: %s:%s", "Successfully connected to: %s:%s",
bot.host(), bot.host,
bot.port() bot.port
) )
); );
if (addedListener) return; if (addedListener) return;
bot.chat().addListener(LoggerPlugin.this); bot.chat.addListener(LoggerPlugin.this);
addedListener = true; addedListener = true;
} }
@Override @Override
public void disconnected (DisconnectedEvent event) { public void disconnected (DisconnectedEvent event) {
final String reason = ComponentUtilities.stringifyAnsi(event.getReason()); final String reason = ComponentUtilities.stringifyAnsi(event.getReason());
log("Disconnected from " + bot.host() + ":" + bot.port() + ", reason: " + reason); log("Disconnected from " + bot.host + ":" + bot.port + ", reason: " + reason);
} }
}); });
} }
@ -68,7 +66,7 @@ public class LoggerPlugin extends ChatPlugin.Listener {
"[%s %s] [%s] %s", "[%s %s] [%s] %s",
Component.text(dateTime.format(dateTimeFormatter)).color(NamedTextColor.GRAY), Component.text(dateTime.format(dateTimeFormatter)).color(NamedTextColor.GRAY),
prefix, prefix,
Component.text(bot.options().serverName()).color(NamedTextColor.GRAY), Component.text(bot.options.serverName).color(NamedTextColor.GRAY),
Component.text(_message).color(NamedTextColor.WHITE) Component.text(_message).color(NamedTextColor.WHITE)
).color(NamedTextColor.DARK_GRAY); ).color(NamedTextColor.DARK_GRAY);
@ -78,12 +76,12 @@ public class LoggerPlugin extends ChatPlugin.Listener {
public void log (String _message) { public void log (String _message) {
final String message = prefix(Component.text("Log").color(NamedTextColor.GOLD), _message); final String message = prefix(Component.text("Log").color(NamedTextColor.GOLD), _message);
if (logToConsole) bot.console().reader().printAbove(message); if (logToConsole) bot.console.reader.printAbove(message);
final String formattedMessage = String.format( final String formattedMessage = String.format(
"[%s] %s", "[%s] %s",
bot.host() + ":" + bot.port(), bot.host + ":" + bot.port,
_message _message
); );
@ -98,13 +96,13 @@ public class LoggerPlugin extends ChatPlugin.Listener {
public void info (String _message) { public void info (String _message) {
final String message = prefix(Component.text("Info").color(NamedTextColor.GREEN), _message); final String message = prefix(Component.text("Info").color(NamedTextColor.GREEN), _message);
if (logToConsole) bot.console().reader().printAbove(message); if (logToConsole) bot.console.reader.printAbove(message);
} }
public void custom (Component prefix, Component _message) { public void custom (Component prefix, Component _message) {
final String message = prefix(prefix, ComponentUtilities.stringifyAnsi(_message)); final String message = prefix(prefix, ComponentUtilities.stringifyAnsi(_message));
if (logToConsole) bot.console().reader().printAbove(message); if (logToConsole) bot.console.reader.printAbove(message);
} }
@Override @Override

View file

@ -8,7 +8,6 @@ import land.chipmunk.chayapak.chomens_bot.data.Mail;
import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry; import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry;
import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities; import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities;
import land.chipmunk.chayapak.chomens_bot.util.PersistentDataUtilities; import land.chipmunk.chayapak.chomens_bot.util.PersistentDataUtilities;
import lombok.Getter;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.NamedTextColor;
@ -18,7 +17,7 @@ import java.util.List;
public class MailPlugin extends PlayersPlugin.Listener { public class MailPlugin extends PlayersPlugin.Listener {
private final Bot bot; private final Bot bot;
@Getter private static JsonArray mails = new JsonArray(); public static JsonArray mails = new JsonArray();
private final Gson gson = new Gson(); private final Gson gson = new Gson();
@ -31,26 +30,26 @@ public class MailPlugin extends PlayersPlugin.Listener {
public MailPlugin (Bot bot) { public MailPlugin (Bot bot) {
this.bot = bot; this.bot = bot;
bot.players().addListener(this); bot.players.addListener(this);
} }
@Override @Override
public void playerJoined(MutablePlayerListEntry target) { public void playerJoined(MutablePlayerListEntry target) {
final String name = target.profile().getName(); final String name = target.profile.getName();
final List<String> sendTos = new ArrayList<>(); // confusing name,.,. final List<String> sendTos = new ArrayList<>(); // confusing name,.,.
for (JsonElement mailElement : mails) { for (JsonElement mailElement : mails) {
final Mail mail = gson.fromJson(mailElement, Mail.class); final Mail mail = gson.fromJson(mailElement, Mail.class);
sendTos.add(mail.sentTo()); sendTos.add(mail.sentTo);
} }
boolean shouldSend = false; boolean shouldSend = false;
for (JsonElement mailElement : mails) { for (JsonElement mailElement : mails) {
final Mail mail = gson.fromJson(mailElement, Mail.class); final Mail mail = gson.fromJson(mailElement, Mail.class);
if (mail.sentTo().equals(name)) { if (mail.sentTo.equals(name)) {
shouldSend = true; shouldSend = true;
break; break;
} }
@ -62,11 +61,11 @@ public class MailPlugin extends PlayersPlugin.Listener {
"Do %s or %s to read", "Do %s or %s to read",
Component.text(sendTos.size()).color(NamedTextColor.GREEN), Component.text(sendTos.size()).color(NamedTextColor.GREEN),
Component.text((sendTos.size() > 1) ? "s" : ""), Component.text((sendTos.size() > 1) ? "s" : ""),
Component.text(bot.config().commandSpyPrefixes().get(0) + "mail read").color(ColorUtilities.getColorByString(bot.config().colorPalette().primary())), Component.text(bot.config.commandSpyPrefixes.get(0) + "mail read").color(ColorUtilities.getColorByString(bot.config.colorPalette.primary)),
Component.text(bot.config().prefixes().get(0) + "mail read").color(ColorUtilities.getColorByString(bot.config().colorPalette().primary())) Component.text(bot.config.prefixes.get(0) + "mail read").color(ColorUtilities.getColorByString(bot.config.colorPalette.primary))
).color(NamedTextColor.GOLD); ).color(NamedTextColor.GOLD);
bot.chat().tellraw(component, target.profile().getId()); bot.chat.tellraw(component, target.profile.getId());
} }
} }

View file

@ -16,16 +16,16 @@ public class MazePlugin {
// also totally didn't ask chatgpt for this too (but modified a bit) // also totally didn't ask chatgpt for this too (but modified a bit)
public void generate (MazeGenerator generator, int startX, int startY, int startZ) { public void generate (MazeGenerator generator, int startX, int startY, int startZ) {
bot.chat().tellraw( bot.chat.tellraw(
Component.translatable( Component.translatable(
"Generating maze at %s %s %s...", "Generating maze at %s %s %s...",
Component.text(startX).color(ColorUtilities.getColorByString(bot.config().colorPalette().number())), Component.text(startX).color(ColorUtilities.getColorByString(bot.config.colorPalette.number)),
Component.text(startY).color(ColorUtilities.getColorByString(bot.config().colorPalette().number())), Component.text(startY).color(ColorUtilities.getColorByString(bot.config.colorPalette.number)),
Component.text(startZ).color(ColorUtilities.getColorByString(bot.config().colorPalette().number())) Component.text(startZ).color(ColorUtilities.getColorByString(bot.config.colorPalette.number))
).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())) ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor))
); );
final int[][] maze = generator.maze(); final int[][] maze = generator.maze;
int x = startX; int x = startX;
int z = startZ; int z = startZ;
@ -53,25 +53,25 @@ public class MazePlugin {
final String command = "minecraft:fill %s %s %s %s %s %s %s"; final String command = "minecraft:fill %s %s %s %s %s %s %s";
// fill the floor // fill the floor
bot.core().run( bot.core.run(
String.format( String.format(
command, command,
x, x,
startY - 1, startY - 1,
z, z,
x + generator.width(), x + generator.width,
startY - 1, startY - 1,
z + generator.height(), z + generator.height,
"minecraft:stone_bricks replace minecraft:air" "minecraft:stone_bricks replace minecraft:air"
) )
); );
// actually build the maze // actually build the maze
for (int row = 0; row < generator.height(); row++) { for (int row = 0; row < generator.height; row++) {
for (int col = 0; col < generator.width(); col++) { for (int col = 0; col < generator.width; col++) {
if (maze[row][col] == 1) { if (maze[row][col] == 1) {
// makes the wall // makes the wall
bot.core().run( bot.core.run(
String.format( String.format(
command, command,
x, x,
@ -85,7 +85,7 @@ public class MazePlugin {
); );
} else if ((row == startRow && col == startCol)) { } else if ((row == startRow && col == startCol)) {
// Set a marker block for the start position // Set a marker block for the start position
bot.core().run( bot.core.run(
String.format( String.format(
command, command,
x, x,
@ -99,7 +99,7 @@ public class MazePlugin {
); );
} else if ((row == endRow && col == endCol)) { } else if ((row == endRow && col == endCol)) {
// Set a marker block for the end position // Set a marker block for the end position
bot.core().run( bot.core.run(
String.format( String.format(
command, command,
x, x,
@ -125,33 +125,33 @@ public class MazePlugin {
} }
// lazy fix for the sus border issue // lazy fix for the sus border issue
bot.core().run( bot.core.run(
String.format( String.format(
command, command,
x + generator.width(), x + generator.width,
startY, startY,
z, z,
x + generator.width(), x + generator.width,
startY + 3, startY + 3,
z + generator.height(), z + generator.height,
"minecraft:stone" "minecraft:stone"
) )
); );
bot.core().run( bot.core.run(
String.format( String.format(
command, command,
x, x,
startY, startY,
z + generator.height(), z + generator.height,
x + generator.width(), x + generator.width,
startY + 3, startY + 3,
z + generator.height(), z + generator.height,
"minecraft:stone" "minecraft:stone"
) )
); );
bot.chat().tellraw( bot.chat.tellraw(
Component.empty() Component.empty()
.append(Component.text("Done generating maze. ")) .append(Component.text("Done generating maze. "))
.append( .append(
@ -169,7 +169,7 @@ public class MazePlugin {
) )
) )
) )
.color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())) .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor))
); );
} }
} }

View file

@ -8,8 +8,6 @@ import land.chipmunk.chayapak.chomens_bot.data.BotBossBar;
import land.chipmunk.chayapak.chomens_bot.song.*; import land.chipmunk.chayapak.chomens_bot.song.*;
import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities; import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities;
import land.chipmunk.chayapak.chomens_bot.util.MathUtilities; import land.chipmunk.chayapak.chomens_bot.util.MathUtilities;
import lombok.Getter;
import lombok.Setter;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.NamedTextColor;
@ -30,14 +28,14 @@ public class MusicPlayerPlugin extends Bot.Listener {
if (!SONG_DIR.exists()) SONG_DIR.mkdir(); if (!SONG_DIR.exists()) SONG_DIR.mkdir();
} }
@Getter @Setter private Song currentSong; public Song currentSong;
@Getter @Setter private List<Song> songQueue = new ArrayList<>(); public List<Song> songQueue = new ArrayList<>();
@Getter @Setter private SongLoaderRunnable loaderThread; public SongLoaderRunnable loaderThread;
@Getter @Setter private Loop loop = Loop.OFF; public Loop loop = Loop.OFF;
// sus nightcore stuff,..,.,. // sus nightcore stuff,..,.,.
@Getter @Setter private float pitch = 0; public float pitch = 0;
@Getter @Setter private float speed = 1; public float speed = 1;
private int ticksUntilPausedBossbar = 20; private int ticksUntilPausedBossbar = 20;
@ -46,7 +44,7 @@ public class MusicPlayerPlugin extends Bot.Listener {
public MusicPlayerPlugin (Bot bot) { public MusicPlayerPlugin (Bot bot) {
this.bot = bot; this.bot = bot;
bot.addListener(this); bot.addListener(this);
bot.core().addListener(new CorePlugin.Listener() { bot.core.addListener(new CorePlugin.Listener() {
public void ready () { coreReady(); } public void ready () { coreReady(); }
}); });
} }
@ -54,35 +52,35 @@ public class MusicPlayerPlugin extends Bot.Listener {
public void loadSong (Path location) { public void loadSong (Path location) {
final SongLoaderRunnable runnable = new SongLoaderRunnable(location, bot); final SongLoaderRunnable runnable = new SongLoaderRunnable(location, bot);
bot.chat().tellraw( bot.chat.tellraw(
Component Component
.translatable( .translatable(
"Loading %s", "Loading %s",
Component.text(location.getFileName().toString(), ColorUtilities.getColorByString(bot.config().colorPalette().secondary())) Component.text(location.getFileName().toString(), ColorUtilities.getColorByString(bot.config.colorPalette.secondary))
) )
.color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())) .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor))
); );
bot.executorService().submit(runnable); bot.executorService.submit(runnable);
} }
public void loadSong (URL location) { public void loadSong (URL location) {
final SongLoaderRunnable runnable = new SongLoaderRunnable(location, bot); final SongLoaderRunnable runnable = new SongLoaderRunnable(location, bot);
bot.chat().tellraw( bot.chat.tellraw(
Component Component
.translatable( .translatable(
"Loading %s", "Loading %s",
Component.text(location.toString(), ColorUtilities.getColorByString(bot.config().colorPalette().secondary())) Component.text(location.toString(), ColorUtilities.getColorByString(bot.config.colorPalette.secondary))
) )
.color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())) .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor))
); );
bot.executorService().submit(runnable); bot.executorService.submit(runnable);
} }
public void coreReady () { public void coreReady () {
bot.tick().addListener(new TickPlugin.Listener() { bot.tick.addListener(new TickPlugin.Listener() {
@Override @Override
public void onTick() { public void onTick() {
try { try {
@ -92,29 +90,29 @@ public class MusicPlayerPlugin extends Bot.Listener {
addBossBar(); addBossBar();
currentSong = songQueue.get(0); // songQueue.poll(); currentSong = songQueue.get(0); // songQueue.poll();
bot.chat().tellraw( bot.chat.tellraw(
Component.translatable( Component.translatable(
"Now playing %s", "Now playing %s",
Component.empty().append(currentSong.name).color(ColorUtilities.getColorByString(bot.config().colorPalette().secondary())) Component.empty().append(currentSong.name).color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary))
).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())) ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor))
); );
currentSong.play(); currentSong.play();
} }
if (currentSong.paused && ticksUntilPausedBossbar-- < 0) return; if (currentSong.paused && ticksUntilPausedBossbar-- < 0) return;
else ticksUntilPausedBossbar = 20 - (((int) bot.tps().getTickRate()) - 20); else ticksUntilPausedBossbar = 20 - (((int) bot.tps.getTickRate()) - 20);
BotBossBar bossBar = bot.bossbar().get(bossbarName); BotBossBar bossBar = bot.bossbar.get(bossbarName);
if (bossBar == null && bot.bossbar().enabled()) bossBar = addBossBar(); if (bossBar == null && bot.bossbar.enabled) bossBar = addBossBar();
if (bot.bossbar().enabled() && bot.options().useCore()) { if (bot.bossbar.enabled && bot.options.useCore) {
bossBar.setTitle(generateBossbar()); bossBar.setTitle(generateBossbar());
bossBar.setColor(pitch > 0 ? BossBarColor.PURPLE : BossBarColor.YELLOW); bossBar.setColor(pitch > 0 ? BossBarColor.PURPLE : BossBarColor.YELLOW);
bossBar.setValue((int) Math.floor(((double) currentSong.time / 1000) * speed)); bossBar.setValue((int) Math.floor(((double) currentSong.time / 1000) * speed));
} }
if (currentSong.paused || bot.core().isRateLimited()) return; if (currentSong.paused || bot.core.isRateLimited()) return;
handlePlaying(); handlePlaying();
@ -124,11 +122,11 @@ public class MusicPlayerPlugin extends Bot.Listener {
return; return;
} }
bot.chat().tellraw( bot.chat.tellraw(
Component.translatable( Component.translatable(
"Finished playing %s", "Finished playing %s",
Component.empty().append(currentSong.name).color(ColorUtilities.getColorByString(bot.config().colorPalette().secondary())) Component.empty().append(currentSong.name).color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary))
).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())) ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor))
); );
if (loop == Loop.ALL) { if (loop == Loop.ALL) {
@ -141,10 +139,10 @@ public class MusicPlayerPlugin extends Bot.Listener {
if (songQueue.size() == 0) { if (songQueue.size() == 0) {
stopPlaying(); stopPlaying();
removeBossBar(); removeBossBar();
bot.chat().tellraw( bot.chat.tellraw(
Component Component
.text("Finished playing every song in the queue") .text("Finished playing every song in the queue")
.color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())) .color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor))
); );
return; return;
} }
@ -190,13 +188,13 @@ public class MusicPlayerPlugin extends Bot.Listener {
bot bot
); );
bot.bossbar().add(bossbarName, bossBar); bot.bossbar.add(bossbarName, bossBar);
return bossBar; return bossBar;
} }
public void removeBossBar() { public void removeBossBar() {
bot.bossbar().remove(bossbarName); bot.bossbar.remove(bossbarName);
} }
public Component generateBossbar () { public Component generateBossbar () {
@ -210,7 +208,7 @@ public class MusicPlayerPlugin extends Bot.Listener {
formatTime(currentSong.length).color(NamedTextColor.GRAY)).color(NamedTextColor.DARK_GRAY) formatTime(currentSong.length).color(NamedTextColor.GRAY)).color(NamedTextColor.DARK_GRAY)
); );
if (!bot.core().hasRateLimit()) { if (!bot.core.hasRateLimit()) {
final DecimalFormat formatter = new DecimalFormat("#,###"); final DecimalFormat formatter = new DecimalFormat("#,###");
component = component component = component
@ -282,7 +280,7 @@ public class MusicPlayerPlugin extends Bot.Listener {
if (s < 100) blockPosition = ((s - 100) * -1) / 100; if (s < 100) blockPosition = ((s - 100) * -1) / 100;
} }
bot.core().run( bot.core.run(
"minecraft:execute as " + "minecraft:execute as " +
SELECTOR + SELECTOR +
" at @s run playsound " + " at @s run playsound " +

View file

@ -3,8 +3,6 @@ package land.chipmunk.chayapak.chomens_bot.plugins;
import com.github.steveice10.packetlib.Session; import com.github.steveice10.packetlib.Session;
import com.github.steveice10.packetlib.packet.Packet; import com.github.steveice10.packetlib.packet.Packet;
import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.Bot;
import lombok.Getter;
import lombok.Setter;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
@ -13,7 +11,7 @@ import java.nio.charset.StandardCharsets;
// normally unused in the main instance of the bot // normally unused in the main instance of the bot
public class PacketSnifferPlugin extends Bot.Listener { public class PacketSnifferPlugin extends Bot.Listener {
@Getter @Setter private boolean enabled = false; public boolean enabled = false;
private OutputStreamWriter writer; private OutputStreamWriter writer;
@ -25,8 +23,8 @@ public class PacketSnifferPlugin extends Bot.Listener {
new FileOutputStream( new FileOutputStream(
String.format( String.format(
"packets-%s-%s.log", "packets-%s-%s.log",
bot.options().host(), bot.options.host,
bot.options().port() bot.options.port
) )
), ),
StandardCharsets.UTF_8 StandardCharsets.UTF_8

View file

@ -12,7 +12,6 @@ import com.google.gson.JsonObject;
import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.Bot;
import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry; import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry;
import land.chipmunk.chayapak.chomens_bot.util.PersistentDataUtilities; import land.chipmunk.chayapak.chomens_bot.util.PersistentDataUtilities;
import lombok.Getter;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import java.time.Instant; import java.time.Instant;
@ -23,11 +22,12 @@ import java.util.UUID;
public class PlayersPlugin extends Bot.Listener { public class PlayersPlugin extends Bot.Listener {
private final Bot bot; private final Bot bot;
@Getter private final List<MutablePlayerListEntry> list = new ArrayList<>();
public final List<MutablePlayerListEntry> list = new ArrayList<>();
private final List<Listener> listeners = new ArrayList<>(); private final List<Listener> listeners = new ArrayList<>();
@Getter private static JsonObject playersObject = new JsonObject(); public static JsonObject playersObject = new JsonObject();
static { static {
if (PersistentDataUtilities.jsonObject.has("players")) { if (PersistentDataUtilities.jsonObject.has("players")) {
@ -71,7 +71,7 @@ public class PlayersPlugin extends Bot.Listener {
public final MutablePlayerListEntry getEntry (UUID uuid) { public final MutablePlayerListEntry getEntry (UUID uuid) {
for (MutablePlayerListEntry candidate : list) { for (MutablePlayerListEntry candidate : list) {
if (candidate.profile().getId().equals(uuid)) { if (candidate.profile.getId().equals(uuid)) {
return candidate; return candidate;
} }
} }
@ -91,7 +91,7 @@ public class PlayersPlugin extends Bot.Listener {
public final MutablePlayerListEntry getEntry (Component displayName) { public final MutablePlayerListEntry getEntry (Component displayName) {
for (MutablePlayerListEntry candidate : list) { for (MutablePlayerListEntry candidate : list) {
if (candidate.displayName() != null && candidate.displayName().equals(displayName)) { if (candidate.displayName != null && candidate.displayName.equals(displayName)) {
return candidate; return candidate;
} }
} }
@ -99,7 +99,7 @@ public class PlayersPlugin extends Bot.Listener {
return null; return null;
} }
public MutablePlayerListEntry getBotEntry () { return getEntry(bot.username()); } public MutablePlayerListEntry getBotEntry () { return getEntry(bot.username); }
private MutablePlayerListEntry getEntry (PlayerListEntry other) { private MutablePlayerListEntry getEntry (PlayerListEntry other) {
return getEntry(other.getProfile().getId()); return getEntry(other.getProfile().getId());
@ -109,18 +109,18 @@ public class PlayersPlugin extends Bot.Listener {
final MutablePlayerListEntry target = getEntry(newEntry); final MutablePlayerListEntry target = getEntry(newEntry);
if (target == null) return; if (target == null) return;
target.publicKey(newEntry.getPublicKey()); target.publicKey = newEntry.getPublicKey();
} }
private void updateListed (PlayerListEntry newEntry) { private void updateListed (PlayerListEntry newEntry) {
final MutablePlayerListEntry target = getEntry(newEntry); final MutablePlayerListEntry target = getEntry(newEntry);
if (target == null) return; if (target == null) return;
target.listed(newEntry.isListed()); target.listed = newEntry.isListed();
} }
private String getName(MutablePlayerListEntry target) { private String getName(MutablePlayerListEntry target) {
return bot.options().creayun() ? target.profile().getName().replaceAll("§.", "") : target.profile().getName(); return bot.options.creayun ? target.profile.getName().replaceAll("§.", "") : target.profile.getName();
} }
private void addPlayer (PlayerListEntry newEntry) { private void addPlayer (PlayerListEntry newEntry) {
@ -138,7 +138,7 @@ public class PlayersPlugin extends Bot.Listener {
if (playersObject.has(getName(target))) return; if (playersObject.has(getName(target))) return;
final JsonObject object = new JsonObject(); final JsonObject object = new JsonObject();
object.addProperty("uuid", target.profile().getIdAsString()); object.addProperty("uuid", target.profile.getIdAsString());
object.add("lastSeen", new JsonObject()); object.add("lastSeen", new JsonObject());
playersObject.add(getName(target), object); playersObject.add(getName(target), object);
@ -153,7 +153,7 @@ public class PlayersPlugin extends Bot.Listener {
final GameMode gameMode = newEntry.getGameMode(); final GameMode gameMode = newEntry.getGameMode();
target.gamemode(gameMode); target.gamemode = gameMode;
for (Listener listener : listeners) { listener.playerGameModeUpdated(target, gameMode); } for (Listener listener : listeners) { listener.playerGameModeUpdated(target, gameMode); }
} }
@ -164,7 +164,7 @@ public class PlayersPlugin extends Bot.Listener {
final int ping = newEntry.getLatency(); final int ping = newEntry.getLatency();
target.latency(ping); target.latency = ping;
for (Listener listener : listeners) { listener.playerLatencyUpdated(target, ping); } for (Listener listener : listeners) { listener.playerLatencyUpdated(target, ping); }
} }
@ -175,7 +175,7 @@ public class PlayersPlugin extends Bot.Listener {
final Component displayName = newEntry.getDisplayName(); final Component displayName = newEntry.getDisplayName();
target.displayName(displayName); target.displayName = displayName;
for (Listener listener : listeners) { listener.playerDisplayNameUpdated(target, displayName); } for (Listener listener : listeners) { listener.playerDisplayNameUpdated(target, displayName); }
} }
@ -184,14 +184,14 @@ public class PlayersPlugin extends Bot.Listener {
final MutablePlayerListEntry target = getEntry(uuid); final MutablePlayerListEntry target = getEntry(uuid);
if (target == null) return; if (target == null) return;
bot.tabComplete().tabComplete("/minecraft:scoreboard players add ").thenApply(packet -> { bot.tabComplete.tabComplete("/minecraft:scoreboard players add ").thenApply(packet -> {
final String[] matches = packet.getMatches(); final String[] matches = packet.getMatches();
final Component[] tooltips = packet.getTooltips(); final Component[] tooltips = packet.getTooltips();
final String username = target.profile().getName(); final String username = target.profile.getName();
for (int i = 0; i < matches.length; i++) { for (int i = 0; i < matches.length; i++) {
if (tooltips[i] != null || !matches[i].equals(username)) continue; if (tooltips[i] != null || !matches[i].equals(username)) continue;
target.listed(false); target.listed = false;
for (Listener listener : listeners) { listener.playerVanished(target); } for (Listener listener : listeners) { listener.playerVanished(target); }
return packet; return packet;
} }
@ -209,7 +209,7 @@ public class PlayersPlugin extends Bot.Listener {
final JsonObject object = new JsonObject(); final JsonObject object = new JsonObject();
object.addProperty("time", Instant.now().toEpochMilli()); object.addProperty("time", Instant.now().toEpochMilli());
object.addProperty("server", bot.host() + ":" + bot.port()); object.addProperty("server", bot.host + ":" + bot.port);
player.add("lastSeen", object); player.add("lastSeen", object);

View file

@ -12,7 +12,6 @@ import com.github.steveice10.packetlib.packet.Packet;
import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.Bot;
import land.chipmunk.chayapak.chomens_bot.data.Rotation; import land.chipmunk.chayapak.chomens_bot.data.Rotation;
import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry; import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry;
import lombok.Getter;
import org.cloudburstmc.math.vector.Vector3f; import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.math.vector.Vector3i; import org.cloudburstmc.math.vector.Vector3i;
@ -27,7 +26,7 @@ public class PositionPlugin extends Bot.Listener {
private final List<Listener> listeners = new ArrayList<>(); private final List<Listener> listeners = new ArrayList<>();
@Getter private Vector3i position = Vector3i.from(0, 0, 0); public Vector3i position = Vector3i.from(0, 0, 0);
private final Map<Integer, MutablePlayerListEntry> entityIdMap = new HashMap<>(); private final Map<Integer, MutablePlayerListEntry> entityIdMap = new HashMap<>();
private final Map<Integer, Vector3f> positionMap = new HashMap<>(); private final Map<Integer, Vector3f> positionMap = new HashMap<>();
@ -49,14 +48,14 @@ public class PositionPlugin extends Bot.Listener {
} }
public void packetReceived (ClientboundPlayerPositionPacket packet) { public void packetReceived (ClientboundPlayerPositionPacket packet) {
bot.session().send(new ServerboundAcceptTeleportationPacket(packet.getTeleportId())); bot.session.send(new ServerboundAcceptTeleportationPacket(packet.getTeleportId()));
position = Vector3i.from(packet.getX(), packet.getY(), packet.getZ()); position = Vector3i.from(packet.getX(), packet.getY(), packet.getZ());
for (Listener listener : listeners) { listener.positionChange(position); } for (Listener listener : listeners) { listener.positionChange(position); }
} }
public void packetReceived (ClientboundAddPlayerPacket packet) { public void packetReceived (ClientboundAddPlayerPacket packet) {
final MutablePlayerListEntry entry = bot.players().getEntry(packet.getUuid()); final MutablePlayerListEntry entry = bot.players.getEntry(packet.getUuid());
if (entry == null) return; if (entry == null) return;
@ -88,7 +87,7 @@ public class PositionPlugin extends Bot.Listener {
rotationMap.put(packet.getEntityId(), rotation); rotationMap.put(packet.getEntityId(), rotation);
for (Listener listener : listeners) listener.playerMoved(player, getPlayerPosition(player.profile().getName()), rotation); for (Listener listener : listeners) listener.playerMoved(player, getPlayerPosition(player.profile.getName()), rotation);
} }
public void packetReceived (ClientboundMoveEntityPosPacket packet) { public void packetReceived (ClientboundMoveEntityPosPacket packet) {
@ -108,7 +107,7 @@ public class PositionPlugin extends Bot.Listener {
positionMap.put(packet.getEntityId(), position); positionMap.put(packet.getEntityId(), position);
for (Listener listener : listeners) listener.playerMoved(player, position, getPlayerRotation(player.profile().getName())); for (Listener listener : listeners) listener.playerMoved(player, position, getPlayerRotation(player.profile.getName()));
} }
public void packetReceived (ClientboundMoveEntityPosRotPacket packet) { public void packetReceived (ClientboundMoveEntityPosRotPacket packet) {
@ -138,7 +137,7 @@ public class PositionPlugin extends Bot.Listener {
public Vector3f getPlayerPosition (String playerName) { public Vector3f getPlayerPosition (String playerName) {
int entityId = -1; int entityId = -1;
for (Map.Entry<Integer, MutablePlayerListEntry> entry : entityIdMap.entrySet()) { for (Map.Entry<Integer, MutablePlayerListEntry> entry : entityIdMap.entrySet()) {
if (entry.getValue().profile().getName().equals(playerName)) entityId = entry.getKey(); if (entry.getValue().profile.getName().equals(playerName)) entityId = entry.getKey();
} }
if (entityId == -1) return null; if (entityId == -1) return null;
@ -153,7 +152,7 @@ public class PositionPlugin extends Bot.Listener {
public Rotation getPlayerRotation (String playerName) { public Rotation getPlayerRotation (String playerName) {
int entityId = -1; int entityId = -1;
for (Map.Entry<Integer, MutablePlayerListEntry> entry : entityIdMap.entrySet()) { for (Map.Entry<Integer, MutablePlayerListEntry> entry : entityIdMap.entrySet()) {
if (entry.getValue().profile().getName().equals(playerName)) entityId = entry.getKey(); if (entry.getValue().profile.getName().equals(playerName)) entityId = entry.getKey();
} }
if (entityId == -1) return null; if (entityId == -1) return null;

View file

@ -15,13 +15,11 @@ import com.github.steveice10.packetlib.Session;
import com.github.steveice10.packetlib.event.session.DisconnectedEvent; import com.github.steveice10.packetlib.event.session.DisconnectedEvent;
import com.github.steveice10.packetlib.packet.Packet; import com.github.steveice10.packetlib.packet.Packet;
import com.github.steveice10.packetlib.packet.PacketProtocol; import com.github.steveice10.packetlib.packet.PacketProtocol;
import org.cloudburstmc.math.vector.Vector3i;
import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.Bot;
import land.chipmunk.chayapak.chomens_bot.Configuration; import land.chipmunk.chayapak.chomens_bot.Configuration;
import land.chipmunk.chayapak.chomens_bot.util.ComponentUtilities; import land.chipmunk.chayapak.chomens_bot.util.ComponentUtilities;
import lombok.Getter;
import lombok.Setter;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import org.cloudburstmc.math.vector.Vector3i;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -31,7 +29,7 @@ public class SelfCarePlugin extends Bot.Listener {
private ScheduledFuture<?> checkTask; private ScheduledFuture<?> checkTask;
@Getter @Setter boolean visibility = false; public boolean visibility = false;
private int entityId; private int entityId;
private GameMode gamemode; private GameMode gamemode;
@ -50,7 +48,7 @@ public class SelfCarePlugin extends Bot.Listener {
bot.addListener(this); bot.addListener(this);
bot.chat().addListener(new ChatPlugin.Listener() { bot.chat.addListener(new ChatPlugin.Listener() {
@Override @Override
public void systemMessageReceived(Component component) { public void systemMessageReceived(Component component) {
final String message = ComponentUtilities.stringify(component); final String message = ComponentUtilities.stringify(component);
@ -58,29 +56,29 @@ public class SelfCarePlugin extends Bot.Listener {
if (message.equals("Successfully enabled CommandSpy")) cspy = true; if (message.equals("Successfully enabled CommandSpy")) cspy = true;
else if (message.equals("Successfully disabled CommandSpy")) cspy = false; else if (message.equals("Successfully disabled CommandSpy")) cspy = false;
else if (message.equals("Vanish for " + bot.username() + ": enabled")) vanish = true; else if (message.equals("Vanish for " + bot.username + ": enabled")) vanish = true;
else if (message.equals("You are now completely invisible to normal users, and hidden from in-game commands.")) vanish = true; else if (message.equals("You are now completely invisible to normal users, and hidden from in-game commands.")) vanish = true;
else if (message.equals("Vanish for " + bot.username() + ": disabled")) vanish = false; else if (message.equals("Vanish for " + bot.username + ": disabled")) vanish = false;
else if (message.equals("You no longer have a nickname.")) nickname = true; else if (message.equals("You no longer have a nickname.")) nickname = true;
else if (message.startsWith("Your nickname is now ")) nickname = false; else if (message.startsWith("Your nickname is now ")) nickname = false;
else if (message.equals("SocialSpy for " + bot.username() + ": enabled")) socialspy = true; else if (message.equals("SocialSpy for " + bot.username + ": enabled")) socialspy = true;
else if (message.equals("SocialSpy for " + bot.username() + ": disabled")) socialspy = false; else if (message.equals("SocialSpy for " + bot.username + ": disabled")) socialspy = false;
else if (message.startsWith("You have been muted")) muted = true; else if (message.startsWith("You have been muted")) muted = true;
else if (message.equals("You have been unmuted.")) muted = false; else if (message.equals("You have been unmuted.")) muted = false;
else if (message.equals("You now have the tag: " + bot.config().selfCare().prefix().prefix())) prefix = true; else if (message.equals("You now have the tag: " + bot.config.selfCare.prefix.prefix)) prefix = true;
else if (message.startsWith("You no longer have a tag")) prefix = false; else if (message.startsWith("You no longer have a tag")) prefix = false;
else if (message.startsWith("You now have the tag: ")) prefix = false; else if (message.startsWith("You now have the tag: ")) prefix = false;
else if (message.equals("Successfully set your username to \"" + bot.username() + "\"")) username = true; else if (message.equals("Successfully set your username to \"" + bot.username + "\"")) username = true;
else if (message.startsWith("Successfully set your username to \"")) username = false; else if (message.startsWith("Successfully set your username to \"")) username = false;
} }
}); });
bot.position().addListener(new PositionPlugin.Listener() { bot.position.addListener(new PositionPlugin.Listener() {
@Override @Override
public void positionChange(Vector3i position) { public void positionChange(Vector3i position) {
SelfCarePlugin.this.positionChange(); SelfCarePlugin.this.positionChange();
@ -89,32 +87,32 @@ public class SelfCarePlugin extends Bot.Listener {
} }
public void check () { public void check () {
final Configuration.SelfCare selfCares = bot.config().selfCare(); final Configuration.SelfCare selfCares = bot.config.selfCare;
// chat only // chat only
if (selfCares.op() && permissionLevel < 2) bot.chat().send("/minecraft:op @s[type=player]"); if (selfCares.op && permissionLevel < 2) bot.chat.send("/minecraft:op @s[type=player]");
else if (selfCares.gamemode() && gamemode != GameMode.CREATIVE) bot.chat().send("/minecraft:gamemode creative @s[type=player]"); else if (selfCares.gamemode && gamemode != GameMode.CREATIVE) bot.chat.send("/minecraft:gamemode creative @s[type=player]");
else if (selfCares.cspy() && !cspy && bot.options().kaboom()) bot.chat().send("/commandspy:commandspy on"); else if (selfCares.cspy && !cspy && bot.options.kaboom) bot.chat.send("/commandspy:commandspy on");
else if (selfCares.prefix().enabled() && !prefix && bot.options().kaboom()) bot.chat().send("/extras:prefix " + bot.config().selfCare().prefix().prefix()); else if (selfCares.prefix.enabled && !prefix && bot.options.kaboom) bot.chat.send("/extras:prefix " + bot.config.selfCare.prefix.prefix);
else if (selfCares.username() && !username && bot.options().kaboom()) bot.chat().send("/extras:username " + bot.username()); else if (selfCares.username && !username && bot.options.kaboom) bot.chat.send("/extras:username " + bot.username);
// core // core
else if (selfCares.icu().enabled() && positionPacketsPerSecond > selfCares.icu().positionPacketsPerSecond()) bot.core().run("essentials:sudo * icu stop"); else if (selfCares.icu.enabled && positionPacketsPerSecond > selfCares.icu.positionPacketsPerSecond) bot.core.run("essentials:sudo * icu stop");
else if (selfCares.vanish() && !vanish && !visibility && bot.options().hasEssentials()) { else if (selfCares.vanish && !vanish && !visibility && bot.options.hasEssentials) {
if (bot.options().useChat()) bot.chat().send("/essentials:vanish enable"); if (bot.options.useChat) bot.chat.send("/essentials:vanish enable");
else bot.core().run("essentials:vanish " + bot.username() + " enable"); else bot.core.run("essentials:vanish " + bot.username + " enable");
} }
else if (selfCares.nickname() && !nickname && bot.options().hasEssentials()) { else if (selfCares.nickname && !nickname && bot.options.hasEssentials) {
if (bot.options().useChat()) bot.chat().send("/essentials:nick off"); if (bot.options.useChat) bot.chat.send("/essentials:nick off");
else bot.core().run("essentials:nickname " + bot.username() + " off"); else bot.core.run("essentials:nickname " + bot.username + " off");
} }
else if (selfCares.socialspy() && !socialspy && bot.options().hasEssentials()) { else if (selfCares.socialspy && !socialspy && bot.options.hasEssentials) {
if (bot.options().useChat()) bot.chat().send("/essentials:socialspy enable"); if (bot.options.useChat) bot.chat.send("/essentials:socialspy enable");
else bot.core().run("essentials:socialspy " + bot.username() + " enable"); else bot.core.run("essentials:socialspy " + bot.username + " enable");
} }
else if (selfCares.mute() && muted && bot.options().hasEssentials()) { else if (selfCares.mute && muted && bot.options.hasEssentials) {
if (bot.options().useChat()) bot.chat().send("/essentials:mute " + bot.profile().getIdAsString()); if (bot.options.useChat) bot.chat.send("/essentials:mute " + bot.profile.getIdAsString());
else bot.core().run("essentials:mute " + bot.profile().getIdAsString()); else bot.core.run("essentials:mute " + bot.profile.getIdAsString());
muted = false; // too lazy fix and probably the worst fix? muted = false; // too lazy fix and probably the worst fix?
} }
@ -140,7 +138,7 @@ public class SelfCarePlugin extends Bot.Listener {
positionPacketsPerSecond = 0; positionPacketsPerSecond = 0;
final Runnable task = () -> { final Runnable task = () -> {
final Session session = bot.session(); final Session session = bot.session;
final PacketProtocol protocol = session.getPacketProtocol(); final PacketProtocol protocol = session.getPacketProtocol();
if ( if (
!session.isConnected() || !session.isConnected() ||
@ -153,7 +151,7 @@ public class SelfCarePlugin extends Bot.Listener {
check(); check();
}; };
checkTask = bot.executor().scheduleAtFixedRate(task, 0, bot.options().chatQueueDelay() + 75, TimeUnit.MILLISECONDS); checkTask = bot.executor.scheduleAtFixedRate(task, 0, bot.options.chatQueueDelay + 75, TimeUnit.MILLISECONDS);
} }
public void packetReceived (ClientboundGameEventPacket packet) { public void packetReceived (ClientboundGameEventPacket packet) {
@ -161,7 +159,7 @@ public class SelfCarePlugin extends Bot.Listener {
final GameEventValue value = packet.getValue(); final GameEventValue value = packet.getValue();
if (notification == GameEvent.ENTER_CREDITS) { if (notification == GameEvent.ENTER_CREDITS) {
bot.session().send(new ServerboundClientCommandPacket(ClientCommand.RESPAWN)); bot.session.send(new ServerboundClientCommandPacket(ClientCommand.RESPAWN));
return; return;
} }
@ -185,7 +183,7 @@ public class SelfCarePlugin extends Bot.Listener {
public void positionChange () { public void positionChange () {
positionPacketsPerSecond++; positionPacketsPerSecond++;
bot.executor().schedule(() -> positionPacketsPerSecond--, 1, TimeUnit.SECONDS); bot.executor.schedule(() -> positionPacketsPerSecond--, 1, TimeUnit.SECONDS);
} }
@Override @Override

View file

@ -33,10 +33,10 @@ public class TPSPlugin extends Bot.Listener {
bot.addListener(this); bot.addListener(this);
bot.core().addListener(new CorePlugin.Listener() { bot.core.addListener(new CorePlugin.Listener() {
@Override @Override
public void ready() { public void ready() {
bot.tick().addListener(new TickPlugin.Listener() { bot.tick.addListener(new TickPlugin.Listener() {
@Override @Override
public void onTick() { public void onTick() {
updateTPSBar(); updateTPSBar();
@ -61,12 +61,12 @@ public class TPSPlugin extends Bot.Listener {
bot bot
); );
bot.bossbar().add(bossbarName, bossBar); bot.bossbar.add(bossbarName, bossBar);
} }
public void off () { public void off () {
enabled = false; enabled = false;
bot.bossbar().remove(bossbarName); bot.bossbar.remove(bossbarName);
} }
private void updateTPSBar () { private void updateTPSBar () {
@ -83,7 +83,7 @@ public class TPSPlugin extends Bot.Listener {
Component.text(formatter.format(tickRate)).color(getColor(tickRate)) Component.text(formatter.format(tickRate)).color(getColor(tickRate))
).color(NamedTextColor.DARK_GRAY); ).color(NamedTextColor.DARK_GRAY);
final BotBossBar bossBar = bot.bossbar().get(bossbarName); final BotBossBar bossBar = bot.bossbar.get(bossbarName);
if (bossBar == null) return; if (bossBar == null) return;

View file

@ -23,7 +23,7 @@ public class TabCompletePlugin extends Bot.Listener {
public CompletableFuture<ClientboundCommandSuggestionsPacket> tabComplete (String command) { public CompletableFuture<ClientboundCommandSuggestionsPacket> tabComplete (String command) {
final int transactionId = nextTransactionId++; final int transactionId = nextTransactionId++;
bot.session().send(new ServerboundCommandSuggestionPacket(transactionId, command)); bot.session.send(new ServerboundCommandSuggestionPacket(transactionId, command));
final CompletableFuture<ClientboundCommandSuggestionsPacket> future = new CompletableFuture<>(); final CompletableFuture<ClientboundCommandSuggestionsPacket> future = new CompletableFuture<>();
transactions.put(transactionId, future); transactions.put(transactionId, future);

View file

@ -5,14 +5,13 @@ import com.github.steveice10.packetlib.Session;
import com.github.steveice10.packetlib.packet.Packet; import com.github.steveice10.packetlib.packet.Packet;
import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.Bot;
import land.chipmunk.chayapak.chomens_bot.data.Team; import land.chipmunk.chayapak.chomens_bot.data.Team;
import lombok.Getter;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
public class TeamPlugin extends Bot.Listener { public class TeamPlugin extends Bot.Listener {
@Getter private final Map<String, Team> teams = new HashMap<>(); public final Map<String, Team> teams = new HashMap<>();
@Getter private final Map<String, Team> teamsByPlayer = new HashMap<>(); public final Map<String, Team> teamsByPlayer = new HashMap<>();
public TeamPlugin (Bot bot) { public TeamPlugin (Bot bot) {
bot.addListener(this); bot.addListener(this);
@ -47,15 +46,15 @@ public class TeamPlugin extends Bot.Listener {
if (team == null) return; if (team == null) return;
team.teamName(packet.getTeamName()); team.teamName = packet.getTeamName();
team.displayName(packet.getDisplayName()); team.displayName = packet.getDisplayName();
team.friendlyFire(packet.isFriendlyFire()); team.friendlyFire = packet.isFriendlyFire();
team.seeFriendlyInvisibles(packet.isSeeFriendlyInvisibles()); team.seeFriendlyInvisibles = packet.isSeeFriendlyInvisibles();
team.nametagVisibility(packet.getNameTagVisibility()); team.nametagVisibility = packet.getNameTagVisibility();
team.collisionRule(packet.getCollisionRule()); team.collisionRule = packet.getCollisionRule();
team.color(packet.getColor()); team.color = packet.getColor();
team.prefix(packet.getPrefix()); team.prefix = packet.getPrefix();
team.suffix(packet.getSuffix()); team.suffix = packet.getSuffix();
} }
case ADD_PLAYER -> { case ADD_PLAYER -> {
final Team team = teams.get(packet.getTeamName()); final Team team = teams.get(packet.getTeamName());

View file

@ -24,7 +24,7 @@ public class TickPlugin extends Bot.Listener {
@Override @Override
public void connected(ConnectedEvent event) { public void connected(ConnectedEvent event) {
tickTask = bot.executor().scheduleAtFixedRate(this::tick, 0, 50, TimeUnit.MILLISECONDS); tickTask = bot.executor.scheduleAtFixedRate(this::tick, 0, 50, TimeUnit.MILLISECONDS);
} }
private void tick () { private void tick () {

View file

@ -3,7 +3,6 @@ package land.chipmunk.chayapak.chomens_bot.plugins;
import land.chipmunk.chayapak.chomens_bot.Bot; import land.chipmunk.chayapak.chomens_bot.Bot;
import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry; import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry;
import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities; import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities;
import lombok.Getter;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.NamedTextColor;
import org.joda.time.DateTime; import org.joda.time.DateTime;
@ -16,37 +15,37 @@ import java.util.UUID;
public class TrustedPlugin extends PlayersPlugin.Listener { public class TrustedPlugin extends PlayersPlugin.Listener {
private final Bot bot; private final Bot bot;
@Getter private final List<String> list; public final List<String> list;
public TrustedPlugin (Bot bot) { public TrustedPlugin (Bot bot) {
this.bot = bot; this.bot = bot;
this.list = bot.config().trusted(); this.list = bot.config.trusted;
bot.players().addListener(this); bot.players.addListener(this);
} }
public void broadcast (Component message, UUID exceptTarget) { public void broadcast (Component message, UUID exceptTarget) {
for (Bot bot : bot.bots()) { for (Bot bot : bot.bots) {
if (!bot.loggedIn()) continue; if (!bot.loggedIn) continue;
final Component component = Component.translatable( final Component component = Component.translatable(
"[%s] [%s] %s", "[%s] [%s] %s",
Component.text("ChomeNS Bot").color(ColorUtilities.getColorByString(bot.config().colorPalette().primary())), Component.text("ChomeNS Bot").color(ColorUtilities.getColorByString(bot.config.colorPalette.primary)),
Component.text(this.bot.options().serverName()).color(NamedTextColor.GRAY), Component.text(this.bot.options.serverName).color(NamedTextColor.GRAY),
message.color(NamedTextColor.WHITE) message.color(NamedTextColor.WHITE)
).color(NamedTextColor.DARK_GRAY); ).color(NamedTextColor.DARK_GRAY);
bot.logger().custom(Component.text("Trusted Broadcast").color(NamedTextColor.AQUA), component); bot.logger.custom(Component.text("Trusted Broadcast").color(NamedTextColor.AQUA), component);
for (String player : list) { for (String player : list) {
final MutablePlayerListEntry entry = bot.players().getEntry(player); final MutablePlayerListEntry entry = bot.players.getEntry(player);
if (entry == null) continue; if (entry == null) continue;
if (entry.profile().getId() == exceptTarget) continue; if (entry.profile.getId() == exceptTarget) continue;
bot.chat().tellraw(component, player); bot.chat.tellraw(component, player);
} }
} }
} }
@ -55,14 +54,14 @@ public class TrustedPlugin extends PlayersPlugin.Listener {
@Override @Override
public void playerJoined (MutablePlayerListEntry target) { public void playerJoined (MutablePlayerListEntry target) {
if (!list.contains(target.profile().getName())) return; if (!list.contains(target.profile.getName())) return;
// based (VERY) // based (VERY)
Component component; Component component;
if (!target.profile().getName().equals(bot.config().ownerName())) { if (!target.profile.getName().equals(bot.config.ownerName)) {
component = Component.translatable( component = Component.translatable(
"Hello, %s!", "Hello, %s!",
Component.text(target.profile().getName()).color(ColorUtilities.getColorByString(bot.config().colorPalette().username())) Component.text(target.profile.getName()).color(ColorUtilities.getColorByString(bot.config.colorPalette.username))
).color(NamedTextColor.GREEN); ).color(NamedTextColor.GREEN);
} else { } else {
final DateTime now = DateTime.now(); final DateTime now = DateTime.now();
@ -75,35 +74,35 @@ public class TrustedPlugin extends PlayersPlugin.Listener {
Hello, %s! Hello, %s!
Time: %s Time: %s
Online players: %s""", Online players: %s""",
Component.text(target.profile().getName()).color(ColorUtilities.getColorByString(bot.config().colorPalette().username())), Component.text(target.profile.getName()).color(ColorUtilities.getColorByString(bot.config.colorPalette.username)),
Component.text(formattedTime).color(ColorUtilities.getColorByString(bot.config().colorPalette().string())), Component.text(formattedTime).color(ColorUtilities.getColorByString(bot.config.colorPalette.string)),
Component.text(bot.players().list().size()).color(ColorUtilities.getColorByString(bot.config().colorPalette().number())) Component.text(bot.players.list.size()).color(ColorUtilities.getColorByString(bot.config.colorPalette.number))
).color(NamedTextColor.GREEN); ).color(NamedTextColor.GREEN);
} }
bot.chat().tellraw( bot.chat.tellraw(
component, component,
target.profile().getId() target.profile.getId()
); );
broadcast( broadcast(
Component.translatable( Component.translatable(
"Trusted player %s is now online", "Trusted player %s is now online",
Component.text(target.profile().getName()).color(ColorUtilities.getColorByString(bot.config().colorPalette().username())) Component.text(target.profile.getName()).color(ColorUtilities.getColorByString(bot.config.colorPalette.username))
).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())), ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)),
target.profile().getId() target.profile.getId()
); );
} }
@Override @Override
public void playerLeft (MutablePlayerListEntry target) { public void playerLeft (MutablePlayerListEntry target) {
if (!list.contains(target.profile().getName())) return; if (!list.contains(target.profile.getName())) return;
broadcast( broadcast(
Component.translatable( Component.translatable(
"Trusted player %s is now offline", "Trusted player %s is now offline",
Component.text(target.profile().getName()).color(ColorUtilities.getColorByString(bot.config().colorPalette().username())) Component.text(target.profile.getName()).color(ColorUtilities.getColorByString(bot.config.colorPalette.username))
).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())) ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor))
); );
} }
} }

View file

@ -16,7 +16,6 @@ import land.chipmunk.chayapak.chomens_bot.voiceChat.NetworkMessage;
import land.chipmunk.chayapak.chomens_bot.voiceChat.customPayload.JoinGroupPacket; import land.chipmunk.chayapak.chomens_bot.voiceChat.customPayload.JoinGroupPacket;
import land.chipmunk.chayapak.chomens_bot.voiceChat.customPayload.SecretPacket; import land.chipmunk.chayapak.chomens_bot.voiceChat.customPayload.SecretPacket;
import land.chipmunk.chayapak.chomens_bot.voiceChat.packets.*; import land.chipmunk.chayapak.chomens_bot.voiceChat.packets.*;
import lombok.Getter;
import java.net.*; import java.net.*;
import java.util.ArrayList; import java.util.ArrayList;
@ -33,7 +32,7 @@ public class VoiceChatPlugin extends Bot.Listener {
private boolean running = false; private boolean running = false;
@Getter private final List<ClientGroup> groups = new ArrayList<>(); public final List<ClientGroup> groups = new ArrayList<>();
public VoiceChatPlugin(Bot bot) { public VoiceChatPlugin(Bot bot) {
this.bot = bot; this.bot = bot;
@ -49,17 +48,17 @@ public class VoiceChatPlugin extends Bot.Listener {
public void packetReceived(ClientboundLoginPacket ignored) { public void packetReceived(ClientboundLoginPacket ignored) {
// totally didn't use a real minecraft client with voicechat mod to get this // totally didn't use a real minecraft client with voicechat mod to get this
bot.session().send(new ServerboundCustomPayloadPacket( bot.session.send(new ServerboundCustomPayloadPacket(
"minecraft:brand", "minecraft:brand",
"\u0006fabric".getBytes() // should i use fabric here? "\u0006fabric".getBytes() // should i use fabric here?
)); ));
bot.session().send(new ServerboundCustomPayloadPacket( bot.session.send(new ServerboundCustomPayloadPacket(
"voicechat:request_secret", "voicechat:request_secret",
new FriendlyByteBuf(Unpooled.buffer()).writeInt(17).array() new FriendlyByteBuf(Unpooled.buffer()).writeInt(17).array()
)); ));
bot.session().send(new ServerboundCustomPayloadPacket( bot.session.send(new ServerboundCustomPayloadPacket(
"voicechat:update_state", "voicechat:update_state",
new FriendlyByteBuf(Unpooled.buffer()).writeBoolean(false).array() new FriendlyByteBuf(Unpooled.buffer()).writeBoolean(false).array()
)); ));
@ -74,11 +73,11 @@ public class VoiceChatPlugin extends Bot.Listener {
final SecretPacket secretPacket = new SecretPacket().fromBytes(buf); final SecretPacket secretPacket = new SecretPacket().fromBytes(buf);
initializationData = new InitializationData(bot.session().getHost(), secretPacket); initializationData = new InitializationData(bot.session.getHost(), secretPacket);
try { try {
final InetAddress address = InetAddress.getByName(bot.session().getHost()); final InetAddress address = InetAddress.getByName(bot.session.getHost());
socketAddress = new InetSocketAddress(address, initializationData.serverPort()); socketAddress = new InetSocketAddress(address, initializationData.serverPort);
} catch (UnknownHostException e) { } catch (UnknownHostException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
@ -91,7 +90,7 @@ public class VoiceChatPlugin extends Bot.Listener {
} }
new Thread(() -> { new Thread(() -> {
sendToServer(new NetworkMessage(new AuthenticatePacket(initializationData.playerUUID(), initializationData.secret()))); sendToServer(new NetworkMessage(new AuthenticatePacket(initializationData.playerUUID, initializationData.secret)));
while (running) { while (running) {
try { try {
@ -99,9 +98,9 @@ public class VoiceChatPlugin extends Bot.Listener {
if (message == null) continue; if (message == null) continue;
if (message.packet() instanceof PingPacket pingPacket) sendToServer(new NetworkMessage(pingPacket)); if (message.packet instanceof PingPacket pingPacket) sendToServer(new NetworkMessage(pingPacket));
else if (message.packet() instanceof KeepAlivePacket) sendToServer(new NetworkMessage(new KeepAlivePacket())); else if (message.packet instanceof KeepAlivePacket) sendToServer(new NetworkMessage(new KeepAlivePacket()));
else if (message.packet() instanceof AuthenticateAckPacket) sendToServer(new NetworkMessage(new ConnectionCheckPacket())); else if (message.packet instanceof AuthenticateAckPacket) sendToServer(new NetworkMessage(new ConnectionCheckPacket()));
} catch (Exception e) { } catch (Exception e) {
if (running) e.printStackTrace(); if (running) e.printStackTrace();
else break; // is this neccessary? else break; // is this neccessary?
@ -132,7 +131,7 @@ public class VoiceChatPlugin extends Bot.Listener {
new JoinGroupPacket(clientGroup.id(), password).toBytes(buf); new JoinGroupPacket(clientGroup.id(), password).toBytes(buf);
bot.session().send(new ServerboundCustomPayloadPacket( bot.session.send(new ServerboundCustomPayloadPacket(
"voicechat:set_group", "voicechat:set_group",
buf.array() buf.array()
)); ));

View file

@ -1,9 +1,6 @@
package land.chipmunk.chayapak.chomens_bot.song; package land.chipmunk.chayapak.chomens_bot.song;
import lombok.AllArgsConstructor;
// Author: hhhzzzsss // Author: hhhzzzsss
@AllArgsConstructor
public class Instrument { public class Instrument {
public static final Instrument HARP = new Instrument(0, "harp", 54); public static final Instrument HARP = new Instrument(0, "harp", 54);
public static final Instrument BASEDRUM = new Instrument(1, "basedrum", 0); public static final Instrument BASEDRUM = new Instrument(1, "basedrum", 0);
@ -34,6 +31,13 @@ public class Instrument {
this.sound = "minecraft:block.note_block." + name; this.sound = "minecraft:block.note_block." + name;
} }
public Instrument (int id, String name, int offset, String sound) {
this.id = id;
this.name = name;
this.offset = offset;
this.sound = sound;
}
public static Instrument of (String sound) { public static Instrument of (String sound) {
return new Instrument(-1, null, 0, sound); return new Instrument(-1, null, 0, sound);
} }

View file

@ -1,9 +1,6 @@
package land.chipmunk.chayapak.chomens_bot.song; package land.chipmunk.chayapak.chomens_bot.song;
import lombok.AllArgsConstructor;
// Author: hhhzzzsss // Author: hhhzzzsss
@AllArgsConstructor
public class Note implements Comparable<Note> { public class Note implements Comparable<Note> {
public Instrument instrument; public Instrument instrument;
public int pitch; public int pitch;
@ -12,6 +9,22 @@ public class Note implements Comparable<Note> {
public int panning; public int panning;
public int stereo; public int stereo;
public Note (
Instrument instrument,
int pitch,
float volume,
long time,
int panning,
int stereo
) {
this.instrument = instrument;
this.pitch = pitch;
this.volume = volume;
this.time = time;
this.panning = panning;
this.stereo = stereo;
}
@Override @Override
public int compareTo(Note other) { public int compareTo(Note other) {
return Long.compare(time, other.time); return Long.compare(time, other.time);

View file

@ -86,16 +86,16 @@ public class Song {
} }
public void advanceTime () { public void advanceTime () {
time = (long) ((System.currentTimeMillis() - startTime) * bot.music().speed()); time = (long) ((System.currentTimeMillis() - startTime) * bot.music.speed);
} }
public boolean reachedNextNote () { public boolean reachedNextNote () {
if (position < notes.size()) { if (position < notes.size()) {
return notes.get(position).time <= time * bot.music().speed(); return notes.get(position).time <= time * bot.music.speed;
} else { } else {
if (finished() && bot.music().loop() != Loop.OFF) { if (finished() && bot.music.loop != Loop.OFF) {
if (position < notes.size()) { if (position < notes.size()) {
return notes.get(position).time <= time * bot.music().speed(); return notes.get(position).time <= time * bot.music.speed;
} else { } else {
return false; return false;
} }
@ -107,7 +107,7 @@ public class Song {
public Note getNextNote () { public Note getNextNote () {
if (position >= notes.size()) { if (position >= notes.size()) {
if (bot.music().loop() == Loop.OFF) return null; if (bot.music.loop == Loop.OFF) return null;
} }
return notes.get(position++); return notes.get(position++);
} }

View file

@ -1,11 +1,10 @@
package land.chipmunk.chayapak.chomens_bot.song; package land.chipmunk.chayapak.chomens_bot.song;
import lombok.Getter;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
// Author: _ChipMC_ or hhhzzzsss? // Author: _ChipMC_ or hhhzzzsss?
public class SongLoaderException extends Exception { public class SongLoaderException extends Exception {
@Getter private final Component message; public final Component message;
public SongLoaderException (Component message) { public SongLoaderException (Component message) {
super(); super();

View file

@ -80,19 +80,19 @@ public class SongLoaderRunnable implements Runnable {
failed(); failed();
} else { } else {
bot.music().songQueue().add(song); bot.music.songQueue.add(song);
bot.chat().tellraw( bot.chat.tellraw(
Component.translatable( Component.translatable(
"Added %s to the song queue", "Added %s to the song queue",
Component.empty().append(song.name).color(ColorUtilities.getColorByString(bot.config().colorPalette().secondary())) Component.empty().append(song.name).color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary))
).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())) ).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor))
); );
} }
} }
private void failed() { private void failed() {
exception.printStackTrace(); exception.printStackTrace();
bot.chat().tellraw(Component.translatable("Failed to load song: %s", exception.message()).color(NamedTextColor.RED)); bot.chat.tellraw(Component.translatable("Failed to load song: %s", exception.message).color(NamedTextColor.RED));
bot.music().loaderThread(null); bot.music.loaderThread = null;
} }
} }

View file

@ -3,7 +3,6 @@ package land.chipmunk.chayapak.chomens_bot.util;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import lombok.AllArgsConstructor;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.TranslatableComponent; import net.kyori.adventure.text.TranslatableComponent;
@ -63,11 +62,10 @@ public class ComponentUtilities {
ansiMap.put("r", "\u001b[0m"); ansiMap.put("r", "\u001b[0m");
} }
@AllArgsConstructor private static record PartiallyStringifiedOutput (
private static class PartiallyStringifiedOutput { String output,
public String output; String lastColor
public String lastColor; ) {}
}
private ComponentUtilities () { private ComponentUtilities () {
} }

View file

@ -1,14 +1,12 @@
package land.chipmunk.chayapak.chomens_bot.util; package land.chipmunk.chayapak.chomens_bot.util;
import lombok.Getter;
import java.util.*; import java.util.*;
// totally didn't ask chatgpt for this lmao // totally didn't ask chatgpt for this lmao
public class MazeGenerator { public class MazeGenerator {
@Getter private final int width; public final int width;
@Getter private final int height; public final int height;
@Getter private final int[][] maze; public final int[][] maze;
private final Random rand; private final Random rand;
public MazeGenerator(int width, int height) { public MazeGenerator(int width, int height) {

View file

@ -2,32 +2,31 @@ package land.chipmunk.chayapak.chomens_bot.voiceChat;
import land.chipmunk.chayapak.chomens_bot.data.voiceChat.Codec; import land.chipmunk.chayapak.chomens_bot.data.voiceChat.Codec;
import land.chipmunk.chayapak.chomens_bot.voiceChat.customPayload.SecretPacket; import land.chipmunk.chayapak.chomens_bot.voiceChat.customPayload.SecretPacket;
import lombok.Getter;
import java.util.UUID; import java.util.UUID;
public class InitializationData { public class InitializationData {
@Getter private final String serverIP; public final String serverIP;
@Getter private final int serverPort; public final int serverPort;
@Getter private final UUID playerUUID; public final UUID playerUUID;
@Getter private final UUID secret; public final UUID secret;
@Getter private final Codec codec; public final Codec codec;
@Getter private final int mtuSize; public final int mtuSize;
@Getter private final double voiceChatDistance; public final double voiceChatDistance;
@Getter private final int keepAlive; public final int keepAlive;
@Getter private final boolean groupsEnabled; public final boolean groupsEnabled;
@Getter private final boolean allowRecording; public final boolean allowRecording;
public InitializationData(String serverIP, SecretPacket secretPacket) { public InitializationData(String serverIP, SecretPacket secretPacket) {
this.serverIP = serverIP; this.serverIP = serverIP;
this.serverPort = secretPacket.serverPort(); this.serverPort = secretPacket.serverPort;
this.playerUUID = secretPacket.playerUUID(); this.playerUUID = secretPacket.playerUUID;
this.secret = secretPacket.secret(); this.secret = secretPacket.secret;
this.codec = secretPacket.codec(); this.codec = secretPacket.codec;
this.mtuSize = secretPacket.mtuSize(); this.mtuSize = secretPacket.mtuSize;
this.voiceChatDistance = secretPacket.voiceChatDistance(); this.voiceChatDistance = secretPacket.voiceChatDistance;
this.keepAlive = secretPacket.keepAlive(); this.keepAlive = secretPacket.keepAlive;
this.groupsEnabled = secretPacket.groupsEnabled(); this.groupsEnabled = secretPacket.groupsEnabled;
this.allowRecording = secretPacket.allowRecording(); this.allowRecording = secretPacket.allowRecording;
} }
} }

View file

@ -5,7 +5,6 @@ import land.chipmunk.chayapak.chomens_bot.data.voiceChat.RawUdpPacket;
import land.chipmunk.chayapak.chomens_bot.util.AES; import land.chipmunk.chayapak.chomens_bot.util.AES;
import land.chipmunk.chayapak.chomens_bot.util.FriendlyByteBuf; import land.chipmunk.chayapak.chomens_bot.util.FriendlyByteBuf;
import land.chipmunk.chayapak.chomens_bot.voiceChat.packets.*; import land.chipmunk.chayapak.chomens_bot.voiceChat.packets.*;
import lombok.Getter;
import javax.crypto.BadPaddingException; import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException; import javax.crypto.IllegalBlockSizeException;
@ -22,9 +21,9 @@ import java.util.UUID;
public class NetworkMessage { public class NetworkMessage {
public static final byte MAGIC_BYTE = (byte) 0b11111111; public static final byte MAGIC_BYTE = (byte) 0b11111111;
@Getter private final long timestamp; public final long timestamp;
@Getter private Packet<? extends Packet<?>> packet; public Packet<? extends Packet<?>> packet;
@Getter private SocketAddress address; public SocketAddress address;
public NetworkMessage(Packet<?> packet) { public NetworkMessage(Packet<?> packet) {
this(System.currentTimeMillis()); this(System.currentTimeMillis());
@ -59,7 +58,7 @@ public class NetworkMessage {
if (b.readByte() != MAGIC_BYTE) return null; if (b.readByte() != MAGIC_BYTE) return null;
return readFromBytes(packet.socketAddress(), initializationData.secret(), b.readByteArray(), System.currentTimeMillis()); return readFromBytes(packet.socketAddress(), initializationData.secret, b.readByteArray(), System.currentTimeMillis());
} }
private static NetworkMessage readFromBytes(SocketAddress socketAddress, UUID secret, byte[] encryptedPayload, long timestamp) throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException { private static NetworkMessage readFromBytes(SocketAddress socketAddress, UUID secret, byte[] encryptedPayload, long timestamp) throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
@ -94,10 +93,10 @@ public class NetworkMessage {
} }
public byte[] writeClient(InitializationData data) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException { public byte[] writeClient(InitializationData data) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException {
byte[] payload = write(data.secret()); byte[] payload = write(data.secret);
FriendlyByteBuf buffer = new FriendlyByteBuf(Unpooled.buffer(1 + 16 + payload.length)); FriendlyByteBuf buffer = new FriendlyByteBuf(Unpooled.buffer(1 + 16 + payload.length));
buffer.writeByte(MAGIC_BYTE); buffer.writeByte(MAGIC_BYTE);
buffer.writeUUID(data.playerUUID()); buffer.writeUUID(data.playerUUID);
buffer.writeByteArray(payload); buffer.writeByteArray(payload);
byte[] bytes = new byte[buffer.readableBytes()]; byte[] bytes = new byte[buffer.readableBytes()];

Some files were not shown because too many files have changed in this diff Show more