1.21 + a LOT of fixies and a bit of optimization. WorldPlugin is still broken with some debug lines

This commit is contained in:
Chayapak 2024-10-06 20:46:51 +07:00
parent 837fe388bb
commit f1c98135a2
41 changed files with 256 additions and 224 deletions

View file

@ -51,5 +51,10 @@
<option name="name" value="opencollab" />
<option name="url" value="https://repo.opencollab.dev/maven-releases/" />
</remote-repository>
<remote-repository>
<option name="id" value="maven" />
<option name="name" value="maven" />
<option name="url" value="https://repo.opencollab.dev/main/" />
</remote-repository>
</component>
</project>

View file

@ -7,7 +7,7 @@ You will see that the exploits plugin is missing because I gitignored it to prev
To make this successfully compile just make `ExploitsPlugin.java` in the plugins folder and add this code:
```java
package land.chipmunk.chayapak.chomens_bot.plugins;
package me.chayapak1.chomens_bot.plugins;
import me.chayapak1.chomens_bot.Bot;

View file

@ -19,6 +19,10 @@ repositories {
mavenCentral()
maven {
url = uri('https://repo.opencollab.dev/main/')
}
maven {
url = uri('https://repo.opencollab.dev/maven-snapshots/')
}
@ -37,8 +41,8 @@ repositories {
}
dependencies {
implementation 'com.github.steveice10:mcprotocollib:1.20.2-1-SNAPSHOT'
implementation 'net.kyori:adventure-text-serializer-ansi:4.14.0'
implementation 'org.geysermc.mcprotocollib:protocol:1.21-SNAPSHOT'
implementation 'net.kyori:adventure-text-serializer-ansi:4.15.0'
implementation 'com.google.code.gson:gson:2.10.1'
implementation 'com.google.guava:guava:31.1-jre'
implementation 'org.jline:jline:3.23.0'
@ -47,7 +51,7 @@ dependencies {
implementation 'org.luaj:luaj-jse:3.0.1'
implementation 'net.dv8tion:JDA:5.0.0-beta.12'
implementation 'joda-time:joda-time:2.12.4'
implementation 'net.kyori:adventure-text-serializer-legacy:4.13.1'
implementation 'net.kyori:adventure-text-serializer-legacy:4.15.0'
implementation 'org.apache.logging.log4j:log4j-slf4j-impl:2.20.0'
implementation 'io.socket:socket.io-client:2.1.0'
implementation 'de.maxhenkel.opus4j:opus4j:2.0.2'
@ -56,7 +60,7 @@ dependencies {
jar {
manifest {
attributes 'Main-Class': 'land.chipmunk.chayapak.chomens_bot.Main'
attributes 'Main-Class': 'me.chayapak1.chomens_bot.Main'
}
}

View file

@ -1,21 +1,20 @@
package me.chayapak1.chomens_bot;
import com.github.steveice10.mc.auth.data.GameProfile;
import com.github.steveice10.mc.protocol.MinecraftProtocol;
import com.github.steveice10.mc.protocol.data.game.entity.player.HandPreference;
import com.github.steveice10.mc.protocol.data.game.setting.ChatVisibility;
import com.github.steveice10.mc.protocol.data.game.setting.SkinPart;
import com.github.steveice10.mc.protocol.packet.common.serverbound.ServerboundClientInformationPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
import com.github.steveice10.mc.protocol.packet.login.clientbound.ClientboundGameProfilePacket;
import com.github.steveice10.packetlib.Session;
import com.github.steveice10.packetlib.event.session.*;
import com.github.steveice10.packetlib.packet.Packet;
import com.github.steveice10.packetlib.tcp.TcpClientSession;
import land.chipmunk.chayapak.chomens_bot.plugins.*;
import me.chayapak1.chomens_bot.plugins.*;
import me.chayapak1.chomens_bot.util.ComponentUtilities;
import me.chayapak1.chomens_bot.util.RandomStringUtilities;
import org.geysermc.mcprotocollib.auth.GameProfile;
import org.geysermc.mcprotocollib.network.Session;
import org.geysermc.mcprotocollib.network.event.session.*;
import org.geysermc.mcprotocollib.network.packet.Packet;
import org.geysermc.mcprotocollib.network.tcp.TcpClientSession;
import org.geysermc.mcprotocollib.protocol.MinecraftProtocol;
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.HandPreference;
import org.geysermc.mcprotocollib.protocol.data.game.setting.ChatVisibility;
import org.geysermc.mcprotocollib.protocol.data.game.setting.SkinPart;
import org.geysermc.mcprotocollib.protocol.packet.common.serverbound.ServerboundClientInformationPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
import org.geysermc.mcprotocollib.protocol.packet.login.clientbound.ClientboundGameProfilePacket;
import java.util.ArrayList;
import java.util.List;

View file

@ -1,7 +1,7 @@
package me.chayapak1.chomens_bot.chatParsers;
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 me.chayapak1.chomens_bot.Bot;
import me.chayapak1.chomens_bot.data.chat.ChatParser;
import me.chayapak1.chomens_bot.data.PlayerEntry;

View file

@ -1,7 +1,7 @@
package me.chayapak1.chomens_bot.chatParsers;
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 me.chayapak1.chomens_bot.Bot;
import me.chayapak1.chomens_bot.data.chat.ChatParser;
import me.chayapak1.chomens_bot.data.PlayerEntry;

View file

@ -7,6 +7,7 @@ import me.chayapak1.chomens_bot.data.chat.PlayerMessage;
import me.chayapak1.chomens_bot.util.ComponentUtilities;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TranslatableComponent;
import net.kyori.adventure.text.TranslationArgument;
import net.kyori.adventure.text.event.HoverEvent;
import java.util.*;
@ -34,12 +35,12 @@ public class MinecraftChatParser implements ChatParser {
}
public PlayerMessage parse (TranslatableComponent message) {
final List<Component> args = message.args();
final List<TranslationArgument> args = message.arguments();
final String key = message.key();
if (args.size() < 2 || !keys.contains(key)) return null;
final Component senderComponent = args.get(0);
final Component contents = args.get(1);
final Component senderComponent = args.get(0).asComponent();
final Component contents = args.get(1).asComponent();
PlayerEntry sender;

View file

@ -7,6 +7,7 @@ import me.chayapak1.chomens_bot.data.chat.PlayerMessage;
import me.chayapak1.chomens_bot.util.ComponentUtilities;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TranslatableComponent;
import net.kyori.adventure.text.TranslationArgument;
import net.kyori.adventure.text.event.HoverEvent;
import java.util.List;
@ -28,11 +29,11 @@ public class U203aChatParser implements ChatParser {
// very similar to MinecraftChatParser
public PlayerMessage parse (TranslatableComponent message) {
final List<Component> args = message.args();
final List<TranslationArgument> args = message.arguments();
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);
final Component senderComponent = args.get(1).asComponent();
final Component contents = args.get(2).asComponent();
PlayerEntry sender;
final HoverEvent<?> hoverEvent = senderComponent.hoverEvent();

View file

@ -1,7 +1,7 @@
package me.chayapak1.chomens_bot.command;
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 me.chayapak1.chomens_bot.data.PlayerEntry;
import me.chayapak1.chomens_bot.util.CodeBlockUtilities;
import me.chayapak1.chomens_bot.Bot;

View file

@ -1,7 +1,7 @@
package me.chayapak1.chomens_bot.command;
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 me.chayapak1.chomens_bot.Bot;
import me.chayapak1.chomens_bot.data.PlayerEntry;
import me.chayapak1.chomens_bot.util.ComponentUtilities;

View file

@ -118,7 +118,7 @@ public class MailCommand extends Command {
return output;
}
final String value = ComponentUtilities.stringify(((TranslatableComponent) children.get(0)).args().get(1));
final String value = ComponentUtilities.stringify(((TranslatableComponent) children.get(0)).arguments().get(1).asComponent());
if (!value.startsWith("\"") && !value.endsWith("\"") && !value.startsWith("'") && !value.endsWith("'")) {
context.sendOutput(Component.text("`message` NBT is not a string").color(NamedTextColor.RED));

View file

@ -11,7 +11,7 @@ import me.chayapak1.chomens_bot.song.Instrument;
import me.chayapak1.chomens_bot.song.Loop;
import me.chayapak1.chomens_bot.song.Note;
import me.chayapak1.chomens_bot.song.Song;
import land.chipmunk.chayapak.chomens_bot.util.*;
import me.chayapak1.chomens_bot.util.*;
import me.chayapak1.chomens_bot.util.*;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.JoinConfiguration;
@ -225,7 +225,7 @@ public class MusicCommand extends Command {
return output;
}
final String value = ComponentUtilities.stringify(((TranslatableComponent) children.get(0)).args().get(1));
final String value = ComponentUtilities.stringify(((TranslatableComponent) children.get(0)).arguments().get(1).asComponent());
if (!value.startsWith("\"") && !value.endsWith("\"") && !value.startsWith("'") && !value.endsWith("'")) {
context.sendOutput(Component.text("`data` NBT is not a string").color(NamedTextColor.RED));
@ -282,7 +282,7 @@ public class MusicCommand extends Command {
return output;
}
final String value = ComponentUtilities.stringify(((TranslatableComponent) children.get(0)).args().get(1));
final String value = ComponentUtilities.stringify(((TranslatableComponent) children.get(0)).arguments().get(1).asComponent());
if (!value.startsWith("\"") && !value.endsWith("\"") && !value.startsWith("'") && !value.endsWith("'")) {
context.sendOutput(Component.text("NBT is not a string").color(NamedTextColor.RED));

View file

@ -6,7 +6,7 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import me.chayapak1.chomens_bot.Bot;
import me.chayapak1.chomens_bot.Main;
import land.chipmunk.chayapak.chomens_bot.command.*;
import me.chayapak1.chomens_bot.command.*;
import me.chayapak1.chomens_bot.command.*;
import me.chayapak1.chomens_bot.util.ColorUtilities;
import me.chayapak1.chomens_bot.util.HttpUtilities;

View file

@ -1,7 +1,7 @@
package me.chayapak1.chomens_bot.data;
import com.github.steveice10.mc.protocol.data.game.BossBarColor;
import com.github.steveice10.mc.protocol.data.game.BossBarDivision;
import org.geysermc.mcprotocollib.protocol.data.game.BossBarColor;
import org.geysermc.mcprotocollib.protocol.data.game.BossBarDivision;
import net.kyori.adventure.text.Component;
import java.util.UUID;

View file

@ -1,7 +1,7 @@
package me.chayapak1.chomens_bot.data;
import com.github.steveice10.mc.protocol.data.game.BossBarColor;
import com.github.steveice10.mc.protocol.data.game.BossBarDivision;
import org.geysermc.mcprotocollib.protocol.data.game.BossBarColor;
import org.geysermc.mcprotocollib.protocol.data.game.BossBarDivision;
import me.chayapak1.chomens_bot.Bot;
import me.chayapak1.chomens_bot.util.ComponentUtilities;
import net.kyori.adventure.text.Component;

View file

@ -1,8 +1,8 @@
package me.chayapak1.chomens_bot.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 java.security.PublicKey;

View file

@ -1,8 +1,8 @@
package me.chayapak1.chomens_bot.data;
import com.github.steveice10.mc.protocol.data.game.scoreboard.CollisionRule;
import com.github.steveice10.mc.protocol.data.game.scoreboard.NameTagVisibility;
import com.github.steveice10.mc.protocol.data.game.scoreboard.TeamColor;
import org.geysermc.mcprotocollib.protocol.data.game.scoreboard.CollisionRule;
import org.geysermc.mcprotocollib.protocol.data.game.scoreboard.NameTagVisibility;
import org.geysermc.mcprotocollib.protocol.data.game.scoreboard.TeamColor;
import net.kyori.adventure.text.Component;
public class Team {

View file

@ -1,11 +1,11 @@
package me.chayapak1.chomens_bot.plugins;
import com.github.steveice10.mc.protocol.data.game.BossBarColor;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundBossEventPacket;
import com.github.steveice10.packetlib.Session;
import com.github.steveice10.packetlib.event.session.ConnectedEvent;
import com.github.steveice10.packetlib.event.session.DisconnectedEvent;
import com.github.steveice10.packetlib.packet.Packet;
import org.geysermc.mcprotocollib.network.Session;
import org.geysermc.mcprotocollib.network.event.session.ConnectedEvent;
import org.geysermc.mcprotocollib.network.event.session.DisconnectedEvent;
import org.geysermc.mcprotocollib.network.packet.Packet;
import org.geysermc.mcprotocollib.protocol.data.game.BossBarColor;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundBossEventPacket;
import me.chayapak1.chomens_bot.Bot;
import me.chayapak1.chomens_bot.data.BossBar;
import me.chayapak1.chomens_bot.data.BotBossBar;

View file

@ -1,12 +1,12 @@
package me.chayapak1.chomens_bot.plugins;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundDisguisedChatPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundPlayerChatPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundSystemChatPacket;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundChatCommandPacket;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundChatPacket;
import com.github.steveice10.packetlib.Session;
import com.github.steveice10.packetlib.packet.Packet;
import org.geysermc.mcprotocollib.network.Session;
import org.geysermc.mcprotocollib.network.packet.Packet;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundDisguisedChatPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundPlayerChatPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundSystemChatPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.ServerboundChatCommandPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.ServerboundChatPacket;
import me.chayapak1.chomens_bot.Bot;
import me.chayapak1.chomens_bot.chatParsers.CreayunChatParser;
import me.chayapak1.chomens_bot.chatParsers.KaboomChatParser;
@ -141,7 +141,7 @@ public class ChatPlugin extends Bot.Listener {
final Component unsignedContent = packet.getUnsignedContent();
final String translation = getTranslationByChatType(packet.getChatType());
final String translation = getTranslationByChatType(packet.getChatType().id());
for (Listener listener : listeners) {
final boolean bool = listener.playerMessageReceived(playerMessage);
@ -152,13 +152,13 @@ public class ChatPlugin extends Bot.Listener {
TranslatableComponent component = Component.translatable(translation);
if (translation.equals("chat.type.team.text") || translation.equals("chat.type.team.sent")) { // ohio
component = component.args(
Component.translatable("chat.square_brackets").args(bot.team.teamsByPlayer.get(bot.profile.getName()).displayName),
component = component.arguments(
Component.translatable("chat.square_brackets").arguments(bot.team.teamsByPlayer.get(bot.profile.getName()).displayName),
playerMessage.displayName,
playerMessage.contents
);
} else {
component = component.args(playerMessage.displayName, playerMessage.contents);
component = component.arguments(playerMessage.displayName, playerMessage.contents);
}
final String string = ComponentUtilities.stringify(component);
@ -180,7 +180,7 @@ public class ChatPlugin extends Bot.Listener {
public void packetReceived (ClientboundDisguisedChatPacket packet) {
try {
final String translation = getTranslationByChatType(packet.getChatType());
final String translation = getTranslationByChatType(packet.getChatType().id());
final Component component = packet.getMessage();
@ -198,13 +198,13 @@ public class ChatPlugin extends Bot.Listener {
TranslatableComponent translatableComponent = Component.translatable(translation);
if (translation.equals("chat.type.team.text") || translation.equals("chat.type.team.sent")) { // ohio
translatableComponent = translatableComponent.args(
Component.translatable("chat.square_brackets").args(bot.team.teamsByPlayer.get(bot.profile.getName()).displayName),
translatableComponent = translatableComponent.arguments(
Component.translatable("chat.square_brackets").arguments(bot.team.teamsByPlayer.get(bot.profile.getName()).displayName),
name,
content
);
} else {
translatableComponent = translatableComponent.args(name, content);
translatableComponent = translatableComponent.arguments(name, content);
}
final String string = ComponentUtilities.stringify(translatableComponent);
@ -282,14 +282,7 @@ public class ChatPlugin extends Bot.Listener {
}
public void sendCommandInstantly (String command) {
bot.session.send(new ServerboundChatCommandPacket(
command,
Instant.now().toEpochMilli(),
0L,
Collections.emptyList(),
0,
new BitSet()
));
bot.session.send(new ServerboundChatCommandPacket(command));
}
public void sendChatInstantly (String message) {

View file

@ -1,8 +1,6 @@
package me.chayapak1.chomens_bot.plugins;
import me.chayapak1.chomens_bot.Bot;
import land.chipmunk.chayapak.chomens_bot.command.*;
import land.chipmunk.chayapak.chomens_bot.commands.*;
import me.chayapak1.chomens_bot.command.*;
import me.chayapak1.chomens_bot.commands.*;
import me.chayapak1.chomens_bot.util.ExceptionUtilities;

View file

@ -1,24 +1,26 @@
package me.chayapak1.chomens_bot.plugins;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
import com.github.steveice10.mc.protocol.data.game.entity.object.Direction;
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerAction;
import com.github.steveice10.mc.protocol.data.game.level.block.BlockChangeEntry;
import com.github.steveice10.mc.protocol.data.game.level.block.CommandBlockMode;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundBlockUpdatePacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundLevelChunkWithLightPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundSectionBlocksUpdatePacket;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.inventory.ServerboundSetCommandBlockPacket;
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.player.ServerboundUseItemOnPacket;
import com.github.steveice10.opennbt.tag.builtin.ByteTag;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.github.steveice10.packetlib.Session;
import com.github.steveice10.packetlib.event.session.DisconnectedEvent;
import com.github.steveice10.packetlib.packet.Packet;
import org.cloudburstmc.nbt.NbtMap;
import org.cloudburstmc.nbt.NbtMapBuilder;
import org.geysermc.mcprotocollib.network.Session;
import org.geysermc.mcprotocollib.network.event.session.DisconnectedEvent;
import org.geysermc.mcprotocollib.network.packet.Packet;
import org.geysermc.mcprotocollib.protocol.data.game.entity.object.Direction;
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand;
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.PlayerAction;
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.data.game.level.block.BlockChangeEntry;
import org.geysermc.mcprotocollib.protocol.data.game.level.block.CommandBlockMode;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.level.ClientboundBlockUpdatePacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.level.ClientboundLevelChunkWithLightPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.level.ClientboundSectionBlocksUpdatePacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.inventory.ServerboundSetCommandBlockPacket;
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.player.ServerboundUseItemOnPacket;
import me.chayapak1.chomens_bot.Bot;
import me.chayapak1.chomens_bot.util.MathUtilities;
import net.kyori.adventure.text.BlockNBTComponent;
@ -179,7 +181,7 @@ public class CorePlugin extends PositionPlugin.Listener {
}
}
// thanks chipmunk for this new tellraw method :3
// thanks chipmunk for this new tellraw method
public CompletableFuture<Component> runTracked (String command) {
if (!bot.options.useCore) return null;
@ -248,13 +250,29 @@ public class CorePlugin extends PositionPlugin.Listener {
public void runPlaceBlock (String command) {
if (!ready || !bot.options.useCore) return;
final CompoundTag tag = new CompoundTag("");
final CompoundTag blockEntityTag = new CompoundTag("BlockEntityTag");
blockEntityTag.put(new StringTag("Command", command));
blockEntityTag.put(new ByteTag("auto", (byte) 1));
blockEntityTag.put(new ByteTag("TrackOutput", (byte) 1));
blockEntityTag.put(new StringTag("CustomName", bot.config.core.customName));
tag.put(blockEntityTag);
// final NbtMapBuilder tagBuilder = NbtMap.builder();
final NbtMapBuilder blockEntityTagBuilder = NbtMap.builder();
blockEntityTagBuilder.putString("id", "minecraft:command_block");
blockEntityTagBuilder.putString("Command", command);
blockEntityTagBuilder.putByte("auto", (byte) 1);
blockEntityTagBuilder.putByte("TrackOutput", (byte) 1);
blockEntityTagBuilder.putString("CustomName", bot.config.core.customName);
final NbtMap blockEntityTag = blockEntityTagBuilder.build();
// tagBuilder.putCompound("BlockEntityTag", blockEntityTag);
// final NbtMap tag = tagBuilder.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));
// map.put(DataComponentType.BLOCK_ENTITY_DATA, DataComponentType.BLOCK_ENTITY_DATA.getDataComponentFactory().create(DataComponentType.BLOCK_ENTITY_DATA, tag));
final DataComponents dataComponents = new DataComponents(map);
final Vector3i temporaryBlockPosition = Vector3i.from(
bot.position.position.getX(),
@ -265,13 +283,13 @@ public class CorePlugin extends PositionPlugin.Listener {
final Session session = bot.session;
session.send(
new ServerboundSetCreativeModeSlotPacket(
36,
(short) 36,
new ItemStack(
bot.serverPluginsManager.hasPlugin(ServerPluginsManagerPlugin.EXTRAS) ?
492 /* repeating command block id */ :
373 /* command block id */,
514 /* repeating command block id */ :
395 /* command block id */,
64,
tag
dataComponents
)
)
);

View file

@ -1,7 +1,5 @@
package me.chayapak1.chomens_bot.plugins;
import com.github.steveice10.packetlib.event.session.ConnectedEvent;
import com.github.steveice10.packetlib.event.session.DisconnectedEvent;
import me.chayapak1.chomens_bot.Bot;
import me.chayapak1.chomens_bot.Configuration;
import me.chayapak1.chomens_bot.Main;
@ -26,6 +24,8 @@ 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.serializer.legacy.LegacyComponentSerializer;
import org.geysermc.mcprotocollib.network.event.session.ConnectedEvent;
import org.geysermc.mcprotocollib.network.event.session.DisconnectedEvent;
import org.jetbrains.annotations.NotNull;
import java.awt.*;
@ -167,7 +167,7 @@ public class DiscordPlugin {
// ignore my very very ohio code,..,,.
Component attachmentsComponent = Component.empty();
if (messageEvent.getAttachments().size() > 0) {
if (!messageEvent.getAttachments().isEmpty()) {
attachmentsComponent = attachmentsComponent.append(Component.space());
for (Message.Attachment attachment : messageEvent.getAttachments()) {
attachmentsComponent = attachmentsComponent
@ -182,7 +182,7 @@ public class DiscordPlugin {
}
Component embedsComponent = Component.empty();
if (messageEvent.getEmbeds().size() > 0) {
if (!messageEvent.getEmbeds().isEmpty()) {
if (messageEvent.getAttachments().isEmpty()) embedsComponent = embedsComponent.append(Component.space());
for (MessageEmbed embed : messageEvent.getEmbeds()) {
final Component hoverEvent = Component.translatable(
@ -216,7 +216,7 @@ public class DiscordPlugin {
final List<Role> roles = member == null ? Collections.emptyList() : member.getRoles();
Component rolesComponent = Component.empty();
if (roles.size() > 0) {
if (!roles.isEmpty()) {
rolesComponent = rolesComponent
.append(Component.text("Roles:").color(NamedTextColor.GRAY))
.append(Component.newline());
@ -356,7 +356,7 @@ public class DiscordPlugin {
public void onDiscordTick(String channelId) {
synchronized (logMessages) {
if (!logMessages.containsKey(channelId) || logMessages.get(channelId).length() == 0) {
if (!logMessages.containsKey(channelId) || logMessages.get(channelId).isEmpty()) {
return;
}
}

View file

@ -6,9 +6,11 @@ import me.chayapak1.chomens_bot.data.PlayerEntry;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.TranslatableComponent;
import net.kyori.adventure.text.TranslationArgument;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.Style;
import net.kyori.adventure.text.format.TextDecoration;
import org.jetbrains.annotations.NotNull;
import java.nio.charset.StandardCharsets;
import java.util.List;
@ -56,10 +58,10 @@ public class FormatCheckerPlugin extends ChatPlugin.Listener {
if (!(component instanceof TranslatableComponent format)) return false;
final List<Component> args = format.args();
final List<TranslationArgument> args = format.arguments();
if (args.size() < 3 || !format.key().equals("[%s] %s %s")) return false;
final Component nameComponent = format.args().get(1);
final TranslationArgument nameComponent = format.arguments().get(1);
if (!(nameComponent instanceof TextComponent)) return false;
@ -67,7 +69,7 @@ public class FormatCheckerPlugin extends ChatPlugin.Listener {
if (!name.equals(bot.config.ownerName)) return false;
final Component prefix = format.args().get(0);
final Component prefix = (Component) format.arguments().get(0);
if (
((prefix instanceof TextComponent text) && text.content().equals(bot.username + " Console")) || // ohio
@ -76,7 +78,7 @@ public class FormatCheckerPlugin extends ChatPlugin.Listener {
if (!(prefix instanceof TranslatableComponent translatablePrefix)) return true;
final Component userHash = translatablePrefix.args().get(0);
final TranslationArgument userHash = translatablePrefix.arguments().get(0);
if (userHash == null) return true;

View file

@ -1,6 +1,5 @@
package me.chayapak1.chomens_bot.plugins;
import com.github.steveice10.packetlib.event.session.ConnectedEvent;
import me.chayapak1.chomens_bot.Bot;
import me.chayapak1.chomens_bot.Configuration;
import me.chayapak1.chomens_bot.Main;
@ -11,6 +10,7 @@ import me.chayapak1.chomens_bot.irc.IRCMessageLoop;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.HoverEvent;
import net.kyori.adventure.text.format.NamedTextColor;
import org.geysermc.mcprotocollib.network.event.session.ConnectedEvent;
import java.util.*;
import java.util.concurrent.TimeUnit;
@ -31,6 +31,8 @@ public class IRCPlugin extends IRCMessageLoop {
this.servers = ircConfig.servers;
if (!ircConfig.enabled) return;
nick(ircConfig.nickname);
user(ircConfig.username, ircConfig.hostName, ircConfig.serverName, ircConfig.realName);

View file

@ -1,11 +1,11 @@
package me.chayapak1.chomens_bot.plugins;
import com.github.steveice10.packetlib.event.session.ConnectedEvent;
import com.github.steveice10.packetlib.event.session.DisconnectedEvent;
import me.chayapak1.chomens_bot.Bot;
import me.chayapak1.chomens_bot.util.ComponentUtilities;
import me.chayapak1.chomens_bot.util.LoggerUtilities;
import net.kyori.adventure.text.Component;
import org.geysermc.mcprotocollib.network.event.session.ConnectedEvent;
import org.geysermc.mcprotocollib.network.event.session.DisconnectedEvent;
public class LoggerPlugin extends ChatPlugin.Listener {
private final Bot bot;

View file

@ -1,12 +1,12 @@
package me.chayapak1.chomens_bot.plugins;
import com.github.steveice10.mc.protocol.data.game.BossBarColor;
import com.github.steveice10.mc.protocol.data.game.BossBarDivision;
import com.github.steveice10.packetlib.event.session.DisconnectedEvent;
import org.geysermc.mcprotocollib.network.event.session.DisconnectedEvent;
import org.geysermc.mcprotocollib.protocol.data.game.BossBarColor;
import org.geysermc.mcprotocollib.protocol.data.game.BossBarDivision;
import me.chayapak1.chomens_bot.Bot;
import me.chayapak1.chomens_bot.data.BotBossBar;
import me.chayapak1.chomens_bot.data.PlayerEntry;
import land.chipmunk.chayapak.chomens_bot.song.*;
import me.chayapak1.chomens_bot.song.*;
import me.chayapak1.chomens_bot.song.*;
import me.chayapak1.chomens_bot.util.ColorUtilities;
import me.chayapak1.chomens_bot.util.MathUtilities;

View file

@ -1,8 +1,8 @@
package me.chayapak1.chomens_bot.plugins;
import com.github.steveice10.packetlib.Session;
import com.github.steveice10.packetlib.packet.Packet;
import me.chayapak1.chomens_bot.Bot;
import org.geysermc.mcprotocollib.network.Session;
import org.geysermc.mcprotocollib.network.packet.Packet;
import java.io.BufferedWriter;
import java.io.IOException;

View file

@ -1,13 +1,13 @@
package me.chayapak1.chomens_bot.plugins;
import com.github.steveice10.mc.protocol.data.game.PlayerListEntry;
import com.github.steveice10.mc.protocol.data.game.PlayerListEntryAction;
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundPlayerInfoRemovePacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundPlayerInfoUpdatePacket;
import com.github.steveice10.packetlib.Session;
import com.github.steveice10.packetlib.event.session.DisconnectedEvent;
import com.github.steveice10.packetlib.packet.Packet;
import org.geysermc.mcprotocollib.network.Session;
import org.geysermc.mcprotocollib.network.event.session.DisconnectedEvent;
import org.geysermc.mcprotocollib.network.packet.Packet;
import org.geysermc.mcprotocollib.protocol.data.game.PlayerListEntry;
import org.geysermc.mcprotocollib.protocol.data.game.PlayerListEntryAction;
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.GameMode;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundPlayerInfoRemovePacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundPlayerInfoUpdatePacket;
import me.chayapak1.chomens_bot.Bot;
import me.chayapak1.chomens_bot.data.PlayerEntry;
import net.kyori.adventure.text.Component;

View file

@ -1,15 +1,15 @@
package me.chayapak1.chomens_bot.plugins;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundMoveEntityPosPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundMoveEntityPosRotPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundMoveEntityRotPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundRemoveEntitiesPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerPositionPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.spawn.ClientboundAddEntityPacket;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.level.ServerboundAcceptTeleportationPacket;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerPosPacket;
import com.github.steveice10.packetlib.Session;
import com.github.steveice10.packetlib.packet.Packet;
import org.geysermc.mcprotocollib.network.Session;
import org.geysermc.mcprotocollib.network.packet.Packet;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.ClientboundMoveEntityPosPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.ClientboundMoveEntityPosRotPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.ClientboundMoveEntityRotPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.ClientboundRemoveEntitiesPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerPositionPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.spawn.ClientboundAddEntityPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.level.ServerboundAcceptTeleportationPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerPosPacket;
import me.chayapak1.chomens_bot.Bot;
import me.chayapak1.chomens_bot.data.Rotation;
import me.chayapak1.chomens_bot.data.PlayerEntry;

View file

@ -1,19 +1,19 @@
package me.chayapak1.chomens_bot.plugins;
import com.github.steveice10.mc.protocol.data.game.ClientCommand;
import com.github.steveice10.mc.protocol.data.game.entity.EntityEvent;
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
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.packet.ingame.clientbound.ClientboundLoginPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundEntityEventPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.inventory.ClientboundOpenScreenPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundGameEventPacket;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundClientCommandPacket;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.inventory.ServerboundContainerClosePacket;
import com.github.steveice10.packetlib.Session;
import com.github.steveice10.packetlib.event.session.DisconnectedEvent;
import com.github.steveice10.packetlib.packet.Packet;
import org.geysermc.mcprotocollib.network.Session;
import org.geysermc.mcprotocollib.network.event.session.DisconnectedEvent;
import org.geysermc.mcprotocollib.network.packet.Packet;
import org.geysermc.mcprotocollib.protocol.data.game.ClientCommand;
import org.geysermc.mcprotocollib.protocol.data.game.entity.EntityEvent;
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.GameMode;
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.packet.ingame.clientbound.ClientboundLoginPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.ClientboundEntityEventPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.inventory.ClientboundOpenScreenPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.level.ClientboundGameEventPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.ServerboundClientCommandPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.inventory.ServerboundContainerClosePacket;
import me.chayapak1.chomens_bot.Bot;
import me.chayapak1.chomens_bot.Configuration;
import net.kyori.adventure.text.Component;

View file

@ -1,7 +1,7 @@
package me.chayapak1.chomens_bot.plugins;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundCommandSuggestionsPacket;
import com.github.steveice10.packetlib.event.session.ConnectedEvent;
import org.geysermc.mcprotocollib.network.event.session.ConnectedEvent;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundCommandSuggestionsPacket;
import me.chayapak1.chomens_bot.Bot;
import java.util.ArrayList;

View file

@ -1,11 +1,11 @@
package me.chayapak1.chomens_bot.plugins;
import com.github.steveice10.mc.protocol.data.game.BossBarColor;
import com.github.steveice10.mc.protocol.data.game.BossBarDivision;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundSetTimePacket;
import com.github.steveice10.packetlib.Session;
import com.github.steveice10.packetlib.packet.Packet;
import org.geysermc.mcprotocollib.network.Session;
import org.geysermc.mcprotocollib.network.packet.Packet;
import org.geysermc.mcprotocollib.protocol.data.game.BossBarColor;
import org.geysermc.mcprotocollib.protocol.data.game.BossBarDivision;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.level.ClientboundSetTimePacket;
import me.chayapak1.chomens_bot.Bot;
import me.chayapak1.chomens_bot.data.BotBossBar;
import me.chayapak1.chomens_bot.util.MathUtilities;
@ -141,7 +141,7 @@ public class TPSPlugin extends Bot.Listener {
float sumTickRates = 0.0f;
for (double tickRate : tickRates) {
if (tickRate > 0) {
sumTickRates += tickRate;
sumTickRates += (float) tickRate;
numTicks++;
}
}

View file

@ -1,9 +1,9 @@
package me.chayapak1.chomens_bot.plugins;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundCommandSuggestionsPacket;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundCommandSuggestionPacket;
import com.github.steveice10.packetlib.Session;
import com.github.steveice10.packetlib.packet.Packet;
import org.geysermc.mcprotocollib.network.Session;
import org.geysermc.mcprotocollib.network.packet.Packet;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundCommandSuggestionsPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.ServerboundCommandSuggestionPacket;
import me.chayapak1.chomens_bot.Bot;
import java.util.HashMap;

View file

@ -1,8 +1,8 @@
package me.chayapak1.chomens_bot.plugins;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.scoreboard.ClientboundSetPlayerTeamPacket;
import com.github.steveice10.packetlib.Session;
import com.github.steveice10.packetlib.packet.Packet;
import org.geysermc.mcprotocollib.network.Session;
import org.geysermc.mcprotocollib.network.packet.Packet;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.scoreboard.ClientboundSetPlayerTeamPacket;
import me.chayapak1.chomens_bot.Bot;
import me.chayapak1.chomens_bot.data.Team;

View file

@ -1,11 +1,12 @@
package me.chayapak1.chomens_bot.plugins;
import com.github.steveice10.mc.protocol.packet.common.clientbound.ClientboundCustomPayloadPacket;
import com.github.steveice10.mc.protocol.packet.common.serverbound.ServerboundCustomPayloadPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
import com.github.steveice10.packetlib.Session;
import com.github.steveice10.packetlib.event.session.DisconnectedEvent;
import com.github.steveice10.packetlib.packet.Packet;
import net.kyori.adventure.key.Key;
import org.geysermc.mcprotocollib.network.Session;
import org.geysermc.mcprotocollib.network.event.session.DisconnectedEvent;
import org.geysermc.mcprotocollib.network.packet.Packet;
import org.geysermc.mcprotocollib.protocol.packet.common.clientbound.ClientboundCustomPayloadPacket;
import org.geysermc.mcprotocollib.protocol.packet.common.serverbound.ServerboundCustomPayloadPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
import io.netty.buffer.Unpooled;
import me.chayapak1.chomens_bot.Bot;
import me.chayapak1.chomens_bot.data.voiceChat.ClientGroup;
@ -15,7 +16,7 @@ import me.chayapak1.chomens_bot.voiceChat.InitializationData;
import me.chayapak1.chomens_bot.voiceChat.NetworkMessage;
import me.chayapak1.chomens_bot.voiceChat.customPayload.JoinGroupPacket;
import me.chayapak1.chomens_bot.voiceChat.customPayload.SecretPacket;
import land.chipmunk.chayapak.chomens_bot.voiceChat.packets.*;
import me.chayapak1.chomens_bot.voiceChat.packets.*;
import me.chayapak1.chomens_bot.voiceChat.packets.*;
import java.net.*;
@ -51,17 +52,17 @@ public class VoiceChatPlugin extends Bot.Listener {
public void packetReceived(ClientboundLoginPacket ignored) {
// totally didn't use a real minecraft client with voicechat mod to get this
bot.session.send(new ServerboundCustomPayloadPacket(
"minecraft:brand",
Key.key("minecraft:brand"),
"\u0006fabric".getBytes() // should i use fabric here?
));
bot.session.send(new ServerboundCustomPayloadPacket(
"voicechat:request_secret",
Key.key("voicechat:request_secret"),
new FriendlyByteBuf(Unpooled.buffer()).writeInt(17).array()
));
bot.session.send(new ServerboundCustomPayloadPacket(
"voicechat:update_state",
Key.key("voicechat:update_state"),
new FriendlyByteBuf(Unpooled.buffer()).writeBoolean(false).array()
));
@ -69,7 +70,7 @@ public class VoiceChatPlugin extends Bot.Listener {
}
public void packetReceived(ClientboundCustomPayloadPacket _packet) {
if (_packet.getChannel().equals("voicechat:secret")) { // fard
if (_packet.getChannel().equals(Key.key("voicechat:secret"))) { // fard
final byte[] bytes = _packet.getData();
final FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.wrappedBuffer(bytes));
@ -112,14 +113,14 @@ public class VoiceChatPlugin extends Bot.Listener {
thread.setName("Simple Voice Chat Thread");
thread.start();
} else if (_packet.getChannel().equals("voicechat:add_group")) {
} else if (_packet.getChannel().equals(Key.key("voicechat:add_group"))) {
final byte[] bytes = _packet.getData();
final FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.wrappedBuffer(bytes));
final ClientGroup group = ClientGroup.fromBytes(buf);
groups.add(group);
} else if (_packet.getChannel().equals("voicechat:remove_group")) {
} else if (_packet.getChannel().equals(Key.key("voicechat:remove_group"))) {
final byte[] bytes = _packet.getData();
final FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.wrappedBuffer(bytes));
@ -144,7 +145,7 @@ public class VoiceChatPlugin extends Bot.Listener {
new JoinGroupPacket(clientGroup.id(), password).toBytes(buf);
bot.session.send(new ServerboundCustomPayloadPacket(
"voicechat:set_group",
Key.key("voicechat:set_group"),
buf.array()
));
}

View file

@ -1,12 +1,11 @@
package me.chayapak1.chomens_bot.plugins;
import com.github.steveice10.mc.protocol.packet.configuration.clientbound.ClientboundRegistryDataPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundRespawnPacket;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
import com.github.steveice10.packetlib.Session;
import com.github.steveice10.packetlib.packet.Packet;
import net.kyori.adventure.key.Key;
import org.geysermc.mcprotocollib.network.Session;
import org.geysermc.mcprotocollib.network.packet.Packet;
import org.geysermc.mcprotocollib.protocol.packet.configuration.clientbound.ClientboundRegistryDataPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundRespawnPacket;
import me.chayapak1.chomens_bot.Bot;
import java.util.ArrayList;
@ -19,7 +18,7 @@ public class WorldPlugin extends Bot.Listener {
public int minY = 0;
public int maxY = 256;
public CompoundTag registry = null;
public Key registry = null;
private final List<Listener> listeners = new ArrayList<>();
@ -36,22 +35,25 @@ public class WorldPlugin extends Bot.Listener {
else if (packet instanceof ClientboundRegistryDataPacket) packetReceived((ClientboundRegistryDataPacket) packet);
}
@SuppressWarnings("unchecked")
private void worldChanged (String dimension) {
final Tag dimensionType = ((LinkedHashMap<String, Tag>) registry.get("minecraft:dimension_type").getValue()).get("value");
final ArrayList<CompoundTag> dimensions = (ArrayList<CompoundTag>) dimensionType.getValue();
final CompoundTag currentDimension = dimensions.stream()
.filter((eachDimension) -> eachDimension.get("name").getValue().equals(dimension))
.toArray(CompoundTag[]::new)[0];
final CompoundTag element = currentDimension.get("element");
minY = (int) element.get("min_y").getValue();
maxY = (int) element.get("height").getValue();
for (Listener listener : listeners) listener.worldChanged(dimension);
// @SuppressWarnings("unchecked")
private void worldChanged (int dimension) {
// FIXME
bot.logger.info(registry.value());
bot.logger.info(registry.toString());
// final Key dimensionType = ((LinkedHashMap<String, Key>) registry.get("minecraft:dimension_type").asString()).get("value");
//
// final ArrayList<Key> dimensions = (ArrayList<Key>) dimensionType.asString();
//
// final Key currentDimension = dimensions.stream()
// .filter((eachDimension) -> eachDimension.get("name").getValue().equals(dimension))
// .toArray(Key[]::new)[0];
//
// final Key element = currentDimension.get("element");
//
// minY = (int) element.get("min_y").getValue();
// maxY = (int) element.get("height").getValue();
//
// for (Listener listener : listeners) listener.worldChanged(dimension);
}
public void packetReceived (ClientboundRegistryDataPacket packet) {

View file

@ -11,7 +11,7 @@ import java.util.*;
import static javax.sound.midi.ShortMessage.SYSTEM_RESET;
// Author: hhhzzzsss
// i modified this and some codes are stolen from https://github.com/RaphiMC/NoteBlockLib so thanks to them uwu
// i modified this and some codes are stolen from https://github.com/RaphiMC/NoteBlockLib so thanks to them
public class MidiConverter implements Converter {
public static final int TEXT = 0x01;
public static final int TRACK_NAME = 0x03;

View file

@ -283,16 +283,16 @@ public class ComponentUtilities {
} else {
String idxStr = matcher.group(1);
int idx = idxStr == null ? i++ : (Integer.parseInt(idxStr) - 1);
if (idx >= 0 && idx < message.args().size()) {
if (idx >= 0 && idx < message.arguments().size()) {
matcher.appendReplacement(
sb,
Matcher.quoteReplacement(
motd ?
stringifyMotd(message.args().get(idx)) + color :
stringifyMotd(message.arguments().get(idx).asComponent()) + color :
(
ansi ?
stringifyAnsi(message.args().get(idx)) + color :
stringify(message.args().get(idx))
stringifyAnsi(message.arguments().get(idx).asComponent()) + color :
stringify(message.arguments().get(idx).asComponent())
)
)
);

View file

@ -1,6 +1,8 @@
package me.chayapak1.chomens_bot.util;
import com.github.steveice10.opennbt.tag.builtin.IntArrayTag;
import org.cloudburstmc.nbt.NbtMap;
import org.cloudburstmc.nbt.NbtMapBuilder;
import java.util.UUID;
import java.nio.ByteBuffer;
@ -19,8 +21,12 @@ public class UUIDUtilities {
return intArray;
}
public static IntArrayTag tag (UUID uuid) {
return new IntArrayTag("", intArray(uuid));
public static NbtMap tag (UUID uuid) {
final NbtMapBuilder builder = NbtMap.builder();
builder.putIntArray("", intArray(uuid));
return builder.build();
}
public static String snbt (UUID uuid) {

View file

@ -4,7 +4,7 @@ import io.netty.buffer.Unpooled;
import me.chayapak1.chomens_bot.data.voiceChat.RawUdpPacket;
import me.chayapak1.chomens_bot.util.AESUtilities;
import me.chayapak1.chomens_bot.util.FriendlyByteBuf;
import land.chipmunk.chayapak.chomens_bot.voiceChat.packets.*;
import me.chayapak1.chomens_bot.voiceChat.packets.*;
import me.chayapak1.chomens_bot.voiceChat.packets.*;
import javax.crypto.BadPaddingException;

View file

@ -48,7 +48,7 @@ irc:
localhost:25565: '#chomens-localhost' # channel name
music:
URLRatelimit:
urlRatelimit:
seconds: 15
limit: 7