Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import net.kyori.adventure.text.event.ClickCallback;
import net.kyori.adventure.text.event.ClickEvent;
import org.bukkit.inventory.ItemStack;
import org.intellij.lang.annotations.Pattern;
import org.jetbrains.annotations.ApiStatus;
import org.jspecify.annotations.Nullable;

Expand Down Expand Up @@ -62,15 +63,15 @@ final class Holder {
PlainMessageDialogBody plainMessageDialogBody(Component component, int width);

// inputs
BooleanDialogInput.Builder booleanBuilder(String key, Component label);
BooleanDialogInput.Builder booleanBuilder(@Pattern("^[a-zA-Z0-9_]+$") String key, Component label);

NumberRangeDialogInput.Builder numberRangeBuilder(String key, Component label, float start, float end);
NumberRangeDialogInput.Builder numberRangeBuilder(@Pattern("^[a-zA-Z0-9_]+$") String key, Component label, float start, float end);

SingleOptionDialogInput.Builder singleOptionBuilder(String key, Component label, List<SingleOptionDialogInput.OptionEntry> entries);
SingleOptionDialogInput.Builder singleOptionBuilder(@Pattern("^[a-zA-Z0-9_]+$") String key, Component label, List<SingleOptionDialogInput.OptionEntry> entries);

SingleOptionDialogInput.OptionEntry singleOptionEntry(String id, @Nullable Component display, boolean initial);

TextDialogInput.Builder textBuilder(String key, Component label);
TextDialogInput.Builder textBuilder(@Pattern("^[a-zA-Z0-9_]+$") String key, Component label);

TextDialogInput.MultilineOptions multilineOptions(@Nullable Integer maxLines, @Nullable Integer height);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.List;
import net.kyori.adventure.text.Component;
import org.checkerframework.checker.index.qual.Positive;
import org.intellij.lang.annotations.Pattern;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.Range;
import org.jspecify.annotations.Nullable;
Expand All @@ -24,7 +25,7 @@ public sealed interface DialogInput permits BooleanDialogInput, NumberRangeDialo
* @return a new boolean dialog input instance
*/
@Contract(pure = true, value = "_, _, _, _, _ -> new")
static BooleanDialogInput bool(final String key, final Component label, final boolean initial, final String onTrue, final String onFalse) {
static BooleanDialogInput bool(@Pattern("^[a-zA-Z0-9_]+$") final String key, final Component label, final boolean initial, final String onTrue, final String onFalse) {
return bool(key, label)
.initial(initial)
.onTrue(onTrue)
Expand All @@ -40,7 +41,7 @@ static BooleanDialogInput bool(final String key, final Component label, final bo
* @return a new builder instance
*/
@Contract(pure = true, value = "_, _ -> new")
static BooleanDialogInput.Builder bool(final String key, final Component label) {
static BooleanDialogInput.Builder bool(@Pattern("^[a-zA-Z0-9_]+$") final String key, final Component label) {
return DialogInstancesProvider.instance().booleanBuilder(key, label);
}

Expand All @@ -59,7 +60,7 @@ static BooleanDialogInput.Builder bool(final String key, final Component label)
*/
@Contract(pure = true, value = "_, _, _, _, _, _, _, _ -> new")
static NumberRangeDialogInput numberRange(
final String key,
@Pattern("^[a-zA-Z0-9_]+$") final String key,
final @Range(from = 1, to = 1024) int width,
final Component label,
final String labelFormat,
Expand All @@ -81,7 +82,7 @@ static NumberRangeDialogInput numberRange(
* @return a new builder instance
*/
@Contract(pure = true, value = "_, _, _, _ -> new")
static NumberRangeDialogInput.Builder numberRange(final String key, final Component label, final float start, final float end) {
static NumberRangeDialogInput.Builder numberRange(@Pattern("^[a-zA-Z0-9_]+$") final String key, final Component label, final float start, final float end) {
return DialogInstancesProvider.instance().numberRangeBuilder(key, label, start, end);
}

Expand All @@ -97,7 +98,7 @@ static NumberRangeDialogInput.Builder numberRange(final String key, final Compon
*/
@Contract(pure = true, value = "_, _, _, _, _ -> new")
static SingleOptionDialogInput singleOption(
final String key,
@Pattern("^[a-zA-Z0-9_]+$") final String key,
final @Range(from = 1, to = 1024) int width,
final List<SingleOptionDialogInput.OptionEntry> entries,
final Component label,
Expand All @@ -115,7 +116,7 @@ static SingleOptionDialogInput singleOption(
* @return a new builder instance
*/
@Contract(pure = true, value = "_, _, _ -> new")
static SingleOptionDialogInput.Builder singleOption(final String key, final Component label, final List<SingleOptionDialogInput.OptionEntry> entries) {
static SingleOptionDialogInput.Builder singleOption(@Pattern("^[a-zA-Z0-9_]+$") final String key, final Component label, final List<SingleOptionDialogInput.OptionEntry> entries) {
return DialogInstancesProvider.instance().singleOptionBuilder(key, label, entries);
}

Expand All @@ -133,7 +134,7 @@ static SingleOptionDialogInput.Builder singleOption(final String key, final Comp
*/
@Contract(pure = true, value = "_, _, _, _, _, _, _ -> new")
static TextDialogInput text(
final String key,
@Pattern("^[a-zA-Z0-9_]+$") final String key,
final @Range(from = 1, to = 1024) int width,
final Component label,
final boolean labelVisible,
Expand All @@ -152,7 +153,7 @@ static TextDialogInput text(
* @return a new builder instance
*/
@Contract(value = "_, _ -> new", pure = true)
static TextDialogInput.Builder text(final String key, final Component label) {
static TextDialogInput.Builder text(@Pattern("^[a-zA-Z0-9_]+$") final String key, final Component label) {
return DialogInstancesProvider.instance().textBuilder(key, label);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import net.minecraft.core.UUIDUtil;
import net.minecraft.nbt.CompoundTag;
import org.bukkit.inventory.ItemStack;
import org.intellij.lang.annotations.Pattern;
import org.jspecify.annotations.Nullable;

public final class PaperDialogInstancesProvider implements DialogInstancesProvider {
Expand Down Expand Up @@ -94,17 +95,17 @@ public PlainMessageDialogBody plainMessageDialogBody(final Component component,
}

@Override
public BooleanDialogInput.Builder booleanBuilder(final String key, final Component label) {
public BooleanDialogInput.Builder booleanBuilder(@Pattern("^[a-zA-Z0-9_]+$") final String key, final Component label) {
return new BooleanDialogInputImpl.BuilderImpl(key, label);
}

@Override
public NumberRangeDialogInput.Builder numberRangeBuilder(final String key, final Component label, final float start, final float end) {
public NumberRangeDialogInput.Builder numberRangeBuilder(@Pattern("^[a-zA-Z0-9_]+$") final String key, final Component label, final float start, final float end) {
return new NumberRangeDialogInputImpl.BuilderImpl(key, label, start, end);
}

@Override
public SingleOptionDialogInput.Builder singleOptionBuilder(final String key, final Component label, final List<SingleOptionDialogInput.OptionEntry> entries) {
public SingleOptionDialogInput.Builder singleOptionBuilder(@Pattern("^[a-zA-Z0-9_]+$") final String key, final Component label, final List<SingleOptionDialogInput.OptionEntry> entries) {
return new SingleOptionDialogInputImpl.BuilderImpl(key, entries, label);
}

Expand All @@ -114,7 +115,7 @@ public SingleOptionDialogInput.OptionEntry singleOptionEntry(final String id, fi
}

@Override
public TextDialogInput.Builder textBuilder(final String key, final Component label) {
public TextDialogInput.Builder textBuilder(@Pattern("^[a-zA-Z0-9_]+$") final String key, final Component label) {
return new TextDialogInputImpl.BuilderImpl(key, label);
}

Expand Down
Loading