Class ServerConnectionContextProvider
java.lang.Object
dev.rollczi.litecommands.velocity.context.ServerConnectionContextProvider
- All Implemented Interfaces:
dev.rollczi.litecommands.context.ContextProvider<com.velocitypowered.api.command.CommandSource,com.velocitypowered.api.proxy.ServerConnection>
public class ServerConnectionContextProvider
extends Object
implements dev.rollczi.litecommands.context.ContextProvider<com.velocitypowered.api.command.CommandSource,com.velocitypowered.api.proxy.ServerConnection>
Built-in context provider that provides a server connection instance if the sender is a player and is connected to a server.
Otherwise, it returns an error message. You can modify the message using
For example:
LiteCommandsBuilder.message(MessageKey, Object).
For example:
or with the lambda function:builder.message(LiteVelocityMessages.NOT_CONNECTED_TO_ANY_SERVER, "Not connected to any server!");
builder.message(LiteVelocityMessages.NOT_CONNECTED_TO_ANY_SERVER, (invocation, player) -> "Hello, " + player.getUsername() + "! You are not connected to any server!");
-
Constructor Summary
ConstructorsConstructorDescriptionServerConnectionContextProvider(dev.rollczi.litecommands.message.MessageRegistry<com.velocitypowered.api.command.CommandSource> messageRegistry) -
Method Summary
Modifier and TypeMethodDescriptiondev.rollczi.litecommands.context.ContextResult<com.velocitypowered.api.proxy.ServerConnection> provide(dev.rollczi.litecommands.invocation.Invocation<com.velocitypowered.api.command.CommandSource> invocation)
-
Constructor Details
-
ServerConnectionContextProvider
public ServerConnectionContextProvider(dev.rollczi.litecommands.message.MessageRegistry<com.velocitypowered.api.command.CommandSource> messageRegistry)
-
-
Method Details
-
provide
public dev.rollczi.litecommands.context.ContextResult<com.velocitypowered.api.proxy.ServerConnection> provide(dev.rollczi.litecommands.invocation.Invocation<com.velocitypowered.api.command.CommandSource> invocation) - Specified by:
providein interfacedev.rollczi.litecommands.context.ContextProvider<com.velocitypowered.api.command.CommandSource,com.velocitypowered.api.proxy.ServerConnection>
-