Interface CommandAbstractionApi
- All Known Subinterfaces:
ModdedCommandAbstractionApi
- All Known Implementing Classes:
CommandAbstractionImpl
public interface CommandAbstractionApi
Provides some abstractions for dealing with commands.
Mostly for internal use for the config command.
Mostly for internal use for the config command.
An Object is used as the generic type for the argument builders, but the implementations (literalImpl(String) and argumentImpl(String, ArgumentType)) will create them with platform-specific command sources.
This way, the methods here can be called with a context containing with the generic Object and implementations will cast that to the platform-specific command sources for implementing the methods.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> com.mojang.brigadier.builder.RequiredArgumentBuilder<Object,T> Creates aRequiredArgumentBuilderfor the current platform specific command source and providedArgumentType.<T> com.mojang.brigadier.builder.RequiredArgumentBuilder<?,T> argumentImpl(String name, com.mojang.brigadier.arguments.ArgumentType<T> type) static booleanexecutedByPlayer(Object source) Checks whether the provided command source is executed by a player.booleanexecutedByPlayerImpl(Object source) static booleanChecks whether the provided command source has operator permissions or is the host of a singleplayer server.static booleanChecks whether the provided command source is the host of a singleplayer server.booleanisHostImpl(Object source) static booleanChecks whether the provided command source has operator permissions.booleanstatic com.mojang.brigadier.builder.LiteralArgumentBuilder<Object>Creates aLiteralArgumentBuilderfor the current platform specific command source.com.mojang.brigadier.builder.LiteralArgumentBuilder<?>literalImpl(String name) static voidSends an error message to the command source.static voidSends an error message to the command source.voidsendErrorImpl(com.mojang.brigadier.context.CommandContext<Object> ctx, String message) static voidsendMessage(com.mojang.brigadier.context.CommandContext<Object> ctx, String message) Sends a message to the command source.static voidsendMessage(com.mojang.brigadier.context.CommandContext<Object> ctx, String message, Object... args) Sends a message to the command source.voidsendMessageImpl(com.mojang.brigadier.context.CommandContext<Object> ctx, String message) static voidsendText(com.mojang.brigadier.context.CommandContext<Object> ctx, MonkeyLibText text) Sends aMonkeyLibTextto the command source.voidsendTextImpl(com.mojang.brigadier.context.CommandContext<Object> ctx, MonkeyLibText text)
-
Field Details
-
INSTANCE
-
-
Method Details
-
literal
Creates aLiteralArgumentBuilderfor the current platform specific command source.- Parameters:
name- the name of theLiteralArgumentBuilder- Returns:
- a
LiteralArgumentBuilderfor the current platform specific command source.
-
argument
static <T> com.mojang.brigadier.builder.RequiredArgumentBuilder<Object,T> argument(String name, com.mojang.brigadier.arguments.ArgumentType<T> type) Creates aRequiredArgumentBuilderfor the current platform specific command source and providedArgumentType.- Type Parameters:
T- the type for theArgumentType- Parameters:
name- the name of theRequiredArgumentBuildertype- theArgumentTypeto use.- Returns:
- a
RequiredArgumentBuilderfor the current platform specific command source and providedArgumentType.
-
sendMessage
static void sendMessage(com.mojang.brigadier.context.CommandContext<Object> ctx, String message, Object... args) Sends a message to the command source.- Parameters:
ctx- theCommandContextto get the current-platform-specific command source from.message- the message to send, formatted usingargsandString.formatted(Object...)args- the args for formatting the message usingString.formatted(Object...)
-
sendMessage
Sends a message to the command source.- Parameters:
ctx- theCommandContextto get the current-platform-specific command source from.message- the message to send
-
sendError
static void sendError(com.mojang.brigadier.context.CommandContext<Object> ctx, String message, Object... args) Sends an error message to the command source.- Parameters:
ctx- theCommandContextto get the current-platform-specific command source from.message- the error message to send, formatted usingString.formatted(Object...)with the providedargsargs- the args for formatting the error message usingString.formatted(Object...)
-
sendError
Sends an error message to the command source.- Parameters:
ctx- theCommandContextto get the current-platform-specific command source from.message- the error message to send
-
sendText
Sends aMonkeyLibTextto the command source.- Parameters:
ctx- theCommandContextto get the current-platform-specific command source from.text- theMonkeyLibTextto send
-
executedByPlayer
Checks whether the provided command source is executed by a player.- Parameters:
source- the current-platform-specific command source.- Returns:
- whether the provided command source is executed by a player.
-
isAdmin
Checks whether the provided command source has operator permissions or is the host of a singleplayer server.
This returns true for singleplayer hosts even when cheats are disabled.- Parameters:
source- the current-platform-specific command source.- Returns:
- whether the provided command source has operator permissions or is the host of a singleplayer server
- See Also:
-
isOp
Checks whether the provided command source has operator permissions.- Parameters:
source- the current-platform-specific command source.- Returns:
- whether the provided command source has operator permissions
- See Also:
-
isHost
Checks whether the provided command source is the host of a singleplayer server.
UnlikeisOp(Object), this method returns true even when cheats aren't enabled.- Parameters:
source- the current-platform-specific command source.- Returns:
- whether the provided command source is the host of a singleplayer server
- See Also:
-
literalImpl
-
argumentImpl
-
sendMessageImpl
-
sendErrorImpl
-
sendTextImpl
@Internal void sendTextImpl(com.mojang.brigadier.context.CommandContext<Object> ctx, MonkeyLibText text) -
executedByPlayerImpl
-
isOpImpl
-
isHostImpl
-