Class AbstractServer

java.lang.Object
org.geysermc.mcprotocollib.network.AbstractServer
All Implemented Interfaces:
Server
Direct Known Subclasses:
TcpServer

public abstract class AbstractServer extends Object implements Server
  • Constructor Details

  • Method Details

    • getHost

      public String getHost()
      Description copied from interface: Server
      Gets the host the session is listening on.
      Specified by:
      getHost in interface Server
      Returns:
      The listening host.
    • getPort

      public int getPort()
      Description copied from interface: Server
      Gets the port the session is listening on.
      Specified by:
      getPort in interface Server
      Returns:
      The listening port.
    • getPacketProtocol

      public Supplier<? extends PacketProtocol> getPacketProtocol()
      Description copied from interface: Server
      Gets the packet protocol of the server.
      Specified by:
      getPacketProtocol in interface Server
      Returns:
      The server's packet protocol.
    • createPacketProtocol

      protected PacketProtocol createPacketProtocol()
    • getGlobalFlags

      public Map<String,Object> getGlobalFlags()
      Description copied from interface: Server
      Gets this server's set flags.
      Specified by:
      getGlobalFlags in interface Server
      Returns:
      This server's flags.
    • hasGlobalFlag

      public boolean hasGlobalFlag(Flag<?> flag)
      Description copied from interface: Server
      Checks whether this server has a flag set.
      Specified by:
      hasGlobalFlag in interface Server
      Parameters:
      flag - Flag to check for.
      Returns:
      Whether this server has a flag set.
    • getGlobalFlag

      public <T> T getGlobalFlag(Flag<T> flag)
      Description copied from interface: Server
      Gets the value of the given flag as an instance of the given type.
      Specified by:
      getGlobalFlag in interface Server
      Type Parameters:
      T - Type of the flag.
      Parameters:
      flag - Flag to check for.
      Returns:
      Value of the flag.
    • getGlobalFlag

      public <T> T getGlobalFlag(Flag<T> flag, T def)
      Description copied from interface: Server
      Gets the value of the given flag as an instance of the given type. If the flag is not set, the specified default value will be returned.
      Specified by:
      getGlobalFlag in interface Server
      Type Parameters:
      T - Type of the flag.
      Parameters:
      flag - Flag to check for.
      def - Default value of the flag.
      Returns:
      Value of the flag.
    • setGlobalFlag

      public <T> void setGlobalFlag(Flag<T> flag, T value)
      Description copied from interface: Server
      Sets the value of a flag. The flag will be used in sessions if a session does not contain a value for the flag.
      Specified by:
      setGlobalFlag in interface Server
      Type Parameters:
      T - Type of the flag.
      Parameters:
      flag - Flag to check for.
      value - Value to set the flag to.
    • getListeners

      public List<ServerListener> getListeners()
      Description copied from interface: Server
      Gets the listeners listening on this session.
      Specified by:
      getListeners in interface Server
      Returns:
      This server's listeners.
    • addListener

      public void addListener(ServerListener listener)
      Description copied from interface: Server
      Adds a listener to this server.
      Specified by:
      addListener in interface Server
      Parameters:
      listener - Listener to add.
    • removeListener

      public void removeListener(ServerListener listener)
      Description copied from interface: Server
      Removes a listener from this server.
      Specified by:
      removeListener in interface Server
      Parameters:
      listener - Listener to remove.
    • callEvent

      protected void callEvent(ServerEvent event)
    • getSessions

      public List<Session> getSessions()
      Description copied from interface: Server
      Gets all sessions belonging to this server.
      Specified by:
      getSessions in interface Server
      Returns:
      Sessions belonging to this server.
    • addSession

      public void addSession(Session session)
    • removeSession

      public void removeSession(Session session)
    • bind

      public AbstractServer bind()
      Description copied from interface: Server
      Binds the listener to its host and port.
      Specified by:
      bind in interface Server
      Returns:
      The server.
    • bind

      public AbstractServer bind(boolean wait)
      Description copied from interface: Server
      Binds the listener to its host and port.
      Specified by:
      bind in interface Server
      Parameters:
      wait - Whether to wait for the listener to finish binding.
      Returns:
      The server.
    • bind

      public AbstractServer bind(boolean wait, Runnable callback)
      Description copied from interface: Server
      Binds the listener to its host and port.
      Specified by:
      bind in interface Server
      Parameters:
      wait - Whether to wait for the listener to finish binding.
      callback - Callback to call when the listener has finished binding.
      Returns:
      The server.
    • bindImpl

      protected abstract void bindImpl(boolean wait, Runnable callback)
    • close

      public void close()
      Description copied from interface: Server
      Closes the listener.
      Specified by:
      close in interface Server
    • close

      public void close(boolean wait)
      Description copied from interface: Server
      Closes the listener.
      Specified by:
      close in interface Server
      Parameters:
      wait - Whether to wait for the listener to finish closing.
    • close

      public void close(boolean wait, Runnable callback)
      Description copied from interface: Server
      Closes the listener.
      Specified by:
      close in interface Server
      Parameters:
      wait - Whether to wait for the listener to finish closing.
      callback - Callback to call when the listener has finished closing.
    • closeImpl

      protected abstract void closeImpl(boolean wait, Runnable callback)