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 PacketProtocol> 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 voidprotected PacketProtocol<T> TgetGlobalFlag(Flag<T> flag) Gets the value of the given flag as an instance of the given type.<T> TgetGlobalFlag(Flag<T> flag, T def) Gets the value of the given flag as an instance of the given type.Gets this server's set flags.getHost()Gets the host the session is listening on.Gets the listeners listening on this session.Supplier<? extends PacketProtocol>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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.geysermc.mcprotocollib.network.Server
isListening
-
Constructor Details
-
AbstractServer
-
-
Method Details
-
getHost
Description copied from interface:ServerGets the host the session is listening on. -
getPort
public int getPort()Description copied from interface:ServerGets the port the session is listening on. -
getPacketProtocol
Description copied from interface:ServerGets the packet protocol of the server.- Specified by:
getPacketProtocolin interfaceServer- Returns:
- The server's packet protocol.
-
createPacketProtocol
-
getGlobalFlags
Description copied from interface:ServerGets this server's set flags.- Specified by:
getGlobalFlagsin interfaceServer- Returns:
- This server's flags.
-
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.
-
getGlobalFlag
Description copied from interface:ServerGets the value of the given flag as an instance of the given type.- Specified by:
getGlobalFlagin interfaceServer- Type Parameters:
T- Type of the flag.- Parameters:
flag- Flag to check for.- Returns:
- Value of the flag.
-
getGlobalFlag
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:
getGlobalFlagin interfaceServer- 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
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
public void close()Description copied from interface:ServerCloses the listener. -
close
public void close(boolean wait) Description copied from interface:ServerCloses the listener. -
close
Description copied from interface:ServerCloses the listener. -
closeImpl
-