add/improve/fix stuff
ig mabe mabe mabe useCore!1!1!
This commit is contained in:
parent
d733da420f
commit
2b9d29e52e
10 changed files with 113 additions and 68 deletions
|
@ -4,31 +4,8 @@
|
|||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="50f184fa-7bed-4956-baf5-7586ff26ea08" name="Changes" comment="improve and fix cmd handler (first commit on arch) yup this is my first commit on arch linux,.,.,..,.,., yes i use arch btw :sunglasses:">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.gitignore" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/.name" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/compiler.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/compiler.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/inspectionProfiles/Project_Default.xml" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/jarRepositories.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/jarRepositories.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/uiDesigner.xml" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/vcs.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/dependency-reduced-pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/dependency-reduced-pom.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/chatParsers/ChomeNSCustomChatParser.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/chatParsers/ChomeNSCustomChatParser.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/chatParsers/KaboomChatParser.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/chatParsers/KaboomChatParser.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/chatParsers/MinecraftChatParser.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/chatParsers/MinecraftChatParser.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/chatParsers/commandSpy/CommandSpyParser.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/chatParsers/commandSpy/CommandSpyParser.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/chatParsers/data/MutablePlayerListEntry.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/chatParsers/data/MutablePlayerListEntry.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/chatParsers/data/PlayerMessage.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/chatParsers/data/PlayerMessage.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/command/DiscordCommandContext.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/command/DiscordCommandContext.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ChatCommandHandlerPlugin.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ChatCommandHandlerPlugin.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ChatPlugin.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ChatPlugin.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ClearChatUsernamePlugin.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/ClearChatUsernamePlugin.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/CorePlugin.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/CorePlugin.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/DiscordPlugin.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/DiscordPlugin.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/LoggerPlugin.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/LoggerPlugin.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/PlayersPlugin.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/PlayersPlugin.java" afterDir="false" />
|
||||
<list default="true" id="50f184fa-7bed-4956-baf5-7586ff26ea08" name="Changes" comment="1.19.4 + add stuff (kinda broken ..,,.)">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
@ -117,13 +94,6 @@
|
|||
<option name="presentableId" value="Default" />
|
||||
<updated>1680245437032</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00037" summary="remove the thing">
|
||||
<created>1681001658785</created>
|
||||
<option name="number" value="00037" />
|
||||
<option name="presentableId" value="LOCAL-00037" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1681001658785</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00038" summary="add sus autocomplete (works, tested)">
|
||||
<created>1681003794277</created>
|
||||
<option name="number" value="00038" />
|
||||
|
@ -460,7 +430,14 @@
|
|||
<option name="project" value="LOCAL" />
|
||||
<updated>1681972329498</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="86" />
|
||||
<task id="LOCAL-00086" summary="1.19.4 + add stuff (kinda broken ..,,.)">
|
||||
<created>1681984879688</created>
|
||||
<option name="number" value="00086" />
|
||||
<option name="presentableId" value="LOCAL-00086" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1681984879688</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="87" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
|
@ -475,7 +452,6 @@
|
|||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="make self care use core if it can" />
|
||||
<MESSAGE value="remove the time from cb" />
|
||||
<MESSAGE value="ig change to `ChomeNS Bot` in .name yup" />
|
||||
<MESSAGE value="hopefully fix the core problem?" />
|
||||
|
@ -500,7 +476,8 @@
|
|||
<MESSAGE value="fard" />
|
||||
<MESSAGE value="add a working (or not?) stereo to music" />
|
||||
<MESSAGE value="improve and fix cmd handler (first commit on arch) yup this is my first commit on arch linux,.,.,..,.,., yes i use arch btw :sunglasses:" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="improve and fix cmd handler (first commit on arch) yup this is my first commit on arch linux,.,.,..,.,., yes i use arch btw :sunglasses:" />
|
||||
<MESSAGE value="1.19.4 + add stuff (kinda broken ..,,.)" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="1.19.4 + add stuff (kinda broken ..,,.)" />
|
||||
</component>
|
||||
<component name="XSLT-Support.FileAssociations.UIState">
|
||||
<expand />
|
||||
|
|
|
@ -25,6 +25,7 @@ public class Bot {
|
|||
private final String _username;
|
||||
@Getter private final boolean kaboom;
|
||||
@Getter private final String serverName;
|
||||
@Getter @Setter private boolean useCore;
|
||||
@Getter @Setter private boolean useChat;
|
||||
@Getter private final boolean hasEssentials;
|
||||
@Getter private final List<Bot> allBots;
|
||||
|
@ -63,12 +64,13 @@ public class Bot {
|
|||
@Getter private MazePlugin maze;
|
||||
@Getter private ExploitsPlugin exploits;
|
||||
|
||||
public Bot (String host, int port, String _username, boolean kaboom, String serverName, boolean useChat, boolean hasEssentials, List<Bot> allBots, Configuration config) {
|
||||
public Bot (String host, int port, String _username, boolean kaboom, String serverName, boolean useCore, boolean useChat, boolean hasEssentials, List<Bot> allBots, Configuration config) {
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
this._username = _username;
|
||||
this.kaboom = kaboom;
|
||||
this.serverName = serverName;
|
||||
this.useCore = useCore;
|
||||
this.useChat = useChat;
|
||||
this.hasEssentials = hasEssentials;
|
||||
this.allBots = allBots;
|
||||
|
|
|
@ -79,7 +79,8 @@ public class Configuration {
|
|||
@Getter public String username;
|
||||
@Getter public boolean kaboom = false;
|
||||
@Getter public String serverName;
|
||||
@Getter public boolean useCore = true;
|
||||
@Getter public boolean useChat = false;
|
||||
@Getter public boolean hasEssentials = false;
|
||||
@Getter public boolean hasEssentials = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,10 +70,11 @@ public class Main {
|
|||
final String username = botOption.username();
|
||||
final boolean kaboom = botOption.kaboom();
|
||||
final String serverName = botOption.serverName();
|
||||
final boolean useCore = botOption.useCore();
|
||||
final boolean useChat = botOption.useChat();
|
||||
final boolean hasEssentials = botOption.hasEssentials();
|
||||
|
||||
final Bot bot = new Bot(host, port, username, kaboom, serverName, useChat, hasEssentials, allBots, config);
|
||||
final Bot bot = new Bot(host, port, username, kaboom, serverName, useCore, useChat, hasEssentials, allBots, config);
|
||||
allBots.add(bot);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
package land.chipmunk.chayapak.chomens_bot.commands;
|
||||
|
||||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||
import land.chipmunk.chayapak.chomens_bot.command.Command;
|
||||
import land.chipmunk.chayapak.chomens_bot.command.CommandContext;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ClearChatQueueCommand implements Command {
|
||||
public String name() { return "clearchatqueue"; }
|
||||
|
||||
public String description() {
|
||||
return "Clears the bot's chat queue";
|
||||
}
|
||||
|
||||
public List<String> usage() {
|
||||
final List<String> usages = new ArrayList<>();
|
||||
usages.add("");
|
||||
|
||||
return usages;
|
||||
}
|
||||
|
||||
public List<String> alias() {
|
||||
final List<String> aliases = new ArrayList<>();
|
||||
aliases.add("ccq");
|
||||
|
||||
return aliases;
|
||||
}
|
||||
|
||||
public int trustLevel() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public Component execute(CommandContext context, String[] args, String[] fullArgs) {
|
||||
final Bot bot = context.bot();
|
||||
|
||||
bot.chat().queue().clear();
|
||||
|
||||
return Component.text("success");
|
||||
}
|
||||
}
|
|
@ -52,6 +52,7 @@ public class BossbarManagerPlugin extends SessionAdapter {
|
|||
}
|
||||
|
||||
private void update() {
|
||||
if (!enabled) return;
|
||||
for (Map.Entry<String, BossBar> _bossBar : bossBars.entrySet()) {
|
||||
final String name = _bossBar.getKey();
|
||||
final BossBar bossBar = _bossBar.getValue();
|
||||
|
@ -84,6 +85,7 @@ public class BossbarManagerPlugin extends SessionAdapter {
|
|||
}
|
||||
|
||||
private void createBossBar (String name, String players) {
|
||||
if (!enabled) return;
|
||||
bot.core().run("minecraft:bossbar add " + bossBarPrefix + name + " \"\"");
|
||||
bot.core().run("minecraft:bossbar set " + bossBarPrefix + name + " players " + players);
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import land.chipmunk.chayapak.chomens_bot.chatParsers.data.MutablePlayerListEntr
|
|||
import land.chipmunk.chayapak.chomens_bot.chatParsers.data.PlayerMessage;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.ComponentUtilities;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.UUIDUtilities;
|
||||
import lombok.Getter;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TranslatableComponent;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
|
@ -32,6 +33,8 @@ public class ChatPlugin extends SessionAdapter {
|
|||
|
||||
private final CommandSpyParser commandSpyParser;
|
||||
|
||||
@Getter private final List<String> queue = new ArrayList<>();
|
||||
|
||||
private final List<ChatListener> listeners = new ArrayList<>();
|
||||
|
||||
public ChatPlugin (Bot bot) {
|
||||
|
@ -45,6 +48,8 @@ public class ChatPlugin extends SessionAdapter {
|
|||
chatParsers.add(new MinecraftChatParser(bot));
|
||||
chatParsers.add(new KaboomChatParser(bot));
|
||||
chatParsers.add(new ChomeNSCustomChatParser(bot));
|
||||
|
||||
bot.executor().scheduleAtFixedRate(this::sendChatTick, 0, 125, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -131,26 +136,28 @@ public class ChatPlugin extends SessionAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
public void send (String message) {
|
||||
final String[] splitted = message.split("(?<=\\G.{100})|\\n");
|
||||
private void sendChatTick () {
|
||||
if (queue.size() == 0) return;
|
||||
|
||||
final String message = queue.get(0);
|
||||
|
||||
final String[] splitted = message.split("(?<=\\G.{255})|\\n");
|
||||
|
||||
int i = 200;
|
||||
for (String splitMessage : splitted) {
|
||||
if (splitMessage.trim().equals("")) continue;
|
||||
|
||||
bot.executor().schedule(() -> {
|
||||
if (splitMessage.startsWith("/")) {
|
||||
bot.session().send(new ServerboundChatCommandPacket(
|
||||
splitMessage.substring(1),
|
||||
Instant.now().toEpochMilli(),
|
||||
0L,
|
||||
Collections.emptyList(),
|
||||
0,
|
||||
new BitSet()
|
||||
));
|
||||
} else {
|
||||
// Temporary fix for the bot getting kicked instead of chatting
|
||||
bot.core().run("essentials:sudo " + bot.players().getBotEntry().profile().getIdAsString() + " c:" + splitMessage);
|
||||
if (splitMessage.startsWith("/")) {
|
||||
bot.session().send(new ServerboundChatCommandPacket(
|
||||
splitMessage.substring(1),
|
||||
Instant.now().toEpochMilli(),
|
||||
0L,
|
||||
Collections.emptyList(),
|
||||
0,
|
||||
new BitSet()
|
||||
));
|
||||
} else {
|
||||
// Temporary fix for the bot getting kicked instead of chatting
|
||||
bot.core().run("essentials:sudo " + bot.players().getBotEntry().profile().getIdAsString() + " c:" + splitMessage);
|
||||
// bot.session().send(new ServerboundChatPacket(
|
||||
// splitMessage,
|
||||
// Instant.now().toEpochMilli(),
|
||||
|
@ -159,11 +166,14 @@ public class ChatPlugin extends SessionAdapter {
|
|||
// 0,
|
||||
// new BitSet()
|
||||
// ));
|
||||
}
|
||||
}, i, TimeUnit.MILLISECONDS);
|
||||
|
||||
i = i + 200;
|
||||
}
|
||||
}
|
||||
|
||||
queue.remove(0);
|
||||
}
|
||||
|
||||
public void send (String message) {
|
||||
queue.add(message);
|
||||
}
|
||||
|
||||
public void tellraw (Component component, String targets) {
|
||||
|
|
|
@ -58,6 +58,7 @@ public class CommandHandlerPlugin {
|
|||
registerCommand(new GenerateMazeCommand());
|
||||
registerCommand(new TranslateCommand());
|
||||
registerCommand(new KickCommand());
|
||||
registerCommand(new ClearChatQueueCommand());
|
||||
}
|
||||
|
||||
public void registerCommand (Command command) {
|
||||
|
|
|
@ -78,16 +78,20 @@ public class CorePlugin extends PositionPlugin.PositionListener {
|
|||
public void run (String command) {
|
||||
if (!ready) return;
|
||||
|
||||
bot.session().send(new ServerboundSetCommandBlockPacket(
|
||||
absoluteCorePosition(),
|
||||
command,
|
||||
kaboom ? CommandBlockMode.AUTO : CommandBlockMode.REDSTONE,
|
||||
true,
|
||||
false,
|
||||
true
|
||||
));
|
||||
if (bot.useCore()) {
|
||||
bot.session().send(new ServerboundSetCommandBlockPacket(
|
||||
absoluteCorePosition(),
|
||||
command,
|
||||
kaboom ? CommandBlockMode.AUTO : CommandBlockMode.REDSTONE,
|
||||
true,
|
||||
false,
|
||||
true
|
||||
));
|
||||
|
||||
incrementBlock();
|
||||
incrementBlock();
|
||||
} else if (command.length() < 256) {
|
||||
bot.chat().send("/" + command);
|
||||
}
|
||||
}
|
||||
|
||||
public CompletableFuture<CompoundTag> runTracked (String command) {
|
||||
|
|
|
@ -61,16 +61,20 @@ selfCare:
|
|||
prefix: true
|
||||
username: true # do NOT set this to false unless you know what you are doing
|
||||
bots:
|
||||
# username and kaboom are optional.
|
||||
# username, kaboom, useCore, useChat and hasEssentials are optional.
|
||||
|
||||
# for username if it doesn't exist it will default to random username
|
||||
# for kaboom it will just default to `false`
|
||||
# for serverName name it whatever you like, it will be used as server name in trusted broadcast
|
||||
# for useCore it just sends the command using chat instead of using core. recommended to enable useChat too when this is enabled
|
||||
# for useChat when the bot sends output (tellraw) it will chat instead of using the core to run tellraw
|
||||
# for hasEssentials it is self-explanatory. if the server has essentials plugin just set it to true
|
||||
|
||||
- host: 'localhost'
|
||||
port: 25565
|
||||
username: 'ChomeNS_Bot'
|
||||
kaboom: false
|
||||
serverName: 'Localhost'
|
||||
useCore: true
|
||||
useChat: false
|
||||
hasEssentials: false
|
||||
|
|
Loading…
Reference in a new issue