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/README.md b/README.md
index 70e04eb..a8ef3b1 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,2 @@
-# chipmunkbot
-A work-in-progress mcprotocollib utility bot, created for free-op servers with minimal restrictions
+# Chipmunk Sex Bot
+Sexy version of [ChipmunkBot](https://code.chipmunk.land/ChipmunkMC/chipmunkbot)!!!!!!
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/pom.xml b/pom.xml
index a267703..02c3bff 100644
--- a/pom.xml
+++ b/pom.xml
@@ -14,8 +14,8 @@
- opencollab
- https://repo.opencollab.dev/maven-snapshots/
+ opencollab
+ https://repo.opencollab.dev/maven-snapshots/
@@ -48,7 +48,7 @@
com.mojang
brigadier
- 1.0.18
+ 1.1.0-SNAPSHOT
diff --git a/src/main/java/land/chipmunk/chipmunkbot/ChipmunkBot.java b/src/main/java/land/chipmunk/chipmunkbot/ChipmunkBot.java
index 6e4bdf4..9568d61 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;
@@ -26,9 +21,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);
@@ -39,7 +36,7 @@ public class ChipmunkBot extends Client {
this.playerCommandHandler = new PlayerCommandHandler(this, options);
this.position = new PositionManager(this);
this.core = new CommandCore(this, options);
- this.selfCare = new SelfCarePlugin(this);
+ this.selfCare = new SelfCarePlugin(this, options);
this.songPlayer = new SongPlayer(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..a2a8122
--- /dev/null
+++ b/src/main/java/land/chipmunk/chipmunkbot/Configuration.java
@@ -0,0 +1,47 @@
+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 SelfCares selfCares = new SelfCares();
+
+ public static class SelfCares {
+ public boolean cspy = true;
+ public PrefixSelfCare prefix = new PrefixSelfCare();
+
+ public static class PrefixSelfCare {
+ public boolean enabled = true;
+ public String prefix = "&x&c&9&5&3&6&7[&x&f&f&c&0&c&bPrefix: s'&x&c&9&5&3&6&7]";
+ }
+ }
+
+ public static class Commands {
+ public String prefix = "default.";
+ public String cspyPrefix = "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 bca2ffc..0000000
--- a/src/main/java/land/chipmunk/chipmunkbot/Options.java
+++ /dev/null
@@ -1,22 +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 String cspyPrefix = "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/EchoCommand.java b/src/main/java/land/chipmunk/chipmunkbot/commands/EchoCommand.java
index c3043a2..28173b6 100644
--- a/src/main/java/land/chipmunk/chipmunkbot/commands/EchoCommand.java
+++ b/src/main/java/land/chipmunk/chipmunkbot/commands/EchoCommand.java
@@ -16,6 +16,7 @@ public class EchoCommand {
dispatcher.register(
literal("echo")
+ .describe(ComponentMessage.wrap(Component.text("Echoes a message")))
.then(
argument("text", greedyString())
.executes(instance::echo)
diff --git a/src/main/java/land/chipmunk/chipmunkbot/commands/HelpCommand.java b/src/main/java/land/chipmunk/chipmunkbot/commands/HelpCommand.java
index f175645..2d01e61 100644
--- a/src/main/java/land/chipmunk/chipmunkbot/commands/HelpCommand.java
+++ b/src/main/java/land/chipmunk/chipmunkbot/commands/HelpCommand.java
@@ -1,6 +1,8 @@
package land.chipmunk.chipmunkbot.commands;
-import land.chipmunk.chipmunkbot.ChipmunkBot;
+import com.mojang.brigadier.Message;
+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 +15,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;
@@ -22,11 +27,12 @@ public class HelpCommand {
dispatcher.register(
literal("help")
- .executes(instance::sendCommandList)
- .then(
- argument("command", greedyString())
- .executes(instance::sendUsage)
- )
+ .describe(ComponentMessage.wrap(Component.text("Shows the help")))
+ .executes(instance::sendCommandList)
+ .then(
+ argument("command", greedyString())
+ .executes(instance::sendUsage)
+ )
);
}
@@ -36,7 +42,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 +56,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,29 +64,60 @@ 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 components = new ArrayList<>();
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(config.color().secondary()))
+ .append(Component.space())
+ .append(
+ Component
+ .text(usage)
+ .color(TextColor.fromHexString(config.color().primary()))
+ )
+ );
}
- return Component.join(JoinConfiguration.separator(Component.newline()), usages);
+ final Message description = node.getDescription();
+
+ components.add(
+ Component.translatable(
+ "%s - %s",
+ Component.text(node.getName()).color(TextColor.fromHexString(config.color().primary())),
+ Component.text(description == null ? "No description" : description.getString()).color(NamedTextColor.GRAY)
+ ).color(NamedTextColor.DARK_GRAY)
+ );
+
+ components.add(Component.join(JoinConfiguration.separator(Component.newline()), usages));
+
+ return Component.join(JoinConfiguration.separator(Component.newline()), components);
}
}
diff --git a/src/main/java/land/chipmunk/chipmunkbot/commands/InfoCommand.java b/src/main/java/land/chipmunk/chipmunkbot/commands/InfoCommand.java
index 778fc6c..388a290 100644
--- a/src/main/java/land/chipmunk/chipmunkbot/commands/InfoCommand.java
+++ b/src/main/java/land/chipmunk/chipmunkbot/commands/InfoCommand.java
@@ -1,30 +1,34 @@
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.event.HoverEvent;
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();
dispatcher.register(
literal("info")
+ .describe(ComponentMessage.wrap(Component.text("Shows the info about the bot")))
.executes(instance::sendBotInfo)
.then(
literal("server")
@@ -35,17 +39,35 @@ 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(client.config().color().secondary())))
+ .append(Component.text(", ", TextColor.fromHexString(client.config().color().primary())))
+ .append(Component.text("chayapak", TextColor.fromHexString(client.config().color().secondary())))
+ .append(Component.text(" (").color(NamedTextColor.DARK_GRAY))
+ .append(
+ Component
+ .text("<3")
+ .color(NamedTextColor.RED)
+ .hoverEvent(
+ HoverEvent.showText(
+ Component.text("y e s :)")
+ )
+ )
+ )
+ .append(Component.text(")").color(NamedTextColor.DARK_GRAY))
.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("My 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 +77,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 +122,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(client.config().color().secondary()))
);
}
diff --git a/src/main/java/land/chipmunk/chipmunkbot/commands/LogQueryCommand.java b/src/main/java/land/chipmunk/chipmunkbot/commands/LogQueryCommand.java
index 36042a4..2ac3b95 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;
@@ -35,6 +38,7 @@ public class LogQueryCommand {
dispatcher.register(
literal("logquery")
+ .describe(ComponentMessage.wrap(Component.text("Queries the bots log files")))
.then(
literal("abort")
.executes(instance::abortCommand)
@@ -86,20 +90,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 +193,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 92dbe54..a5d5be5 100644
--- a/src/main/java/land/chipmunk/chipmunkbot/commands/MusicCommand.java
+++ b/src/main/java/land/chipmunk/chipmunkbot/commands/MusicCommand.java
@@ -1,34 +1,34 @@
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.FloatArgumentType.getFloat;
+import static com.mojang.brigadier.arguments.IntegerArgumentType.getInteger;
+import static com.mojang.brigadier.arguments.IntegerArgumentType.integer;
+import static com.mojang.brigadier.arguments.FloatArgumentType.floatArg;
+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")));
@@ -42,6 +42,7 @@ public class MusicCommand {
dispatcher.register(
literal("music")
+ .describe(ComponentMessage.wrap(Component.text("Play musics")))
.then(
literal("play")
.then(
@@ -79,6 +80,14 @@ public class MusicCommand {
.executes(instance::gotoCommand)
)
)
+
+ .then(
+ literal("pitch")
+ .then(
+ argument("pitch", floatArg())
+ .executes(instance::pitch)
+ )
+ )
);
}
@@ -95,25 +104,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 +169,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(client.config().color().secondary()) : TextColor.fromHexString(client.config().color().primary());
final Path relativeFilepath = Path.of(relativePath, filename);
final String escapedPath = escapePath(relativeFilepath.toString());
@@ -174,7 +185,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(client.config().color().secondary()) : TextColor.fromHexString(client.config().color().primary());
final Path relativeFilepath = Path.of(relativePath, filename);
final String escapedPath = escapePath(relativeFilepath.toString());
@@ -189,7 +200,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;
@@ -255,4 +266,22 @@ public class MusicCommand {
return 1;
}
+
+ public int pitch (CommandContext context) {
+ final CommandSource source = context.getSource();
+ final SongPlayer songPlayer = source.client().songPlayer();
+
+ final float pitch = getFloat(context, "pitch");
+
+ songPlayer.pitch(pitch);
+
+ source.sendOutput(
+ Component.translatable(
+ "Set the pitch to: %s",
+ Component.text(String.valueOf(pitch))
+ ).color(TextColor.fromHexString(source.client().config().color().primary()))
+ );
+
+ 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..c7b5a9a 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) {
@@ -21,10 +22,11 @@ public class NetMsgCommand {
dispatcher.register(
literal("netmsg")
- .then(
- argument("message", greedyString())
- .executes(instance::netmsg)
- )
+ .describe(ComponentMessage.wrap(Component.text("Broadcasts a message to every server")))
+ .then(
+ argument("message", greedyString())
+ .executes(instance::netmsg)
+ )
);
}
@@ -36,7 +38,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(client.config().color().secondary())).append(source.displayName()),
Component.text(input, NamedTextColor.GRAY)
).color(NamedTextColor.DARK_GRAY);
diff --git a/src/main/java/land/chipmunk/chipmunkbot/commands/ReconnectCommand.java b/src/main/java/land/chipmunk/chipmunkbot/commands/ReconnectCommand.java
index 68f058c..e5bf34a 100644
--- a/src/main/java/land/chipmunk/chipmunkbot/commands/ReconnectCommand.java
+++ b/src/main/java/land/chipmunk/chipmunkbot/commands/ReconnectCommand.java
@@ -13,7 +13,8 @@ public class ReconnectCommand {
dispatcher.register(
literal("reconnect")
- .executes(instance::reconnect)
+ .describe(ComponentMessage.wrap(Component.text("Reconnects the bot")))
+ .executes(instance::reconnect)
);
}
diff --git a/src/main/java/land/chipmunk/chipmunkbot/commands/RunCommand.java b/src/main/java/land/chipmunk/chipmunkbot/commands/RunCommand.java
index e613582..1708737 100644
--- a/src/main/java/land/chipmunk/chipmunkbot/commands/RunCommand.java
+++ b/src/main/java/land/chipmunk/chipmunkbot/commands/RunCommand.java
@@ -20,10 +20,11 @@ public class RunCommand {
dispatcher.register(
literal("run")
- .then(
- argument("command", greedyString())
- .executes(instance::run)
- )
+ .describe(ComponentMessage.wrap(Component.text("Runs a command in the command core and return its output")))
+ .then(
+ argument("command", greedyString())
+ .executes(instance::run)
+ )
);
}
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..c6fee57
--- /dev/null
+++ b/src/main/java/land/chipmunk/chipmunkbot/commands/SayCommand.java
@@ -0,0 +1,40 @@
+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 land.chipmunk.chipmunkbot.command.ComponentMessage;
+import net.kyori.adventure.text.Component;
+
+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")
+ .describe(ComponentMessage.wrap(Component.text("Makes the bot say a message")))
+ .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/commands/TestCommand.java b/src/main/java/land/chipmunk/chipmunkbot/commands/TestCommand.java
index f1619d9..6a41a2c 100644
--- a/src/main/java/land/chipmunk/chipmunkbot/commands/TestCommand.java
+++ b/src/main/java/land/chipmunk/chipmunkbot/commands/TestCommand.java
@@ -12,7 +12,8 @@ public class TestCommand {
dispatcher.register(
literal("test")
- .executes(instance::helloWorld)
+ .describe(ComponentMessage.wrap(Component.text("Tests if the bot is online/working")))
+ .executes(instance::helloWorld)
);
}
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 f82a7fe..c3b6b11 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..7ed3b96 100644
--- a/src/main/java/land/chipmunk/chipmunkbot/plugins/CommandManager.java
+++ b/src/main/java/land/chipmunk/chipmunkbot/plugins/CommandManager.java
@@ -1,12 +1,15 @@
package land.chipmunk.chipmunkbot.plugins;
+import com.mojang.brigadier.builder.ArgumentBuilder;
import land.chipmunk.chipmunkbot.ChipmunkBot;
import land.chipmunk.chipmunkbot.command.CommandSource;
import land.chipmunk.chipmunkbot.command.ComponentMessage;
import land.chipmunk.chipmunkbot.command.BuiltInExceptions;
import land.chipmunk.chipmunkbot.commands.*;
+import lombok.RequiredArgsConstructor;
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 +43,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/PlayerCommandHandler.java b/src/main/java/land/chipmunk/chipmunkbot/plugins/PlayerCommandHandler.java
index 0370f3b..8aae201 100644
--- a/src/main/java/land/chipmunk/chipmunkbot/plugins/PlayerCommandHandler.java
+++ b/src/main/java/land/chipmunk/chipmunkbot/plugins/PlayerCommandHandler.java
@@ -1,7 +1,7 @@
package land.chipmunk.chipmunkbot.plugins;
import land.chipmunk.chipmunkbot.ChipmunkBot;
-import land.chipmunk.chipmunkbot.Options;
+import land.chipmunk.chipmunkbot.Configuration;
import land.chipmunk.chipmunkbot.command.CommandSource;
import land.chipmunk.chipmunkbot.command.PlayerCommandSource;
import land.chipmunk.chipmunkbot.command.ComponentMessage;
@@ -23,7 +23,7 @@ public class PlayerCommandHandler {
@Getter @Setter private String prefix;
@Getter @Setter private String cspyPrefix;
- public PlayerCommandHandler (ChipmunkBot client, Options options) {
+ public PlayerCommandHandler (ChipmunkBot client, Configuration.Bot options) {
this.client = client;
this.prefix = options.commands.prefix;
this.cspyPrefix = options.commands.cspyPrefix != null ? options.commands.cspyPrefix : this.prefix;
diff --git a/src/main/java/land/chipmunk/chipmunkbot/plugins/SelfCarePlugin.java b/src/main/java/land/chipmunk/chipmunkbot/plugins/SelfCarePlugin.java
index 11785bf..acfe376 100644
--- a/src/main/java/land/chipmunk/chipmunkbot/plugins/SelfCarePlugin.java
+++ b/src/main/java/land/chipmunk/chipmunkbot/plugins/SelfCarePlugin.java
@@ -18,23 +18,45 @@ import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLo
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundGameEventPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundEntityEventPacket;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundClientCommandPacket;
+import land.chipmunk.chipmunkbot.Configuration;
+import land.chipmunk.chipmunkbot.util.ComponentUtilities;
import lombok.Getter;
import lombok.Setter;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.TextComponent;
+
import java.util.Timer;
import java.util.TimerTask;
public class SelfCarePlugin extends SessionAdapter {
private final ChipmunkBot client;
+ private final Configuration.Bot options;
@Getter @Setter private GameMode gamemode;
@Getter @Setter private int permissionLevel;
+
+ private boolean prefix = false;
+
private Timer timer;
private int entityId; // TODO: Move entity id handling somewhere else
- public SelfCarePlugin (ChipmunkBot client) {
+ public SelfCarePlugin (ChipmunkBot client, Configuration.Bot options) {
this.client = client;
+ this.options = options;
client.addListener((SessionListener) this);
+ client.chat().addListener(new ChatPlugin.Listener() {
+ @Override
+ public void systemMessageReceived(Component component, boolean overlay) {
+ // mabe parse using components? too lazy
+ final String stringifiedMessage = ComponentUtilities.stringify(component);
+
+ if (stringifiedMessage.equals("You now have the tag: " + options.selfCares.prefix.prefix)) prefix = true;
+ else if (stringifiedMessage.equals("You no longer have a tag")) prefix = false;
+ else if (stringifiedMessage.startsWith("You now have the tag: ")) prefix = false;
+ }
+ });
+
final TimerTask task = new TimerTask() {
@Override
public void run () {
@@ -48,19 +70,19 @@ public class SelfCarePlugin extends SessionAdapter {
};
timer = new Timer();
- timer.schedule(task, 75, 75);
+ timer.schedule(task, 125, 125);
}
public void tick () {
if (permissionLevel < 2) client.chat().command("minecraft:op @s[type=player]");
else if (gamemode != GameMode.CREATIVE) client.chat().command("minecraft:gamemode creative");
- else if (!client.commandSpy().enabled()) client.chat().command("c on");
+ else if (!client.commandSpy().enabled() && options.selfCares.cspy) client.chat().command("c on");
+ else if (!prefix && options.selfCares.prefix.enabled) client.chat().command("prefix " + options.selfCares.prefix.prefix);
}
@Override
public void packetReceived (Session session, Packet packet) {
if (packet instanceof ClientboundGameEventPacket) packetReceived(session, (ClientboundGameEventPacket) packet);
- else if (packet instanceof ClientboundGameEventPacket) packetReceived(session, (ClientboundGameEventPacket) packet);
else if (packet instanceof ClientboundEntityEventPacket) packetReceived(session, (ClientboundEntityEventPacket) packet);
else if (packet instanceof ClientboundLoginPacket) packetReceived(session, (ClientboundLoginPacket) packet);
}
diff --git a/src/main/java/land/chipmunk/chipmunkbot/plugins/SongPlayer.java b/src/main/java/land/chipmunk/chipmunkbot/plugins/SongPlayer.java
index 3d0dcaf..b198307 100644
--- a/src/main/java/land/chipmunk/chipmunkbot/plugins/SongPlayer.java
+++ b/src/main/java/land/chipmunk/chipmunkbot/plugins/SongPlayer.java
@@ -7,8 +7,10 @@ import land.chipmunk.chipmunkbot.song.*;
import com.github.steveice10.packetlib.event.session.SessionListener;
import com.github.steveice10.packetlib.event.session.SessionAdapter;
import com.github.steveice10.packetlib.event.session.DisconnectedEvent;
+import land.chipmunk.chipmunkbot.util.MathUtilities;
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;
@@ -33,6 +35,8 @@ public class SongPlayer extends SessionAdapter {
@Getter @Setter private SongLoaderThread loaderThread;
private int ticksUntilPausedActionbar = 20;
+ @Getter @Setter private float pitch = 0;
+
public SongPlayer (ChipmunkBot client) {
this.client = client;
client.addListener((SessionListener) this);
@@ -54,7 +58,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(client.config().color().secondary()))).color(TextColor.fromHexString(client.config().color().primary())));
_loaderThread.start();
loaderThread = _loaderThread;
} catch (SongLoaderException e) {
@@ -71,7 +75,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(client.config().color().secondary()))).color(TextColor.fromHexString(client.config().color().primary())));
_loaderThread.start();
loaderThread = _loaderThread;
} catch (SongLoaderException e) {
@@ -92,7 +96,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(client.config().color().secondary()))).color(TextColor.fromHexString(client.config().color().primary())));
}
loaderThread = null;
}
@@ -101,7 +105,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(client.config().color().secondary()))).color(TextColor.fromHexString(client.config().color().primary())));
currentSong.play();
}
@@ -115,35 +119,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(client.config().color().secondary()))).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(client.config().color().secondary()))).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(client.config().color().secondary())));
}
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(client.config().color().secondary())));
}
return component
.append(Component.translatable(" | ", NamedTextColor.DARK_GRAY))
- .append(Component.translatable("Looping", NamedTextColor.DARK_GREEN));
+ .append(Component.translatable("Looping", TextColor.fromHexString(client.config().color().secondary())));
}
return component;
@@ -176,7 +180,7 @@ public class SongPlayer extends SessionAdapter {
while (currentSong.reachedNextNote()) {
final Note note = currentSong.getNextNote();
- final double floatingPitch = Math.pow(2, (note.pitch - 12) / 12.0);
+ final double floatingPitch = MathUtilities.clamp(0.5 * (Math.pow(2, ((note.pitch + (pitch / 10)) / 12))), 0, 2);
client.core().run("execute as " + SELECTOR + " at @s run playsound " + note.instrument.sound + " record @s ~ ~ ~ " + note.volume + " " + floatingPitch);
}
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..370d661
--- /dev/null
+++ b/src/main/java/land/chipmunk/chipmunkbot/systemChat/ChomeNSCustomChatParser.java
@@ -0,0 +1,52 @@
+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 net.kyori.adventure.text.event.HoverEvent;
+
+import java.util.List;
+import java.util.UUID;
+
+// 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 senderComponent = args.get(1);
+ final Component contents = args.get(2);
+
+ MutablePlayerListEntry sender;
+ final HoverEvent> hoverEvent = senderComponent.hoverEvent();
+ if (hoverEvent != null && hoverEvent.action().equals(HoverEvent.Action.SHOW_ENTITY)) {
+ HoverEvent.ShowEntity entityInfo = (HoverEvent.ShowEntity) hoverEvent.value();
+ final UUID senderUUID = entityInfo.id();
+ sender = client.playerList().getEntry(senderUUID);
+ } else {
+ final String stringUsername = ComponentUtilities.stringify(senderComponent);
+ sender = client.playerList().getEntry(stringUsername);
+ }
+
+ if (sender == null) return null;
+
+ return new PlayerMessage(sender, contents, "minecraft:chat", senderComponent);
+ }
+}
diff --git a/src/main/java/land/chipmunk/chipmunkbot/util/MathUtilities.java b/src/main/java/land/chipmunk/chipmunkbot/util/MathUtilities.java
new file mode 100644
index 0000000..a2eaab6
--- /dev/null
+++ b/src/main/java/land/chipmunk/chipmunkbot/util/MathUtilities.java
@@ -0,0 +1,7 @@
+package land.chipmunk.chipmunkbot.util;
+
+public class MathUtilities {
+ public static double clamp (double value, double min, double max) {
+ return Math.max(Math.min(value, max), min);
+ }
+}
diff --git a/src/main/resources/default_config.json b/src/main/resources/default_config.json
index 6051c7c..42c984a 100644
--- a/src/main/resources/default_config.json
+++ b/src/main/resources/default_config.json
@@ -1,4 +1,8 @@
{
+ "color": {
+ "primary": "#ffc0cb",
+ "secondary": "#c95367"
+ },
"bots": [
{
"host": "localhost",
@@ -11,6 +15,14 @@
"cspyPrefix": "default."
},
+ "selfCares": {
+ "cspy": true,
+ "prefix": {
+ "enabled": true,
+ "prefix": "&x&c&9&5&3&6&7[&x&f&f&c&0&c&bPrefix: s'&x&c&9&5&3&6&7]"
+ }
+ },
+
"core": {
"enabled": true
}