Interface CommandContext.Builder
- All Superinterfaces:
CommandContext
,Contextual
,Subject
,SubjectProxy
- Enclosing interface:
- CommandContext
A builder for creating this context.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
A transaction on a context builder.Nested classes/interfaces inherited from interface org.spongepowered.api.command.parameter.CommandContext
CommandContext.Builder
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addFlagInvocation
(Flag flag) Adds a flag invocation to the context.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.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, 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 Details
-
addFlagInvocation
Adds a flag invocation to the context.- Parameters:
flag
- The flag to add the invocation for.
-
putEntry
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
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
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
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
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
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
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.
-