Compare commits

...

32 commits
main ... main

Author SHA1 Message Date
10ca2e4e06
feat: allow path outside bot dir for funnies 2024-11-03 14:05:35 +07:00
0fcc68c7a2
fix: commandspy on non-chipmunk servers 2024-11-02 15:06:43 +07:00
22c736c67d Update to 1.21.1 & some more stuff 2024-11-01 17:12:12 +07:00
8d81084f8d fi 2023-08-28 17:06:11 +07:00
11ed0c5eb1 stop it 2023-08-28 17:02:53 +07:00
88ceb46d71 fix custom sounds mabe
fixes the one with the pitch higher/lower than the 2 octave limit thing
2023-08-09 18:51:43 +07:00
d63adca59a ignore long messages/commands 2023-07-04 21:06:31 +07:00
5cef742fef rename 2023-06-22 18:38:17 +07:00
bcdbf5c2f3 Merge remote-tracking branch 'origin/main' 2023-06-22 18:26:40 +07:00
9a55cd11f4 add description to commands
yes i need to modify brigaydier to do this
2023-06-11 20:29:35 +07:00
d6f68cd2fa Merge remote-tracking branch 'original/main' 2023-06-11 08:07:38 +07:00
84853b78c4 chip munk forgor about the block id
chip mc moment #69420
2023-06-10 18:10:22 +07:00
67a6f409af Merge remote-tracking branch 'original/main' 2023-06-10 16:19:28 +07:00
ac0437ab48 Merge remote-tracking branch 'original/main' 2023-05-28 15:14:34 +07:00
26ef63b176 yes
----[-->+++++<]>-.++.--.-[---->+<]>+++.---[->++<]>.-------.
cum pie it !!!!!
2023-05-28 14:07:13 +07:00
801ce9cbd2 add prefix self care and make the self cares configurable
more spam ngl,.,.,.,. well i increased the delay a bit but its still spammy,.,.
2023-05-25 18:38:27 +07:00
372cdce2fa Merge remote-tracking branch 'origin/main' 2023-05-23 19:47:20 +07:00
7306377a3f some more stuff
also sorry for me impostering chipmunk.,.,,.,. im so sorry
2023-05-23 19:46:32 +07:00
25d983c71c among 2023-05-23 19:34:19 +07:00
ae837c897c Merge remote-tracking branch 'original/main'
# Conflicts:
#	src/main/java/land/chipmunk/chipmunkbot/Options.java
#	src/main/java/land/chipmunk/chipmunkbot/plugins/PlayerCommandHandler.java
2023-05-23 19:29:36 +07:00
4d3c05c439 chip mc moment 2023-05-21 09:23:20 +07:00
e20571f2be some random readme update 2023-05-20 20:50:45 +07:00
9f32784279 titty 2023-05-12 17:38:36 +07:00
56ddfded75 fix color mabe mabe 2023-05-12 11:48:20 +07:00
5d56589c2e actually clamp the thing 2023-05-12 11:47:00 +07:00
0ad227acae update chomens chat parser 2023-05-11 13:16:16 +07:00
eb78e8de5c actually remove no song is currently playing 2023-05-11 10:33:37 +07:00
9a0261ccad music pitch YUUUUUP 2023-05-11 09:41:31 +07:00
e45d2c1f48 mabe 2023-05-10 18:05:49 +07:00
ce3bd2ebc1 sexy readme 2023-05-10 18:02:49 +07:00
005cb0d3a4 i forgor secondary 2023-05-10 18:00:24 +07:00
18fb46c008 make it more sexy!111!!!!%!@#$!43!%
mabe
2023-05-10 17:56:42 +07:00
45 changed files with 654 additions and 317 deletions

View file

@ -2,6 +2,7 @@
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile default="true" name="Default" enabled="true" />
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />

7
.idea/discord.xml Normal file
View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DiscordProjectSettings">
<option name="show" value="PROJECT_FILES" />
<option name="description" value="" />
</component>
</project>

View file

@ -6,16 +6,46 @@
<option name="name" value="Minecraft Libraries" />
<option name="url" value="https://libraries.minecraft.net" />
</remote-repository>
<remote-repository>
<option name="id" value="CollabNet" />
<option name="name" value="CollabNet" />
<option name="url" value="https://repo.opencollab.dev/main/" />
</remote-repository>
<remote-repository>
<option name="id" value="opencollab" />
<option name="name" value="opencollab" />
<option name="url" value="https://repo.opencollab.dev/main" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="opencollab" />
<option name="name" value="opencollab" />
<option name="url" value="https://repo.opencollab.dev/main/" />
</remote-repository>
<remote-repository>
<option name="id" value="CollabNetSnapshots" />
<option name="name" value="CollabNetSnapshots" />
<option name="url" value="https://repo.opencollab.dev/maven-snapshots/" />
</remote-repository>
<remote-repository>
<option name="id" value="opencollab" />
<option name="name" value="opencollab" />
<option name="url" value="https://repo.opencollab.dev/maven-snapshots/" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="CollabNetReleases" />
<option name="name" value="CollabNetReleases" />
<option name="url" value="https://repo.opencollab.dev/maven-releases/" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />

