vanished player support, disguised chat parsing fix up, command block output parsing, somewhat world parsing, moved the classes to a new folder with the bots codename, etc. Build 5312. this was supposed to be commited at 2:30pm central time but i was having gpg issues

This commit is contained in:
Parker
2026-10-23 07:30:06 +08:00
parent a331466d9e
commit baf210f369
92 changed files with 1425 additions and 858 deletions
+2 -2
View File
@@ -10,5 +10,5 @@ build
# Ignore the bin folder vscode keeps creating
bin
# Ignore the config
config.yml
# get a nbt parser somewhere else lmao
src/main/kotlin
+1 -1
View File
@@ -1,5 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
<option name="PREFERRED_PROJECT_CODE_STYLE" value="code style" />
</state>
</component>
+1 -8
View File
@@ -1,12 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="PrintToLogpointModuleInspectionState">
<option name="disabledModuleNames">
<set>
<option value="NitoriBot.main" />
</set>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_25" default="true" project-jdk-name="25 (4)" project-jdk-type="JavaSDK" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_25" default="true" project-jdk-name="25 (3)" project-jdk-type="JavaSDK" />
</project>
-9
View File
@@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/modules/NitoriBot.main.iml" filepath="$PROJECT_DIR$/.idea/modules/NitoriBot.main.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/NitoriBot.test.iml" filepath="$PROJECT_DIR$/.idea/modules/NitoriBot.test.iml" />
</modules>
</component>
</project>
+5 -10
View File
@@ -22,19 +22,12 @@ repositories {
maven("https://jitpack.io/")
maven("https://repo.opencollab.dev/main/")
maven("https://maven.maxhenkel.de/repository/public/")
maven("https://central.sonatype.com/repository/maven-snapshots")
maven("https://code.chipmunk.land/api/packages/kaboomstandardsorganization/maven/")
}
dependencies {
implementation("org.geysermc.mcprotocollib:protocol:26.2-SNAPSHOT")
constraints {
implementation("io.netty:netty-codec-dns:4.2.16.Final") {
because("dos vulnerability!")
}
implementation("io.netty:netty-all:4.2.18.Final") {
because("vulnerability")
}
}
implementation("org.geysermc.mcprotocollib:protocol:26.3-SNAPSHOT")
implementation("org.slf4j:slf4j-api:2.0.20")
implementation("org.tinylog:slf4j-tinylog:2.8.1")
implementation("org.tinylog:tinylog-impl:2.8.1")
@@ -46,6 +39,8 @@ dependencies {
implementation("net.kyori:adventure-text-minimessage:5.2.0")
implementation("net.dv8tion:JDA:6.7.0")
implementation("org.jline:jline:4.4.7")
implementation("com.github.oshi:oshi-core:7.7.1")
implementation("net.kyori:adventure-nbt:5.2.0")
}
tasks.jar {
@@ -55,7 +50,7 @@ tasks.jar {
val dateTimeInfo = zoneDate.toLocalDateTime();
manifest {
attributes["Main-Class"] = "land.chipmunk.parker2991.nitoribot.Main"
attributes["Main-Class"] = "land.chipmunk.parker2991.nitoribot.nightofnights.Main"
attributes("Build-Time" to dateTimeFormatter.format(dateTimeInfo))
attributes("Enable-Native-Access" to "ALL-UNNAMED")
}
+26
View File
@@ -0,0 +1,26 @@
<code_scheme name="Default" version="173">
<JavaCodeStyleSettings>
<option name="DO_NOT_WRAP_AFTER_SINGLE_ANNOTATION" value="true" />
<option name="SPACE_BEFORE_DECONSTRUCTION_LIST" value="true" />
</JavaCodeStyleSettings>
<codeStyleSettings language="JAVA">
<option name="KEEP_LINE_BREAKS" value="false" />
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
<option name="ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION" value="true" />
<option name="SPACE_BEFORE_METHOD_PARENTHESES" value="true" />
<option name="CALL_PARAMETERS_WRAP" value="2" />
<option name="CALL_PARAMETERS_LPAREN_ON_NEXT_LINE" value="true" />
<option name="CALL_PARAMETERS_RPAREN_ON_NEXT_LINE" value="true" />
<option name="METHOD_PARAMETERS_WRAP" value="2" />
<option name="METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE" value="true" />
<option name="METHOD_PARAMETERS_RPAREN_ON_NEXT_LINE" value="true" />
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="kotlin">
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
</indentOptions>
</codeStyleSettings>
</code_scheme>
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.8.0-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
@@ -1,6 +0,0 @@
package land.chipmunk.parker2991.nitoribot.command;
import land.chipmunk.parker2991.nitoribot.Bot;
public record CommandContext(Bot bot, String[] args, CommandSource source) {
}
@@ -1,15 +0,0 @@
package land.chipmunk.parker2991.nitoribot.command;
import net.kyori.adventure.text.Component;
public class CommandError extends Exception {
public final Component message;
public CommandError (Component message) {
this.message = message;
}
public Component message () {
return message;
}
}
@@ -1,16 +0,0 @@
package land.chipmunk.parker2991.nitoribot.command;
import land.chipmunk.parker2991.nitoribot.Bot;
import land.chipmunk.parker2991.nitoribot.data.ParsedChatType;
import land.chipmunk.parker2991.nitoribot.data.PlayerProfileData;
import net.kyori.adventure.text.Component;
public record CommandSource(PlayerProfileData sender, boolean inGame, ParsedChatType chatType) {
public void sendFeedback (Bot bot, Component message) {
final String selector = String.format("@p[nbt={UUID:%s}]", sender().entityUUID());
if (chatType() == ParsedChatType.NORMAL) bot.chat.tellraw("@a", message);
else bot.chat.tellraw(selector, message);
}
}
@@ -1,103 +0,0 @@
package land.chipmunk.parker2991.nitoribot.commands.Public;
import land.chipmunk.parker2991.nitoribot.command.CommandContext;
import land.chipmunk.parker2991.nitoribot.command.CommandInfo;
import land.chipmunk.parker2991.nitoribot.command.CommandTrustLevels;
import land.chipmunk.parker2991.nitoribot.data.buildstring.BotBuildInfo;
import land.chipmunk.parker2991.nitoribot.data.buildstring.RepoCommitInfo;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import java.io.IOException;
import java.net.URL;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Enumeration;
import java.util.List;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
import static land.chipmunk.parker2991.nitoribot.util.ComponentUtil.convertColorString;
public class InfoCommand implements CommandInfo {
private final Enumeration<URL> resources = InfoCommand.class.getClassLoader().getResources("META-INF/MANIFEST.MF");
private final Manifest manifest = new Manifest(resources.nextElement().openStream());
private final Attributes attributes = manifest.getMainAttributes();
private final String buildTime = attributes.getValue("Build-Time");
public InfoCommand () throws IOException {
}
@Override
public CommandTrustLevels getTrustLevel () {
return CommandTrustLevels.PUBLIC;
}
@Override
public List<String> getAliases () {
return List.of("information", "info");
}
@Override
public String getDescription () {
return "see the bots info";
}
@Override
public void execute (CommandContext context) {
var bot = context.bot();
var source = context.source();
var args = context.args();
Component component = null;
GsonComponentSerializer gson = GsonComponentSerializer.gson();
switch (args[0].toLowerCase()) {
case "loaded" -> component = Component.translatable(
"%s: %s\n%s: %s\n%s: %s",
Component.text("Modules").color(convertColorString(bot.config.colors.commands.primary)),
Component.text(bot.modules.size()).color(convertColorString(bot.config.colors.integer)),
Component.text("Commands").color(convertColorString(bot.config.colors.commands.primary)),
Component.text(bot.commandManager.commands.size()).color(convertColorString(bot.config.colors.integer)),
Component.text("Chat Parsers").color(convertColorString(bot.config.colors.commands.primary)),
Component.text(bot.chat.chatParsers.size()).color(convertColorString(bot.config.colors.integer))
);
case "version" -> {
BotBuildInfo info = bot.botBuildInfo;
RepoCommitInfo repoCommitInfo = bot.repoCommitInfo;
ZonedDateTime dateTime = ZonedDateTime.parse(repoCommitInfo.created);
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("MMMM dd, yyyy hh:mm:ss a");
component = Component.translatable(
"%s-%s-%s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s",
gson.deserialize(info.buildstring.botName.toString()),
Component.text(info.buildstring.version).color(convertColorString(bot.config.colors.commands.secondary)),
gson.deserialize(info.buildstring.codename.toString()),
Component.text("Build").color(convertColorString(bot.config.colors.commands.primary)),
Component.text(info.buildstring.build).color(convertColorString(bot.config.colors.integer)),
Component.text("Commit").color(convertColorString(bot.config.colors.commands.primary)),
Component.text(repoCommitInfo.sha.substring(
0,
8
)).color(convertColorString(bot.config.colors.commands.secondary)),
Component.text("Version release Date").color(convertColorString(bot.config.colors.commands.primary)),
Component.text(dateTime.format(dateTimeFormatter)).color(convertColorString(bot.config.colors.commands.secondary)),
Component.text("Initial Bot Release").color(convertColorString(bot.config.colors.commands.primary)),
Component.text(info.buildstring.initialBotRelease).color(convertColorString(bot.config.colors.commands.secondary)),
Component.text("Jar Compile Date").color(convertColorString(bot.config.colors.commands.primary)),
Component.text(buildTime).color(convertColorString(bot.config.colors.commands.secondary))
).color(convertColorString(bot.config.colors.commands.tertiary));
}
}
source.sendFeedback(bot, component);
}
}
@@ -1,5 +0,0 @@
package land.chipmunk.parker2991.nitoribot.data;
public enum ChatType {
PLAYER, SYSTEM, DISGUISED
}
@@ -1,6 +0,0 @@
package land.chipmunk.parker2991.nitoribot.data;
import org.cloudburstmc.math.vector.Vector3d;
public record CommandCoreAreaData(Vector3d start, Vector3d end) {
}
@@ -1,5 +0,0 @@
package land.chipmunk.parker2991.nitoribot.data;
public enum ParsedChatType {
COMMANDSPY, NORMAL
}
@@ -1,31 +0,0 @@
package land.chipmunk.parker2991.nitoribot.data;
import net.kyori.adventure.text.Component;
import org.geysermc.mcprotocollib.auth.GameProfile;
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.GameMode;
import org.jetbrains.annotations.Nullable;
import java.util.UUID;
public record PlayerProfileData(UUID uuid, String entityUUID, GameProfile profile, boolean listed, int latency,
GameMode gameMode, Component displayName, boolean showHat, int listOrder,
PositionData position, String dimension, Integer entityId) {
public void listed (boolean listed) {
}
public void gameMode (GameMode gameMode) {
}
public void latency (int latency) {
}
public void position (PositionData position) {
}
public void displayName (@Nullable Component displayName) {
}
public void entityId (int entityId) {
}
}
@@ -1,6 +0,0 @@
package land.chipmunk.parker2991.nitoribot.data;
import org.cloudburstmc.math.vector.Vector3d;
public record PositionData(float pitch, float yaw, Vector3d position) {
}
@@ -1,7 +0,0 @@
package land.chipmunk.parker2991.nitoribot.data.chat;
import net.kyori.adventure.text.Component;
public interface ParseChatData {
PlayerMessageData parse (Component message);
}
@@ -1,7 +0,0 @@
package land.chipmunk.parker2991.nitoribot.data.chat;
import land.chipmunk.parker2991.nitoribot.data.PlayerProfileData;
import net.kyori.adventure.text.Component;
public record PlayerMessageData(PlayerProfileData sender, Component contents, String chatType, Component senderName) {
}
@@ -1,227 +0,0 @@
package land.chipmunk.parker2991.nitoribot.modules;
import land.chipmunk.parker2991.nitoribot.Bot;
import land.chipmunk.parker2991.nitoribot.data.CommandCoreAreaData;
import land.chipmunk.parker2991.nitoribot.data.PositionData;
import land.chipmunk.parker2991.nitoribot.listeners.Listener;
import land.chipmunk.parker2991.nitoribot.util.ComponentUtil;
import org.cloudburstmc.math.vector.Vector3d;
import org.cloudburstmc.math.vector.Vector3i;
import org.cloudburstmc.nbt.NbtMap;
import org.cloudburstmc.nbt.NbtMapBuilder;
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.*;
import org.geysermc.mcprotocollib.protocol.data.game.level.block.BlockEntityType;
import org.geysermc.mcprotocollib.protocol.data.game.level.block.CommandBlockMode;
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 org.jetbrains.annotations.NotNull;
import java.util.HashMap;
import java.util.Map;
public class CommandCoreModule implements Listener {
public final CommandCoreAreaData area;
private @NotNull final Bot bot;
public Vector3i position;
public Vector3i itemPosition;
public Vector3d currentBlockRelative = Vector3d.from(0, 0, 0);
public CommandCoreModule (Bot bot) {
this.bot = bot;
this.area = new CommandCoreAreaData(
Vector3d.from(
bot.config.core.area.start.x,
bot.config.core.area.start.y,
bot.config.core.area.start.z
), Vector3d.from(bot.config.core.area.end.x, bot.config.core.area.end.y, bot.config.core.area.end.z)
);
bot.listenerManager.addListener(this);
}
@Override
public void botMoved () {
move();
}
public void move () {
Vector3d botPos = bot.position.positionData.position();
position = Vector3i.from(Math.floor(botPos.getX() / 16) * 16, 0, Math.floor(botPos.getZ() / 16) * 16);
itemPosition = Vector3i.from(botPos.getX(), botPos.getY() - 1, botPos.getZ());
chatRefill();
}
public void chatRefill () {
Vector3i pos = position;
CommandCoreAreaData coreArea = area;
int startPosX = (int) Math.floor(pos.getX() - coreArea.start().getX());
int startPosY = (int) Math.floor(pos.getY() - coreArea.start().getY());
int startPosZ = (int) Math.floor(pos.getZ() - coreArea.start().getZ());
int endPosX = (int) Math.floor(pos.getX() - coreArea.end().getX());
int endPosY = (int) Math.floor(pos.getY() - coreArea.end().getY());
int endPosZ = (int) Math.floor(pos.getZ() - coreArea.end().getZ());
String command = String.format(
"minecraft:fill %s %s %s %s %s %s command_block{CustomName:%s} destroy",
startPosX,
startPosY,
startPosZ,
endPosX,
endPosY,
endPosZ,
bot.config.core.coreName
);
bot.chat.command(command);
}
public void itemRefill () {
final NbtMapBuilder blockEntityTagBuilder = NbtMap.builder();
String command = getCommand();
blockEntityTagBuilder.putString("Command", command).putByte("auto", (byte) 1).putByte("TrackOutput", (byte) 1);
final NbtMap blockEntityTag = blockEntityTagBuilder.build();
final Map<DataComponentType<?>, DataComponent<?, ?>> map = new HashMap<>();
map.put(
DataComponentTypes.BLOCK_ENTITY_DATA,
DataComponentTypes.BLOCK_ENTITY_DATA.getDataComponentFactory().create(
DataComponentTypes.BLOCK_ENTITY_DATA,
TypedEntityData.<BlockEntityType>builder().type(BlockEntityType.COMMAND_BLOCK).tag(blockEntityTag).build()
)
);
map.put(
DataComponentTypes.ITEM_NAME,
DataComponentTypes.ITEM_NAME.getDataComponentFactory().create(
DataComponentTypes.ITEM_NAME,
ComponentUtil.componentFromJSON(bot.config.core.coreName)
)
);
map.put(
DataComponentTypes.CUSTOM_NAME,
DataComponentTypes.CUSTOM_NAME.getDataComponentFactory().create(
DataComponentTypes.CUSTOM_NAME,
ComponentUtil.componentFromJSON(bot.config.core.coreName)
)
);
final DataComponents dataComponents = new DataComponents(map);
bot.session.send(new ServerboundSetCreativeModeSlotPacket((short) 36, new ItemStack(482, 64, dataComponents)));
bot.session.send(new ServerboundPlayerActionPacket(
PlayerAction.START_DIGGING,
itemPosition,
Direction.NORTH,
0
));
bot.session.send(new ServerboundUseItemOnPacket(
itemPosition,
Direction.NORTH,
Hand.MAIN_HAND,
0.5f,
0.5f,
0.5f,
false,
false,
1
));
}
private String getCommand () {
Vector3i pos = position;
CommandCoreAreaData coreArea = area;
int startPosX = (int) Math.round(pos.getX() - coreArea.start().getX());
int startPosY = (int) Math.round(pos.getY() - coreArea.start().getY());
int startPosZ = (int) Math.round(pos.getZ() - coreArea.start().getZ());
int endPosX = (int) Math.round(pos.getX() - coreArea.end().getX());
int endPosY = (int) Math.round(pos.getY() - coreArea.end().getY());
int endPosZ = (int) Math.round(pos.getZ() - coreArea.end().getZ());
return String.format(
"minecraft:fill %s %s %s %s %s %s command_block{CustomName:%s} replace",
startPosX,
startPosY,
startPosZ,
endPosX,
endPosY,
endPosZ,
bot.config.core.coreName
);
}
public PositionData currentBlock () {
Vector3d relativePosition = currentBlockRelative;
Vector3i corePosition = position;
return new PositionData(
(float) (relativePosition.getX() + corePosition.getX()),
(float) (relativePosition.getY() + corePosition.getY()),
Vector3d.from(relativePosition.getZ(), relativePosition.getY(), relativePosition.getZ())
);
}
public void incrementCurrentBlock () {
Vector3d relativePosition = currentBlockRelative;
CommandCoreAreaData coreArea = area;
double posX = relativePosition.getX();
double posY = relativePosition.getY();
double posZ = relativePosition.getZ();
posX++;
if (posX > coreArea.end().getX()) {
posX = coreArea.start().getX();
posZ++;
}
if (posZ > coreArea.end().getZ()) {
posZ = coreArea.start().getZ();
posY++;
}
if (posY > coreArea.end().getY()) {
posX = coreArea.start().getX();
posY = coreArea.start().getY();
posZ = coreArea.start().getZ();
}
currentBlockRelative = Vector3d.from(posX, posY, posZ);
}
public void commandBlock (String command, boolean doesTrackOutput, boolean conditional, boolean automatic) {
if (command.length() > 32767 || position == null) return;
bot.session.send(new ServerboundSetCommandBlockPacket(
position,
command,
CommandBlockMode.AUTO,
doesTrackOutput,
conditional,
automatic
));
}
public void run (String command) {
commandBlock(command, true, false, true);
incrementCurrentBlock();
}
}
@@ -1,53 +0,0 @@
package land.chipmunk.parker2991.nitoribot.modules;
import land.chipmunk.parker2991.nitoribot.Bot;
import land.chipmunk.parker2991.nitoribot.data.DimensionData;
import land.chipmunk.parker2991.nitoribot.listeners.Listener;
import org.geysermc.mcprotocollib.network.packet.Packet;
import org.geysermc.mcprotocollib.protocol.data.game.RegistryEntry;
import org.geysermc.mcprotocollib.protocol.packet.configuration.clientbound.ClientboundRegistryDataPacket;
import java.util.ArrayList;
import java.util.List;
public class RegistryModule implements Listener {
public final List<String> chatTypes = new ArrayList<>();
public final List<DimensionData> dimensions = new ArrayList<>();
private Bot bot;
public RegistryModule (Bot bot) {
this.bot = bot;
bot.listenerManager.addListener(this);
}
@Override
public void packetReceived (Packet packet) {
if (packet instanceof ClientboundRegistryDataPacket) packetReceived((ClientboundRegistryDataPacket) packet);
}
public void packetReceived (ClientboundRegistryDataPacket packet) {
String getRegistry = packet.getRegistry().asString();
for (RegistryEntry entry : packet.getEntries()) {
if (getRegistry.equals("minecraft:chat_type")) if (entry.getData() != null) {
chatTypes.add(entry.getData().getCompound("chat").getString("translation_key"));
}
if (getRegistry.equals("minecraft:worldgen/biome")) {
System.out.println(entry);
}
if (getRegistry.equals("minecraft:dimension_type")) {
if (entry.getData() != null) {
String dimension = null;
if (entry.getId().toString().equals("minecraft:overworld_caves"))
dimension = "minecraft:world_flatlands";
else dimension = String.valueOf(entry.getId());
this.dimensions.add(new DimensionData(
dimension,
Integer.parseInt(entry.getData().get("height").toString().replace("i", "")),
Integer.parseInt(entry.getData().get("min_y").toString().replace("i", ""))
));
}
}
}
}
}
@@ -1,30 +0,0 @@
package land.chipmunk.parker2991.nitoribot.modules;
import land.chipmunk.parker2991.nitoribot.Bot;
import land.chipmunk.parker2991.nitoribot.listeners.Listener;
import org.geysermc.mcprotocollib.network.packet.Packet;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.level.ClientboundLevelChunkWithLightPacket;
import org.jetbrains.annotations.NotNull;
public class WorldModule implements Listener {
private @NotNull Bot bot;
public WorldModule (Bot bot) {
this.bot = bot;
bot.listenerManager.addListener(this);
}
@Override
public void packetReceived (Packet packet) {
switch (packet) {
case ClientboundLevelChunkWithLightPacket p -> chunks(p);
default -> {
}
}
}
private void chunks (ClientboundLevelChunkWithLightPacket packet) {
//System.out.println(Arrays.toString(packet.getChunkData()));
}
}
@@ -1,13 +1,13 @@
package land.chipmunk.parker2991.nitoribot;
package land.chipmunk.parker2991.nitoribot.nightofnights;
import land.chipmunk.parker2991.nitoribot.boot.GetProxiesList;
import land.chipmunk.parker2991.nitoribot.data.buildstring.BotBuildInfo;
import land.chipmunk.parker2991.nitoribot.data.buildstring.RepoCommitInfo;
import land.chipmunk.parker2991.nitoribot.listeners.Listener;
import land.chipmunk.parker2991.nitoribot.listeners.ListenerManager;
import land.chipmunk.parker2991.nitoribot.logger.Logger;
import land.chipmunk.parker2991.nitoribot.modules.*;
import land.chipmunk.parker2991.nitoribot.util.ComponentUtil;
import land.chipmunk.parker2991.nitoribot.nightofnights.boot.GetProxiesList;
import land.chipmunk.parker2991.nitoribot.nightofnights.data.buildstring.BotBuildInfo;
import land.chipmunk.parker2991.nitoribot.nightofnights.data.buildstring.RepoCommitInfo;
import land.chipmunk.parker2991.nitoribot.nightofnights.listeners.Listener;
import land.chipmunk.parker2991.nitoribot.nightofnights.listeners.ListenerManager;
import land.chipmunk.parker2991.nitoribot.nightofnights.logger.Logger;
import land.chipmunk.parker2991.nitoribot.nightofnights.modules.*;
import land.chipmunk.parker2991.nitoribot.nightofnights.util.ComponentUtil;
import net.kyori.adventure.text.Component;
import org.geysermc.mcprotocollib.auth.GameProfile;
import org.geysermc.mcprotocollib.network.Session;
@@ -23,6 +23,7 @@ import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.Clientbound
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.ServerboundPlayerLoadedPacket;
import org.geysermc.mcprotocollib.protocol.packet.login.clientbound.ClientboundLoginFinishedPacket;
import org.jetbrains.annotations.NotNull;
import org.jspecify.annotations.NonNull;
import java.io.IOException;
import java.util.List;
@@ -50,9 +51,10 @@ public class Bot extends SessionAdapter {
public CommandManagerModule commandManager;
public MCServerModule mcServer;
public WorldModule world;
public TabCompleteModule tabComplete;
public List<?> modules;
public Bot (Config.Options options, List<Bot> bots, @NotNull Config config) throws IOException {
public Bot (Config.Options options, List<Bot> bots, @NotNull Config config) throws Exception {
this.options = options;
this.bots = bots;
this.config = config;
@@ -70,7 +72,8 @@ public class Bot extends SessionAdapter {
new TextDisplayModule(this),
this.mcServer = new MCServerModule(this),
new CommandSpyModule(this),
this.world = new WorldModule(this)
this.world = new WorldModule(this),
this.tabComplete = new TabCompleteModule(this)
);
try {
@@ -103,7 +106,7 @@ public class Bot extends SessionAdapter {
}
@Override
public void packetSent (Session session, Packet packet) {
public void packetSent (@NonNull Session session, @NonNull Packet packet) {
for (Listener listener : listenerManager.listeners) {
listener.packetSent();
}
@@ -115,7 +118,7 @@ public class Bot extends SessionAdapter {
}
@Override
public void packetReceived (Session session, Packet packet) {
public void packetReceived (@NonNull Session session, @NonNull Packet packet) {
try {
if (packet instanceof ClientboundLoginPacket) this.session.send(ServerboundPlayerLoadedPacket.INSTANCE);
@@ -1,4 +1,4 @@
package land.chipmunk.parker2991.nitoribot;
package land.chipmunk.parker2991.nitoribot.nightofnights;
import java.util.List;
@@ -10,6 +10,7 @@ public class Config {
public List<String> prefixes;
public static class Core {
public boolean itemRefill;
public final Area area = new Area();
public String coreName;
}
@@ -1,11 +1,13 @@
package land.chipmunk.parker2991.nitoribot;
package land.chipmunk.parker2991.nitoribot.nightofnights;
import land.chipmunk.parker2991.nitoribot.boot.GetBotBuildInfo;
import land.chipmunk.parker2991.nitoribot.boot.GetRepoInfo;
import land.chipmunk.parker2991.nitoribot.boot.LoadConfig;
import land.chipmunk.parker2991.nitoribot.data.buildstring.BotBuildInfo;
import land.chipmunk.parker2991.nitoribot.data.buildstring.RepoCommitInfo;
import land.chipmunk.parker2991.nitoribot.modules.ConsoleModule;
import land.chipmunk.parker2991.nitoribot.nightofnights.boot.GetBotBuildInfo;
import land.chipmunk.parker2991.nitoribot.nightofnights.boot.GetRepoInfo;
import land.chipmunk.parker2991.nitoribot.nightofnights.boot.LoadConfig;
import land.chipmunk.parker2991.nitoribot.nightofnights.data.buildstring.BotBuildInfo;
import land.chipmunk.parker2991.nitoribot.nightofnights.data.buildstring.RepoCommitInfo;
import land.chipmunk.parker2991.nitoribot.nightofnights.modules.ConsoleModule;
import land.chipmunk.parker2991.nitoribot.nightofnights.util.ComponentUtil;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import java.util.ArrayList;
import java.util.List;
@@ -25,14 +27,19 @@ public class Main {
void main () {
try {
botBuildInfo = new GetBotBuildInfo().getBuildInfo();
System.out.println("Starting NitoriBot " + ComponentUtil.componentToAnsi(GsonComponentSerializer.gson().deserialize(botBuildInfo.buildstring.codename.toString())));
config = new LoadConfig().loadConfig();
Config.Options[] bots = config.bots;
console = new ConsoleModule();
repoCommitInfo = new GetRepoInfo().getRepoInfo();
botBuildInfo = new GetBotBuildInfo().getBuildInfo();
for (Config.Options options : bots) {
final Bot bot = new Bot(options, Bots, config);
final Bot bot = new Bot(
options,
Bots,
config
);
Bots.add(bot);
}
} catch (Exception e) {
@@ -1,8 +1,8 @@
package land.chipmunk.parker2991.nitoribot.boot;
package land.chipmunk.parker2991.nitoribot.nightofnights.boot;
import com.google.gson.Gson;
import land.chipmunk.parker2991.nitoribot.Main;
import land.chipmunk.parker2991.nitoribot.data.buildstring.BotBuildInfo;
import land.chipmunk.parker2991.nitoribot.nightofnights.Main;
import land.chipmunk.parker2991.nitoribot.nightofnights.data.buildstring.BotBuildInfo;
import java.io.InputStreamReader;
import java.io.Reader;
@@ -1,4 +1,4 @@
package land.chipmunk.parker2991.nitoribot.boot;
package land.chipmunk.parker2991.nitoribot.nightofnights.boot;
import org.geysermc.mcprotocollib.network.ProxyInfo;
@@ -1,15 +1,17 @@
package land.chipmunk.parker2991.nitoribot.boot;
package land.chipmunk.parker2991.nitoribot.nightofnights.boot;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import land.chipmunk.parker2991.nitoribot.data.buildstring.RepoCommitInfo;
import land.chipmunk.parker2991.nitoribot.nightofnights.data.buildstring.RepoCommitInfo;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
import java.time.ZoneId;
import java.time.ZonedDateTime;
public class GetRepoInfo {
private static final Gson GSON = new Gson();
@@ -17,25 +19,28 @@ public class GetRepoInfo {
public RepoCommitInfo getRepoInfo () {
final String repo = "https://code.chipmunk.land/api/v1/repos/Parker2991/NitoriBot/commits?sha=main";
HttpClient client = HttpClient.newBuilder().followRedirects(HttpClient.Redirect.NORMAL).connectTimeout(Duration.ofSeconds(
10)).build();
20)).build();
HttpRequest request = HttpRequest.newBuilder().uri(URI.create(repo)).timeout(Duration.ofSeconds(20)).header(
"accept",
"application/json"
HttpRequest request = HttpRequest.newBuilder().uri(URI.create(repo)).timeout(Duration.ofMillis(20)).header("accept",
"application/json"
).build();
RepoCommitInfo info = null;
try {
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
String body = response.body();
JsonElement e = JsonParser.parseString(response.body());
JsonElement json = JsonParser.parseString(response.body());
info = GSON.fromJson(e.getAsJsonArray().get(0), RepoCommitInfo.class);
info = GSON.fromJson(json.getAsJsonArray().get(0), RepoCommitInfo.class);
} catch (Exception e) {
e.printStackTrace(System.err);
ZoneId timezone = ZoneId.of("America/Chicago");
String zoneDate = String.valueOf(ZonedDateTime.now(timezone));
//e.printStackTrace(System.err);
info = new RepoCommitInfo();
info.created = zoneDate;
info.commits = 0;
info.sha = "N/A";
}
return info;
}
@@ -1,8 +1,8 @@
package land.chipmunk.parker2991.nitoribot.boot;
package land.chipmunk.parker2991.nitoribot.nightofnights.boot;
import land.chipmunk.parker2991.nitoribot.Config;
import land.chipmunk.parker2991.nitoribot.Main;
import land.chipmunk.parker2991.nitoribot.logger.Logger;
import land.chipmunk.parker2991.nitoribot.nightofnights.Config;
import land.chipmunk.parker2991.nitoribot.nightofnights.Main;
import land.chipmunk.parker2991.nitoribot.nightofnights.logger.Logger;
import org.yaml.snakeyaml.LoaderOptions;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.Constructor;
@@ -1,9 +1,10 @@
package land.chipmunk.parker2991.nitoribot.chatparsers;
package land.chipmunk.parker2991.nitoribot.nightofnights.chatparsers;
import land.chipmunk.parker2991.nitoribot.Bot;
import land.chipmunk.parker2991.nitoribot.data.PlayerProfileData;
import land.chipmunk.parker2991.nitoribot.data.chat.ParseChatData;
import land.chipmunk.parker2991.nitoribot.data.chat.PlayerMessageData;
import land.chipmunk.parker2991.nitoribot.nightofnights.Bot;
import land.chipmunk.parker2991.nitoribot.nightofnights.data.ChatType;
import land.chipmunk.parker2991.nitoribot.nightofnights.data.PlayerProfileData;
import land.chipmunk.parker2991.nitoribot.nightofnights.data.chat.ParseChatData;
import land.chipmunk.parker2991.nitoribot.nightofnights.data.chat.PlayerMessageData;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
@@ -20,12 +21,12 @@ public class KaboomChatParser implements ParseChatData {
}
@Override
public PlayerMessageData parse (Component message) {
if (message instanceof TextComponent) return parse((TextComponent) message);
public PlayerMessageData parse (ChatType chatType, Component message) {
if (message instanceof TextComponent) return parse(chatType, (TextComponent) message);
return null;
}
public PlayerMessageData parse (TextComponent message) {
public PlayerMessageData parse (ChatType chatType, TextComponent message) {
List<Component> children = message.children();
if (!message.content().isEmpty() || !message.style().isEmpty() || children.size() < 3) return null;
@@ -44,7 +45,7 @@ public class KaboomChatParser implements ParseChatData {
}
PlayerProfileData sender = bot.players.getDisplayName(Component.empty().append(prefix).append(displayName));
return new PlayerMessageData(sender, contents, "minecraft:chat", displayName);
return new PlayerMessageData(sender, contents, chatType, displayName);
}
private boolean isSeperatorAt (List<Component> children, int start) {
@@ -0,0 +1,6 @@
package land.chipmunk.parker2991.nitoribot.nightofnights.command;
import land.chipmunk.parker2991.nitoribot.nightofnights.Bot;
public record CommandContext(Bot bot, String[] args, CommandSource source) {
}
@@ -1,4 +1,4 @@
package land.chipmunk.parker2991.nitoribot.command;
package land.chipmunk.parker2991.nitoribot.nightofnights.command;
import net.kyori.adventure.text.Component;
@@ -1,15 +1,15 @@
package land.chipmunk.parker2991.nitoribot.command;
package land.chipmunk.parker2991.nitoribot.nightofnights.command;
import java.util.List;
public interface CommandInfo {
//String getCommandName ();
CommandTrustLevels getTrustLevel ();
List<String> getAliases ();
String getDescription ();
void execute (CommandContext context);
List<String> getUsages ();
void execute (CommandContext context) throws CommandError;
}
@@ -0,0 +1,16 @@
package land.chipmunk.parker2991.nitoribot.nightofnights.command;
import land.chipmunk.parker2991.nitoribot.nightofnights.Bot;
import land.chipmunk.parker2991.nitoribot.nightofnights.data.ParsedChatType;
import land.chipmunk.parker2991.nitoribot.nightofnights.data.PlayerProfileData;
import net.kyori.adventure.text.Component;
public record CommandSource(PlayerProfileData sender, boolean inGame, ParsedChatType chatType) {
public void sendFeedback (Bot bot, Component message) {
final String selector = String.format("@p[nbt={UUID:uuid(\"%s\")}]", sender.uuid);
if (chatType() == ParsedChatType.NORMAL) bot.chat.tellraw("@a", message);
else bot.chat.tellraw(selector, message);
}
}
@@ -1,4 +1,4 @@
package land.chipmunk.parker2991.nitoribot.command;
package land.chipmunk.parker2991.nitoribot.nightofnights.command;
public enum CommandTrustLevels {
PUBLIC, TRUSTED, ADMIN, OWNER, CONSOLE, DISABLED
@@ -0,0 +1,47 @@
package land.chipmunk.parker2991.nitoribot.nightofnights.commands.Public;
import land.chipmunk.parker2991.nitoribot.nightofnights.Bot;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandContext;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandInfo;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandSource;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandTrustLevels;
import net.kyori.adventure.text.Component;
import java.util.List;
public class CoreCommand implements CommandInfo {
@Override
public CommandTrustLevels getTrustLevel () {
return CommandTrustLevels.PUBLIC;
}
@Override
public List<String> getAliases () {
return List.of("core", "cb", "corerun");
}
@Override
public String getDescription () {
return "run commands in the bots core";
}
@Override
public List<String> getUsages () {
return List.of("<command>");
}
@Override
public void execute (CommandContext context) {
Bot bot = context.bot();
CommandSource source = context.source();
String message = String.join(" ", context.args());
Component output = bot.core.runTrackedWithTellraw("nitoribot.command_block.output", "@a", message);
source.sendFeedback(bot, output);
/*CompletableFuture.runAsync(() -> {
source.sendFeedback(bot, bot.core.output);
bot.core.output = null;
}, CompletableFuture.delayedExecutor(100, TimeUnit.MILLISECONDS));*/
}
}
@@ -1,9 +1,9 @@
package land.chipmunk.parker2991.nitoribot.commands.Public;
package land.chipmunk.parker2991.nitoribot.nightofnights.commands.Public;
import land.chipmunk.parker2991.nitoribot.Bot;
import land.chipmunk.parker2991.nitoribot.command.CommandContext;
import land.chipmunk.parker2991.nitoribot.command.CommandInfo;
import land.chipmunk.parker2991.nitoribot.command.CommandTrustLevels;
import land.chipmunk.parker2991.nitoribot.nightofnights.Bot;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandContext;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandInfo;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandTrustLevels;
import java.util.List;
@@ -27,6 +27,11 @@ public class EchoCommand implements CommandInfo {
return "make the bot say something";
}
@Override
public List<String> getUsages () {
return List.of("<message>");
}
@Override
public void execute (CommandContext context) {
Bot bot = context.bot();
@@ -1,17 +1,17 @@
package land.chipmunk.parker2991.nitoribot.commands.Public;
package land.chipmunk.parker2991.nitoribot.nightofnights.commands.Public;
import land.chipmunk.parker2991.nitoribot.Bot;
import land.chipmunk.parker2991.nitoribot.command.CommandContext;
import land.chipmunk.parker2991.nitoribot.command.CommandInfo;
import land.chipmunk.parker2991.nitoribot.command.CommandSource;
import land.chipmunk.parker2991.nitoribot.command.CommandTrustLevels;
import land.chipmunk.parker2991.nitoribot.nightofnights.Bot;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandContext;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandInfo;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandSource;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandTrustLevels;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.JoinConfiguration;
import java.util.ArrayList;
import java.util.List;
import static land.chipmunk.parker2991.nitoribot.util.ComponentUtil.convertColorString;
import static land.chipmunk.parker2991.nitoribot.nightofnights.util.ComponentUtil.convertColorString;
public class HelpCommand implements CommandInfo {
public HelpCommand () {
@@ -33,18 +33,19 @@ public class HelpCommand implements CommandInfo {
return "see the list of commands the bot has";
}
@Override
public List<String> getUsages () {
return List.of("<command>");
}
public Component getCommands (Bot bot) {
List<Component> Public = new ArrayList<>();
List<Component> Trusted = new ArrayList<>();
for (CommandInfo commands : bot.commandManager.commands) {
switch (commands.getTrustLevel()) {
case CommandTrustLevels.PUBLIC -> {
Public.add(Component.text(commands.getAliases().getFirst() + " ").color(convertColorString(bot.config.colors.help.Public)));
}
case CommandTrustLevels.TRUSTED -> {
Trusted.add(Component.text(commands.getAliases().getFirst() + " ").color(convertColorString(bot.config.colors.help.trusted)));
}
case CommandTrustLevels.PUBLIC -> Public.add(Component.text(commands.getAliases().getFirst() + " ").color(convertColorString(bot.config.colors.help.Public)));
case CommandTrustLevels.TRUSTED -> Trusted.add(Component.text(commands.getAliases().getFirst() + " ").color(convertColorString(bot.config.colors.help.trusted)));
default -> {
}
}
@@ -53,6 +54,23 @@ public class HelpCommand implements CommandInfo {
return Component.empty().append(Public).append(Component.text("\n")).append(Trusted);
}
private Component getUsages (Bot bot, List<String> usages) {
Component component = null;
if (usages == null) component = Component.empty().append(
Component.text("N/A").color(
convertColorString(bot.config.colors.commands.secondary)
)
);
else component = Component.empty().append(
Component.text(usages.toString()).color(
convertColorString(bot.config.colors.commands.secondary)
)
);
return component;
}
private Component getCommand (Bot bot, String[] command) {
Component component = null;
@@ -69,7 +87,7 @@ public class HelpCommand implements CommandInfo {
Component.text("Trust Level").color(convertColorString(bot.config.colors.commands.primary)),
Component.text(commands.getTrustLevel().toString()).color(convertColorString(bot.config.colors.commands.secondary)),
Component.text("Usages").color(convertColorString(bot.config.colors.commands.primary)),
Component.text("DUMMY STRING").color(convertColorString(bot.config.colors.commands.secondary))
getUsages(bot, commands.getUsages())
).color(convertColorString(bot.config.colors.commands.tertiary));
}
}
@@ -0,0 +1,168 @@
package land.chipmunk.parker2991.nitoribot.nightofnights.commands.Public;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandContext;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandError;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandInfo;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandTrustLevels;
import land.chipmunk.parker2991.nitoribot.nightofnights.data.buildstring.BotBuildInfo;
import land.chipmunk.parker2991.nitoribot.nightofnights.data.buildstring.RepoCommitInfo;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import oshi.hardware.CentralProcessor;
import oshi.hardware.HardwareAbstractionLayer;
import oshi.spi.SystemInfoFactory;
import oshi.spi.SystemInfoProvider;
import java.io.IOException;
import java.net.InetAddress;
import java.net.URL;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Enumeration;
import java.util.List;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
import static land.chipmunk.parker2991.nitoribot.nightofnights.util.ComponentUtil.convertColorString;
public class InfoCommand implements CommandInfo {
private final Enumeration<URL> resources = InfoCommand.class.getClassLoader().getResources("META-INF/MANIFEST.MF");
private final Manifest manifest = new Manifest(resources.nextElement().openStream());
private final Attributes attributes = manifest.getMainAttributes();
private final String buildTime = attributes.getValue("Build-Time");
private final String classPath = attributes.getValue("Main-Class");
public InfoCommand () throws IOException {
}
@Override
public CommandTrustLevels getTrustLevel () {
return CommandTrustLevels.PUBLIC;
}
@Override
public List<String> getAliases () {
return List.of(
"information",
"info"
);
}
@Override
public String getDescription () {
return "see the bots info";
}
public List<String> getUsages () {
return List.of(
"version",
"loaded",
"server",
"about"
);
}
private final SystemInfoProvider si = SystemInfoFactory.create();
private final long totalMemory = si.getHardware().getMemory().getTotal() / 1024 / 1024;
@Override
public void execute (CommandContext context) throws CommandError {
var bot = context.bot();
final BotBuildInfo info = bot.botBuildInfo;
var source = context.source();
var args = context.args();
Component component = null;
GsonComponentSerializer gson = GsonComponentSerializer.gson();
switch (args[0].toLowerCase()) {
case "loaded" -> component = Component.translatable(
"%s: %s\n%s: %s\n%s: %s",
Component.text("Modules").color(convertColorString(bot.config.colors.commands.primary)),
Component.text(bot.modules.size()).color(convertColorString(bot.config.colors.integer)),
Component.text("Commands").color(convertColorString(bot.config.colors.commands.primary)),
Component.text(bot.commandManager.commands.size()).color(convertColorString(bot.config.colors.integer)),
Component.text("Chat Parsers").color(convertColorString(bot.config.colors.commands.primary)),
Component.text(bot.chat.chatParsers.size()).color(convertColorString(bot.config.colors.integer))
);
case "version" -> {
RepoCommitInfo repoCommitInfo = bot.repoCommitInfo;
ZonedDateTime dateTime = ZonedDateTime.parse(repoCommitInfo.created);
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("MMMM dd, yyyy hh:mm:ss a");
component = Component.translatable(
"%s-%s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s",
gson.deserialize(info.buildstring.botName.toString()),
// Component.text(info.buildstring.version).color(convertColorString(bot.config.colors.commands.secondary)),
gson.deserialize(info.buildstring.codename.toString()),
Component.text("Build").color(convertColorString(bot.config.colors.commands.primary)),
Component.text(info.buildstring.build).color(convertColorString(bot.config.colors.integer)),
Component.text("Commit").color(convertColorString(bot.config.colors.commands.primary)),
Component.text(repoCommitInfo.sha).color(convertColorString(bot.config.colors.commands.secondary)),
Component.text("Version release Date").color(convertColorString(bot.config.colors.commands.primary)),
Component.text(dateTime.format(dateTimeFormatter)).color(convertColorString(bot.config.colors.commands.secondary)),
Component.text("Initial Bot Release").color(convertColorString(bot.config.colors.commands.primary)),
Component.text(info.buildstring.initialBotRelease).color(convertColorString(bot.config.colors.commands.secondary)),
Component.text("Jar Compile Date").color(convertColorString(bot.config.colors.commands.primary)),
Component.text(buildTime).color(convertColorString(bot.config.colors.commands.secondary)),
Component.text("Main Class Path").color(convertColorString(bot.config.colors.commands.primary)),
Component.text(classPath).color(convertColorString(bot.config.colors.commands.secondary))
).color(convertColorString(bot.config.colors.commands.tertiary));
}
case "server" -> {
try {
final String osInfo = si.getOperatingSystem().toString();
final HardwareAbstractionLayer hardware = si.getHardware();
final CentralProcessor cpuInfo = hardware.getProcessor();
final String cpuName = cpuInfo.getProcessorIdentifier().getName();
final int cpuCores = cpuInfo.getPhysicalProcessorCount();
final int processes = si.getOperatingSystem().getProcessCount();
component = Component.translatable(
"%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s",
Component.text("Hostname").color(convertColorString(bot.config.colors.commands.primary)),
Component.text(InetAddress.getLocalHost().getHostName()).color(convertColorString(bot.config.colors.commands.secondary)),
Component.text("Username").color(convertColorString(bot.config.colors.commands.primary)),
Component.text(System.getProperty("user.name")).color(convertColorString(bot.config.colors.commands.secondary)),
Component.text("Directory").color(convertColorString(bot.config.colors.commands.primary)),
Component.text(System.getProperty("user.dir")).color(convertColorString(bot.config.colors.commands.secondary)),
Component.text("CPU Arch").color(convertColorString(bot.config.colors.commands.primary)),
Component.text(System.getProperty("os.arch")).color(convertColorString(bot.config.colors.commands.secondary)),
Component.text("OS").color(convertColorString(bot.config.colors.commands.primary)),
Component.text(osInfo).color(convertColorString(bot.config.colors.commands.secondary)),
Component.text("CPU").color(convertColorString(bot.config.colors.commands.primary)),
Component.text(cpuName).color(convertColorString(bot.config.colors.commands.secondary)),
Component.text("CPU Cores").color(convertColorString(bot.config.colors.commands.primary)),
Component.text(cpuCores).color(convertColorString(bot.config.colors.integer)),
Component.text("Processes").color(convertColorString(bot.config.colors.commands.primary)),
Component.text(processes).color(convertColorString(bot.config.colors.integer)),
Component.text("Java Version").color(convertColorString(bot.config.colors.commands.primary)),
Component.text(System.getProperty("java.version")).color(convertColorString(bot.config.colors.commands.secondary)),
Component.text("Total Memory").color(convertColorString(bot.config.colors.commands.primary)),
Component.text(totalMemory + " MB").color(convertColorString(bot.config.colors.commands.secondary))
).color(convertColorString(bot.config.colors.commands.tertiary));
} catch (Exception ignore) {
}
}
case "about" -> component = Component.text(info.about).color(convertColorString(bot.config.colors.commands.primary));
default -> throw new CommandError(Component.text("Unknown Argument"));
}
source.sendFeedback(
bot,
component
);
}
}
@@ -0,0 +1,77 @@
package land.chipmunk.parker2991.nitoribot.nightofnights.commands.Public;
import land.chipmunk.parker2991.nitoribot.nightofnights.Bot;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandContext;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandInfo;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandSource;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandTrustLevels;
import land.chipmunk.parker2991.nitoribot.nightofnights.data.PlayerProfileData;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.JoinConfiguration;
import net.kyori.adventure.text.format.NamedTextColor;
import java.util.ArrayList;
import java.util.List;
import static land.chipmunk.parker2991.nitoribot.nightofnights.util.ComponentUtil.convertColorString;
public class ListCommand implements CommandInfo {
@Override
public CommandTrustLevels getTrustLevel () {
return CommandTrustLevels.PUBLIC;
}
@Override
public List<String> getAliases () {
return List.of("list", "pl", "playerlist");
}
@Override
public String getDescription () {
return "see the list of players";
}
@Override
public List<String> getUsages () {
return null;
}
@Override
public void execute (CommandContext context) {
Bot bot = context.bot();
CommandSource source = context.source();
Component component = null;
Component playerComponent = null;
List<Component> playersComponent = new ArrayList<>();
playerComponent = Component.translatable(
"%s: (%s)\n",
Component.text("Players").color(convertColorString(bot.config.colors.commands.primary)),
Component.text(bot.players.list.size()).color(convertColorString(bot.config.colors.integer))
).color(convertColorString(bot.config.colors.commands.tertiary));
for (PlayerProfileData player : bot.players.list) {
//TranslatableComponent displayName = (TranslatableComponent) player.displayName();
playersComponent.add(
Component.translatable(
"%s › %s",
player.displayName.color(NamedTextColor.WHITE),
Component.text(player.uuid.toString()).color(convertColorString(bot.config.colors.commands.secondary))
).color(convertColorString(bot.config.colors.commands.tertiary))
);
}
component = Component.empty().append(
playerComponent
).append(
Component.join(
JoinConfiguration.newlines(),
playersComponent
)
);
source.sendFeedback(bot, Component.empty().append(component));
}
}
@@ -1,8 +1,8 @@
package land.chipmunk.parker2991.nitoribot.commands.Public;
package land.chipmunk.parker2991.nitoribot.nightofnights.commands.Public;
import land.chipmunk.parker2991.nitoribot.command.CommandContext;
import land.chipmunk.parker2991.nitoribot.command.CommandInfo;
import land.chipmunk.parker2991.nitoribot.command.CommandTrustLevels;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandContext;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandInfo;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandTrustLevels;
import java.util.List;
@@ -26,6 +26,11 @@ public class MCServerCommand implements CommandInfo {
return "ping minecraft servers";
}
@Override
public List<String> getUsages () {
return List.of("<ip>:<port>");
}
@Override
public void execute (CommandContext context) {
var bot = context.bot();
@@ -0,0 +1,61 @@
package land.chipmunk.parker2991.nitoribot.nightofnights.commands.Public;
import land.chipmunk.parker2991.nitoribot.nightofnights.Bot;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandContext;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandInfo;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandSource;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandTrustLevels;
import land.chipmunk.parker2991.nitoribot.nightofnights.data.PlayerProfileData;
import net.kyori.adventure.text.Component;
import java.util.List;
import static land.chipmunk.parker2991.nitoribot.nightofnights.util.ComponentUtil.convertColorString;
public class PlayerInfoCommand implements CommandInfo {
@Override
public CommandTrustLevels getTrustLevel () {
return CommandTrustLevels.PUBLIC;
}
@Override
public List<String> getAliases () {
return List.of("playerinfo", "getplayer");
}
@Override
public String getDescription () {
return "get the info of a player";
}
@Override
public List<String> getUsages () {
return List.of("<username>", "<uuid>");
}
@Override
public void execute (CommandContext context) {
Bot bot = context.bot();
String[] args = context.args();
CommandSource source = context.source();
Component component = null;
for (PlayerProfileData player : bot.players.list) {
if (player.profile.getName().equals(args[0])) component = Component.translatable(
"%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s",
Component.text("Player").color(convertColorString(bot.config.colors.commands.primary)),
player.displayName,
Component.text("UUID").color(convertColorString(bot.config.colors.commands.primary)),
Component.text(player.uuid.toString()).color(convertColorString(bot.config.colors.commands.secondary)),
Component.text("Position").color(convertColorString(bot.config.colors.commands.primary)),
Component.text(player.position.toString()).color(convertColorString(bot.config.colors.commands.secondary)),
Component.text("Latency").color(convertColorString(bot.config.colors.commands.primary)),
Component.text(player.latency + "ms").color(convertColorString(bot.config.colors.commands.secondary)),
Component.text("GameMode").color(convertColorString(bot.config.colors.commands.primary)),
Component.text(player.gameMode.toString()).color(convertColorString(bot.config.colors.commands.secondary))
).color(convertColorString(bot.config.colors.commands.tertiary));
}
source.sendFeedback(bot, component);
}
}
@@ -1,15 +1,15 @@
package land.chipmunk.parker2991.nitoribot.commands.Public;
package land.chipmunk.parker2991.nitoribot.nightofnights.commands.Public;
import land.chipmunk.parker2991.nitoribot.Bot;
import land.chipmunk.parker2991.nitoribot.command.CommandContext;
import land.chipmunk.parker2991.nitoribot.command.CommandInfo;
import land.chipmunk.parker2991.nitoribot.command.CommandSource;
import land.chipmunk.parker2991.nitoribot.command.CommandTrustLevels;
import land.chipmunk.parker2991.nitoribot.nightofnights.Bot;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandContext;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandInfo;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandSource;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandTrustLevels;
import net.kyori.adventure.text.Component;
import java.util.List;
import static land.chipmunk.parker2991.nitoribot.util.ComponentUtil.convertColorString;
import static land.chipmunk.parker2991.nitoribot.nightofnights.util.ComponentUtil.convertColorString;
public class RCCommand implements CommandInfo {
public RCCommand () {
@@ -30,6 +30,11 @@ public class RCCommand implements CommandInfo {
return "refill the bots core";
}
@Override
public List<String> getUsages () {
return null;
}
@Override
public void execute (CommandContext context) {
Bot bot = context.bot();
@@ -1,10 +1,11 @@
package land.chipmunk.parker2991.nitoribot.commands.Public;
package land.chipmunk.parker2991.nitoribot.nightofnights.commands.Public;
import land.chipmunk.parker2991.nitoribot.command.CommandContext;
import land.chipmunk.parker2991.nitoribot.command.CommandInfo;
import land.chipmunk.parker2991.nitoribot.command.CommandTrustLevels;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandContext;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandInfo;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandTrustLevels;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.cloudburstmc.math.vector.Vector3i;
import java.util.List;
@@ -37,26 +38,18 @@ public class TestCommand implements CommandInfo {
return "test cmd";
}
@Override
public List<String> getUsages () {
return null;
}
@Override
public void execute (CommandContext context) {
var bot = context.bot();
var args = String.join(" ", context.args());
String[] args = context.args();
var source = context.source();
var component = MINI_MESSAGE.deserialize(String.format(
"%s%s %s %s %s %s %s%s%s",
"<gradient:dark_aqua:aqua:blue:dark_blue:light_purple:dark_purple>", // gradient shenanigans
"Hello World! User:",
source.sender().profile().getName(),
"UUID:",
source.sender().uuid(),
"Args:",
"<rainbow>", // we gotta turn the arguments gay!
args,
"</gradient>"
));
source.sendFeedback(bot, component);
bot.world.getBlock(Vector3i.from(Integer.parseInt(args[0]), Integer.parseInt(args[1]), Integer.parseInt(args[2])));
}
}
@@ -1,9 +1,9 @@
package land.chipmunk.parker2991.nitoribot.commands.trusted;
package land.chipmunk.parker2991.nitoribot.nightofnights.commands.trusted;
import land.chipmunk.parker2991.nitoribot.Bot;
import land.chipmunk.parker2991.nitoribot.command.CommandContext;
import land.chipmunk.parker2991.nitoribot.command.CommandInfo;
import land.chipmunk.parker2991.nitoribot.command.CommandTrustLevels;
import land.chipmunk.parker2991.nitoribot.nightofnights.Bot;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandContext;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandInfo;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandTrustLevels;
import java.util.List;
@@ -22,6 +22,11 @@ public class ReconnectCommand implements CommandInfo {
return List.of("end");
}
@Override
public List<String> getUsages () {
return null;
}
@Override
public String getDescription () {
return "reconnect the bot";
@@ -0,0 +1,18 @@
package land.chipmunk.parker2991.nitoribot.nightofnights.data;
import java.util.ArrayList;
import java.util.List;
public class ChatTranslationsData {
public static class Narration {
public String translation_key;
public List<String> parameters = new ArrayList<>();
}
public static class Chat {
public String translation_key;
public List<String> parameters = new ArrayList<>();
public Narration narration = new Narration();
}
public final Chat chat = new Chat();
}
@@ -0,0 +1,5 @@
package land.chipmunk.parker2991.nitoribot.nightofnights.data;
public enum ChatType {
PLAYER, SYSTEM, DISGUISED
}
@@ -0,0 +1,6 @@
package land.chipmunk.parker2991.nitoribot.nightofnights.data;
import org.cloudburstmc.math.vector.Vector3i;
public record CommandCoreAreaData(Vector3i start, Vector3i end) {
}
@@ -0,0 +1,5 @@
package land.chipmunk.parker2991.nitoribot.nightofnights.data;
public enum ParsedChatType {
COMMANDSPY, NORMAL
}
@@ -1,4 +1,4 @@
package land.chipmunk.parker2991.nitoribot.data;
package land.chipmunk.parker2991.nitoribot.nightofnights.data;
import net.kyori.adventure.text.Component;
@@ -0,0 +1,52 @@
package land.chipmunk.parker2991.nitoribot.nightofnights.data;
import net.kyori.adventure.text.Component;
import org.cloudburstmc.math.vector.Vector3d;
import org.geysermc.mcprotocollib.auth.GameProfile;
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.GameMode;
import java.util.UUID;
public class PlayerProfileData {
public UUID uuid;
public String entityUUID;
public GameProfile profile;
public boolean listed;
public int latency;
public GameMode gameMode;
public Component displayName;
public boolean showHat;
public int listOrder;
public Vector3d position;
public String dimension;
public int entityId;
public PlayerProfileData (
UUID uuid,
String entityUUID,
GameProfile profile,
boolean listed,
int latency,
GameMode gameMode,
Component displayName,
boolean showHat,
int listOrder,
Vector3d position,
String dimension,
int entityId
) {
this.uuid = uuid;
this.entityUUID = entityUUID;
this.profile = profile;
this.listed = listed;
this.latency = latency;
this.gameMode = gameMode;
this.displayName = displayName;
this.showHat = showHat;
this.listOrder = listOrder;
this.position = position;
this.dimension = dimension;
this.entityId = entityId;
}
}
@@ -0,0 +1,6 @@
package land.chipmunk.parker2991.nitoribot.nightofnights.data;
import org.cloudburstmc.math.vector.Vector3d;
public record PositionData(Vector3d position) {
}
@@ -1,10 +1,11 @@
package land.chipmunk.parker2991.nitoribot.data.buildstring;
package land.chipmunk.parker2991.nitoribot.nightofnights.data.buildstring;
import com.google.gson.JsonObject;
import java.util.List;
public class BotBuildInfo {
public String about;
public final BuildInfo buildstring = new BuildInfo();
public String owner;
public Contributors[] contributors = new Contributors[]{};
@@ -1,4 +1,4 @@
package land.chipmunk.parker2991.nitoribot.data.buildstring;
package land.chipmunk.parker2991.nitoribot.nightofnights.data.buildstring;
public class RepoCommitInfo {
public String sha;
@@ -0,0 +1,8 @@
package land.chipmunk.parker2991.nitoribot.nightofnights.data.chat;
import land.chipmunk.parker2991.nitoribot.nightofnights.data.ChatType;
import net.kyori.adventure.text.Component;
public interface ParseChatData {
PlayerMessageData parse (ChatType chatType, Component message);
}
@@ -0,0 +1,8 @@
package land.chipmunk.parker2991.nitoribot.nightofnights.data.chat;
import land.chipmunk.parker2991.nitoribot.nightofnights.data.ChatType;
import land.chipmunk.parker2991.nitoribot.nightofnights.data.PlayerProfileData;
import net.kyori.adventure.text.Component;
public record PlayerMessageData(PlayerProfileData sender, Component contents, ChatType chatType, Component senderName) {
}
@@ -0,0 +1,8 @@
package land.chipmunk.parker2991.nitoribot.nightofnights.data.world;
import java.util.List;
public record BlockData (String block, int id, List<Integer> stateIds) {
public void stateIds (List<Integer> stateIds) {
}
}
@@ -0,0 +1,5 @@
package land.chipmunk.parker2991.nitoribot.nightofnights.data.world;
public record ChunkData (ChunkPosData chunkPos, byte[] data, int maxHeight, int minY) {
}
@@ -0,0 +1,4 @@
package land.chipmunk.parker2991.nitoribot.nightofnights.data.world;
public record ChunkPosData(int x, int z) {
}
@@ -1,4 +1,4 @@
package land.chipmunk.parker2991.nitoribot.data;
package land.chipmunk.parker2991.nitoribot.nightofnights.data.world;
public record DimensionData(String dimension, int maxHeight, int minHeight) {
}
@@ -1,7 +1,7 @@
package land.chipmunk.parker2991.nitoribot.selfcare.entity;
package land.chipmunk.parker2991.nitoribot.nightofnights.entity;
import land.chipmunk.parker2991.nitoribot.Bot;
import land.chipmunk.parker2991.nitoribot.listeners.Listener;
import land.chipmunk.parker2991.nitoribot.nightofnights.Bot;
import land.chipmunk.parker2991.nitoribot.nightofnights.listeners.Listener;
import org.geysermc.mcprotocollib.network.packet.Packet;
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.GameMode;
import org.geysermc.mcprotocollib.protocol.data.game.level.notify.GameEvent;
@@ -1,7 +1,7 @@
package land.chipmunk.parker2991.nitoribot.selfcare.entity;
package land.chipmunk.parker2991.nitoribot.nightofnights.entity;
import land.chipmunk.parker2991.nitoribot.Bot;
import land.chipmunk.parker2991.nitoribot.listeners.Listener;
import land.chipmunk.parker2991.nitoribot.nightofnights.Bot;
import land.chipmunk.parker2991.nitoribot.nightofnights.listeners.Listener;
import org.geysermc.mcprotocollib.network.packet.Packet;
import org.geysermc.mcprotocollib.protocol.data.game.entity.EntityEvent;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.ClientboundEntityEventPacket;
@@ -1,9 +1,10 @@
package land.chipmunk.parker2991.nitoribot.listeners;
package land.chipmunk.parker2991.nitoribot.nightofnights.listeners;
import land.chipmunk.parker2991.nitoribot.data.PlayerProfileData;
import land.chipmunk.parker2991.nitoribot.data.chat.PlayerMessageData;
import land.chipmunk.parker2991.nitoribot.nightofnights.data.PlayerProfileData;
import land.chipmunk.parker2991.nitoribot.nightofnights.data.chat.PlayerMessageData;
import net.kyori.adventure.text.Component;
import org.geysermc.mcprotocollib.network.packet.Packet;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.level.ClientboundTagQueryPacket;
public interface Listener {
default void packetSent () {
@@ -29,4 +30,6 @@ public interface Listener {
default void commandSpyReceived (PlayerProfileData player, String command) {
}
default void tabCompleteReceived (ClientboundTagQueryPacket packet) {}
}
@@ -1,4 +1,4 @@
package land.chipmunk.parker2991.nitoribot.listeners;
package land.chipmunk.parker2991.nitoribot.nightofnights.listeners;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -1,8 +1,8 @@
package land.chipmunk.parker2991.nitoribot.logger;
package land.chipmunk.parker2991.nitoribot.nightofnights.logger;
import land.chipmunk.parker2991.nitoribot.Bot;
import land.chipmunk.parker2991.nitoribot.Main;
import land.chipmunk.parker2991.nitoribot.util.ComponentUtil;
import land.chipmunk.parker2991.nitoribot.nightofnights.Bot;
import land.chipmunk.parker2991.nitoribot.nightofnights.Main;
import land.chipmunk.parker2991.nitoribot.nightofnights.util.ComponentUtil;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -1,4 +1,4 @@
package land.chipmunk.parker2991.nitoribot.logger;
package land.chipmunk.parker2991.nitoribot.nightofnights.logger;
public enum LoggerType {
LOG, DEBUG, INFO, COMMAND, WARN, ERROR, RECONNECT,
@@ -1,13 +1,13 @@
package land.chipmunk.parker2991.nitoribot.modules;
package land.chipmunk.parker2991.nitoribot.nightofnights.modules;
import land.chipmunk.parker2991.nitoribot.Bot;
import land.chipmunk.parker2991.nitoribot.Config;
import land.chipmunk.parker2991.nitoribot.command.CommandSource;
import land.chipmunk.parker2991.nitoribot.data.ParsedChatType;
import land.chipmunk.parker2991.nitoribot.data.PlayerProfileData;
import land.chipmunk.parker2991.nitoribot.data.chat.PlayerMessageData;
import land.chipmunk.parker2991.nitoribot.listeners.Listener;
import land.chipmunk.parker2991.nitoribot.util.ComponentUtil;
import land.chipmunk.parker2991.nitoribot.nightofnights.Bot;
import land.chipmunk.parker2991.nitoribot.nightofnights.Config;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandSource;
import land.chipmunk.parker2991.nitoribot.nightofnights.data.ParsedChatType;
import land.chipmunk.parker2991.nitoribot.nightofnights.data.PlayerProfileData;
import land.chipmunk.parker2991.nitoribot.nightofnights.data.chat.PlayerMessageData;
import land.chipmunk.parker2991.nitoribot.nightofnights.listeners.Listener;
import land.chipmunk.parker2991.nitoribot.nightofnights.util.ComponentUtil;
import org.jetbrains.annotations.NotNull;
import java.util.List;
@@ -25,8 +25,6 @@ public class ChatCommandHandlerModule implements Listener {
@Override
public void parsedMessage (PlayerMessageData data) {
if (!data.chatType().equals("minecraft:chat")) return;
List<String> prefixes = config.prefixes;
for (String prefix : prefixes) {
@@ -1,12 +1,14 @@
package land.chipmunk.parker2991.nitoribot.modules;
package land.chipmunk.parker2991.nitoribot.nightofnights.modules;
import land.chipmunk.parker2991.nitoribot.Bot;
import land.chipmunk.parker2991.nitoribot.chatparsers.KaboomChatParser;
import land.chipmunk.parker2991.nitoribot.data.chat.ParseChatData;
import land.chipmunk.parker2991.nitoribot.data.chat.PlayerMessageData;
import land.chipmunk.parker2991.nitoribot.listeners.Listener;
import land.chipmunk.parker2991.nitoribot.nightofnights.Bot;
import land.chipmunk.parker2991.nitoribot.nightofnights.chatparsers.KaboomChatParser;
import land.chipmunk.parker2991.nitoribot.nightofnights.data.ChatTranslationsData;
import land.chipmunk.parker2991.nitoribot.nightofnights.data.ChatType;
import land.chipmunk.parker2991.nitoribot.nightofnights.data.chat.ParseChatData;
import land.chipmunk.parker2991.nitoribot.nightofnights.data.chat.PlayerMessageData;
import land.chipmunk.parker2991.nitoribot.nightofnights.listeners.Listener;
import land.chipmunk.parker2991.nitoribot.nightofnights.util.ComponentUtil;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import org.geysermc.mcprotocollib.network.packet.Packet;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundDisguisedChatPacket;
@@ -16,6 +18,7 @@ import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.Serverbound
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.ServerboundChatPacket;
import java.time.Instant;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.List;
import java.util.Objects;
@@ -44,8 +47,13 @@ public class ChatModule implements Listener {
}
public String parseChatTypes (int chatType) {
List<String> translations = new ArrayList<>();
return bot.registry.chatTypes.get(chatType);
for (ChatTranslationsData translation : bot.registry.chatTypes) {
translations.add(translation.chat.translation_key);
}
return translations.get(chatType);
}
public void systemChat (ClientboundSystemChatPacket packet) {
@@ -74,17 +82,18 @@ public class ChatModule implements Listener {
listener.disguisedChatReceived(message);
}
TextComponent textComponent = (TextComponent) targetUsername;
parseMessage(
ChatType.DISGUISED,
message,
new PlayerMessageData(
bot.players.getPlayerByUsername(textComponent.content()),
bot.players.getPlayerByUsername(ComponentUtil.componentToString(packet.getName())),
packet.getMessage(),
"minecraft:chat",
Objects.requireNonNull(bot.players.getPlayerByUsername(textComponent.content())).displayName()
ChatType.DISGUISED,
packet.getName()
)
);
}
public void playerChat (ClientboundPlayerChatPacket packet) {
@@ -96,29 +105,35 @@ public class ChatModule implements Listener {
}
parseMessage(
ChatType.PLAYER,
unsignedContent,
new PlayerMessageData(
bot.players.getPlayerUUID(packet.getSender()),
content,
"minecraft:chat",
Objects.requireNonNull(bot.players.getPlayerUUID(packet.getSender())).displayName()
content, ChatType.PLAYER,
Objects.requireNonNull(bot.players.getPlayerUUID(packet.getSender())).displayName
)
);
}
public void parseMessage (Component message, PlayerMessageData data) {
public void parseMessage (ChatType chatType, Component message, PlayerMessageData data) {
try {
PlayerMessageData parsed = null;
for (ParseChatData parser : chatParsers) {
parsed = parser.parse(message);
parsed = parser.parse(chatType, message);
if (parsed != null) break;
}
if (parsed == null) return;
for (Listener listener : bot.listenerManager.listeners) {
listener.parsedMessage(data);
if (data.chatType() == ChatType.DISGUISED) {
final PlayerMessageData playerMessageData = new PlayerMessageData(parsed.sender(), parsed.contents(), ChatType.DISGUISED, data.senderName());
listener.parsedMessage(playerMessageData);
}
else listener.parsedMessage(data);
}
} catch (Exception ignore) {
@@ -0,0 +1,348 @@
package land.chipmunk.parker2991.nitoribot.nightofnights.modules;
import land.chipmunk.parker2991.nitoribot.nightofnights.Bot;
import land.chipmunk.parker2991.nitoribot.nightofnights.data.CommandCoreAreaData;
import land.chipmunk.parker2991.nitoribot.nightofnights.listeners.Listener;
import land.chipmunk.parker2991.nitoribot.nightofnights.util.ComponentUtil;
import net.kyori.adventure.text.BlockNBTComponent;
import net.kyori.adventure.text.Component;
import org.cloudburstmc.math.vector.Vector3d;
import org.cloudburstmc.math.vector.Vector3i;
import org.cloudburstmc.nbt.NbtMap;
import org.cloudburstmc.nbt.NbtMapBuilder;
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.*;
import org.geysermc.mcprotocollib.protocol.data.game.level.block.BlockEntityType;
import org.geysermc.mcprotocollib.protocol.data.game.level.block.CommandBlockMode;
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 java.util.HashMap;
import java.util.Map;
public class CommandCoreModule implements Listener {
private final Bot bot;
public Vector3i position;
public Vector3i itemPosition;
public final CommandCoreAreaData area;
public Vector3i lastBlockPosition;
public Vector3i currentBlockRelative = Vector3i.from(
0,
0,
0
);
public CommandCoreModule (Bot bot) {
this.bot = bot;
this.area = new CommandCoreAreaData(
Vector3i.from(
bot.config.core.area.start.x,
bot.config.core.area.start.y,
bot.config.core.area.start.z
),
Vector3i.from(
bot.config.core.area.end.x,
bot.config.core.area.end.y,
bot.config.core.area.end.z
)
);
bot.listenerManager.addListener(this);
}
@Override
public void packetReceived (Packet packet) {
}
@Override
public void botMoved () {
move();
}
public void move () {
Vector3d botPos = bot.position.positionData;
position = Vector3i.from(
Math.floor(botPos.getX() / 16) * 16,
0,
Math.floor(botPos.getZ() / 16) * 16
);
itemPosition = Vector3i.from(
Math.floor(botPos.getX()),
Math.floor(botPos.getY() - 1),
Math.floor(botPos.getZ())
);
if (bot.config.core.itemRefill) itemRefill();
else chatRefill();
}
public void chatRefill () {
bot.chat.command(getCommand());
}
public void itemRefill () {
final NbtMapBuilder blockEntityTagBuilder = NbtMap.builder();
String command = getCommand();
final NbtMap blockEntityTag = blockEntityTagBuilder.build();
final Map<DataComponentType<?>, DataComponent<?, ?>> map = new HashMap<>();
map.put(
DataComponentTypes.BLOCK_ENTITY_DATA,
DataComponentTypes.BLOCK_ENTITY_DATA.getDataComponentFactory().create(
DataComponentTypes.BLOCK_ENTITY_DATA,
TypedEntityData.<BlockEntityType>builder().type(BlockEntityType.COMMAND_BLOCK).tag(blockEntityTag).build()
)
);
map.put(
DataComponentTypes.ITEM_NAME,
DataComponentTypes.ITEM_NAME.getDataComponentFactory().create(
DataComponentTypes.ITEM_NAME,
ComponentUtil.componentFromJSON(bot.config.core.coreName)
)
);
map.put(
DataComponentTypes.CUSTOM_NAME,
DataComponentTypes.CUSTOM_NAME.getDataComponentFactory().create(
DataComponentTypes.CUSTOM_NAME,
ComponentUtil.componentFromJSON(bot.config.core.coreName)
)
);
final DataComponents dataComponents = new DataComponents(map);
bot.session.send(new ServerboundSetCreativeModeSlotPacket(
(short) 36,
new ItemStack(
482,
64,
dataComponents
)
));
bot.session.send(new ServerboundPlayerActionPacket(
PlayerAction.START_DIGGING,
itemPosition,
Direction.NORTH,
0
));
bot.session.send(new ServerboundUseItemOnPacket(
itemPosition,
Direction.UP,
Hand.MAIN_HAND,
0.5f,
0.5f,
0.5f,
true,
false,
420
));
commandBlock(
itemPosition,
command,
true,
false,
true
);
Vector3i pos = Vector3i.from(
itemPosition.getX(),
itemPosition.getY(),
itemPosition.getZ()
);
/*bot.world.getBlock(pos).thenApply((packet) -> {
try {
@Nullable NbtMap nbt = packet.getNbt();
if (nbt == null) bot.core.chatRefill();
} catch (Exception e) {
e.printStackTrace(System.err);
}
return packet;
});*/
}
private String getCommand () {
Vector3i areaStart = area.start();
Vector3i areaEnd = area.end();
return String.format(
"minecraft:fill %s %s %s %s %s %s command_block{CustomName:%s} destroy",
position.getX() + areaStart.getX(),
position.getY() + areaStart.getY(),
position.getZ() + areaStart.getZ(),
position.getX() + areaEnd.getX(),
position.getY() + areaEnd.getY(),
position.getZ() + areaEnd.getZ(),
bot.config.core.coreName
);
}
public Vector3i currentBlock () {
if (position == null) return null;
return Vector3i.from(
currentBlockRelative.getX() + position.getX(),
currentBlockRelative.getY() + position.getY(),
currentBlockRelative.getZ() + position.getZ()
);
}
private void incrementCurrentBlock () {
currentBlockRelative = currentBlockRelative.add(
1,
0,
0
);
if (currentBlockRelative.getX() > area.end().getX()) {
currentBlockRelative = currentBlockRelative.add(
area.start().getX() - area.end().getX(),
0,
0
);
currentBlockRelative = currentBlockRelative.add(
0,
0,
1
);
}
if (currentBlockRelative.getZ() > area.end().getZ()) {
currentBlockRelative = currentBlockRelative.add(
0,
0,
area.start().getZ() - area.end().getZ()
);
currentBlockRelative = currentBlockRelative.add(
0,
1,
0
);
}
if (currentBlockRelative.getX() > area.end().getX()) {
currentBlockRelative = currentBlockRelative.add(
area.start().getX() - area.end().getX(),
area.start().getY() - area.end().getY(),
area.start().getZ() - area.end().getZ()
);
}
}
private void commandBlock (
Vector3i pos,
String command,
boolean doesTrackOutput,
boolean conditional,
boolean automatic
) {
if (command.length() > 32767 || position == null) return;
bot.session.send(new ServerboundSetCommandBlockPacket(
pos,
command,
CommandBlockMode.AUTO,
doesTrackOutput,
conditional,
automatic
));
}
public void run (String command) {
commandBlock(
currentBlock(),
command,
true,
false,
true
);
incrementCurrentBlock();
}
public Component runTrackedWithTellraw (String tag, String selector, String command) {
commandBlock(
currentBlock(),
command,
true,
false,
true
);
lastBlockPosition = Vector3i.from(
currentBlock().getX(),
currentBlock().getY(),
currentBlock().getZ()
);
Component nbtComponent = Component.blockNBT(
"LastOutput.extra",
true,
BlockNBTComponent.WorldPos.worldPos(
BlockNBTComponent.WorldPos.Coordinate.absolute(lastBlockPosition.getX()),
BlockNBTComponent.WorldPos.Coordinate.absolute(lastBlockPosition.getY()),
BlockNBTComponent.WorldPos.Coordinate.absolute(lastBlockPosition.getZ())
)
).insertion(tag);
Component component = Component.empty().append(nbtComponent).append(Component.text().insertion(selector));
incrementCurrentBlock();
return component;
}
/*public void runTrackedWithPacket (String command) {
List<NbtMap> output = new ArrayList<>();
commandBlock(
currentBlock(),
command,
true,
false,
true
);
CompletableFuture.runAsync(
() -> {
bot.world.getBlock(currentBlock()).thenApplyAsync((packet) -> {
try {
if (packet.getTransactionId() == bot.world.transactionId) {
NbtMap nbt = packet.getNbt();
Object json = packet.getNbt().get("LastOutput");
if (json != null) {
JsonObject nbtParsed = NbtMapToJson.INSTANCE.convert((NbtMap) json);
System.out.println(nbtParsed.toString());
}
}
} catch (Exception e) {
e.printStackTrace(System.err);
}
return packet;
});
// System.out.println(cmdBlockOutput.join());
// incrementCurrentBlock();
//return null;
},
CompletableFuture.delayedExecutor(
50,
TimeUnit.MILLISECONDS
)
);
}*/
}
@@ -1,21 +1,19 @@
package land.chipmunk.parker2991.nitoribot.modules;
package land.chipmunk.parker2991.nitoribot.nightofnights.modules;
import land.chipmunk.parker2991.nitoribot.Bot;
import land.chipmunk.parker2991.nitoribot.command.CommandContext;
import land.chipmunk.parker2991.nitoribot.command.CommandError;
import land.chipmunk.parker2991.nitoribot.command.CommandInfo;
import land.chipmunk.parker2991.nitoribot.command.CommandSource;
import land.chipmunk.parker2991.nitoribot.commands.Public.*;
import land.chipmunk.parker2991.nitoribot.commands.trusted.ReconnectCommand;
import land.chipmunk.parker2991.nitoribot.logger.Logger;
import land.chipmunk.parker2991.nitoribot.util.ErrorToString;
import land.chipmunk.parker2991.nitoribot.nightofnights.Bot;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandContext;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandError;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandInfo;
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandSource;
import land.chipmunk.parker2991.nitoribot.nightofnights.commands.Public.*;
import land.chipmunk.parker2991.nitoribot.nightofnights.commands.trusted.ReconnectCommand;
import land.chipmunk.parker2991.nitoribot.nightofnights.logger.Logger;
import land.chipmunk.parker2991.nitoribot.nightofnights.util.ErrorToString;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.*;
public class CommandManagerModule {
public final List<CommandInfo> commands = new ArrayList<>();
@@ -23,7 +21,6 @@ public class CommandManagerModule {
public CommandManagerModule (Bot bot) throws IOException {
this.bot = bot;
registerCommand(new EchoCommand());
registerCommand(new HelpCommand());
registerCommand(new ReconnectCommand());
@@ -31,10 +28,14 @@ public class CommandManagerModule {
registerCommand(new MCServerCommand());
registerCommand(new TestCommand());
registerCommand(new InfoCommand());
registerCommand(new ListCommand());
registerCommand(new PlayerInfoCommand());
registerCommand(new CoreCommand());
}
public void registerCommand (CommandInfo command) {
commands.add(command);
commands.sort(Comparator.comparing((commands) -> commands.getAliases().getFirst()));
}
public CommandInfo getCommand (String getCommand) {
@@ -60,7 +61,7 @@ public class CommandManagerModule {
CommandContext context = new CommandContext(bot, args, source);
command.execute(context);
command. execute(context);
} catch (CommandError error) {
source.sendFeedback(bot, error.message());
} catch (Exception error) {
@@ -1,8 +1,8 @@
package land.chipmunk.parker2991.nitoribot.modules;
package land.chipmunk.parker2991.nitoribot.nightofnights.modules;
import land.chipmunk.parker2991.nitoribot.Bot;
import land.chipmunk.parker2991.nitoribot.data.PlayerProfileData;
import land.chipmunk.parker2991.nitoribot.listeners.Listener;
import land.chipmunk.parker2991.nitoribot.nightofnights.Bot;
import land.chipmunk.parker2991.nitoribot.nightofnights.data.PlayerProfileData;
import land.chipmunk.parker2991.nitoribot.nightofnights.listeners.Listener;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import org.jetbrains.annotations.Unmodifiable;
@@ -30,7 +30,7 @@ public class CommandSpyModule implements Listener {
PlayerProfileData sender = null;
for (PlayerProfileData player : bot.players.list) {
String username = player.profile().getName();
String username = player.profile.getName();
if (username.equals(userComponent.content())) sender = player;
}
@@ -1,7 +1,7 @@
package land.chipmunk.parker2991.nitoribot.modules;
package land.chipmunk.parker2991.nitoribot.nightofnights.modules;
import land.chipmunk.parker2991.nitoribot.Bot;
import land.chipmunk.parker2991.nitoribot.Main;
import land.chipmunk.parker2991.nitoribot.nightofnights.Bot;
import land.chipmunk.parker2991.nitoribot.nightofnights.Main;
import org.jline.reader.*;
import java.util.List;
@@ -1,9 +1,9 @@
package land.chipmunk.parker2991.nitoribot.modules;
package land.chipmunk.parker2991.nitoribot.nightofnights.modules;
import land.chipmunk.parker2991.nitoribot.Bot;
import land.chipmunk.parker2991.nitoribot.listeners.Listener;
import land.chipmunk.parker2991.nitoribot.logger.Logger;
import land.chipmunk.parker2991.nitoribot.util.ComponentUtil;
import land.chipmunk.parker2991.nitoribot.nightofnights.Bot;
import land.chipmunk.parker2991.nitoribot.nightofnights.listeners.Listener;
import land.chipmunk.parker2991.nitoribot.nightofnights.logger.Logger;
import land.chipmunk.parker2991.nitoribot.nightofnights.util.ComponentUtil;
import net.kyori.adventure.text.Component;
public class LoggingModule implements Listener {
@@ -1,7 +1,7 @@
package land.chipmunk.parker2991.nitoribot.modules;
package land.chipmunk.parker2991.nitoribot.nightofnights.modules;
import land.chipmunk.parker2991.nitoribot.Bot;
import land.chipmunk.parker2991.nitoribot.data.PingServerData;
import land.chipmunk.parker2991.nitoribot.nightofnights.Bot;
import land.chipmunk.parker2991.nitoribot.nightofnights.data.PingServerData;
import org.geysermc.mcprotocollib.auth.SessionService;
import org.geysermc.mcprotocollib.network.ClientSession;
import org.geysermc.mcprotocollib.network.Session;
@@ -1,10 +1,10 @@
package land.chipmunk.parker2991.nitoribot.modules;
package land.chipmunk.parker2991.nitoribot.nightofnights.modules;
import land.chipmunk.parker2991.nitoribot.Bot;
import land.chipmunk.parker2991.nitoribot.data.PlayerProfileData;
import land.chipmunk.parker2991.nitoribot.data.PositionData;
import land.chipmunk.parker2991.nitoribot.listeners.Listener;
import land.chipmunk.parker2991.nitoribot.nightofnights.Bot;
import land.chipmunk.parker2991.nitoribot.nightofnights.data.PlayerProfileData;
import land.chipmunk.parker2991.nitoribot.nightofnights.listeners.Listener;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import org.cloudburstmc.math.vector.Vector3d;
import org.geysermc.mcprotocollib.network.packet.Packet;
import org.geysermc.mcprotocollib.protocol.data.game.PlayerListEntry;
@@ -12,6 +12,7 @@ import org.geysermc.mcprotocollib.protocol.data.game.PlayerListEntryAction;
import org.geysermc.mcprotocollib.protocol.data.game.entity.type.EntityType;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundPlayerInfoRemovePacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundPlayerInfoUpdatePacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundSystemChatPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.ClientboundAddEntityPacket;
import org.jetbrains.annotations.Nullable;
@@ -21,10 +22,12 @@ import java.util.List;
import java.util.UUID;
public class PlayerListModule implements Listener {
private final Bot bot;
public final List<PlayerProfileData> list = new ArrayList<>();
public PlayerListModule (Bot bot) {
this.bot = bot;
bot.listenerManager.addListener(this);
}
@@ -34,11 +37,22 @@ public class PlayerListModule implements Listener {
case ClientboundPlayerInfoUpdatePacket p -> playerInfo(p);
case ClientboundPlayerInfoRemovePacket p -> playerRemove(p);
case ClientboundAddEntityPacket p -> getPlayerPosition(p);
case ClientboundSystemChatPacket p -> systemChatReceived(p);
default -> {
}
}
}
public void systemChatReceived (ClientboundSystemChatPacket packet) {
try {
if (!(packet.getContent() instanceof TextComponent component)) return;
// if (component.insertion().equals("nitoribot.player.ip")) {
//}
} catch (Exception ignore) {
}
}
public void playerInfo (ClientboundPlayerInfoUpdatePacket packet) {
EnumSet<PlayerListEntryAction> actions = packet.getActions();
@@ -60,13 +74,16 @@ public class PlayerListModule implements Listener {
if (packet.getType() == EntityType.PLAYER) {
UUID uuid = packet.getUuid();
int entityId = packet.getEntityId();
Vector3d playerPosition = Vector3d.from(packet.getX(), packet.getY(), packet.getZ());
float yaw = packet.getYaw();
float pitch = packet.getPitch();
Vector3d playerPosition = Vector3d.from(
packet.getX(),
packet.getY(),
packet.getZ()
);
PlayerProfileData player = getPlayerUUID(uuid);
assert player != null;
player.entityId(entityId);
player.position(new PositionData(pitch, yaw, playerPosition));
if (player != null) {
player.position = playerPosition;
player.entityId = entityId;
}
}
}
@@ -77,10 +94,10 @@ public class PlayerListModule implements Listener {
try {
// lazy ass fix for the bot erroring when a player is null
for (PlayerProfileData player : list) {
UUID playerUUID = player.profile().getId();
UUID playerUUID = player.profile.getId();
if (playerUUID == null) return playerInfo;
else if (player.profile().getId().equals(uuid)) {
else if (player.profile.getId().equals(uuid)) {
playerInfo = player;
}
}
@@ -91,7 +108,7 @@ public class PlayerListModule implements Listener {
public final PlayerProfileData getDisplayName (Component displayName) {
for (PlayerProfileData candidate : list) {
if (candidate.displayName() != null && candidate.displayName().equals(displayName)) {
if (candidate.displayName != null && candidate.displayName.equals(displayName)) {
return candidate;
}
}
@@ -101,7 +118,7 @@ public class PlayerListModule implements Listener {
public final PlayerProfileData getPlayerByUsername (String username) {
for (PlayerProfileData candidate : list) {
if (candidate.profile().getName().equals(username)) {
if (candidate.profile.getName().equals(username)) {
return candidate;
}
}
@@ -114,35 +131,59 @@ public class PlayerListModule implements Listener {
if (getPlayer == null) return;
getPlayer.listed(player.isListed());
getPlayer.listed = player.isListed();
}
public void updateGamemode (PlayerListEntry player) {
PlayerProfileData getPlayer = getPlayerUUID(player.getProfileId());
if (getPlayer == null) {
} else getPlayer.gameMode(player.getGameMode());
} else getPlayer.gameMode = player.getGameMode();
}
public void updateLatency (PlayerListEntry player) {
PlayerProfileData getPlayer = getPlayerUUID(player.getProfileId());
if (getPlayer == null) {
} else getPlayer.latency(player.getLatency());
} else getPlayer.latency = player.getLatency();
}
public void updateDisplayName (PlayerListEntry player) {
PlayerProfileData getPlayer = getPlayerUUID(player.getProfileId());
if (getPlayer == null) {
} else getPlayer.displayName(player.getDisplayName());
} else getPlayer.displayName = player.getDisplayName();
}
private void getPlayerIP (UUID uuid) {
/*
this function is unused right now because i cant figure how the fuck to get ips without problems
first i tried packets which didnt work half the time
now i tried tellraw but thats gonna cause problems because its gonna spam a servers console quite a lot on bot and player joins
feel free to reach out to me on matrix or discord, hell even a issue on the bots repo for this
*/
final String selector = String.format(
"@p[nbt={UUID:uuid(\"%s\")}]",
bot.profile.getIdAsString()
);
bot.chat.tellraw(
selector,
bot.core.runTrackedWithTellraw(
"nitoribot.player.ip",
uuid.toString(),
String.format(
"essentials:seen %s",
uuid
)
)
);
}
public void addPlayer (PlayerListEntry player) {
PlayerProfileData findDuplicatePlayer = getPlayerUUID(player.getProfileId());
if (findDuplicatePlayer != null) list.remove(findDuplicatePlayer);
PlayerProfileData formatPlayerData = new PlayerProfileData(
player.getProfileId(),
null,
@@ -155,18 +196,34 @@ public class PlayerListModule implements Listener {
player.getListOrder(),
null,
null,
null
0
);
list.add(formatPlayerData);
}
public void playerRemove (ClientboundPlayerInfoRemovePacket packet) {
for (UUID uuid : packet.getProfileIds()) {
PlayerProfileData getPlayer = getPlayerUUID(uuid);
try {
for (UUID uuid : packet.getProfileIds()) {
PlayerProfileData target = getPlayerUUID(uuid);
bot.tabComplete.completion("scoreboard players add ").thenApply((suggestion) -> {
final String[] matches = suggestion.getMatches();
final Component[] tooltips = suggestion.getTooltips();
final String username = target.profile.getName();
if (getPlayer == null) return;
list.remove(getPlayer);
for (int i = 0; i < matches.length; i++) {
if (tooltips[i] != null || !matches[i].equals(username)) continue;
target.listed = false;
return suggestion;
}
list.remove(target);
return suggestion;
});
}
} catch (Exception e) {
e.printStackTrace(System.err);
}
}
}
@@ -1,8 +1,7 @@
package land.chipmunk.parker2991.nitoribot.modules;
package land.chipmunk.parker2991.nitoribot.nightofnights.modules;
import land.chipmunk.parker2991.nitoribot.Bot;
import land.chipmunk.parker2991.nitoribot.data.PositionData;
import land.chipmunk.parker2991.nitoribot.listeners.Listener;
import land.chipmunk.parker2991.nitoribot.nightofnights.Bot;
import land.chipmunk.parker2991.nitoribot.nightofnights.listeners.Listener;
import org.cloudburstmc.math.vector.Vector3d;
import org.geysermc.mcprotocollib.network.packet.Packet;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerPositionPacket;
@@ -17,7 +16,7 @@ public class PositionModule implements Listener {
private final Bot bot;
public ScheduledFuture<?> timer;
public PositionData positionData;
public Vector3d positionData;
private int i = 0;
private int x;
private int z;
@@ -40,7 +39,8 @@ public class PositionModule implements Listener {
int y = (int) Math.round(getPosition.getY());
z = (int) Math.round(getPosition.getZ());
positionData = new PositionData(packet.getXRot(), packet.getYRot(), packet.getPosition());
positionData = Vector3d.from(packet.getPosition());
// positionData = new PositionData( packet.getPosition());
if (bot.options.mode.equals("totalfreedom")) {
if (i < 5) timer = bot.executor.scheduleAtFixedRate(
@@ -58,7 +58,20 @@ public class PositionModule implements Listener {
);
}
bot.session.send(new ServerboundAcceptTeleportationPacket(packet.getId()));
bot.session.send(
new ServerboundAcceptTeleportationPacket(
packet.getId(),
packet.getPosition().getX(),
packet.getPosition().getY(),
packet.getPosition().getZ(),
packet.getXRot(),
packet.getYRot()
)
);
/*
ServerboundAcceptTeleportationPacket(int id, double x, double y, double z, float yRot, float xRot)
*/
//bot.session.send(new ServerboundAcceptTeleportationPacket(packet.getId()));
for (Listener listener : bot.listenerManager.listeners) {
if (!Objects.equals(bot.options.mode, "kaboom")) return;
@@ -0,0 +1,48 @@
package land.chipmunk.parker2991.nitoribot.nightofnights.modules;
import com.google.gson.Gson;
import land.chipmunk.parker2991.nitoribot.nightofnights.Bot;
import land.chipmunk.parker2991.nitoribot.nightofnights.data.ChatTranslationsData;
import land.chipmunk.parker2991.nitoribot.nightofnights.data.world.DimensionData;
import land.chipmunk.parker2991.nitoribot.nightofnights.listeners.Listener;
import org.geysermc.mcprotocollib.network.packet.Packet;
import org.geysermc.mcprotocollib.protocol.data.game.RegistryEntry;
import org.geysermc.mcprotocollib.protocol.packet.configuration.clientbound.ClientboundRegistryDataPacket;
import java.util.ArrayList;
import java.util.List;
public class RegistryModule implements Listener {
public final List<ChatTranslationsData> chatTypes = new ArrayList<>();
public final List<DimensionData> dimensions = new ArrayList<>();
private final Gson gson = new Gson();
public RegistryModule (Bot bot) {
bot.listenerManager.addListener(this);
}
@Override
public void packetReceived (Packet packet) {
if (packet instanceof ClientboundRegistryDataPacket) packetReceived((ClientboundRegistryDataPacket) packet);
}
public void packetReceived (ClientboundRegistryDataPacket packet) {
String getRegistry = packet.getRegistry().asString();
for (RegistryEntry entry : packet.getEntries()) {
switch (getRegistry) {
case "minecraft:chat_type" -> {
ChatTranslationsData parsed = gson.fromJson(
entry.getData().toString(),
ChatTranslationsData.class
);
chatTypes.add(parsed);
}
case "minecraft:dimension_type" -> {
}
default -> {}
}
}
}
}
@@ -1,9 +1,9 @@
package land.chipmunk.parker2991.nitoribot.modules;
package land.chipmunk.parker2991.nitoribot.nightofnights.modules;
import land.chipmunk.parker2991.nitoribot.Bot;
import land.chipmunk.parker2991.nitoribot.listeners.Listener;
import land.chipmunk.parker2991.nitoribot.selfcare.entity.GamemodeSelfcare;
import land.chipmunk.parker2991.nitoribot.selfcare.entity.PermissionSelfcare;
import land.chipmunk.parker2991.nitoribot.nightofnights.Bot;
import land.chipmunk.parker2991.nitoribot.nightofnights.listeners.Listener;
import land.chipmunk.parker2991.nitoribot.nightofnights.entity.GamemodeSelfcare;
import land.chipmunk.parker2991.nitoribot.nightofnights.entity.PermissionSelfcare;
import org.geysermc.mcprotocollib.network.packet.Packet;
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.GameMode;
import org.geysermc.mcprotocollib.protocol.packet.common.clientbound.ClientboundDisconnectPacket;
@@ -0,0 +1,46 @@
package land.chipmunk.parker2991.nitoribot.nightofnights.modules;
import land.chipmunk.parker2991.nitoribot.nightofnights.Bot;
import land.chipmunk.parker2991.nitoribot.nightofnights.listeners.Listener;
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 java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
public class TabCompleteModule implements Listener {
private final Bot bot;
private final Map<Integer, CompletableFuture<ClientboundCommandSuggestionsPacket>> transactions = new HashMap<>();
public CompletableFuture<ClientboundCommandSuggestionsPacket> completion (String args) {
int transationId = 10;
bot.session.send(
new ServerboundCommandSuggestionPacket(
transationId,
args
)
);
final CompletableFuture<ClientboundCommandSuggestionsPacket> future = new CompletableFuture<>();
transactions.put(transationId, future);
return future;
}
@Override
public void packetReceived (Packet packet) {
if (packet instanceof ClientboundCommandSuggestionsPacket) commandSuggestionsReceived((ClientboundCommandSuggestionsPacket) packet);
}
private void commandSuggestionsReceived (ClientboundCommandSuggestionsPacket packet) {
transactions.get(packet.getTransactionId()).complete(packet);
}
public TabCompleteModule (Bot bot) {
this.bot = bot;
bot.listenerManager.addListener(this);
}
}
@@ -1,8 +1,8 @@
package land.chipmunk.parker2991.nitoribot.modules;
package land.chipmunk.parker2991.nitoribot.nightofnights.modules;
import land.chipmunk.parker2991.nitoribot.Bot;
import land.chipmunk.parker2991.nitoribot.listeners.Listener;
import land.chipmunk.parker2991.nitoribot.util.ComponentUtil;
import land.chipmunk.parker2991.nitoribot.nightofnights.Bot;
import land.chipmunk.parker2991.nitoribot.nightofnights.listeners.Listener;
import land.chipmunk.parker2991.nitoribot.nightofnights.util.ComponentUtil;
import net.kyori.adventure.text.Component;
import org.geysermc.mcprotocollib.network.packet.Packet;
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.EntityMetadata;
@@ -0,0 +1,69 @@
package land.chipmunk.parker2991.nitoribot.nightofnights.modules;
import land.chipmunk.parker2991.nitoribot.nightofnights.Bot;
import land.chipmunk.parker2991.nitoribot.nightofnights.data.world.ChunkPosData;
import land.chipmunk.parker2991.nitoribot.nightofnights.data.world.DimensionData;
import land.chipmunk.parker2991.nitoribot.nightofnights.listeners.Listener;
import org.cloudburstmc.math.vector.Vector3i;
import org.geysermc.mcprotocollib.network.packet.Packet;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundRespawnPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.level.ClientboundLevelChunkWithLightPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.level.ClientboundTagQueryPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.level.ServerboundBlockEntityTagQueryPacket;
import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
public class WorldModule implements Listener {
private final @NotNull Bot bot;
private final Map<Integer, CompletableFuture<ClientboundTagQueryPacket>> transactions = new HashMap<>();
public int transactionId = (int) Math.floor(Math.random() * 69);
public WorldModule (Bot bot) {
this.bot = bot;
bot.listenerManager.addListener(this);
}
@Override
public void packetReceived (Packet packet) {
switch (packet) {
case ClientboundLevelChunkWithLightPacket p -> addChunks(p);
case ClientboundRespawnPacket p -> respawn(p);
case ClientboundTagQueryPacket p -> getBlockOutput(p);
default -> {
}
}
}
public void getBlockOutput (ClientboundTagQueryPacket packet) {
transactions.get(packet.getTransactionId()).complete(packet);
}
private void respawn (ClientboundRespawnPacket packet) {
// currentDimension = String.valueOf(packet.getCommonPlayerSpawnInfo().getWorldName());
}
private void addChunks (ClientboundLevelChunkWithLightPacket packet) {
ChunkPosData pos = new ChunkPosData(packet.getX(), packet.getX());
for (DimensionData dimension : bot.registry.dimensions) {
}
}
public CompletableFuture<ClientboundTagQueryPacket> getBlock (Vector3i pos) {
bot.session.send(
new ServerboundBlockEntityTagQueryPacket(
transactionId,
pos
)
);
final CompletableFuture<ClientboundTagQueryPacket> future = new CompletableFuture<>();
transactions.put(transactionId, future);
return future;
}
}
@@ -1,4 +1,4 @@
package land.chipmunk.parker2991.nitoribot.util;
package land.chipmunk.parker2991.nitoribot.nightofnights.util;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
@@ -1,4 +1,4 @@
package land.chipmunk.parker2991.nitoribot.util;
package land.chipmunk.parker2991.nitoribot.nightofnights.util;
import java.io.ByteArrayOutputStream;
import java.io.OutputStreamWriter;
@@ -1,4 +1,4 @@
package land.chipmunk.parker2991.nitoribot.util;
package land.chipmunk.parker2991.nitoribot.nightofnights.util;
import org.cloudburstmc.nbt.NbtMap;
import org.cloudburstmc.nbt.NbtMapBuilder;
@@ -0,0 +1,4 @@
package land.chipmunk.parker2991.nitoribot.util;
public class NbtUtil {
}
+3 -2
View File
@@ -1,4 +1,5 @@
{
"about": "NitoriBot (formerly FridayNightFunkinBoyfriendBot or FNFBoyfriendBot) is a bot made for the servers kaboom.pw (and clones) and Savage Friends",
"buildstring": {
"botName": [
{
@@ -25,7 +26,7 @@
"color": "blue"
}
],
"build": "5311",
"build": "5312",
"versionReleaseDate": "N\\A",
"initialBotRelease": "11/22/22"
},
@@ -37,7 +38,7 @@
},
{
"name": "chayapak",
"reason": "v4.0.0-rewrite / listeners for v9.0.0 / v9.0.0 threads / v9.0.0 entity uuid / v9.0.0 command"
"reason": "v4.0.0-rewrite / listeners for v9.0.0 / v9.0.0 threads / v9.0.0 entity uuid / v9.0.0 command / v9.0.0 tab complete / v9.0.0 vanished player support"
},
{
"name": "_yfd",
@@ -1,6 +0,0 @@
package land.chipmunk.parker2991.nitoribot.command;
import land.chipmunk.parker2991.nitoribot.Bot;
public record CommandContext(Bot bot, String[] args, CommandSource source) {
}
@@ -1,20 +0,0 @@
package land.chipmunk.parker2991.nitoribot.command;
public abstract class CommandInfo {
// probably could make this a record or interface
public final String name;
public final CommandTrustLevels trustlevel;
public final String[] aliases;
public final String description;
public CommandInfo (String name, CommandTrustLevels trustlevel, String[] aliases, String description) {
this.name = name;
this.trustlevel = trustlevel;
this.aliases = aliases;
this.description = description;
}
public abstract void execute (CommandContext context);
}
@@ -1,42 +0,0 @@
package land.chipmunk.parker2991.nitoribot.command;
import land.chipmunk.parker2991.nitoribot.Bot;
import land.chipmunk.parker2991.nitoribot.data.ParsedChatType;
import land.chipmunk.parker2991.nitoribot.data.PlayerProfileData;
import land.chipmunk.parker2991.nitoribot.util.ComponentUtil;
import net.kyori.adventure.text.Component;
public class CommandSource {
public final PlayerProfileData sender;
public final ParsedChatType parsedChatType;
private final Bot bot;
public boolean inGame;
public CommandSource (Bot bot, ParsedChatType parsedChatType, PlayerProfileData sender) {
this.bot = bot;
this.parsedChatType = parsedChatType;
this.sender = sender;
}
public void sendFeedback (Component message) {
String convertToJson = ComponentUtil.componentToJSON(message);
//Vector3d playerPos = sender.position.position();
/* String formatCommand = String.format(
"minecraft:summon text_display %s %s %s {tag:[%s], text:%s}",
playerPos.getX(),
playerPos.getY(),
playerPos.getZ(),
"NitoriBot",
convertToJson
);*/
String selector = String.format("@p[nbt={UUID:%s}]", sender.entityUUID());
//System.out.println(sender.profile.getName());
if (this.parsedChatType == ParsedChatType.NORMAL) bot.chat.tellraw("@a", message);
else bot.chat.tellraw(selector, message);
}
}
@@ -1,5 +0,0 @@
package land.chipmunk.parker2991.nitoribot.command;
public enum CommandTrustLevels {
PUBLIC, TRUSTED, ADMIN, OWNER, CONSOLE, DISABLED
}