-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
clean up everything, add challenge token check
- Loading branch information
1 parent
4899220
commit 8260fb3
Showing
12 changed files
with
395 additions
and
147 deletions.
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
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
227 changes: 83 additions & 144 deletions
227
src/server/java/io/thiemann/kurt/query/query/QueryServer.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
48 changes: 48 additions & 0 deletions
48
src/server/java/io/thiemann/kurt/query/query/packet/ClientBoundBasicStatPacket.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,48 @@ | ||
package io.thiemann.kurt.query.query.packet; | ||
|
||
import java.nio.Buffer; | ||
import java.nio.ByteBuffer; | ||
import java.nio.ByteOrder; | ||
import java.nio.charset.StandardCharsets; | ||
|
||
public class ClientBoundBasicStatPacket extends ClientBoundPacket { | ||
|
||
private final String motd; | ||
private final String gameType; | ||
private final String map; | ||
private final int playersOnline; | ||
private final int maxPlayers; | ||
private final int port; | ||
private final String host; | ||
|
||
public ClientBoundBasicStatPacket(int sessionId, String motd, String gameType, String map, int playersOnline, int maxPlayers, int port, String host) { | ||
super(PacketType.STAT, sessionId); | ||
this.motd = motd; | ||
this.gameType = gameType; | ||
this.map = map; | ||
this.playersOnline = playersOnline; | ||
this.maxPlayers = maxPlayers; | ||
this.port = port; | ||
this.host = host; | ||
} | ||
|
||
@Override | ||
protected byte[] serializePayload() { | ||
ByteBuffer buffer = ByteBuffer.allocate(1024); | ||
buffer.order(ByteOrder.LITTLE_ENDIAN); | ||
|
||
buffer.put((this.motd + "\0").getBytes(StandardCharsets.UTF_8)); | ||
buffer.put((this.gameType + "\0").getBytes(StandardCharsets.UTF_8)); | ||
buffer.put((this.map + "\0").getBytes(StandardCharsets.UTF_8)); | ||
buffer.put((this.playersOnline + "\0").getBytes(StandardCharsets.UTF_8)); | ||
buffer.put((this.maxPlayers + "\0").getBytes(StandardCharsets.UTF_8)); | ||
buffer.putShort((short) this.port); | ||
buffer.put((this.host + "\0").getBytes(StandardCharsets.UTF_8)); | ||
|
||
//only return written length as byte array | ||
byte[] response = new byte[buffer.position()]; | ||
((Buffer) buffer).rewind(); | ||
buffer.get(response); | ||
return response; | ||
} | ||
} |
Oops, something went wrong.