Class AbstractServer
java.lang.Object
org.geysermc.mcprotocollib.network.AbstractServer
- All Implemented Interfaces:
Server
- Direct Known Subclasses:
TcpServer
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractServer(String host, int port, Supplier<? extends MinecraftProtocol> protocolSupplier) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(ServerListener listener) Adds a listener to this server.voidaddSession(Session session) bind()Binds the listener to its host and port.bind(boolean wait) Binds the listener to its host and port.Binds the listener to its host and port.protected abstract voidprotected voidcallEvent(ServerEvent event) voidclose()Closes the listener.voidclose(boolean wait) Closes the listener.voidCloses the listener.protected abstract voidGets this server's set flags.<T> TgetGlobalFlagSupplied(Flag<T> flag, Supplier<T> defSupplier) Gets the value of the given flag as an instance of the given type.getHost()Gets the host the session is listening on.Gets the listeners listening on this session.Supplier<? extends MinecraftProtocol> Gets the packet protocol of the server.intgetPort()Gets the port the session is listening on.Gets all sessions belonging to this server.booleanhasGlobalFlag(Flag<?> flag) Checks whether this server has a flag set.voidremoveListener(ServerListener listener) Removes a listener from this server.voidremoveSession(Session session) <T> voidsetGlobalFlag(Flag<T> flag, T value) Sets the value of a flag.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Server
getGlobalFlag, getGlobalFlag, isListening
-
Constructor Details
-
AbstractServer
public AbstractServer(String host, int port, Supplier<? extends MinecraftProtocol> protocolSupplier)
-
-
Method Details
-
getHost
-
getPort
-
getPacketProtocol
Description copied from interface:ServerGets the packet protocol of the server.- Specified by:
getPacketProtocolin interfaceServer- Returns:
- The server's packet protocol.
-
createPacketProtocol
-
getGlobalFlags
-
hasGlobalFlag
Description copied from interface:ServerChecks whether this server has a flag set.- Specified by:
hasGlobalFlagin interfaceServer- Parameters:
flag- Flag to check for.- Returns:
- Whether this server has a flag set.
-
getGlobalFlagSupplied
Description copied from interface:ServerGets 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:
getGlobalFlagSuppliedin interfaceServer- Type Parameters:
T- Type of the flag.- Parameters:
flag- Flag to check for.defSupplier- Default value supplier.- Returns:
- Value of the flag.
-
setGlobalFlag
Description copied from interface:ServerSets 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:
setGlobalFlagin interfaceServer- Type Parameters:
T- Type of the flag.- Parameters:
flag- Flag to check for.value- Value to set the flag to.
-
getListeners
Description copied from interface:ServerGets the listeners listening on this session.- Specified by:
getListenersin interfaceServer- Returns:
- This server's listeners.
-
addListener
Description copied from interface:ServerAdds a listener to this server.- Specified by:
addListenerin interfaceServer- Parameters:
listener- Listener to add.
-
removeListener
Description copied from interface:ServerRemoves a listener from this server.- Specified by:
removeListenerin interfaceServer- Parameters:
listener- Listener to remove.
-
callEvent
-
getSessions
Description copied from interface:ServerGets all sessions belonging to this server.- Specified by:
getSessionsin interfaceServer- Returns:
- Sessions belonging to this server.
-
addSession
-
removeSession
-
bind
Description copied from interface:ServerBinds the listener to its host and port. -
bind
Description copied from interface:ServerBinds the listener to its host and port. -
bind
Description copied from interface:ServerBinds the listener to its host and port. -
bindImpl
-
close
-
close
-
close
-
closeImpl
-