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:
parent
df66e94680
commit
5eadb1c868
105 changed files with 1033 additions and 1014 deletions
|
@ -6,7 +6,6 @@ plugins {
|
|||
id 'java'
|
||||
id 'java-library'
|
||||
id 'maven-publish'
|
||||
id 'io.freefair.lombok' version '8.0.1'
|
||||
id 'com.github.johnrengelman.shadow' version '8.1.1'
|
||||
}
|
||||
|
||||
|
|
|
@ -11,8 +11,6 @@ import com.github.steveice10.packetlib.tcp.TcpClientSession;
|
|||
import land.chipmunk.chayapak.chomens_bot.plugins.*;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.ComponentUtilities;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.RandomStringUtilities;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -23,56 +21,56 @@ import java.util.concurrent.TimeUnit;
|
|||
public class Bot {
|
||||
private final ArrayList<Listener> listeners = new ArrayList<>();
|
||||
|
||||
@Getter private final String host;
|
||||
@Getter private final int port;
|
||||
public final String host;
|
||||
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;
|
||||
@Getter private final ScheduledExecutorService executor = Main.executor;
|
||||
public final ExecutorService executorService = Main.executorService;
|
||||
public final ScheduledExecutorService executor = Main.executor;
|
||||
|
||||
@Getter @Setter private ConsolePlugin console;
|
||||
@Getter @Setter private LoggerPlugin logger; // in ConsolePlugin
|
||||
@Getter @Setter private DiscordPlugin discord; // same for this one too
|
||||
public ConsolePlugin console;
|
||||
public LoggerPlugin logger; // in ConsolePlugin
|
||||
public DiscordPlugin discord; // same for this one too
|
||||
|
||||
@Getter private TickPlugin tick;
|
||||
@Getter private ChatPlugin chat;
|
||||
@Getter private PositionPlugin position;
|
||||
@Getter private SelfCarePlugin selfCare;
|
||||
@Getter private CorePlugin core;
|
||||
@Getter private TeamPlugin team;
|
||||
@Getter private PlayersPlugin players;
|
||||
@Getter private TabCompletePlugin tabComplete;
|
||||
@Getter private CommandHandlerPlugin commandHandler;
|
||||
@Getter private ChatCommandHandlerPlugin chatCommandHandler;
|
||||
@Getter private HashingPlugin hashing;
|
||||
@Getter private BossbarManagerPlugin bossbar;
|
||||
@Getter private MusicPlayerPlugin music;
|
||||
@Getter private TPSPlugin tps;
|
||||
@Getter private EvalPlugin eval;
|
||||
@Getter private TrustedPlugin trusted;
|
||||
@Getter private BruhifyPlugin bruhify;
|
||||
@Getter private GrepLogPlugin grepLog;
|
||||
@Getter private CloopPlugin cloop;
|
||||
@Getter private MazePlugin maze;
|
||||
@Getter private ExploitsPlugin exploits;
|
||||
@Getter private FilterPlugin filter;
|
||||
@Getter private CommandSuggestionPlugin commandSuggestion;
|
||||
@Getter private MailPlugin mail;
|
||||
@Getter private PacketSnifferPlugin packetSniffer;
|
||||
@Getter private VoiceChatPlugin voiceChat;
|
||||
public TickPlugin tick;
|
||||
public ChatPlugin chat;
|
||||
public PositionPlugin position;
|
||||
public SelfCarePlugin selfCare;
|
||||
public CorePlugin core;
|
||||
public TeamPlugin team;
|
||||
public PlayersPlugin players;
|
||||
public TabCompletePlugin tabComplete;
|
||||
public CommandHandlerPlugin commandHandler;
|
||||
public ChatCommandHandlerPlugin chatCommandHandler;
|
||||
public HashingPlugin hashing;
|
||||
public BossbarManagerPlugin bossbar;
|
||||
public MusicPlayerPlugin music;
|
||||
public TPSPlugin tps;
|
||||
public EvalPlugin eval;
|
||||
public TrustedPlugin trusted;
|
||||
public BruhifyPlugin bruhify;
|
||||
public GrepLogPlugin grepLog;
|
||||
public CloopPlugin cloop;
|
||||
public MazePlugin maze;
|
||||
public ExploitsPlugin exploits;
|
||||
public FilterPlugin filter;
|
||||
public CommandSuggestionPlugin commandSuggestion;
|
||||
public MailPlugin mail;
|
||||
public PacketSnifferPlugin packetSniffer;
|
||||
public VoiceChatPlugin voiceChat;
|
||||
|
||||
public Bot (Configuration.BotOption botOption, List<Bot> bots, Configuration config) {
|
||||
this.host = botOption.host;
|
||||
|
@ -132,7 +130,7 @@ public class Bot {
|
|||
listener.connecting();
|
||||
}
|
||||
|
||||
final String _username = options.username();
|
||||
final String _username = options.username;
|
||||
|
||||
if (_username == null) username = RandomStringUtilities.generate(8);
|
||||
else username = _username;
|
||||
|
@ -195,7 +193,7 @@ public class Bot {
|
|||
public void disconnected(DisconnectedEvent disconnectedEvent) {
|
||||
loggedIn = false;
|
||||
|
||||
int reconnectDelay = options.reconnectDelay();
|
||||
int reconnectDelay = options.reconnectDelay;
|
||||
|
||||
final String stringMessage = ComponentUtilities.stringify(disconnectedEvent.getReason());
|
||||
|
||||
|
|
|
@ -1,138 +1,135 @@
|
|||
package land.chipmunk.chayapak.chomens_bot;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class Configuration {
|
||||
@Getter public List<String> prefixes;
|
||||
@Getter public List<String> commandSpyPrefixes;
|
||||
public List<String> prefixes;
|
||||
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();
|
||||
@Getter public Discord discord = new Discord();
|
||||
public Core core = new Core();
|
||||
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<>();
|
||||
@Getter public SelfCare selfCare = new SelfCare();
|
||||
@Getter public Eval eval = new Eval();
|
||||
public List<String> trusted = new ArrayList<>();
|
||||
public SelfCare selfCare = new SelfCare();
|
||||
public Eval eval = new Eval();
|
||||
|
||||
@Getter public BotOption[] bots = new BotOption[]{};
|
||||
public BotOption[] bots = new BotOption[]{};
|
||||
|
||||
public static class ConsolePrefixes {
|
||||
@Getter public String normalCommandsPrefix;
|
||||
@Getter public String consoleServerPrefix;
|
||||
public String normalCommandsPrefix;
|
||||
public String consoleServerPrefix;
|
||||
}
|
||||
|
||||
public static class Keys {
|
||||
@Getter public String normalKey;
|
||||
@Getter public String ownerKey;
|
||||
public String normalKey;
|
||||
public String ownerKey;
|
||||
}
|
||||
|
||||
public static class Core {
|
||||
@Getter public Position start = new Position();
|
||||
@Getter public Position end = new Position();
|
||||
@Getter public int refillInterval = (60 * 5) * 1000; // 5 minutes
|
||||
@Getter public String customName = "{\"text\":\"@\"}";
|
||||
public Position start = new Position();
|
||||
public Position end = new Position();
|
||||
public int refillInterval = (60 * 5) * 1000; // 5 minutes
|
||||
public String customName = "{\"text\":\"@\"}";
|
||||
}
|
||||
|
||||
public static class Position {
|
||||
@Getter public int x = 0;
|
||||
@Getter public int y = 0;
|
||||
@Getter public int z = 0;
|
||||
public int x = 0;
|
||||
public int y = 0;
|
||||
public int z = 0;
|
||||
}
|
||||
|
||||
public static class ColorPalette {
|
||||
@Getter public String primary = "yellow";
|
||||
@Getter public String secondary = "gold";
|
||||
@Getter public String defaultColor = "white";
|
||||
@Getter public String username = "gold";
|
||||
@Getter public String uuid = "aqua";
|
||||
@Getter public String string = "aqua";
|
||||
@Getter public String number = "gold";
|
||||
@Getter public String ownerName = "green";
|
||||
public String primary = "yellow";
|
||||
public String secondary = "gold";
|
||||
public String defaultColor = "white";
|
||||
public String username = "gold";
|
||||
public String uuid = "aqua";
|
||||
public String string = "aqua";
|
||||
public String number = "gold";
|
||||
public String ownerName = "green";
|
||||
}
|
||||
|
||||
public static class Discord {
|
||||
@Getter public boolean enabled = true;
|
||||
@Getter public String prefix = "default!";
|
||||
@Getter public String token;
|
||||
@Getter public Map<String, String> servers = new HashMap<>();
|
||||
@Getter public EmbedColors embedColors = new EmbedColors();
|
||||
@Getter public String trustedRoleName = "Trusted";
|
||||
@Getter public String adminRoleName = "Admin";
|
||||
@Getter public String statusMessage = "Gay Sex";
|
||||
@Getter public String inviteLink = "https://discord.gg/xdgCkUyaA4";
|
||||
public boolean enabled = true;
|
||||
public String prefix = "default!";
|
||||
public String token;
|
||||
public Map<String, String> servers = new HashMap<>();
|
||||
public EmbedColors embedColors = new EmbedColors();
|
||||
public String trustedRoleName = "Trusted";
|
||||
public String adminRoleName = "Admin";
|
||||
public String statusMessage = "Gay Sex";
|
||||
public String inviteLink = "https://discord.gg/xdgCkUyaA4";
|
||||
}
|
||||
|
||||
public static class EmbedColors {
|
||||
@Getter public String normal = "#FFFF00";
|
||||
@Getter public String error = "#FF0000";
|
||||
public String normal = "#FFFF00";
|
||||
public String error = "#FF0000";
|
||||
}
|
||||
|
||||
public static class SelfCare {
|
||||
@Getter public boolean op = true;
|
||||
@Getter public boolean gamemode = true;
|
||||
@Getter public boolean endCredits = true;
|
||||
public boolean op = true;
|
||||
public boolean gamemode = true;
|
||||
public boolean endCredits = true;
|
||||
|
||||
@Getter public boolean vanish = true;
|
||||
@Getter public boolean nickname = true;
|
||||
@Getter public boolean socialspy = true;
|
||||
@Getter public boolean mute = true;
|
||||
public boolean vanish = true;
|
||||
public boolean nickname = true;
|
||||
public boolean socialspy = 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 {
|
||||
@Getter public boolean enabled = true;
|
||||
@Getter public int positionPacketsPerSecond = 10;
|
||||
public boolean enabled = true;
|
||||
public int positionPacketsPerSecond = 10;
|
||||
}
|
||||
|
||||
@Getter public Prefix prefix = new Prefix();
|
||||
public Prefix prefix = new Prefix();
|
||||
|
||||
public static class Prefix {
|
||||
@Getter public boolean enabled = true;
|
||||
@Getter public String prefix = "&8[&eChomeNS Bot&8]";
|
||||
public boolean enabled = true;
|
||||
public String prefix = "&8[&eChomeNS Bot&8]";
|
||||
}
|
||||
|
||||
@Getter public boolean username = true;
|
||||
public boolean username = true;
|
||||
}
|
||||
|
||||
public static class Eval {
|
||||
@Getter public String address = "ws://localhost:3069";
|
||||
public String address = "ws://localhost:3069";
|
||||
}
|
||||
|
||||
public static class BotOption {
|
||||
@Getter public String host;
|
||||
@Getter public int port;
|
||||
@Getter public String username;
|
||||
@Getter public boolean kaboom = false;
|
||||
@Getter public boolean creayun = false;
|
||||
@Getter public String serverName;
|
||||
@Getter @Setter public boolean useCore = true;
|
||||
@Getter @Setter public boolean useChat = false;
|
||||
@Getter public boolean hasEssentials = true;
|
||||
@Getter public int reconnectDelay = 2000;
|
||||
@Getter public boolean removeNamespaces = false;
|
||||
@Getter public int chatQueueDelay = 125;
|
||||
@Getter public CoreRateLimit coreRateLimit = new CoreRateLimit();
|
||||
public String host;
|
||||
public int port;
|
||||
public String username;
|
||||
public boolean kaboom = false;
|
||||
public boolean creayun = false;
|
||||
public String serverName;
|
||||
public boolean useCore = true;
|
||||
public boolean useChat = false;
|
||||
public boolean hasEssentials = true;
|
||||
public int reconnectDelay = 2000;
|
||||
public boolean removeNamespaces = false;
|
||||
public int chatQueueDelay = 125;
|
||||
public CoreRateLimit coreRateLimit = new CoreRateLimit();
|
||||
|
||||
public static class CoreRateLimit {
|
||||
@Getter public int limit = 0;
|
||||
@Getter public int reset = 0;
|
||||
public int limit = 0;
|
||||
public int reset = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,12 +57,12 @@ public class Main {
|
|||
|
||||
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
|
||||
JDA jda = null;
|
||||
if (config.discord().enabled()) {
|
||||
JDABuilder builder = JDABuilder.createDefault(config.discord().token());
|
||||
if (config.discord.enabled) {
|
||||
JDABuilder builder = JDABuilder.createDefault(config.discord.token);
|
||||
try {
|
||||
jda = builder.build();
|
||||
jda.awaitReady();
|
||||
|
@ -73,7 +73,7 @@ public class Main {
|
|||
} catch (InterruptedException ignored) {
|
||||
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) {
|
||||
|
|
|
@ -29,7 +29,7 @@ public class CreayunChatParser implements ChatParser {
|
|||
public PlayerMessage parse (Component 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);
|
||||
|
||||
|
@ -37,7 +37,7 @@ public class CreayunChatParser implements ChatParser {
|
|||
final String displayName = matcher.group(1);
|
||||
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);
|
||||
|
||||
return new PlayerMessage(sender, Component.text(displayName), Component.text(contents));
|
||||
|
|
|
@ -43,8 +43,8 @@ public class KaboomChatParser implements ChatParser {
|
|||
return null;
|
||||
}
|
||||
|
||||
MutablePlayerListEntry sender = bot.players().getEntry(Component.empty().append(prefix).append(displayName));
|
||||
if (sender == null) sender = bot.players().getEntry(prefix.append(displayName)); // old
|
||||
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 = 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);
|
||||
|
|
|
@ -47,10 +47,10 @@ public class MinecraftChatParser implements ChatParser {
|
|||
if (hoverEvent != null && hoverEvent.action().equals(HoverEvent.Action.SHOW_ENTITY)) {
|
||||
HoverEvent.ShowEntity entityInfo = (HoverEvent.ShowEntity) hoverEvent.value();
|
||||
final UUID senderUUID = entityInfo.id();
|
||||
sender = bot.players().getEntry(senderUUID);
|
||||
sender = bot.players.getEntry(senderUUID);
|
||||
} else {
|
||||
final String stringUsername = ComponentUtilities.stringify(senderComponent);
|
||||
sender = bot.players().getEntry(stringUsername);
|
||||
sender = bot.players.getEntry(stringUsername);
|
||||
}
|
||||
|
||||
if (sender == null) return null;
|
||||
|
|
|
@ -39,10 +39,10 @@ public class U203aChatParser implements ChatParser {
|
|||
if (hoverEvent != null && hoverEvent.action().equals(HoverEvent.Action.SHOW_ENTITY)) {
|
||||
HoverEvent.ShowEntity entityInfo = (HoverEvent.ShowEntity) hoverEvent.value();
|
||||
final UUID senderUUID = entityInfo.id();
|
||||
sender = bot.players().getEntry(senderUUID);
|
||||
sender = bot.players.getEntry(senderUUID);
|
||||
} else {
|
||||
final String stringUsername = ComponentUtilities.stringify(senderComponent);
|
||||
sender = bot.players().getEntry(stringUsername);
|
||||
sender = bot.players.getEntry(stringUsername);
|
||||
}
|
||||
|
||||
if (sender == null) return null;
|
||||
|
|
|
@ -40,7 +40,7 @@ public class CommandSpyParser implements ChatParser {
|
|||
final Component command = children.get(1);
|
||||
|
||||
final String stringUsername = ComponentUtilities.stringify(username);
|
||||
MutablePlayerListEntry sender = bot.players().getEntry(stringUsername);
|
||||
MutablePlayerListEntry sender = bot.players.getEntry(stringUsername);
|
||||
|
||||
if (sender == null) return null;
|
||||
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
package land.chipmunk.chayapak.chomens_bot.command;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
public abstract class Command {
|
||||
@Getter private final String name;
|
||||
@Getter private final String description;
|
||||
@Getter private final String[] usages;
|
||||
@Getter private final String[] aliases;
|
||||
@Getter private final TrustLevel trustLevel;
|
||||
public final String name;
|
||||
public final String description;
|
||||
public final String[] usages;
|
||||
public final String[] aliases;
|
||||
public final TrustLevel trustLevel;
|
||||
|
||||
public Command (
|
||||
String name,
|
||||
|
|
|
@ -2,20 +2,19 @@ package land.chipmunk.chayapak.chomens_bot.command;
|
|||
|
||||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry;
|
||||
import lombok.Getter;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
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;
|
||||
@Getter private final String ownerHash;
|
||||
public final String hash;
|
||||
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) {
|
||||
this.bot = bot;
|
||||
|
|
|
@ -9,18 +9,18 @@ public class ConsoleCommandContext extends CommandContext {
|
|||
private final Bot bot;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendOutput (Component component) {
|
||||
final String message = ComponentUtilities.stringifyAnsi(component);
|
||||
bot.logger().info(message);
|
||||
bot.logger.info(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component displayName () {
|
||||
return sender().displayName().color(NamedTextColor.YELLOW);
|
||||
return sender.displayName.color(NamedTextColor.YELLOW);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ public class DiscordCommandContext extends CommandContext {
|
|||
final String output = ComponentUtilities.stringifyAnsi(component);
|
||||
final EmbedBuilder builder = new EmbedBuilder();
|
||||
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```");
|
||||
|
||||
final MessageEmbed embed = builder.build();
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
package land.chipmunk.chayapak.chomens_bot.command;
|
||||
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry;
|
||||
import lombok.Getter;
|
||||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
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;
|
||||
|
||||
|
@ -21,11 +20,11 @@ public class PlayerCommandContext extends CommandContext {
|
|||
|
||||
@Override
|
||||
public void sendOutput (Component message) {
|
||||
bot.chat().tellraw(message, selector);
|
||||
bot.chat.tellraw(message, selector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component displayName () {
|
||||
return sender().displayName();
|
||||
return sender.displayName;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,10 +23,10 @@ public class BotUserCommand extends Command {
|
|||
|
||||
@Override
|
||||
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 uuid = bot.profile().getIdAsString();
|
||||
final String username = bot.username;
|
||||
final String uuid = bot.profile.getIdAsString();
|
||||
|
||||
return Component.translatable(
|
||||
"The bot's username is: %s and the UUID is: %s",
|
||||
|
@ -42,7 +42,7 @@ public class BotUserCommand extends Command {
|
|||
.clickEvent(
|
||||
ClickEvent.copyToClipboard(username)
|
||||
)
|
||||
.color(ColorUtilities.getColorByString(bot.config().colorPalette().username())),
|
||||
.color(ColorUtilities.getColorByString(bot.config.colorPalette.username)),
|
||||
Component
|
||||
.text(uuid)
|
||||
.hoverEvent(
|
||||
|
@ -55,7 +55,7 @@ public class BotUserCommand extends Command {
|
|||
.clickEvent(
|
||||
ClickEvent.copyToClipboard(uuid)
|
||||
)
|
||||
.color(ColorUtilities.getColorByString(bot.config().colorPalette().uuid()))
|
||||
).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor()));
|
||||
.color(ColorUtilities.getColorByString(bot.config.colorPalette.uuid))
|
||||
).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,36 +21,36 @@ public class BotVisibilityCommand extends Command {
|
|||
|
||||
@Override
|
||||
public Component execute(CommandContext context, String[] args, String[] fullArgs) {
|
||||
final Bot bot = context.bot();
|
||||
final Bot bot = context.bot;
|
||||
|
||||
if (args.length == 0) {
|
||||
final boolean visibility = bot.selfCare().visibility();
|
||||
bot.selfCare().visibility(!visibility);
|
||||
final boolean visibility = bot.selfCare.visibility;
|
||||
bot.selfCare.visibility = !visibility;
|
||||
|
||||
final NamedTextColor greenOrGold = bot.selfCare().visibility() ? NamedTextColor.GREEN : NamedTextColor.GOLD;
|
||||
final String visibleOrInvisible = bot.selfCare().visibility() ? "visible" : "invisible";
|
||||
final String disableOrEnable = bot.selfCare().visibility() ? "disable" : "enable";
|
||||
bot.chat().send("/essentials:vanish " + disableOrEnable);
|
||||
final NamedTextColor greenOrGold = bot.selfCare.visibility ? NamedTextColor.GREEN : NamedTextColor.GOLD;
|
||||
final String visibleOrInvisible = bot.selfCare.visibility ? "visible" : "invisible";
|
||||
final String disableOrEnable = bot.selfCare.visibility ? "disable" : "enable";
|
||||
bot.chat.send("/essentials:vanish " + disableOrEnable);
|
||||
return Component.empty()
|
||||
.append(Component.text("The bot's visibility is now "))
|
||||
.append(Component.text(visibleOrInvisible).color(greenOrGold));
|
||||
} else {
|
||||
switch (args[0]) {
|
||||
case "on", "true" -> {
|
||||
bot.selfCare().visibility(true);
|
||||
bot.chat().send("/essentials:vanish disable");
|
||||
bot.selfCare.visibility = true;
|
||||
bot.chat.send("/essentials:vanish disable");
|
||||
return Component.empty()
|
||||
.append(Component.text("The bot's visibility is now "))
|
||||
.append(Component.text("visible").color(NamedTextColor.GREEN))
|
||||
.color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor()));
|
||||
.color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
|
||||
}
|
||||
case "off", "false" -> {
|
||||
bot.selfCare().visibility(false);
|
||||
bot.chat().send("/essentials:vanish enable");
|
||||
bot.selfCare.visibility = false;
|
||||
bot.chat.send("/essentials:vanish enable");
|
||||
return Component.empty()
|
||||
.append(Component.text("The bot's visibility is now "))
|
||||
.append(Component.text("invisible").color(NamedTextColor.GOLD))
|
||||
.color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor()));
|
||||
.color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
|
||||
}
|
||||
default -> {
|
||||
return Component.text("Invalid argument").color(NamedTextColor.RED);
|
||||
|
|
|
@ -22,12 +22,12 @@ public class BruhifyCommand extends Command {
|
|||
|
||||
@Override
|
||||
public Component execute(CommandContext context, String[] args, String[] fullArgs) {
|
||||
final Bot bot = context.bot();
|
||||
final Bot bot = context.bot;
|
||||
|
||||
if (args.length == 0) {
|
||||
bot.bruhify().bruhifyText("");
|
||||
bot.bruhify.bruhifyText = "";
|
||||
} else {
|
||||
bot.bruhify().bruhifyText(String.join(" ", args));
|
||||
bot.bruhify.bruhifyText = String.join(" ", args);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -25,16 +25,16 @@ public class ClearChatCommand extends Command {
|
|||
|
||||
@Override
|
||||
public Component execute(CommandContext context, String[] args, String[] fullArgs) {
|
||||
final Bot bot = context.bot();
|
||||
final Bot bot = context.bot;
|
||||
|
||||
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);
|
||||
|
||||
final UUID uuid = entry.profile().getId();
|
||||
final UUID uuid = entry.profile.getId();
|
||||
|
||||
bot.chat().tellraw(
|
||||
bot.chat.tellraw(
|
||||
Component.empty()
|
||||
.append(Component.text("\n".repeat(1000)))
|
||||
.append(
|
||||
|
@ -46,7 +46,7 @@ public class ClearChatCommand extends Command {
|
|||
uuid
|
||||
);
|
||||
} else {
|
||||
bot.chat().tellraw(
|
||||
bot.chat.tellraw(
|
||||
Component.empty()
|
||||
.append(Component.text("\n".repeat(1000)))
|
||||
.append(Component.text("The chat has been cleared").color(NamedTextColor.DARK_GREEN))
|
||||
|
|
|
@ -46,9 +46,9 @@ public class ClearChatQueueCommand extends Command {
|
|||
|
||||
@Override
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ public class CloopCommand extends Command {
|
|||
|
||||
@Override
|
||||
public Component execute(CommandContext context, String[] args, String[] fullArgs) {
|
||||
final Bot bot = context.bot();
|
||||
final Bot bot = context.bot;
|
||||
|
||||
switch (args[0]) {
|
||||
case "add" -> {
|
||||
|
@ -42,42 +42,42 @@ public class CloopCommand extends Command {
|
|||
|
||||
final String command = String.join(" ", Arrays.copyOfRange(args, 2, args.length));
|
||||
|
||||
bot.cloop().add(interval, command);
|
||||
bot.cloop.add(interval, command);
|
||||
|
||||
return Component.translatable(
|
||||
"Added %s with interval %s to the cloops",
|
||||
Component.text(command).color(ColorUtilities.getColorByString(bot.config().colorPalette().string())),
|
||||
Component.text(interval).color(ColorUtilities.getColorByString(bot.config().colorPalette().number()))
|
||||
).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor()));
|
||||
Component.text(command).color(ColorUtilities.getColorByString(bot.config.colorPalette.string)),
|
||||
Component.text(interval).color(ColorUtilities.getColorByString(bot.config.colorPalette.number))
|
||||
).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
|
||||
}
|
||||
case "remove" -> {
|
||||
try {
|
||||
final int index = Integer.parseInt(args[1]);
|
||||
bot.cloop().remove(index);
|
||||
bot.cloop.remove(index);
|
||||
|
||||
return Component.translatable(
|
||||
"Removed cloop %s",
|
||||
Component.text(index).color(ColorUtilities.getColorByString(bot.config().colorPalette().number()))
|
||||
).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor()));
|
||||
Component.text(index).color(ColorUtilities.getColorByString(bot.config.colorPalette.number))
|
||||
).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
|
||||
} catch (IndexOutOfBoundsException | IllegalArgumentException | NullPointerException ignored) {
|
||||
return Component.text("Invalid index").color(NamedTextColor.RED);
|
||||
}
|
||||
}
|
||||
case "clear" -> {
|
||||
bot.cloop().clear();
|
||||
return Component.text("Cleared all cloops").color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor()));
|
||||
bot.cloop.clear();
|
||||
return Component.text("Cleared all cloops").color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
|
||||
}
|
||||
case "list" -> {
|
||||
final List<Component> cloopsComponent = new ArrayList<>();
|
||||
|
||||
int index = 0;
|
||||
for (CommandLoop command : bot.cloop().loops()) {
|
||||
for (CommandLoop command : bot.cloop.loops) {
|
||||
cloopsComponent.add(
|
||||
Component.translatable(
|
||||
"%s › %s (%s)",
|
||||
Component.text(index).color(ColorUtilities.getColorByString(bot.config().colorPalette().number())),
|
||||
Component.text(command.command()).color(ColorUtilities.getColorByString(bot.config().colorPalette().string())),
|
||||
Component.text(command.interval()).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.interval()).color(ColorUtilities.getColorByString(bot.config.colorPalette.number))
|
||||
).color(NamedTextColor.DARK_GRAY)
|
||||
);
|
||||
index++;
|
||||
|
@ -86,7 +86,7 @@ public class CloopCommand extends Command {
|
|||
return Component.empty()
|
||||
.append(Component.text("Cloops ").color(NamedTextColor.GREEN))
|
||||
.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.newline())
|
||||
.append(
|
||||
|
|
|
@ -26,9 +26,9 @@ public class CommandBlockCommand extends Command {
|
|||
|
||||
@Override
|
||||
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;
|
||||
|
||||
|
|
|
@ -23,11 +23,11 @@ public class CreatorCommand extends Command {
|
|||
|
||||
@Override
|
||||
public Component execute(CommandContext context, String[] args, String[] fullArgs) {
|
||||
final Bot bot = context.bot();
|
||||
final Bot bot = context.bot;
|
||||
|
||||
return Component.empty()
|
||||
.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("chayapak").color(ColorUtilities.getColorByString(bot.config().colorPalette().ownerName())));
|
||||
.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("chayapak").color(ColorUtilities.getColorByString(bot.config.colorPalette.ownerName)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,11 +22,11 @@ public class DiscordCommand extends Command {
|
|||
|
||||
@Override
|
||||
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()
|
||||
.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(
|
||||
Component
|
||||
.text(link)
|
||||
|
|
|
@ -19,9 +19,9 @@ public class EchoCommand extends Command {
|
|||
|
||||
@Override
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -19,9 +19,9 @@ public class EndCommand extends Command {
|
|||
|
||||
@Override
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -27,15 +27,15 @@ public class EvalCommand extends Command {
|
|||
public Component execute(CommandContext context, String[] args, String[] fullArgs) {
|
||||
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]) {
|
||||
case "run" -> {
|
||||
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) -> {
|
||||
if (output.isError()) context.sendOutput(Component.text(output.output()).color(NamedTextColor.RED));
|
||||
|
@ -45,9 +45,9 @@ public class EvalCommand extends Command {
|
|||
});
|
||||
}
|
||||
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 -> {
|
||||
return Component.text("Invalid argument").color(NamedTextColor.RED);
|
||||
|
|
|
@ -38,7 +38,7 @@ public class FilterCommand extends Command {
|
|||
|
||||
// most of these codes are from cloop and greplog
|
||||
public Component execute(CommandContext context, String[] _args, String[] fullArgs) {
|
||||
final Bot bot = context.bot();
|
||||
final Bot bot = context.bot;
|
||||
|
||||
boolean ignoreCase = false;
|
||||
boolean regex = false;
|
||||
|
@ -68,42 +68,42 @@ public class FilterCommand extends Command {
|
|||
case "add" -> {
|
||||
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(
|
||||
"Added %s to the filters",
|
||||
Component.text(player).color(ColorUtilities.getColorByString(bot.config().colorPalette().username()))
|
||||
).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor()));
|
||||
Component.text(player).color(ColorUtilities.getColorByString(bot.config.colorPalette.username))
|
||||
).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
|
||||
}
|
||||
case "remove" -> {
|
||||
try {
|
||||
final int index = Integer.parseInt(args[1]);
|
||||
|
||||
final FilteredPlayer removed = bot.filter().remove(index);
|
||||
final FilteredPlayer removed = bot.filter.remove(index);
|
||||
|
||||
return Component.translatable(
|
||||
"Removed %s from the filters",
|
||||
Component.text(removed.playerName).color(ColorUtilities.getColorByString(bot.config().colorPalette().username()))
|
||||
).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor()));
|
||||
Component.text(removed.playerName).color(ColorUtilities.getColorByString(bot.config.colorPalette.username))
|
||||
).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
|
||||
} catch (IndexOutOfBoundsException | IllegalArgumentException | NullPointerException ignored) {
|
||||
return Component.text("Invalid index").color(NamedTextColor.RED);
|
||||
}
|
||||
}
|
||||
case "clear" -> {
|
||||
bot.filter().clear();
|
||||
return Component.text("Cleared the filter").color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor()));
|
||||
bot.filter.clear();
|
||||
return Component.text("Cleared the filter").color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
|
||||
}
|
||||
case "list" -> {
|
||||
final List<Component> filtersComponents = new ArrayList<>();
|
||||
|
||||
int index = 0;
|
||||
for (JsonElement playerElement : FilterPlugin.filteredPlayers()) {
|
||||
for (JsonElement playerElement : FilterPlugin.filteredPlayers) {
|
||||
final FilteredPlayer player = gson.fromJson(playerElement, FilteredPlayer.class);
|
||||
|
||||
filtersComponents.add(
|
||||
Component.translatable(
|
||||
"%s › %s",
|
||||
Component.text(index).color(ColorUtilities.getColorByString(bot.config().colorPalette().number())),
|
||||
Component.text(player.playerName).color(ColorUtilities.getColorByString(bot.config().colorPalette().username()))
|
||||
Component.text(index).color(ColorUtilities.getColorByString(bot.config.colorPalette.number)),
|
||||
Component.text(player.playerName).color(ColorUtilities.getColorByString(bot.config.colorPalette.username))
|
||||
).color(NamedTextColor.DARK_GRAY)
|
||||
);
|
||||
|
||||
|
@ -113,7 +113,7 @@ public class FilterCommand extends Command {
|
|||
return Component.empty()
|
||||
.append(Component.text("Filtered players ").color(NamedTextColor.GREEN))
|
||||
.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.newline())
|
||||
.append(
|
||||
|
|
|
@ -21,7 +21,7 @@ public class GenerateMazeCommand extends Command {
|
|||
|
||||
@Override
|
||||
public Component execute(CommandContext context, String[] args, String[] fullArgs) {
|
||||
final Bot bot = context.bot();
|
||||
final Bot bot = context.bot;
|
||||
|
||||
try {
|
||||
final int x = Integer.parseInt(args[0]);
|
||||
|
@ -37,7 +37,7 @@ public class GenerateMazeCommand extends Command {
|
|||
|
||||
generator.generateMaze();
|
||||
|
||||
bot.maze().generate(generator, x, y, z);
|
||||
bot.maze.generate(generator, x, y, z);
|
||||
} catch (NumberFormatException e) {
|
||||
return Component.text("Invalid position/size").color(NamedTextColor.RED);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ public class GrepLogCommand extends Command {
|
|||
|
||||
@Override
|
||||
public Component execute(CommandContext context, String[] _args, String[] fullArgs) {
|
||||
final Bot bot = context.bot();
|
||||
final Bot bot = context.bot;
|
||||
|
||||
String[] args = _args;
|
||||
|
||||
|
@ -36,13 +36,13 @@ public class GrepLogCommand extends Command {
|
|||
boolean regex = false;
|
||||
|
||||
if (_args[0].equals("stop")) {
|
||||
bot.grepLog().thread().interrupt();
|
||||
bot.grepLog().thread(null);
|
||||
bot.grepLog.thread.interrupt();
|
||||
bot.grepLog.thread = null;
|
||||
|
||||
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
|
||||
if (_args[0].equals("-ignorecase")) {
|
||||
|
@ -61,7 +61,7 @@ public class GrepLogCommand extends Command {
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ public class HelpCommand extends Command {
|
|||
|
||||
@Override
|
||||
public Component execute(CommandContext context, String[] args, String[] fullArgs) {
|
||||
this.bot = context.bot();
|
||||
this.bot = context.bot;
|
||||
this.context = context;
|
||||
|
||||
if (args.length == 0) {
|
||||
|
@ -66,10 +66,10 @@ public class HelpCommand extends Command {
|
|||
|
||||
List<String> commandNames = new ArrayList<>();
|
||||
|
||||
for (Command command : bot.commandHandler().commands()) {
|
||||
if (command.trustLevel() != trustLevel) continue;
|
||||
for (Command command : bot.commandHandler.commands) {
|
||||
if (command.trustLevel != trustLevel) continue;
|
||||
|
||||
commandNames.add(command.name());
|
||||
commandNames.add(command.name);
|
||||
}
|
||||
|
||||
Collections.sort(commandNames);
|
||||
|
@ -99,39 +99,39 @@ public class HelpCommand extends Command {
|
|||
}
|
||||
|
||||
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()) {
|
||||
if (!command.name().equals(args[0]) && !Arrays.stream(command.aliases()).toList().contains(args[0])) continue;
|
||||
for (Command command : bot.commandHandler.commands) {
|
||||
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<>();
|
||||
|
||||
usages.add(
|
||||
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(
|
||||
(command.aliases().length > 0 && !command.aliases()[0].equals("")) ?
|
||||
" (" + String.join(", ", command.aliases()) + ")" :
|
||||
(command.aliases.length > 0 && !command.aliases[0].equals("")) ?
|
||||
" (" + String.join(", ", command.aliases) + ")" :
|
||||
""
|
||||
))
|
||||
.append(Component.text(" - " + command.description()).color(NamedTextColor.GRAY))
|
||||
.append(Component.text(" - " + command.description)).color(NamedTextColor.GRAY)
|
||||
);
|
||||
|
||||
usages.add(
|
||||
Component.empty()
|
||||
.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(
|
||||
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(usage).color(ColorUtilities.getColorByString(bot.config().colorPalette().string())))
|
||||
.append(Component.text(usage).color(ColorUtilities.getColorByString(bot.config.colorPalette.string)))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,20 +24,20 @@ public class KickCommand extends Command {
|
|||
|
||||
@Override
|
||||
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);
|
||||
|
||||
final String name = entry.profile().getName();
|
||||
final UUID uuid = entry.profile().getId();
|
||||
final String name = entry.profile.getName();
|
||||
final UUID uuid = entry.profile.getId();
|
||||
|
||||
bot.exploits().kick(uuid);
|
||||
bot.exploits.kick(uuid);
|
||||
|
||||
return Component.empty()
|
||||
.append(Component.text("Kicking player "))
|
||||
.append(Component.text(name).color(ColorUtilities.getColorByString(bot.config().colorPalette().username())))
|
||||
.color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor()));
|
||||
.append(Component.text(name).color(ColorUtilities.getColorByString(bot.config.colorPalette.username)))
|
||||
.color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,9 +28,9 @@ public class ListCommand extends Command {
|
|||
|
||||
@Override
|
||||
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<>();
|
||||
|
||||
|
@ -38,32 +38,32 @@ public class ListCommand extends Command {
|
|||
playersComponent.add(
|
||||
Component.translatable(
|
||||
"%s › %s",
|
||||
entry.displayName() == null ?
|
||||
Component.text(entry.profile().getName()).color(ColorUtilities.getColorByString(bot.config().colorPalette().username())) :
|
||||
entry.displayName()
|
||||
entry.displayName == null ?
|
||||
Component.text(entry.profile.getName()).color(ColorUtilities.getColorByString(bot.config.colorPalette.username)) :
|
||||
entry.displayName
|
||||
.hoverEvent(
|
||||
HoverEvent.showText(
|
||||
Component
|
||||
.text(entry.profile().getName())
|
||||
.text(entry.profile.getName())
|
||||
.append(Component.newline())
|
||||
.append(Component.text("Click here to copy the username to your clipboard").color(NamedTextColor.GREEN))
|
||||
)
|
||||
)
|
||||
.clickEvent(
|
||||
ClickEvent.copyToClipboard(entry.profile().getName())
|
||||
ClickEvent.copyToClipboard(entry.profile.getName())
|
||||
)
|
||||
.color(NamedTextColor.WHITE),
|
||||
Component
|
||||
.text(entry.profile().getIdAsString())
|
||||
.text(entry.profile.getIdAsString())
|
||||
.hoverEvent(
|
||||
HoverEvent.showText(
|
||||
Component.text("Click here to copy the UUID to your clipboard").color(NamedTextColor.GREEN)
|
||||
)
|
||||
)
|
||||
.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)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -45,59 +45,62 @@ public class MailCommand extends Command {
|
|||
public Component execute(CommandContext context, String[] args, String[] fullArgs) {
|
||||
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();
|
||||
|
||||
// kinda messy ngl
|
||||
|
||||
bot.executorService().submit(() -> {
|
||||
bot.executorService.submit(() -> {
|
||||
switch (args[0]) {
|
||||
case "send" -> {
|
||||
int senderMailsSentTotal = 0;
|
||||
for (JsonElement mailElement : MailPlugin.mails()) {
|
||||
for (JsonElement mailElement : MailPlugin.mails) {
|
||||
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++;
|
||||
}
|
||||
|
||||
if (senderMailsSentTotal > 256) context.sendOutput(Component.text("You are sending too much mails!").color(NamedTextColor.RED));
|
||||
|
||||
bot.mail().send(
|
||||
bot.mail.send(
|
||||
new Mail(
|
||||
sender.profile().getName(),
|
||||
sender.profile.getName(),
|
||||
args[1],
|
||||
Instant.now().toEpochMilli(),
|
||||
bot.host() + ":" + bot.port(),
|
||||
bot.host + ":" + bot.port,
|
||||
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" -> {
|
||||
int senderMailsSentTotal = 0;
|
||||
for (JsonElement mailElement : MailPlugin.mails()) {
|
||||
for (JsonElement mailElement : MailPlugin.mails) {
|
||||
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++;
|
||||
}
|
||||
|
||||
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 " +
|
||||
UUIDUtilities.selector(sender.profile().getId()) +
|
||||
UUIDUtilities.selector(sender.profile.getId()) +
|
||||
" 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 -> {
|
||||
if (!tags.contains("LastOutput") || !(tags.get("LastOutput") instanceof StringTag)) return tags;
|
||||
|
@ -123,18 +126,18 @@ public class MailCommand extends Command {
|
|||
return tags;
|
||||
}
|
||||
|
||||
bot.mail().send(
|
||||
bot.mail.send(
|
||||
new Mail(
|
||||
sender.profile().getName(),
|
||||
sender.profile.getName(),
|
||||
args[1],
|
||||
Instant.now().toEpochMilli(),
|
||||
bot.host() + ":" + bot.port(),
|
||||
bot.host + ":" + bot.port,
|
||||
value.substring(1).substring(0, value.length() - 2)
|
||||
)
|
||||
);
|
||||
|
||||
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;
|
||||
|
@ -144,10 +147,10 @@ public class MailCommand extends Command {
|
|||
// TODO: use less for loops?
|
||||
|
||||
int senderMailSize = 0;
|
||||
for (JsonElement mailElement : MailPlugin.mails()) {
|
||||
for (JsonElement mailElement : MailPlugin.mails) {
|
||||
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++;
|
||||
}
|
||||
|
||||
|
@ -156,13 +159,13 @@ public class MailCommand extends Command {
|
|||
final List<Component> mailsComponent = new ArrayList<>();
|
||||
|
||||
int i = 1;
|
||||
for (JsonElement mailElement : MailPlugin.mails()) {
|
||||
for (JsonElement mailElement : MailPlugin.mails) {
|
||||
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 String formattedTime = formatter.print(mail.timeSent());
|
||||
final String formattedTime = formatter.print(mail.timeSent);
|
||||
|
||||
mailsComponent.add(
|
||||
Component.translatable(
|
||||
|
@ -170,10 +173,10 @@ public class MailCommand extends Command {
|
|||
%s %s Sent by: %s %s
|
||||
Contents:
|
||||
%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(mail.sentBy()).color(ColorUtilities.getColorByString(bot.config().colorPalette().username())),
|
||||
Component.text(mail.sentBy).color(ColorUtilities.getColorByString(bot.config.colorPalette.username)),
|
||||
Component
|
||||
.text("[Hover here for more info]")
|
||||
.color(NamedTextColor.GREEN)
|
||||
|
@ -183,12 +186,12 @@ public class MailCommand extends Command {
|
|||
"""
|
||||
Time sent: %s
|
||||
Server: %s""",
|
||||
Component.text(formattedTime).color(ColorUtilities.getColorByString(bot.config().colorPalette().string())),
|
||||
Component.text(mail.server()).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))
|
||||
).color(NamedTextColor.GREEN)
|
||||
)
|
||||
),
|
||||
Component.text(mail.contents()).color(NamedTextColor.WHITE)
|
||||
Component.text(mail.contents).color(NamedTextColor.WHITE)
|
||||
).color(NamedTextColor.GREEN)
|
||||
);
|
||||
|
||||
|
@ -203,22 +206,22 @@ public class MailCommand extends Command {
|
|||
.append(Component.newline())
|
||||
.append(Component.join(JoinConfiguration.newlines(), mailsComponent));
|
||||
|
||||
if (context.inGame()) {
|
||||
bot.chat().tellraw(
|
||||
if (context.inGame) {
|
||||
bot.chat.tellraw(
|
||||
component,
|
||||
context.sender().profile().getId()
|
||||
context.sender.profile.getId()
|
||||
);
|
||||
} else {
|
||||
context.sendOutput(component);
|
||||
}
|
||||
|
||||
for (JsonElement mailElement : MailPlugin.mails().deepCopy()) {
|
||||
for (JsonElement mailElement : MailPlugin.mails.deepCopy()) {
|
||||
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));
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ public class MusicCommand extends Command {
|
|||
}
|
||||
|
||||
public Component play (CommandContext context, String[] args) {
|
||||
final MusicPlayerPlugin player = context.bot().music();
|
||||
final MusicPlayerPlugin player = context.bot.music;
|
||||
|
||||
String _path;
|
||||
Path path;
|
||||
|
@ -131,15 +131,15 @@ public class MusicCommand extends Command {
|
|||
}
|
||||
|
||||
public Component stop (CommandContext context) {
|
||||
final Bot bot = context.bot();
|
||||
bot.music().stopPlaying();
|
||||
bot.music().songQueue().clear();
|
||||
final Bot bot = context.bot;
|
||||
bot.music.stopPlaying();
|
||||
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) {
|
||||
final Bot bot = context.bot();
|
||||
final Bot bot = context.bot;
|
||||
|
||||
if (args.length < 2) return Component.text("Invalid argument").color(NamedTextColor.RED);
|
||||
|
||||
|
@ -151,7 +151,7 @@ public class MusicCommand extends Command {
|
|||
Component.empty()
|
||||
.append(Component.text("Looping is now "))
|
||||
.append(Component.text("disabled").color(NamedTextColor.RED))
|
||||
.color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor()))
|
||||
.color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor))
|
||||
);
|
||||
}
|
||||
case "current" -> {
|
||||
|
@ -159,28 +159,28 @@ public class MusicCommand extends Command {
|
|||
context.sendOutput(
|
||||
Component.empty()
|
||||
.append(Component.text("Now looping "))
|
||||
.append(bot.music().currentSong().name.color(ColorUtilities.getColorByString(bot.config().colorPalette().secondary())))
|
||||
.color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor()))
|
||||
.append(bot.music.currentSong.name.color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary)))
|
||||
.color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor))
|
||||
);
|
||||
}
|
||||
case "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 -> {
|
||||
return Component.text("Invalid argument").color(NamedTextColor.RED);
|
||||
}
|
||||
}
|
||||
|
||||
bot.music().loop(loop);
|
||||
bot.music.loop = loop;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
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 = (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();
|
||||
fullList.add(
|
||||
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.suggestCommand(
|
||||
prefix +
|
||||
name() +
|
||||
name +
|
||||
(file.isFile() ? " play " : " list ") +
|
||||
joinedPath
|
||||
)
|
||||
|
@ -244,15 +244,15 @@ public class MusicCommand extends Command {
|
|||
}
|
||||
|
||||
public Component skip (CommandContext context) {
|
||||
final Bot bot = context.bot();
|
||||
final MusicPlayerPlugin music = bot.music();
|
||||
if (music.currentSong() == null) return Component.text("No song is currently playing").color(NamedTextColor.RED);
|
||||
final Bot bot = context.bot;
|
||||
final MusicPlayerPlugin music = bot.music;
|
||||
if (music.currentSong == null) return Component.text("No song is currently playing").color(NamedTextColor.RED);
|
||||
|
||||
context.sendOutput(
|
||||
Component.empty()
|
||||
.append(Component.text("Skipping "))
|
||||
.append(music.currentSong().name.color(ColorUtilities.getColorByString(bot.config().colorPalette().secondary())))
|
||||
.color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor()))
|
||||
.append(music.currentSong.name.color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary)))
|
||||
.color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor))
|
||||
);
|
||||
|
||||
music.skip();
|
||||
|
@ -261,25 +261,25 @@ public class MusicCommand extends Command {
|
|||
}
|
||||
|
||||
public Component nowplaying (CommandContext context) {
|
||||
final Bot bot = context.bot();
|
||||
final Song song = bot.music().currentSong();
|
||||
final Bot bot = context.bot;
|
||||
final Song song = bot.music.currentSong;
|
||||
if (song == null) return Component.text("No song is currently playing").color(NamedTextColor.RED);
|
||||
|
||||
return Component.empty()
|
||||
.append(Component.text("Now playing "))
|
||||
.append(song.name.color(ColorUtilities.getColorByString(bot.config().colorPalette().secondary())))
|
||||
.color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor()));
|
||||
.append(song.name.color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary)))
|
||||
.color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
|
||||
}
|
||||
|
||||
public Component queue (CommandContext context) {
|
||||
final Bot bot = context.bot();
|
||||
final List<Song> queue = bot.music().songQueue();
|
||||
final Bot bot = context.bot;
|
||||
final List<Song> queue = bot.music.songQueue;
|
||||
|
||||
final List<Component> queueWithNames = new ArrayList<>();
|
||||
int i = 0;
|
||||
for (Song song : queue) {
|
||||
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
|
||||
public Component goTo (CommandContext context, String[] args) {
|
||||
final Bot bot = context.bot();
|
||||
final Song currentSong = bot.music().currentSong();
|
||||
final Bot bot = context.bot;
|
||||
final Song currentSong = bot.music.currentSong;
|
||||
|
||||
final long milliseconds;
|
||||
try {
|
||||
|
@ -309,7 +309,7 @@ public class MusicCommand extends Command {
|
|||
}
|
||||
|
||||
public Component pitch (CommandContext context, String[] args) {
|
||||
final Bot bot = context.bot();
|
||||
final Bot bot = context.bot;
|
||||
|
||||
float pitch;
|
||||
try {
|
||||
|
@ -318,16 +318,16 @@ public class MusicCommand extends Command {
|
|||
return Component.text("Invalid pitch").color(NamedTextColor.RED);
|
||||
}
|
||||
|
||||
bot.music().pitch(pitch);
|
||||
bot.music.pitch = pitch;
|
||||
|
||||
return Component.empty()
|
||||
.append(Component.text("Set the pitch to "))
|
||||
.append(Component.text(pitch).color(ColorUtilities.getColorByString(bot.config().colorPalette().number())))
|
||||
.color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor()));
|
||||
.append(Component.text(pitch).color(ColorUtilities.getColorByString(bot.config.colorPalette.number)))
|
||||
.color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
|
||||
}
|
||||
|
||||
public Component speed (CommandContext context, String[] args) {
|
||||
final Bot bot = context.bot();
|
||||
final Bot bot = context.bot;
|
||||
|
||||
float speed;
|
||||
try {
|
||||
|
@ -336,17 +336,17 @@ public class MusicCommand extends Command {
|
|||
return Component.text("Invalid speed").color(NamedTextColor.RED);
|
||||
}
|
||||
|
||||
bot.music().speed(speed);
|
||||
bot.music.speed = speed;
|
||||
|
||||
return Component.empty()
|
||||
.append(Component.text("Set the speed to "))
|
||||
.append(Component.text(speed).color(ColorUtilities.getColorByString(bot.config().colorPalette().number())))
|
||||
.color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor()));
|
||||
.append(Component.text(speed).color(ColorUtilities.getColorByString(bot.config.colorPalette.number)))
|
||||
.color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
|
||||
}
|
||||
|
||||
public Component pause (CommandContext context) {
|
||||
final Bot bot = context.bot();
|
||||
final Song currentSong = bot.music().currentSong();
|
||||
final Bot bot = context.bot;
|
||||
final Song currentSong = bot.music.currentSong;
|
||||
|
||||
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) {
|
||||
final Bot bot = context.bot();
|
||||
final Song currentSong = bot.music().currentSong();
|
||||
final Bot bot = context.bot;
|
||||
final Song currentSong = bot.music.currentSong;
|
||||
|
||||
if (currentSong == null) return Component.text("No song is currently playing").color(NamedTextColor.RED);
|
||||
|
||||
|
|
|
@ -24,10 +24,10 @@ public class NetMessageCommand extends Command {
|
|||
|
||||
@Override
|
||||
public Component execute(CommandContext context, String[] args, String[] fullArgs) {
|
||||
final Bot bot = context.bot();
|
||||
final List<Bot> bots = bot.bots();
|
||||
final Bot bot = context.bot;
|
||||
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(
|
||||
"[%s]%s%s%s› %s",
|
||||
|
@ -44,14 +44,14 @@ public class NetMessageCommand extends Command {
|
|||
)
|
||||
),
|
||||
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(String.join(" ", args)).color(NamedTextColor.GRAY)
|
||||
).color(NamedTextColor.DARK_GRAY);
|
||||
|
||||
for (Bot eachBot : bots) {
|
||||
if (!eachBot.loggedIn()) continue;
|
||||
eachBot.chat().tellraw(component);
|
||||
if (!eachBot.loggedIn) continue;
|
||||
eachBot.chat.tellraw(component);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -23,22 +23,22 @@ public class RandomTeleportCommand extends Command {
|
|||
|
||||
@Override
|
||||
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 positionZ = MathUtilities.between(1_000, 1_000_000);
|
||||
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()
|
||||
.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(stringPosition).color(NamedTextColor.GREEN))
|
||||
.append(Component.text("...").color(NamedTextColor.WHITE))
|
||||
.color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor()));
|
||||
.color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,10 +19,10 @@ public class RefillCoreCommand extends Command {
|
|||
|
||||
@Override
|
||||
public Component execute(CommandContext context, String[] args, String[] fullArgs) {
|
||||
final Bot bot = context.bot();
|
||||
final Bot bot = context.bot;
|
||||
|
||||
bot.core().reset();
|
||||
bot.core().refill();
|
||||
bot.core.reset();
|
||||
bot.core.refill();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -15,9 +15,6 @@ import org.joda.time.DateTimeZone;
|
|||
import org.joda.time.format.DateTimeFormat;
|
||||
import org.joda.time.format.DateTimeFormatter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SeenCommand extends Command {
|
||||
public SeenCommand () {
|
||||
super(
|
||||
|
@ -31,19 +28,19 @@ public class SeenCommand extends Command {
|
|||
|
||||
@Override
|
||||
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);
|
||||
|
||||
for (Bot eachBot : bot.bots()) {
|
||||
if (eachBot.players().getEntry(player) != null) return Component.empty()
|
||||
for (Bot eachBot : bot.bots) {
|
||||
if (eachBot.players.getEntry(player) != null) return Component.empty()
|
||||
.append(Component.text(player))
|
||||
.append(Component.text(" is currently online on "))
|
||||
.append(Component.text(eachBot.host() + ":" + eachBot.port()))
|
||||
.append(Component.text(eachBot.host + ":" + eachBot.port))
|
||||
.color(NamedTextColor.RED);
|
||||
}
|
||||
|
||||
final JsonElement playerElement = PlayersPlugin.playersObject().get(player);
|
||||
final JsonElement playerElement = PlayersPlugin.playersObject.get(player);
|
||||
if (playerElement == null) return Component.translatable(
|
||||
"%s was never seen",
|
||||
Component.text(player)
|
||||
|
@ -60,9 +57,9 @@ public class SeenCommand extends Command {
|
|||
|
||||
return Component.translatable(
|
||||
"%s was last seen at %s on %s",
|
||||
Component.text(player).color(ColorUtilities.getColorByString(bot.config().colorPalette().username())),
|
||||
Component.text(formattedTime).color(ColorUtilities.getColorByString(bot.config().colorPalette().string())),
|
||||
Component.text(server).color(ColorUtilities.getColorByString(bot.config().colorPalette().string()))
|
||||
).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor()));
|
||||
Component.text(player).color(ColorUtilities.getColorByString(bot.config.colorPalette.username)),
|
||||
Component.text(formattedTime).color(ColorUtilities.getColorByString(bot.config.colorPalette.string)),
|
||||
Component.text(server).color(ColorUtilities.getColorByString(bot.config.colorPalette.string))
|
||||
).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ public class ServerEvalCommand extends Command {
|
|||
@Override
|
||||
public Component execute(CommandContext context, String[] args, String[] fullArgs) {
|
||||
try {
|
||||
final Bot bot = context.bot();
|
||||
final Bot bot = context.bot;
|
||||
|
||||
final Globals globals = JsePlatform.standardGlobals();
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ public class ServerInfoCommand extends Command {
|
|||
|
||||
@Override
|
||||
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
|
||||
final Component component;
|
||||
|
@ -65,7 +65,7 @@ public class ServerInfoCommand extends Command {
|
|||
file.close();
|
||||
} 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 Optional<String> modelName = Arrays.stream(lines)
|
||||
|
@ -98,7 +98,7 @@ public class ServerInfoCommand extends Command {
|
|||
Component.text(heapUsage.getUsed() / 1024L / 1024L),
|
||||
Component.text(heapUsage.getMax() / 1024L / 1024L)
|
||||
).color(color)
|
||||
).color(ColorUtilities.getColorByString(bot.config().colorPalette().secondary()));
|
||||
).color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary));
|
||||
|
||||
return component;
|
||||
}
|
||||
|
|
|
@ -21,10 +21,10 @@ public class SudoAllCommand extends Command {
|
|||
|
||||
@Override
|
||||
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()) {
|
||||
bot.core().run("essentials:sudo " + entry.profile().getName() + " " + String.join(" ", args));
|
||||
for (MutablePlayerListEntry entry : bot.players.list) {
|
||||
bot.core.run("essentials:sudo " + entry.profile.getName() + " " + String.join(" ", args));
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -21,22 +21,22 @@ public class TPSBarCommand extends Command {
|
|||
|
||||
@Override
|
||||
public Component execute(CommandContext context, String[] args, String[] fullArgs) {
|
||||
final Bot bot = context.bot();
|
||||
final Bot bot = context.bot;
|
||||
|
||||
switch (args[0]) {
|
||||
case "on" -> {
|
||||
bot.tps().on();
|
||||
bot.tps.on();
|
||||
return Component.empty()
|
||||
.append(Component.text("TPSBar is now "))
|
||||
.append(Component.text("enabled").color(NamedTextColor.GREEN))
|
||||
.color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor()));
|
||||
.color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
|
||||
}
|
||||
case "off" -> {
|
||||
bot.tps().off();
|
||||
bot.tps.off();
|
||||
return Component.empty()
|
||||
.append(Component.text("TPSBar is now "))
|
||||
.append(Component.text("disabled").color(NamedTextColor.RED))
|
||||
.color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor()));
|
||||
.color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
|
||||
}
|
||||
default -> {
|
||||
return Component.text("Invalid argument").color(NamedTextColor.RED);
|
||||
|
|
|
@ -21,9 +21,9 @@ public class TestCommand extends Command {
|
|||
public Component execute(CommandContext context, String[] args, String[] fullArgs) {
|
||||
return Component.translatable(
|
||||
"Hello, World! Username: %s, Sender UUID: %s, Prefix: %s, Args: %s",
|
||||
Component.text(context.sender().profile().getName()),
|
||||
Component.text(context.sender().profile().getIdAsString()),
|
||||
Component.text(context.prefix()),
|
||||
Component.text(context.sender.profile.getName()),
|
||||
Component.text(context.sender.profile.getIdAsString()),
|
||||
Component.text(context.prefix),
|
||||
Component.text(String.join(", ", args))
|
||||
).color(NamedTextColor.GREEN);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ public class TimeCommand extends Command {
|
|||
|
||||
@Override
|
||||
public Component execute(CommandContext context, String[] args, String[] fullArgs) {
|
||||
final Bot bot = context.bot();
|
||||
final Bot bot = context.bot;
|
||||
|
||||
final String timezone = args[0];
|
||||
|
||||
|
@ -43,8 +43,8 @@ public class TimeCommand extends Command {
|
|||
|
||||
return Component.translatable(
|
||||
"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)
|
||||
).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor()));
|
||||
).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ public class TranslateCommand extends Command {
|
|||
|
||||
@Override
|
||||
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 to = args[1];
|
||||
|
@ -39,7 +39,7 @@ public class TranslateCommand extends Command {
|
|||
|
||||
final Gson gson = new Gson();
|
||||
|
||||
bot.executorService().submit(() -> {
|
||||
bot.executorService.submit(() -> {
|
||||
try {
|
||||
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",
|
||||
Component.text(output).color(NamedTextColor.GREEN)
|
||||
)
|
||||
.color(ColorUtilities.getColorByString(bot.config().colorPalette().secondary()))
|
||||
.color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary))
|
||||
);
|
||||
} catch (Exception e) {
|
||||
context.sendOutput(Component.text(e.toString()).color(NamedTextColor.RED));
|
||||
|
|
|
@ -24,15 +24,15 @@ public class UUIDCommand extends Command {
|
|||
|
||||
@Override
|
||||
public Component execute(CommandContext context, String[] args, String[] fullArgs) {
|
||||
final Bot bot = context.bot();
|
||||
final Bot bot = context.bot;
|
||||
|
||||
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);
|
||||
|
||||
final String name = entry.profile().getName();
|
||||
final String uuid = entry.profile().getIdAsString();
|
||||
final String name = entry.profile.getName();
|
||||
final String uuid = entry.profile.getIdAsString();
|
||||
|
||||
return Component.translatable(
|
||||
"%s's UUID: %s",
|
||||
|
@ -47,12 +47,12 @@ public class UUIDCommand extends Command {
|
|||
.clickEvent(
|
||||
ClickEvent.copyToClipboard(uuid)
|
||||
)
|
||||
.color(ColorUtilities.getColorByString(bot.config().colorPalette().uuid()))
|
||||
.color(ColorUtilities.getColorByString(bot.config.colorPalette.uuid))
|
||||
).color(NamedTextColor.GREEN);
|
||||
} 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(
|
||||
"Your UUID: %s",
|
||||
|
@ -66,7 +66,7 @@ public class UUIDCommand extends Command {
|
|||
.clickEvent(
|
||||
ClickEvent.copyToClipboard(uuid)
|
||||
)
|
||||
.color(ColorUtilities.getColorByString(bot.config().colorPalette().uuid()))
|
||||
.color(ColorUtilities.getColorByString(bot.config.colorPalette.uuid))
|
||||
).color(NamedTextColor.GREEN);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public class UptimeCommand extends Command {
|
|||
|
||||
@Override
|
||||
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;
|
||||
|
||||
|
@ -42,6 +42,6 @@ public class UptimeCommand extends Command {
|
|||
Component.text(minutes),
|
||||
Component.text(seconds)
|
||||
).color(NamedTextColor.GREEN)
|
||||
).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor()));
|
||||
).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,13 +31,13 @@ public class UrbanCommand extends Command {
|
|||
}
|
||||
|
||||
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 Gson gson = new Gson();
|
||||
|
||||
bot.executorService().submit(() -> {
|
||||
bot.executorService.submit(() -> {
|
||||
try {
|
||||
final URL url = new URL(
|
||||
"https://api.urbandictionary.com/v0/define?term=" +
|
||||
|
@ -80,8 +80,8 @@ public class UrbanCommand extends Command {
|
|||
.clickEvent(
|
||||
ClickEvent
|
||||
.suggestCommand(
|
||||
context.prefix() +
|
||||
name() +
|
||||
context.prefix +
|
||||
name +
|
||||
" " +
|
||||
splittedDefinition[i]
|
||||
)
|
||||
|
|
|
@ -21,8 +21,8 @@ public class ValidateCommand extends Command {
|
|||
public Component execute(CommandContext context, String[] args, String[] fullArgs) {
|
||||
final String hash = fullArgs[0];
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public class WeatherCommand extends Command {
|
|||
}
|
||||
|
||||
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);
|
||||
|
||||
|
@ -39,7 +39,7 @@ public class WeatherCommand extends Command {
|
|||
|
||||
try {
|
||||
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(
|
||||
location,
|
||||
StandardCharsets.UTF_8
|
||||
|
@ -61,12 +61,12 @@ public class WeatherCommand extends Command {
|
|||
|
||||
return Component.translatable(
|
||||
"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("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("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("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(time).color(ColorUtilities.getColorByString(bot.config().colorPalette().string()))
|
||||
).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor()));
|
||||
Component.text(time).color(ColorUtilities.getColorByString(bot.config.colorPalette.string))
|
||||
).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
|
||||
} catch (Exception e) {
|
||||
return Component.text("Location \"" + location + "\" not found").color(NamedTextColor.RED);
|
||||
}
|
||||
|
|
|
@ -27,13 +27,13 @@ public class WikipediaCommand extends Command {
|
|||
}
|
||||
|
||||
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 Gson gson = new Gson();
|
||||
|
||||
bot.executorService().submit(() -> {
|
||||
bot.executorService.submit(() -> {
|
||||
try {
|
||||
final URL url = new URL(
|
||||
"https://en.wikipedia.org/api/rest_v1/page/summary/" +
|
||||
|
|
|
@ -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.BossBarDivision;
|
||||
import lombok.AllArgsConstructor;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class BossBar {
|
||||
public UUID uuid;
|
||||
|
||||
|
@ -15,5 +13,19 @@ public class BossBar {
|
|||
public BossBarColor color;
|
||||
public BossBarDivision division;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ public class BotBossBar extends BossBar {
|
|||
|
||||
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) {
|
||||
|
@ -58,7 +58,7 @@ public class BotBossBar extends BossBar {
|
|||
|
||||
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) {
|
||||
|
@ -66,7 +66,7 @@ public class BotBossBar extends BossBar {
|
|||
|
||||
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) {
|
||||
|
@ -87,7 +87,7 @@ public class BotBossBar extends BossBar {
|
|||
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) {
|
||||
|
@ -98,7 +98,7 @@ public class BotBossBar extends BossBar {
|
|||
|
||||
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) {
|
||||
|
@ -106,7 +106,7 @@ public class BotBossBar extends BossBar {
|
|||
|
||||
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) {
|
||||
|
@ -117,6 +117,6 @@ public class BotBossBar extends BossBar {
|
|||
|
||||
this.max = max;
|
||||
|
||||
bot.core().run("minecraft:bossbar set " + id + " max " + max);
|
||||
bot.core.run("minecraft:bossbar set " + id + " max " + max);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
package land.chipmunk.chayapak.chomens_bot.data;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class CommandLoop {
|
||||
@Getter private String command;
|
||||
@Getter private int interval;
|
||||
}
|
||||
public record CommandLoop (
|
||||
String command,
|
||||
int interval
|
||||
) {}
|
||||
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
package land.chipmunk.chayapak.chomens_bot.data;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class EvalOutput {
|
||||
@Getter private final boolean isError;
|
||||
@Getter private final String output;
|
||||
}
|
||||
public record EvalOutput (
|
||||
boolean isError,
|
||||
String output
|
||||
) {}
|
||||
|
|
|
@ -1,10 +1,17 @@
|
|||
package land.chipmunk.chayapak.chomens_bot.data;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class FilteredPlayer {
|
||||
public String playerName;
|
||||
public boolean regex;
|
||||
public boolean ignoreCase;
|
||||
|
||||
public FilteredPlayer (
|
||||
String playerName,
|
||||
boolean regex,
|
||||
boolean ignoreCase
|
||||
) {
|
||||
this.playerName = playerName;
|
||||
this.regex = regex;
|
||||
this.ignoreCase = ignoreCase;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,23 @@
|
|||
package land.chipmunk.chayapak.chomens_bot.data;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class Mail {
|
||||
@Getter private String sentBy;
|
||||
@Getter private String sentTo;
|
||||
@Getter private long timeSent;
|
||||
@Getter private String server;
|
||||
@Getter private String contents;
|
||||
public String sentBy;
|
||||
public String sentTo;
|
||||
public long timeSent;
|
||||
public String server;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package land.chipmunk.chayapak.chomens_bot.data;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class Rotation {
|
||||
public float yaw;
|
||||
public float pitch;
|
||||
}
|
||||
public record Rotation (
|
||||
float yaw,
|
||||
float pitch
|
||||
) {}
|
||||
|
|
|
@ -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.NameTagVisibility;
|
||||
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;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class Team {
|
||||
@Getter @Setter private String teamName;
|
||||
@Getter @Setter private Component displayName;
|
||||
@Getter @Setter private boolean friendlyFire;
|
||||
@Getter @Setter private boolean seeFriendlyInvisibles;
|
||||
@Getter @Setter private NameTagVisibility nametagVisibility;
|
||||
@Getter @Setter private CollisionRule collisionRule;
|
||||
@Getter @Setter private TeamColor color;
|
||||
@Getter @Setter private Component prefix;
|
||||
@Getter @Setter private Component suffix;
|
||||
public String teamName;
|
||||
public Component displayName;
|
||||
public boolean friendlyFire;
|
||||
public boolean seeFriendlyInvisibles;
|
||||
public NameTagVisibility nametagVisibility;
|
||||
public CollisionRule collisionRule;
|
||||
public TeamColor color;
|
||||
public Component prefix;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.protocol.data.game.PlayerListEntry;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.security.PublicKey;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class MutablePlayerListEntry {
|
||||
private GameProfile profile;
|
||||
private GameMode gamemode;
|
||||
private int latency;
|
||||
private Component displayName;
|
||||
private long expiresAt;
|
||||
private PublicKey publicKey;
|
||||
private byte[] keySignature;
|
||||
private boolean listed;
|
||||
public GameProfile profile;
|
||||
public GameMode gamemode;
|
||||
public int latency;
|
||||
public Component displayName;
|
||||
public long expiresAt;
|
||||
public PublicKey publicKey;
|
||||
public byte[] keySignature;
|
||||
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) {
|
||||
this(entry.getProfile(), entry.getGameMode(), entry.getLatency(), entry.getDisplayName(), entry.getExpiresAt(), entry.getPublicKey(), entry.getKeySignature(), entry.isListed());
|
||||
|
|
|
@ -1,13 +1,19 @@
|
|||
package land.chipmunk.chayapak.chomens_bot.data.chat;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class PlayerMessage {
|
||||
private MutablePlayerListEntry sender;
|
||||
private Component displayName;
|
||||
private Component contents;
|
||||
public final MutablePlayerListEntry sender;
|
||||
public final Component displayName;
|
||||
public final Component contents;
|
||||
|
||||
public PlayerMessage (
|
||||
MutablePlayerListEntry sender,
|
||||
Component displayName,
|
||||
Component contents
|
||||
) {
|
||||
this.sender = sender;
|
||||
this.displayName = displayName;
|
||||
this.contents = contents;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,19 +1,10 @@
|
|||
package land.chipmunk.chayapak.chomens_bot.data.voiceChat;
|
||||
|
||||
import land.chipmunk.chayapak.chomens_bot.util.FriendlyByteBuf;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@AllArgsConstructor
|
||||
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 record ClientGroup(UUID id, String name, boolean hasPassword, boolean persistent, GroupType type) {
|
||||
public static ClientGroup fromBytes(FriendlyByteBuf buf) {
|
||||
return new ClientGroup(
|
||||
buf.readUUID(),
|
||||
|
|
|
@ -1,13 +1,5 @@
|
|||
package land.chipmunk.chayapak.chomens_bot.data.voiceChat;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class RawUdpPacket {
|
||||
@Getter private final byte[] data;
|
||||
@Getter private final SocketAddress socketAddress;
|
||||
@Getter private final long timestamp;
|
||||
}
|
||||
public record RawUdpPacket(byte[] data, SocketAddress socketAddress, long timestamp) {}
|
||||
|
|
|
@ -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.chat.MutablePlayerListEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.ComponentUtilities;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
@ -21,19 +19,19 @@ import java.util.UUID;
|
|||
public class BossbarManagerPlugin extends Bot.Listener {
|
||||
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<>();
|
||||
|
||||
@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) {
|
||||
this.bot = bot;
|
||||
|
||||
bot.addListener(this);
|
||||
|
||||
bot.players().addListener(new PlayersPlugin.Listener() {
|
||||
bot.players.addListener(new PlayersPlugin.Listener() {
|
||||
@Override
|
||||
public void playerJoined(MutablePlayerListEntry target) {
|
||||
BossbarManagerPlugin.this.playerJoined();
|
||||
|
@ -47,7 +45,7 @@ public class BossbarManagerPlugin extends Bot.Listener {
|
|||
}
|
||||
|
||||
public void packetReceived(ClientboundBossEventPacket packet) {
|
||||
if (!enabled || !bot.options().useCore()) return;
|
||||
if (!enabled || !bot.options.useCore) return;
|
||||
|
||||
try {
|
||||
switch (packet.getAction()) {
|
||||
|
@ -157,7 +155,7 @@ public class BossbarManagerPlugin extends Bot.Listener {
|
|||
}
|
||||
|
||||
public void add (String name, BotBossBar bossBar) {
|
||||
if (!enabled || !bot.options().useCore()) return;
|
||||
if (!enabled || !bot.options.useCore) return;
|
||||
|
||||
bossBar.id = bossBarPrefix + name;
|
||||
|
||||
|
@ -184,17 +182,17 @@ public class BossbarManagerPlugin extends Bot.Listener {
|
|||
case NOTCHES_10 -> division = "notched_10";
|
||||
}
|
||||
|
||||
bot.core().run("minecraft:bossbar add " + name + " " + stringifiedName);
|
||||
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 + "visible " + bossBar.visible);
|
||||
bot.core().run(prefix + "style " + division);
|
||||
bot.core().run(prefix + "max " + bossBar.max);
|
||||
bot.core().run(prefix + "value " + bossBar.value);
|
||||
bot.core.run("minecraft:bossbar add " + name + " " + stringifiedName);
|
||||
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 + "visible " + bossBar.visible);
|
||||
bot.core.run(prefix + "style " + division);
|
||||
bot.core.run(prefix + "max " + bossBar.max);
|
||||
bot.core.run(prefix + "value " + bossBar.value);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
|
@ -202,7 +200,7 @@ public class BossbarManagerPlugin extends Bot.Listener {
|
|||
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) {
|
||||
|
|
|
@ -2,20 +2,18 @@ package land.chipmunk.chayapak.chomens_bot.plugins;
|
|||
|
||||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||
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.format.TextColor;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class BruhifyPlugin {
|
||||
@Getter @Setter private String bruhifyText = "";
|
||||
public String bruhifyText = "";
|
||||
|
||||
private int startHue = 0;
|
||||
|
||||
public BruhifyPlugin (Bot bot) {
|
||||
bot.executor().scheduleAtFixedRate(() -> {
|
||||
bot.executor.scheduleAtFixedRate(() -> {
|
||||
if (bruhifyText.equals("")) return;
|
||||
|
||||
int hue = startHue;
|
||||
|
@ -30,7 +28,7 @@ public class BruhifyPlugin {
|
|||
hue = (hue + increment) % 360;
|
||||
}
|
||||
|
||||
bot.chat().actionBar(component);
|
||||
bot.chat.actionBar(component);
|
||||
|
||||
startHue = (startHue + increment) % 360;
|
||||
}, 50, 100, TimeUnit.MILLISECONDS);
|
||||
|
|
|
@ -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.util.ComponentUtilities;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.UUIDUtilities;
|
||||
import lombok.Getter;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -13,16 +12,16 @@ import java.util.List;
|
|||
public class ChatCommandHandlerPlugin extends ChatPlugin.Listener {
|
||||
public final Bot bot;
|
||||
|
||||
@Getter private final List<String> prefixes;
|
||||
@Getter private final List<String> commandSpyPrefixes;
|
||||
public final List<String> prefixes;
|
||||
public final List<String> commandSpyPrefixes;
|
||||
|
||||
public ChatCommandHandlerPlugin(Bot bot) {
|
||||
this.bot = bot;
|
||||
|
||||
this.prefixes = bot.config().prefixes();
|
||||
this.commandSpyPrefixes = bot.config().commandSpyPrefixes();
|
||||
this.prefixes = bot.config.prefixes;
|
||||
this.commandSpyPrefixes = bot.config.commandSpyPrefixes;
|
||||
|
||||
bot.chat().addListener(this);
|
||||
bot.chat.addListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -33,11 +32,11 @@ public class ChatCommandHandlerPlugin extends ChatPlugin.Listener {
|
|||
|
||||
private void listener (PlayerMessage message, boolean cspy) {
|
||||
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
|
||||
|
||||
final Component displayNameComponent = message.displayName();
|
||||
final Component messageComponent = message.contents();
|
||||
final Component displayNameComponent = message.displayName;
|
||||
final Component messageComponent = message.contents;
|
||||
if (displayNameComponent == null || messageComponent == null) return;
|
||||
|
||||
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 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) {
|
||||
context.sendOutput(output);
|
||||
|
|
|
@ -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.IllegalCharactersUtilities;
|
||||
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.TranslatableComponent;
|
||||
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<>();
|
||||
|
||||
@Getter @Setter private int queueDelay;
|
||||
public int queueDelay;
|
||||
|
||||
private final List<Listener> listeners = new ArrayList<>();
|
||||
|
||||
public ChatPlugin (Bot bot) {
|
||||
this.bot = bot;
|
||||
|
||||
queueDelay = bot.options().chatQueueDelay();
|
||||
queueDelay = bot.options.chatQueueDelay;
|
||||
|
||||
this.commandSpyParser = new CommandSpyParser(bot);
|
||||
|
||||
|
@ -62,7 +60,7 @@ public class ChatPlugin extends Bot.Listener {
|
|||
chatParsers.add(new U203aChatParser(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
|
||||
|
@ -121,7 +119,7 @@ public class ChatPlugin extends Bot.Listener {
|
|||
public void packetReceived (ClientboundPlayerChatPacket packet) {
|
||||
final UUID senderUUID = packet.getSender();
|
||||
|
||||
final MutablePlayerListEntry entry = bot.players().getEntry(senderUUID);
|
||||
final MutablePlayerListEntry entry = bot.players.getEntry(senderUUID);
|
||||
|
||||
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
|
||||
component = component.args(
|
||||
Component.empty(), // TODO: fix team name.,.,
|
||||
playerMessage.displayName(),
|
||||
playerMessage.contents()
|
||||
playerMessage.displayName,
|
||||
playerMessage.contents
|
||||
);
|
||||
} else {
|
||||
component = component.args(playerMessage.displayName(), playerMessage.contents());
|
||||
component = component.args(playerMessage.displayName, playerMessage.contents);
|
||||
}
|
||||
|
||||
listener.systemMessageReceived(component);
|
||||
|
@ -196,7 +194,7 @@ public class ChatPlugin extends Bot.Listener {
|
|||
|
||||
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) {
|
||||
listener.playerMessageReceived(playerMessage);
|
||||
|
@ -205,7 +203,7 @@ public class ChatPlugin extends Bot.Listener {
|
|||
} else {
|
||||
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) {
|
||||
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[] 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));
|
||||
|
||||
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,
|
||||
Instant.now().toEpochMilli(),
|
||||
0L,
|
||||
|
@ -245,7 +243,7 @@ public class ChatPlugin extends Bot.Listener {
|
|||
new BitSet()
|
||||
));
|
||||
} else {
|
||||
bot.session().send(new ServerboundChatPacket(
|
||||
bot.session.send(new ServerboundChatPacket(
|
||||
message,
|
||||
Instant.now().toEpochMilli(),
|
||||
0L,
|
||||
|
@ -290,13 +288,13 @@ public class ChatPlugin extends Bot.Listener {
|
|||
}
|
||||
|
||||
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!
|
||||
|
||||
final String stringified = ComponentUtilities.stringifyMotd(component).replace("§", "&");
|
||||
send(stringified);
|
||||
} 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 actionBar (Component component, String targets) {
|
||||
if (bot.options().useChat()) return;
|
||||
bot.core().run("minecraft:title " + targets + " actionbar " + GsonComponentSerializer.gson().serialize(component));
|
||||
if (bot.options.useChat) return;
|
||||
bot.core.run("minecraft:title " + targets + " actionbar " + GsonComponentSerializer.gson().serialize(component));
|
||||
}
|
||||
|
||||
public void actionBar (Component component, UUID uuid) { actionBar(component, UUIDUtilities.selector(uuid)); }
|
||||
|
|
|
@ -2,7 +2,6 @@ package land.chipmunk.chayapak.chomens_bot.plugins;
|
|||
|
||||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.CommandLoop;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -12,20 +11,19 @@ import java.util.concurrent.TimeUnit;
|
|||
public class CloopPlugin {
|
||||
private final Bot bot;
|
||||
|
||||
// too lazy to use executor
|
||||
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) {
|
||||
this.bot = bot;
|
||||
}
|
||||
|
||||
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,.,..
|
||||
// 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) {
|
||||
|
|
|
@ -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.commands.*;
|
||||
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.Role;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
@ -22,9 +20,9 @@ import java.util.List;
|
|||
public class CommandHandlerPlugin {
|
||||
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) {
|
||||
this.bot = bot;
|
||||
|
@ -97,18 +95,18 @@ public class CommandHandlerPlugin {
|
|||
if (command == null && !inGame) return Component.text("Unknown command: " + commandName).color(NamedTextColor.RED);
|
||||
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);
|
||||
|
||||
// TODO: improve these minimum args and maximum args stuff, the current one really sucks.,.,
|
||||
final int shortestUsageIndex = getShortestUsageIndex(command.usages());
|
||||
final int longestUsageIndex = getLongestUsageIndex(command.usages());
|
||||
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 int shortestUsageIndex = getShortestUsageIndex(command.usages);
|
||||
final int longestUsageIndex = getLongestUsageIndex(command.usages);
|
||||
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 int minimumArgs = getMinimumArgs(shortestUsage, inGame, command.trustLevel());
|
||||
final int maximumArgs = getMaximumArgs(longestUsage, inGame, command.trustLevel());
|
||||
final int minimumArgs = getMinimumArgs(shortestUsage, 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 > 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);
|
||||
|
||||
if (command.trustLevel() != TrustLevel.PUBLIC && !console) {
|
||||
if (command.trustLevel != TrustLevel.PUBLIC && !console) {
|
||||
if (discord) {
|
||||
final Member member = event.getMember();
|
||||
|
||||
|
@ -127,29 +125,29 @@ public class CommandHandlerPlugin {
|
|||
|
||||
final List<Role> roles = member.getRoles();
|
||||
|
||||
final String trustedRoleName = bot.config().discord().trustedRoleName();
|
||||
final String adminRoleName = bot.config().discord().adminRoleName();
|
||||
final String trustedRoleName = bot.config.discord.trustedRoleName;
|
||||
final String adminRoleName = bot.config.discord.adminRoleName;
|
||||
|
||||
if (
|
||||
command.trustLevel() == TrustLevel.TRUSTED &&
|
||||
command.trustLevel == TrustLevel.TRUSTED &&
|
||||
roles.stream().noneMatch(role -> role.getName().equalsIgnoreCase(trustedRoleName)) &&
|
||||
roles.stream().noneMatch(role -> role.getName().equalsIgnoreCase(adminRoleName))
|
||||
) return Component.text("You're not in the trusted role!").color(NamedTextColor.RED);
|
||||
|
||||
if (
|
||||
command.trustLevel() == TrustLevel.OWNER &&
|
||||
command.trustLevel == TrustLevel.OWNER &&
|
||||
roles.stream().noneMatch(role -> role.getName().equalsIgnoreCase(adminRoleName))
|
||||
) return Component.text("You're not in the admin role!").color(NamedTextColor.RED);
|
||||
} else {
|
||||
if (
|
||||
command.trustLevel() == TrustLevel.TRUSTED &&
|
||||
!userHash.equals(bot.hashing().hash()) &&
|
||||
!userHash.equals(bot.hashing().ownerHash())
|
||||
command.trustLevel == TrustLevel.TRUSTED &&
|
||||
!userHash.equals(bot.hashing.hash) &&
|
||||
!userHash.equals(bot.hashing.ownerHash)
|
||||
) return Component.text("Invalid hash").color(NamedTextColor.RED);
|
||||
|
||||
if (
|
||||
command.trustLevel() == TrustLevel.OWNER &&
|
||||
!userHash.equals(bot.hashing().ownerHash())
|
||||
command.trustLevel == TrustLevel.OWNER &&
|
||||
!userHash.equals(bot.hashing.ownerHash)
|
||||
) return Component.text("Invalid OwnerHash").color(NamedTextColor.RED);
|
||||
}
|
||||
}
|
||||
|
@ -161,7 +159,7 @@ public class CommandHandlerPlugin {
|
|||
|
||||
final String stackTrace = ExceptionUtilities.getStacktrace(e);
|
||||
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
|
||||
.text("An error occurred while trying to execute the command, hover here for stacktrace", NamedTextColor.RED)
|
||||
.hoverEvent(
|
||||
|
@ -181,8 +179,8 @@ public class CommandHandlerPlugin {
|
|||
for (Command command : commands) {
|
||||
if (
|
||||
(
|
||||
command.name().equals(searchTerm.toLowerCase()) ||
|
||||
Arrays.stream(command.aliases()).toList().contains(searchTerm.toLowerCase())
|
||||
command.name.equals(searchTerm.toLowerCase()) ||
|
||||
Arrays.stream(command.aliases).toList().contains(searchTerm.toLowerCase())
|
||||
) &&
|
||||
!searchTerm.equals("") // ig yup
|
||||
) {
|
||||
|
|
|
@ -2,8 +2,6 @@ package land.chipmunk.chayapak.chomens_bot.plugins;
|
|||
|
||||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||
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.JoinConfiguration;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
|
@ -14,11 +12,11 @@ import java.util.List;
|
|||
public class CommandSuggestionPlugin extends ChatPlugin.Listener {
|
||||
private final Bot bot;
|
||||
|
||||
@Getter @Setter private String id = "chomens_bot_command_suggestion";
|
||||
public String id = "chomens_bot_command_suggestion";
|
||||
|
||||
public CommandSuggestionPlugin (Bot bot) {
|
||||
this.bot = bot;
|
||||
bot.chat().addListener(this);
|
||||
bot.chat.addListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -47,13 +45,13 @@ public class CommandSuggestionPlugin extends ChatPlugin.Listener {
|
|||
output.add(Component.text(id));
|
||||
output.add(Component.text(transactionId));
|
||||
|
||||
for (Command command : bot.commandHandler().commands()) {
|
||||
if (!command.name().startsWith(input)) continue;
|
||||
for (Command command : bot.commandHandler.commands) {
|
||||
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) {}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import land.chipmunk.chayapak.chomens_bot.Configuration;
|
|||
import land.chipmunk.chayapak.chomens_bot.Main;
|
||||
import land.chipmunk.chayapak.chomens_bot.command.ConsoleCommandContext;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities;
|
||||
import lombok.Getter;
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
@ -19,12 +18,12 @@ import java.util.List;
|
|||
public class ConsolePlugin {
|
||||
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;
|
||||
@Getter private String consoleServerPrefix;
|
||||
public String prefix;
|
||||
public String consoleServerPrefix;
|
||||
|
||||
private static final List<Listener> listeners = new ArrayList<>();
|
||||
|
||||
|
@ -35,12 +34,12 @@ public class ConsolePlugin {
|
|||
reader.option(LineReader.Option.DISABLE_EVENT_EXPANSION, true);
|
||||
|
||||
for (Bot bot : allBots) {
|
||||
prefix = bot.config().consolePrefixes().normalCommandsPrefix();
|
||||
consoleServerPrefix = bot.config().consolePrefixes().consoleServerPrefix();
|
||||
prefix = bot.config.consolePrefixes.normalCommandsPrefix;
|
||||
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);
|
||||
|
@ -77,18 +76,18 @@ public class ConsolePlugin {
|
|||
final List<String> servers = new ArrayList<>();
|
||||
|
||||
for (Bot bot : allBots) {
|
||||
servers.add(bot.host() + ":" + bot.port());
|
||||
servers.add(bot.host + ":" + bot.port);
|
||||
}
|
||||
|
||||
for (Bot bot : allBots) {
|
||||
if (args.length == 0) {
|
||||
bot.logger().info("No server specified");
|
||||
bot.logger.info("No server specified");
|
||||
return;
|
||||
}
|
||||
|
||||
if (String.join(" ", args).equalsIgnoreCase("all")) {
|
||||
consoleServer = "all";
|
||||
bot.logger().info("Set the console server to all servers");
|
||||
bot.logger.info("Set the console server to all servers");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
|
@ -97,9 +96,9 @@ public class ConsolePlugin {
|
|||
.filter(server -> server.toLowerCase().contains(String.join(" ", args)))
|
||||
.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) {
|
||||
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) {
|
||||
final String hostAndPort = bot.host() + ":" + bot.port();
|
||||
final String hostAndPort = bot.host + ":" + bot.port;
|
||||
|
||||
if (!hostAndPort.equals(consoleServer) && !consoleServer.equals("all")) continue;
|
||||
|
||||
if (line.startsWith(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) {
|
||||
context.sendOutput(output);
|
||||
|
@ -124,11 +123,11 @@ public class ConsolePlugin {
|
|||
continue;
|
||||
}
|
||||
|
||||
bot.chat().tellraw(
|
||||
bot.chat.tellraw(
|
||||
Component.translatable(
|
||||
"[%s] %s › %s",
|
||||
Component.text(bot.username() + " Console").color(NamedTextColor.GRAY),
|
||||
Component.text(bot.config().ownerName()).color(ColorUtilities.getColorByString(bot.config().colorPalette().ownerName())),
|
||||
Component.text(bot.username + " Console").color(NamedTextColor.GRAY),
|
||||
Component.text(bot.config.ownerName).color(ColorUtilities.getColorByString(bot.config.colorPalette.ownerName)),
|
||||
Component.text(line).color(NamedTextColor.GRAY)
|
||||
).color(NamedTextColor.DARK_GRAY)
|
||||
);
|
||||
|
|
|
@ -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.PlayerAction;
|
||||
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.packet.ingame.clientbound.level.ClientboundBlockUpdatePacket;
|
||||
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.packet.Packet;
|
||||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||
import lombok.Getter;
|
||||
import org.cloudburstmc.math.vector.Vector3i;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -37,9 +35,9 @@ import java.util.concurrent.TimeUnit;
|
|||
public class CorePlugin extends PositionPlugin.Listener {
|
||||
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;
|
||||
|
||||
|
@ -56,30 +54,30 @@ public class CorePlugin extends PositionPlugin.Listener {
|
|||
|
||||
private final boolean kaboom;
|
||||
|
||||
@Getter private int commandsPerSecond = 0;
|
||||
private int commandsPerSecond = 0;
|
||||
|
||||
public CorePlugin (Bot bot) {
|
||||
this.bot = bot;
|
||||
this.kaboom = bot.options().kaboom();
|
||||
this.kaboom = bot.options.kaboom;
|
||||
|
||||
this.fromSize = Vector3i.from(
|
||||
bot.config().core().start().x(),
|
||||
bot.config().core().start().y(),
|
||||
bot.config().core().start().z()
|
||||
bot.config.core.start.x,
|
||||
bot.config.core.start.y,
|
||||
bot.config.core.start.z
|
||||
);
|
||||
this.toSize = Vector3i.from(
|
||||
bot.config().core().end().x(),
|
||||
bot.config().core().end().y(),
|
||||
bot.config().core().end().z()
|
||||
bot.config.core.end.x,
|
||||
bot.config.core.end.y,
|
||||
bot.config.core.end.z
|
||||
);
|
||||
|
||||
bot.position().addListener(this);
|
||||
bot.position.addListener(this);
|
||||
|
||||
if (hasRateLimit() && hasReset()) {
|
||||
bot.executor().scheduleAtFixedRate(
|
||||
bot.executor.scheduleAtFixedRate(
|
||||
() -> commandsPerSecond = 0,
|
||||
0,
|
||||
bot.options().coreRateLimit().reset(),
|
||||
bot.options.coreRateLimit.reset,
|
||||
TimeUnit.MILLISECONDS
|
||||
);
|
||||
}
|
||||
|
@ -105,19 +103,19 @@ public class CorePlugin extends PositionPlugin.Listener {
|
|||
}
|
||||
|
||||
public boolean hasRateLimit () {
|
||||
return bot.options().coreRateLimit().limit() > 0;
|
||||
return bot.options.coreRateLimit.limit > 0;
|
||||
}
|
||||
|
||||
public boolean hasReset () {
|
||||
return bot.options().coreRateLimit().reset() > 0;
|
||||
return bot.options.coreRateLimit.reset > 0;
|
||||
}
|
||||
|
||||
public boolean isRateLimited () {
|
||||
return commandsPerSecond > bot.options().coreRateLimit().limit();
|
||||
return commandsPerSecond > bot.options.coreRateLimit.limit;
|
||||
}
|
||||
|
||||
private void forceRun (String command) {
|
||||
bot.session().send(new ServerboundSetCommandBlockPacket(
|
||||
bot.session.send(new ServerboundSetCommandBlockPacket(
|
||||
block,
|
||||
command,
|
||||
kaboom ? CommandBlockMode.AUTO : CommandBlockMode.REDSTONE,
|
||||
|
@ -132,21 +130,21 @@ public class CorePlugin extends PositionPlugin.Listener {
|
|||
public void run (String command) {
|
||||
if (!ready || command.length() > 32767) return;
|
||||
|
||||
if (bot.options().useCore()) {
|
||||
if (bot.options.useCore) {
|
||||
if (isRateLimited() && hasRateLimit()) return;
|
||||
|
||||
forceRun(command);
|
||||
|
||||
if (hasRateLimit()) commandsPerSecond++;
|
||||
} else if (command.length() < 256) {
|
||||
bot.chat().send("/" + command);
|
||||
bot.chat.send("/" + command);
|
||||
}
|
||||
}
|
||||
|
||||
public CompletableFuture<CompoundTag> runTracked (String command) {
|
||||
run(command);
|
||||
|
||||
if (!bot.options().useCore()) return null;
|
||||
if (!bot.options.useCore) return null;
|
||||
|
||||
final int transactionId = nextTransactionId++;
|
||||
|
||||
|
@ -154,15 +152,15 @@ public class CorePlugin extends PositionPlugin.Listener {
|
|||
final CompletableFuture<CompoundTag> future = new CompletableFuture<>();
|
||||
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;
|
||||
}
|
||||
|
||||
public void runPlaceBlock (String command) {
|
||||
if (!ready || !bot.options().useCore()) return;
|
||||
if (!ready || !bot.options.useCore) return;
|
||||
|
||||
final CompoundTag tag = new CompoundTag("");
|
||||
final CompoundTag blockEntityTag = new CompoundTag("BlockEntityTag");
|
||||
|
@ -172,12 +170,12 @@ public class CorePlugin extends PositionPlugin.Listener {
|
|||
tag.put(blockEntityTag);
|
||||
|
||||
final Vector3i temporaryBlockPosition = Vector3i.from(
|
||||
bot.position().position().getX(),
|
||||
bot.position().position().getY() - 1,
|
||||
bot.position().position().getZ()
|
||||
bot.position.position.getX(),
|
||||
bot.position.position.getY() - 1,
|
||||
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 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));
|
||||
|
@ -275,15 +273,15 @@ public class CorePlugin extends PositionPlugin.Listener {
|
|||
@Override
|
||||
public void positionChange (Vector3i position) {
|
||||
from = Vector3i.from(
|
||||
fromSize.getX() + bot.position().position().getX(),
|
||||
fromSize.getX() + bot.position.position.getX(),
|
||||
fromSize.getY(),
|
||||
fromSize.getZ() + bot.position().position().getZ()
|
||||
fromSize.getZ() + bot.position.position.getZ()
|
||||
);
|
||||
|
||||
to = Vector3i.from(
|
||||
toSize.getX() + bot.position().position().getX(),
|
||||
toSize.getX() + bot.position.position.getX(),
|
||||
toSize.getY(),
|
||||
toSize.getZ() + bot.position().position().getZ()
|
||||
toSize.getZ() + bot.position.position.getZ()
|
||||
);
|
||||
|
||||
reset();
|
||||
|
@ -292,7 +290,7 @@ public class CorePlugin extends PositionPlugin.Listener {
|
|||
if (!ready) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -315,10 +313,10 @@ public class CorePlugin extends PositionPlugin.Listener {
|
|||
to.getY(),
|
||||
to.getZ(),
|
||||
|
||||
bot.config().core().customName()
|
||||
bot.config.core.customName
|
||||
);
|
||||
|
||||
// bot.chat().send(command);
|
||||
// bot.chat.send(command);
|
||||
|
||||
runPlaceBlock(command);
|
||||
}
|
||||
|
|
|
@ -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.ComponentUtilities;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.CodeBlockUtilities;
|
||||
import lombok.Getter;
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
import net.dv8tion.jda.api.entities.*;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
@ -30,34 +29,34 @@ import java.util.List;
|
|||
// please ignore my ohio code
|
||||
// also this is one of the classes which has >100 lines or actually >300 LMAO
|
||||
public class DiscordPlugin {
|
||||
@Getter private JDA jda;
|
||||
public JDA jda;
|
||||
|
||||
public final Map<String, String> servers;
|
||||
|
||||
public final String prefix;
|
||||
|
||||
public DiscordPlugin (Configuration config, JDA jda) {
|
||||
final Configuration.Discord options = config.discord();
|
||||
this.prefix = options.prefix();
|
||||
this.servers = options.servers();
|
||||
final Configuration.Discord options = config.discord;
|
||||
this.prefix = options.prefix;
|
||||
this.servers = options.servers;
|
||||
this.jda = jda;
|
||||
|
||||
if (jda == null) return;
|
||||
|
||||
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() {
|
||||
@Override
|
||||
public void loadedPlugins() {
|
||||
bot.tick().addListener(new TickPlugin.Listener() {
|
||||
bot.tick.addListener(new TickPlugin.Listener() {
|
||||
@Override
|
||||
public void onTick() {
|
||||
onDiscordTick(channelId);
|
||||
}
|
||||
});
|
||||
|
||||
bot.chat().addListener(new ChatPlugin.Listener() {
|
||||
bot.chat.addListener(new ChatPlugin.Listener() {
|
||||
@Override
|
||||
public void systemMessageReceived (Component component) {
|
||||
final String content = ComponentUtilities.stringifyAnsi(component);
|
||||
|
@ -71,8 +70,8 @@ public class DiscordPlugin {
|
|||
sendMessageInstantly(
|
||||
String.format(
|
||||
"Connecting to: `%s:%s`",
|
||||
bot.host(),
|
||||
bot.port()
|
||||
bot.host,
|
||||
bot.port
|
||||
),
|
||||
channelId
|
||||
);
|
||||
|
@ -83,8 +82,8 @@ public class DiscordPlugin {
|
|||
sendMessageInstantly(
|
||||
String.format(
|
||||
"Successfully connected to: `%s:%s`",
|
||||
bot.host(),
|
||||
bot.port()
|
||||
bot.host,
|
||||
bot.port
|
||||
),
|
||||
channelId
|
||||
);
|
||||
|
@ -110,7 +109,7 @@ public class DiscordPlugin {
|
|||
if (
|
||||
!event.getChannel().getId().equals(channelId) ||
|
||||
event.getAuthor().getId().equals(jda.getSelfUser().getId()) ||
|
||||
!bot.loggedIn()
|
||||
!bot.loggedIn
|
||||
) return;
|
||||
|
||||
final Message messageEvent = event.getMessage();
|
||||
|
@ -119,7 +118,7 @@ public class DiscordPlugin {
|
|||
if (message.startsWith(prefix)) {
|
||||
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) {
|
||||
context.sendOutput(output);
|
||||
|
@ -155,7 +154,7 @@ public class DiscordPlugin {
|
|||
%s""",
|
||||
embed.getTitle() == null ?
|
||||
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 ?
|
||||
Component.text("No description").color(NamedTextColor.GRAY) :
|
||||
Component.text(embed.getDescription()).color(NamedTextColor.WHITE)
|
||||
|
@ -250,7 +249,7 @@ public class DiscordPlugin {
|
|||
|
||||
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()
|
||||
.append(Component.text("ChomeNS ").color(NamedTextColor.YELLOW))
|
||||
|
@ -280,11 +279,11 @@ public class DiscordPlugin {
|
|||
messageComponent
|
||||
).color(NamedTextColor.DARK_GRAY);
|
||||
|
||||
bot.chat().tellraw(component);
|
||||
bot.chat.tellraw(component);
|
||||
}
|
||||
});
|
||||
|
||||
bot.discord(this);
|
||||
bot.discord = this;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import io.socket.client.IO;
|
|||
import io.socket.client.Socket;
|
||||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.EvalOutput;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -13,7 +12,7 @@ import java.util.concurrent.CompletableFuture;
|
|||
public class EvalPlugin {
|
||||
public static final String BRIDGE_PREFIX = "function:";
|
||||
|
||||
@Getter private boolean connected = false;
|
||||
public boolean connected = false;
|
||||
|
||||
private Socket socket = null;
|
||||
|
||||
|
@ -23,7 +22,7 @@ public class EvalPlugin {
|
|||
|
||||
public EvalPlugin (Bot bot) {
|
||||
try {
|
||||
socket = IO.socket(bot.config().eval().address());
|
||||
socket = IO.socket(bot.config.eval.address);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -45,13 +44,13 @@ public class EvalPlugin {
|
|||
socket.on(BRIDGE_PREFIX + "chat", (args) -> {
|
||||
final String message = (String) args[0];
|
||||
|
||||
bot.chat().send(message);
|
||||
bot.chat.send(message);
|
||||
});
|
||||
|
||||
socket.on(BRIDGE_PREFIX + "core", (args) -> {
|
||||
final String command = (String) args[0];
|
||||
|
||||
bot.core().run(command);
|
||||
bot.core.run(command);
|
||||
});
|
||||
|
||||
socket.connect();
|
||||
|
|
|
@ -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.util.PersistentDataUtilities;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.UUIDUtilities;
|
||||
import lombok.Getter;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
||||
|
@ -19,7 +18,7 @@ import java.util.regex.Pattern;
|
|||
public class FilterPlugin extends PlayersPlugin.Listener {
|
||||
private final Bot bot;
|
||||
|
||||
@Getter private static JsonArray filteredPlayers = new JsonArray();
|
||||
public static JsonArray filteredPlayers = new JsonArray();
|
||||
|
||||
private final Gson gson = new Gson();
|
||||
|
||||
|
@ -32,9 +31,9 @@ public class FilterPlugin extends PlayersPlugin.Listener {
|
|||
public FilterPlugin (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
|
||||
public void commandSpyMessageReceived(PlayerMessage 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) {
|
||||
|
@ -64,7 +63,7 @@ public class FilterPlugin extends PlayersPlugin.Listener {
|
|||
try {
|
||||
pattern = Pattern.compile(_filteredPlayer.playerName);
|
||||
} 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
|
||||
public void playerJoined (MutablePlayerListEntry target) {
|
||||
final FilteredPlayer player = getPlayer(target.profile().getName());
|
||||
final FilteredPlayer player = getPlayer(target.profile.getName());
|
||||
|
||||
if (player == null) return;
|
||||
|
||||
deOp(target);
|
||||
mute(target);
|
||||
|
||||
bot.exploits().kick(target.profile().getId());
|
||||
bot.exploits.kick(target.profile.getId());
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
deOp(message.sender());
|
||||
deOp(message.sender);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
deOp(message.sender());
|
||||
mute(message.sender());
|
||||
deOp(message.sender);
|
||||
mute(message.sender);
|
||||
}
|
||||
|
||||
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) {
|
||||
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 () {
|
||||
for (MutablePlayerListEntry target : bot.players().list()) {
|
||||
final FilteredPlayer player = getPlayer(target.profile().getName());
|
||||
for (MutablePlayerListEntry target : bot.players.list) {
|
||||
final FilteredPlayer player = getPlayer(target.profile.getName());
|
||||
|
||||
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);
|
||||
|
||||
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;
|
||||
|
||||
|
|
|
@ -3,8 +3,6 @@ package land.chipmunk.chayapak.chomens_bot.plugins;
|
|||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.FileLoggerUtilities;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
@ -19,7 +17,7 @@ import java.util.zip.GZIPInputStream;
|
|||
public class GrepLogPlugin {
|
||||
private final Bot bot;
|
||||
|
||||
@Getter @Setter private Thread thread = null;
|
||||
public Thread thread = null;
|
||||
|
||||
public GrepLogPlugin (Bot bot) {
|
||||
this.bot = bot;
|
||||
|
@ -56,7 +54,7 @@ public class GrepLogPlugin {
|
|||
try {
|
||||
pattern = Pattern.compile(query);
|
||||
} catch (Exception e) {
|
||||
bot.chat().tellraw(Component.text(e.toString()).color(NamedTextColor.RED));
|
||||
bot.chat.tellraw(Component.text(e.toString()).color(NamedTextColor.RED));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -68,11 +66,11 @@ public class GrepLogPlugin {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
bot.chat().tellraw(
|
||||
bot.chat.tellraw(
|
||||
Component.translatable(
|
||||
"Collecting %s in logs...",
|
||||
Component.text(query).color(ColorUtilities.getColorByString(bot.config().colorPalette().secondary()))
|
||||
).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor()))
|
||||
Component.text(query).color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary))
|
||||
).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor))
|
||||
);
|
||||
|
||||
final File[] fileList = FileLoggerUtilities.logDir.listFiles();
|
||||
|
@ -160,7 +158,7 @@ public class GrepLogPlugin {
|
|||
|
||||
private void finish () {
|
||||
if (results.toString().split("\n").length < 100) { // ig lazy fix for removing \n lol
|
||||
bot.chat().tellraw(
|
||||
bot.chat.tellraw(
|
||||
Component.empty()
|
||||
.append(Component.text("Log query output for \""))
|
||||
.append(Component.text(query))
|
||||
|
@ -168,17 +166,17 @@ public class GrepLogPlugin {
|
|||
.append(Component.newline())
|
||||
.append(Component.text(results.toString()))
|
||||
);
|
||||
} else if (bot.config().discord().enabled()) {
|
||||
bot.chat().tellraw(
|
||||
} else if (bot.config.discord.enabled) {
|
||||
bot.chat.tellraw(
|
||||
Component.translatable(
|
||||
"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(matches).color(ColorUtilities.getColorByString(bot.config().colorPalette().number()))
|
||||
Component.text(query).color(ColorUtilities.getColorByString(bot.config.colorPalette.string)),
|
||||
Component.text(matches).color(ColorUtilities.getColorByString(bot.config.colorPalette.number))
|
||||
)
|
||||
);
|
||||
|
||||
final String channelId = bot.discord().servers.get(bot.host() + ":" + bot.port());
|
||||
final TextChannel logChannel = bot.discord().jda().getTextChannelById(channelId);
|
||||
final String channelId = bot.discord.servers.get(bot.host + ":" + bot.port);
|
||||
final TextChannel logChannel = bot.discord.jda.getTextChannelById(channelId);
|
||||
|
||||
if (logChannel == null) return;
|
||||
|
||||
|
|
|
@ -2,22 +2,21 @@ package land.chipmunk.chayapak.chomens_bot.plugins;
|
|||
|
||||
import com.google.common.hash.Hashing;
|
||||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class HashingPlugin {
|
||||
private final Bot bot;
|
||||
|
||||
@Getter private String hash;
|
||||
@Getter private String ownerHash;
|
||||
public String hash;
|
||||
public String ownerHash;
|
||||
|
||||
private long lastTime;
|
||||
|
||||
public HashingPlugin (Bot bot) {
|
||||
this.bot = bot;
|
||||
|
||||
bot.tick().addListener(new TickPlugin.Listener() {
|
||||
bot.tick.addListener(new TickPlugin.Listener() {
|
||||
@Override
|
||||
public void onTick() {
|
||||
update();
|
||||
|
@ -32,8 +31,8 @@ public class HashingPlugin {
|
|||
if (time == lastTime) return;
|
||||
lastTime = time;
|
||||
|
||||
final String normalHashKey = bot.config().keys().normalKey();
|
||||
final String ownerHashKey = bot.config().keys().ownerKey();
|
||||
final String normalHashKey = bot.config.keys.normalKey;
|
||||
final String ownerHashKey = bot.config.keys.ownerKey;
|
||||
|
||||
final String hashValue = time + normalHashKey;
|
||||
hash = Hashing.sha256()
|
||||
|
|
|
@ -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.util.FileLoggerUtilities;
|
||||
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.format.NamedTextColor;
|
||||
|
||||
|
@ -18,7 +16,7 @@ public class LoggerPlugin extends ChatPlugin.Listener {
|
|||
|
||||
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");
|
||||
|
||||
|
@ -31,8 +29,8 @@ public class LoggerPlugin extends ChatPlugin.Listener {
|
|||
log(
|
||||
String.format(
|
||||
"Connecting to: %s:%s",
|
||||
bot.host(),
|
||||
bot.port()
|
||||
bot.host,
|
||||
bot.port
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -42,20 +40,20 @@ public class LoggerPlugin extends ChatPlugin.Listener {
|
|||
log(
|
||||
String.format(
|
||||
"Successfully connected to: %s:%s",
|
||||
bot.host(),
|
||||
bot.port()
|
||||
bot.host,
|
||||
bot.port
|
||||
)
|
||||
);
|
||||
|
||||
if (addedListener) return;
|
||||
bot.chat().addListener(LoggerPlugin.this);
|
||||
bot.chat.addListener(LoggerPlugin.this);
|
||||
addedListener = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnected (DisconnectedEvent event) {
|
||||
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",
|
||||
Component.text(dateTime.format(dateTimeFormatter)).color(NamedTextColor.GRAY),
|
||||
prefix,
|
||||
Component.text(bot.options().serverName()).color(NamedTextColor.GRAY),
|
||||
Component.text(bot.options.serverName).color(NamedTextColor.GRAY),
|
||||
Component.text(_message).color(NamedTextColor.WHITE)
|
||||
).color(NamedTextColor.DARK_GRAY);
|
||||
|
||||
|
@ -78,12 +76,12 @@ public class LoggerPlugin extends ChatPlugin.Listener {
|
|||
public void log (String _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(
|
||||
"[%s] %s",
|
||||
bot.host() + ":" + bot.port(),
|
||||
bot.host + ":" + bot.port,
|
||||
_message
|
||||
);
|
||||
|
||||
|
@ -98,13 +96,13 @@ public class LoggerPlugin extends ChatPlugin.Listener {
|
|||
public void info (String _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) {
|
||||
final String message = prefix(prefix, ComponentUtilities.stringifyAnsi(_message));
|
||||
|
||||
if (logToConsole) bot.console().reader().printAbove(message);
|
||||
if (logToConsole) bot.console.reader.printAbove(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -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.util.ColorUtilities;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.PersistentDataUtilities;
|
||||
import lombok.Getter;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
||||
|
@ -18,7 +17,7 @@ import java.util.List;
|
|||
public class MailPlugin extends PlayersPlugin.Listener {
|
||||
private final Bot bot;
|
||||
|
||||
@Getter private static JsonArray mails = new JsonArray();
|
||||
public static JsonArray mails = new JsonArray();
|
||||
|
||||
private final Gson gson = new Gson();
|
||||
|
||||
|
@ -31,26 +30,26 @@ public class MailPlugin extends PlayersPlugin.Listener {
|
|||
public MailPlugin (Bot bot) {
|
||||
this.bot = bot;
|
||||
|
||||
bot.players().addListener(this);
|
||||
bot.players.addListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
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,.,.
|
||||
|
||||
for (JsonElement mailElement : mails) {
|
||||
final Mail mail = gson.fromJson(mailElement, Mail.class);
|
||||
|
||||
sendTos.add(mail.sentTo());
|
||||
sendTos.add(mail.sentTo);
|
||||
}
|
||||
|
||||
boolean shouldSend = false;
|
||||
for (JsonElement mailElement : mails) {
|
||||
final Mail mail = gson.fromJson(mailElement, Mail.class);
|
||||
|
||||
if (mail.sentTo().equals(name)) {
|
||||
if (mail.sentTo.equals(name)) {
|
||||
shouldSend = true;
|
||||
break;
|
||||
}
|
||||
|
@ -62,11 +61,11 @@ public class MailPlugin extends PlayersPlugin.Listener {
|
|||
"Do %s or %s to read",
|
||||
Component.text(sendTos.size()).color(NamedTextColor.GREEN),
|
||||
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().prefixes().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))
|
||||
).color(NamedTextColor.GOLD);
|
||||
|
||||
bot.chat().tellraw(component, target.profile().getId());
|
||||
bot.chat.tellraw(component, target.profile.getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,16 +16,16 @@ public class MazePlugin {
|
|||
|
||||
// also totally didn't ask chatgpt for this too (but modified a bit)
|
||||
public void generate (MazeGenerator generator, int startX, int startY, int startZ) {
|
||||
bot.chat().tellraw(
|
||||
bot.chat.tellraw(
|
||||
Component.translatable(
|
||||
"Generating maze at %s %s %s...",
|
||||
Component.text(startX).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()))
|
||||
).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor()))
|
||||
Component.text(startX).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))
|
||||
).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor))
|
||||
);
|
||||
|
||||
final int[][] maze = generator.maze();
|
||||
final int[][] maze = generator.maze;
|
||||
|
||||
int x = startX;
|
||||
int z = startZ;
|
||||
|
@ -53,25 +53,25 @@ public class MazePlugin {
|
|||
final String command = "minecraft:fill %s %s %s %s %s %s %s";
|
||||
|
||||
// fill the floor
|
||||
bot.core().run(
|
||||
bot.core.run(
|
||||
String.format(
|
||||
command,
|
||||
x,
|
||||
startY - 1,
|
||||
z,
|
||||
x + generator.width(),
|
||||
x + generator.width,
|
||||
startY - 1,
|
||||
z + generator.height(),
|
||||
z + generator.height,
|
||||
"minecraft:stone_bricks replace minecraft:air"
|
||||
)
|
||||
);
|
||||
|
||||
// actually build the maze
|
||||
for (int row = 0; row < generator.height(); row++) {
|
||||
for (int col = 0; col < generator.width(); col++) {
|
||||
for (int row = 0; row < generator.height; row++) {
|
||||
for (int col = 0; col < generator.width; col++) {
|
||||
if (maze[row][col] == 1) {
|
||||
// makes the wall
|
||||
bot.core().run(
|
||||
bot.core.run(
|
||||
String.format(
|
||||
command,
|
||||
x,
|
||||
|
@ -85,7 +85,7 @@ public class MazePlugin {
|
|||
);
|
||||
} else if ((row == startRow && col == startCol)) {
|
||||
// Set a marker block for the start position
|
||||
bot.core().run(
|
||||
bot.core.run(
|
||||
String.format(
|
||||
command,
|
||||
x,
|
||||
|
@ -99,7 +99,7 @@ public class MazePlugin {
|
|||
);
|
||||
} else if ((row == endRow && col == endCol)) {
|
||||
// Set a marker block for the end position
|
||||
bot.core().run(
|
||||
bot.core.run(
|
||||
String.format(
|
||||
command,
|
||||
x,
|
||||
|
@ -125,33 +125,33 @@ public class MazePlugin {
|
|||
}
|
||||
|
||||
// lazy fix for the sus border issue
|
||||
bot.core().run(
|
||||
bot.core.run(
|
||||
String.format(
|
||||
command,
|
||||
x + generator.width(),
|
||||
x + generator.width,
|
||||
startY,
|
||||
z,
|
||||
x + generator.width(),
|
||||
x + generator.width,
|
||||
startY + 3,
|
||||
z + generator.height(),
|
||||
z + generator.height,
|
||||
"minecraft:stone"
|
||||
)
|
||||
);
|
||||
|
||||
bot.core().run(
|
||||
bot.core.run(
|
||||
String.format(
|
||||
command,
|
||||
x,
|
||||
startY,
|
||||
z + generator.height(),
|
||||
x + generator.width(),
|
||||
z + generator.height,
|
||||
x + generator.width,
|
||||
startY + 3,
|
||||
z + generator.height(),
|
||||
z + generator.height,
|
||||
"minecraft:stone"
|
||||
)
|
||||
);
|
||||
|
||||
bot.chat().tellraw(
|
||||
bot.chat.tellraw(
|
||||
Component.empty()
|
||||
.append(Component.text("Done generating maze. "))
|
||||
.append(
|
||||
|
@ -169,7 +169,7 @@ public class MazePlugin {
|
|||
)
|
||||
)
|
||||
)
|
||||
.color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor()))
|
||||
.color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.util.ColorUtilities;
|
||||
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.format.NamedTextColor;
|
||||
|
||||
|
@ -30,14 +28,14 @@ public class MusicPlayerPlugin extends Bot.Listener {
|
|||
if (!SONG_DIR.exists()) SONG_DIR.mkdir();
|
||||
}
|
||||
|
||||
@Getter @Setter private Song currentSong;
|
||||
@Getter @Setter private List<Song> songQueue = new ArrayList<>();
|
||||
@Getter @Setter private SongLoaderRunnable loaderThread;
|
||||
@Getter @Setter private Loop loop = Loop.OFF;
|
||||
public Song currentSong;
|
||||
public List<Song> songQueue = new ArrayList<>();
|
||||
public SongLoaderRunnable loaderThread;
|
||||
public Loop loop = Loop.OFF;
|
||||
|
||||
// sus nightcore stuff,..,.,.
|
||||
@Getter @Setter private float pitch = 0;
|
||||
@Getter @Setter private float speed = 1;
|
||||
public float pitch = 0;
|
||||
public float speed = 1;
|
||||
|
||||
private int ticksUntilPausedBossbar = 20;
|
||||
|
||||
|
@ -46,7 +44,7 @@ public class MusicPlayerPlugin extends Bot.Listener {
|
|||
public MusicPlayerPlugin (Bot bot) {
|
||||
this.bot = bot;
|
||||
bot.addListener(this);
|
||||
bot.core().addListener(new CorePlugin.Listener() {
|
||||
bot.core.addListener(new CorePlugin.Listener() {
|
||||
public void ready () { coreReady(); }
|
||||
});
|
||||
}
|
||||
|
@ -54,35 +52,35 @@ public class MusicPlayerPlugin extends Bot.Listener {
|
|||
public void loadSong (Path location) {
|
||||
final SongLoaderRunnable runnable = new SongLoaderRunnable(location, bot);
|
||||
|
||||
bot.chat().tellraw(
|
||||
bot.chat.tellraw(
|
||||
Component
|
||||
.translatable(
|
||||
"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) {
|
||||
final SongLoaderRunnable runnable = new SongLoaderRunnable(location, bot);
|
||||
|
||||
bot.chat().tellraw(
|
||||
bot.chat.tellraw(
|
||||
Component
|
||||
.translatable(
|
||||
"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 () {
|
||||
bot.tick().addListener(new TickPlugin.Listener() {
|
||||
bot.tick.addListener(new TickPlugin.Listener() {
|
||||
@Override
|
||||
public void onTick() {
|
||||
try {
|
||||
|
@ -92,29 +90,29 @@ public class MusicPlayerPlugin extends Bot.Listener {
|
|||
addBossBar();
|
||||
|
||||
currentSong = songQueue.get(0); // songQueue.poll();
|
||||
bot.chat().tellraw(
|
||||
bot.chat.tellraw(
|
||||
Component.translatable(
|
||||
"Now playing %s",
|
||||
Component.empty().append(currentSong.name).color(ColorUtilities.getColorByString(bot.config().colorPalette().secondary()))
|
||||
).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor()))
|
||||
Component.empty().append(currentSong.name).color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary))
|
||||
).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor))
|
||||
);
|
||||
currentSong.play();
|
||||
}
|
||||
|
||||
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.setColor(pitch > 0 ? BossBarColor.PURPLE : BossBarColor.YELLOW);
|
||||
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();
|
||||
|
||||
|
@ -124,11 +122,11 @@ public class MusicPlayerPlugin extends Bot.Listener {
|
|||
return;
|
||||
}
|
||||
|
||||
bot.chat().tellraw(
|
||||
bot.chat.tellraw(
|
||||
Component.translatable(
|
||||
"Finished playing %s",
|
||||
Component.empty().append(currentSong.name).color(ColorUtilities.getColorByString(bot.config().colorPalette().secondary()))
|
||||
).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor()))
|
||||
Component.empty().append(currentSong.name).color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary))
|
||||
).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor))
|
||||
);
|
||||
|
||||
if (loop == Loop.ALL) {
|
||||
|
@ -141,10 +139,10 @@ public class MusicPlayerPlugin extends Bot.Listener {
|
|||
if (songQueue.size() == 0) {
|
||||
stopPlaying();
|
||||
removeBossBar();
|
||||
bot.chat().tellraw(
|
||||
bot.chat.tellraw(
|
||||
Component
|
||||
.text("Finished playing every song in the queue")
|
||||
.color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor()))
|
||||
.color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor))
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
@ -190,13 +188,13 @@ public class MusicPlayerPlugin extends Bot.Listener {
|
|||
bot
|
||||
);
|
||||
|
||||
bot.bossbar().add(bossbarName, bossBar);
|
||||
bot.bossbar.add(bossbarName, bossBar);
|
||||
|
||||
return bossBar;
|
||||
}
|
||||
|
||||
public void removeBossBar() {
|
||||
bot.bossbar().remove(bossbarName);
|
||||
bot.bossbar.remove(bossbarName);
|
||||
}
|
||||
|
||||
public Component generateBossbar () {
|
||||
|
@ -210,7 +208,7 @@ public class MusicPlayerPlugin extends Bot.Listener {
|
|||
formatTime(currentSong.length).color(NamedTextColor.GRAY)).color(NamedTextColor.DARK_GRAY)
|
||||
);
|
||||
|
||||
if (!bot.core().hasRateLimit()) {
|
||||
if (!bot.core.hasRateLimit()) {
|
||||
final DecimalFormat formatter = new DecimalFormat("#,###");
|
||||
|
||||
component = component
|
||||
|
@ -282,7 +280,7 @@ public class MusicPlayerPlugin extends Bot.Listener {
|
|||
if (s < 100) blockPosition = ((s - 100) * -1) / 100;
|
||||
}
|
||||
|
||||
bot.core().run(
|
||||
bot.core.run(
|
||||
"minecraft:execute as " +
|
||||
SELECTOR +
|
||||
" at @s run playsound " +
|
||||
|
|
|
@ -3,8 +3,6 @@ package land.chipmunk.chayapak.chomens_bot.plugins;
|
|||
import com.github.steveice10.packetlib.Session;
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -13,7 +11,7 @@ import java.nio.charset.StandardCharsets;
|
|||
|
||||
// normally unused in the main instance of the bot
|
||||
public class PacketSnifferPlugin extends Bot.Listener {
|
||||
@Getter @Setter private boolean enabled = false;
|
||||
public boolean enabled = false;
|
||||
|
||||
private OutputStreamWriter writer;
|
||||
|
||||
|
@ -25,8 +23,8 @@ public class PacketSnifferPlugin extends Bot.Listener {
|
|||
new FileOutputStream(
|
||||
String.format(
|
||||
"packets-%s-%s.log",
|
||||
bot.options().host(),
|
||||
bot.options().port()
|
||||
bot.options.host,
|
||||
bot.options.port
|
||||
)
|
||||
),
|
||||
StandardCharsets.UTF_8
|
||||
|
|
|
@ -12,7 +12,6 @@ import com.google.gson.JsonObject;
|
|||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.PersistentDataUtilities;
|
||||
import lombok.Getter;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.time.Instant;
|
||||
|
@ -23,11 +22,12 @@ import java.util.UUID;
|
|||
|
||||
public class PlayersPlugin extends Bot.Listener {
|
||||
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<>();
|
||||
|
||||
@Getter private static JsonObject playersObject = new JsonObject();
|
||||
public static JsonObject playersObject = new JsonObject();
|
||||
|
||||
static {
|
||||
if (PersistentDataUtilities.jsonObject.has("players")) {
|
||||
|
@ -71,7 +71,7 @@ public class PlayersPlugin extends Bot.Listener {
|
|||
|
||||
public final MutablePlayerListEntry getEntry (UUID uuid) {
|
||||
for (MutablePlayerListEntry candidate : list) {
|
||||
if (candidate.profile().getId().equals(uuid)) {
|
||||
if (candidate.profile.getId().equals(uuid)) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ public class PlayersPlugin extends Bot.Listener {
|
|||
|
||||
public final MutablePlayerListEntry getEntry (Component displayName) {
|
||||
for (MutablePlayerListEntry candidate : list) {
|
||||
if (candidate.displayName() != null && candidate.displayName().equals(displayName)) {
|
||||
if (candidate.displayName != null && candidate.displayName.equals(displayName)) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ public class PlayersPlugin extends Bot.Listener {
|
|||
return null;
|
||||
}
|
||||
|
||||
public MutablePlayerListEntry getBotEntry () { return getEntry(bot.username()); }
|
||||
public MutablePlayerListEntry getBotEntry () { return getEntry(bot.username); }
|
||||
|
||||
private MutablePlayerListEntry getEntry (PlayerListEntry other) {
|
||||
return getEntry(other.getProfile().getId());
|
||||
|
@ -109,18 +109,18 @@ public class PlayersPlugin extends Bot.Listener {
|
|||
final MutablePlayerListEntry target = getEntry(newEntry);
|
||||
if (target == null) return;
|
||||
|
||||
target.publicKey(newEntry.getPublicKey());
|
||||
target.publicKey = newEntry.getPublicKey();
|
||||
}
|
||||
|
||||
private void updateListed (PlayerListEntry newEntry) {
|
||||
final MutablePlayerListEntry target = getEntry(newEntry);
|
||||
if (target == null) return;
|
||||
|
||||
target.listed(newEntry.isListed());
|
||||
target.listed = newEntry.isListed();
|
||||
}
|
||||
|
||||
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) {
|
||||
|
@ -138,7 +138,7 @@ public class PlayersPlugin extends Bot.Listener {
|
|||
if (playersObject.has(getName(target))) return;
|
||||
|
||||
final JsonObject object = new JsonObject();
|
||||
object.addProperty("uuid", target.profile().getIdAsString());
|
||||
object.addProperty("uuid", target.profile.getIdAsString());
|
||||
object.add("lastSeen", new JsonObject());
|
||||
|
||||
playersObject.add(getName(target), object);
|
||||
|
@ -153,7 +153,7 @@ public class PlayersPlugin extends Bot.Listener {
|
|||
|
||||
final GameMode gameMode = newEntry.getGameMode();
|
||||
|
||||
target.gamemode(gameMode);
|
||||
target.gamemode = gameMode;
|
||||
|
||||
for (Listener listener : listeners) { listener.playerGameModeUpdated(target, gameMode); }
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ public class PlayersPlugin extends Bot.Listener {
|
|||
|
||||
final int ping = newEntry.getLatency();
|
||||
|
||||
target.latency(ping);
|
||||
target.latency = ping;
|
||||
|
||||
for (Listener listener : listeners) { listener.playerLatencyUpdated(target, ping); }
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ public class PlayersPlugin extends Bot.Listener {
|
|||
|
||||
final Component displayName = newEntry.getDisplayName();
|
||||
|
||||
target.displayName(displayName);
|
||||
target.displayName = displayName;
|
||||
|
||||
for (Listener listener : listeners) { listener.playerDisplayNameUpdated(target, displayName); }
|
||||
}
|
||||
|
@ -184,14 +184,14 @@ public class PlayersPlugin extends Bot.Listener {
|
|||
final MutablePlayerListEntry target = getEntry(uuid);
|
||||
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 Component[] tooltips = packet.getTooltips();
|
||||
final String username = target.profile().getName();
|
||||
final String username = target.profile.getName();
|
||||
|
||||
for (int i = 0; i < matches.length; i++) {
|
||||
if (tooltips[i] != null || !matches[i].equals(username)) continue;
|
||||
target.listed(false);
|
||||
target.listed = false;
|
||||
for (Listener listener : listeners) { listener.playerVanished(target); }
|
||||
return packet;
|
||||
}
|
||||
|
@ -209,7 +209,7 @@ public class PlayersPlugin extends Bot.Listener {
|
|||
|
||||
final JsonObject object = new JsonObject();
|
||||
object.addProperty("time", Instant.now().toEpochMilli());
|
||||
object.addProperty("server", bot.host() + ":" + bot.port());
|
||||
object.addProperty("server", bot.host + ":" + bot.port);
|
||||
|
||||
player.add("lastSeen", object);
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ import com.github.steveice10.packetlib.packet.Packet;
|
|||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.Rotation;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry;
|
||||
import lombok.Getter;
|
||||
import org.cloudburstmc.math.vector.Vector3f;
|
||||
import org.cloudburstmc.math.vector.Vector3i;
|
||||
|
||||
|
@ -27,7 +26,7 @@ public class PositionPlugin extends Bot.Listener {
|
|||
|
||||
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, Vector3f> positionMap = new HashMap<>();
|
||||
|
@ -49,14 +48,14 @@ public class PositionPlugin extends Bot.Listener {
|
|||
}
|
||||
|
||||
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());
|
||||
for (Listener listener : listeners) { listener.positionChange(position); }
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
|
@ -88,7 +87,7 @@ public class PositionPlugin extends Bot.Listener {
|
|||
|
||||
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) {
|
||||
|
@ -108,7 +107,7 @@ public class PositionPlugin extends Bot.Listener {
|
|||
|
||||
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) {
|
||||
|
@ -138,7 +137,7 @@ public class PositionPlugin extends Bot.Listener {
|
|||
public Vector3f getPlayerPosition (String playerName) {
|
||||
int entityId = -1;
|
||||
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;
|
||||
|
@ -153,7 +152,7 @@ public class PositionPlugin extends Bot.Listener {
|
|||
public Rotation getPlayerRotation (String playerName) {
|
||||
int entityId = -1;
|
||||
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;
|
||||
|
|
|
@ -15,13 +15,11 @@ import com.github.steveice10.packetlib.Session;
|
|||
import com.github.steveice10.packetlib.event.session.DisconnectedEvent;
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
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.Configuration;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.ComponentUtilities;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.cloudburstmc.math.vector.Vector3i;
|
||||
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
@ -31,7 +29,7 @@ public class SelfCarePlugin extends Bot.Listener {
|
|||
|
||||
private ScheduledFuture<?> checkTask;
|
||||
|
||||
@Getter @Setter boolean visibility = false;
|
||||
public boolean visibility = false;
|
||||
|
||||
private int entityId;
|
||||
private GameMode gamemode;
|
||||
|
@ -50,7 +48,7 @@ public class SelfCarePlugin extends Bot.Listener {
|
|||
|
||||
bot.addListener(this);
|
||||
|
||||
bot.chat().addListener(new ChatPlugin.Listener() {
|
||||
bot.chat.addListener(new ChatPlugin.Listener() {
|
||||
@Override
|
||||
public void systemMessageReceived(Component 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;
|
||||
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("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.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() + ": disabled")) socialspy = false;
|
||||
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.startsWith("You have been muted")) muted = true;
|
||||
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 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;
|
||||
}
|
||||
});
|
||||
|
||||
bot.position().addListener(new PositionPlugin.Listener() {
|
||||
bot.position.addListener(new PositionPlugin.Listener() {
|
||||
@Override
|
||||
public void positionChange(Vector3i position) {
|
||||
SelfCarePlugin.this.positionChange();
|
||||
|
@ -89,32 +87,32 @@ public class SelfCarePlugin extends Bot.Listener {
|
|||
}
|
||||
|
||||
public void check () {
|
||||
final Configuration.SelfCare selfCares = bot.config().selfCare();
|
||||
final Configuration.SelfCare selfCares = bot.config.selfCare;
|
||||
|
||||
// chat only
|
||||
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.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.username() && !username && bot.options().kaboom()) bot.chat().send("/extras:username " + bot.username());
|
||||
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.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.username && !username && bot.options.kaboom) bot.chat.send("/extras:username " + bot.username);
|
||||
|
||||
// core
|
||||
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()) {
|
||||
if (bot.options().useChat()) bot.chat().send("/essentials:vanish enable");
|
||||
else bot.core().run("essentials:vanish " + bot.username() + " enable");
|
||||
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) {
|
||||
if (bot.options.useChat) bot.chat.send("/essentials:vanish enable");
|
||||
else bot.core.run("essentials:vanish " + bot.username + " enable");
|
||||
}
|
||||
else if (selfCares.nickname() && !nickname && bot.options().hasEssentials()) {
|
||||
if (bot.options().useChat()) bot.chat().send("/essentials:nick off");
|
||||
else bot.core().run("essentials:nickname " + bot.username() + " off");
|
||||
else if (selfCares.nickname && !nickname && bot.options.hasEssentials) {
|
||||
if (bot.options.useChat) bot.chat.send("/essentials:nick off");
|
||||
else bot.core.run("essentials:nickname " + bot.username + " off");
|
||||
}
|
||||
else if (selfCares.socialspy() && !socialspy && bot.options().hasEssentials()) {
|
||||
if (bot.options().useChat()) bot.chat().send("/essentials:socialspy enable");
|
||||
else bot.core().run("essentials:socialspy " + bot.username() + " enable");
|
||||
else if (selfCares.socialspy && !socialspy && bot.options.hasEssentials) {
|
||||
if (bot.options.useChat) bot.chat.send("/essentials:socialspy enable");
|
||||
else bot.core.run("essentials:socialspy " + bot.username + " enable");
|
||||
}
|
||||
else if (selfCares.mute() && muted && bot.options().hasEssentials()) {
|
||||
if (bot.options().useChat()) bot.chat().send("/essentials:mute " + bot.profile().getIdAsString());
|
||||
else bot.core().run("essentials:mute " + bot.profile().getIdAsString());
|
||||
else if (selfCares.mute && muted && bot.options.hasEssentials) {
|
||||
if (bot.options.useChat) bot.chat.send("/essentials:mute " + bot.profile.getIdAsString());
|
||||
else bot.core.run("essentials:mute " + bot.profile.getIdAsString());
|
||||
|
||||
muted = false; // too lazy fix and probably the worst fix?
|
||||
}
|
||||
|
@ -140,7 +138,7 @@ public class SelfCarePlugin extends Bot.Listener {
|
|||
positionPacketsPerSecond = 0;
|
||||
|
||||
final Runnable task = () -> {
|
||||
final Session session = bot.session();
|
||||
final Session session = bot.session;
|
||||
final PacketProtocol protocol = session.getPacketProtocol();
|
||||
if (
|
||||
!session.isConnected() ||
|
||||
|
@ -153,7 +151,7 @@ public class SelfCarePlugin extends Bot.Listener {
|
|||
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) {
|
||||
|
@ -161,7 +159,7 @@ public class SelfCarePlugin extends Bot.Listener {
|
|||
final GameEventValue value = packet.getValue();
|
||||
|
||||
if (notification == GameEvent.ENTER_CREDITS) {
|
||||
bot.session().send(new ServerboundClientCommandPacket(ClientCommand.RESPAWN));
|
||||
bot.session.send(new ServerboundClientCommandPacket(ClientCommand.RESPAWN));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -185,7 +183,7 @@ public class SelfCarePlugin extends Bot.Listener {
|
|||
public void positionChange () {
|
||||
positionPacketsPerSecond++;
|
||||
|
||||
bot.executor().schedule(() -> positionPacketsPerSecond--, 1, TimeUnit.SECONDS);
|
||||
bot.executor.schedule(() -> positionPacketsPerSecond--, 1, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -33,10 +33,10 @@ public class TPSPlugin extends Bot.Listener {
|
|||
|
||||
bot.addListener(this);
|
||||
|
||||
bot.core().addListener(new CorePlugin.Listener() {
|
||||
bot.core.addListener(new CorePlugin.Listener() {
|
||||
@Override
|
||||
public void ready() {
|
||||
bot.tick().addListener(new TickPlugin.Listener() {
|
||||
bot.tick.addListener(new TickPlugin.Listener() {
|
||||
@Override
|
||||
public void onTick() {
|
||||
updateTPSBar();
|
||||
|
@ -61,12 +61,12 @@ public class TPSPlugin extends Bot.Listener {
|
|||
bot
|
||||
);
|
||||
|
||||
bot.bossbar().add(bossbarName, bossBar);
|
||||
bot.bossbar.add(bossbarName, bossBar);
|
||||
}
|
||||
|
||||
public void off () {
|
||||
enabled = false;
|
||||
bot.bossbar().remove(bossbarName);
|
||||
bot.bossbar.remove(bossbarName);
|
||||
}
|
||||
|
||||
private void updateTPSBar () {
|
||||
|
@ -83,7 +83,7 @@ public class TPSPlugin extends Bot.Listener {
|
|||
Component.text(formatter.format(tickRate)).color(getColor(tickRate))
|
||||
).color(NamedTextColor.DARK_GRAY);
|
||||
|
||||
final BotBossBar bossBar = bot.bossbar().get(bossbarName);
|
||||
final BotBossBar bossBar = bot.bossbar.get(bossbarName);
|
||||
|
||||
if (bossBar == null) return;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ public class TabCompletePlugin extends Bot.Listener {
|
|||
public CompletableFuture<ClientboundCommandSuggestionsPacket> tabComplete (String command) {
|
||||
final int transactionId = nextTransactionId++;
|
||||
|
||||
bot.session().send(new ServerboundCommandSuggestionPacket(transactionId, command));
|
||||
bot.session.send(new ServerboundCommandSuggestionPacket(transactionId, command));
|
||||
|
||||
final CompletableFuture<ClientboundCommandSuggestionsPacket> future = new CompletableFuture<>();
|
||||
transactions.put(transactionId, future);
|
||||
|
|
|
@ -5,14 +5,13 @@ import com.github.steveice10.packetlib.Session;
|
|||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.Team;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class TeamPlugin extends Bot.Listener {
|
||||
@Getter private final Map<String, Team> teams = new HashMap<>();
|
||||
@Getter private final Map<String, Team> teamsByPlayer = new HashMap<>();
|
||||
public final Map<String, Team> teams = new HashMap<>();
|
||||
public final Map<String, Team> teamsByPlayer = new HashMap<>();
|
||||
|
||||
public TeamPlugin (Bot bot) {
|
||||
bot.addListener(this);
|
||||
|
@ -47,15 +46,15 @@ public class TeamPlugin extends Bot.Listener {
|
|||
|
||||
if (team == null) return;
|
||||
|
||||
team.teamName(packet.getTeamName());
|
||||
team.displayName(packet.getDisplayName());
|
||||
team.friendlyFire(packet.isFriendlyFire());
|
||||
team.seeFriendlyInvisibles(packet.isSeeFriendlyInvisibles());
|
||||
team.nametagVisibility(packet.getNameTagVisibility());
|
||||
team.collisionRule(packet.getCollisionRule());
|
||||
team.color(packet.getColor());
|
||||
team.prefix(packet.getPrefix());
|
||||
team.suffix(packet.getSuffix());
|
||||
team.teamName = packet.getTeamName();
|
||||
team.displayName = packet.getDisplayName();
|
||||
team.friendlyFire = packet.isFriendlyFire();
|
||||
team.seeFriendlyInvisibles = packet.isSeeFriendlyInvisibles();
|
||||
team.nametagVisibility = packet.getNameTagVisibility();
|
||||
team.collisionRule = packet.getCollisionRule();
|
||||
team.color = packet.getColor();
|
||||
team.prefix = packet.getPrefix();
|
||||
team.suffix = packet.getSuffix();
|
||||
}
|
||||
case ADD_PLAYER -> {
|
||||
final Team team = teams.get(packet.getTeamName());
|
||||
|
|
|
@ -24,7 +24,7 @@ public class TickPlugin extends Bot.Listener {
|
|||
|
||||
@Override
|
||||
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 () {
|
||||
|
|
|
@ -3,7 +3,6 @@ package land.chipmunk.chayapak.chomens_bot.plugins;
|
|||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.ColorUtilities;
|
||||
import lombok.Getter;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.joda.time.DateTime;
|
||||
|
@ -16,37 +15,37 @@ import java.util.UUID;
|
|||
public class TrustedPlugin extends PlayersPlugin.Listener {
|
||||
private final Bot bot;
|
||||
|
||||
@Getter private final List<String> list;
|
||||
public final List<String> list;
|
||||
|
||||
public TrustedPlugin (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) {
|
||||
for (Bot bot : bot.bots()) {
|
||||
if (!bot.loggedIn()) continue;
|
||||
for (Bot bot : bot.bots) {
|
||||
if (!bot.loggedIn) continue;
|
||||
|
||||
final Component component = Component.translatable(
|
||||
"[%s] [%s] %s",
|
||||
Component.text("ChomeNS Bot").color(ColorUtilities.getColorByString(bot.config().colorPalette().primary())),
|
||||
Component.text(this.bot.options().serverName()).color(NamedTextColor.GRAY),
|
||||
Component.text("ChomeNS Bot").color(ColorUtilities.getColorByString(bot.config.colorPalette.primary)),
|
||||
Component.text(this.bot.options.serverName).color(NamedTextColor.GRAY),
|
||||
message.color(NamedTextColor.WHITE)
|
||||
).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) {
|
||||
final MutablePlayerListEntry entry = bot.players().getEntry(player);
|
||||
final MutablePlayerListEntry entry = bot.players.getEntry(player);
|
||||
|
||||
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
|
||||
public void playerJoined (MutablePlayerListEntry target) {
|
||||
if (!list.contains(target.profile().getName())) return;
|
||||
if (!list.contains(target.profile.getName())) return;
|
||||
|
||||
// based (VERY)
|
||||
Component component;
|
||||
if (!target.profile().getName().equals(bot.config().ownerName())) {
|
||||
if (!target.profile.getName().equals(bot.config.ownerName)) {
|
||||
component = Component.translatable(
|
||||
"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);
|
||||
} else {
|
||||
final DateTime now = DateTime.now();
|
||||
|
@ -75,35 +74,35 @@ public class TrustedPlugin extends PlayersPlugin.Listener {
|
|||
Hello, %s!
|
||||
Time: %s
|
||||
Online players: %s""",
|
||||
Component.text(target.profile().getName()).color(ColorUtilities.getColorByString(bot.config().colorPalette().username())),
|
||||
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(target.profile.getName()).color(ColorUtilities.getColorByString(bot.config.colorPalette.username)),
|
||||
Component.text(formattedTime).color(ColorUtilities.getColorByString(bot.config.colorPalette.string)),
|
||||
Component.text(bot.players.list.size()).color(ColorUtilities.getColorByString(bot.config.colorPalette.number))
|
||||
).color(NamedTextColor.GREEN);
|
||||
}
|
||||
|
||||
bot.chat().tellraw(
|
||||
bot.chat.tellraw(
|
||||
component,
|
||||
target.profile().getId()
|
||||
target.profile.getId()
|
||||
);
|
||||
|
||||
broadcast(
|
||||
Component.translatable(
|
||||
"Trusted player %s is now online",
|
||||
Component.text(target.profile().getName()).color(ColorUtilities.getColorByString(bot.config().colorPalette().username()))
|
||||
).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())),
|
||||
target.profile().getId()
|
||||
Component.text(target.profile.getName()).color(ColorUtilities.getColorByString(bot.config.colorPalette.username))
|
||||
).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor)),
|
||||
target.profile.getId()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playerLeft (MutablePlayerListEntry target) {
|
||||
if (!list.contains(target.profile().getName())) return;
|
||||
if (!list.contains(target.profile.getName())) return;
|
||||
|
||||
broadcast(
|
||||
Component.translatable(
|
||||
"Trusted player %s is now offline",
|
||||
Component.text(target.profile().getName()).color(ColorUtilities.getColorByString(bot.config().colorPalette().username()))
|
||||
).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor()))
|
||||
Component.text(target.profile.getName()).color(ColorUtilities.getColorByString(bot.config.colorPalette.username))
|
||||
).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.SecretPacket;
|
||||
import land.chipmunk.chayapak.chomens_bot.voiceChat.packets.*;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.net.*;
|
||||
import java.util.ArrayList;
|
||||
|
@ -33,7 +32,7 @@ public class VoiceChatPlugin extends Bot.Listener {
|
|||
|
||||
private boolean running = false;
|
||||
|
||||
@Getter private final List<ClientGroup> groups = new ArrayList<>();
|
||||
public final List<ClientGroup> groups = new ArrayList<>();
|
||||
|
||||
public VoiceChatPlugin(Bot bot) {
|
||||
this.bot = bot;
|
||||
|
@ -49,17 +48,17 @@ public class VoiceChatPlugin extends Bot.Listener {
|
|||
|
||||
public void packetReceived(ClientboundLoginPacket ignored) {
|
||||
// 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",
|
||||
"\u0006fabric".getBytes() // should i use fabric here?
|
||||
));
|
||||
|
||||
bot.session().send(new ServerboundCustomPayloadPacket(
|
||||
bot.session.send(new ServerboundCustomPayloadPacket(
|
||||
"voicechat:request_secret",
|
||||
new FriendlyByteBuf(Unpooled.buffer()).writeInt(17).array()
|
||||
));
|
||||
|
||||
bot.session().send(new ServerboundCustomPayloadPacket(
|
||||
bot.session.send(new ServerboundCustomPayloadPacket(
|
||||
"voicechat:update_state",
|
||||
new FriendlyByteBuf(Unpooled.buffer()).writeBoolean(false).array()
|
||||
));
|
||||
|
@ -74,11 +73,11 @@ public class VoiceChatPlugin extends Bot.Listener {
|
|||
|
||||
final SecretPacket secretPacket = new SecretPacket().fromBytes(buf);
|
||||
|
||||
initializationData = new InitializationData(bot.session().getHost(), secretPacket);
|
||||
initializationData = new InitializationData(bot.session.getHost(), secretPacket);
|
||||
|
||||
try {
|
||||
final InetAddress address = InetAddress.getByName(bot.session().getHost());
|
||||
socketAddress = new InetSocketAddress(address, initializationData.serverPort());
|
||||
final InetAddress address = InetAddress.getByName(bot.session.getHost());
|
||||
socketAddress = new InetSocketAddress(address, initializationData.serverPort);
|
||||
} catch (UnknownHostException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -91,7 +90,7 @@ public class VoiceChatPlugin extends Bot.Listener {
|
|||
}
|
||||
|
||||
new Thread(() -> {
|
||||
sendToServer(new NetworkMessage(new AuthenticatePacket(initializationData.playerUUID(), initializationData.secret())));
|
||||
sendToServer(new NetworkMessage(new AuthenticatePacket(initializationData.playerUUID, initializationData.secret)));
|
||||
|
||||
while (running) {
|
||||
try {
|
||||
|
@ -99,9 +98,9 @@ public class VoiceChatPlugin extends Bot.Listener {
|
|||
|
||||
if (message == null) continue;
|
||||
|
||||
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 AuthenticateAckPacket) sendToServer(new NetworkMessage(new ConnectionCheckPacket()));
|
||||
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 AuthenticateAckPacket) sendToServer(new NetworkMessage(new ConnectionCheckPacket()));
|
||||
} catch (Exception e) {
|
||||
if (running) e.printStackTrace();
|
||||
else break; // is this neccessary?
|
||||
|
@ -132,7 +131,7 @@ public class VoiceChatPlugin extends Bot.Listener {
|
|||
|
||||
new JoinGroupPacket(clientGroup.id(), password).toBytes(buf);
|
||||
|
||||
bot.session().send(new ServerboundCustomPayloadPacket(
|
||||
bot.session.send(new ServerboundCustomPayloadPacket(
|
||||
"voicechat:set_group",
|
||||
buf.array()
|
||||
));
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package land.chipmunk.chayapak.chomens_bot.song;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
// Author: hhhzzzsss
|
||||
@AllArgsConstructor
|
||||
public class Instrument {
|
||||
public static final Instrument HARP = new Instrument(0, "harp", 54);
|
||||
public static final Instrument BASEDRUM = new Instrument(1, "basedrum", 0);
|
||||
|
@ -34,6 +31,13 @@ public class Instrument {
|
|||
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) {
|
||||
return new Instrument(-1, null, 0, sound);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package land.chipmunk.chayapak.chomens_bot.song;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
// Author: hhhzzzsss
|
||||
@AllArgsConstructor
|
||||
public class Note implements Comparable<Note> {
|
||||
public Instrument instrument;
|
||||
public int pitch;
|
||||
|
@ -12,6 +9,22 @@ public class Note implements Comparable<Note> {
|
|||
public int panning;
|
||||
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
|
||||
public int compareTo(Note other) {
|
||||
return Long.compare(time, other.time);
|
||||
|
|
|
@ -86,16 +86,16 @@ public class Song {
|
|||
}
|
||||
|
||||
public void advanceTime () {
|
||||
time = (long) ((System.currentTimeMillis() - startTime) * bot.music().speed());
|
||||
time = (long) ((System.currentTimeMillis() - startTime) * bot.music.speed);
|
||||
}
|
||||
|
||||
public boolean reachedNextNote () {
|
||||
if (position < notes.size()) {
|
||||
return notes.get(position).time <= time * bot.music().speed();
|
||||
return notes.get(position).time <= time * bot.music.speed;
|
||||
} else {
|
||||
if (finished() && bot.music().loop() != Loop.OFF) {
|
||||
if (finished() && bot.music.loop != Loop.OFF) {
|
||||
if (position < notes.size()) {
|
||||
return notes.get(position).time <= time * bot.music().speed();
|
||||
return notes.get(position).time <= time * bot.music.speed;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ public class Song {
|
|||
|
||||
public Note getNextNote () {
|
||||
if (position >= notes.size()) {
|
||||
if (bot.music().loop() == Loop.OFF) return null;
|
||||
if (bot.music.loop == Loop.OFF) return null;
|
||||
}
|
||||
return notes.get(position++);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
package land.chipmunk.chayapak.chomens_bot.song;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
// Author: _ChipMC_ or hhhzzzsss?
|
||||
public class SongLoaderException extends Exception {
|
||||
@Getter private final Component message;
|
||||
public final Component message;
|
||||
|
||||
public SongLoaderException (Component message) {
|
||||
super();
|
||||
|
|
|
@ -80,19 +80,19 @@ public class SongLoaderRunnable implements Runnable {
|
|||
|
||||
failed();
|
||||
} else {
|
||||
bot.music().songQueue().add(song);
|
||||
bot.chat().tellraw(
|
||||
bot.music.songQueue.add(song);
|
||||
bot.chat.tellraw(
|
||||
Component.translatable(
|
||||
"Added %s to the song queue",
|
||||
Component.empty().append(song.name).color(ColorUtilities.getColorByString(bot.config().colorPalette().secondary()))
|
||||
).color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor()))
|
||||
Component.empty().append(song.name).color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary))
|
||||
).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private void failed() {
|
||||
exception.printStackTrace();
|
||||
bot.chat().tellraw(Component.translatable("Failed to load song: %s", exception.message()).color(NamedTextColor.RED));
|
||||
bot.music().loaderThread(null);
|
||||
bot.chat.tellraw(Component.translatable("Failed to load song: %s", exception.message).color(NamedTextColor.RED));
|
||||
bot.music.loaderThread = null;
|
||||
}
|
||||
}
|
|
@ -3,7 +3,6 @@ package land.chipmunk.chayapak.chomens_bot.util;
|
|||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import lombok.AllArgsConstructor;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.TranslatableComponent;
|
||||
|
@ -63,11 +62,10 @@ public class ComponentUtilities {
|
|||
ansiMap.put("r", "\u001b[0m");
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
private static class PartiallyStringifiedOutput {
|
||||
public String output;
|
||||
public String lastColor;
|
||||
}
|
||||
private static record PartiallyStringifiedOutput (
|
||||
String output,
|
||||
String lastColor
|
||||
) {}
|
||||
|
||||
private ComponentUtilities () {
|
||||
}
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
package land.chipmunk.chayapak.chomens_bot.util;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
// totally didn't ask chatgpt for this lmao
|
||||
public class MazeGenerator {
|
||||
@Getter private final int width;
|
||||
@Getter private final int height;
|
||||
@Getter private final int[][] maze;
|
||||
public final int width;
|
||||
public final int height;
|
||||
public final int[][] maze;
|
||||
private final Random rand;
|
||||
|
||||
public MazeGenerator(int width, int height) {
|
||||
|
|
|
@ -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.voiceChat.customPayload.SecretPacket;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class InitializationData {
|
||||
@Getter private final String serverIP;
|
||||
@Getter private final int serverPort;
|
||||
@Getter private final UUID playerUUID;
|
||||
@Getter private final UUID secret;
|
||||
@Getter private final Codec codec;
|
||||
@Getter private final int mtuSize;
|
||||
@Getter private final double voiceChatDistance;
|
||||
@Getter private final int keepAlive;
|
||||
@Getter private final boolean groupsEnabled;
|
||||
@Getter private final boolean allowRecording;
|
||||
public final String serverIP;
|
||||
public final int serverPort;
|
||||
public final UUID playerUUID;
|
||||
public final UUID secret;
|
||||
public final Codec codec;
|
||||
public final int mtuSize;
|
||||
public final double voiceChatDistance;
|
||||
public final int keepAlive;
|
||||
public final boolean groupsEnabled;
|
||||
public final boolean allowRecording;
|
||||
|
||||
public InitializationData(String serverIP, SecretPacket secretPacket) {
|
||||
this.serverIP = serverIP;
|
||||
this.serverPort = secretPacket.serverPort();
|
||||
this.playerUUID = secretPacket.playerUUID();
|
||||
this.secret = secretPacket.secret();
|
||||
this.codec = secretPacket.codec();
|
||||
this.mtuSize = secretPacket.mtuSize();
|
||||
this.voiceChatDistance = secretPacket.voiceChatDistance();
|
||||
this.keepAlive = secretPacket.keepAlive();
|
||||
this.groupsEnabled = secretPacket.groupsEnabled();
|
||||
this.allowRecording = secretPacket.allowRecording();
|
||||
this.serverPort = secretPacket.serverPort;
|
||||
this.playerUUID = secretPacket.playerUUID;
|
||||
this.secret = secretPacket.secret;
|
||||
this.codec = secretPacket.codec;
|
||||
this.mtuSize = secretPacket.mtuSize;
|
||||
this.voiceChatDistance = secretPacket.voiceChatDistance;
|
||||
this.keepAlive = secretPacket.keepAlive;
|
||||
this.groupsEnabled = secretPacket.groupsEnabled;
|
||||
this.allowRecording = secretPacket.allowRecording;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.FriendlyByteBuf;
|
||||
import land.chipmunk.chayapak.chomens_bot.voiceChat.packets.*;
|
||||
import lombok.Getter;
|
||||
|
||||
import javax.crypto.BadPaddingException;
|
||||
import javax.crypto.IllegalBlockSizeException;
|
||||
|
@ -22,9 +21,9 @@ import java.util.UUID;
|
|||
public class NetworkMessage {
|
||||
public static final byte MAGIC_BYTE = (byte) 0b11111111;
|
||||
|
||||
@Getter private final long timestamp;
|
||||
@Getter private Packet<? extends Packet<?>> packet;
|
||||
@Getter private SocketAddress address;
|
||||
public final long timestamp;
|
||||
public Packet<? extends Packet<?>> packet;
|
||||
public SocketAddress address;
|
||||
|
||||
public NetworkMessage(Packet<?> packet) {
|
||||
this(System.currentTimeMillis());
|
||||
|
@ -59,7 +58,7 @@ public class NetworkMessage {
|
|||
|
||||
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 {
|
||||
|
@ -94,10 +93,10 @@ public class NetworkMessage {
|
|||
}
|
||||
|
||||
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));
|
||||
buffer.writeByte(MAGIC_BYTE);
|
||||
buffer.writeUUID(data.playerUUID());
|
||||
buffer.writeUUID(data.playerUUID);
|
||||
buffer.writeByteArray(payload);
|
||||
|
||||
byte[] bytes = new byte[buffer.readableBytes()];
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue