This commit is contained in:
Anuken
2020-05-21 19:20:37 -04:00
parent 55effc54bb
commit 4787a68a08
5 changed files with 10 additions and 9 deletions

View File

@@ -339,7 +339,6 @@ public class ArcNetProvider implements NetProvider{
@SuppressWarnings("unchecked")
public static class PacketSerializer implements NetSerializer{
static Cons2<Packet, ByteBuffer> writer = Packet::write;
@Override
public Object read(ByteBuffer byteBuffer){
@@ -359,13 +358,11 @@ public class ArcNetProvider implements NetProvider{
byteBuffer.put((byte)-2); //code for framework message
writeFramework(byteBuffer, (FrameworkMessage)o);
}else{
if(!(o instanceof Packet))
throw new RuntimeException("All sent objects must implement be Packets! Class: " + o.getClass());
if(!(o instanceof Packet)) throw new RuntimeException("All sent objects must implement be Packets! Class: " + o.getClass());
byte id = Registrator.getID(o.getClass());
if(id == -1)
throw new RuntimeException("Unregistered class: " + o.getClass());
if(id == -1) throw new RuntimeException("Unregistered class: " + o.getClass());
byteBuffer.put(id);
writer.get((Packet)o, byteBuffer);
((Packet)o).write(byteBuffer);
}
}