Server packet priority fix

This commit is contained in:
Anuken
2025-01-23 16:17:10 -05:00
parent 6c42b30309
commit 8f5eccaba6
4 changed files with 17 additions and 9 deletions

View File

@@ -322,7 +322,7 @@ public class NetClient implements ApplicationListener{
ui.join.connect(ip, port); ui.join.connect(ip, port);
} }
@Remote(targets = Loc.client) @Remote(targets = Loc.client, priority = PacketPriority.high)
public static void ping(Player player, long time){ public static void ping(Player player, long time){
Call.pingResponse(player.con, time); Call.pingResponse(player.con, time);
} }

View File

@@ -632,7 +632,7 @@ public class NetServer implements ApplicationListener{
return Float.isInfinite(f) || Float.isNaN(f); return Float.isInfinite(f) || Float.isNaN(f);
} }
@Remote(targets = Loc.client, unreliable = true) @Remote(targets = Loc.client, unreliable = true, priority = PacketPriority.high)
public static void clientSnapshot( public static void clientSnapshot(
Player player, Player player,
int snapshotID, int snapshotID,
@@ -830,7 +830,7 @@ public class NetServer implements ApplicationListener{
} }
} }
@Remote(targets = Loc.client) @Remote(targets = Loc.client, priority = PacketPriority.high)
public static void connectConfirm(Player player){ public static void connectConfirm(Player player){
if(player.con.kicked) return; if(player.con.kicked) return;

View File

@@ -306,14 +306,17 @@ public class Net{
* Call to handle a packet being received for the server. * Call to handle a packet being received for the server.
*/ */
public void handleServerReceived(NetConnection connection, Packet object){ public void handleServerReceived(NetConnection connection, Packet object){
object.handled();
try{ try{
//handle object normally if(connection.hasConnected || object.getPriority() == Packet.priorityHigh){
if(serverListeners.get(object.getClass()) != null){ object.handled();
serverListeners.get(object.getClass()).get(connection, object);
}else{ //handle object normally
object.handleServer(connection); if(serverListeners.get(object.getClass()) != null){
serverListeners.get(object.getClass()).get(connection, object);
}else{
object.handleServer(connection);
}
} }
}catch(ValidateException e){ }catch(ValidateException e){
//ignore invalid actions //ignore invalid actions

View File

@@ -157,5 +157,10 @@ public class Packets{
mods.add(TypeIO.readString(buffer)); mods.add(TypeIO.readString(buffer));
} }
} }
@Override
public int getPriority(){
return priorityHigh;
}
} }
} }