diff --git a/.idea/discord.xml b/.idea/discord.xml
new file mode 100644
index 0000000..d8e9561
--- /dev/null
+++ b/.idea/discord.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
index 709f317..564e5e3 100644
--- a/.idea/jarRepositories.xml
+++ b/.idea/jarRepositories.xml
@@ -11,6 +11,11 @@
+
+
+
+
+
diff --git a/.idea/misc.xml b/.idea/misc.xml
index ad2ba02..42b8b28 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -8,5 +8,5 @@
-
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..c2a5c43
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/chipmunkbot.iml b/chipmunkbot.iml
new file mode 100644
index 0000000..c462275
--- /dev/null
+++ b/chipmunkbot.iml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+ ADVENTURE
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/land/chipmunk/chipmunkbot/ChipmunkBot.java b/src/main/java/land/chipmunk/chipmunkbot/ChipmunkBot.java
index 33d4f15..87d118d 100644
--- a/src/main/java/land/chipmunk/chipmunkbot/ChipmunkBot.java
+++ b/src/main/java/land/chipmunk/chipmunkbot/ChipmunkBot.java
@@ -1,18 +1,13 @@
package land.chipmunk.chipmunkbot;
import com.github.steveice10.mc.protocol.MinecraftProtocol;
-import com.github.steveice10.packetlib.ProxyInfo;
-import com.github.steveice10.packetlib.Session;
-import com.github.steveice10.packetlib.tcp.TcpClientSession;
-import com.github.steveice10.packetlib.event.session.SessionListener;
-import java.util.Map;
-import java.util.HashMap;
-import java.lang.reflect.Constructor;
import lombok.Getter;
import land.chipmunk.chipmunkbot.plugins.*;
import java.util.List;
public class ChipmunkBot extends Client {
+ @Getter private final Configuration config;
+
@Getter private final TickLoop tickLoop;
@Getter private final ChatPlugin chat;
@Getter private final TabCompletePlugin tabComplete;
@@ -25,9 +20,11 @@ public class ChipmunkBot extends Client {
@Getter private final SelfCarePlugin selfCare;
@Getter private final SongPlayer songPlayer;
- public ChipmunkBot (Options options, List allClients) {
+ public ChipmunkBot (Configuration config, Configuration.Bot options, List allClients) {
super(options.host, options.port, new MinecraftProtocol(options.username), null, options.reconnectDelay, allClients);
+ this.config = config;
+
this.tickLoop = new TickLoop(this);
this.chat = new ChatPlugin(this);
this.tabComplete = new TabCompletePlugin(this);
diff --git a/src/main/java/land/chipmunk/chipmunkbot/Configuration.java b/src/main/java/land/chipmunk/chipmunkbot/Configuration.java
new file mode 100644
index 0000000..52f37ed
--- /dev/null
+++ b/src/main/java/land/chipmunk/chipmunkbot/Configuration.java
@@ -0,0 +1,34 @@
+package land.chipmunk.chipmunkbot;
+
+import lombok.Getter;
+
+public class Configuration {
+ @Getter public Color color = new Color();
+
+ public Bot[] bots = new Bot[]{};
+
+ public static class Color {
+ @Getter public String primary = "#ffc0cb";
+ @Getter public String secondary = "#c95367";
+ }
+
+ public static class Bot {
+ public String host = "0.0.0.0";
+ public int port = 25565;
+ public String username = "Player";
+ // public ProxyInfo proxy;
+ public long reconnectDelay = 1000;
+
+ public Commands commands = new Commands();
+
+ public Core core = new Core();
+
+ public static class Commands {
+ public String prefix = "default.";
+ }
+
+ public static class Core {
+ public boolean enabled = true;
+ }
+ }
+}
diff --git a/src/main/java/land/chipmunk/chipmunkbot/Main.java b/src/main/java/land/chipmunk/chipmunkbot/Main.java
index ff529c0..aa237a0 100644
--- a/src/main/java/land/chipmunk/chipmunkbot/Main.java
+++ b/src/main/java/land/chipmunk/chipmunkbot/Main.java
@@ -1,11 +1,5 @@
package land.chipmunk.chipmunkbot;
-import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
-import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundChatPacket;
-import com.github.steveice10.packetlib.Session;
-import com.github.steveice10.packetlib.event.session.SessionAdapter;
-import com.github.steveice10.packetlib.packet.Packet;
-
import java.io.InputStream;
import java.io.FileInputStream;
import java.io.InputStreamReader;
@@ -65,13 +59,9 @@ public class Main {
List allClients = new ArrayList<>();
- for (Options options : config.bots) {
- final Client client = new ChipmunkBot(options, allClients);
+ for (Configuration.Bot options : config.bots) {
+ final Client client = new ChipmunkBot(config, options, allClients);
allClients.add(client);
}
}
-
- private static class Configuration {
- public Options[] bots;
- }
}
diff --git a/src/main/java/land/chipmunk/chipmunkbot/Options.java b/src/main/java/land/chipmunk/chipmunkbot/Options.java
deleted file mode 100644
index e356482..0000000
--- a/src/main/java/land/chipmunk/chipmunkbot/Options.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package land.chipmunk.chipmunkbot;
-
-public class Options {
- public String host = "0.0.0.0";
- public int port = 25565;
- public String username = "Player";
- // public ProxyInfo proxy;
- public long reconnectDelay = 1000;
-
- public Commands commands = new Commands();
-
- public Core core = new Core();
-
- public class Commands {
- public String prefix = "default.";
- }
-
- public class Core {
- public boolean enabled = true;
- }
-}
diff --git a/src/main/java/land/chipmunk/chipmunkbot/command/ConsoleCommandSource.java b/src/main/java/land/chipmunk/chipmunkbot/command/ConsoleCommandSource.java
index c3cbec4..3550167 100644
--- a/src/main/java/land/chipmunk/chipmunkbot/command/ConsoleCommandSource.java
+++ b/src/main/java/land/chipmunk/chipmunkbot/command/ConsoleCommandSource.java
@@ -3,6 +3,7 @@ package land.chipmunk.chipmunkbot.command;
import land.chipmunk.chipmunkbot.ChipmunkBot;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
+import net.kyori.adventure.text.format.TextColor;
import net.kyori.adventure.text.format.TextDecoration;
public class ConsoleCommandSource extends CommandSource {
diff --git a/src/main/java/land/chipmunk/chipmunkbot/command/PlayerCommandSource.java b/src/main/java/land/chipmunk/chipmunkbot/command/PlayerCommandSource.java
index e5b2dbc..9600632 100644
--- a/src/main/java/land/chipmunk/chipmunkbot/command/PlayerCommandSource.java
+++ b/src/main/java/land/chipmunk/chipmunkbot/command/PlayerCommandSource.java
@@ -6,6 +6,7 @@ import land.chipmunk.chipmunkbot.ChipmunkBot;
import com.github.steveice10.mc.auth.data.GameProfile;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
+import net.kyori.adventure.text.format.TextColor;
import net.kyori.adventure.text.format.TextDecoration;
import net.kyori.adventure.text.format.Style;
import net.kyori.adventure.text.event.ClickEvent;
diff --git a/src/main/java/land/chipmunk/chipmunkbot/commands/HelpCommand.java b/src/main/java/land/chipmunk/chipmunkbot/commands/HelpCommand.java
index f175645..8e6cc9c 100644
--- a/src/main/java/land/chipmunk/chipmunkbot/commands/HelpCommand.java
+++ b/src/main/java/land/chipmunk/chipmunkbot/commands/HelpCommand.java
@@ -1,6 +1,7 @@
package land.chipmunk.chipmunkbot.commands;
-import land.chipmunk.chipmunkbot.ChipmunkBot;
+import land.chipmunk.chipmunkbot.ChipmunkBot;
+import land.chipmunk.chipmunkbot.Configuration;
import land.chipmunk.chipmunkbot.command.*;
import static land.chipmunk.chipmunkbot.plugins.CommandManager.literal;
import static land.chipmunk.chipmunkbot.plugins.CommandManager.argument;
@@ -13,6 +14,9 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.HoverEvent;
import net.kyori.adventure.text.JoinConfiguration;
+import net.kyori.adventure.text.format.NamedTextColor;
+import net.kyori.adventure.text.format.TextColor;
+
import java.util.List;
import java.util.ArrayList;
@@ -36,7 +40,7 @@ public class HelpCommand {
final CommandDispatcher dispatcher = client.commandManager().dispatcher();
- source.sendOutput(generateCommandList(dispatcher), false);
+ source.sendOutput(generateCommandList(client, dispatcher), false);
return 1;
}
@@ -50,7 +54,7 @@ public class HelpCommand {
final CommandDispatcher dispatcher = client.commandManager().dispatcher();
for (CommandNode node : dispatcher.getRoot().getChildren()) {
if (!node.getName().equals(commandName)) continue;
- source.sendOutput(generateUsages(dispatcher, node), false);
+ source.sendOutput(generateUsages(client.config(), dispatcher, node), false);
return 1;
}
@@ -58,27 +62,45 @@ public class HelpCommand {
throw CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherUnknownCommand().create();
}
- public Component generateCommandList (CommandDispatcher dispatcher) {
+ public Component generateCommandList (ChipmunkBot client, CommandDispatcher dispatcher) {
final List list = new ArrayList<>();
for (CommandNode node : dispatcher.getRoot().getChildren()) {
final String name = node.getName();
- final Component usages = generateUsages(dispatcher, node);
+ final Component usages = generateUsages(client.config(), dispatcher, node);
final HoverEvent hoverEvent = HoverEvent.showText(usages);
- list.add(Component.text(name).hoverEvent(hoverEvent));
+ list.add(
+ Component
+ .text(name)
+ .color(TextColor.fromHexString(client.config().color().primary()))
+ .hoverEvent(hoverEvent)
+ );
}
- return Component.translatable("Commands - %s", Component.join(JoinConfiguration.separator(Component.space()), list));
+ return Component.translatable(
+ "%s - %s",
+ Component.text("Commands").color(NamedTextColor.GRAY),
+ Component.join(JoinConfiguration.separator(Component.space()), list)
+ ).color(NamedTextColor.DARK_GRAY);
}
- public Component generateUsages (CommandDispatcher dispatcher, CommandNode node) {
+ public Component generateUsages (Configuration config, CommandDispatcher dispatcher, CommandNode node) {
final List usages = new ArrayList<>();
for (String usage : dispatcher.getAllUsage(node, null, true)) {
- final String text = (node.getName() + " " + usage).trim();
- usages.add(Component.text(text));
+ usages.add(
+ Component
+ .text(node.getName())
+ .color(TextColor.fromHexString("#c95367"))
+ .append(Component.space())
+ .append(
+ Component
+ .text(usage)
+ .color(TextColor.fromHexString(config.color().primary()))
+ )
+ );
}
return Component.join(JoinConfiguration.separator(Component.newline()), usages);
diff --git a/src/main/java/land/chipmunk/chipmunkbot/commands/InfoCommand.java b/src/main/java/land/chipmunk/chipmunkbot/commands/InfoCommand.java
index 778fc6c..64f91fa 100644
--- a/src/main/java/land/chipmunk/chipmunkbot/commands/InfoCommand.java
+++ b/src/main/java/land/chipmunk/chipmunkbot/commands/InfoCommand.java
@@ -1,24 +1,26 @@
package land.chipmunk.chipmunkbot.commands;
+import land.chipmunk.chipmunkbot.ChipmunkBot;
import land.chipmunk.chipmunkbot.util.CPUInfo;
import land.chipmunk.chipmunkbot.command.*;
import static land.chipmunk.chipmunkbot.plugins.CommandManager.literal;
-import static land.chipmunk.chipmunkbot.plugins.CommandManager.argument;
-import static com.mojang.brigadier.arguments.StringArgumentType.greedyString;
-import static com.mojang.brigadier.arguments.StringArgumentType.getString;
+
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
+import net.kyori.adventure.text.format.TextColor;
import net.kyori.adventure.text.event.ClickEvent;
-import java.util.List;
-import java.util.ArrayList;
+
import java.net.InetAddress;
import java.lang.management.*;
import java.io.IOException;
public class InfoCommand {
- private static final String REPOSITORY_URL = "https://code.chipmunk.land/ChipmunkMC/chipmunkbot";
+ private static final String ORIGINAL_REPOSITORY_URL = "https://code.chipmunk.land/ChipmunkMC/chipmunkbot";
+ private static final String FORK_URL = "https://code.chipmunk.land/ChomeNS/chipmunkbot";
+
+ private static ChipmunkBot client;
public static void register (CommandDispatcher dispatcher) {
final InfoCommand instance = new InfoCommand();
@@ -35,17 +37,21 @@ public class InfoCommand {
public int sendBotInfo (CommandContext context) {
final CommandSource source = context.getSource();
+ client = source.client();
final Component component = Component.empty()
- .append(Component.text("ChipmunkBot", NamedTextColor.GREEN))
+ .append(Component.text("Chipmunk(Sex)Bot", TextColor.fromHexString(client.config().color().primary())))
.append(Component.text(" - A utility bot for free-operator servers with minimal or no restrictions", NamedTextColor.GRAY))
.append(Component.newline())
.append(Component.text("Made by ", NamedTextColor.GRAY))
- .append(Component.text("_ChipMC_", NamedTextColor.DARK_GREEN))
+ .append(Component.text("_ChipMC_", TextColor.fromHexString("#c95367")))
.append(Component.text(" and contributors", NamedTextColor.GRAY))
.append(Component.newline())
- .append(Component.text("Repository: ", NamedTextColor.GRAY))
- .append(Component.text(REPOSITORY_URL, NamedTextColor.GREEN).clickEvent(ClickEvent.openUrl(REPOSITORY_URL)));
+ .append(Component.text("Original Repository: ", NamedTextColor.GRAY))
+ .append(Component.text(ORIGINAL_REPOSITORY_URL, TextColor.fromHexString(client.config().color().primary())).clickEvent(ClickEvent.openUrl(ORIGINAL_REPOSITORY_URL)))
+ .append(Component.newline())
+ .append(Component.text("chayapak's fork: ", NamedTextColor.GRAY))
+ .append(Component.text(FORK_URL, TextColor.fromHexString(client.config().color().primary())).clickEvent(ClickEvent.openUrl(FORK_URL)));
source.sendOutput(component, false);
@@ -55,6 +61,8 @@ public class InfoCommand {
public int sendServerInfo (CommandContext context) {
final CommandSource source = context.getSource();
+ client = source.client();
+
final Runtime runtime = Runtime.getRuntime();
final OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean();
final RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
@@ -98,8 +106,8 @@ public class InfoCommand {
public Component formatEntry (Component key, Component value) {
return Component.translatable(
"%s: %s",
- key.color(NamedTextColor.GREEN),
- value.color(NamedTextColor.DARK_GREEN)
+ key.color(TextColor.fromHexString(client.config().color().primary())),
+ value.color(TextColor.fromHexString("#c95367"))
);
}
diff --git a/src/main/java/land/chipmunk/chipmunkbot/commands/LogQueryCommand.java b/src/main/java/land/chipmunk/chipmunkbot/commands/LogQueryCommand.java
index 36042a4..ecf96dd 100644
--- a/src/main/java/land/chipmunk/chipmunkbot/commands/LogQueryCommand.java
+++ b/src/main/java/land/chipmunk/chipmunkbot/commands/LogQueryCommand.java
@@ -1,29 +1,32 @@
package land.chipmunk.chipmunkbot.commands;
-import land.chipmunk.chipmunkbot.util.Logging;
-import land.chipmunk.chipmunkbot.command.*;
-import static land.chipmunk.chipmunkbot.plugins.CommandManager.literal;
-import static land.chipmunk.chipmunkbot.plugins.CommandManager.argument;
-import static com.mojang.brigadier.arguments.StringArgumentType.greedyString;
-import static com.mojang.brigadier.arguments.StringArgumentType.getString;
import com.mojang.brigadier.Command;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
-import net.kyori.adventure.text.Component;
-import net.kyori.adventure.text.format.NamedTextColor;
+import land.chipmunk.chipmunkbot.ChipmunkBot;
+import land.chipmunk.chipmunkbot.command.CommandSource;
+import land.chipmunk.chipmunkbot.command.ComponentMessage;
+import land.chipmunk.chipmunkbot.util.Logging;
import lombok.AllArgsConstructor;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.format.TextColor;
+
import java.io.File;
-import java.io.InputStream;
import java.io.FileInputStream;
-import java.io.IOException;
+import java.io.InputStream;
import java.nio.charset.StandardCharsets;
-import java.util.Scanner;
import java.util.Arrays;
+import java.util.Scanner;
import java.util.function.Predicate;
import java.util.zip.GZIPInputStream;
+import static com.mojang.brigadier.arguments.StringArgumentType.getString;
+import static com.mojang.brigadier.arguments.StringArgumentType.greedyString;
+import static land.chipmunk.chipmunkbot.plugins.CommandManager.argument;
+import static land.chipmunk.chipmunkbot.plugins.CommandManager.literal;
+
public class LogQueryCommand {
private LogQueryThread thread;
@@ -86,20 +89,24 @@ public class LogQueryCommand {
final CommandSource source = context.getSource();
+ final ChipmunkBot client = source.client();
+
final String text = getString(context, "text");
thread = new CountThread(line -> line.contains(text), Logging.LOGS_DIR, source);
thread.start();
- source.sendOutput(Component.translatable("Searching for instances of %s in the logs", Component.text(text, NamedTextColor.GREEN)));
+ source.sendOutput(Component.translatable("Searching for instances of %s in the logs", Component.text(text, TextColor.fromHexString(client.config().color().primary()))));
return Command.SINGLE_SUCCESS;
}
public int progressCommand (CommandContext context) {
+ final ChipmunkBot client = context.getSource().client();
+
final Component progress = Component.translatable(
"Currently reading %s (%s/%s)",
- Component.text(thread.currentFilename, NamedTextColor.GREEN),
+ Component.text(thread.currentFilename, TextColor.fromHexString(client.config().color().primary())),
Component.text(thread.currentIndex + 1),
Component.text(thread.totalFiles)
);
@@ -185,8 +192,9 @@ public class LogQueryCommand {
}
public void onFinish () {
+ final ChipmunkBot client = source.client();
double seconds = (double) (System.currentTimeMillis() - startTime) / 1000d;
- source.sendOutput(Component.translatable("Found %s instances of the specified query in %s seconds", Component.text(instances, NamedTextColor.GREEN), Component.text(seconds, NamedTextColor.GREEN)));
+ source.sendOutput(Component.translatable("Found %s instances of the specified query in %s seconds", Component.text(instances, TextColor.fromHexString(client.config().color().primary())), Component.text(seconds, TextColor.fromHexString(client.config().color().primary()))));
}
}
}
diff --git a/src/main/java/land/chipmunk/chipmunkbot/commands/MusicCommand.java b/src/main/java/land/chipmunk/chipmunkbot/commands/MusicCommand.java
index 67b1121..90b0cbf 100644
--- a/src/main/java/land/chipmunk/chipmunkbot/commands/MusicCommand.java
+++ b/src/main/java/land/chipmunk/chipmunkbot/commands/MusicCommand.java
@@ -1,34 +1,32 @@
package land.chipmunk.chipmunkbot.commands;
-import land.chipmunk.chipmunkbot.ChipmunkBot;
-import land.chipmunk.chipmunkbot.song.Song;
-import land.chipmunk.chipmunkbot.plugins.SongPlayer;
-import land.chipmunk.chipmunkbot.command.*;
-import static land.chipmunk.chipmunkbot.plugins.CommandManager.literal;
-import static land.chipmunk.chipmunkbot.plugins.CommandManager.argument;
-import static com.mojang.brigadier.arguments.StringArgumentType.greedyString;
-import static com.mojang.brigadier.arguments.StringArgumentType.getString;
-import static com.mojang.brigadier.arguments.IntegerArgumentType.integer;
-import static com.mojang.brigadier.arguments.IntegerArgumentType.getInteger;
-import static land.chipmunk.chipmunkbot.command.arguments.LocationArgumentType.location;
-import static land.chipmunk.chipmunkbot.command.arguments.LocationArgumentType.filepath;
-import static land.chipmunk.chipmunkbot.command.arguments.LocationArgumentType.getPath;
-import static land.chipmunk.chipmunkbot.command.arguments.LocationArgumentType.getUrl;
-import static land.chipmunk.chipmunkbot.command.arguments.TimestampArgumentType.timestamp;
-import static com.mojang.brigadier.arguments.LongArgumentType.getLong;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
+import land.chipmunk.chipmunkbot.ChipmunkBot;
+import land.chipmunk.chipmunkbot.command.CommandSource;
+import land.chipmunk.chipmunkbot.command.ComponentMessage;
+import land.chipmunk.chipmunkbot.plugins.SongPlayer;
+import land.chipmunk.chipmunkbot.song.Song;
import net.kyori.adventure.text.Component;
-import net.kyori.adventure.text.format.NamedTextColor;
+import net.kyori.adventure.text.JoinConfiguration;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.event.HoverEvent;
-import net.kyori.adventure.text.JoinConfiguration;
+import net.kyori.adventure.text.format.TextColor;
+
import java.io.File;
import java.nio.file.Path;
-import java.util.List;
import java.util.ArrayList;
+import java.util.List;
+
+import static com.mojang.brigadier.arguments.IntegerArgumentType.getInteger;
+import static com.mojang.brigadier.arguments.IntegerArgumentType.integer;
+import static com.mojang.brigadier.arguments.LongArgumentType.getLong;
+import static land.chipmunk.chipmunkbot.command.arguments.LocationArgumentType.*;
+import static land.chipmunk.chipmunkbot.command.arguments.TimestampArgumentType.timestamp;
+import static land.chipmunk.chipmunkbot.plugins.CommandManager.argument;
+import static land.chipmunk.chipmunkbot.plugins.CommandManager.literal;
public class MusicCommand {
private static SimpleCommandExceptionType NO_SONG_IS_CURRENTLY_PLAYING = new SimpleCommandExceptionType(ComponentMessage.wrap(Component.translatable("No song is currently playing")));
@@ -95,25 +93,27 @@ public class MusicCommand {
public int stop (CommandContext context) throws CommandSyntaxException {
final CommandSource source = context.getSource();
- final SongPlayer songPlayer = source.client().songPlayer();
+ final ChipmunkBot client = source.client();
+ final SongPlayer songPlayer = client.songPlayer();
if (songPlayer.currentSong() == null) throw NO_SONG_IS_CURRENTLY_PLAYING.create();
songPlayer.stopPlaying();
songPlayer.songQueue().clear();
- source.sendOutput(Component.translatable("Stopped music playback", NamedTextColor.GREEN));
+ source.sendOutput(Component.translatable("Stopped music playback", TextColor.fromHexString(client.config().color().primary())));
return 1;
}
public int skip (CommandContext context) throws CommandSyntaxException {
final CommandSource source = context.getSource();
- final SongPlayer songPlayer = source.client().songPlayer();
+ final ChipmunkBot client = source.client();
+ final SongPlayer songPlayer = client.songPlayer();
if (songPlayer.currentSong() == null) throw NO_SONG_IS_CURRENTLY_PLAYING.create();
songPlayer.stopPlaying();
- source.sendOutput(Component.translatable("Skipped the current song", NamedTextColor.GREEN));
+ source.sendOutput(Component.translatable("Skipped the current song", TextColor.fromHexString(client.config().color().primary())));
return 1;
}
@@ -158,7 +158,7 @@ public class MusicCommand {
final File file = new File(directory, filename);
if (!file.isDirectory()) continue;
- final NamedTextColor color = (i++ & 1) == 0 ? NamedTextColor.DARK_GREEN : NamedTextColor.GREEN;
+ final TextColor color = (i++ & 1) == 0 ? TextColor.fromHexString("#c95367") : TextColor.fromHexString(client.config().color().primary());
final Path relativeFilepath = Path.of(relativePath, filename);
final String escapedPath = escapePath(relativeFilepath.toString());
@@ -174,7 +174,7 @@ public class MusicCommand {
final File file = new File(directory, filename);
if (file.isDirectory()) continue;
- final NamedTextColor color = (i++ & 1) == 0 ? NamedTextColor.DARK_GREEN : NamedTextColor.GREEN;
+ final TextColor color = (i++ & 1) == 0 ? TextColor.fromHexString("#c95367") : TextColor.fromHexString(client.config().color().primary());
final Path relativeFilepath = Path.of(relativePath, filename);
final String escapedPath = escapePath(relativeFilepath.toString());
@@ -189,7 +189,7 @@ public class MusicCommand {
final ArrayList mergedList = new ArrayList<>();
for (Component component : directories) mergedList.add(component);
for (Component component : files) mergedList.add(component);
- final Component component = Component.translatable("Songs - %s", Component.join(JoinConfiguration.separator(Component.space()), mergedList)).color(NamedTextColor.GREEN);
+ final Component component = Component.translatable("Songs - %s", Component.join(JoinConfiguration.separator(Component.space()), mergedList)).color(TextColor.fromHexString(client.config().color().primary()));
source.sendOutput(component, false);
return 1;
diff --git a/src/main/java/land/chipmunk/chipmunkbot/commands/NetMsgCommand.java b/src/main/java/land/chipmunk/chipmunkbot/commands/NetMsgCommand.java
index 19914b7..594432a 100644
--- a/src/main/java/land/chipmunk/chipmunkbot/commands/NetMsgCommand.java
+++ b/src/main/java/land/chipmunk/chipmunkbot/commands/NetMsgCommand.java
@@ -14,6 +14,7 @@ import com.github.steveice10.mc.protocol.MinecraftProtocol;
import com.github.steveice10.mc.protocol.data.ProtocolState;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
+import net.kyori.adventure.text.format.TextColor;
public class NetMsgCommand {
public static void register (CommandDispatcher dispatcher) {
@@ -36,7 +37,7 @@ public class NetMsgCommand {
final Component message = Component.translatable(
"[%s] %s \u203a %s",
Component.text(client.session().getHost() + ":" + client.session().getPort(), NamedTextColor.GRAY),
- Component.empty().color(NamedTextColor.DARK_GREEN).append(source.displayName()),
+ Component.empty().color(TextColor.fromHexString("#c95367")).append(source.displayName()),
Component.text(input, NamedTextColor.GRAY)
).color(NamedTextColor.DARK_GRAY);
diff --git a/src/main/java/land/chipmunk/chipmunkbot/commands/SayCommand.java b/src/main/java/land/chipmunk/chipmunkbot/commands/SayCommand.java
new file mode 100644
index 0000000..034e05d
--- /dev/null
+++ b/src/main/java/land/chipmunk/chipmunkbot/commands/SayCommand.java
@@ -0,0 +1,37 @@
+package land.chipmunk.chipmunkbot.commands;
+
+import com.mojang.brigadier.CommandDispatcher;
+import com.mojang.brigadier.context.CommandContext;
+import land.chipmunk.chipmunkbot.ChipmunkBot;
+import land.chipmunk.chipmunkbot.command.CommandSource;
+
+import static com.mojang.brigadier.arguments.StringArgumentType.getString;
+import static com.mojang.brigadier.arguments.StringArgumentType.greedyString;
+import static land.chipmunk.chipmunkbot.plugins.CommandManager.argument;
+import static land.chipmunk.chipmunkbot.plugins.CommandManager.literal;
+
+public class SayCommand {
+ public static void register (CommandDispatcher dispatcher) {
+ final SayCommand instance = new SayCommand();
+
+ dispatcher.register(
+ literal("say")
+ .then(
+ argument("message", greedyString())
+ .executes(instance::say)
+ )
+ );
+ }
+
+ public int say (CommandContext context) {
+ final CommandSource source = context.getSource();
+ final String message = getString(context, "message");
+
+ final ChipmunkBot client = source.client();
+
+ if (message.startsWith("/")) client.chat().command(message.substring(1));
+ else client.chat().message(message);
+
+ return 1;
+ }
+}
diff --git a/src/main/java/land/chipmunk/chipmunkbot/plugins/ChatCommandHandler.java b/src/main/java/land/chipmunk/chipmunkbot/plugins/ChatCommandHandler.java
index f2057c6..68f1e16 100644
--- a/src/main/java/land/chipmunk/chipmunkbot/plugins/ChatCommandHandler.java
+++ b/src/main/java/land/chipmunk/chipmunkbot/plugins/ChatCommandHandler.java
@@ -1,19 +1,14 @@
package land.chipmunk.chipmunkbot.plugins;
import land.chipmunk.chipmunkbot.ChipmunkBot;
-import land.chipmunk.chipmunkbot.Options;
-import land.chipmunk.chipmunkbot.command.CommandSource;
+import land.chipmunk.chipmunkbot.Configuration;
import land.chipmunk.chipmunkbot.command.PlayerCommandSource;
-import land.chipmunk.chipmunkbot.command.ComponentMessage;
-import land.chipmunk.chipmunkbot.plugins.ChatPlugin;
import land.chipmunk.chipmunkbot.data.chat.PlayerMessage;
import land.chipmunk.chipmunkbot.util.ComponentUtilities;
-import land.chipmunk.chipmunkbot.plugins.CommandManager;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
-import com.mojang.brigadier.Message;
import lombok.Getter;
import lombok.Setter;
@@ -21,7 +16,7 @@ public class ChatCommandHandler extends ChatPlugin.Listener {
private ChipmunkBot client;
@Getter @Setter private String prefix;
- public ChatCommandHandler (ChipmunkBot client, Options options) {
+ public ChatCommandHandler (ChipmunkBot client, Configuration.Bot options) {
this.client = client;
this.prefix = options.commands.prefix;
client.chat().addListener((ChatPlugin.Listener) this);
diff --git a/src/main/java/land/chipmunk/chipmunkbot/plugins/ChatPlugin.java b/src/main/java/land/chipmunk/chipmunkbot/plugins/ChatPlugin.java
index 3b73dc2..72bcb93 100644
--- a/src/main/java/land/chipmunk/chipmunkbot/plugins/ChatPlugin.java
+++ b/src/main/java/land/chipmunk/chipmunkbot/plugins/ChatPlugin.java
@@ -47,6 +47,7 @@ public class ChatPlugin extends SessionAdapter {
systemChatParsers = new ArrayList<>();
systemChatParsers.add(new MinecraftChatParser(client));
systemChatParsers.add(new KaboomChatParser(client));
+ systemChatParsers.add(new ChomeNSCustomChatParser(client));
}
public void message (String message) {
diff --git a/src/main/java/land/chipmunk/chipmunkbot/plugins/CommandCore.java b/src/main/java/land/chipmunk/chipmunkbot/plugins/CommandCore.java
index 49c1397..080e2e0 100644
--- a/src/main/java/land/chipmunk/chipmunkbot/plugins/CommandCore.java
+++ b/src/main/java/land/chipmunk/chipmunkbot/plugins/CommandCore.java
@@ -1,8 +1,7 @@
package land.chipmunk.chipmunkbot.plugins;
import land.chipmunk.chipmunkbot.ChipmunkBot;
-import land.chipmunk.chipmunkbot.Options;
-import land.chipmunk.chipmunkbot.plugins.PositionManager;
+import land.chipmunk.chipmunkbot.Configuration;
import land.chipmunk.chipmunkbot.data.BlockArea;
import org.cloudburstmc.math.vector.Vector3i;
import com.github.steveice10.packetlib.packet.Packet;
@@ -15,7 +14,6 @@ import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.Server
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.inventory.ServerboundSetCreativeModeSlotPacket;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundPlayerActionPacket;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.inventory.ServerboundSetCommandBlockPacket;
-import com.github.steveice10.mc.protocol.packet.ingame.serverbound.level.ServerboundBlockEntityTagQuery;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import com.github.steveice10.mc.protocol.data.game.entity.object.Direction;
@@ -24,7 +22,6 @@ import com.github.steveice10.mc.protocol.data.game.level.block.CommandBlockMode;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.github.steveice10.opennbt.tag.builtin.ByteTag;
-import com.google.gson.JsonObject;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@@ -45,7 +42,7 @@ public class CommandCore extends SessionAdapter {
@Getter private List listeners = new ArrayList<>();
- public CommandCore (ChipmunkBot client, Options options) {
+ public CommandCore (ChipmunkBot client, Configuration.Bot options) {
this.client = client;
this.enabled = options.core.enabled;
client.addListener((SessionListener) this);
diff --git a/src/main/java/land/chipmunk/chipmunkbot/plugins/CommandManager.java b/src/main/java/land/chipmunk/chipmunkbot/plugins/CommandManager.java
index b9b8352..3000ef8 100644
--- a/src/main/java/land/chipmunk/chipmunkbot/plugins/CommandManager.java
+++ b/src/main/java/land/chipmunk/chipmunkbot/plugins/CommandManager.java
@@ -7,6 +7,7 @@ import land.chipmunk.chipmunkbot.command.BuiltInExceptions;
import land.chipmunk.chipmunkbot.commands.*;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
+import net.kyori.adventure.text.format.TextColor;
import net.kyori.adventure.text.format.TextDecoration;
import net.kyori.adventure.text.event.ClickEvent;
import com.mojang.brigadier.CommandDispatcher;
@@ -40,6 +41,7 @@ public class CommandManager {
NetMsgCommand.register(dispatcher);
MusicCommand.register(dispatcher);
LogQueryCommand.register(dispatcher);
+ SayCommand.register(dispatcher);
}
public static void sendException (CommandSource source, CommandSyntaxException exception) {
diff --git a/src/main/java/land/chipmunk/chipmunkbot/plugins/SongPlayer.java b/src/main/java/land/chipmunk/chipmunkbot/plugins/SongPlayer.java
index 3d0dcaf..505c01c 100644
--- a/src/main/java/land/chipmunk/chipmunkbot/plugins/SongPlayer.java
+++ b/src/main/java/land/chipmunk/chipmunkbot/plugins/SongPlayer.java
@@ -9,6 +9,7 @@ import com.github.steveice10.packetlib.event.session.SessionAdapter;
import com.github.steveice10.packetlib.event.session.DisconnectedEvent;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
+import net.kyori.adventure.text.format.TextColor;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import lombok.Getter;
import lombok.Setter;
@@ -54,7 +55,7 @@ public class SongPlayer extends SessionAdapter {
try {
final SongLoaderThread _loaderThread = new SongLoaderThread(location);
- client.chat().tellraw(Component.translatable("Loading %s", Component.text(location.getFileName().toString(), NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN));
+ client.chat().tellraw(Component.translatable("Loading %s", Component.text(location.getFileName().toString(), TextColor.fromHexString("#c95367"))).color(TextColor.fromHexString(client.config().color().primary())));
_loaderThread.start();
loaderThread = _loaderThread;
} catch (SongLoaderException e) {
@@ -71,7 +72,7 @@ public class SongPlayer extends SessionAdapter {
try {
final SongLoaderThread _loaderThread = new SongLoaderThread(location);
- client.chat().tellraw(Component.translatable("Loading %s", Component.text(location.toString(), NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN));
+ client.chat().tellraw(Component.translatable("Loading %s", Component.text(location.toString(), TextColor.fromHexString("#c95367"))).color(TextColor.fromHexString(client.config().color().primary())));
_loaderThread.start();
loaderThread = _loaderThread;
} catch (SongLoaderException e) {
@@ -92,7 +93,7 @@ public class SongPlayer extends SessionAdapter {
client.chat().tellraw(Component.translatable("Failed to load song: %s", loaderThread.exception.message()).color(NamedTextColor.RED));
} else {
songQueue.add(loaderThread.song);
- client.chat().tellraw(Component.translatable("Added %s to the song queue", Component.empty().append(loaderThread.song.name).color(NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN));
+ client.chat().tellraw(Component.translatable("Added %s to the song queue", Component.empty().append(loaderThread.song.name).color(TextColor.fromHexString("#c95367"))).color(TextColor.fromHexString(client.config().color().primary())));
}
loaderThread = null;
}
@@ -101,7 +102,7 @@ public class SongPlayer extends SessionAdapter {
if (songQueue.size() == 0) return;
currentSong = songQueue.poll();
- client.chat().tellraw(Component.translatable("Now playing %s", Component.empty().append(currentSong.name).color(NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN));
+ client.chat().tellraw(Component.translatable("Now playing %s", Component.empty().append(currentSong.name).color(TextColor.fromHexString("#c95367"))).color(TextColor.fromHexString(client.config().color().primary())));
currentSong.play();
}
@@ -115,35 +116,35 @@ public class SongPlayer extends SessionAdapter {
handlePlaying();
if (currentSong.finished()) {
- client.chat().tellraw(Component.translatable("Finished playing %s", Component.empty().append(currentSong.name).color(NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN));
+ client.chat().tellraw(Component.translatable("Finished playing %s", Component.empty().append(currentSong.name).color(TextColor.fromHexString("#c95367"))).color(TextColor.fromHexString(client.config().color().primary())));
currentSong = null;
}
}
public Component generateActionbar () {
Component component = Component.empty()
- .append(Component.translatable("Now playing %s", Component.empty().append(currentSong.name).color(NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN))
+ .append(Component.translatable("Now playing %s", Component.empty().append(currentSong.name).color(TextColor.fromHexString("#c95367"))).color(TextColor.fromHexString(client.config().color().primary())))
.append(Component.translatable(" | ", NamedTextColor.DARK_GRAY))
- .append(Component.translatable("%s / %s", formatTime(currentSong.time).color(NamedTextColor.GREEN), formatTime(currentSong.length).color(NamedTextColor.GREEN)).color(NamedTextColor.GRAY))
+ .append(Component.translatable("%s / %s", formatTime(currentSong.time).color(TextColor.fromHexString(client.config().color().primary())), formatTime(currentSong.length).color(TextColor.fromHexString(client.config().color().primary()))).color(NamedTextColor.GRAY))
.append(Component.translatable(" | ", NamedTextColor.DARK_GRAY))
- .append(Component.translatable("%s / %s", Component.text(currentSong.position, NamedTextColor.GREEN), Component.text(currentSong.size(), NamedTextColor.GREEN)).color(NamedTextColor.GRAY));
+ .append(Component.translatable("%s / %s", Component.text(currentSong.position, TextColor.fromHexString(client.config().color().primary())), Component.text(currentSong.size(), TextColor.fromHexString(client.config().color().primary()))).color(NamedTextColor.GRAY));
if (currentSong.paused) {
return component
.append(Component.translatable(" | ", NamedTextColor.DARK_GRAY))
- .append(Component.translatable("Paused", NamedTextColor.DARK_GREEN));
+ .append(Component.translatable("Paused", TextColor.fromHexString("#c95367")));
}
if (currentSong.looping) {
if (currentSong.loopCount > 0) {
return component
.append(Component.translatable(" | ", NamedTextColor.DARK_GRAY))
- .append(Component.translatable("Looping (%s/%s)", Component.text(currentSong.currentLoop), Component.text(currentSong.loopCount)).color(NamedTextColor.DARK_GREEN));
+ .append(Component.translatable("Looping (%s/%s)", Component.text(currentSong.currentLoop), Component.text(currentSong.loopCount)).color(TextColor.fromHexString("#c95367")));
}
return component
.append(Component.translatable(" | ", NamedTextColor.DARK_GRAY))
- .append(Component.translatable("Looping", NamedTextColor.DARK_GREEN));
+ .append(Component.translatable("Looping", TextColor.fromHexString("#c95367")));
}
return component;
diff --git a/src/main/java/land/chipmunk/chipmunkbot/systemChat/ChomeNSCustomChatParser.java b/src/main/java/land/chipmunk/chipmunkbot/systemChat/ChomeNSCustomChatParser.java
new file mode 100644
index 0000000..21ca493
--- /dev/null
+++ b/src/main/java/land/chipmunk/chipmunkbot/systemChat/ChomeNSCustomChatParser.java
@@ -0,0 +1,42 @@
+package land.chipmunk.chipmunkbot.systemChat;
+
+import land.chipmunk.chipmunkbot.ChipmunkBot;
+import land.chipmunk.chipmunkbot.data.MutablePlayerListEntry;
+import land.chipmunk.chipmunkbot.data.chat.PlayerMessage;
+import land.chipmunk.chipmunkbot.data.chat.SystemChatParser;
+import land.chipmunk.chipmunkbot.util.ComponentUtilities;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.TranslatableComponent;
+
+import java.util.List;
+
+// ported from chomens sex bot
+public class ChomeNSCustomChatParser implements SystemChatParser {
+ private final ChipmunkBot client;
+
+ public ChomeNSCustomChatParser (ChipmunkBot client) {
+ this.client = client;
+ }
+
+ @Override
+ public PlayerMessage parse (Component message) {
+ if (message instanceof TranslatableComponent) return parse((TranslatableComponent) message);
+ return null;
+ }
+
+ // very similar to MinecraftChatParser
+ public PlayerMessage parse (TranslatableComponent message) {
+ final List args = message.args();
+ if (args.size() < 3 || (!message.key().equals("[%s] %s › %s") && !message.key().equals("%s %s › %s"))) return null;
+
+ final Component username = args.get(1);
+ final Component contents = args.get(2);
+
+ final String stringUsername = ComponentUtilities.stringify(username);
+ MutablePlayerListEntry sender = client.playerList().getEntry(stringUsername);
+
+ if (sender == null) return null;
+
+ return new PlayerMessage(sender, contents, "minecraft:chat", username);
+ }
+}
diff --git a/src/main/resources/default_config.json b/src/main/resources/default_config.json
index a2a850f..adad017 100644
--- a/src/main/resources/default_config.json
+++ b/src/main/resources/default_config.json
@@ -1,4 +1,8 @@
{
+ "color": {
+ "primary": "#ffc0cb",
+ "secondary": "#c9536"
+ },
"bots": [
{
"host": "localhost",