-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/main/java/cqb13/NumbyHack/modules/general/PacketDelay.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package cqb13.NumbyHack.modules.general; | ||
|
||
import cqb13.NumbyHack.NumbyHack; | ||
import meteordevelopment.meteorclient.events.packets.PacketEvent; | ||
import meteordevelopment.meteorclient.settings.PacketListSetting; | ||
import meteordevelopment.meteorclient.settings.Setting; | ||
import meteordevelopment.meteorclient.settings.SettingGroup; | ||
import meteordevelopment.meteorclient.systems.modules.Module; | ||
import meteordevelopment.meteorclient.utils.network.PacketUtils; | ||
import meteordevelopment.orbit.EventHandler; | ||
import meteordevelopment.orbit.EventPriority; | ||
import net.minecraft.network.packet.Packet; | ||
|
||
import java.util.Set; | ||
import java.util.ArrayList; | ||
|
||
public class PacketDelay extends Module { | ||
private final SettingGroup sgGeneral = settings.getDefaultGroup(); | ||
|
||
private final Setting<Set<Class<? extends Packet<?>>>> c2sPackets = sgGeneral.add(new PacketListSetting.Builder() | ||
.name("C2S-packets") | ||
.description("Client-to-server packets to delay.") | ||
.filter(aClass -> PacketUtils.getC2SPackets().contains(aClass)) | ||
.build() | ||
); | ||
|
||
private static ArrayList<Packet<?>> delayedPackets = new ArrayList<>(); | ||
|
||
public PacketDelay() { | ||
super(NumbyHack.CATEGORY, "packet-delay", "Allows you to delay the packets you send to a server."); | ||
runInMainMenu = true; | ||
} | ||
|
||
@EventHandler(priority = EventPriority.HIGHEST + 1) | ||
private void onSendPacket(PacketEvent.Send event) { | ||
if (c2sPackets.get().contains(event.packet.getClass())) { | ||
delayedPackets.add(event.packet); | ||
event.cancel(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onDeactivate() { | ||
for (Packet<?> packet : delayedPackets) { | ||
mc.getNetworkHandler().sendPacket(packet); | ||
} | ||
delayedPackets.clear(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters