forked from afspiegeling/NitoriBot
v9.0.0-alpha build: 5300
This commit is contained in:
Generated
+1
@@ -11,6 +11,7 @@
|
||||
<option value="$PROJECT_DIR$" />
|
||||
</set>
|
||||
</option>
|
||||
<option name="myGradleHome" value="/usr/share/java/gradle" />
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
|
||||
+31
-21
@@ -1,11 +1,9 @@
|
||||
version = "v9.0.0"
|
||||
version = "v9.0.0-alpha"
|
||||
group = "nitoribot"
|
||||
description = "NitoriBot"
|
||||
plugins {
|
||||
id("com.gradleup.shadow") version "9.2.2"
|
||||
kotlin("jvm") version "2.3.10"
|
||||
id("maven-publish")
|
||||
application
|
||||
}
|
||||
|
||||
kotlin {
|
||||
@@ -26,15 +24,7 @@ repositories {
|
||||
|
||||
maven("https://maven.maxhenkel.de/repository/public/")
|
||||
|
||||
// maven("https://libraries.minecraft.net")
|
||||
|
||||
/* maven("https://code.optmstc.dev/api/packages/kso/maven") {
|
||||
content {
|
||||
includeGroupAndSubgroups("land.chipmunk.code")
|
||||
}
|
||||
}*/
|
||||
|
||||
//maven("https://libraries.minecraft.net")
|
||||
maven("https://libraries.minecraft.net")
|
||||
|
||||
maven("https://code.chipmunk.land/api/packages/kaboomstandardsorganization/maven/")
|
||||
}
|
||||
@@ -45,18 +35,38 @@ dependencies {
|
||||
implementation("org.tinylog:slf4j-tinylog:2.7.0")
|
||||
implementation("org.tinylog:tinylog-impl:2.7.0")
|
||||
implementation("org.yaml:snakeyaml:2.2")
|
||||
implementation("net.kyori:adventure-text-serializer-ansi:4.26.1")
|
||||
implementation("net.kyori:adventure-text-serializer-plain:4.26.1")
|
||||
implementation("net.kyori:adventure-text-serializer-legacy:4.26.1")
|
||||
implementation("net.kyori:adventure-text-serializer-gson:4.26.1")
|
||||
implementation("net.kyori:adventure-text-serializer-ansi:5.2.0")
|
||||
implementation("net.kyori:adventure-text-serializer-plain:5.2.0")
|
||||
implementation("net.kyori:adventure-text-serializer-legacy:5.2.0")
|
||||
implementation("net.kyori:adventure-text-serializer-gson:5.2.0")
|
||||
implementation("net.kyori:adventure-text-minimessage:5.2.0")
|
||||
implementation("net.dv8tion:JDA:6.4.1")
|
||||
implementation("de.connect2x.trixnity:trixnity-client:5.0.0")
|
||||
implementation("org.pircbotx:pircbotx:2.1")
|
||||
implementation("org.jline:jline:4.1.0")
|
||||
implementation("land.chipmunk.code.kaboomstandardsorganization.messaginglib:mcprotocollib:3.1.2")
|
||||
implementation("com.mojang:brigadier:1.0.500")
|
||||
}
|
||||
|
||||
application {
|
||||
mainClass.set("land.chipmunk.parker2991.nitoribot.Main")
|
||||
}
|
||||
tasks.jar {
|
||||
manifest {
|
||||
attributes["Main-Class"] = "land.chipmunk.parker2991.nitoribot.Main"
|
||||
attributes("Enable-Native-Access" to "ALL-UNNAMED")
|
||||
}
|
||||
|
||||
archiveClassifier.set("all")
|
||||
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
|
||||
from(sourceSets.main.get().output)
|
||||
|
||||
dependsOn(configurations.runtimeClasspath)
|
||||
|
||||
from(
|
||||
{
|
||||
configurations.runtimeClasspath.get().filter {
|
||||
it.name.endsWith("jar")
|
||||
}.map {
|
||||
zipTree(it)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package land.chipmunk.parker2991.nitoribot;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.data.buildstring.BotBuildInfo;
|
||||
import land.chipmunk.parker2991.nitoribot.data.buildstring.RepoCommitInfo;
|
||||
import land.chipmunk.parker2991.nitoribot.logger.Logger;
|
||||
import land.chipmunk.parker2991.nitoribot.modules.*;
|
||||
import land.chipmunk.parker2991.nitoribot.util.ComponentUtil;
|
||||
@@ -20,21 +22,14 @@ import org.geysermc.mcprotocollib.auth.GameProfile;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.ServerboundPlayerLoadedPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.login.clientbound.ClientboundLoginFinishedPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.ServerboundPlayerLoadedPacket;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.Scanner;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Map;
|
||||
|
||||
public class Bot extends SessionAdapter {
|
||||
public final ListenerManager listenerManager = new ListenerManager();
|
||||
@@ -47,6 +42,12 @@ public class Bot extends SessionAdapter {
|
||||
|
||||
public final ExecutorService executorService = Main.executorService;
|
||||
|
||||
public final ConcurrentMap<String, Future<?>> services = Main.services;
|
||||
|
||||
public BotBuildInfo botBuildInfo = Main.botBuildInfo;
|
||||
|
||||
public RepoCommitInfo repoCommitInfo;
|
||||
|
||||
public ClientNetworkSession session;
|
||||
|
||||
public GameProfile profile;
|
||||
@@ -78,8 +79,6 @@ public class Bot extends SessionAdapter {
|
||||
public MCServerModule mcServer;
|
||||
|
||||
public ProxyInfo randomProxyIp () throws IOException {
|
||||
String result = null; // stub
|
||||
|
||||
Path proxiesPath = Paths.get("proxies.txt");
|
||||
|
||||
int countLines = Math.round(
|
||||
@@ -90,18 +89,22 @@ public class Bot extends SessionAdapter {
|
||||
|
||||
int randomIndex = random.nextInt(countLines);
|
||||
|
||||
String[] getIp = Files.lines(proxiesPath)
|
||||
List<String> lines = Files.lines(proxiesPath).toList();//.toList();
|
||||
|
||||
String[] ip = lines.stream()
|
||||
.skip(randomIndex)
|
||||
.findAny()
|
||||
.get()
|
||||
.split(":");
|
||||
|
||||
String ip = getIp[0];
|
||||
int port = new Integer(getIp[1]);
|
||||
InetSocketAddress address = new InetSocketAddress(
|
||||
ip[0],
|
||||
Integer.parseInt(ip[1])
|
||||
);
|
||||
|
||||
return new ProxyInfo(
|
||||
ProxyInfo.Type.SOCKS5,
|
||||
new InetSocketAddress(ip, port)
|
||||
address
|
||||
);
|
||||
}
|
||||
|
||||
@@ -119,7 +122,9 @@ public class Bot extends SessionAdapter {
|
||||
this.extrasMessaging = new ExtrasMessagingModule(this);
|
||||
new TextDisplayModule(this);
|
||||
this.mcServer = new MCServerModule(this);
|
||||
} catch (Exception e) {}
|
||||
new CommandSpyModule(this);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
public Bot (Config.Options options, List<Bot> bots, Config config) {
|
||||
@@ -127,9 +132,40 @@ public class Bot extends SessionAdapter {
|
||||
this.bots = bots;
|
||||
this.config = config;
|
||||
|
||||
Main.services.put(
|
||||
"bot build information",
|
||||
executorService.submit(() -> {
|
||||
this.botBuildInfo = Main.getBuildInfo();
|
||||
this.repoCommitInfo = Main.getRepoInfo();
|
||||
})
|
||||
);
|
||||
|
||||
try {
|
||||
connect();
|
||||
} catch (Exception e) {}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace(System.err);
|
||||
}
|
||||
|
||||
Future<?> botBuildThread = services.get("bot build information");
|
||||
if (botBuildThread != null) {
|
||||
try {
|
||||
executorService.submit(() -> {
|
||||
try {
|
||||
Thread.sleep(5000);
|
||||
} catch (InterruptedException e) {
|
||||
|
||||
}
|
||||
botBuildThread.cancel(true);
|
||||
}).cancel(true);
|
||||
/*
|
||||
i counted how long it takes to get the repo info via https
|
||||
which is approximately 2 - 3 seconds
|
||||
so clear the thread after 3 seconds
|
||||
*/
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public void connect () throws IOException {
|
||||
@@ -137,8 +173,8 @@ public class Bot extends SessionAdapter {
|
||||
|
||||
if (options.useProxy) session = ClientNetworkSessionFactory.factory()
|
||||
.setAddress(
|
||||
options.host,
|
||||
options.port
|
||||
options.host,
|
||||
options.port
|
||||
)
|
||||
.setProxy(randomProxyIp())
|
||||
.setProtocol(protocol)
|
||||
@@ -151,7 +187,7 @@ public class Bot extends SessionAdapter {
|
||||
)
|
||||
.setProtocol(protocol)
|
||||
.create();
|
||||
session.addListener(this);
|
||||
session.addListener(this);
|
||||
loadModules();
|
||||
session.connect(false);
|
||||
}
|
||||
@@ -162,8 +198,6 @@ public class Bot extends SessionAdapter {
|
||||
session.disconnect(reason);
|
||||
}
|
||||
|
||||
// ServerboundPlayerLoadedPacket
|
||||
|
||||
@Override
|
||||
public void packetSent (Session session, Packet packet) {
|
||||
for (Listener listener : listenerManager.listeners) {
|
||||
@@ -174,6 +208,7 @@ public class Bot extends SessionAdapter {
|
||||
@Override
|
||||
public void packetError (PacketErrorEvent error) {
|
||||
error.setSuppress(true);
|
||||
//System.out.println(error);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -193,7 +228,8 @@ public class Bot extends SessionAdapter {
|
||||
|
||||
if (packet instanceof ClientboundLoginFinishedPacket) getProfile((ClientboundLoginFinishedPacket) packet);
|
||||
else if (packet instanceof ClientboundLoginPacket) getEntityId((ClientboundLoginPacket) packet);
|
||||
} catch (Exception e) { }
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -61,5 +61,6 @@ public class Config {
|
||||
public String username;
|
||||
public int reconnectDelay;
|
||||
public int selfcareInterval;
|
||||
public String mode;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
package land.chipmunk.parker2991.nitoribot;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParser;
|
||||
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.logger.Logger;
|
||||
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import org.yaml.snakeyaml.LoaderOptions;
|
||||
@@ -8,14 +14,19 @@ import org.yaml.snakeyaml.constructor.Constructor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
public class Main {
|
||||
public final Object obj = new Object();
|
||||
@@ -28,6 +39,51 @@ public class Main {
|
||||
Runtime.getRuntime().availableProcessors()
|
||||
);
|
||||
|
||||
public static final ConcurrentMap<String, Future<?>> services = new ConcurrentHashMap<>();
|
||||
|
||||
private static final Gson GSON = new Gson();
|
||||
|
||||
public static BotBuildInfo getBuildInfo () {
|
||||
Reader reader = new InputStreamReader(
|
||||
Objects.requireNonNull(Main.class
|
||||
.getResourceAsStream("/info.json"))
|
||||
);
|
||||
|
||||
return GSON.fromJson(reader, BotBuildInfo.class);
|
||||
}
|
||||
|
||||
public static 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(20))
|
||||
.build();
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(URI.create(repo))
|
||||
.timeout(Duration.ofSeconds(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());
|
||||
|
||||
info = GSON.fromJson(e.getAsJsonArray().get(1), RepoCommitInfo.class);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace(System.err);
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
public static RepoCommitInfo repoCommitInfo = null;// = getRepoInfo();
|
||||
|
||||
public static BotBuildInfo botBuildInfo = null;// = getBuildInfo();
|
||||
|
||||
public static Config config;
|
||||
|
||||
public static final List<Bot> Bots = new ArrayList<>();
|
||||
@@ -38,10 +94,10 @@ public class Main {
|
||||
final Path configPath = Path.of("config.yaml");
|
||||
if (!Files.exists(configPath)) {
|
||||
|
||||
//LoggerManager.INFO(null, "config not found making config now");
|
||||
Logger.INFO(null, "config not found making config now");
|
||||
|
||||
InputStream defaultConfig = Main.class.getClassLoader().getResourceAsStream("default_config.yaml");
|
||||
Files.copy(defaultConfig, Paths.get("config.yaml"));
|
||||
Files.copy(defaultConfig, configPath);
|
||||
}
|
||||
|
||||
InputStream configFile = Files.newInputStream(configPath);
|
||||
@@ -58,14 +114,12 @@ public class Main {
|
||||
Config.Options[] bots = config.bots;
|
||||
|
||||
console = new ConsoleModule(config);
|
||||
|
||||
for (Config.Options options : bots) {
|
||||
final Bot bot = new Bot(options, Bots, config);
|
||||
Bots.add(bot);
|
||||
}
|
||||
|
||||
synchronized(obj) {
|
||||
obj.wait();
|
||||
};
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package land.chipmunk.parker2991.nitoribot.chatparsers;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.Bot;
|
||||
import land.chipmunk.parker2991.nitoribot.data.chat.ParseChatData;
|
||||
import land.chipmunk.parker2991.nitoribot.data.chat.PlayerMessageData;
|
||||
import land.chipmunk.parker2991.nitoribot.util.ComponentUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TotalFreedomChatParser implements ParseChatData {
|
||||
private Bot bot;
|
||||
public TotalFreedomChatParser (Bot bot) {
|
||||
this.bot = bot;
|
||||
}
|
||||
@Override
|
||||
public PlayerMessageData parse (Component message) {
|
||||
if (message instanceof TextComponent) return parse((TextComponent) message);
|
||||
return null;
|
||||
}
|
||||
/*
|
||||
private boolean isSeperatorAt (List<Component> children, int start) {
|
||||
return (children.get(start).equals(SEPERATOR_COLON)
|
||||
|| children.get(start).equals(SEPERATOR_COLON_RACCOON)) && children.get(start + 1).equals(SEPERATOR_SPACE);
|
||||
}
|
||||
*/
|
||||
|
||||
private boolean isSeperatorAt (List<Component> children, int start) {
|
||||
return (
|
||||
children.get(start).equals(">")
|
||||
||
|
||||
children.get(start).equals(">")
|
||||
);
|
||||
}
|
||||
public PlayerMessageData parse (TextComponent message) {
|
||||
String content = message.content();
|
||||
List<Component> children = message.children();//.toString();
|
||||
|
||||
// parsing total freedom chat is fucking horrid bro
|
||||
|
||||
for (Component component : children) {
|
||||
TextComponent textComponent = (TextComponent) component;
|
||||
//String e = textComponent.toString().split("[");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package land.chipmunk.parker2991.nitoribot.command;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.jline.shell.Command;
|
||||
|
||||
public class CommandArguments {
|
||||
private CommandSource source;
|
||||
private CommandInfo command;
|
||||
public String[] arguments;
|
||||
|
||||
public CommandArguments (
|
||||
CommandSource source,
|
||||
CommandInfo command,
|
||||
String[] arguments
|
||||
) {
|
||||
this.source = source;
|
||||
this.command = command;
|
||||
this.arguments = arguments;
|
||||
}
|
||||
|
||||
/* public static void getArguments (
|
||||
CommandSource source,
|
||||
CommandInfo command,
|
||||
String[] args
|
||||
) throws CommandError {
|
||||
|
||||
System.out.println(args.length);
|
||||
if (
|
||||
args.length > command.maxArguments
|
||||
) {
|
||||
throw new CommandError(
|
||||
Component.translatable(
|
||||
"Too many arguments, expected %s max not %s",
|
||||
Component.text(command.maxArguments),
|
||||
Component.text(args.length)
|
||||
).color(NamedTextColor.RED)
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
args.length < command.minArguments
|
||||
) {
|
||||
throw new CommandError(
|
||||
Component.translatable(
|
||||
"Expected more than %s arguments recieved %s",
|
||||
Component.text(command.maxArguments),
|
||||
Component.text(args.length)
|
||||
).color(NamedTextColor.RED)
|
||||
);
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
//public void checkArgumentType ()
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package land.chipmunk.parker2991.nitoribot.command;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.Bot;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
||||
public class CommandContext {
|
||||
public Bot bot;
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
package land.chipmunk.parker2991.nitoribot.command;
|
||||
|
||||
public abstract class CommandInfo {
|
||||
// probably could make this a record or interface
|
||||
public String name;
|
||||
public CommandTrustLevels trustlevel;
|
||||
public String[] aliases;
|
||||
public String description;
|
||||
|
||||
public CommandInfo (String name, CommandTrustLevels trustlevel, String[] aliases, String description) {
|
||||
public CommandInfo (
|
||||
String name,
|
||||
CommandTrustLevels trustlevel,
|
||||
String[] aliases,
|
||||
String description
|
||||
) {
|
||||
this.name = name;
|
||||
this.trustlevel = trustlevel;
|
||||
this.aliases = aliases;
|
||||
@@ -14,6 +20,6 @@ public abstract class CommandInfo {
|
||||
}
|
||||
|
||||
public abstract void execute (CommandContext context);
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package land.chipmunk.parker2991.nitoribot.command;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.data.ParsedChatType;
|
||||
import land.chipmunk.parker2991.nitoribot.data.PlayerProfileData;
|
||||
import land.chipmunk.parker2991.nitoribot.Bot;
|
||||
import land.chipmunk.parker2991.nitoribot.util.ComponentUtil;
|
||||
@@ -15,31 +16,36 @@ public class CommandSource {
|
||||
|
||||
public boolean inGame;
|
||||
|
||||
public CommandSource (Bot bot, PlayerProfileData sender) {
|
||||
public ParsedChatType parsedChatType;
|
||||
|
||||
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();
|
||||
//Vector3d playerPos = sender.position.position();
|
||||
|
||||
String formatCommand = String.format(
|
||||
/* 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
|
||||
);
|
||||
|
||||
bot.chat.tellraw(selector, message);
|
||||
//System.out.println(sender.profile.getName());
|
||||
|
||||
if (this.parsedChatType == ParsedChatType.NORMAL) bot.chat.tellraw("@a", message);
|
||||
else bot.chat.tellraw(selector, message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,13 +10,13 @@ public class EchoCommand extends CommandInfo {
|
||||
super(
|
||||
"echo",
|
||||
CommandTrustLevels.PUBLIC,
|
||||
new String[] { "say" },
|
||||
new String[]{ "say" },
|
||||
"make the bot say a message"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandContext context) {
|
||||
public void execute (CommandContext context) {
|
||||
Bot bot = context.bot;
|
||||
String args = String.join(" ", context.args);
|
||||
if (args.startsWith("/")) {
|
||||
@@ -25,4 +25,4 @@ public class EchoCommand extends CommandInfo {
|
||||
bot.chat.message(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class HelpCommand extends CommandInfo {
|
||||
super(
|
||||
"help",
|
||||
CommandTrustLevels.PUBLIC,
|
||||
new String[] { "heko", "hell", "?", "cmds"},
|
||||
new String[]{ "heko", "hell", "?", "cmds" },
|
||||
"see the list of commands"
|
||||
);
|
||||
}
|
||||
@@ -42,20 +42,20 @@ public class HelpCommand extends CommandInfo {
|
||||
Public.add(
|
||||
Component.text(commands.name + " ").color(NamedTextColor.BLUE)
|
||||
);
|
||||
break;
|
||||
break;
|
||||
case CommandTrustLevels.TRUSTED:
|
||||
Trusted.add(
|
||||
Component.text(commands.name + " ").color(NamedTextColor.DARK_AQUA)
|
||||
);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Component component = Component.empty()
|
||||
.append(Public)
|
||||
.append(Component.text("\n"))
|
||||
.append(Trusted);
|
||||
// .append(Component.text("\n"));
|
||||
// .append(Component.text("\n"));
|
||||
|
||||
return component;
|
||||
}
|
||||
@@ -66,52 +66,54 @@ public class HelpCommand extends CommandInfo {
|
||||
Component component = null;
|
||||
|
||||
for (CommandInfo commands : bot.commandManager.commands) {
|
||||
if (commands.name.equals(command[0])) component = Component.empty()
|
||||
.append(
|
||||
TranslationsUtil.customTranslations(
|
||||
"command.help.info.layout",
|
||||
List.of(
|
||||
TranslationsUtil.customTranslations("command.help.info.command", null).color(NamedTextColor.BLUE),
|
||||
Component.text(commands.name).color(NamedTextColor.AQUA)
|
||||
for (String aliases : commands.aliases) {
|
||||
if (commands.name.equals(command[0]) || aliases.equals(command[0])) component = Component.empty()
|
||||
.append(
|
||||
TranslationsUtil.customTranslations(
|
||||
"command.help.info.layout",
|
||||
List.of(
|
||||
TranslationsUtil.customTranslations("command.help.info.command", null).color(NamedTextColor.BLUE),
|
||||
Component.text(commands.name).color(NamedTextColor.AQUA)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
.append(
|
||||
TranslationsUtil.customTranslations(
|
||||
"command.help.info.layout",
|
||||
List.of(
|
||||
TranslationsUtil.customTranslations("command.help.info.aliases", null).color(NamedTextColor.BLUE),
|
||||
Component.text(Arrays.toString(commands.aliases)).color(NamedTextColor.AQUA)
|
||||
.append(
|
||||
TranslationsUtil.customTranslations(
|
||||
"command.help.info.layout",
|
||||
List.of(
|
||||
TranslationsUtil.customTranslations("command.help.info.aliases", null).color(NamedTextColor.BLUE),
|
||||
Component.text(Arrays.toString(commands.aliases)).color(NamedTextColor.AQUA)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
.append(
|
||||
TranslationsUtil.customTranslations(
|
||||
"command.help.info.layout",
|
||||
List.of(
|
||||
TranslationsUtil.customTranslations("command.help.info.description", null).color(NamedTextColor.BLUE),
|
||||
Component.text(commands.description).color(NamedTextColor.AQUA)
|
||||
.append(
|
||||
TranslationsUtil.customTranslations(
|
||||
"command.help.info.layout",
|
||||
List.of(
|
||||
TranslationsUtil.customTranslations("command.help.info.description", null).color(NamedTextColor.BLUE),
|
||||
Component.text(commands.description).color(NamedTextColor.AQUA)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
.append(
|
||||
TranslationsUtil.customTranslations(
|
||||
"command.help.info.layout",
|
||||
List.of(
|
||||
TranslationsUtil.customTranslations("command.help.info.trust_level", null).color(NamedTextColor.BLUE),
|
||||
Component.text(commands.trustlevel + "").color(NamedTextColor.AQUA)
|
||||
.append(
|
||||
TranslationsUtil.customTranslations(
|
||||
"command.help.info.layout",
|
||||
List.of(
|
||||
TranslationsUtil.customTranslations("command.help.info.trust_level", null).color(NamedTextColor.BLUE),
|
||||
Component.text(commands.trustlevel + "").color(NamedTextColor.AQUA)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
.append(
|
||||
TranslationsUtil.customTranslations(
|
||||
"command.help.info.layout",
|
||||
List.of(
|
||||
TranslationsUtil.customTranslations("command.help.info.usages", null).color(NamedTextColor.BLUE),
|
||||
Component.text("DUMMY String").color(NamedTextColor.AQUA)
|
||||
.append(
|
||||
TranslationsUtil.customTranslations(
|
||||
"command.help.info.layout",
|
||||
List.of(
|
||||
TranslationsUtil.customTranslations("command.help.info.usages", null).color(NamedTextColor.BLUE),
|
||||
Component.text("DUMMY String").color(NamedTextColor.AQUA)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
return component;
|
||||
}
|
||||
@@ -127,7 +129,7 @@ public class HelpCommand extends CommandInfo {
|
||||
|
||||
if (args.length != 0) {
|
||||
source.sendFeedback(getCommand(bot, args));
|
||||
//return null;
|
||||
return;
|
||||
}
|
||||
|
||||
list = List.of(
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
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.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
public class InfoCommand extends CommandInfo {
|
||||
public InfoCommand () {
|
||||
super(
|
||||
"info",
|
||||
CommandTrustLevels.PUBLIC,
|
||||
new String[]{ "information" },
|
||||
"information about the bot"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute (CommandContext context) {
|
||||
var bot = context.bot;
|
||||
|
||||
var source = context.source;
|
||||
|
||||
var args = context.args;
|
||||
|
||||
Component component = null;
|
||||
/*
|
||||
Build: 3355
|
||||
Repo Build: 242
|
||||
Version Release Date: 10/22/2025, 11:24:04 AM
|
||||
Commit: fcbd9f983c
|
||||
11/22/22-9/10/2026
|
||||
*/
|
||||
GsonComponentSerializer gson = GsonComponentSerializer.gson();
|
||||
|
||||
switch (args[0].toLowerCase()) {
|
||||
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");
|
||||
|
||||
component = Component.translatable(
|
||||
"%s-%s-%s\n%s: %s\n%s: %s\n%s: %s",
|
||||
gson.deserialize(info.buildstring.botName.toString()),
|
||||
Component.text(info.buildstring.version).color(NamedTextColor.AQUA),
|
||||
gson.deserialize(info.buildstring.codename.toString()),
|
||||
Component.text("Build").color(NamedTextColor.BLUE),
|
||||
Component.text(info.buildstring.build).color(NamedTextColor.YELLOW),
|
||||
Component.text("Version release Date").color(NamedTextColor.BLUE),
|
||||
Component.text(dateTime.format(dateTimeFormatter)).color(NamedTextColor.DARK_BLUE),
|
||||
Component.text("Commit").color(NamedTextColor.BLUE),
|
||||
Component.text(repoCommitInfo.sha.substring(0, 8)).color(NamedTextColor.DARK_BLUE)
|
||||
).color(NamedTextColor.GRAY);
|
||||
}
|
||||
}
|
||||
|
||||
source.sendFeedback(component);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
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 net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
|
||||
|
||||
/*
|
||||
Adventure Minimessage is very fucking weird.....
|
||||
the fact it uses an HTML style with strings instead of components is very weird
|
||||
it also makes the JSON so fucking big especially with gradients
|
||||
this does remind me of how i did component.push shit in the JS build of my bot aka v8.0.0-Reignite
|
||||
*/
|
||||
public class TestCommand extends CommandInfo {
|
||||
public TestCommand () {
|
||||
super(
|
||||
"test",
|
||||
CommandTrustLevels.PUBLIC,
|
||||
new String[]{ "t" },
|
||||
"testing shit"
|
||||
);
|
||||
}
|
||||
|
||||
private static final MiniMessage MINI_MESSAGE = MiniMessage.miniMessage();
|
||||
|
||||
@Override
|
||||
public void execute (CommandContext context) {
|
||||
var bot = context.bot;
|
||||
|
||||
var args = String.join(" ", 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(component);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package land.chipmunk.parker2991.nitoribot.data;
|
||||
|
||||
public enum ChatType {
|
||||
PLAYER,
|
||||
SYSTEM,
|
||||
DISGUISED
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package land.chipmunk.parker2991.nitoribot.data;
|
||||
|
||||
public enum ParsedChatType {
|
||||
COMMANDSPY,
|
||||
NORMAL
|
||||
}
|
||||
@@ -1,16 +1,14 @@
|
||||
package land.chipmunk.parker2991.nitoribot.data;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.util.UUIDUtil;
|
||||
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.GameMode;
|
||||
import org.geysermc.mcprotocollib.auth.GameProfile;
|
||||
|
||||
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 org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Nullable
|
||||
public class PlayerProfileData {
|
||||
public UUID uuid;
|
||||
public String entityUUID;
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package land.chipmunk.parker2991.nitoribot.data.buildstring;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BotBuildInfo {
|
||||
public static class BuildInfo {
|
||||
public List<JsonObject> botName;
|
||||
public String version;
|
||||
public List<JsonObject> codename;
|
||||
public String build;
|
||||
public String versionReleaseDate;
|
||||
public String initialBotRelease;
|
||||
}
|
||||
|
||||
public BuildInfo buildstring = new BuildInfo();
|
||||
|
||||
public String owner;
|
||||
|
||||
public static class Contributors {
|
||||
public String name;
|
||||
public String reason;
|
||||
}
|
||||
|
||||
public Contributors[] contributors = new Contributors[]{};
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package land.chipmunk.parker2991.nitoribot.data.buildstring;
|
||||
|
||||
public class RepoCommitInfo {
|
||||
public String sha;
|
||||
|
||||
public String created;
|
||||
|
||||
public int commits;
|
||||
}
|
||||
@@ -1,13 +1,7 @@
|
||||
package land.chipmunk.parker2991.nitoribot.data.chat;
|
||||
|
||||
//import land.chipmunk.parker2991.nitoribot.data.PlayerProfileData;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
//import org.geysermc.mcprotocollib.protocol.data.game.PlayerListEntry;
|
||||
|
||||
public interface ParseChatData {
|
||||
PlayerMessageData parse (Component message);
|
||||
|
||||
// PlayerProfileData parse (PlayerMessageData data);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,6 @@ public class PlayerMessageData {
|
||||
this.contents = contents;
|
||||
this.chatType = chatType;
|
||||
this.senderName = senderName;
|
||||
// return this;
|
||||
// return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
package land.chipmunk.parker2991.nitoribot.listeners;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import land.chipmunk.code.kaboomstandardsorganization.messaginglib.mcprotocollib.MCProtocolLibMessenger;
|
||||
import org.geysermc.mcprotocollib.network.Session;
|
||||
import org.geysermc.mcprotocollib.network.packet.Packet;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.data.PlayerProfileData;
|
||||
import land.chipmunk.parker2991.nitoribot.data.chat.PlayerMessageData;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.UUID;
|
||||
import org.geysermc.mcprotocollib.network.Session;
|
||||
import org.geysermc.mcprotocollib.network.packet.Packet;
|
||||
|
||||
public class Listener {
|
||||
public void packetSent (Session session, Packet packet) {}
|
||||
@@ -28,4 +25,6 @@ public class Listener {
|
||||
public void parsedMessage (Component message, PlayerMessageData data) {}
|
||||
|
||||
public void botMoved () {}
|
||||
|
||||
public void commandSpyReceived (PlayerProfileData player, String command) {}
|
||||
}
|
||||
+18
-1
@@ -3,6 +3,8 @@ package land.chipmunk.parker2991.nitoribot.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.*;
|
||||
import land.chipmunk.parker2991.nitoribot.util.ComponentUtil;
|
||||
@@ -27,13 +29,28 @@ public class ChatCommandHandlerModule extends Listener {
|
||||
|
||||
String command = plainMessage.substring(prefix.length());
|
||||
|
||||
CommandSource source = new CommandSource(bot, data.sender);
|
||||
CommandSource source = new CommandSource(bot, ParsedChatType.NORMAL, data.sender);
|
||||
|
||||
bot.commandManager.executeString(source, command);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commandSpyReceived (PlayerProfileData player, String message) {
|
||||
List<String> prefixes = bot.config.prefixes;
|
||||
|
||||
for (String prefix : prefixes) {
|
||||
if (!message.startsWith(prefix)) return;
|
||||
|
||||
String command = message.substring(prefix.length());
|
||||
|
||||
CommandSource source = new CommandSource(bot, ParsedChatType.COMMANDSPY, player);
|
||||
|
||||
bot.commandManager.executeString(source, command);
|
||||
}
|
||||
}
|
||||
|
||||
public ChatCommandHandlerModule (Bot bot) {
|
||||
this.bot = bot;
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import land.chipmunk.parker2991.nitoribot.chatparsers.*;
|
||||
import land.chipmunk.parker2991.nitoribot.data.chat.*;
|
||||
import land.chipmunk.parker2991.nitoribot.data.PlayerProfileData;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.util.ComponentUtil;
|
||||
import org.geysermc.mcprotocollib.network.Session;
|
||||
import org.geysermc.mcprotocollib.network.packet.Packet;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundDisguisedChatPacket;
|
||||
@@ -52,6 +53,7 @@ public class ChatModule extends Listener {
|
||||
public void diguisedChat (ClientboundDisguisedChatPacket packet) {
|
||||
Component getMessage = packet.getMessage();
|
||||
Component targetUsername = packet.getName();
|
||||
|
||||
Component message;
|
||||
|
||||
final String parseChatTypes = parseChatTypes(packet.getChatType().id());
|
||||
@@ -69,13 +71,24 @@ public class ChatModule extends Listener {
|
||||
for (Listener listener : bot.listenerManager.listeners) {
|
||||
listener.disguisedChatReceived(message);
|
||||
}
|
||||
|
||||
TextComponent textComponent = (TextComponent) targetUsername;
|
||||
|
||||
parseMessage(
|
||||
message,
|
||||
new PlayerMessageData(
|
||||
bot.players.getPlayerByUsername(textComponent.content()),
|
||||
packet.getMessage(),
|
||||
"minecraft:chat",
|
||||
bot.players.getPlayerByUsername(textComponent.content()).displayName
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public void playerChat (ClientboundPlayerChatPacket packet) {
|
||||
final Component unsignedContent = packet.getUnsignedContent();
|
||||
final Component content = Component.text(packet.getContent());
|
||||
|
||||
|
||||
for (Listener listener : bot.listenerManager.listeners) {
|
||||
listener.playerChatReceived(unsignedContent);
|
||||
}
|
||||
@@ -138,13 +151,21 @@ public class ChatModule extends Listener {
|
||||
}
|
||||
|
||||
public void tellraw (String selector, Component message) {
|
||||
bot.core.run("minecraft:tellraw " + selector + " " + GsonComponentSerializer.gson().serialize(message));
|
||||
bot.core.run(
|
||||
String.format(
|
||||
"%s %s %s",
|
||||
"minecraft:tellraw",
|
||||
selector,
|
||||
GsonComponentSerializer.gson().serialize(message).trim()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public ChatModule (Bot bot) {
|
||||
this.bot = bot;
|
||||
|
||||
|
||||
chatParsers.add(new KaboomChatParser(bot));
|
||||
chatParsers.add(new TotalFreedomChatParser(bot));
|
||||
|
||||
bot.listenerManager.addListener(this);
|
||||
};
|
||||
|
||||
@@ -64,7 +64,7 @@ public class CommandCoreModule extends Listener {
|
||||
botPos.getZ()
|
||||
);
|
||||
|
||||
itemRefill();
|
||||
chatRefill();
|
||||
};
|
||||
|
||||
public void chatRefill () {
|
||||
@@ -79,7 +79,7 @@ public class CommandCoreModule extends Listener {
|
||||
int endPosZ = pos.getZ() - coreArea.end.getZ();
|
||||
|
||||
String command = String.format(
|
||||
"minecraft:fill %s %s %s %s %s %s command_block{CustomName:%s}",
|
||||
"minecraft:fill %s %s %s %s %s %s command_block{CustomName:%s} destroy",
|
||||
startPosX,
|
||||
startPosY,
|
||||
startPosZ,
|
||||
@@ -200,6 +200,7 @@ public class CommandCoreModule extends Listener {
|
||||
Vector3i relativePosition = currentBlockRelative;
|
||||
Vector3i corePosition = position;
|
||||
|
||||
if (corePosition == null) return null;
|
||||
return new PositionData(
|
||||
relativePosition.getX() + corePosition.getX(),
|
||||
relativePosition.getY() + corePosition.getY(),
|
||||
@@ -235,7 +236,7 @@ public class CommandCoreModule extends Listener {
|
||||
}
|
||||
|
||||
public void commandBlock (String command, boolean doesTrackOutput, boolean conditional, boolean automatic) {
|
||||
if (command.length() > 32767) return;
|
||||
if (command.length() > 32767 || position == null) return;
|
||||
bot.session.send(
|
||||
new ServerboundSetCommandBlockPacket(
|
||||
position,
|
||||
@@ -249,6 +250,7 @@ public class CommandCoreModule extends Listener {
|
||||
}
|
||||
|
||||
public void run (String command) {
|
||||
|
||||
commandBlock(command, true, false, true);
|
||||
|
||||
incrementCurrentBlock();
|
||||
|
||||
@@ -1,26 +1,27 @@
|
||||
package land.chipmunk.parker2991.nitoribot.modules;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import land.chipmunk.parker2991.nitoribot.Bot;
|
||||
import land.chipmunk.parker2991.nitoribot.command.CommandError;
|
||||
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 net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandManagerModule {
|
||||
private Bot bot;
|
||||
|
||||
public CommandDispatcher <CommandSource> dispatcher = new CommandDispatcher<>();
|
||||
|
||||
public List<CommandInfo> commands = new ArrayList<>();
|
||||
|
||||
public void registerCommand (CommandInfo command) {
|
||||
@@ -54,7 +55,6 @@ public class CommandManagerModule {
|
||||
CommandContext context = new CommandContext(bot, args, source, command);
|
||||
|
||||
command.execute(context);
|
||||
|
||||
} catch (CommandError error) {
|
||||
source.sendFeedback(error.message());
|
||||
} catch (Exception error) {
|
||||
@@ -82,5 +82,7 @@ public class CommandManagerModule {
|
||||
registerCommand(new ReconnectCommand());
|
||||
registerCommand(new RCCommand());
|
||||
registerCommand(new MCServerCommand());
|
||||
registerCommand(new TestCommand());
|
||||
registerCommand(new InfoCommand());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package land.chipmunk.parker2991.nitoribot.modules;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.Bot;
|
||||
import land.chipmunk.parker2991.nitoribot.data.PlayerProfileData;
|
||||
import land.chipmunk.parker2991.nitoribot.listeners.Listener;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommandSpyModule extends Listener {
|
||||
private Bot bot;
|
||||
|
||||
private static final String COLON = ":";
|
||||
|
||||
private static final String SLASH = "/";
|
||||
|
||||
@Override
|
||||
public void systemChatReceived (Component data) {
|
||||
@Unmodifiable List<Component> children = data.children();
|
||||
|
||||
TextComponent userComponent = null;
|
||||
|
||||
TextComponent commandComponent = null;
|
||||
|
||||
if (children.get(1) instanceof final TextComponent textComponent) commandComponent = textComponent;
|
||||
|
||||
if (data instanceof final TextComponent textComponent) userComponent = textComponent;
|
||||
|
||||
PlayerProfileData sender = null;
|
||||
|
||||
for (PlayerProfileData player : bot.players.list) {
|
||||
String username = player.profile.getName();
|
||||
|
||||
if (username.equals(userComponent.content())) sender = player;
|
||||
}
|
||||
|
||||
String command = commandComponent.content().substring(SLASH.length());
|
||||
|
||||
if (
|
||||
(
|
||||
commandComponent.content().contains(SLASH + command)
|
||||
&&
|
||||
sender != null
|
||||
)
|
||||
) {
|
||||
for (Listener listener : bot.listenerManager.listeners) {
|
||||
listener.commandSpyReceived(sender, command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public CommandSpyModule (Bot bot) {
|
||||
this.bot = bot;
|
||||
|
||||
bot.listenerManager.addListener(this);
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,10 @@
|
||||
package land.chipmunk.parker2991.nitoribot.modules;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.Bot;
|
||||
|
||||
//import org.jline
|
||||
import land.chipmunk.parker2991.nitoribot.Config;
|
||||
import land.chipmunk.parker2991.nitoribot.Main;
|
||||
import org.jline.reader.*;
|
||||
import org.jline.terminal.*;
|
||||
|
||||
import javax.sound.sampled.Line;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public class ConsoleModule implements Completer {
|
||||
|
||||
@@ -32,7 +32,7 @@ public class LoggingModule extends Listener {
|
||||
|
||||
String message = ComponentUtil.componentToAnsi(_message);
|
||||
//if (host.equals("kaboom.pw")) return;
|
||||
// Logger.LOG(bot, message);
|
||||
Logger.LOG(bot, message);
|
||||
}
|
||||
|
||||
public LoggingModule (Bot bot) {
|
||||
|
||||
@@ -56,17 +56,6 @@ public class MCServerModule {
|
||||
client.setFlag(MinecraftConstants.SESSION_SERVICE_KEY, sessionService);
|
||||
|
||||
client.setFlag(MinecraftConstants.SERVER_INFO_HANDLER_KEY, (Session session, ServerStatusInfo info) -> {
|
||||
//System.out.println(info.getVersionInfo().getVersionName());
|
||||
//System.out.println(info.getPlayerInfo().getOnlinePlayers());
|
||||
//assert info.getVersionInfo() != null;
|
||||
//assert info.getPlayerInfo() != null;
|
||||
/*
|
||||
String versionName,
|
||||
long protocolVersion,
|
||||
int playersOnline,
|
||||
int maxPlayers,
|
||||
Component description
|
||||
*/
|
||||
assert info.getVersionInfo() != null;
|
||||
assert info.getPlayerInfo() != null;
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package land.chipmunk.parker2991.nitoribot.modules;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.Bot;
|
||||
import land.chipmunk.parker2991.nitoribot.data.PlayerPositionData;
|
||||
import land.chipmunk.parker2991.nitoribot.data.PlayerProfileData;
|
||||
import land.chipmunk.parker2991.nitoribot.listeners.Listener;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.cloudburstmc.math.vector.Vector3d;
|
||||
import org.geysermc.mcprotocollib.network.Session;
|
||||
import org.geysermc.mcprotocollib.network.packet.Packet;
|
||||
@@ -13,21 +13,14 @@ 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.entity.ClientboundMoveEntityPosPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.ClientboundMoveEntityPosRotPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.ClientboundAddEntityPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.ClientboundRemoveEntitiesPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.ClientboundTeleportEntityPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.ClientboundRotateHeadPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.ClientboundEntityPositionSyncPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.level.ServerboundEntityTagQuery;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.level.ClientboundTagQueryPacket;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.Bot;
|
||||
import land.chipmunk.parker2991.nitoribot.data.PlayerPositionData;
|
||||
import land.chipmunk.parker2991.nitoribot.data.PlayerProfileData;
|
||||
import land.chipmunk.parker2991.nitoribot.listeners.Listener;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlayerListModule extends Listener {
|
||||
private Bot bot;
|
||||
@@ -101,17 +94,26 @@ public class PlayerListModule extends Listener {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Nullable
|
||||
public final PlayerProfileData getPlayerUUID (UUID uuid) {
|
||||
PlayerProfileData playerInfo = null;
|
||||
|
||||
for (PlayerProfileData player : list) {
|
||||
if (player.profile.getId().equals(uuid)) {
|
||||
playerInfo = player;
|
||||
try {
|
||||
// lazy ass fix for the bot erroring when a player is null
|
||||
for (PlayerProfileData player : list) {
|
||||
//if (player.profile.getId() == null) {}
|
||||
|
||||
UUID playerUUID = player.profile.getId();
|
||||
|
||||
if (playerUUID == null) return playerInfo;
|
||||
else if (player.profile.getId().equals(uuid)) {
|
||||
playerInfo = player;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (playerInfo == null) {};
|
||||
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return playerInfo;
|
||||
}
|
||||
|
||||
@@ -125,6 +127,16 @@ public class PlayerListModule extends Listener {
|
||||
return null;
|
||||
}
|
||||
|
||||
public final PlayerProfileData getPlayerByUsername (String username) {
|
||||
for (PlayerProfileData candidate : list) {
|
||||
if (candidate.profile.getName().equals(username)) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void updateListed (PlayerListEntry player) {
|
||||
PlayerProfileData getPlayer = getPlayerUUID(player.getProfileId());
|
||||
|
||||
@@ -138,7 +150,7 @@ public class PlayerListModule extends Listener {
|
||||
|
||||
if (getPlayer == null) return;
|
||||
|
||||
getPlayer.gameMode = player.getGameMode();
|
||||
else getPlayer.gameMode = player.getGameMode();
|
||||
}
|
||||
|
||||
public void updateLatency (PlayerListEntry player) {
|
||||
@@ -146,7 +158,7 @@ public class PlayerListModule extends Listener {
|
||||
|
||||
if (getPlayer == null) return;
|
||||
|
||||
getPlayer.latency = player.getLatency();
|
||||
else getPlayer.latency = player.getLatency();
|
||||
}
|
||||
|
||||
public void updateDisplayName (PlayerListEntry player) {
|
||||
@@ -154,7 +166,7 @@ public class PlayerListModule extends Listener {
|
||||
|
||||
if (getPlayer == null) return;
|
||||
|
||||
getPlayer.displayName = player.getDisplayName();
|
||||
else getPlayer.displayName = player.getDisplayName();
|
||||
}
|
||||
|
||||
public void addPlayer (PlayerListEntry player) {
|
||||
@@ -177,6 +189,8 @@ public class PlayerListModule extends Listener {
|
||||
public void playerRemove (ClientboundPlayerInfoRemovePacket packet) {
|
||||
for (UUID uuid : packet.getProfileIds()) {
|
||||
PlayerProfileData getPlayer = getPlayerUUID(uuid);
|
||||
|
||||
if (getPlayer == null) return;
|
||||
list.remove(getPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,22 +2,32 @@ package land.chipmunk.parker2991.nitoribot.modules;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.Bot;
|
||||
import land.chipmunk.parker2991.nitoribot.data.PositionData;
|
||||
import land.chipmunk.parker2991.nitoribot.listeners.*;
|
||||
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerPositionPacket;
|
||||
import org.geysermc.mcprotocollib.network.packet.Packet;
|
||||
import org.geysermc.mcprotocollib.network.Session;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.level.ServerboundAcceptTeleportationPacket;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.listeners.Listener;
|
||||
import org.cloudburstmc.math.vector.Vector3d;
|
||||
import org.geysermc.mcprotocollib.network.Session;
|
||||
import org.geysermc.mcprotocollib.network.packet.Packet;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerPositionPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.level.ServerboundAcceptTeleportationPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerPosPacket;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class PositionModule extends Listener {
|
||||
private Bot bot;
|
||||
|
||||
public ScheduledFuture<?> timer;
|
||||
|
||||
private int i = 0;
|
||||
|
||||
public Vector3d positionAsVector = null;
|
||||
|
||||
public PositionData positionAsInteger;
|
||||
|
||||
private int x;
|
||||
private int z;
|
||||
|
||||
@Override
|
||||
public void packetReceived (Session session, Packet packet) {
|
||||
if (packet instanceof ClientboundPlayerPositionPacket) packetReceived((ClientboundPlayerPositionPacket) packet);
|
||||
@@ -26,13 +36,35 @@ public class PositionModule extends Listener {
|
||||
public void packetReceived (ClientboundPlayerPositionPacket packet) {
|
||||
Vector3d getPosition = packet.getPosition();
|
||||
|
||||
int x = (int) Math.round(getPosition.getX());
|
||||
x = (int) Math.round(getPosition.getX());
|
||||
int y = (int) Math.round(getPosition.getY());
|
||||
int z = (int) Math.round(getPosition.getZ());
|
||||
|
||||
z = (int) Math.round(getPosition.getZ());
|
||||
|
||||
positionAsInteger = new PositionData(x, y, z);
|
||||
positionAsVector = getPosition;
|
||||
|
||||
if (bot.options.mode.equals("totalfreedom")) {
|
||||
if (i < 5) timer = bot.executor.scheduleAtFixedRate(() -> {
|
||||
System.out.println(i);
|
||||
x += 1;
|
||||
z += 1;
|
||||
|
||||
bot.session.send(
|
||||
new ServerboundMovePlayerPosPacket(
|
||||
false,
|
||||
false,
|
||||
x,
|
||||
y,
|
||||
z
|
||||
)
|
||||
);
|
||||
System.out.println("moved");
|
||||
System.out.println(x);
|
||||
i++;
|
||||
if (i > 5) timer.cancel(true);
|
||||
}, 5000, 5000, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
bot.session.send(
|
||||
new ServerboundAcceptTeleportationPacket(
|
||||
packet.getId()
|
||||
@@ -40,10 +72,11 @@ public class PositionModule extends Listener {
|
||||
);
|
||||
|
||||
for (Listener listener : bot.listenerManager.listeners) {
|
||||
if (! Objects.equals(bot.options.mode, "kaboom")) return;
|
||||
listener.botMoved();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public PositionModule (Bot bot) {
|
||||
this.bot = bot;
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ public class SelfcareModule extends Listener {
|
||||
}
|
||||
|
||||
public void login (ClientboundLoginFinishedPacket packet) {
|
||||
if (bot.options.mode.equals("totalfreedom")) return;
|
||||
timer = bot.executor.scheduleAtFixedRate(() -> {
|
||||
if (permission.level < 2 && bot.loggedIn == true) bot.chat.command("minecraft:op @s[type=player]");
|
||||
else if (gamemode.gamemode != 1) bot.session.send(
|
||||
|
||||
@@ -1,24 +1,14 @@
|
||||
package land.chipmunk.parker2991.nitoribot.modules;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.Bot;
|
||||
import land.chipmunk.parker2991.nitoribot.listeners.*;
|
||||
import land.chipmunk.parker2991.nitoribot.listeners.Listener;
|
||||
import land.chipmunk.parker2991.nitoribot.util.ComponentUtil;
|
||||
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.MetadataType;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.MetadataTypes;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.ByteMetadataType;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.type.EntityType;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.geysermc.mcprotocollib.network.Session;
|
||||
import org.geysermc.mcprotocollib.network.packet.Packet;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.ClientboundAddEntityPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.ClientboundSetEntityDataPacket;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TextDisplayModule extends Listener {
|
||||
private Bot bot;
|
||||
|
||||
|
||||
@@ -1,23 +1,75 @@
|
||||
{
|
||||
"buildstring": {
|
||||
"bot": {
|
||||
"version": "v9.0.0-alpha",
|
||||
"codename": "Night of Nights",
|
||||
"build": "5250"
|
||||
}
|
||||
"botName": [
|
||||
{
|
||||
"text": "Nitori",
|
||||
"color": "blue"
|
||||
},
|
||||
{
|
||||
"text": "Bot",
|
||||
"color": "green"
|
||||
}
|
||||
],
|
||||
"version": "v9.0.0-alpha",
|
||||
"codename": [
|
||||
{
|
||||
"text": "Night",
|
||||
"color": "blue"
|
||||
},
|
||||
{
|
||||
"text": " of ",
|
||||
"color": "dark_blue"
|
||||
},
|
||||
{
|
||||
"text": "Nights",
|
||||
"color": "blue"
|
||||
}
|
||||
],
|
||||
"build": "5300",
|
||||
"versionReleaseDate": "N\\A",
|
||||
"initialBotRelease": "11/22/22"
|
||||
},
|
||||
"owner": "Parker2991",
|
||||
"credits": [
|
||||
{ "name": "_ChipMC_", "reason": "v4.0.0 rewrite / v9.0.0 entity uuid / v9.0.0 chat command parsing" },
|
||||
{ "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" },
|
||||
{ "name": "_yfd", "reason": "rewriting the discord logging for v4.x and giving tht version a username gen" },
|
||||
{ "name": "aaa/ImFloriz", "reason": "v6.0.3 vanish support" },
|
||||
{ "name": "Ploat/ImGloriz/NamespaceDev", "reason": "v7.0.3 command core runTracked function" },
|
||||
{ "name": "TurtleKid", "reason": "v5.0.7b file logger rewrite" },
|
||||
{ "name": "Blackilykat", "reason": "v9.0.0 client creation / v9.0.0 config creation" },
|
||||
{ "name": "OptimisticDev", "reason": "v9.0.0 client creation / v9.0.0 ErrorToString function / v9.0.0 multi-server connecting / v9.0.0 jar creation" },
|
||||
{ "name": "PthePro777", "reason": "v9.0.0 client creation / v9.0.0 config yaml parsing" },
|
||||
{ "name": "Werkku", "reason": "v9.0.0 ComponentUtil functions / v9.0.0 command sending" }
|
||||
"contributors": [
|
||||
{
|
||||
"name": "_ChipMC_",
|
||||
"reason": "v4.0.0 rewrite / v9.0.0 entity uuid / v9.0.0 chat command parsing"
|
||||
},
|
||||
{
|
||||
"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"
|
||||
},
|
||||
{
|
||||
"name": "_yfd",
|
||||
"reason": "rewriting the discord logging for v4.x and giving tht version a username gen"
|
||||
},
|
||||
{
|
||||
"name": "aaa/ImFloriz",
|
||||
"reason": "v6.0.3 vanish support"
|
||||
},
|
||||
{
|
||||
"name": "Ploat/ImGloriz/NamespaceDev",
|
||||
"reason": "v7.0.3 command core runTracked function"
|
||||
},
|
||||
{
|
||||
"name": "TurtleKid",
|
||||
"reason": "v5.0.7b file logger rewrite"
|
||||
},
|
||||
{
|
||||
"name": "Blackilykat",
|
||||
"reason": "v9.0.0 client creation / v9.0.0 config creation"
|
||||
},
|
||||
{
|
||||
"name": "OptimisticDev",
|
||||
"reason": "v9.0.0 client creation / v9.0.0 ErrorToString function / v9.0.0 multi-server connecting / v9.0.0 jar creation"
|
||||
},
|
||||
{
|
||||
"name": "PthePro777",
|
||||
"reason": "v9.0.0 client creation / v9.0.0 config yaml parsing"
|
||||
},
|
||||
{
|
||||
"name": "Werkku",
|
||||
"reason": "v9.0.0 ComponentUtil functions / v9.0.0 command sending"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user