Interface CommandContext.Builder
-
- All Superinterfaces:
CommandContext
,Contextual
,Subject
,SubjectProxy
- Enclosing interface:
- CommandContext
public static interface CommandContext.Builder extends CommandContext
A builder for creating this context.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
CommandContext.Builder.Transaction
A transaction on a context builder.-
Nested classes/interfaces inherited from interface org.spongepowered.api.command.parameter.CommandContext
CommandContext.Builder
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
addFlagInvocation(Flag flag)
Adds a flag invocation to the context.CommandContext
build(String input)
Creates aCommandContext
.void
commit(CommandContext.Builder.Transaction transaction)
Commits the specifiedCommandContext.Builder.Transaction
if it was the most recently created transaction.default <T> void
putEntries(Parameter.Key<? super T> parameter, Collection<T> value)
Adds a collection of parsed objects into the context, for use by commands.default <T> void
putEntries(Parameter.Value<? super T> parameter, Collection<T> value)
Adds a collection of parsed objects into the context, for use by commands.<T> void
putEntry(Parameter.Key<T> key, T object)
Adds a parsed object into the context, for use by commands.default <T> void
putEntry(Parameter.Value<? super T> parameter, T value)
Adds a parsed object into the context, for use by commands.void
rollback(CommandContext.Builder.Transaction transaction)
Cancels the specifiedCommandContext.Builder.Transaction
if it was the most recently created transaction.CommandContext.Builder.Transaction
startTransaction()
Starts aCommandContext.Builder.Transaction
which allows for this builder to be returned to a previous state if necessary.-
Methods inherited from interface org.spongepowered.api.command.parameter.CommandContext
all, all, cause, executedCommand, flagInvocationCount, flagInvocationCount, hasAny, hasAny, hasFlag, hasFlag, one, one, requireOne, requireOne, sendMessage, sendMessage
-
Methods inherited from interface org.spongepowered.api.service.permission.SubjectProxy
associatedObject, asSubjectReference, containingCollection, contextCause, friendlyIdentifier, hasPermission, hasPermission, hasPermission, identifier, isChildOf, isChildOf, isChildOf, isSubjectDataPersisted, option, option, option, parents, parents, parents, permissionValue, permissionValue, permissionValue, subject, subjectData, transientSubjectData
-
-
-
-
Method Detail
-
addFlagInvocation
void addFlagInvocation(Flag flag)
Adds a flag invocation to the context.- Parameters:
flag
- The flag to add the invocation for.
-
putEntry
default <T> void putEntry(Parameter.Value<? super T> parameter, T value)
Adds a parsed object into the context, for use by commands.- Type Parameters:
T
- The type of parameter key- Parameters:
parameter
- The key to store the entry under.value
- The collection of objects to store.
-
putEntries
default <T> void putEntries(Parameter.Value<? super T> parameter, Collection<T> value)
Adds a collection of parsed objects into the context, for use by commands.- Type Parameters:
T
- The type of parameter key- Parameters:
parameter
- The key to store the entry under.value
- The collection of objects to store.
-
putEntries
default <T> void putEntries(Parameter.Key<? super T> parameter, Collection<T> value)
Adds a collection of parsed objects into the context, for use by commands.- Type Parameters:
T
- The type of parameter key- Parameters:
parameter
- The key to store the entry under.value
- The collection of objects to store.
-
putEntry
<T> void putEntry(Parameter.Key<T> key, T object)
Adds a parsed object into the context, for use by commands.- Type Parameters:
T
- The type of parameter key- Parameters:
key
- The key to store the entry under.object
- The object to store.
-
startTransaction
CommandContext.Builder.Transaction startTransaction()
Starts aCommandContext.Builder.Transaction
which allows for this builder to be returned to a previous state if necessary.Multiple transactions can be started on the same builder, however, they must be either
committed
orrolledback
in reverse order (that is, the last transaction must be committed first)Transactions must not be held on to for longer than necessary.
- Returns:
- The state.
-
build
CommandContext build(String input)
Creates aCommandContext
.If
CommandContext.Builder.Transaction
s are still open at this point, they will all becommitted
.- Parameters:
input
- The input argument string.- Returns:
- The context
-
commit
void commit(CommandContext.Builder.Transaction transaction) throws IllegalArgumentException
Commits the specifiedCommandContext.Builder.Transaction
if it was the most recently created transaction.- Parameters:
transaction
- The transaction to commit.- Throws:
IllegalArgumentException
- Thrown if there are newer transactions to commit first, if this transaction is not active, or if this transaction is not part of this builder.
-
rollback
void rollback(CommandContext.Builder.Transaction transaction) throws IllegalArgumentException
Cancels the specifiedCommandContext.Builder.Transaction
if it was the most recently created transaction.- Parameters:
transaction
- The transaction to rollback.- Throws:
IllegalArgumentException
- Thrown if there are newer transactions to commit first, if this transaction is not active, or if this transaction is not part of this builder.
-
-