Packet writeouts are now queued excluding dynamic packets

This commit is contained in:
ceikry
2021-07-07 17:32:48 -05:00
parent bcde41b7c9
commit 7f0b45241b
5 changed files with 56 additions and 11 deletions
@@ -5,12 +5,12 @@ package core.net.packet;
* @author Emperor
* @param <T> The context type.
*/
public interface OutgoingPacket<T extends Context> {
public interface OutgoingPacket<Context> {
/**
* Sends the packet.
* @param context The context.
*/
public void send(T context);
public void send(Context context);
}
@@ -4,6 +4,7 @@ import core.net.packet.in.*;
import core.net.packet.out.GrandExchangePacket;
import core.net.packet.out.*;
import rs09.game.system.SystemLogger;
import rs09.net.packet.PacketWriteQueue;
import rs09.net.packet.in.ItemOnGroundItemPacket;
import rs09.net.packet.in.QuickChatPacketHandler;
@@ -19,7 +20,7 @@ public final class PacketRepository {
/**
* The outgoing packets mapping.
*/
private final static Map<Class<?>, OutgoingPacket<? extends Context>> OUTGOING_PACKETS = new HashMap<>();
public final static Map<Class<?>, OutgoingPacket<? extends Context>> OUTGOING_PACKETS = new HashMap<>();
/**
* The incoming packets mapping.
@@ -189,8 +190,9 @@ public final class PacketRepository {
SystemLogger.logErr("Invalid outgoing packet [handler=" + clazz + ", context=" + context + "].");
return;
}
if(!context.getPlayer().isArtificial())
p.send(context);
if(!context.getPlayer().isArtificial()) {
PacketWriteQueue.handle(p, context);
}
}
/**