add packet queue for funni
This commit is contained in:
parent
5b8fa78acf
commit
e5bd9d98f8
7 changed files with 34 additions and 19 deletions
|
@ -4,9 +4,8 @@
|
||||||
<option name="autoReloadType" value="SELECTIVE" />
|
<option name="autoReloadType" value="SELECTIVE" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="50f184fa-7bed-4956-baf5-7586ff26ea08" name="Changes" comment="remove debug line ig">
|
<list default="true" id="50f184fa-7bed-4956-baf5-7586ff26ea08" name="Changes" comment="fix error i guess">
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/MusicCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/MusicCommand.java" afterDir="false" />
|
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
|
@ -99,13 +98,6 @@
|
||||||
<option name="presentableId" value="Default" />
|
<option name="presentableId" value="Default" />
|
||||||
<updated>1680245437032</updated>
|
<updated>1680245437032</updated>
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00093" summary="fard 2">
|
|
||||||
<created>1682131432220</created>
|
|
||||||
<option name="number" value="00093" />
|
|
||||||
<option name="presentableId" value="LOCAL-00093" />
|
|
||||||
<option name="project" value="LOCAL" />
|
|
||||||
<updated>1682131432220</updated>
|
|
||||||
</task>
|
|
||||||
<task id="LOCAL-00094" summary="readme i guess">
|
<task id="LOCAL-00094" summary="readme i guess">
|
||||||
<created>1682133205362</created>
|
<created>1682133205362</created>
|
||||||
<option name="number" value="00094" />
|
<option name="number" value="00094" />
|
||||||
|
@ -442,7 +434,14 @@
|
||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1682823229424</updated>
|
<updated>1682823229424</updated>
|
||||||
</task>
|
</task>
|
||||||
<option name="localTasksCounter" value="142" />
|
<task id="LOCAL-00142" summary="fix error i guess">
|
||||||
|
<created>1682828334937</created>
|
||||||
|
<option name="number" value="00142" />
|
||||||
|
<option name="presentableId" value="LOCAL-00142" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1682828334938</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="143" />
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="Vcs.Log.Tabs.Properties">
|
<component name="Vcs.Log.Tabs.Properties">
|
||||||
|
@ -457,7 +456,6 @@
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="VcsManagerConfiguration">
|
<component name="VcsManagerConfiguration">
|
||||||
<MESSAGE value="fix chomens bot crsah exploit 2023 working" />
|
|
||||||
<MESSAGE value="i forgor 1 thing lmfao" />
|
<MESSAGE value="i forgor 1 thing lmfao" />
|
||||||
<MESSAGE value="gex" />
|
<MESSAGE value="gex" />
|
||||||
<MESSAGE value="make trusted broadcast log in console" />
|
<MESSAGE value="make trusted broadcast log in console" />
|
||||||
|
@ -482,7 +480,8 @@
|
||||||
<MESSAGE value="update language file to 1.19.4" />
|
<MESSAGE value="update language file to 1.19.4" />
|
||||||
<MESSAGE value="fix core?" />
|
<MESSAGE value="fix core?" />
|
||||||
<MESSAGE value="remove debug line ig" />
|
<MESSAGE value="remove debug line ig" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value="remove debug line ig" />
|
<MESSAGE value="fix error i guess" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value="fix error i guess" />
|
||||||
</component>
|
</component>
|
||||||
<component name="XDebuggerManager">
|
<component name="XDebuggerManager">
|
||||||
<breakpoint-manager>
|
<breakpoint-manager>
|
||||||
|
|
|
@ -38,6 +38,8 @@ public class Bot {
|
||||||
|
|
||||||
@Getter private final ScheduledExecutorService executor = Executors.newScheduledThreadPool(100);
|
@Getter private final ScheduledExecutorService executor = Executors.newScheduledThreadPool(100);
|
||||||
|
|
||||||
|
private final List<Packet> packetQueue = new ArrayList<>();
|
||||||
|
|
||||||
@Getter @Setter private ConsolePlugin console;
|
@Getter @Setter private ConsolePlugin console;
|
||||||
@Getter @Setter private LoggerPlugin logger; // in ConsolePlugin
|
@Getter @Setter private LoggerPlugin logger; // in ConsolePlugin
|
||||||
@Getter @Setter private DiscordPlugin discord; // same for this one too
|
@Getter @Setter private DiscordPlugin discord; // same for this one too
|
||||||
|
@ -82,6 +84,8 @@ public class Bot {
|
||||||
Bot.this.ready();
|
Bot.this.ready();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
executor.scheduleAtFixedRate(this::tick, 0, 10, TimeUnit.MILLISECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ready () {
|
public void ready () {
|
||||||
|
@ -111,6 +115,18 @@ public class Bot {
|
||||||
reconnect();
|
reconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void sendPacket (Packet packet) {
|
||||||
|
packetQueue.add(packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void tick () {
|
||||||
|
if (!loggedIn || packetQueue.size() == 0) return;
|
||||||
|
|
||||||
|
session.send(packetQueue.get(0));
|
||||||
|
|
||||||
|
packetQueue.remove(0);
|
||||||
|
}
|
||||||
|
|
||||||
private void reconnect () {
|
private void reconnect () {
|
||||||
for (Listener listener : listeners) {
|
for (Listener listener : listeners) {
|
||||||
listener.connecting();
|
listener.connecting();
|
||||||
|
|
|
@ -183,7 +183,7 @@ public class ChatPlugin extends Bot.Listener {
|
||||||
if (splitMessage.trim().equals("")) continue;
|
if (splitMessage.trim().equals("")) continue;
|
||||||
|
|
||||||
if (splitMessage.startsWith("/")) {
|
if (splitMessage.startsWith("/")) {
|
||||||
bot.session().send(new ServerboundChatCommandPacket(
|
bot.sendPacket(new ServerboundChatCommandPacket(
|
||||||
splitMessage.substring(1),
|
splitMessage.substring(1),
|
||||||
Instant.now().toEpochMilli(),
|
Instant.now().toEpochMilli(),
|
||||||
0L,
|
0L,
|
||||||
|
@ -192,7 +192,7 @@ public class ChatPlugin extends Bot.Listener {
|
||||||
new BitSet()
|
new BitSet()
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
bot.session().send(new ServerboundChatPacket(
|
bot.sendPacket(new ServerboundChatPacket(
|
||||||
splitMessage,
|
splitMessage,
|
||||||
Instant.now().toEpochMilli(),
|
Instant.now().toEpochMilli(),
|
||||||
0L,
|
0L,
|
||||||
|
|
|
@ -83,7 +83,7 @@ public class CorePlugin extends PositionPlugin.PositionListener {
|
||||||
if (!ready) return;
|
if (!ready) return;
|
||||||
|
|
||||||
if (bot.options().useCore()) {
|
if (bot.options().useCore()) {
|
||||||
bot.session().send(new ServerboundSetCommandBlockPacket(
|
bot.sendPacket(new ServerboundSetCommandBlockPacket(
|
||||||
absoluteCorePosition(),
|
absoluteCorePosition(),
|
||||||
command,
|
command,
|
||||||
kaboom ? CommandBlockMode.AUTO : CommandBlockMode.REDSTONE,
|
kaboom ? CommandBlockMode.AUTO : CommandBlockMode.REDSTONE,
|
||||||
|
@ -109,7 +109,7 @@ public class CorePlugin extends PositionPlugin.PositionListener {
|
||||||
final CompletableFuture<CompoundTag> future = new CompletableFuture<>();
|
final CompletableFuture<CompoundTag> future = new CompletableFuture<>();
|
||||||
transactions.put(transactionId, future);
|
transactions.put(transactionId, future);
|
||||||
|
|
||||||
final Runnable afterTick = () -> bot.session().send(new ServerboundBlockEntityTagQuery(transactionId, position));
|
final Runnable afterTick = () -> bot.sendPacket(new ServerboundBlockEntityTagQuery(transactionId, position));
|
||||||
|
|
||||||
bot.executor().schedule(afterTick, 50, TimeUnit.MILLISECONDS);
|
bot.executor().schedule(afterTick, 50, TimeUnit.MILLISECONDS);
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class PositionPlugin extends Bot.Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void packetReceived (ClientboundPlayerPositionPacket packet) {
|
public void packetReceived (ClientboundPlayerPositionPacket packet) {
|
||||||
bot.session().send(new ServerboundAcceptTeleportationPacket(packet.getTeleportId()));
|
bot.sendPacket(new ServerboundAcceptTeleportationPacket(packet.getTeleportId()));
|
||||||
|
|
||||||
position = Vector3i.from(packet.getX(), packet.getY(), packet.getZ());
|
position = Vector3i.from(packet.getX(), packet.getY(), packet.getZ());
|
||||||
for (PositionListener listener : listeners) { listener.positionChange(position); }
|
for (PositionListener listener : listeners) { listener.positionChange(position); }
|
||||||
|
|
|
@ -157,7 +157,7 @@ public class SelfCarePlugin extends Bot.Listener {
|
||||||
final GameEventValue value = packet.getValue();
|
final GameEventValue value = packet.getValue();
|
||||||
|
|
||||||
if (notification == GameEvent.ENTER_CREDITS) {
|
if (notification == GameEvent.ENTER_CREDITS) {
|
||||||
bot.session().send(new ServerboundClientCommandPacket(ClientCommand.RESPAWN));
|
bot.sendPacket(new ServerboundClientCommandPacket(ClientCommand.RESPAWN));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class TabCompletePlugin extends Bot.Listener {
|
||||||
public CompletableFuture<ClientboundCommandSuggestionsPacket> tabComplete (String command) {
|
public CompletableFuture<ClientboundCommandSuggestionsPacket> tabComplete (String command) {
|
||||||
final int transactionId = nextTransactionId++;
|
final int transactionId = nextTransactionId++;
|
||||||
|
|
||||||
bot.session().send(new ServerboundCommandSuggestionPacket(transactionId, command));
|
bot.sendPacket(new ServerboundCommandSuggestionPacket(transactionId, command));
|
||||||
|
|
||||||
final CompletableFuture<ClientboundCommandSuggestionsPacket> future = new CompletableFuture<>();
|
final CompletableFuture<ClientboundCommandSuggestionsPacket> future = new CompletableFuture<>();
|
||||||
transactions.put(transactionId, future);
|
transactions.put(transactionId, future);
|
||||||
|
|
Loading…
Reference in a new issue