Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
import net.minestom.server.dialog.DialogMetadata;
import net.onelitefeather.pica.dialog.display.component.ComponentTemplate;
import net.onelitefeather.pica.dialog.display.item.ItemTemplate;
import net.onelitefeather.pica.dialog.input.bool.BooleanTemplate;
import net.onelitefeather.pica.dialog.input.option.SingleOptionTemplate;
import net.onelitefeather.pica.dialog.input.range.RangeTemplate;
import net.onelitefeather.pica.dialog.input.text.TextInputTemplate;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
Expand All @@ -18,7 +21,7 @@
* The {@link DialogMeta} is responsible for building the {@link DialogMetadata} object for a {@link net.minestom.server.dialog.Dialog}.
*
* @author theEvilReaper
* @version 1.0.1
* @version 1.1.0
* @since 1.0.0
*/
@ApiStatus.NonExtendable
Expand Down Expand Up @@ -104,6 +107,33 @@ public sealed interface DialogMeta permits DialogMetaData {
*/
DialogMeta text(String key, Consumer<TextInputTemplate> template);

/**
* Add a {@link SingleOptionTemplate} to the dialog meta.
*
* @param key the key of the option
* @param template the template to add
* @return the builder
*/
DialogMeta option(String key, Consumer<SingleOptionTemplate> template);

/**
* Add a {@link RangeTemplate} to the dialog meta.
*
* @param key the key of the range
* @param template the template to add
* @return the builder
*/
DialogMeta range(String key, Consumer<RangeTemplate> template);

/**
* Add a {@link BooleanTemplate} to the dialog meta.
*
* @param key the key of the boolean
* @param template the template to add
* @return the builder
*/
DialogMeta bool(String key, Consumer<BooleanTemplate> template);

/**
* Set a list of {@link DialogInput}s to the dialog meta
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
import net.minestom.server.dialog.DialogMetadata;
import net.onelitefeather.pica.dialog.display.component.ComponentTemplate;
import net.onelitefeather.pica.dialog.display.item.ItemTemplate;
import net.onelitefeather.pica.dialog.input.bool.BooleanTemplate;
import net.onelitefeather.pica.dialog.input.option.SingleOptionTemplate;
import net.onelitefeather.pica.dialog.input.range.RangeTemplate;
import net.onelitefeather.pica.dialog.input.text.TextInputTemplate;
import org.jetbrains.annotations.Nullable;

Expand All @@ -18,7 +21,7 @@
* The {@link DialogMetaData} is responsible for building the {@link DialogMetadata} object.
*
* @author theEvilReaper
* @version 1.0.0
* @version 1.1.0
* @since 0.1.0
*/
public final class DialogMetaData implements DialogMeta {
Expand Down Expand Up @@ -131,6 +134,39 @@ public DialogMeta text(String key, Consumer<TextInputTemplate> template) {
return this;
}

/**
* {@inheritDoc}
*/
@Override
public DialogMeta option(String key, Consumer<SingleOptionTemplate> template) {
SingleOptionTemplate body = SingleOptionTemplate.builder(key);
template.accept(body);
this.inputList.add(body.build());
return this;
}

/**
* {@inheritDoc}
*/
@Override
public DialogMeta range(String key, Consumer<RangeTemplate> template) {
RangeTemplate body = RangeTemplate.builder(key);
template.accept(body);
this.inputList.add(body.build());
return this;
}

/**
* {@inheritDoc}
*/
@Override
public DialogMeta bool(String key, Consumer<BooleanTemplate> template) {
BooleanTemplate body = BooleanTemplate.builder(key);
template.accept(body);
this.inputList.add(body.build());
return this;
}

/**
* {@inheritDoc}
*/
Expand Down
Loading