View file

@ -8,5 +8,5 @@
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="19" project-jdk-type="JavaSDK" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_20" project-jdk-name="17" project-jdk-type="JavaSDK" />
</project>

8
.idea/modules.xml Normal file
View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/chipmunkbot.iml" filepath="$PROJECT_DIR$/chipmunkbot.iml" />
</modules>
</component>
</project>

View file

@ -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)!!!!!!

12
chipmunkbot.iml Normal file
View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="FacetManager">
<facet type="minecraft" name="Minecraft">
<configuration>
<autoDetectTypes>
<platformType>ADVENTURE</platformType>
</autoDetectTypes>
</configuration>
</facet>
</component>
</module>

24
pom.xml
View file

@ -13,23 +13,31 @@
</properties>
<repositories>
<repository>
<id>opencollab</id>
<url>https://repo.opencollab.dev/maven-snapshots/</url>
</repository>
<repository>
<id>minecraft-libraries</id>
<name>Minecraft Libraries</name>
<url>https://libraries.minecraft.net</url>
</repository>
<repository>
<id>CollabNet</id>
<url>https://repo.opencollab.dev/main/</url>
</repository>
<repository>
<id>CollabNetSnapshots</id>
<url>https://repo.opencollab.dev/maven-snapshots/</url>
</repository>
<repository>
<id>CollabNetReleases</id>
<url>https://repo.opencollab.dev/maven-releases/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.steveice10</groupId>
<artifactId>mcprotocollib</artifactId>
<version>1.20-1-SNAPSHOT</version>
<groupId>org.geysermc.mcprotocollib</groupId>
<artifactId>protocol</artifactId>
<version>1.21-SNAPSHOT</version>
</dependency>
<dependency>

View file

@ -1,18 +1,14 @@
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 org.geysermc.mcprotocollib.protocol.MinecraftProtocol;
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 +22,11 @@ public class ChipmunkBot extends Client {
@Getter private final SelfCarePlugin selfCare;
@Getter private final SongPlayer songPlayer;
public ChipmunkBot (Options options, List<Client> allClients) {
public ChipmunkBot (Configuration config, Configuration.Bot options, List<Client> 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 +37,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);
}
}

View file

@ -1,13 +1,14 @@
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.packet.Packet;
import com.github.steveice10.packetlib.event.session.*;
import com.github.steveice10.mc.auth.data.GameProfile;
import com.github.steveice10.mc.protocol.packet.login.clientbound.ClientboundGameProfilePacket;
import land.chipmunk.chipmunkbot.util.ComponentUtilities;
import org.geysermc.mcprotocollib.auth.GameProfile;
import org.geysermc.mcprotocollib.network.ProxyInfo;
import org.geysermc.mcprotocollib.protocol.MinecraftProtocol;
import org.geysermc.mcprotocollib.network.Session;
import org.geysermc.mcprotocollib.network.tcp.TcpClientSession;
import org.geysermc.mcprotocollib.network.packet.Packet;
import org.geysermc.mcprotocollib.network.event.session.*;
import org.geysermc.mcprotocollib.protocol.packet.login.clientbound.ClientboundGameProfilePacket;
import java.util.Timer;
import java.util.TimerTask;
import java.util.List;

View file

@ -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;
}
}
}

View file

@ -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<Client> 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;
}
}

View file

@ -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;
}
}

View file

