mirror of
https://code.chipmunk.land/Parker2991/NitoriBot/
synced 2026-12-05 08:35:39 -05:00
v9.0.0 build:5919. finally finished after almost a year!
This commit is contained in:
@@ -16,6 +16,7 @@ import org.geysermc.mcprotocollib.network.factory.ClientNetworkSessionFactory;
|
||||
import org.geysermc.mcprotocollib.network.packet.Packet;
|
||||
import org.geysermc.mcprotocollib.protocol.MinecraftProtocol;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundPlayerInfoUpdatePacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.ServerboundPlayerLoadedPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.login.clientbound.ClientboundLoginFinishedPacket;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
@@ -57,7 +58,8 @@ public @NullMarked class Client extends NitoriBot {
|
||||
this.world = new WorldModule(this),
|
||||
this.tabComplete = new TabCompleteModule(this),
|
||||
this.extrasMessaging = new ExtrasMessagingModule(this),
|
||||
this.validation = new ValidationModule(this)
|
||||
this.validation = new ValidationModule(this),
|
||||
this.cloop = new CloopModule(this)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -100,6 +102,7 @@ public @NullMarked class Client extends NitoriBot {
|
||||
switch (packet) {
|
||||
case ClientboundLoginFinishedPacket p -> getProfile(p);
|
||||
case ClientboundLoginPacket p -> getEntityId(p);
|
||||
case ClientboundPlayerInfoUpdatePacket p -> getBotProfileChanges(p);
|
||||
default -> {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,11 @@ import land.chipmunk.code.kaboomstandardsorganization.messaginglib.mcprotocollib
|
||||
import land.chipmunk.code.kaboomstandardsorganization.messaginglib.mcprotocollib.MCProtocolLibMessenger;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.boot.GetProxiesList;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.chatattestation.ChatAttestation;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.console.CreateConsole;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.console.logger.LoggerManager;
|
||||
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.modules.*;
|
||||
import static land.chipmunk.parker2991.nitoribot.nightofnights.util.UsernameGenUtil.generateUsername;
|
||||
@@ -27,9 +29,13 @@ import org.geysermc.mcprotocollib.network.netty.DefaultPacketHandlerExecutor;
|
||||
import org.geysermc.mcprotocollib.network.session.ClientNetworkSession;
|
||||
import org.geysermc.mcprotocollib.protocol.MinecraftConstants;
|
||||
import org.geysermc.mcprotocollib.protocol.MinecraftProtocol;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.PlayerListEntry;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.PlayerListEntryAction;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundPlayerInfoUpdatePacket;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -40,6 +46,7 @@ import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
public class NitoriBot extends SessionAdapter implements MCProtocolLibMessagingEntrypoint {
|
||||
public final LoggerManager logger = new LoggerManager();
|
||||
public final CreateConsole console = Main.console;
|
||||
public final ListenerManager listenerManager = new ListenerManager();
|
||||
public final ScheduledExecutorService scheduler = Main.scheduler;
|
||||
public final BotBuildInfo botBuildInfo = Main.botBuildInfo;
|
||||
@@ -53,6 +60,7 @@ public class NitoriBot extends SessionAdapter implements MCProtocolLibMessagingE
|
||||
public PlayerListModule players;
|
||||
public RegistryModule registry;
|
||||
public ValidationModule validation;
|
||||
public String username;
|
||||
public boolean loggedIn = false;
|
||||
public int entityId;
|
||||
public ClientNetworkSession session;
|
||||
@@ -61,6 +69,7 @@ public class NitoriBot extends SessionAdapter implements MCProtocolLibMessagingE
|
||||
public MCServerModule mcServer;
|
||||
public WorldModule world;
|
||||
public TabCompleteModule tabComplete;
|
||||
public CloopModule cloop;
|
||||
public ExtrasMessagingModule extrasMessaging;
|
||||
public List<?> modules;
|
||||
public DiscordModule discord;
|
||||
@@ -98,8 +107,35 @@ public class NitoriBot extends SessionAdapter implements MCProtocolLibMessagingE
|
||||
session.disconnect("Killing Bot Process");
|
||||
}
|
||||
|
||||
public void getBotProfileChanges(ClientboundPlayerInfoUpdatePacket packet) {
|
||||
EnumSet<PlayerListEntryAction> actions = packet.getActions();
|
||||
|
||||
for (PlayerListEntryAction action : actions) {
|
||||
for (PlayerListEntry entry : packet.getEntries()) {
|
||||
switch (action) {
|
||||
case PlayerListEntryAction.UPDATE_LISTED -> {
|
||||
if (entry.getProfileId().equals(profile.getId())) {
|
||||
for (Listener listener : listenerManager.listeners) {
|
||||
listener.botUsernameUpdated(entry.getProfile().getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
case PlayerListEntryAction.UPDATE_DISPLAY_NAME -> {
|
||||
if (entry.getProfileId().equals(profile.getId())) {
|
||||
for (Listener listener : listenerManager.listeners) {
|
||||
listener.botDisplayUpdated(entry.getDisplayName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void connect () throws IOException {
|
||||
final MinecraftProtocol protocol = new MinecraftProtocol(generateUsername());
|
||||
if (options.username == null) username = generateUsername();
|
||||
else username = options.username;
|
||||
final MinecraftProtocol protocol = new MinecraftProtocol(username);
|
||||
DefaultPacketHandlerExecutor.USE_EVENT_LOOP_FOR_PACKETS = false;
|
||||
|
||||
if (options.useProxy)
|
||||
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.chatparsers.kaboom;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.NitoriBot;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.data.PlayerProfileData;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.data.chat.ChatType;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.data.chat.ParseChatData;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.data.chat.PlayerMessageData;
|
||||
import static land.chipmunk.parker2991.nitoribot.nightofnights.util.ComponentUtil.componentToString;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.TranslatableComponent;
|
||||
import net.kyori.adventure.text.TranslationArgument;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
import net.kyori.adventure.text.event.HoverEventSource;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ChipmunkModChatParser implements ParseChatData {
|
||||
private NitoriBot bot;
|
||||
|
||||
public ChipmunkModChatParser (NitoriBot bot) {
|
||||
this.bot = bot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerMessageData parse(ChatType chatType, Component message) {
|
||||
if (message instanceof TranslatableComponent) {
|
||||
return this.parse(chatType, (TranslatableComponent) message);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public PlayerMessageData parse (
|
||||
ChatType chatType,
|
||||
TranslatableComponent message
|
||||
) {
|
||||
final List<TranslationArgument> children = message.arguments();
|
||||
if ((!message.key().equals("[%s] %s › %s") && !message.key().equals("%s %s › " +
|
||||
"%s"))) return null;
|
||||
|
||||
Component senderComponent = children.get(1).asComponent();
|
||||
Component contents = children.get(2).asComponent();
|
||||
|
||||
PlayerProfileData sender;
|
||||
|
||||
final HoverEvent<?> hoverEvent = senderComponent.hoverEvent();
|
||||
|
||||
if (hoverEvent != null && hoverEvent.action().equals(HoverEvent.Action.SHOW_ENTITY)) {
|
||||
final HoverEvent.ShowEntity entityInfo = (HoverEvent.ShowEntity)hoverEvent.value();
|
||||
final UUID senderUUID = entityInfo.id();
|
||||
sender = this.bot.players.getPlayerUUID(senderUUID);
|
||||
} else {
|
||||
final String stringUsername = componentToString(senderComponent);
|
||||
sender = this.bot.players.getPlayerByUsername(stringUsername);//getEntry(stringUsername);
|
||||
}
|
||||
|
||||
if (sender == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new PlayerMessageData(
|
||||
sender,
|
||||
contents,
|
||||
chatType,
|
||||
contents
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
+2
@@ -13,5 +13,7 @@ public interface CommandInfo {
|
||||
|
||||
List<String> getUsages ();
|
||||
|
||||
boolean getPlayerChatOnly ();
|
||||
|
||||
Component execute (CommandContext context) throws CommandError;
|
||||
}
|
||||
+12
-1
@@ -49,7 +49,18 @@ public record CommandSource(
|
||||
.queue();
|
||||
}
|
||||
case CommandMessageSource.CONSOLE -> {
|
||||
|
||||
Component host = Component
|
||||
.text(String.format(
|
||||
"[%s:%s] ",
|
||||
bot.options.host,
|
||||
bot.options.port
|
||||
))
|
||||
.color(NamedTextColor.BLUE);
|
||||
Component format = Component
|
||||
.empty()
|
||||
.append(host)
|
||||
.append(component);
|
||||
bot.logger.command(componentToAnsi(format));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -36,6 +36,11 @@ public class CoreCommand implements CommandInfo {
|
||||
return List.of("<command>");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerChatOnly () {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component execute (CommandContext context) {
|
||||
NitoriBot bot = context.bot();
|
||||
|
||||
+5
@@ -13,6 +13,11 @@ public class EchoCommand implements CommandInfo {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerChatOnly () {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandTrustLevels getTrustLevel () {
|
||||
return CommandTrustLevels.PUBLIC;
|
||||
|
||||
+5
@@ -18,6 +18,11 @@ public class HelpCommand implements CommandInfo {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerChatOnly () {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandTrustLevels getTrustLevel () {
|
||||
return CommandTrustLevels.PUBLIC;
|
||||
|
||||
+8
-2
@@ -63,6 +63,12 @@ public class InfoCommand implements CommandInfo {
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerChatOnly () {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getDescription () {
|
||||
return "see the bots info";
|
||||
@@ -272,9 +278,9 @@ public class InfoCommand implements CommandInfo {
|
||||
case "version" -> {
|
||||
component = Component
|
||||
.translatable(
|
||||
"%s-%s\n%s: %s\n%s: %s\n%s: %s\n%s: %s",
|
||||
"%s-%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)),
|
||||
Component.text(info.buildstring.version).color(convertColorString(bot.config.colors.commands.secondary)),
|
||||
gson.deserialize(info.buildstring.codename.toString()),
|
||||
Component
|
||||
.text("Build")
|
||||
|
||||
+6
@@ -43,6 +43,12 @@ public class ListCommand implements CommandInfo {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerChatOnly () {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Component execute (CommandContext context) {
|
||||
NitoriBot bot = context.bot();
|
||||
|
||||
+5
@@ -17,6 +17,11 @@ public class MCServerCommand implements CommandInfo {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerChatOnly () {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandTrustLevels getTrustLevel () {
|
||||
return CommandTrustLevels.PUBLIC;
|
||||
|
||||
+4
@@ -11,6 +11,10 @@ import net.kyori.adventure.text.Component;
|
||||
import java.util.List;
|
||||
|
||||
public class NetmsgCommand implements CommandInfo {
|
||||
@Override
|
||||
public boolean getPlayerChatOnly () {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandTrustLevels getTrustLevel () {
|
||||
|
||||
+5
@@ -17,6 +17,11 @@ public class PlayerInfoCommand implements CommandInfo {
|
||||
public CommandTrustLevels getTrustLevel () {
|
||||
return CommandTrustLevels.PUBLIC;
|
||||
}
|
||||
@Override
|
||||
public boolean getPlayerChatOnly () {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> getAliases () {
|
||||
|
||||
+6
@@ -15,6 +15,12 @@ public class RCCommand implements CommandInfo {
|
||||
public RCCommand () {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerChatOnly () {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandTrustLevels getTrustLevel () {
|
||||
return CommandTrustLevels.PUBLIC;
|
||||
|
||||
+5
@@ -15,6 +15,11 @@ public class RTPCommand implements CommandInfo {
|
||||
return CommandTrustLevels.PUBLIC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerChatOnly () {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAliases () {
|
||||
return List.of(
|
||||
|
||||
+5
@@ -25,6 +25,11 @@ public class TestCommand implements CommandInfo {
|
||||
public TestCommand () {
|
||||
|
||||
}
|
||||
@Override
|
||||
public boolean getPlayerChatOnly () {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandTrustLevels getTrustLevel () {
|
||||
|
||||
+6
@@ -25,6 +25,12 @@ public class WeatherCommand implements CommandInfo {
|
||||
return CommandTrustLevels.PUBLIC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerChatOnly () {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> getAliases () {
|
||||
return List.of("weather");
|
||||
|
||||
+5
@@ -15,6 +15,11 @@ public class NetcmdCommand implements CommandInfo {
|
||||
return CommandTrustLevels.ADMIN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerChatOnly () {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAliases () {
|
||||
return List.of("netcmd");
|
||||
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.commands.console;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.NitoriBot;
|
||||
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 net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ConsoleCommand implements CommandInfo {
|
||||
@Override
|
||||
public CommandTrustLevels getTrustLevel () {
|
||||
return CommandTrustLevels.CONSOLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAliases () {
|
||||
return List.of("console");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription () {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getUsages () {
|
||||
return List.of(
|
||||
"server/srv <all/servername>",
|
||||
"customchat <on/true/enable/off/false/disable>",
|
||||
"say <message>",
|
||||
"validate/validation/val <owner/o/admin/a/trusted/t>",
|
||||
"logging/togglelogging/logtoconsole <on/true/enable/off/false/disable>"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerChatOnly () {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component execute (CommandContext context) throws CommandError {
|
||||
final NitoriBot bot = context.bot();
|
||||
final String[] args = context.args();
|
||||
Component component = null;
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "server" -> {
|
||||
for (final NitoriBot eachBot : bot.bots) {
|
||||
if (eachBot.options.serverName.toLowerCase().equals(args[1])) {
|
||||
eachBot.console.server = eachBot.options.serverName;
|
||||
component = Component.text("Set the console server to " + eachBot.console.server);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return component;
|
||||
}
|
||||
}
|
||||
+5
@@ -35,6 +35,11 @@ public class KillCommand implements CommandInfo {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerChatOnly () {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component execute (CommandContext context) throws CommandError {
|
||||
NitoriBot bot = context.bot();
|
||||
|
||||
+5
@@ -38,6 +38,11 @@ public class ServerEvalCommand implements CommandInfo {
|
||||
return List.of("<code>");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerChatOnly () {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component execute (CommandContext context) throws CommandError {
|
||||
final NitoriBot bot = context.bot();
|
||||
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.commands.trusted;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.NitoriBot;
|
||||
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.CloopData;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class CloopCommand implements CommandInfo {
|
||||
@Override
|
||||
public CommandTrustLevels getTrustLevel () {
|
||||
return CommandTrustLevels.TRUSTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAliases () {
|
||||
return List.of("cloop");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription () {
|
||||
return "run cloops via the bots core";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getUsages () {
|
||||
return List.of("add <interval> <command>", "remove <index>", "clear", "list");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerChatOnly () {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component execute (CommandContext context) throws CommandError {
|
||||
final NitoriBot bot = context.bot();
|
||||
final String[] args = context.args();
|
||||
Component component = null;
|
||||
|
||||
switch (args[0]) {
|
||||
case "add" -> {
|
||||
String command = String.join(" ",
|
||||
Arrays.copyOfRange(args, 2, args.length)
|
||||
);
|
||||
bot.cloop.add(
|
||||
command,
|
||||
Long.parseLong(args[1])
|
||||
);
|
||||
|
||||
component = Component.translatable(
|
||||
"added %s to the cloops with the interval %s",
|
||||
Component.text(command),
|
||||
Component.text(Long.parseLong(args[1]))
|
||||
);
|
||||
}
|
||||
|
||||
case "remove" -> {
|
||||
bot.cloop.remove(Integer.parseInt(args[1]));
|
||||
component = Component.translatable(
|
||||
"removed %s from the cloops",
|
||||
Component.text(Integer.parseInt(args[1]))
|
||||
);
|
||||
}
|
||||
|
||||
case "clear" -> {
|
||||
bot.cloop.clear();
|
||||
component = Component.text("Cleared the cloops");
|
||||
}
|
||||
|
||||
case "list" -> {
|
||||
final List<Component> cloopList = new ArrayList<>();
|
||||
int i = 0;
|
||||
for (CloopData cloop : bot.cloop.list) {
|
||||
cloopList.add(
|
||||
Component.translatable(
|
||||
"%s \u203a %s (%s)",
|
||||
Component.text(i),
|
||||
Component.text(cloop.command()),
|
||||
Component.text(cloop.interval())
|
||||
)
|
||||
);
|
||||
cloopList.add(Component.newline());
|
||||
i++;
|
||||
}
|
||||
|
||||
component = Component.empty()
|
||||
.append(
|
||||
Component.translatable(
|
||||
"Cloops (%s):",
|
||||
Component.text(bot.cloop.list.size())
|
||||
)
|
||||
).append(
|
||||
Component.newline()
|
||||
).append(cloopList);
|
||||
}
|
||||
|
||||
default -> {
|
||||
}
|
||||
}
|
||||
|
||||
return component;
|
||||
}
|
||||
}
|
||||
+6
@@ -13,6 +13,12 @@ public class ReconnectCommand implements CommandInfo {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerChatOnly () {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandTrustLevels getTrustLevel () {
|
||||
return CommandTrustLevels.TRUSTED;
|
||||
|
||||
+6
@@ -17,6 +17,12 @@ public class ValidateCommand implements CommandInfo {
|
||||
return CommandTrustLevels.TRUSTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPlayerChatOnly () {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> getAliases () {
|
||||
return List.of(
|
||||
|
||||
+38
-9
@@ -1,16 +1,19 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.console;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.NitoriBot;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.Main;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.NitoriBot;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandMessageSource;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandSource;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.data.chat.ChatType;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.data.chat.ParsedChatType;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jline.reader.*;
|
||||
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
import java.util.List;
|
||||
|
||||
public class CreateConsole implements Completer {
|
||||
private static final List<NitoriBot> servers = Main.Bots;
|
||||
public LineReader reader;
|
||||
public final String server = "all";
|
||||
public String server = "all";
|
||||
|
||||
@Override
|
||||
public void complete (
|
||||
@@ -21,10 +24,31 @@ public class CreateConsole implements Completer {
|
||||
|
||||
}
|
||||
|
||||
private void handleLine (String line) {
|
||||
for (NitoriBot bot : servers) {
|
||||
if (line.equals(bot.config.console.prefix + "kill"))
|
||||
System.exit(0);
|
||||
private void handleLine (
|
||||
NitoriBot bot,
|
||||
String line
|
||||
) {
|
||||
if (bot.options.serverName != this.server && this.server != "all") return;
|
||||
if (line.startsWith(Main.config.console.prefix)) {
|
||||
|
||||
final CommandSource source = new CommandSource(
|
||||
null,
|
||||
null,
|
||||
CommandMessageSource.CONSOLE,
|
||||
ChatType.PLAYER,
|
||||
ParsedChatType.NORMAL
|
||||
);
|
||||
|
||||
Component output = bot.commandManager.executeString(
|
||||
source,
|
||||
line.substring(bot.config.console.prefix.length())
|
||||
);
|
||||
|
||||
source.sendFeedback(
|
||||
bot,
|
||||
output
|
||||
);
|
||||
} else {
|
||||
bot.chat.send(line);
|
||||
}
|
||||
}
|
||||
@@ -48,7 +72,12 @@ public class CreateConsole implements Completer {
|
||||
this.server
|
||||
));
|
||||
|
||||
handleLine(line);
|
||||
for (final NitoriBot bot : Main.Bots) {
|
||||
handleLine(
|
||||
bot,
|
||||
line
|
||||
);
|
||||
}
|
||||
} catch (Exception _) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.data;
|
||||
|
||||
public record CloopData (String command, long interval) {}
|
||||
@@ -30,6 +30,10 @@ public interface Listener {
|
||||
) {
|
||||
}
|
||||
|
||||
default void botUsernameUpdated (String username) {}
|
||||
|
||||
default void botDisplayUpdated (Component displayName) {}
|
||||
|
||||
default void parsedMessage (PlayerMessageData data) {
|
||||
}
|
||||
|
||||
|
||||
+32
-7
@@ -2,6 +2,7 @@ package land.chipmunk.parker2991.nitoribot.nightofnights.modules;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.NitoriBot;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.chatattestation.MessagingEntrypointImpl;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.chatparsers.kaboom.ChipmunkModChatParser;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.chatparsers.kaboom.KaboomChatParser;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.data.chat.ChatTranslationsData;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.data.chat.ChatType;
|
||||
@@ -19,19 +20,23 @@ import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.Clientbound
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundSystemChatPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.ServerboundChatCommandPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.ServerboundChatPacket;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
|
||||
public class ChatModule implements Listener {
|
||||
public final List<ParseChatData> chatParsers;
|
||||
public final List<ParseChatData> chatParsers = new ArrayList<>();
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ChatModule.class);
|
||||
private final NitoriBot bot;
|
||||
|
||||
public ChatModule (NitoriBot bot) {
|
||||
this.bot = bot;
|
||||
|
||||
this.chatParsers = List.of(new KaboomChatParser(bot));
|
||||
chatParsers.add(new KaboomChatParser(bot));
|
||||
chatParsers.add(new ChipmunkModChatParser(bot));
|
||||
//this.chatParsers = List.of(new KaboomChatParser(bot), new ChipmunkModChatParser(bot));
|
||||
|
||||
bot.listenerManager.addListener(this);
|
||||
}
|
||||
@@ -76,6 +81,13 @@ public class ChatModule implements Listener {
|
||||
) return;
|
||||
}
|
||||
|
||||
|
||||
parseMessage(
|
||||
ChatType.SYSTEM,
|
||||
message,
|
||||
null
|
||||
);
|
||||
|
||||
for (Listener listener : bot.listenerManager.listeners) {
|
||||
listener.systemChatReceived(message);
|
||||
listener.chatMessageReceived(
|
||||
@@ -83,6 +95,19 @@ public class ChatModule implements Listener {
|
||||
message
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
parseMessage(
|
||||
ChatType.PLAYER,
|
||||
unsignedContent,
|
||||
new PlayerMessageData(
|
||||
bot.players.getPlayerUUID(packet.getSender()),
|
||||
content,
|
||||
ChatType.PLAYER,
|
||||
Objects.requireNonNull(bot.players.getPlayerUUID(packet.getSender())).displayName
|
||||
)
|
||||
);
|
||||
*/
|
||||
}
|
||||
|
||||
public void disguisedChat (ClientboundDisguisedChatPacket packet) {
|
||||
@@ -174,7 +199,6 @@ public class ChatModule implements Listener {
|
||||
) {
|
||||
try {
|
||||
PlayerMessageData parsed = null;
|
||||
|
||||
for (ParseChatData parser : chatParsers) {
|
||||
parsed = parser.parse(
|
||||
chatType,
|
||||
@@ -188,7 +212,7 @@ public class ChatModule implements Listener {
|
||||
return;
|
||||
|
||||
for (Listener listener : bot.listenerManager.listeners) {
|
||||
if (data.chatType() == ChatType.DISGUISED) {
|
||||
if (parsed.chatType() == ChatType.DISGUISED) {
|
||||
final PlayerMessageData playerMessageData = new PlayerMessageData(
|
||||
parsed.sender(),
|
||||
parsed.contents(),
|
||||
@@ -197,10 +221,11 @@ public class ChatModule implements Listener {
|
||||
);
|
||||
listener.parsedMessage(playerMessageData);
|
||||
} else
|
||||
listener.parsedMessage(data);
|
||||
listener.parsedMessage(parsed);
|
||||
}
|
||||
|
||||
} catch (Exception ignore) {
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("{}", e.getClass(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.modules;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.NitoriBot;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.data.CloopData;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class CloopModule {
|
||||
private NitoriBot bot;
|
||||
|
||||
public CloopModule (NitoriBot bot) {
|
||||
this.bot = bot;
|
||||
}
|
||||
|
||||
private final List<Future<?>> executorList = new ArrayList<>();
|
||||
public final List<CloopData> list = new ArrayList<>();
|
||||
|
||||
public void add (String command, long interval) {
|
||||
Future<?> runnable = bot.scheduler.scheduleAtFixedRate(() -> bot.core.run(command), 0, interval,
|
||||
TimeUnit.MILLISECONDS);
|
||||
executorList.add(
|
||||
runnable
|
||||
);
|
||||
|
||||
list.add(new CloopData(command, interval));
|
||||
}
|
||||
|
||||
public void remove (int index) {
|
||||
if (list.get(index) != null) {
|
||||
executorList.get(index).cancel(true);
|
||||
list.remove(index);
|
||||
}
|
||||
}
|
||||
|
||||
public void clear () {
|
||||
for (Future<?> cloop : executorList) {
|
||||
cloop.cancel(true);
|
||||
}
|
||||
|
||||
list.clear();
|
||||
}
|
||||
|
||||
}
|
||||
+25
-29
@@ -4,8 +4,10 @@ import land.chipmunk.parker2991.nitoribot.nightofnights.NitoriBot;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.*;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.commands.Public.*;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.commands.admin.NetcmdCommand;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.commands.console.ConsoleCommand;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.commands.owner.KillCommand;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.commands.owner.ServerEvalCommand;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.commands.trusted.CloopCommand;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.commands.trusted.ReconnectCommand;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.commands.trusted.ValidateCommand;
|
||||
|
||||
@@ -49,6 +51,8 @@ public class CommandManagerModule {
|
||||
registerCommand(new ServerEvalCommand());
|
||||
registerCommand(new NetcmdCommand());
|
||||
registerCommand(new WeatherCommand());
|
||||
registerCommand(new ConsoleCommand());
|
||||
registerCommand(new CloopCommand());
|
||||
}
|
||||
|
||||
public void registerCommand (CommandInfo command) {
|
||||
@@ -112,16 +116,15 @@ public class CommandManagerModule {
|
||||
CommandInfo command = getCommand(commandName.toLowerCase());
|
||||
|
||||
if (command == null)
|
||||
throw new CommandError(Component
|
||||
.translatable(
|
||||
"%s%s%s %s",
|
||||
Component.translatable("command.unknown.command"),
|
||||
Component.text("\n"),
|
||||
Component
|
||||
.text(commandName)
|
||||
.color(NamedTextColor.GRAY),
|
||||
Component.translatable("command.context.here")
|
||||
));
|
||||
throw new CommandError(Component.translatable(
|
||||
"%s%s%s %s",
|
||||
Component.translatable("command.unknown.command"),
|
||||
Component.text("\n"),
|
||||
Component
|
||||
.text(commandName)
|
||||
.color(NamedTextColor.GRAY),
|
||||
Component.translatable("command.context.here")
|
||||
));
|
||||
|
||||
CommandContext context = new CommandContext(
|
||||
bot,
|
||||
@@ -133,7 +136,7 @@ public class CommandManagerModule {
|
||||
.getTrustLevel()
|
||||
.level();
|
||||
|
||||
if (cmdTrustLevel != 0 && cmdTrustLevel < 4) {
|
||||
if (cmdTrustLevel != 0 && cmdTrustLevel < 4 && source.source() != CommandMessageSource.CONSOLE) {
|
||||
if (source
|
||||
.source()
|
||||
.equals(CommandMessageSource.DISCORD)) {
|
||||
@@ -146,13 +149,12 @@ public class CommandManagerModule {
|
||||
final Component playerTrustLevelComponent = convertTrustLevelIdToComponent(userTrustLevel);
|
||||
final Component cmdTrustLevelComponent = convertTrustLevelIdToComponent(cmdTrustLevel);
|
||||
|
||||
throw new CommandError(Component
|
||||
.translatable(
|
||||
"Your Trust Level (%s) does not meet the required Trust Level (%s) for the command: %s",
|
||||
playerTrustLevelComponent,
|
||||
cmdTrustLevelComponent,
|
||||
Component.text(commandName)
|
||||
));
|
||||
throw new CommandError(Component.translatable(
|
||||
"Your Trust Level (%s) does not meet the required Trust Level (%s) for the command: %s",
|
||||
playerTrustLevelComponent,
|
||||
cmdTrustLevelComponent,
|
||||
Component.text(commandName)
|
||||
));
|
||||
}
|
||||
} else {
|
||||
final int playerTrustLevel = source.sender().trustLevel.level();
|
||||
@@ -172,17 +174,11 @@ public class CommandManagerModule {
|
||||
throw new CommandError(Component.text("Invalid Hash"));
|
||||
}
|
||||
}
|
||||
} if (command
|
||||
.getTrustLevel()
|
||||
.level() != 0 && source.chatType() != ChatType.PLAYER && source.parsedChatType() == ParsedChatType.COMMANDSPY && source.discordEvent() == null)
|
||||
throw new CommandError(Component.translatable(
|
||||
"The command (%s) can only be ran via player chat!",
|
||||
Component
|
||||
.text(command
|
||||
.getAliases()
|
||||
.getFirst())
|
||||
.color(convertColorString(bot.config.colors.commands.primary))
|
||||
));
|
||||
}
|
||||
|
||||
if (command.getPlayerChatOnly() == true && source.chatType() != ChatType.PLAYER) return null;
|
||||
|
||||
if (source.source() != CommandMessageSource.CONSOLE && command.getTrustLevel().level() == 4) throw new CommandError(Component.text("This command can only be ran via console!"));
|
||||
|
||||
commandOutput = command.execute(context);
|
||||
} catch (CommandError error) {
|
||||
|
||||
+6
-3
@@ -101,6 +101,11 @@ public class DiscordModule extends ListenerAdapter implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
String globalName = event
|
||||
.getAuthor()
|
||||
.getGlobalName();
|
||||
assert globalName != null;
|
||||
|
||||
Component component = Component
|
||||
.translatable(
|
||||
"[%s] %s \u203a %s",
|
||||
@@ -117,9 +122,7 @@ public class DiscordModule extends ListenerAdapter implements Listener {
|
||||
.color(NamedTextColor.DARK_BLUE)
|
||||
),
|
||||
Component
|
||||
.text(event
|
||||
.getAuthor()
|
||||
.getName())
|
||||
.text(globalName)
|
||||
.color(NamedTextColor.GRAY),
|
||||
Component
|
||||
.text(event
|
||||
|
||||
+24
-4
@@ -2,8 +2,13 @@ package land.chipmunk.parker2991.nitoribot.nightofnights.modules;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.NitoriBot;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.listeners.Listener;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.selfcare.entity.DisplayNameSelfcare;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.selfcare.entity.GamemodeSelfcare;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.selfcare.entity.PermissionSelfcare;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.selfcare.essentials.GodSelfcare;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.selfcare.essentials.MuteSelfcare;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.selfcare.extras.CommandSpySelfcare;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.selfcare.extras.UsernameSelfcare;
|
||||
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;
|
||||
@@ -16,10 +21,13 @@ import java.util.concurrent.TimeUnit;
|
||||
public class SelfcareModule implements Listener {
|
||||
private final NitoriBot bot;
|
||||
public ScheduledFuture<?> timer;
|
||||
public PermissionSelfcare permission;
|
||||
|
||||
public GamemodeSelfcare gamemode;
|
||||
|
||||
private PermissionSelfcare permission;
|
||||
private GamemodeSelfcare gamemode;
|
||||
private MuteSelfcare mute;
|
||||
private CommandSpySelfcare commandSpy;
|
||||
private UsernameSelfcare username;
|
||||
private DisplayNameSelfcare displayName;
|
||||
private GodSelfcare god;
|
||||
public int entityId;
|
||||
|
||||
public SelfcareModule (NitoriBot bot) {
|
||||
@@ -31,6 +39,11 @@ public class SelfcareModule implements Listener {
|
||||
public void loadSelfcare () {
|
||||
this.permission = new PermissionSelfcare(bot);
|
||||
this.gamemode = new GamemodeSelfcare(bot);
|
||||
this.mute = new MuteSelfcare(bot);
|
||||
this.commandSpy = new CommandSpySelfcare(bot);
|
||||
this.username = new UsernameSelfcare(bot);
|
||||
this.displayName = new DisplayNameSelfcare(bot);
|
||||
//this.god = new GodSelfcare(bot);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -52,6 +65,13 @@ public class SelfcareModule implements Listener {
|
||||
bot.chat.command("minecraft:op @s[type=player]");
|
||||
else if (gamemode.gamemode != 1)
|
||||
bot.session.send(new ServerboundChangeGameModePacket(GameMode.CREATIVE));
|
||||
|
||||
else if (mute.muted) bot.core.run("essentials:unmute " + bot.profile.getIdAsString());
|
||||
else if (!commandSpy.enabled) bot.core.run(String.format("commandspy %s on", bot.profile.getIdAsString()));
|
||||
else if (username.usernameChanged) bot.chat.command("username " + bot.profile.getName());
|
||||
else if (displayName.rankChanged) bot.chat.command("prefix off");
|
||||
else if (displayName.displayNameChanged) bot.core.run(String.format("essentials:nick %s off", bot.profile.getIdAsString()));
|
||||
// else if (!god.enabled) bot.core.run(String.format("essentials:god %s on", bot.profile.getName()));
|
||||
},
|
||||
0,
|
||||
bot.options.selfcareInterval,
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.selfcare.entity;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.NitoriBot;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.listeners.Listener;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
|
||||
public class DisplayNameSelfcare implements Listener {
|
||||
private NitoriBot bot;
|
||||
private static final String DEFAULT_OP_PREFIX = "§4§l[§c§lOP§4§l]";
|
||||
private static final String DEFAULT_DEOP_PREFIX = "§8§l[§7§lDeOP§8§l]";
|
||||
public boolean displayNameChanged = false;
|
||||
public boolean rankChanged = false;
|
||||
|
||||
@Override
|
||||
public void botDisplayUpdated (Component displayName) {
|
||||
String prefix = LegacyComponentSerializer.legacySection().serialize(displayName.children().getFirst()).trim();
|
||||
String nickName = LegacyComponentSerializer
|
||||
.legacySection().serialize(displayName.children().getLast()).trim();
|
||||
if (prefix.equals(DEFAULT_DEOP_PREFIX) || nickName.equals(bot.profile.getName())) return;
|
||||
rankChanged = !prefix.equals(DEFAULT_OP_PREFIX);
|
||||
|
||||
displayNameChanged = !nickName.equals("§c" + bot.profile.getName());
|
||||
}
|
||||
|
||||
public DisplayNameSelfcare (NitoriBot bot) {
|
||||
this.bot = bot;
|
||||
bot.listenerManager.addListener(this);
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.selfcare.essentials;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.NitoriBot;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.listeners.Listener;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.util.ComponentUtil;
|
||||
import org.geysermc.mcprotocollib.network.packet.Packet;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundSystemChatPacket;
|
||||
|
||||
public class GodSelfcare implements Listener {
|
||||
private static final String GOD_MODE_ENABLED_MESSAGE = "God mode enabled.";
|
||||
private static final String GOD_MODE_DISABLED_MESSAGE = "God mode disabled.";
|
||||
public boolean enabled = false;
|
||||
|
||||
@Override
|
||||
public void packetReceived (Packet packet) {
|
||||
if (packet instanceof final ClientboundSystemChatPacket p) {
|
||||
String content = ComponentUtil.componentToString(p.getContent());
|
||||
|
||||
System.out.println(content.equals(GOD_MODE_ENABLED_MESSAGE));
|
||||
if (content.equals(GOD_MODE_DISABLED_MESSAGE)) enabled = false;
|
||||
else if (content.equals(GOD_MODE_ENABLED_MESSAGE)) enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
public GodSelfcare (NitoriBot bot) {
|
||||
bot.listenerManager.addListener(this);
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.selfcare.essentials;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.NitoriBot;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.listeners.Listener;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.geysermc.mcprotocollib.network.packet.Packet;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundSystemChatPacket;
|
||||
|
||||
public class MuteSelfcare implements Listener {
|
||||
public boolean muted = false;
|
||||
private static final String MUTE_STRING = "You have been muted";
|
||||
private static final String UNMUTE_STRING = "You have been unmuted.";
|
||||
@Override
|
||||
public void packetReceived (Packet packet) {
|
||||
if (packet instanceof final ClientboundSystemChatPacket p) {
|
||||
Component content = p.getContent();
|
||||
if (content instanceof final TextComponent textComponent) {
|
||||
if (
|
||||
textComponent.content().startsWith(MUTE_STRING)
|
||||
&&
|
||||
textComponent.color().equals(NamedTextColor.GOLD)
|
||||
) muted = true;
|
||||
|
||||
else if (
|
||||
textComponent.content().equals(UNMUTE_STRING)
|
||||
&&
|
||||
textComponent.color().equals(NamedTextColor.GOLD)
|
||||
) muted = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public MuteSelfcare (NitoriBot bot) {
|
||||
bot.listenerManager.addListener(this);
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.selfcare.extras;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.NitoriBot;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.listeners.Listener;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.util.ComponentUtil;
|
||||
import org.geysermc.mcprotocollib.network.packet.Packet;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundSystemChatPacket;
|
||||
|
||||
public class CommandSpySelfcare implements Listener {
|
||||
public boolean enabled = false;
|
||||
private static final String COMMAND_SPY_ENABLED = "Successfully enabled CommandSpy";
|
||||
private static final String COMMAND_SPY_DISABLED = "Successfully disabled CommandSpy";
|
||||
|
||||
@Override
|
||||
public void packetReceived (Packet packet) {
|
||||
if (packet instanceof final ClientboundSystemChatPacket p) {
|
||||
String content = ComponentUtil.componentToString(p.getContent());
|
||||
if (content.equals(COMMAND_SPY_ENABLED)) enabled = true;
|
||||
else if (content.equals(COMMAND_SPY_DISABLED)) enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
public CommandSpySelfcare (NitoriBot bot) {
|
||||
bot.listenerManager.addListener(this);
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.selfcare.extras;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.NitoriBot;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.listeners.Listener;
|
||||
|
||||
public class UsernameSelfcare implements Listener {
|
||||
private NitoriBot bot;
|
||||
public boolean usernameChanged = false;
|
||||
|
||||
@Override
|
||||
public void botUsernameUpdated (String username) {
|
||||
usernameChanged = !username.equals(bot.profile.getName());
|
||||
}
|
||||
|
||||
public UsernameSelfcare (NitoriBot bot) {
|
||||
this.bot = bot;
|
||||
|
||||
bot.listenerManager.addListener(this);
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@
|
||||
"color": "green"
|
||||
}
|
||||
],
|
||||
"version": "v9.0.0-alpha",
|
||||
"version": "v9.0.0",
|
||||
"codename": [
|
||||
{
|
||||
"text": "Night",
|
||||
@@ -26,7 +26,7 @@
|
||||
"color": "blue"
|
||||
}
|
||||
],
|
||||
"build": "5318",
|
||||
"build": "5319",
|
||||
"versionReleaseDate": "N\\A",
|
||||
"initialBotRelease": "November 22, 2022"
|
||||
},
|
||||
@@ -38,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 / v9.0.0 tab complete / v9.0.0 vanished player support / v9.0.0 chunk parser"
|
||||
"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 / v9.0.0 chunk parser/ v9.0.0 chipmunkmod chat parser"
|
||||
},
|
||||
{
|
||||
"name": "_yfd",
|
||||
|
||||
Reference in New Issue
Block a user