refactor: drop support for creayun since shit is getting messy with it

This commit is contained in:
ChomeNS
2025-04-07 08:05:07 +07:00
parent c0390b806f
commit 5e06c7cf8b
8 changed files with 8 additions and 73 deletions

View File

@@ -243,8 +243,6 @@ public class Bot extends SessionAdapter {
}
session.send(ServerboundPlayerLoadedPacket.INSTANCE);
if (options.creayun) chat.send("/server creative");
}
private void packetReceived (ClientboundCustomQueryPacket packet) {

View File

@@ -166,7 +166,6 @@ public class Configuration {
public String host;
public int port;
public String username;
public boolean creayun = false;
public String serverName;
public boolean hidden = false;
public boolean useCore = true;

View File

@@ -1,49 +0,0 @@
package me.chayapak1.chomens_bot.chatParsers;
import me.chayapak1.chomens_bot.Bot;
import me.chayapak1.chomens_bot.data.chat.ChatParser;
import me.chayapak1.chomens_bot.data.chat.PlayerMessage;
import me.chayapak1.chomens_bot.data.player.PlayerEntry;
import me.chayapak1.chomens_bot.util.ComponentUtilities;
import me.chayapak1.chomens_bot.util.UUIDUtilities;
import net.kyori.adventure.text.Component;
import org.geysermc.mcprotocollib.auth.GameProfile;
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.GameMode;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class CreayunChatParser implements ChatParser {
private final Bot bot;
// is parsing creayun chat using regex a good idea?
// mabe mabe mabe
// it doesn't use like translation or anything
private static final Pattern PATTERN = Pattern.compile("([^ ]*) » (.*)");
public CreayunChatParser (Bot bot) {
this.bot = bot;
}
@Override
public PlayerMessage parse (Component message) {
final String stringified = ComponentUtilities.stringify(message);
if (!bot.options.creayun) return null;
final Matcher matcher = PATTERN.matcher(stringified);
if (matcher.find()) {
final String displayName = matcher.group(1);
final String contents = matcher.group(2);
PlayerEntry sender = bot.players.getEntry(displayName);
if (sender == null)
sender = new PlayerEntry(new GameProfile(UUIDUtilities.getOfflineUUID(displayName), displayName), GameMode.SURVIVAL, 0, Component.text(displayName), 0L, null, new byte[0], true);
return new PlayerMessage(sender, Component.text(displayName), Component.text(contents));
}
return null;
}
}

View File

@@ -1,7 +1,6 @@
package me.chayapak1.chomens_bot.plugins;
import me.chayapak1.chomens_bot.Bot;
import me.chayapak1.chomens_bot.chatParsers.CreayunChatParser;
import me.chayapak1.chomens_bot.chatParsers.KaboomChatParser;
import me.chayapak1.chomens_bot.chatParsers.MinecraftChatParser;
import me.chayapak1.chomens_bot.chatParsers.U203aChatParser;
@@ -47,7 +46,7 @@ public class ChatPlugin extends Bot.Listener {
private final Bot bot;
public final Pattern CHAT_SPLIT_PATTERN;
public final Pattern CHAT_SPLIT_PATTERN = Pattern.compile("\\G\\s*([^\\r\\n]{1,254}(?=\\s|$)|[^\\r\\n]{254})");
private final List<ChatParser> chatParsers;
@@ -61,7 +60,6 @@ public class ChatPlugin extends Bot.Listener {
public ChatPlugin (Bot bot) {
this.bot = bot;
this.CHAT_SPLIT_PATTERN = Pattern.compile("\\G\\s*([^\\r\\n]{1," + (bot.options.creayun ? 126 : 254) + "}(?=\\s|$)|[^\\r\\n]{254})"); // thanks HBot for the regex <3
queueDelay = bot.options.chatQueueDelay;
@@ -71,7 +69,6 @@ public class ChatPlugin extends Bot.Listener {
chatParsers.add(new MinecraftChatParser(bot));
chatParsers.add(new KaboomChatParser(bot));
chatParsers.add(new U203aChatParser(bot));
chatParsers.add(new CreayunChatParser(bot));
bot.executor.scheduleAtFixedRate(this::sendChatTick, 0, queueDelay, TimeUnit.MILLISECONDS);
}

View File

@@ -143,7 +143,7 @@ public class PlayersPlugin extends Bot.Listener implements TickPlugin.Listener {
candidate != null &&
(
candidate.profile.getIdAsString().equals(username) || // checks for a string UUID
getName(candidate).equals(username) ||
candidate.profile.getName().equals(username) ||
candidate.usernames.contains(username)
)
) {
@@ -184,12 +184,6 @@ public class PlayersPlugin extends Bot.Listener implements TickPlugin.Listener {
target.listed = newEntry.isListed();
}
private String getName (PlayerEntry target) {
return bot.options.creayun ?
target.profile.getName().replaceAll("§.", "") :
target.profile.getName();
}
private void addPlayer (PlayerListEntry newEntry) {
final PlayerEntry duplicate = getEntry(newEntry);

View File

@@ -96,11 +96,9 @@ public class SelfCarePlugin extends Bot.Listener implements ChatPlugin.Listener
final boolean kaboom = bot.serverFeatures.hasExtras;
final boolean hasEssentials = bot.serverFeatures.hasEssentials;
final boolean creayun = bot.options.creayun;
// chat only
if (selfCares.op && permissionLevel < 2) bot.chat.send("/minecraft:op @s[type=player]");
else if (selfCares.gamemode && gamemode != GameMode.CREATIVE && !bot.options.creayun)
else if (selfCares.gamemode && gamemode != GameMode.CREATIVE)
bot.chat.send("/minecraft:gamemode creative @s[type=player]");
// core
@@ -111,7 +109,7 @@ public class SelfCarePlugin extends Bot.Listener implements ChatPlugin.Listener
}
// back to chat only
else if (selfCares.prefix.enabled && !prefix && kaboom && !bot.options.creayun)
else if (selfCares.prefix.enabled && !prefix && kaboom)
bot.chat.send("/extras:prefix " + bot.config.selfCare.prefix.prefix);
else if (selfCares.username && (System.currentTimeMillis() - usernameStartTime) >= 2 * 1000 && !username && kaboom)
bot.chat.send("/extras:username " + bot.username);
@@ -123,13 +121,13 @@ public class SelfCarePlugin extends Bot.Listener implements ChatPlugin.Listener
"";
final String uuid = bot.profile.getIdAsString();
if (selfCares.vanish && visible == vanish && !creayun) {
if (selfCares.vanish && visible == vanish) {
runEssentialsCommand("essentials:vanish " + usernameOrBlank + (visible ? "disable" : "enable"));
} else if (selfCares.nickname && !nickname) {
runEssentialsCommand("essentials:nickname " + uuid + " off");
} else if (selfCares.socialspy && !socialspy && !creayun) {
} else if (selfCares.socialspy && !socialspy) {
runEssentialsCommand("essentials:socialspy " + usernameOrBlank + "enable");
} else if (selfCares.mute && muted && !creayun) {
} else if (selfCares.mute && muted) {
runEssentialsCommand("essentials:mute " + uuid);
muted = false;
}