@ -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 {

View file

@ -3,14 +3,16 @@ package land.chipmunk.chipmunkbot.command;
import land.chipmunk.chipmunkbot.data.MutablePlayerListEntry;
import land.chipmunk.chipmunkbot.util.UUIDUtilities;
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;
import net.kyori.adventure.text.event.HoverEvent;
import net.kyori.adventure.key.Key;
import org.geysermc.mcprotocollib.auth.GameProfile;
import java.util.UUID;
public class PlayerCommandSource extends CommandSource {

View file

@ -58,7 +58,7 @@ public class LocationArgumentType implements ArgumentType<Object> {
public Path parsePath (StringReader reader) throws CommandSyntaxException {
final String pathString = reader.readString();
final Path path = Path.of(root.toString(), pathString).toAbsolutePath().normalize();
if (!path.startsWith(root)) throw OOB_FILEPATH.create();
// if (!path.startsWith(root)) throw OOB_FILEPATH.create(); for the funnies
return path;
}

View file

@ -1,6 +1,8 @@
package land.chipmunk.chipmunkbot.commands;
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;
@ -36,7 +41,7 @@ public class HelpCommand {
final CommandDispatcher<CommandSource> dispatcher = client.commandManager().dispatcher();
source.sendOutput(generateCommandList(dispatcher), false);
source.sendOutput(generateCommandList(client, dispatcher), false);
return 1;
}
@ -50,7 +55,7 @@ public class HelpCommand {
final CommandDispatcher<CommandSource> dispatcher = client.commandManager().dispatcher();
for (CommandNode<CommandSource> 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 +63,57 @@ public class HelpCommand {
throw CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherUnknownCommand().create();
}
public Component generateCommandList (CommandDispatcher<CommandSource> dispatcher) {
public Component generateCommandList (ChipmunkBot client, CommandDispatcher<CommandSource> dispatcher) {
final List<Component> list = new ArrayList<>();
for (CommandNode<CommandSource> 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<CommandSource> node) {
public Component generateUsages (Configuration config, CommandDispatcher dispatcher, CommandNode<CommandSource> node) {
final List<Component> components = new ArrayList<>();
final List<Component> 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);
components.add(
Component.translatable(
"%s",
Component.text(node.getName()).color(TextColor.fromHexString(config.color().primary()))
).color(NamedTextColor.DARK_GRAY)
);
components.add(Component.join(JoinConfiguration.separator(Component.newline()), usages));
return Component.join(JoinConfiguration.separator(Component.newline()), components);
}
}

View file

@ -1,24 +1,27 @@
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();
@ -35,17 +38,30 @@ public class InfoCommand {
public int sendBotInfo (CommandContext<CommandSource> context) {
final CommandSource source = context.getSource();
client = source.client();
final Component component = Component.empty()
.append(Component.text("ChipmunkBot", NamedTextColor.GREEN))
.append(Component.text("ChipmunkBot", 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)
)
.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 +71,8 @@ public class InfoCommand {
public int sendServerInfo (CommandContext<CommandSource> 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 +116,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()))
);
}

View file

@ -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<CommandSource> 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()))));
}
}
}

View file

