Package dev.forbit.server.utilities
Class Utilities
java.lang.Object
dev.forbit.server.utilities.Utilities
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
addLogOutputFile(Level level, String dest)
static String
getBuffer(ByteBuffer buffer)
Returns the raw bytes of a bufferstatic Optional<GSONPacket>
getGSONPacket(String header)
static String
getHexBuffer(ByteBuffer buffer)
static Logger
Singleton loggergetNextString(ByteBuffer buffer)
Reads from a buffer to find the next string writtenReflectively loads a new packet instance from the given header.static void
loadPacket(ConnectionServer server, GMLInputBuffer buffer, String header, Client client)
static ByteBuffer
Returns a LITTLE_ENDIAN ordered buffer with the default size
-
Field Details
-
DEFAULT_PACKET_SIZE
public static final int DEFAULT_PACKET_SIZE- See Also:
- Constant Field Values
-
REGISTER_PACKET_IDENTIFIER
- See Also:
- Constant Field Values
-
-
Constructor Details
-
Utilities
public Utilities()
-
-
Method Details
-
getNextString
Reads from a buffer to find the next string writtenStrings in gamemaker buffers are ended with 0x00, if the functon can't find a 0x00 is will throw an IOException error
- Parameters:
buffer
- buffer to read from.- Returns:
- the concatenated string
-
getLogger
Singleton logger- Returns:
- logger instance
-
addLogOutputFile
-
getBuffer
Returns the raw bytes of a buffer- Parameters:
buffer
- the buffer to read from- Returns:
- a string of all the bytes in the buffer, trimmed.
-
getHexBuffer
-
newBuffer
Returns a LITTLE_ENDIAN ordered buffer with the default size- Returns:
- new byte buffer
-
getPacket
Reflectively loads a new packet instance from the given header.- Parameters:
header
- the class name to load from.- Returns:
- optional of packet, empty if error occurs.
-
getGSONPacket
-
loadPacket
public static void loadPacket(ConnectionServer server, GMLInputBuffer buffer, String header, Client client)
-