Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add method to command meta for adding a key with no value #710 #763

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions cloud-core/src/main/java/org/incendo/cloud/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,27 @@ private Builder(
);
}

/**
* Adds command meta with no value to the internal command meta-map
*
* @param key meta key
* @return new builder instance using the inserted meta key
*/
@API(status = API.Status.STABLE)
public @NonNull Builder<C> meta(final @NonNull CloudKey<Void> key) {
final CommandMeta commandMeta = CommandMeta.builder().with(this.commandMeta).with(key).build();
return new Builder<>(
this.commandManager,
commandMeta,
this.senderType,
this.commandComponents,
this.commandExecutionHandler,
this.permission,
this.flags,
this.commandDescription
);
}

/**
* Supplies a command manager instance to the builder.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,19 @@ public class CommandMetaBuilder {
return this;
}

/**
* Stores the given {@code key} with no value.
*
* @param key the key
* @return {@code this}
*/
public @This @NonNull CommandMetaBuilder with(
final @NonNull CloudKey<Void> key
) {
this.map.put(key, new Object());
return this;
}

/**
* Builds a new {@link CommandMeta} instance using the stored {@code key}-{@code value} pairs.
*
Expand Down
Loading