@ -1,34 +1,35 @@
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.NamedTextColor;
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")));
@ -79,11 +80,21 @@ public class MusicCommand {
.executes(instance::gotoCommand)
)
)
.then(
literal("pitch")
.then(
argument("pitch", floatArg())
.executes(instance::pitch)
)
)
);
}
public int play (CommandContext<CommandSource> context) {
final SongPlayer songPlayer = context.getSource().client().songPlayer();
final CommandSource source = context.getSource();
final SongPlayer songPlayer = source.client().songPlayer();
final Path path = getPath(context, "location");
@ -95,25 +106,27 @@ public class MusicCommand {
public int stop (CommandContext<CommandSource> 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<CommandSource> 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 +171,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 +187,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 +202,7 @@ public class MusicCommand {
final ArrayList<Component> 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 +268,22 @@ public class MusicCommand {
return 1;
}
public int pitch (CommandContext<CommandSource> 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;
}
}

View file

@ -9,11 +9,12 @@ 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 com.github.steveice10.packetlib.Session;
import com.github.steveice10.mc.protocol.MinecraftProtocol;
import com.github.steveice10.mc.protocol.data.ProtocolState;
import org.geysermc.mcprotocollib.network.Session;
import org.geysermc.mcprotocollib.protocol.MinecraftProtocol;
import org.geysermc.mcprotocollib.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(client.config().color().secondary())).append(source.displayName()),
Component.text(input, NamedTextColor.GRAY)
).color(NamedTextColor.DARK_GRAY);
@ -45,7 +46,7 @@ public class NetMsgCommand {
final Session session = remote.session();
final MinecraftProtocol protocol = (MinecraftProtocol) session.getPacketProtocol();
if (!session.isConnected() || protocol.getState() != ProtocolState.GAME) continue;
if (!session.isConnected() || protocol.getOutboundState() != ProtocolState.GAME) continue;
((ChipmunkBot) remote).chat().tellraw(message);
}

View file

@ -10,8 +10,8 @@ import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import org.cloudburstmc.nbt.NbtMap;
import java.util.concurrent.CompletableFuture;
public class RunCommand {
@ -31,11 +31,11 @@ public class RunCommand {
final CommandSource source = context.getSource();
final ChipmunkBot client = source.client();
final CompletableFuture<CompoundTag> future = client.core().runTracked(getString(context, "command"));
final CompletableFuture<NbtMap> future = client.core().runTracked(getString(context, "command"));
future.thenApply(tag -> {
if (!tag.contains("LastOutput") || !(tag.get("LastOutput") instanceof StringTag)) return tag;
final String outputJson = ((StringTag) tag.get("LastOutput")).getValue();
if (!tag.containsKey("LastOutput") || !(tag.get("LastOutput") instanceof String)) return tag;
final String outputJson = tag.getString("LastOutput");
try {
final Component output = GsonComponentSerializer.gson().deserialize(outputJson);

View file

@ -0,0 +1,39 @@
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")
.then(
argument("message", greedyString())
.executes(instance::say)
)
);
}
public int say (CommandContext<CommandSource> 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;
}
}

View file

@ -1,8 +1,8 @@
package land.chipmunk.chipmunkbot.data;
import com.github.steveice10.mc.auth.data.GameProfile;
import com.github.steveice10.mc.protocol.data.game.PlayerListEntry;
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
import org.geysermc.mcprotocollib.auth.GameProfile;
import org.geysermc.mcprotocollib.protocol.data.game.PlayerListEntry;
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.GameMode;
import net.kyori.adventure.text.Component;
import lombok.Data;
import lombok.AllArgsConstructor;

View file

@ -5,30 +5,28 @@ import land.chipmunk.chipmunkbot.data.chat.PlayerMessage;
import land.chipmunk.chipmunkbot.data.chat.SystemChatParser;
import land.chipmunk.chipmunkbot.data.MutablePlayerListEntry;
import land.chipmunk.chipmunkbot.util.UUIDUtilities;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundSystemChatPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundPlayerChatPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundDisguisedChatPacket;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundChatPacket;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundChatCommandPacket;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.inventory.ServerboundSetCreativeModeSlotPacket;
import com.github.steveice10.packetlib.packet.Packet;
import com.github.steveice10.packetlib.Session;
import com.github.steveice10.packetlib.event.session.SessionAdapter;
import com.github.steveice10.packetlib.event.session.SessionListener;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.github.steveice10.mc.protocol.MinecraftProtocol;
import org.cloudburstmc.nbt.NbtMap;
import org.cloudburstmc.nbt.NbtMapBuilder;
import org.geysermc.mcprotocollib.protocol.data.game.item.ItemStack;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponent;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponentType;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundSystemChatPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundPlayerChatPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundDisguisedChatPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.ServerboundChatPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.ServerboundChatCommandPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.inventory.ServerboundSetCreativeModeSlotPacket;
import org.geysermc.mcprotocollib.network.packet.Packet;
import org.geysermc.mcprotocollib.network.Session;
import org.geysermc.mcprotocollib.network.event.session.SessionAdapter;
import org.geysermc.mcprotocollib.network.event.session.SessionListener;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.event.HoverEvent;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import lombok.Getter;
import java.util.BitSet;
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.*;
import java.time.Instant;
import java.nio.charset.StandardCharsets;
@ -47,15 +45,20 @@ public class ChatPlugin extends SessionAdapter {
systemChatParsers = new ArrayList<>();
systemChatParsers.add(new MinecraftChatParser(client));
systemChatParsers.add(new KaboomChatParser(client));
systemChatParsers.add(new U203aChatParser(client));
}
public void message (String message) {
if (message.length() > 256) return;
final ServerboundChatPacket packet = new ServerboundChatPacket(message, Instant.now().toEpochMilli(), 0, null, 0, new BitSet());
client.session().send(packet);
}
public void command (String command) {
final ServerboundChatCommandPacket packet = new ServerboundChatCommandPacket(command, Instant.now().toEpochMilli(), 0, Collections.emptyList(), 0, new BitSet());
if (command.length() > 256) return;
final ServerboundChatCommandPacket packet = new ServerboundChatCommandPacket(command);
client.session().send(packet);
}
@ -144,12 +147,19 @@ public class ChatPlugin extends SessionAdapter {
if (tagString.getBytes(StandardCharsets.UTF_8).length > 65535) return;
CompoundTag itemTag = new CompoundTag("");
itemTag.put(new StringTag("m", tagString));
final NbtMapBuilder blockEntityTagBuilder = NbtMap.builder();
final NbtMap itemTag = blockEntityTagBuilder.putString("m", tagString).build();
final Map<DataComponentType<?>, DataComponent<?, ?>> map = new HashMap<>();
map.put(DataComponentType.BLOCK_ENTITY_DATA, DataComponentType.BLOCK_ENTITY_DATA.getDataComponentFactory().create(DataComponentType.BLOCK_ENTITY_DATA, itemTag));
final DataComponents dataComponents = new DataComponents(map);
final Session session = client.session();
session.send(new ServerboundSetCreativeModeSlotPacket(26, new ItemStack(1 /* stone */, 1, itemTag)));
session.send(new ServerboundSetCreativeModeSlotPacket((short) 26, new ItemStack(1 /* stone */, 1, dataComponents)));
client.core().run("minecraft:tellraw " + targets + " {\"nbt\":\"Inventory[0].tag.m\",\"entity\":\"" + client.profile().getIdAsString() + "\",\"interpret\":" + interpret + "}"); // TODO: Use GSON instead of concatenating strings, and hardcode less of this (it shouldn't matter here but yes)
return;

View file

@ -1,36 +1,33 @@
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;
import com.github.steveice10.packetlib.Session;
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 com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerPositionPacket;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundUseItemOnPacket;
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;
import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerAction;
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 org.cloudburstmc.nbt.NbtMap;
import org.cloudburstmc.nbt.NbtMapBuilder;
import org.geysermc.mcprotocollib.network.packet.Packet;
import org.geysermc.mcprotocollib.network.Session;
import org.geysermc.mcprotocollib.network.event.session.SessionListener;
import org.geysermc.mcprotocollib.network.event.session.SessionAdapter;
import org.geysermc.mcprotocollib.network.event.session.DisconnectedEvent;
import org.geysermc.mcprotocollib.protocol.data.game.item.ItemStack;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponent;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponentType;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerPositionPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.player.ServerboundUseItemOnPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.inventory.ServerboundSetCreativeModeSlotPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.player.ServerboundPlayerActionPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.inventory.ServerboundSetCommandBlockPacket;
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand;
import org.geysermc.mcprotocollib.protocol.data.game.entity.object.Direction;
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.PlayerAction;
import org.geysermc.mcprotocollib.protocol.data.game.level.block.CommandBlockMode;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
import java.util.ArrayList;
import java.util.Timer;
import java.util.TimerTask;
import java.util.*;
import java.util.concurrent.CompletableFuture;
public class CommandCore extends SessionAdapter {
@ -45,7 +42,7 @@ public class CommandCore extends SessionAdapter {
@Getter private List<Listener> 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);
@ -98,11 +95,19 @@ public class CommandCore extends SessionAdapter {
relEnd.getZ() + origin.getZ()
);
CompoundTag itemTag = new CompoundTag("");
CompoundTag blockEntityTag = new CompoundTag("BlockEntityTag");
blockEntityTag.put(new StringTag("Command", command));
blockEntityTag.put(new ByteTag("auto", (byte) 1));
itemTag.put(blockEntityTag);
final NbtMapBuilder blockEntityTagBuilder = NbtMap.builder();
blockEntityTagBuilder.putString("id", "minecraft:command_block");
blockEntityTagBuilder.putString("Command", command);
blockEntityTagBuilder.putByte("auto", (byte) 1);
final NbtMap blockEntityTag = blockEntityTagBuilder.build();
final Map<DataComponentType<?>, DataComponent<?, ?>> map = new HashMap<>();
map.put(DataComponentType.BLOCK_ENTITY_DATA, DataComponentType.BLOCK_ENTITY_DATA.getDataComponentFactory().create(DataComponentType.BLOCK_ENTITY_DATA, blockEntityTag));
final DataComponents dataComponents = new DataComponents(map);
final PositionManager position = client.position();
@ -111,7 +116,7 @@ public class CommandCore extends SessionAdapter {
// client.chat().command(command);
final Session session = client.session();
session.send(new ServerboundSetCreativeModeSlotPacket(45, new ItemStack(373 /* command_block */, 1, itemTag)));
session.send(new ServerboundSetCreativeModeSlotPacket((short) 45, new ItemStack(395 /* command_block */, 1, dataComponents)));
session.send(new ServerboundPlayerActionPacket(PlayerAction.START_DIGGING, temporaryBlockPosition, Direction.NORTH, 0));
session.send(new ServerboundUseItemOnPacket(temporaryBlockPosition, Direction.NORTH, Hand.OFF_HAND, 0.5f, 0.5f, 0.5f, false, 0));
}
@ -172,13 +177,13 @@ public class CommandCore extends SessionAdapter {
incrementCurrentBlock();
}
public CompletableFuture<CompoundTag> runTracked (String command) {
if (command.length() > maxCommandLength()) return emptyCompoundTagFuture();
public CompletableFuture<NbtMap> runTracked (String command) {
if (command.length() > maxCommandLength()) return emptyNbtMapFuture();
if (!enabled) {
client.chat().command(command); // fall back to chat
return emptyCompoundTagFuture();
return emptyNbtMapFuture();
}
final Session session = client.session();
@ -190,7 +195,7 @@ public class CommandCore extends SessionAdapter {
incrementCurrentBlock();
CompletableFuture<CompoundTag> future = new CompletableFuture<CompoundTag>();
CompletableFuture<NbtMap> future = new CompletableFuture<NbtMap>();
final Timer timer = new Timer();
final TimerTask queryTask = new TimerTask() {
@ -207,9 +212,9 @@ public class CommandCore extends SessionAdapter {
return future;
}
private CompletableFuture<CompoundTag> emptyCompoundTagFuture () {
CompletableFuture<CompoundTag> future = new CompletableFuture<CompoundTag>();
future.complete(new CompoundTag(""));
private CompletableFuture<NbtMap> emptyNbtMapFuture () {
CompletableFuture<NbtMap> future = new CompletableFuture<NbtMap>();
future.complete(NbtMap.EMPTY);
return future;
}

View file

@ -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) {

View file

@ -21,6 +21,16 @@ public class CommandSpyPlugin extends ChatPlugin.Listener {
private static final Component COMMANDSPY_ENABLED_COMPONENT = Component.text("Successfully enabled CommandSpy");
private static final Component COMMANDSPY_DISABLED_COMPONENT = Component.text("Successfully disabled CommandSpy");
private static final Component COMMANDSPY_ENABLED_COMPONENT_CHIPMUNK = Component
.empty()
.append(Component.text("Successfully "))
.append(Component.text("enabled"))
.append(Component.text(" CommandSpy"));
private static final Component COMMANDSPY_DISABLED_COMPONENT_CHIPMUNK = Component
.empty()
.append(Component.text("Successfully "))
.append(Component.text("disabled"))
.append(Component.text(" CommandSpy"));
private static final Component COMMAND_SEPARATOR_COMPONENT = Component.text(": ");
private static final Component SIGN_CREATED_TEXT_COMPONENT = Component.text(" created a sign with contents:");
private static final Component SIGN_LINE_SEPARATOR_COMPONENT = Component.text("\n ");
@ -34,8 +44,8 @@ public class CommandSpyPlugin extends ChatPlugin.Listener {
public void systemMessageReceived (Component component, boolean overlay) {
if (overlay || !(component instanceof final TextComponent t_component)) return;
if (component.equals(COMMANDSPY_ENABLED_COMPONENT)) { this.enabled = true; return; }
if (component.equals(COMMANDSPY_DISABLED_COMPONENT)) { this.enabled = false; return; }
if (component.equals(COMMANDSPY_ENABLED_COMPONENT) || component.equals(COMMANDSPY_ENABLED_COMPONENT_CHIPMUNK)) { this.enabled = true; return; }
if (component.equals(COMMANDSPY_DISABLED_COMPONENT) || component.equals(COMMANDSPY_DISABLED_COMPONENT_CHIPMUNK)) { this.enabled = false; return; }
final boolean enabled = component.style().equals(ENABLED_STYLE);
if (!enabled && !component.style().equals(DISABLED_STYLE)) return;

View file

@ -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;

View file

@ -1,14 +1,14 @@
package land.chipmunk.chipmunkbot.plugins;
import land.chipmunk.chipmunkbot.ChipmunkBot;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundPlayerInfoUpdatePacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundPlayerInfoRemovePacket;
import com.github.steveice10.packetlib.packet.Packet;
import com.github.steveice10.packetlib.Session;
import com.github.steveice10.packetlib.event.session.SessionAdapter;
import com.github.steveice10.packetlib.event.session.SessionListener;
import com.github.steveice10.mc.protocol.data.game.PlayerListEntry;
import com.github.steveice10.mc.protocol.data.game.PlayerListEntryAction;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundPlayerInfoUpdatePacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundPlayerInfoRemovePacket;
import org.geysermc.mcprotocollib.network.packet.Packet;
import org.geysermc.mcprotocollib.network.Session;
import org.geysermc.mcprotocollib.network.event.session.SessionAdapter;
import org.geysermc.mcprotocollib.network.event.session.SessionListener;
import org.geysermc.mcprotocollib.protocol.data.game.PlayerListEntry;
import org.geysermc.mcprotocollib.protocol.data.game.PlayerListEntryAction;
import net.kyori.adventure.text.Component;
import land.chipmunk.chipmunkbot.data.MutablePlayerListEntry;
@ -81,7 +81,7 @@ public class PlayerListPlugin extends SessionAdapter {
}
private final MutablePlayerListEntry getEntry (PlayerListEntry other) {
return getEntry(other.getProfile().getId());
return getEntry(other.getProfileId());
}
private void addPlayer (PlayerListEntry newEntry) {

View file

@ -2,12 +2,12 @@ package land.chipmunk.chipmunkbot.plugins;
import land.chipmunk.chipmunkbot.Client;
import org.cloudburstmc.math.vector.Vector3d;
import com.github.steveice10.packetlib.packet.Packet;
import com.github.steveice10.packetlib.Session;
import com.github.steveice10.packetlib.event.session.SessionListener;
import com.github.steveice10.packetlib.event.session.SessionAdapter;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerPositionPacket;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.level.ServerboundAcceptTeleportationPacket;
import org.geysermc.mcprotocollib.network.packet.Packet;
import org.geysermc.mcprotocollib.network.Session;
import org.geysermc.mcprotocollib.network.event.session.SessionListener;
import org.geysermc.mcprotocollib.network.event.session.SessionAdapter;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerPositionPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.level.ServerboundAcceptTeleportationPacket;
import org.cloudburstmc.math.vector.Vector3d;
import org.cloudburstmc.math.vector.Vector3i;
import lombok.Getter;

View file

@ -2,14 +2,14 @@ package land.chipmunk.chipmunkbot.plugins;
import land.chipmunk.chipmunkbot.Client;
import org.cloudburstmc.math.vector.Vector3i;
import com.github.steveice10.packetlib.packet.Packet;
import com.github.steveice10.packetlib.Session;
import com.github.steveice10.packetlib.event.session.SessionListener;
import com.github.steveice10.packetlib.event.session.SessionAdapter;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.level.ServerboundBlockEntityTagQuery;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.level.ServerboundEntityTagQuery;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundTagQueryPacket;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import org.cloudburstmc.nbt.NbtMap;
import org.geysermc.mcprotocollib.network.packet.Packet;
import org.geysermc.mcprotocollib.network.Session;
import org.geysermc.mcprotocollib.network.event.session.SessionListener;
import org.geysermc.mcprotocollib.network.event.session.SessionAdapter;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.level.ServerboundBlockEntityTagQueryPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.level.ServerboundEntityTagQuery;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.level.ClientboundTagQueryPacket;
import java.util.concurrent.CompletableFuture;
import java.util.Map;
import java.util.HashMap;
@ -17,29 +17,29 @@ import java.util.HashMap;
public class QueryPlugin extends SessionAdapter {
private Client client;
private int nextTransactionId = 0;
private Map<Integer, CompletableFuture<CompoundTag>> transactions = new HashMap<>();
private Map<Integer, CompletableFuture<NbtMap>> transactions = new HashMap<>();
public QueryPlugin (Client client) {
this.client = client;
client.addListener((SessionListener) this);
}
public CompletableFuture<CompoundTag> block (Vector3i position) {
public CompletableFuture<NbtMap> block (Vector3i position) {
final int transactionId = nextTransactionId++;
if (nextTransactionId > Integer.MAX_VALUE) nextTransactionId = 0; // ? Can and should I use negative numbers too?
client.session().send(new ServerboundBlockEntityTagQuery(transactionId, position));
client.session().send(new ServerboundBlockEntityTagQueryPacket(transactionId, position));
final CompletableFuture<CompoundTag> future = new CompletableFuture<CompoundTag>();
final CompletableFuture<NbtMap> future = new CompletableFuture<NbtMap>();
transactions.put(transactionId, future);
return future;
}
public CompletableFuture<CompoundTag> entity (int entityId) {
public CompletableFuture<NbtMap> entity (int entityId) {
final int transactionId = nextTransactionId++;
if (nextTransactionId > Integer.MAX_VALUE) nextTransactionId = 0; // ? Can and should I use negative numbers too?
client.session().send(new ServerboundEntityTagQuery(transactionId, entityId));
final CompletableFuture<CompoundTag> future = new CompletableFuture<CompoundTag>();
final CompletableFuture<NbtMap> future = new CompletableFuture<NbtMap>();
transactions.put(transactionId, future);
return future;
}
@ -50,7 +50,7 @@ public class QueryPlugin extends SessionAdapter {
}
public void packetReceived (Session session, ClientboundTagQueryPacket packet) {
final CompletableFuture<CompoundTag> future = transactions.get(packet.getTransactionId());
final CompletableFuture<NbtMap> future = transactions.get(packet.getTransactionId());
if (future == null) return;
future.complete(packet.getNbt());
transactions.remove(future);

View file

@ -1,46 +1,68 @@
package land.chipmunk.chipmunkbot.plugins;
import land.chipmunk.chipmunkbot.ChipmunkBot;
import com.github.steveice10.packetlib.packet.Packet;
import com.github.steveice10.packetlib.Session;
import com.github.steveice10.packetlib.packet.PacketProtocol;
import com.github.steveice10.mc.protocol.MinecraftProtocol;
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
import com.github.steveice10.mc.protocol.data.ProtocolState;
import com.github.steveice10.mc.protocol.data.game.level.notify.GameEvent;
import com.github.steveice10.mc.protocol.data.game.level.notify.GameEventValue;
import com.github.steveice10.mc.protocol.data.game.entity.EntityEvent;
import com.github.steveice10.mc.protocol.data.game.ClientCommand;
import com.github.steveice10.packetlib.event.session.SessionAdapter;
import com.github.steveice10.packetlib.event.session.SessionListener;
import com.github.steveice10.packetlib.event.session.DisconnectedEvent;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
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 org.geysermc.mcprotocollib.network.packet.Packet;
import org.geysermc.mcprotocollib.network.Session;
import org.geysermc.mcprotocollib.network.packet.PacketProtocol;
import org.geysermc.mcprotocollib.protocol.MinecraftProtocol;
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.GameMode;
import org.geysermc.mcprotocollib.protocol.data.ProtocolState;
import org.geysermc.mcprotocollib.protocol.data.game.level.notify.GameEvent;
import org.geysermc.mcprotocollib.protocol.data.game.level.notify.GameEventValue;
import org.geysermc.mcprotocollib.protocol.data.game.entity.EntityEvent;
import org.geysermc.mcprotocollib.protocol.data.game.ClientCommand;
import org.geysermc.mcprotocollib.network.event.session.SessionAdapter;
import org.geysermc.mcprotocollib.network.event.session.SessionListener;
import org.geysermc.mcprotocollib.network.event.session.DisconnectedEvent;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.level.ClientboundGameEventPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.ClientboundEntityEventPacket;
import org.geysermc.mcprotocollib.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 () {
final Session session = client.session();
final PacketProtocol protocol = session.getPacketProtocol();
if (!session.isConnected() || (protocol instanceof MinecraftProtocol && ((MinecraftProtocol) protocol).getState() != ProtocolState.GAME)) return;
if (!session.isConnected() || (protocol instanceof MinecraftProtocol && ((MinecraftProtocol) protocol).getOutboundState() != ProtocolState.GAME)) return;
// TODO: Maybe make it possible for other stuff to listen for ticks
tick();
@ -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);
}
@ -75,7 +97,7 @@ public class SelfCarePlugin extends SessionAdapter {
public void packetReceived (Session session, ClientboundLoginPacket packet) {
entityId = packet.getEntityId(); // TODO: Move entity id handling somewhere else
gamemode = packet.getGameMode();
gamemode = packet.getCommonPlayerSpawnInfo().getGameMode();
}
public void packetReceived (Session session, ClientboundEntityEventPacket packet) {

View file

@ -2,13 +2,15 @@ package land.chipmunk.chipmunkbot.plugins;
import land.chipmunk.chipmunkbot.ChipmunkBot;
import land.chipmunk.chipmunkbot.song.*;
// import com.github.steveice10.packetlib.packet.Packet;
// import com.github.steveice10.packetlib.Session;
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 org.geysermc.mcprotocollib.network.packet.Packet;
// import org.geysermc.mcprotocollib.network.Session;
import org.geysermc.mcprotocollib.network.event.session.SessionListener;
import org.geysermc.mcprotocollib.network.event.session.SessionAdapter;
import org.geysermc.mcprotocollib.network.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);
}

View file

@ -2,12 +2,12 @@ package land.chipmunk.chipmunkbot.plugins;
import land.chipmunk.chipmunkbot.Client;
import org.cloudburstmc.math.vector.Vector3i;
import com.github.steveice10.packetlib.packet.Packet;
import com.github.steveice10.packetlib.Session;
import com.github.steveice10.packetlib.event.session.SessionListener;
import com.github.steveice10.packetlib.event.session.SessionAdapter;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundCommandSuggestionPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundCommandSuggestionsPacket;
import org.geysermc.mcprotocollib.network.packet.Packet;
import org.geysermc.mcprotocollib.network.Session;
import org.geysermc.mcprotocollib.network.event.session.SessionListener;
import org.geysermc.mcprotocollib.network.event.session.SessionAdapter;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.ServerboundCommandSuggestionPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundCommandSuggestionsPacket;
import java.util.concurrent.CompletableFuture;
import java.util.Map;
import java.util.HashMap;

View file

@ -1,11 +1,11 @@
package land.chipmunk.chipmunkbot.plugins;
import land.chipmunk.chipmunkbot.Client;
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 com.github.steveice10.mc.protocol.MinecraftProtocol;
import com.github.steveice10.mc.protocol.data.ProtocolState;
import org.geysermc.mcprotocollib.network.event.session.SessionListener;
import org.geysermc.mcprotocollib.network.event.session.SessionAdapter;
import org.geysermc.mcprotocollib.network.event.session.DisconnectedEvent;
import org.geysermc.mcprotocollib.protocol.MinecraftProtocol;
import org.geysermc.mcprotocollib.protocol.data.ProtocolState;
import lombok.Getter;
import java.util.ArrayList;
import java.util.List;
@ -26,7 +26,7 @@ public class TickLoop extends SessionAdapter {
public void run () {
for (Listener listener : listeners) {
listener.onTick(tick);
if (((MinecraftProtocol) client.session().getPacketProtocol()).getState() == ProtocolState.GAME) listener.onGameTick(tick);
if (((MinecraftProtocol) client.session().getPacketProtocol()).getOutboundState() == ProtocolState.GAME) listener.onGameTick(tick);
}
}
};

View file

@ -167,9 +167,9 @@ public class NBSConverter {
key += customInstrument.pitch;
}
if (key < 33 || key > 57) {
/* if (key < 33 || key > 57) {
continue;
}
} */
byte layerVolume = 100;
if (nbsLayers.size() > note.layer) {

View file

@ -1,7 +1,6 @@
package land.chipmunk.chipmunkbot.systemChat;
import com.github.steveice10.mc.auth.data.GameProfile;
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.GameMode;
import land.chipmunk.chipmunkbot.ChipmunkBot;
import land.chipmunk.chipmunkbot.data.MutablePlayerListEntry;
import land.chipmunk.chipmunkbot.data.chat.PlayerMessage;

View file

@ -1,7 +1,7 @@
package land.chipmunk.chipmunkbot.systemChat;
import com.github.steveice10.mc.auth.data.GameProfile;
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
import org.geysermc.mcprotocollib.auth.GameProfile;
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.GameMode;
import land.chipmunk.chipmunkbot.ChipmunkBot;
import land.chipmunk.chipmunkbot.data.MutablePlayerListEntry;
import land.chipmunk.chipmunkbot.data.chat.PlayerMessage;

View file

@ -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 U203aChatParser implements SystemChatParser {
private final ChipmunkBot client;
public U203aChatParser(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<Component> 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);
}
}

View file

@ -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);
}
}

View file

@ -1,6 +1,5 @@
package land.chipmunk.chipmunkbot.util;
import com.github.steveice10.opennbt.tag.builtin.IntArrayTag;
import java.util.UUID;
import java.nio.ByteBuffer;
@ -19,9 +18,9 @@ public class UUIDUtilities {
return intArray;
}
public static IntArrayTag tag (UUID uuid) {
return new IntArrayTag("", intArray(uuid));
}
// public static IntArrayTag tag (UUID uuid) {
// return new IntArrayTag("", intArray(uuid));
// }
public static String snbt (UUID uuid) {
int[] array = intArray(uuid);

View file

@ -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
}