Class Utilities

java.lang.Object
dev.forbit.server.utilities.Utilities

public class Utilities extends Object
  • Field Details

  • Constructor Details

    • Utilities

      public Utilities()
  • Method Details

    • getNextString

      public static Optional<String> getNextString(ByteBuffer buffer)
      Reads from a buffer to find the next string written

      Strings 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

      public static Logger getLogger()
      Singleton logger
      Returns:
      logger instance
    • addLogOutputFile

      public static void addLogOutputFile(Level level, String dest)
    • getBuffer

      public static String getBuffer(ByteBuffer buffer)
      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

      public static String getHexBuffer(ByteBuffer buffer)
    • newBuffer

      public static ByteBuffer newBuffer()
      Returns a LITTLE_ENDIAN ordered buffer with the default size
      Returns:
      new byte buffer
    • getPacket

      public static Optional<Packet> getPacket(String header)
      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

      public static Optional<GSONPacket> getGSONPacket(String header)
    • loadPacket

      public static void loadPacket(ConnectionServer server, GMLInputBuffer buffer, String header, Client client)