fabric: General cleanup and javadoc improvements
This commit is contained in:
parent
f90db1c648
commit
ab86332990
37 changed files with 752 additions and 539 deletions
|
|
@ -26,7 +26,7 @@ package cloud.commandframework.fabric;
|
|||
import cloud.commandframework.captions.SimpleCaptionRegistry;
|
||||
|
||||
/**
|
||||
* Caption registry that uses bi-functions to produce messages
|
||||
* Caption registry that uses bi-functions to produce messages.
|
||||
*
|
||||
* @param <C> Command sender type
|
||||
* @since 1.5.0
|
||||
|
|
@ -38,7 +38,9 @@ public class FabricCaptionRegistry<C> extends SimpleCaptionRegistry<C> {
|
|||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static final String ARGUMENT_PARSE_FAILURE_REGISTRY_ENTRY_UNKNOWN_ENTRY = "Could not find key {id} in registry '{registry}'";
|
||||
public static final String ARGUMENT_PARSE_FAILURE_REGISTRY_ENTRY_UNKNOWN_ENTRY =
|
||||
"Could not find value with key '{id}' in registry '{registry}'.";
|
||||
|
||||
/**
|
||||
* Default caption for {@link FabricCaptionKeys#ARGUMENT_PARSE_FAILURE_TEAM_UNKNOWN}
|
||||
*
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ public abstract class FabricCommandManager<C, S extends CommandSource> extends C
|
|||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
private void registerRegistryEntryMappings() {
|
||||
this.brigadierManager.registerMapping(
|
||||
new TypeToken<RegistryEntryArgument.RegistryEntryParser<C, ?>>() {
|
||||
new TypeToken<RegistryEntryArgument.Parser<C, ?>>() {
|
||||
},
|
||||
builder -> builder.to(argument -> {
|
||||
/* several registries have specialized argument types, so let's use those where possible */
|
||||
|
|
@ -289,7 +289,7 @@ public abstract class FabricCommandManager<C, S extends CommandSource> extends C
|
|||
/* and now, finally, we can register */
|
||||
this.getParserRegistry().registerParserSupplier(
|
||||
TypeToken.get(valueType),
|
||||
params -> new RegistryEntryArgument.RegistryEntryParser(key)
|
||||
params -> new RegistryEntryArgument.Parser(key)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ import cloud.commandframework.exceptions.InvalidCommandSenderException;
|
|||
import cloud.commandframework.exceptions.InvalidSyntaxException;
|
||||
import cloud.commandframework.exceptions.NoPermissionException;
|
||||
import cloud.commandframework.exceptions.NoSuchCommandException;
|
||||
import cloud.commandframework.execution.CommandResult;
|
||||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
|
|
@ -52,6 +51,7 @@ import java.util.function.BiConsumer;
|
|||
import java.util.function.Function;
|
||||
|
||||
final class FabricExecutor<C, S extends CommandSource> implements Command<S> {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private static final Text NEWLINE = new LiteralText("\n");
|
||||
|
|
@ -80,104 +80,96 @@ final class FabricExecutor<C, S extends CommandSource> implements Command<S> {
|
|||
final S source = ctx.getSource();
|
||||
final String input = ctx.getInput().substring(ctx.getLastChild().getNodes().get(0).getRange().getStart());
|
||||
final C sender = this.manager.getCommandSourceMapper().apply(source);
|
||||
this.manager.executeCommand(sender, input).whenComplete(this.getResultConsumer(source, sender));
|
||||
this.manager.executeCommand(sender, input).whenComplete((result, throwable) -> {
|
||||
if (throwable == null) {
|
||||
return;
|
||||
}
|
||||
if (throwable instanceof CompletionException) {
|
||||
throwable = throwable.getCause();
|
||||
}
|
||||
this.handleThrowable(source, sender, throwable);
|
||||
});
|
||||
return com.mojang.brigadier.Command.SINGLE_SUCCESS;
|
||||
}
|
||||
|
||||
private @NonNull BiConsumer<@NonNull CommandResult<C>, ? super Throwable> getResultConsumer(
|
||||
final @NonNull S source,
|
||||
final @NonNull C sender
|
||||
) {
|
||||
return (result, throwable) -> {
|
||||
if (throwable != null) {
|
||||
if (throwable instanceof CompletionException) {
|
||||
throwable = throwable.getCause();
|
||||
}
|
||||
final Throwable finalThrowable = throwable;
|
||||
if (throwable instanceof InvalidSyntaxException) {
|
||||
this.manager.handleException(
|
||||
sender,
|
||||
InvalidSyntaxException.class,
|
||||
(InvalidSyntaxException) throwable,
|
||||
(c, e) ->
|
||||
this.sendError.accept(
|
||||
source,
|
||||
new LiteralText("Invalid Command Syntax. Correct command syntax is: ")
|
||||
.append(new LiteralText(String.format("/%s", e.getCorrectSyntax()))
|
||||
.styled(style -> style.withColor(Formatting.GRAY))))
|
||||
);
|
||||
} else if (throwable instanceof InvalidCommandSenderException) {
|
||||
this.manager.handleException(
|
||||
sender,
|
||||
InvalidCommandSenderException.class,
|
||||
(InvalidCommandSenderException) throwable,
|
||||
(c, e) ->
|
||||
this.sendError.accept(source, new LiteralText(finalThrowable.getMessage()))
|
||||
);
|
||||
} else if (throwable instanceof NoPermissionException) {
|
||||
this.manager.handleException(
|
||||
sender,
|
||||
NoPermissionException.class,
|
||||
(NoPermissionException) throwable,
|
||||
(c, e) -> this.sendError.accept(source, new LiteralText(MESSAGE_NO_PERMS))
|
||||
);
|
||||
} else if (throwable instanceof NoSuchCommandException) {
|
||||
this.manager.handleException(
|
||||
sender,
|
||||
NoSuchCommandException.class,
|
||||
(NoSuchCommandException) throwable,
|
||||
(c, e) -> this.sendError.accept(source, new LiteralText(MESSAGE_UNKNOWN_COMMAND))
|
||||
);
|
||||
} else if (throwable instanceof ArgumentParseException) {
|
||||
this.manager.handleException(
|
||||
sender,
|
||||
ArgumentParseException.class,
|
||||
(ArgumentParseException) throwable,
|
||||
(c, e) -> {
|
||||
if (finalThrowable.getCause() instanceof CommandSyntaxException) {
|
||||
this.sendError.accept(source, new LiteralText("Invalid Command Argument: ")
|
||||
.append(new LiteralText("")
|
||||
.append(Texts.toText(((CommandSyntaxException) finalThrowable.getCause()).getRawMessage()))
|
||||
private void handleThrowable(final @NonNull S source, final @NonNull C sender, final @NonNull Throwable throwable) {
|
||||
if (throwable instanceof InvalidSyntaxException) {
|
||||
this.manager.handleException(
|
||||
sender,
|
||||
InvalidSyntaxException.class,
|
||||
(InvalidSyntaxException) throwable,
|
||||
(c, e) -> this.sendError.accept(
|
||||
source,
|
||||
new LiteralText("Invalid Command Syntax. Correct command syntax is: ")
|
||||
.append(new LiteralText(String.format("/%s", e.getCorrectSyntax()))
|
||||
.styled(style -> style.withColor(Formatting.GRAY)))
|
||||
)
|
||||
);
|
||||
} else if (throwable instanceof InvalidCommandSenderException) {
|
||||
this.manager.handleException(
|
||||
sender,
|
||||
InvalidCommandSenderException.class,
|
||||
(InvalidCommandSenderException) throwable,
|
||||
(c, e) -> this.sendError.accept(source, new LiteralText(throwable.getMessage()))
|
||||
);
|
||||
} else if (throwable instanceof NoPermissionException) {
|
||||
this.manager.handleException(
|
||||
sender,
|
||||
NoPermissionException.class,
|
||||
(NoPermissionException) throwable,
|
||||
(c, e) -> this.sendError.accept(source, new LiteralText(MESSAGE_NO_PERMS))
|
||||
);
|
||||
} else if (throwable instanceof NoSuchCommandException) {
|
||||
this.manager.handleException(
|
||||
sender,
|
||||
NoSuchCommandException.class,
|
||||
(NoSuchCommandException) throwable,
|
||||
(c, e) -> this.sendError.accept(source, new LiteralText(MESSAGE_UNKNOWN_COMMAND))
|
||||
);
|
||||
} else if (throwable instanceof ArgumentParseException) {
|
||||
this.manager.handleException(
|
||||
sender,
|
||||
ArgumentParseException.class,
|
||||
(ArgumentParseException) throwable,
|
||||
(c, e) -> {
|
||||
if (throwable.getCause() instanceof CommandSyntaxException) {
|
||||
this.sendError.accept(source, new LiteralText("Invalid Command Argument: ")
|
||||
.append(new LiteralText("")
|
||||
.append(Texts.toText(((CommandSyntaxException) throwable.getCause()).getRawMessage()))
|
||||
.formatted(Formatting.GRAY)));
|
||||
} else {
|
||||
this.sendError.accept(source, new LiteralText("Invalid Command Argument: ")
|
||||
.append(new LiteralText(finalThrowable.getCause().getMessage())
|
||||
} else {
|
||||
this.sendError.accept(source, new LiteralText("Invalid Command Argument: ")
|
||||
.append(new LiteralText(throwable.getCause().getMessage())
|
||||
.formatted(Formatting.GRAY)));
|
||||
}
|
||||
}
|
||||
);
|
||||
} else if (throwable instanceof CommandExecutionException) {
|
||||
this.manager.handleException(
|
||||
sender,
|
||||
CommandExecutionException.class,
|
||||
(CommandExecutionException) throwable,
|
||||
(c, e) -> {
|
||||
this.sendError.accept(source, this.decorateHoverStacktrace(
|
||||
new LiteralText(MESSAGE_INTERNAL_ERROR),
|
||||
finalThrowable.getCause(),
|
||||
sender
|
||||
));
|
||||
LOGGER.warn(
|
||||
"Error occurred while executing command for user {}:",
|
||||
this.getName.apply(source),
|
||||
finalThrowable
|
||||
);
|
||||
}
|
||||
);
|
||||
} else {
|
||||
this.sendError.accept(source, this.decorateHoverStacktrace(
|
||||
new LiteralText(MESSAGE_INTERNAL_ERROR),
|
||||
throwable,
|
||||
sender
|
||||
));
|
||||
LOGGER.warn(
|
||||
"Error occurred while executing command for user {}:",
|
||||
this.getName.apply(source),
|
||||
throwable
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
);
|
||||
} else if (throwable instanceof CommandExecutionException) {
|
||||
this.manager.handleException(
|
||||
sender,
|
||||
CommandExecutionException.class,
|
||||
(CommandExecutionException) throwable,
|
||||
(c, e) -> {
|
||||
this.sendError.accept(source, this.decorateHoverStacktrace(
|
||||
new LiteralText(MESSAGE_INTERNAL_ERROR),
|
||||
throwable.getCause(),
|
||||
sender
|
||||
));
|
||||
LOGGER.warn(
|
||||
"Error occurred while executing command for user {}:",
|
||||
this.getName.apply(source),
|
||||
throwable
|
||||
);
|
||||
}
|
||||
);
|
||||
} else {
|
||||
this.sendError.accept(source, this.decorateHoverStacktrace(
|
||||
new LiteralText(MESSAGE_INTERNAL_ERROR),
|
||||
throwable,
|
||||
sender
|
||||
));
|
||||
LOGGER.warn("Error occurred while executing command for user {}:", this.getName.apply(source), throwable);
|
||||
}
|
||||
}
|
||||
|
||||
private MutableText decorateHoverStacktrace(final MutableText input, final Throwable cause, final C sender) {
|
||||
|
|
@ -189,13 +181,12 @@ final class FabricExecutor<C, S extends CommandSource> implements Command<S> {
|
|||
cause.printStackTrace(new PrintWriter(writer));
|
||||
final String stackTrace = writer.toString().replace("\t", " ");
|
||||
return input.styled(style -> style
|
||||
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||
.withHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new LiteralText(stackTrace)
|
||||
.append(NEWLINE)
|
||||
.append(new LiteralText(" Click to copy")
|
||||
.styled(s2 -> s2
|
||||
.withColor(Formatting.GRAY)
|
||||
.withItalic(true)))
|
||||
.styled(s2 -> s2.withColor(Formatting.GRAY).withItalic(true)))
|
||||
))
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.COPY_TO_CLIPBOARD,
|
||||
|
|
|
|||
|
|
@ -189,7 +189,8 @@ public final class FabricServerCommandManager<C> extends FabricCommandManager<C,
|
|||
/**
|
||||
* Check if a sender has a certain permission.
|
||||
*
|
||||
* <p>The current implementation checks op level, pending a full Fabric permissions api.</p>
|
||||
* <p>The current implementation checks permissions using {@code fabric-permissions-api-v0},
|
||||
* falling back to op level checks.</p>
|
||||
*
|
||||
* @param sender Command sender
|
||||
* @param permission Permission node
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@
|
|||
//
|
||||
package cloud.commandframework.fabric.annotations.specifier;
|
||||
|
||||
import cloud.commandframework.fabric.argument.server.Vec2Argument;
|
||||
import cloud.commandframework.fabric.argument.server.Vec3Argument;
|
||||
import cloud.commandframework.fabric.argument.server.Vec2dArgument;
|
||||
import cloud.commandframework.fabric.argument.server.Vec3dArgument;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
|
|
@ -32,7 +32,7 @@ import java.lang.annotation.RetentionPolicy;
|
|||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Annotation used to enable coordinate centering for {@link Vec3Argument} and {@link Vec2Argument}.
|
||||
* Annotation used to enable coordinate centering for {@link Vec3dArgument} and {@link Vec2dArgument}.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -61,19 +61,19 @@ public final class AngleArgument<C> extends CommandArgument<C, AngleArgumentType
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new builder.
|
||||
* Create a new {@link Builder}.
|
||||
*
|
||||
* @param name Name of the argument
|
||||
* @param <C> Command sender type
|
||||
* @return Created builder
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> AngleArgument.@NonNull Builder<C> newBuilder(final @NonNull String name) {
|
||||
return new AngleArgument.Builder<>(name);
|
||||
public static <C> @NonNull Builder<C> builder(final @NonNull String name) {
|
||||
return new Builder<>(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new required command argument.
|
||||
* Create a new required {@link AngleArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -81,11 +81,11 @@ public final class AngleArgument<C> extends CommandArgument<C, AngleArgumentType
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull AngleArgument<C> of(final @NonNull String name) {
|
||||
return AngleArgument.<C>newBuilder(name).asRequired().build();
|
||||
return AngleArgument.<C>builder(name).asRequired().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument.
|
||||
* Create a new optional {@link AngleArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -93,11 +93,11 @@ public final class AngleArgument<C> extends CommandArgument<C, AngleArgumentType
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull AngleArgument<C> optional(final @NonNull String name) {
|
||||
return AngleArgument.<C>newBuilder(name).asOptional().build();
|
||||
return AngleArgument.<C>builder(name).asOptional().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument with a default value.
|
||||
* Create a new optional {@link AngleArgument} with the specified default value.
|
||||
*
|
||||
* @param name Argument name
|
||||
* @param defaultAngle Default angle, in degrees
|
||||
|
|
@ -109,7 +109,7 @@ public final class AngleArgument<C> extends CommandArgument<C, AngleArgumentType
|
|||
final @NonNull String name,
|
||||
final float defaultAngle
|
||||
) {
|
||||
return AngleArgument.<C>newBuilder(name).asOptionalWithDefault(Float.toString(defaultAngle)).build();
|
||||
return AngleArgument.<C>builder(name).asOptionalWithDefault(defaultAngle).build();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -126,7 +126,7 @@ public final class AngleArgument<C> extends CommandArgument<C, AngleArgumentType
|
|||
}
|
||||
|
||||
/**
|
||||
* Build a new angle argument.
|
||||
* Build a new {@link AngleArgument}.
|
||||
*
|
||||
* @return Constructed argument
|
||||
* @since 1.5.0
|
||||
|
|
@ -142,6 +142,18 @@ public final class AngleArgument<C> extends CommandArgument<C, AngleArgumentType
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the command argument to be optional, with the specified default value.
|
||||
*
|
||||
* @param defaultValue default value
|
||||
* @return this builder
|
||||
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final float defaultValue) {
|
||||
return this.asOptionalWithDefault(Float.toString(defaultValue));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ import java.util.Set;
|
|||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* An argument for a set of axes, described in Vanilla as a "swizzle".
|
||||
* An argument for a set of {@link net.minecraft.util.math.Direction.Axis axes}, described in Vanilla as a "swizzle".
|
||||
*
|
||||
* @param <C> the sender type
|
||||
* @since 1.5.0
|
||||
|
|
@ -68,19 +68,19 @@ public final class AxisArgument<C> extends CommandArgument<C, EnumSet<Direction.
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new builder.
|
||||
* Create a new {@link Builder}.
|
||||
*
|
||||
* @param name Name of the argument
|
||||
* @param <C> Command sender type
|
||||
* @return Created builder
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> AxisArgument.@NonNull Builder<C> newBuilder(final @NonNull String name) {
|
||||
return new AxisArgument.Builder<>(name);
|
||||
public static <C> @NonNull Builder<C> builder(final @NonNull String name) {
|
||||
return new Builder<>(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new required command argument.
|
||||
* Create a new required {@link AxisArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -88,11 +88,11 @@ public final class AxisArgument<C> extends CommandArgument<C, EnumSet<Direction.
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull AxisArgument<C> of(final @NonNull String name) {
|
||||
return AxisArgument.<C>newBuilder(name).asRequired().build();
|
||||
return AxisArgument.<C>builder(name).asRequired().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument.
|
||||
* Create a new optional {@link AxisArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -100,27 +100,23 @@ public final class AxisArgument<C> extends CommandArgument<C, EnumSet<Direction.
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull AxisArgument<C> optional(final @NonNull String name) {
|
||||
return AxisArgument.<C>newBuilder(name).asOptional().build();
|
||||
return AxisArgument.<C>builder(name).asOptional().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument with a default value.
|
||||
* Create a new optional {@link AxisArgument} with the specified default value.
|
||||
*
|
||||
* @param name Argument name
|
||||
* @param defaultValues Default axes to include
|
||||
* @param <C> Command sender type
|
||||
* @param name Argument name
|
||||
* @param defaultValue Default axes to include
|
||||
* @param <C> Command sender type
|
||||
* @return Created argument
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull AxisArgument<C> optional(
|
||||
final @NonNull String name,
|
||||
final @NonNull Set<Direction.@NonNull Axis> defaultValues
|
||||
final @NonNull Set<Direction.@NonNull Axis> defaultValue
|
||||
) {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
for (final Direction.Axis axis : defaultValues) {
|
||||
builder.append(axis.getName());
|
||||
}
|
||||
return AxisArgument.<C>newBuilder(name).asOptionalWithDefault(builder.toString()).build();
|
||||
return AxisArgument.<C>builder(name).asOptionalWithDefault(defaultValue).build();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -137,7 +133,7 @@ public final class AxisArgument<C> extends CommandArgument<C, EnumSet<Direction.
|
|||
}
|
||||
|
||||
/**
|
||||
* Build a new axis argument.
|
||||
* Build a new {@link AxisArgument}.
|
||||
*
|
||||
* @return Constructed argument
|
||||
* @since 1.5.0
|
||||
|
|
@ -153,6 +149,25 @@ public final class AxisArgument<C> extends CommandArgument<C, EnumSet<Direction.
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the command argument to be optional, with the specified default value.
|
||||
*
|
||||
* @param defaultValue default value
|
||||
* @return this builder
|
||||
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final @NonNull Set<Direction.@NonNull Axis> defaultValue) {
|
||||
if (defaultValue.isEmpty()) {
|
||||
throw new IllegalArgumentException("Default value must include at least one Axis!");
|
||||
}
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
for (final Direction.Axis axis : defaultValue) {
|
||||
builder.append(axis.getName());
|
||||
}
|
||||
return this.asOptionalWithDefault(builder.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,19 +62,19 @@ public final class ColorArgument<C> extends CommandArgument<C, Formatting> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new builder.
|
||||
* Create a new {@link Builder}.
|
||||
*
|
||||
* @param name Name of the component
|
||||
* @param <C> Command sender type
|
||||
* @return Created builder
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> ColorArgument.@NonNull Builder<C> newBuilder(final @NonNull String name) {
|
||||
return new ColorArgument.Builder<>(name);
|
||||
public static <C> @NonNull Builder<C> builder(final @NonNull String name) {
|
||||
return new Builder<>(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new required command argument.
|
||||
* Create a new required {@link ColorArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -82,11 +82,11 @@ public final class ColorArgument<C> extends CommandArgument<C, Formatting> {
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull ColorArgument<C> of(final @NonNull String name) {
|
||||
return ColorArgument.<C>newBuilder(name).asRequired().build();
|
||||
return ColorArgument.<C>builder(name).asRequired().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument.
|
||||
* Create a new optional {@link ColorArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -94,11 +94,11 @@ public final class ColorArgument<C> extends CommandArgument<C, Formatting> {
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull ColorArgument<C> optional(final @NonNull String name) {
|
||||
return ColorArgument.<C>newBuilder(name).asOptional().build();
|
||||
return ColorArgument.<C>builder(name).asOptional().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument with a default value.
|
||||
* Create a new optional {@link ColorArgument} with the specified default value.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param defaultColor Default colour, must be {@link Formatting#isColor() a color}
|
||||
|
|
@ -110,10 +110,7 @@ public final class ColorArgument<C> extends CommandArgument<C, Formatting> {
|
|||
final @NonNull String name,
|
||||
final @NonNull Formatting defaultColor
|
||||
) {
|
||||
if (!defaultColor.isColor()) {
|
||||
throw new IllegalArgumentException("Only color types are allowed but " + defaultColor + " was provided");
|
||||
}
|
||||
return ColorArgument.<C>newBuilder(name).asOptionalWithDefault(defaultColor.toString()).build();
|
||||
return ColorArgument.<C>builder(name).asOptionalWithDefault(defaultColor).build();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -130,7 +127,7 @@ public final class ColorArgument<C> extends CommandArgument<C, Formatting> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Build a new color argument.
|
||||
* Build a new {@link ColorArgument}.
|
||||
*
|
||||
* @return Constructed argument
|
||||
* @since 1.5.0
|
||||
|
|
@ -146,6 +143,21 @@ public final class ColorArgument<C> extends CommandArgument<C, Formatting> {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the command argument to be optional, with the specified default value.
|
||||
*
|
||||
* @param defaultColor default value, must be {@link Formatting#isColor() a color}
|
||||
* @return this builder
|
||||
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final @NonNull Formatting defaultColor) {
|
||||
if (!defaultColor.isColor()) {
|
||||
throw new IllegalArgumentException("Only color types are allowed but " + defaultColor + " was provided");
|
||||
}
|
||||
return this.asOptionalWithDefault(defaultColor.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,19 +62,19 @@ public final class CompoundTagArgument<C> extends CommandArgument<C, CompoundTag
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new builder.
|
||||
* Create a new {@link Builder}.
|
||||
*
|
||||
* @param name Name of the component
|
||||
* @param <C> Command sender type
|
||||
* @return Created builder
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> CompoundTagArgument.@NonNull Builder<C> newBuilder(final @NonNull String name) {
|
||||
return new CompoundTagArgument.Builder<>(name);
|
||||
public static <C> @NonNull Builder<C> builder(final @NonNull String name) {
|
||||
return new Builder<>(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new required command argument.
|
||||
* Create a new required {@link CompoundTagArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -82,11 +82,11 @@ public final class CompoundTagArgument<C> extends CommandArgument<C, CompoundTag
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull CompoundTagArgument<C> of(final @NonNull String name) {
|
||||
return CompoundTagArgument.<C>newBuilder(name).asRequired().build();
|
||||
return CompoundTagArgument.<C>builder(name).asRequired().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument.
|
||||
* Create a new optional {@link CompoundTagArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -94,11 +94,11 @@ public final class CompoundTagArgument<C> extends CommandArgument<C, CompoundTag
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull CompoundTagArgument<C> optional(final @NonNull String name) {
|
||||
return CompoundTagArgument.<C>newBuilder(name).asOptional().build();
|
||||
return CompoundTagArgument.<C>builder(name).asOptional().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument with a default value.
|
||||
* Create a new optional {@link CompoundTagArgument} with the specified default value.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param defaultTag Default tag value
|
||||
|
|
@ -110,7 +110,7 @@ public final class CompoundTagArgument<C> extends CommandArgument<C, CompoundTag
|
|||
final @NonNull String name,
|
||||
final @NonNull CompoundTag defaultTag
|
||||
) {
|
||||
return CompoundTagArgument.<C>newBuilder(name).asOptionalWithDefault(defaultTag.toString()).build();
|
||||
return CompoundTagArgument.<C>builder(name).asOptionalWithDefault(defaultTag).build();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -127,7 +127,7 @@ public final class CompoundTagArgument<C> extends CommandArgument<C, CompoundTag
|
|||
}
|
||||
|
||||
/**
|
||||
* Build a new compound tag argument.
|
||||
* Build a new {@link CompoundTagArgument}.
|
||||
*
|
||||
* @return Constructed argument
|
||||
* @since 1.5.0
|
||||
|
|
@ -143,6 +143,18 @@ public final class CompoundTagArgument<C> extends CommandArgument<C, CompoundTag
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the command argument to be optional, with the specified default value.
|
||||
*
|
||||
* @param defaultValue default value
|
||||
* @return this builder
|
||||
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final @NonNull CompoundTag defaultValue) {
|
||||
return this.asOptionalWithDefault(defaultValue.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ import java.util.List;
|
|||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* An argument parsing an entity anchor.
|
||||
* An argument parsing an {@link net.minecraft.command.argument.EntityAnchorArgumentType.EntityAnchor}.
|
||||
*
|
||||
* @param <C> the sender type
|
||||
* @since 1.5.0
|
||||
|
|
@ -61,19 +61,19 @@ public final class EntityAnchorArgument<C> extends CommandArgument<C, EntityAnch
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new builder.
|
||||
* Create a new {@link Builder}.
|
||||
*
|
||||
* @param name Name of the argument
|
||||
* @param <C> Command sender type
|
||||
* @return Created builder
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> EntityAnchorArgument.@NonNull Builder<C> newBuilder(final @NonNull String name) {
|
||||
return new EntityAnchorArgument.Builder<>(name);
|
||||
public static <C> @NonNull Builder<C> builder(final @NonNull String name) {
|
||||
return new Builder<>(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new required command argument.
|
||||
* Create a new required {@link EntityAnchorArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -81,11 +81,11 @@ public final class EntityAnchorArgument<C> extends CommandArgument<C, EntityAnch
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull EntityAnchorArgument<C> of(final @NonNull String name) {
|
||||
return EntityAnchorArgument.<C>newBuilder(name).asRequired().build();
|
||||
return EntityAnchorArgument.<C>builder(name).asRequired().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument.
|
||||
* Create a new optional {@link EntityAnchorArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -93,11 +93,11 @@ public final class EntityAnchorArgument<C> extends CommandArgument<C, EntityAnch
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull EntityAnchorArgument<C> optional(final @NonNull String name) {
|
||||
return EntityAnchorArgument.<C>newBuilder(name).asOptional().build();
|
||||
return EntityAnchorArgument.<C>builder(name).asOptional().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument with a default value.
|
||||
* Create a new optional {@link EntityAnchorArgument} with the specified default value.
|
||||
*
|
||||
* @param name Argument name
|
||||
* @param defaultValue Default value
|
||||
|
|
@ -109,7 +109,7 @@ public final class EntityAnchorArgument<C> extends CommandArgument<C, EntityAnch
|
|||
final @NonNull String name,
|
||||
final EntityAnchorArgumentType.@NonNull EntityAnchor defaultValue
|
||||
) {
|
||||
return EntityAnchorArgument.<C>newBuilder(name).asOptionalWithDefault(defaultValue.name()).build();
|
||||
return EntityAnchorArgument.<C>builder(name).asOptionalWithDefault(defaultValue).build();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -126,7 +126,7 @@ public final class EntityAnchorArgument<C> extends CommandArgument<C, EntityAnch
|
|||
}
|
||||
|
||||
/**
|
||||
* Build a new entity anchor argument.
|
||||
* Build a new {@link EntityAnchorArgument}.
|
||||
*
|
||||
* @return Constructed argument
|
||||
* @since 1.5.0
|
||||
|
|
@ -142,6 +142,18 @@ public final class EntityAnchorArgument<C> extends CommandArgument<C, EntityAnch
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the command argument to be optional, with the specified default value.
|
||||
*
|
||||
* @param defaultValue default value
|
||||
* @return this builder
|
||||
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final EntityAnchorArgumentType.@NonNull EntityAnchor defaultValue) {
|
||||
return this.asOptionalWithDefault(defaultValue.name());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -366,7 +366,7 @@ public final class FabricArgumentParsers {
|
|||
}
|
||||
|
||||
@Override
|
||||
public @NonNull PosArgument getWrappedCoordinates() {
|
||||
public @NonNull PosArgument wrappedCoordinates() {
|
||||
return this.posArgument;
|
||||
}
|
||||
|
||||
|
|
@ -389,12 +389,12 @@ public final class FabricArgumentParsers {
|
|||
}
|
||||
|
||||
@Override
|
||||
public @NonNull String getInput() {
|
||||
public @NonNull String inputString() {
|
||||
return this.inputString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull EntitySelector getSelector() {
|
||||
public @NonNull EntitySelector selector() {
|
||||
return this.entitySelector;
|
||||
}
|
||||
|
||||
|
|
@ -422,12 +422,12 @@ public final class FabricArgumentParsers {
|
|||
}
|
||||
|
||||
@Override
|
||||
public @NonNull String getInput() {
|
||||
public @NonNull String inputString() {
|
||||
return this.inputString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull EntitySelector getSelector() {
|
||||
public @NonNull EntitySelector selector() {
|
||||
return this.entitySelector;
|
||||
}
|
||||
|
||||
|
|
@ -455,12 +455,12 @@ public final class FabricArgumentParsers {
|
|||
}
|
||||
|
||||
@Override
|
||||
public @NonNull String getInput() {
|
||||
public @NonNull String inputString() {
|
||||
return this.inputString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull EntitySelector getSelector() {
|
||||
public @NonNull EntitySelector selector() {
|
||||
return this.entitySelector;
|
||||
}
|
||||
|
||||
|
|
@ -488,12 +488,12 @@ public final class FabricArgumentParsers {
|
|||
}
|
||||
|
||||
@Override
|
||||
public @NonNull String getInput() {
|
||||
public @NonNull String inputString() {
|
||||
return this.inputString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull EntitySelector getSelector() {
|
||||
public @NonNull EntitySelector selector() {
|
||||
return this.entitySelector;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,8 +36,8 @@ import java.util.List;
|
|||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* An argument parsing an unbounded float range, in the form {@code [min]..[max] }, where both lower and upper bounds are
|
||||
* optional.
|
||||
* An argument parsing an unbounded {@link net.minecraft.predicate.NumberRange.FloatRange float range}, in the form
|
||||
* {@code [min]..[max]}, where both lower and upper bounds are optional.
|
||||
*
|
||||
* @param <C> the sender type
|
||||
* @since 1.5.0
|
||||
|
|
@ -63,19 +63,19 @@ public final class FloatRangeArgument<C> extends CommandArgument<C, NumberRange.
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new builder.
|
||||
* Create a new {@link Builder}.
|
||||
*
|
||||
* @param name Name of the argument
|
||||
* @param <C> Command sender type
|
||||
* @return Created builder
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> FloatRangeArgument.@NonNull Builder<C> newBuilder(final @NonNull String name) {
|
||||
return new FloatRangeArgument.Builder<>(name);
|
||||
public static <C> @NonNull Builder<C> builder(final @NonNull String name) {
|
||||
return new Builder<>(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new required command argument.
|
||||
* Create a new required {@link FloatRangeArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -83,11 +83,11 @@ public final class FloatRangeArgument<C> extends CommandArgument<C, NumberRange.
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull FloatRangeArgument<C> of(final @NonNull String name) {
|
||||
return FloatRangeArgument.<C>newBuilder(name).asRequired().build();
|
||||
return FloatRangeArgument.<C>builder(name).asRequired().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument.
|
||||
* Create a new optional {@link FloatRangeArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -95,11 +95,11 @@ public final class FloatRangeArgument<C> extends CommandArgument<C, NumberRange.
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull FloatRangeArgument<C> optional(final @NonNull String name) {
|
||||
return FloatRangeArgument.<C>newBuilder(name).asOptional().build();
|
||||
return FloatRangeArgument.<C>builder(name).asOptional().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument with a default value.
|
||||
* Create a new optional {@link FloatRangeArgument} with the specified default value.
|
||||
*
|
||||
* @param name Argument name
|
||||
* @param defaultValue Default value
|
||||
|
|
@ -111,16 +111,7 @@ public final class FloatRangeArgument<C> extends CommandArgument<C, NumberRange.
|
|||
final @NonNull String name,
|
||||
final NumberRange.@NonNull FloatRange defaultValue
|
||||
) {
|
||||
final StringBuilder value = new StringBuilder(6);
|
||||
if (defaultValue.getMin() != null) {
|
||||
value.append(defaultValue.getMin());
|
||||
}
|
||||
value.append("..");
|
||||
if (defaultValue.getMax() != null) {
|
||||
value.append(defaultValue.getMax());
|
||||
}
|
||||
|
||||
return FloatRangeArgument.<C>newBuilder(name).asOptionalWithDefault(value.toString()).build();
|
||||
return FloatRangeArgument.<C>builder(name).asOptionalWithDefault(defaultValue).build();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -137,7 +128,7 @@ public final class FloatRangeArgument<C> extends CommandArgument<C, NumberRange.
|
|||
}
|
||||
|
||||
/**
|
||||
* Build a new float range argument.
|
||||
* Build a new {@link FloatRangeArgument}.
|
||||
*
|
||||
* @return Constructed argument
|
||||
* @since 1.5.0
|
||||
|
|
@ -153,6 +144,26 @@ public final class FloatRangeArgument<C> extends CommandArgument<C, NumberRange.
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the command argument to be optional, with the specified default value.
|
||||
*
|
||||
* @param defaultValue default value
|
||||
* @return this builder
|
||||
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final NumberRange.@NonNull FloatRange defaultValue) {
|
||||
final StringBuilder value = new StringBuilder(6);
|
||||
if (defaultValue.getMin() != null) {
|
||||
value.append(defaultValue.getMin());
|
||||
}
|
||||
value.append("..");
|
||||
if (defaultValue.getMax() != null) {
|
||||
value.append(defaultValue.getMax());
|
||||
}
|
||||
return this.asOptionalWithDefault(value.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ import java.util.List;
|
|||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* An argument parsing an identifier, or "resource location".
|
||||
* An argument parsing an {@link Identifier}, or "resource location".
|
||||
*
|
||||
* @param <C> the sender type
|
||||
* @since 1.5.0
|
||||
|
|
@ -62,19 +62,19 @@ public final class IdentifierArgument<C> extends CommandArgument<C, Identifier>
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new builder.
|
||||
* Create a new {@link Builder}.
|
||||
*
|
||||
* @param name Name of the argument
|
||||
* @param <C> Command sender type
|
||||
* @return Created builder
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> IdentifierArgument.@NonNull Builder<C> newBuilder(final @NonNull String name) {
|
||||
return new IdentifierArgument.Builder<>(name);
|
||||
public static <C> @NonNull Builder<C> builder(final @NonNull String name) {
|
||||
return new Builder<>(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new required command argument.
|
||||
* Create a new required {@link IdentifierArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -82,11 +82,11 @@ public final class IdentifierArgument<C> extends CommandArgument<C, Identifier>
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull IdentifierArgument<C> of(final @NonNull String name) {
|
||||
return IdentifierArgument.<C>newBuilder(name).asRequired().build();
|
||||
return IdentifierArgument.<C>builder(name).asRequired().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument.
|
||||
* Create a new optional {@link IdentifierArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -94,11 +94,11 @@ public final class IdentifierArgument<C> extends CommandArgument<C, Identifier>
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull IdentifierArgument<C> optional(final @NonNull String name) {
|
||||
return IdentifierArgument.<C>newBuilder(name).asOptional().build();
|
||||
return IdentifierArgument.<C>builder(name).asOptional().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument with a default value.
|
||||
* Create a new optional {@link IdentifierArgument} with the specified default value.
|
||||
*
|
||||
* @param name Argument name
|
||||
* @param defaultValue Default value
|
||||
|
|
@ -110,7 +110,7 @@ public final class IdentifierArgument<C> extends CommandArgument<C, Identifier>
|
|||
final @NonNull String name,
|
||||
final @NonNull Identifier defaultValue
|
||||
) {
|
||||
return IdentifierArgument.<C>newBuilder(name).asOptionalWithDefault(defaultValue.toString()).build();
|
||||
return IdentifierArgument.<C>builder(name).asOptionalWithDefault(defaultValue).build();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -127,7 +127,7 @@ public final class IdentifierArgument<C> extends CommandArgument<C, Identifier>
|
|||
}
|
||||
|
||||
/**
|
||||
* Build a new identifier argument.
|
||||
* Build a new {@link IdentifierArgument}.
|
||||
*
|
||||
* @return Constructed argument
|
||||
* @since 1.5.0
|
||||
|
|
@ -143,6 +143,18 @@ public final class IdentifierArgument<C> extends CommandArgument<C, Identifier>
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the command argument to be optional, with the specified default value.
|
||||
*
|
||||
* @param defaultValue default value
|
||||
* @return this builder
|
||||
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final @NonNull Identifier defaultValue) {
|
||||
return this.asOptionalWithDefault(defaultValue.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,8 +36,8 @@ import java.util.List;
|
|||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* An argument parsing an unbounded number range, in the form {@code [min]..[max] }, where both lower and upper bounds are
|
||||
* optional.
|
||||
* An argument parsing an unbounded {@link net.minecraft.predicate.NumberRange.IntRange integer range}, in the form
|
||||
* {@code [min]..[max]}, where both lower and upper bounds are optional.
|
||||
*
|
||||
* @param <C> the sender type
|
||||
* @since 1.5.0
|
||||
|
|
@ -63,19 +63,19 @@ public final class IntRangeArgument<C> extends CommandArgument<C, NumberRange.In
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new builder.
|
||||
* Create a new {@link Builder}.
|
||||
*
|
||||
* @param name Name of the argument
|
||||
* @param <C> Command sender type
|
||||
* @return Created builder
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> IntRangeArgument.@NonNull Builder<C> newBuilder(final @NonNull String name) {
|
||||
return new IntRangeArgument.Builder<>(name);
|
||||
public static <C> @NonNull Builder<C> builder(final @NonNull String name) {
|
||||
return new Builder<>(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new required command argument.
|
||||
* Create a new required {@link IntRangeArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -83,11 +83,11 @@ public final class IntRangeArgument<C> extends CommandArgument<C, NumberRange.In
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull IntRangeArgument<C> of(final @NonNull String name) {
|
||||
return IntRangeArgument.<C>newBuilder(name).asRequired().build();
|
||||
return IntRangeArgument.<C>builder(name).asRequired().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument.
|
||||
* Create a new optional {@link IntRangeArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -95,11 +95,11 @@ public final class IntRangeArgument<C> extends CommandArgument<C, NumberRange.In
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull IntRangeArgument<C> optional(final @NonNull String name) {
|
||||
return IntRangeArgument.<C>newBuilder(name).asOptional().build();
|
||||
return IntRangeArgument.<C>builder(name).asOptional().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument with a default value.
|
||||
* Create a new optional {@link IntRangeArgument} with the specified default value.
|
||||
*
|
||||
* @param name Argument name
|
||||
* @param defaultValue Default value
|
||||
|
|
@ -111,16 +111,7 @@ public final class IntRangeArgument<C> extends CommandArgument<C, NumberRange.In
|
|||
final @NonNull String name,
|
||||
final NumberRange.@NonNull IntRange defaultValue
|
||||
) {
|
||||
final StringBuilder value = new StringBuilder(6);
|
||||
if (defaultValue.getMin() != null) {
|
||||
value.append(defaultValue.getMin());
|
||||
}
|
||||
value.append("..");
|
||||
if (defaultValue.getMax() != null) {
|
||||
value.append(defaultValue.getMax());
|
||||
}
|
||||
|
||||
return IntRangeArgument.<C>newBuilder(name).asOptionalWithDefault(value.toString()).build();
|
||||
return IntRangeArgument.<C>builder(name).asOptionalWithDefault(defaultValue).build();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -137,7 +128,7 @@ public final class IntRangeArgument<C> extends CommandArgument<C, NumberRange.In
|
|||
}
|
||||
|
||||
/**
|
||||
* Build a new int range argument.
|
||||
* Build a new {@link IntRangeArgument}.
|
||||
*
|
||||
* @return Constructed argument
|
||||
* @since 1.5.0
|
||||
|
|
@ -153,6 +144,26 @@ public final class IntRangeArgument<C> extends CommandArgument<C, NumberRange.In
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the command argument to be optional, with the specified default value.
|
||||
*
|
||||
* @param defaultValue default value
|
||||
* @return this builder
|
||||
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final NumberRange.@NonNull IntRange defaultValue) {
|
||||
final StringBuilder value = new StringBuilder(6);
|
||||
if (defaultValue.getMin() != null) {
|
||||
value.append(defaultValue.getMin());
|
||||
}
|
||||
value.append("..");
|
||||
if (defaultValue.getMax() != null) {
|
||||
value.append(defaultValue.getMax());
|
||||
}
|
||||
return this.asOptionalWithDefault(value.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ import java.util.List;
|
|||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* An argument parsing an item identifier and optional NBT data.
|
||||
* An argument parsing an item identifier and optional extra NBT data into an {@link ItemStackArgument}.
|
||||
*
|
||||
* @param <C> the sender type
|
||||
* @since 1.5.0
|
||||
|
|
@ -64,19 +64,19 @@ public final class ItemDataArgument<C> extends CommandArgument<C, ItemStackArgum
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new builder.
|
||||
* Create a new {@link Builder}.
|
||||
*
|
||||
* @param name Name of the argument
|
||||
* @param <C> Command sender type
|
||||
* @return Created builder
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> ItemDataArgument.@NonNull Builder<C> newBuilder(final @NonNull String name) {
|
||||
return new ItemDataArgument.Builder<>(name);
|
||||
public static <C> @NonNull Builder<C> builder(final @NonNull String name) {
|
||||
return new Builder<>(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new required command argument.
|
||||
* Create a new required {@link ItemDataArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -84,11 +84,11 @@ public final class ItemDataArgument<C> extends CommandArgument<C, ItemStackArgum
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull ItemDataArgument<C> of(final @NonNull String name) {
|
||||
return ItemDataArgument.<C>newBuilder(name).asRequired().build();
|
||||
return ItemDataArgument.<C>builder(name).asRequired().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument.
|
||||
* Create a new optional {@link ItemDataArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -96,11 +96,11 @@ public final class ItemDataArgument<C> extends CommandArgument<C, ItemStackArgum
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull ItemDataArgument<C> optional(final @NonNull String name) {
|
||||
return ItemDataArgument.<C>newBuilder(name).asOptional().build();
|
||||
return ItemDataArgument.<C>builder(name).asOptional().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument with a default value.
|
||||
* Create a new optional {@link ItemDataArgument} with the specified default value.
|
||||
*
|
||||
* @param name Argument name
|
||||
* @param defaultValue Default value
|
||||
|
|
@ -108,17 +108,8 @@ public final class ItemDataArgument<C> extends CommandArgument<C, ItemStackArgum
|
|||
* @return Created argument
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull ItemDataArgument<C> optional(
|
||||
final @NonNull String name,
|
||||
final @NonNull ItemStack defaultValue
|
||||
) {
|
||||
final String serializedDefault;
|
||||
if (defaultValue.hasTag()) {
|
||||
serializedDefault = Registry.ITEM.getId(defaultValue.getItem()).toString() + defaultValue.getTag().toString();
|
||||
} else {
|
||||
serializedDefault = Registry.ITEM.getId(defaultValue.getItem()).toString();
|
||||
}
|
||||
return ItemDataArgument.<C>newBuilder(name).asOptionalWithDefault(serializedDefault).build();
|
||||
public static <C> @NonNull ItemDataArgument<C> optional(final @NonNull String name, final @NonNull ItemStack defaultValue) {
|
||||
return ItemDataArgument.<C>builder(name).asOptionalWithDefault(defaultValue).build();
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -134,7 +125,7 @@ public final class ItemDataArgument<C> extends CommandArgument<C, ItemStackArgum
|
|||
}
|
||||
|
||||
/**
|
||||
* Build a new item data argument.
|
||||
* Build a new {@link ItemDataArgument}.
|
||||
*
|
||||
* @return Constructed argument
|
||||
* @since 1.5.0
|
||||
|
|
@ -150,6 +141,24 @@ public final class ItemDataArgument<C> extends CommandArgument<C, ItemStackArgum
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the command argument to be optional, with the specified default value.
|
||||
*
|
||||
* @param defaultValue default value
|
||||
* @return this builder
|
||||
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final @NonNull ItemStack defaultValue) {
|
||||
final String serializedDefault;
|
||||
if (defaultValue.hasTag()) {
|
||||
serializedDefault = Registry.ITEM.getId(defaultValue.getItem()) + defaultValue.getTag().toString();
|
||||
} else {
|
||||
serializedDefault = Registry.ITEM.getId(defaultValue.getItem()).toString();
|
||||
}
|
||||
return this.asOptionalWithDefault(serializedDefault);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,8 @@ import java.util.List;
|
|||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* An argument for NBT paths to locations within {@link net.minecraft.nbt.Tag Tags}.
|
||||
* An argument for {@link net.minecraft.command.argument.NbtPathArgumentType.NbtPath NBT paths} to locations within
|
||||
* {@link net.minecraft.nbt.Tag Tags}.
|
||||
*
|
||||
* @param <C> the sender type
|
||||
* @since 1.5.0
|
||||
|
|
@ -61,19 +62,19 @@ public final class NbtPathArgument<C> extends CommandArgument<C, NbtPathArgument
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new builder.
|
||||
* Create a new {@link Builder}.
|
||||
*
|
||||
* @param name Name of the component
|
||||
* @param <C> Command sender type
|
||||
* @return Created builder
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> NbtPathArgument.@NonNull Builder<C> newBuilder(final @NonNull String name) {
|
||||
return new NbtPathArgument.Builder<>(name);
|
||||
public static <C> @NonNull Builder<C> builder(final @NonNull String name) {
|
||||
return new Builder<>(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new required command argument.
|
||||
* Create a new required {@link NbtPathArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -81,11 +82,11 @@ public final class NbtPathArgument<C> extends CommandArgument<C, NbtPathArgument
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull NbtPathArgument<C> of(final @NonNull String name) {
|
||||
return NbtPathArgument.<C>newBuilder(name).asRequired().build();
|
||||
return NbtPathArgument.<C>builder(name).asRequired().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument.
|
||||
* Create a new optional {@link NbtPathArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -93,11 +94,11 @@ public final class NbtPathArgument<C> extends CommandArgument<C, NbtPathArgument
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull NbtPathArgument<C> optional(final @NonNull String name) {
|
||||
return NbtPathArgument.<C>newBuilder(name).asOptional().build();
|
||||
return NbtPathArgument.<C>builder(name).asOptional().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument with a default value.
|
||||
* Create a new optional {@link NbtPathArgument} with the specified default value.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param defaultTag Default tag value
|
||||
|
|
@ -109,7 +110,7 @@ public final class NbtPathArgument<C> extends CommandArgument<C, NbtPathArgument
|
|||
final @NonNull String name,
|
||||
final NbtPathArgumentType.@NonNull NbtPath defaultTag
|
||||
) {
|
||||
return NbtPathArgument.<C>newBuilder(name).asOptionalWithDefault(defaultTag.toString()).build();
|
||||
return NbtPathArgument.<C>builder(name).asOptionalWithDefault(defaultTag).build();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -142,6 +143,18 @@ public final class NbtPathArgument<C> extends CommandArgument<C, NbtPathArgument
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the command argument to be optional, with the specified default value.
|
||||
*
|
||||
* @param defaultValue default value
|
||||
* @return this builder
|
||||
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final NbtPathArgumentType.@NonNull NbtPath defaultValue) {
|
||||
return this.asOptionalWithDefault(defaultValue.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,19 +62,19 @@ public final class NbtTagArgument<C> extends CommandArgument<C, Tag> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new builder.
|
||||
* Create a new {@link Builder}.
|
||||
*
|
||||
* @param name Name of the component
|
||||
* @param <C> Command sender type
|
||||
* @return Created builder
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> NbtTagArgument.@NonNull Builder<C> newBuilder(final @NonNull String name) {
|
||||
public static <C> NbtTagArgument.@NonNull Builder<C> builder(final @NonNull String name) {
|
||||
return new NbtTagArgument.Builder<>(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new required command argument.
|
||||
* Create a new required {@link NbtTagArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -82,11 +82,11 @@ public final class NbtTagArgument<C> extends CommandArgument<C, Tag> {
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull NbtTagArgument<C> of(final @NonNull String name) {
|
||||
return NbtTagArgument.<C>newBuilder(name).asRequired().build();
|
||||
return NbtTagArgument.<C>builder(name).asRequired().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument.
|
||||
* Create a new optional {@link NbtTagArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -94,11 +94,11 @@ public final class NbtTagArgument<C> extends CommandArgument<C, Tag> {
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull NbtTagArgument<C> optional(final @NonNull String name) {
|
||||
return NbtTagArgument.<C>newBuilder(name).asOptional().build();
|
||||
return NbtTagArgument.<C>builder(name).asOptional().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument with a default value.
|
||||
* Create a new optional {@link NbtTagArgument} with the specified default value.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param defaultTag Default tag value
|
||||
|
|
@ -106,11 +106,8 @@ public final class NbtTagArgument<C> extends CommandArgument<C, Tag> {
|
|||
* @return Created component
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull NbtTagArgument<C> optional(
|
||||
final @NonNull String name,
|
||||
final @NonNull Tag defaultTag
|
||||
) {
|
||||
return NbtTagArgument.<C>newBuilder(name).asOptionalWithDefault(defaultTag.toString()).build();
|
||||
public static <C> @NonNull NbtTagArgument<C> optional(final @NonNull String name, final @NonNull Tag defaultTag) {
|
||||
return NbtTagArgument.<C>builder(name).asOptionalWithDefault(defaultTag).build();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -127,7 +124,7 @@ public final class NbtTagArgument<C> extends CommandArgument<C, Tag> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Build a new nbt tag argument.
|
||||
* Build a new {@link NbtTagArgument}.
|
||||
*
|
||||
* @return Constructed component
|
||||
* @since 1.5.0
|
||||
|
|
@ -143,6 +140,18 @@ public final class NbtTagArgument<C> extends CommandArgument<C, Tag> {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the command argument to be optional, with the specified default value.
|
||||
*
|
||||
* @param defaultValue default value
|
||||
* @return this builder
|
||||
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final @NonNull Tag defaultValue) {
|
||||
return this.asOptionalWithDefault(defaultValue.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,19 +62,19 @@ public final class ParticleEffectArgument<C> extends CommandArgument<C, Particle
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new builder.
|
||||
* Create a new {@link Builder}.
|
||||
*
|
||||
* @param name Name of the argument
|
||||
* @param <C> Command sender type
|
||||
* @return Created builder
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> ParticleEffectArgument.@NonNull Builder<C> newBuilder(final @NonNull String name) {
|
||||
return new ParticleEffectArgument.Builder<>(name);
|
||||
public static <C> @NonNull Builder<C> builder(final @NonNull String name) {
|
||||
return new Builder<>(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new required command argument.
|
||||
* Create a new required {@link ParticleEffectArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -82,11 +82,11 @@ public final class ParticleEffectArgument<C> extends CommandArgument<C, Particle
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull ParticleEffectArgument<C> of(final @NonNull String name) {
|
||||
return ParticleEffectArgument.<C>newBuilder(name).asRequired().build();
|
||||
return ParticleEffectArgument.<C>builder(name).asRequired().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument.
|
||||
* Create a new optional {@link ParticleEffectArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -94,11 +94,11 @@ public final class ParticleEffectArgument<C> extends CommandArgument<C, Particle
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull ParticleEffectArgument<C> optional(final @NonNull String name) {
|
||||
return ParticleEffectArgument.<C>newBuilder(name).asOptional().build();
|
||||
return ParticleEffectArgument.<C>builder(name).asOptional().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument with a default value.
|
||||
* Create a new optional {@link ParticleEffectArgument} with the specified default value.
|
||||
*
|
||||
* @param name Argument name
|
||||
* @param defaultValue Default particle effect value
|
||||
|
|
@ -110,7 +110,7 @@ public final class ParticleEffectArgument<C> extends CommandArgument<C, Particle
|
|||
final @NonNull String name,
|
||||
final @NonNull ParticleEffect defaultValue
|
||||
) {
|
||||
return ParticleEffectArgument.<C>newBuilder(name).asOptionalWithDefault(defaultValue.asString()).build();
|
||||
return ParticleEffectArgument.<C>builder(name).asOptionalWithDefault(defaultValue).build();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -143,6 +143,18 @@ public final class ParticleEffectArgument<C> extends CommandArgument<C, Particle
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the command argument to be optional, with the specified default value.
|
||||
*
|
||||
* @param defaultValue default value
|
||||
* @return this builder
|
||||
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final @NonNull ParticleEffect defaultValue) {
|
||||
return this.asOptionalWithDefault(defaultValue.asString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ import java.util.function.BiFunction;
|
|||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* Get a value from a registry.
|
||||
* Argument for getting a values from a {@link Registry}.
|
||||
*
|
||||
* <p>Both static and dynamic registries are supported.</p>
|
||||
*
|
||||
|
|
@ -76,7 +76,7 @@ public class RegistryEntryArgument<C, V> extends CommandArgument<C, V> {
|
|||
super(
|
||||
required,
|
||||
name,
|
||||
new RegistryEntryParser<>(registry),
|
||||
new Parser<>(registry),
|
||||
defaultValue,
|
||||
valueType,
|
||||
suggestionsProvider,
|
||||
|
|
@ -85,7 +85,7 @@ public class RegistryEntryArgument<C, V> extends CommandArgument<C, V> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new builder.
|
||||
* Create a new {@link Builder}.
|
||||
*
|
||||
* @param name Name of the argument
|
||||
* @param type The type of registry entry
|
||||
|
|
@ -104,7 +104,7 @@ public class RegistryEntryArgument<C, V> extends CommandArgument<C, V> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new builder.
|
||||
* Create a new {@link Builder}.
|
||||
*
|
||||
* @param name Name of the argument
|
||||
* @param type The type of registry entry
|
||||
|
|
@ -123,7 +123,7 @@ public class RegistryEntryArgument<C, V> extends CommandArgument<C, V> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new required command argument.
|
||||
* Create a new required {@link RegistryEntryArgument}.
|
||||
*
|
||||
* @param name Argument name
|
||||
* @param type The type of registry entry
|
||||
|
|
@ -142,7 +142,7 @@ public class RegistryEntryArgument<C, V> extends CommandArgument<C, V> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument.
|
||||
* Create a new optional {@link RegistryEntryArgument}.
|
||||
*
|
||||
* @param name Argument name
|
||||
* @param type The type of registry entry
|
||||
|
|
@ -161,7 +161,7 @@ public class RegistryEntryArgument<C, V> extends CommandArgument<C, V> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument with a default value.
|
||||
* Create a new optional {@link RegistryEntryArgument} with the specified default value.
|
||||
*
|
||||
* @param name Argument name
|
||||
* @param type The type of registry entry
|
||||
|
|
@ -179,7 +179,7 @@ public class RegistryEntryArgument<C, V> extends CommandArgument<C, V> {
|
|||
final @NonNull RegistryKey<V> defaultValue
|
||||
) {
|
||||
return RegistryEntryArgument.<C, V>newBuilder(name, type, registry)
|
||||
.asOptionalWithDefault(defaultValue.getValue().toString())
|
||||
.asOptionalWithDefault(defaultValue)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
@ -190,17 +190,17 @@ public class RegistryEntryArgument<C, V> extends CommandArgument<C, V> {
|
|||
* @param <V> Registry entry type
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static final class RegistryEntryParser<C, V> implements ArgumentParser<C, V> {
|
||||
public static final class Parser<C, V> implements ArgumentParser<C, V> {
|
||||
|
||||
private final RegistryKey<? extends Registry<V>> registryIdent;
|
||||
|
||||
/**
|
||||
* Create a new parser for registry entries.
|
||||
* Create a new {@link Parser}.
|
||||
*
|
||||
* @param registryIdent the registry identifier
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public RegistryEntryParser(final RegistryKey<? extends Registry<V>> registryIdent) {
|
||||
public Parser(final RegistryKey<? extends Registry<V>> registryIdent) {
|
||||
this.registryIdent = requireNonNull(registryIdent, "registryIdent");
|
||||
}
|
||||
|
||||
|
|
@ -211,10 +211,7 @@ public class RegistryEntryArgument<C, V> extends CommandArgument<C, V> {
|
|||
) {
|
||||
final String possibleIdentifier = inputQueue.peek();
|
||||
if (possibleIdentifier == null) {
|
||||
return ArgumentParseResult.failure(new NoInputProvidedException(
|
||||
RegistryEntryArgument.class,
|
||||
commandContext
|
||||
));
|
||||
return ArgumentParseResult.failure(new NoInputProvidedException(RegistryEntryArgument.class, commandContext));
|
||||
}
|
||||
|
||||
final Identifier key;
|
||||
|
|
@ -285,7 +282,7 @@ public class RegistryEntryArgument<C, V> extends CommandArgument<C, V> {
|
|||
}
|
||||
|
||||
/**
|
||||
* A builder for registry entry arguments.
|
||||
* A builder for {@link RegistryEntryArgument}.
|
||||
*
|
||||
* @param <C> The sender type
|
||||
* @param <V> The registry value type
|
||||
|
|
@ -326,6 +323,18 @@ public class RegistryEntryArgument<C, V> extends CommandArgument<C, V> {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the command argument to be optional, with the specified default value.
|
||||
*
|
||||
* @param defaultValue default value
|
||||
* @return this builder
|
||||
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public @NonNull Builder<C, V> asOptionalWithDefault(final @NonNull RegistryKey<V> defaultValue) {
|
||||
return this.asOptionalWithDefault(defaultValue.getValue().toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -62,19 +62,19 @@ public final class ScoreboardCriterionArgument<C> extends CommandArgument<C, Sco
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new builder.
|
||||
* Create a new {@link Builder}.
|
||||
*
|
||||
* @param name Name of the argument
|
||||
* @param <C> Command sender type
|
||||
* @return Created builder
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> ScoreboardCriterionArgument.@NonNull Builder<C> newBuilder(final @NonNull String name) {
|
||||
return new ScoreboardCriterionArgument.Builder<>(name);
|
||||
public static <C> @NonNull Builder<C> builder(final @NonNull String name) {
|
||||
return new Builder<>(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new required command argument.
|
||||
* Create a new required {@link ScoreboardCriterionArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -82,11 +82,11 @@ public final class ScoreboardCriterionArgument<C> extends CommandArgument<C, Sco
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull ScoreboardCriterionArgument<C> of(final @NonNull String name) {
|
||||
return ScoreboardCriterionArgument.<C>newBuilder(name).asRequired().build();
|
||||
return ScoreboardCriterionArgument.<C>builder(name).asRequired().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument.
|
||||
* Create a new optional {@link ScoreboardCriterionArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -94,11 +94,11 @@ public final class ScoreboardCriterionArgument<C> extends CommandArgument<C, Sco
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull ScoreboardCriterionArgument<C> optional(final @NonNull String name) {
|
||||
return ScoreboardCriterionArgument.<C>newBuilder(name).asOptional().build();
|
||||
return ScoreboardCriterionArgument.<C>builder(name).asOptional().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument with a default value.
|
||||
* Create a new optional {@link ScoreboardCriterionArgument} with the specified default value.
|
||||
*
|
||||
* @param name Argument name
|
||||
* @param defaultCriterion Default criterion
|
||||
|
|
@ -110,7 +110,7 @@ public final class ScoreboardCriterionArgument<C> extends CommandArgument<C, Sco
|
|||
final @NonNull String name,
|
||||
final @NonNull ScoreboardCriterion defaultCriterion
|
||||
) {
|
||||
return ScoreboardCriterionArgument.<C>newBuilder(name).asOptionalWithDefault(defaultCriterion.getName()).build();
|
||||
return ScoreboardCriterionArgument.<C>builder(name).asOptionalWithDefault(defaultCriterion).build();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -127,7 +127,7 @@ public final class ScoreboardCriterionArgument<C> extends CommandArgument<C, Sco
|
|||
}
|
||||
|
||||
/**
|
||||
* Build a new criterion argument.
|
||||
* Build a new {@link ScoreboardCriterionArgument}.
|
||||
*
|
||||
* @return Constructed argument
|
||||
* @since 1.5.0
|
||||
|
|
@ -143,6 +143,18 @@ public final class ScoreboardCriterionArgument<C> extends CommandArgument<C, Sco
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the command argument to be optional, with the specified default value.
|
||||
*
|
||||
* @param defaultValue default value
|
||||
* @return this builder
|
||||
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final @NonNull ScoreboardCriterion defaultValue) {
|
||||
return this.asOptionalWithDefault(defaultValue.getName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,19 +64,19 @@ public final class ScoreboardOperationArgument<C> extends CommandArgument<C, Ope
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new builder.
|
||||
* Create a new {@link Builder}.
|
||||
*
|
||||
* @param name Name of the argument
|
||||
* @param <C> Command sender type
|
||||
* @return Created builder
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> ScoreboardOperationArgument.@NonNull Builder<C> newBuilder(final @NonNull String name) {
|
||||
public static <C> @NonNull Builder<C> builder(final @NonNull String name) {
|
||||
return new ScoreboardOperationArgument.Builder<>(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new required command argument.
|
||||
* Create a new required {@link ScoreboardOperationArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -84,11 +84,11 @@ public final class ScoreboardOperationArgument<C> extends CommandArgument<C, Ope
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull ScoreboardOperationArgument<C> of(final @NonNull String name) {
|
||||
return ScoreboardOperationArgument.<C>newBuilder(name).asRequired().build();
|
||||
return ScoreboardOperationArgument.<C>builder(name).asRequired().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument.
|
||||
* Create a new optional {@link ScoreboardOperationArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -96,7 +96,7 @@ public final class ScoreboardOperationArgument<C> extends CommandArgument<C, Ope
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull ScoreboardOperationArgument<C> optional(final @NonNull String name) {
|
||||
return ScoreboardOperationArgument.<C>newBuilder(name).asOptional().build();
|
||||
return ScoreboardOperationArgument.<C>builder(name).asOptional().build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -112,7 +112,7 @@ public final class ScoreboardOperationArgument<C> extends CommandArgument<C, Ope
|
|||
}
|
||||
|
||||
/**
|
||||
* Build a new operation argument.
|
||||
* Build a new {@link ScoreboardOperationArgument}.
|
||||
*
|
||||
* @return Constructed argument
|
||||
* @since 1.5.0
|
||||
|
|
|
|||
|
|
@ -27,8 +27,7 @@ import cloud.commandframework.arguments.parser.ArgumentParseResult;
|
|||
import cloud.commandframework.arguments.parser.ArgumentParser;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import cloud.commandframework.fabric.FabricCommandContextKeys;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
|
@ -55,9 +54,9 @@ abstract class SidedArgumentParser<C, I, R> implements ArgumentParser<C, R> {
|
|||
|
||||
return intermediate.flatMapParsedValue(value -> {
|
||||
if (source instanceof ServerCommandSource) {
|
||||
return this.resolveServer(commandContext, source, value);
|
||||
} else if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) {
|
||||
return this.resolveClient(commandContext, source, value);
|
||||
return this.resolveServer(commandContext, (ServerCommandSource) source, value);
|
||||
} else if (source instanceof FabricClientCommandSource) {
|
||||
return this.resolveClient(commandContext, (FabricClientCommandSource) source, value);
|
||||
} else {
|
||||
throw new IllegalStateException("Cannot have non-server command source when not on client");
|
||||
}
|
||||
|
|
@ -80,7 +79,7 @@ abstract class SidedArgumentParser<C, I, R> implements ArgumentParser<C, R> {
|
|||
*/
|
||||
protected abstract @NonNull ArgumentParseResult<@NonNull R> resolveClient(
|
||||
@NonNull CommandContext<@NonNull C> context,
|
||||
@NonNull CommandSource source,
|
||||
@NonNull FabricClientCommandSource source,
|
||||
@NonNull I value
|
||||
);
|
||||
|
||||
|
|
@ -95,7 +94,7 @@ abstract class SidedArgumentParser<C, I, R> implements ArgumentParser<C, R> {
|
|||
*/
|
||||
protected abstract @NonNull ArgumentParseResult<@NonNull R> resolveServer(
|
||||
@NonNull CommandContext<@NonNull C> context,
|
||||
@NonNull CommandSource source,
|
||||
@NonNull ServerCommandSource source,
|
||||
@NonNull I value
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -63,19 +63,19 @@ public final class StatusEffectArgument<C> extends CommandArgument<C, StatusEffe
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new builder.
|
||||
* Create a new {@link Builder}.
|
||||
*
|
||||
* @param name Name of the argument
|
||||
* @param <C> Command sender type
|
||||
* @return Created builder
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> StatusEffectArgument.@NonNull Builder<C> newBuilder(final @NonNull String name) {
|
||||
public static <C> @NonNull Builder<C> builder(final @NonNull String name) {
|
||||
return new StatusEffectArgument.Builder<>(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new required command argument.
|
||||
* Create a new required {@link StatusEffectArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -83,11 +83,11 @@ public final class StatusEffectArgument<C> extends CommandArgument<C, StatusEffe
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull StatusEffectArgument<C> of(final @NonNull String name) {
|
||||
return StatusEffectArgument.<C>newBuilder(name).asRequired().build();
|
||||
return StatusEffectArgument.<C>builder(name).asRequired().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument.
|
||||
* Create a new optional {@link StatusEffectArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -95,11 +95,11 @@ public final class StatusEffectArgument<C> extends CommandArgument<C, StatusEffe
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull StatusEffectArgument<C> optional(final @NonNull String name) {
|
||||
return StatusEffectArgument.<C>newBuilder(name).asOptional().build();
|
||||
return StatusEffectArgument.<C>builder(name).asOptional().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument with a default value.
|
||||
* Create a new optional {@link StatusEffectArgument} with the specified default value.
|
||||
*
|
||||
* @param name Argument name
|
||||
* @param defaultValue Default value
|
||||
|
|
@ -111,9 +111,7 @@ public final class StatusEffectArgument<C> extends CommandArgument<C, StatusEffe
|
|||
final @NonNull String name,
|
||||
final @NonNull StatusEffect defaultValue
|
||||
) {
|
||||
return StatusEffectArgument.<C>newBuilder(name)
|
||||
.asOptionalWithDefault(Registry.STATUS_EFFECT.getId(defaultValue).toString())
|
||||
.build();
|
||||
return StatusEffectArgument.<C>builder(name).asOptionalWithDefault(defaultValue).build();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -130,7 +128,7 @@ public final class StatusEffectArgument<C> extends CommandArgument<C, StatusEffe
|
|||
}
|
||||
|
||||
/**
|
||||
* Build a new status effect argument.
|
||||
* Build a new {@link StatusEffectArgument}.
|
||||
*
|
||||
* @return Constructed argument
|
||||
* @since 1.5.0
|
||||
|
|
@ -146,6 +144,18 @@ public final class StatusEffectArgument<C> extends CommandArgument<C, StatusEffe
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the command argument to be optional, with the specified default value.
|
||||
*
|
||||
* @param defaultValue default value
|
||||
* @return this builder
|
||||
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final @NonNull StatusEffect defaultValue) {
|
||||
return this.asOptionalWithDefault(Registry.STATUS_EFFECT.getId(defaultValue).toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,9 +32,7 @@ import cloud.commandframework.exceptions.parsing.NoInputProvidedException;
|
|||
import cloud.commandframework.exceptions.parsing.ParserException;
|
||||
import cloud.commandframework.fabric.FabricCaptionKeys;
|
||||
import cloud.commandframework.fabric.FabricCommandContextKeys;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.command.argument.EntityAnchorArgumentType;
|
||||
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
|
||||
import net.minecraft.scoreboard.Team;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
|
@ -46,7 +44,7 @@ import java.util.Queue;
|
|||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* An argument parsing an entity anchor.
|
||||
* An argument for parsing {@link Team Teams}.
|
||||
*
|
||||
* @param <C> the sender type
|
||||
* @since 1.5.0
|
||||
|
|
@ -72,19 +70,19 @@ public final class TeamArgument<C> extends CommandArgument<C, Team> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new builder.
|
||||
* Create a new {@link Builder}.
|
||||
*
|
||||
* @param name Name of the argument
|
||||
* @param <C> Command sender type
|
||||
* @return Created builder
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> TeamArgument.@NonNull Builder<C> newBuilder(final @NonNull String name) {
|
||||
return new TeamArgument.Builder<>(name);
|
||||
public static <C> @NonNull Builder<C> builder(final @NonNull String name) {
|
||||
return new Builder<>(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new required command argument.
|
||||
* Create a new required {@link TeamArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -92,11 +90,11 @@ public final class TeamArgument<C> extends CommandArgument<C, Team> {
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull TeamArgument<C> of(final @NonNull String name) {
|
||||
return TeamArgument.<C>newBuilder(name).asRequired().build();
|
||||
return TeamArgument.<C>builder(name).asRequired().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument.
|
||||
* Create a new optional {@link TeamArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -104,11 +102,11 @@ public final class TeamArgument<C> extends CommandArgument<C, Team> {
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull TeamArgument<C> optional(final @NonNull String name) {
|
||||
return TeamArgument.<C>newBuilder(name).asOptional().build();
|
||||
return TeamArgument.<C>builder(name).asOptional().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument with a default value.
|
||||
* Create a new optional {@link TeamArgument} with the specified default value.
|
||||
*
|
||||
* @param name Argument name
|
||||
* @param defaultValue Default value
|
||||
|
|
@ -118,13 +116,13 @@ public final class TeamArgument<C> extends CommandArgument<C, Team> {
|
|||
*/
|
||||
public static <C> @NonNull TeamArgument<C> optional(
|
||||
final @NonNull String name,
|
||||
final EntityAnchorArgumentType.@NonNull EntityAnchor defaultValue
|
||||
final @NonNull Team defaultValue
|
||||
) {
|
||||
return TeamArgument.<C>newBuilder(name).asOptionalWithDefault(defaultValue.name()).build();
|
||||
return TeamArgument.<C>builder(name).asOptionalWithDefault(defaultValue).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Argument parser for {@link Team}.
|
||||
* Argument parser for {@link Team Teams}.
|
||||
*
|
||||
* @param <C> sender type
|
||||
* @since 1.5.0
|
||||
|
|
@ -154,10 +152,10 @@ public final class TeamArgument<C> extends CommandArgument<C, Team> {
|
|||
@Override
|
||||
protected @NonNull ArgumentParseResult<Team> resolveClient(
|
||||
final @NonNull CommandContext<C> context,
|
||||
final @NonNull CommandSource source,
|
||||
final @NonNull FabricClientCommandSource source,
|
||||
final @NonNull String value
|
||||
) {
|
||||
final Team result = MinecraftClient.getInstance().getNetworkHandler().getWorld().getScoreboard().getTeam(value);
|
||||
final Team result = source.getClient().getNetworkHandler().getWorld().getScoreboard().getTeam(value);
|
||||
if (result == null) {
|
||||
return ArgumentParseResult.failure(new UnknownTeamException(context, value));
|
||||
}
|
||||
|
|
@ -167,10 +165,10 @@ public final class TeamArgument<C> extends CommandArgument<C, Team> {
|
|||
@Override
|
||||
protected @NonNull ArgumentParseResult<Team> resolveServer(
|
||||
final @NonNull CommandContext<C> context,
|
||||
final @NonNull CommandSource source,
|
||||
final @NonNull ServerCommandSource source,
|
||||
final @NonNull String value
|
||||
) {
|
||||
final Team result = ((ServerCommandSource) source).getWorld().getScoreboard().getTeam(value);
|
||||
final Team result = source.getWorld().getScoreboard().getTeam(value);
|
||||
if (result == null) {
|
||||
return ArgumentParseResult.failure(new UnknownTeamException(context, value));
|
||||
}
|
||||
|
|
@ -192,7 +190,7 @@ public final class TeamArgument<C> extends CommandArgument<C, Team> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Build a new team argument.
|
||||
* Build a new {@link TeamArgument}.
|
||||
*
|
||||
* @return Constructed argument
|
||||
* @since 1.5.0
|
||||
|
|
@ -208,6 +206,18 @@ public final class TeamArgument<C> extends CommandArgument<C, Team> {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the command argument to be optional, with the specified default value.
|
||||
*
|
||||
* @param defaultValue default value
|
||||
* @return this builder
|
||||
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final @NonNull Team defaultValue) {
|
||||
return this.asOptionalWithDefault(defaultValue.getName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -60,19 +60,19 @@ public final class TimeArgument<C> extends CommandArgument<C, MinecraftTime> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new builder.
|
||||
* Create a new {@link Builder}.
|
||||
*
|
||||
* @param name Name of the argument
|
||||
* @param <C> Command sender type
|
||||
* @return Created builder
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> TimeArgument.@NonNull Builder<C> newBuilder(final @NonNull String name) {
|
||||
return new TimeArgument.Builder<>(name);
|
||||
public static <C> @NonNull Builder<C> builder(final @NonNull String name) {
|
||||
return new Builder<>(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new required command argument.
|
||||
* Create a new required {@link TimeArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -80,11 +80,11 @@ public final class TimeArgument<C> extends CommandArgument<C, MinecraftTime> {
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull TimeArgument<C> of(final @NonNull String name) {
|
||||
return TimeArgument.<C>newBuilder(name).asRequired().build();
|
||||
return TimeArgument.<C>builder(name).asRequired().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument.
|
||||
* Create a new optional {@link TimeArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -92,11 +92,11 @@ public final class TimeArgument<C> extends CommandArgument<C, MinecraftTime> {
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull TimeArgument<C> optional(final @NonNull String name) {
|
||||
return TimeArgument.<C>newBuilder(name).asOptional().build();
|
||||
return TimeArgument.<C>builder(name).asOptional().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument with a default value.
|
||||
* Create a new optional {@link TimeArgument} with the specified default value.
|
||||
*
|
||||
* @param name Argument name
|
||||
* @param defaultTime Default time, in ticks
|
||||
|
|
@ -108,7 +108,7 @@ public final class TimeArgument<C> extends CommandArgument<C, MinecraftTime> {
|
|||
final @NonNull String name,
|
||||
final @NonNull MinecraftTime defaultTime
|
||||
) {
|
||||
return TimeArgument.<C>newBuilder(name).asOptionalWithDefault(defaultTime.toString()).build();
|
||||
return TimeArgument.<C>builder(name).asOptionalWithDefault(defaultTime).build();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -125,7 +125,7 @@ public final class TimeArgument<C> extends CommandArgument<C, MinecraftTime> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Build a new time argument.
|
||||
* Build a new {@link TimeArgument}.
|
||||
*
|
||||
* @return Constructed argument
|
||||
* @since 1.5.0
|
||||
|
|
@ -141,6 +141,18 @@ public final class TimeArgument<C> extends CommandArgument<C, MinecraftTime> {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the command argument to be optional, with the specified default value.
|
||||
*
|
||||
* @param defaultValue default value
|
||||
* @return this builder
|
||||
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final @NonNull MinecraftTime defaultValue) {
|
||||
return this.asOptionalWithDefault(defaultValue.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ import java.util.List;
|
|||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* An argument for resolving block coordinates.
|
||||
* An argument for resolving {@link BlockCoordinates}.
|
||||
*
|
||||
* @param <C> the sender type
|
||||
* @since 1.5.0
|
||||
|
|
@ -62,19 +62,19 @@ public final class BlockPosArgument<C> extends CommandArgument<C, BlockCoordinat
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new builder.
|
||||
* Create a new {@link Builder}.
|
||||
*
|
||||
* @param name Name of the argument
|
||||
* @param <C> Command sender type
|
||||
* @return Created builder
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> BlockPosArgument.@NonNull Builder<C> newBuilder(final @NonNull String name) {
|
||||
public static <C> BlockPosArgument.@NonNull Builder<C> builder(final @NonNull String name) {
|
||||
return new BlockPosArgument.Builder<>(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new required command argument.
|
||||
* Create a new required {@link BlockPosArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -82,11 +82,11 @@ public final class BlockPosArgument<C> extends CommandArgument<C, BlockCoordinat
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull BlockPosArgument<C> of(final @NonNull String name) {
|
||||
return BlockPosArgument.<C>newBuilder(name).asRequired().build();
|
||||
return BlockPosArgument.<C>builder(name).asRequired().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument
|
||||
* Create a new optional {@link BlockPosArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -94,11 +94,11 @@ public final class BlockPosArgument<C> extends CommandArgument<C, BlockCoordinat
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull BlockPosArgument<C> optional(final @NonNull String name) {
|
||||
return BlockPosArgument.<C>newBuilder(name).asOptional().build();
|
||||
return BlockPosArgument.<C>builder(name).asOptional().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument
|
||||
* Create a new optional {@link BlockPosArgument} with the specified default value.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param defaultValue default value
|
||||
|
|
@ -107,20 +107,11 @@ public final class BlockPosArgument<C> extends CommandArgument<C, BlockCoordinat
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull BlockPosArgument<C> optional(final @NonNull String name, final @NonNull BlockPos defaultValue) {
|
||||
return BlockPosArgument.<C>newBuilder(name)
|
||||
.asOptionalWithDefault(serializeBlockPos(defaultValue))
|
||||
return BlockPosArgument.<C>builder(name)
|
||||
.asOptionalWithDefault(defaultValue)
|
||||
.build();
|
||||
}
|
||||
|
||||
private static @NonNull String serializeBlockPos(final @NonNull BlockPos pos) {
|
||||
return String.format(
|
||||
"%s %s %s",
|
||||
pos.getX(),
|
||||
pos.getY(),
|
||||
pos.getZ()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builder for {@link BlockPosArgument}.
|
||||
*
|
||||
|
|
@ -134,7 +125,7 @@ public final class BlockPosArgument<C> extends CommandArgument<C, BlockCoordinat
|
|||
}
|
||||
|
||||
/**
|
||||
* Build a block position argument.
|
||||
* Build a new {@link BlockPosArgument}.
|
||||
*
|
||||
* @return Constructed argument
|
||||
* @since 1.5.0
|
||||
|
|
@ -150,6 +141,23 @@ public final class BlockPosArgument<C> extends CommandArgument<C, BlockCoordinat
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the command argument to be optional, with the specified default value.
|
||||
*
|
||||
* @param defaultValue default value
|
||||
* @return this builder
|
||||
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final @NonNull BlockPos defaultValue) {
|
||||
return this.asOptionalWithDefault(String.format(
|
||||
"%s %s %s",
|
||||
defaultValue.getX(),
|
||||
defaultValue.getY(),
|
||||
defaultValue.getZ()
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ import java.util.List;
|
|||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* An argument for resolving column (xz) coordinates.
|
||||
* An argument for resolving {@link ColumnCoordinates column (xz) coordinates}.
|
||||
*
|
||||
* @param <C> the sender type
|
||||
* @since 1.5.0
|
||||
|
|
@ -62,19 +62,19 @@ public final class ColumnPosArgument<C> extends CommandArgument<C, ColumnCoordin
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new builder.
|
||||
* Create a new {@link Builder}.
|
||||
*
|
||||
* @param name Name of the argument
|
||||
* @param <C> Command sender type
|
||||
* @return Created builder
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> ColumnPosArgument.@NonNull Builder<C> newBuilder(final @NonNull String name) {
|
||||
public static <C> ColumnPosArgument.@NonNull Builder<C> builder(final @NonNull String name) {
|
||||
return new ColumnPosArgument.Builder<>(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new required command argument.
|
||||
* Create a new required {@link ColumnPosArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -82,11 +82,11 @@ public final class ColumnPosArgument<C> extends CommandArgument<C, ColumnCoordin
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull ColumnPosArgument<C> of(final @NonNull String name) {
|
||||
return ColumnPosArgument.<C>newBuilder(name).asRequired().build();
|
||||
return ColumnPosArgument.<C>builder(name).asRequired().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument
|
||||
* Create a new optional {@link ColumnPosArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -94,11 +94,11 @@ public final class ColumnPosArgument<C> extends CommandArgument<C, ColumnCoordin
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull ColumnPosArgument<C> optional(final @NonNull String name) {
|
||||
return ColumnPosArgument.<C>newBuilder(name).asOptional().build();
|
||||
return ColumnPosArgument.<C>builder(name).asOptional().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument
|
||||
* Create a new optional {@link ColumnPosArgument} with the specified default value.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param defaultValue default value, y coordinate will be ignored as it is always 0
|
||||
|
|
@ -107,19 +107,11 @@ public final class ColumnPosArgument<C> extends CommandArgument<C, ColumnCoordin
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull ColumnPosArgument<C> optional(final @NonNull String name, final @NonNull BlockPos defaultValue) {
|
||||
return ColumnPosArgument.<C>newBuilder(name)
|
||||
.asOptionalWithDefault(serializeColumnPos(defaultValue))
|
||||
return ColumnPosArgument.<C>builder(name)
|
||||
.asOptionalWithDefault(defaultValue)
|
||||
.build();
|
||||
}
|
||||
|
||||
private static @NonNull String serializeColumnPos(final @NonNull BlockPos pos) {
|
||||
return String.format(
|
||||
"%s %s",
|
||||
pos.getX(),
|
||||
pos.getZ()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builder for {@link ColumnPosArgument}.
|
||||
*
|
||||
|
|
@ -133,7 +125,7 @@ public final class ColumnPosArgument<C> extends CommandArgument<C, ColumnCoordin
|
|||
}
|
||||
|
||||
/**
|
||||
* Build a column position argument.
|
||||
* Build a new {@link ColumnPosArgument}.
|
||||
*
|
||||
* @return Constructed argument
|
||||
* @since 1.5.0
|
||||
|
|
@ -149,6 +141,22 @@ public final class ColumnPosArgument<C> extends CommandArgument<C, ColumnCoordin
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the command argument to be optional, with the specified default value.
|
||||
*
|
||||
* @param defaultValue default value
|
||||
* @return this builder
|
||||
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final @NonNull BlockPos defaultValue) {
|
||||
return this.asOptionalWithDefault(String.format(
|
||||
"%s %s",
|
||||
defaultValue.getX(),
|
||||
defaultValue.getZ()
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,19 +61,19 @@ public final class MessageArgument<C> extends CommandArgument<C, Message> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new builder.
|
||||
* Create a new {@link Builder}.
|
||||
*
|
||||
* @param name Name of the argument
|
||||
* @param <C> Command sender type
|
||||
* @return Created builder
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> MessageArgument.@NonNull Builder<C> newBuilder(final @NonNull String name) {
|
||||
public static <C> MessageArgument.@NonNull Builder<C> builder(final @NonNull String name) {
|
||||
return new MessageArgument.Builder<>(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new required command argument.
|
||||
* Create a new required {@link MessageArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -81,11 +81,11 @@ public final class MessageArgument<C> extends CommandArgument<C, Message> {
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull MessageArgument<C> of(final @NonNull String name) {
|
||||
return MessageArgument.<C>newBuilder(name).asRequired().build();
|
||||
return MessageArgument.<C>builder(name).asRequired().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument
|
||||
* Create a new optional {@link MessageArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -93,11 +93,11 @@ public final class MessageArgument<C> extends CommandArgument<C, Message> {
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull MessageArgument<C> optional(final @NonNull String name) {
|
||||
return MessageArgument.<C>newBuilder(name).asOptional().build();
|
||||
return MessageArgument.<C>builder(name).asOptional().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument with a default value
|
||||
* Create a new optional {@link MessageArgument} with the specified value.
|
||||
*
|
||||
* @param name Argument name
|
||||
* @param defaultValue Default value
|
||||
|
|
@ -109,7 +109,7 @@ public final class MessageArgument<C> extends CommandArgument<C, Message> {
|
|||
final @NonNull String name,
|
||||
final @NonNull String defaultValue
|
||||
) {
|
||||
return MessageArgument.<C>newBuilder(name).asOptionalWithDefault(defaultValue).build();
|
||||
return MessageArgument.<C>builder(name).asOptionalWithDefault(defaultValue).build();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -126,7 +126,7 @@ public final class MessageArgument<C> extends CommandArgument<C, Message> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Build a new message argument.
|
||||
* Build a new {@link MessageArgument}.
|
||||
*
|
||||
* @return Constructed argument
|
||||
* @since 1.5.0
|
||||
|
|
|
|||
|
|
@ -35,7 +35,8 @@ import java.util.List;
|
|||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* An argument for selecting multiple entities
|
||||
* An argument for selecting multiple {@link net.minecraft.entity.Entity entities} using an
|
||||
* {@link net.minecraft.command.EntitySelector}.
|
||||
*
|
||||
* @param <C> the sender type
|
||||
* @since 1.5.0
|
||||
|
|
@ -61,19 +62,19 @@ public final class MultipleEntitySelectorArgument<C> extends CommandArgument<C,
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new builder.
|
||||
* Create a new {@link Builder}.
|
||||
*
|
||||
* @param name Name of the argument
|
||||
* @param <C> Command sender type
|
||||
* @return Created builder
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> MultipleEntitySelectorArgument.@NonNull Builder<C> newBuilder(final @NonNull String name) {
|
||||
return new MultipleEntitySelectorArgument.Builder<>(name);
|
||||
public static <C> @NonNull Builder<C> builder(final @NonNull String name) {
|
||||
return new Builder<>(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new required command argument.
|
||||
* Create a new required {@link MultipleEntitySelectorArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -81,11 +82,11 @@ public final class MultipleEntitySelectorArgument<C> extends CommandArgument<C,
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull MultipleEntitySelectorArgument<C> of(final @NonNull String name) {
|
||||
return MultipleEntitySelectorArgument.<C>newBuilder(name).asRequired().build();
|
||||
return MultipleEntitySelectorArgument.<C>builder(name).asRequired().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument
|
||||
* Create a new optional {@link MultipleEntitySelectorArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -93,7 +94,7 @@ public final class MultipleEntitySelectorArgument<C> extends CommandArgument<C,
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull MultipleEntitySelectorArgument<C> optional(final @NonNull String name) {
|
||||
return MultipleEntitySelectorArgument.<C>newBuilder(name).asOptional().build();
|
||||
return MultipleEntitySelectorArgument.<C>builder(name).asOptional().build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -109,7 +110,7 @@ public final class MultipleEntitySelectorArgument<C> extends CommandArgument<C,
|
|||
}
|
||||
|
||||
/**
|
||||
* Build a multiple entity selector argument.
|
||||
* Build a new {@link MultipleEntitySelectorArgument}.
|
||||
*
|
||||
* @return Constructed argument
|
||||
* @since 1.5.0
|
||||
|
|
|
|||
|
|
@ -35,7 +35,8 @@ import java.util.List;
|
|||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* An argument for selecting multiple players
|
||||
* An argument for selecting multiple {@link net.minecraft.server.network.ServerPlayerEntity players} using an
|
||||
* {@link net.minecraft.command.EntitySelector}.
|
||||
*
|
||||
* @param <C> the sender type
|
||||
* @since 1.5.0
|
||||
|
|
@ -61,19 +62,19 @@ public final class MultiplePlayerSelectorArgument<C> extends CommandArgument<C,
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new builder.
|
||||
* Create a new {@link Builder}.
|
||||
*
|
||||
* @param name Name of the argument
|
||||
* @param <C> Command sender type
|
||||
* @return Created builder
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> MultiplePlayerSelectorArgument.@NonNull Builder<C> newBuilder(final @NonNull String name) {
|
||||
return new MultiplePlayerSelectorArgument.Builder<>(name);
|
||||
public static <C> @NonNull Builder<C> builder(final @NonNull String name) {
|
||||
return new Builder<>(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new required command argument.
|
||||
* Create a new required {@link MultiplePlayerSelectorArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -81,11 +82,11 @@ public final class MultiplePlayerSelectorArgument<C> extends CommandArgument<C,
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull MultiplePlayerSelectorArgument<C> of(final @NonNull String name) {
|
||||
return MultiplePlayerSelectorArgument.<C>newBuilder(name).asRequired().build();
|
||||
return MultiplePlayerSelectorArgument.<C>builder(name).asRequired().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument.
|
||||
* Create a new optional {@link MultiplePlayerSelectorArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -93,7 +94,7 @@ public final class MultiplePlayerSelectorArgument<C> extends CommandArgument<C,
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull MultiplePlayerSelectorArgument<C> optional(final @NonNull String name) {
|
||||
return MultiplePlayerSelectorArgument.<C>newBuilder(name).asOptional().build();
|
||||
return MultiplePlayerSelectorArgument.<C>builder(name).asOptional().build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -109,7 +110,7 @@ public final class MultiplePlayerSelectorArgument<C> extends CommandArgument<C,
|
|||
}
|
||||
|
||||
/**
|
||||
* Build a multiple player selector argument.
|
||||
* Build a new {@link MultiplePlayerSelectorArgument}.
|
||||
*
|
||||
* @return Constructed argument
|
||||
* @since 1.5.0
|
||||
|
|
|
|||
|
|
@ -35,7 +35,8 @@ import java.util.List;
|
|||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* An argument for selecting a single entity
|
||||
* An argument for selecting a single {@link net.minecraft.entity.Entity entity} using an
|
||||
* {@link net.minecraft.command.EntitySelector}.
|
||||
*
|
||||
* @param <C> the sender type
|
||||
* @since 1.5.0
|
||||
|
|
@ -61,19 +62,19 @@ public final class SingleEntitySelectorArgument<C> extends CommandArgument<C, Si
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new builder.
|
||||
* Create a new {@link Builder}.
|
||||
*
|
||||
* @param name Name of the argument
|
||||
* @param <C> Command sender type
|
||||
* @return Created builder
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> SingleEntitySelectorArgument.@NonNull Builder<C> newBuilder(final @NonNull String name) {
|
||||
public static <C> SingleEntitySelectorArgument.@NonNull Builder<C> builder(final @NonNull String name) {
|
||||
return new SingleEntitySelectorArgument.Builder<>(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new required command argument.
|
||||
* Create a new required {@link SingleEntitySelectorArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -81,11 +82,11 @@ public final class SingleEntitySelectorArgument<C> extends CommandArgument<C, Si
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull SingleEntitySelectorArgument<C> of(final @NonNull String name) {
|
||||
return SingleEntitySelectorArgument.<C>newBuilder(name).asRequired().build();
|
||||
return SingleEntitySelectorArgument.<C>builder(name).asRequired().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument.
|
||||
* Create a new optional {@link SingleEntitySelectorArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -93,7 +94,7 @@ public final class SingleEntitySelectorArgument<C> extends CommandArgument<C, Si
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull SingleEntitySelectorArgument<C> optional(final @NonNull String name) {
|
||||
return SingleEntitySelectorArgument.<C>newBuilder(name).asOptional().build();
|
||||
return SingleEntitySelectorArgument.<C>builder(name).asOptional().build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -109,7 +110,7 @@ public final class SingleEntitySelectorArgument<C> extends CommandArgument<C, Si
|
|||
}
|
||||
|
||||
/**
|
||||
* Build a single entity selector argument.
|
||||
* Build a new {@link SingleEntitySelectorArgument}.
|
||||
*
|
||||
* @return Constructed argument
|
||||
* @since 1.5.0
|
||||
|
|
|
|||
|
|
@ -35,7 +35,8 @@ import java.util.List;
|
|||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* An argument for selecting a single player
|
||||
* An argument for selecting a single {@link net.minecraft.server.network.ServerPlayerEntity player} using an
|
||||
* {@link net.minecraft.command.EntitySelector}.
|
||||
*
|
||||
* @param <C> the sender type
|
||||
* @since 1.5.0
|
||||
|
|
@ -61,19 +62,19 @@ public final class SinglePlayerSelectorArgument<C> extends CommandArgument<C, Si
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new builder.
|
||||
* Create a new {@link Builder}.
|
||||
*
|
||||
* @param name Name of the argument
|
||||
* @param <C> Command sender type
|
||||
* @return Created builder
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> SinglePlayerSelectorArgument.@NonNull Builder<C> newBuilder(final @NonNull String name) {
|
||||
return new SinglePlayerSelectorArgument.Builder<>(name);
|
||||
public static <C> @NonNull Builder<C> builder(final @NonNull String name) {
|
||||
return new Builder<>(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new required command argument.
|
||||
* Create a new required {@link SinglePlayerSelectorArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -81,11 +82,11 @@ public final class SinglePlayerSelectorArgument<C> extends CommandArgument<C, Si
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull SinglePlayerSelectorArgument<C> of(final @NonNull String name) {
|
||||
return SinglePlayerSelectorArgument.<C>newBuilder(name).asRequired().build();
|
||||
return SinglePlayerSelectorArgument.<C>builder(name).asRequired().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument.
|
||||
* Create a new optional {@link SinglePlayerSelectorArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -93,7 +94,7 @@ public final class SinglePlayerSelectorArgument<C> extends CommandArgument<C, Si
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull SinglePlayerSelectorArgument<C> optional(final @NonNull String name) {
|
||||
return SinglePlayerSelectorArgument.<C>newBuilder(name).asOptional().build();
|
||||
return SinglePlayerSelectorArgument.<C>builder(name).asOptional().build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -109,7 +110,7 @@ public final class SinglePlayerSelectorArgument<C> extends CommandArgument<C, Si
|
|||
}
|
||||
|
||||
/**
|
||||
* Build a single player selector argument.
|
||||
* Build a new {@link SinglePlayerSelectorArgument}.
|
||||
*
|
||||
* @return Constructed argument
|
||||
* @since 1.5.0
|
||||
|
|
|
|||
|
|
@ -36,16 +36,16 @@ import java.util.List;
|
|||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* An argument for resolving x and z coordinates from 2 doubles.
|
||||
* An argument for resolving {@link cloud.commandframework.fabric.data.Coordinates.CoordinatesXZ} from 2 doubles.
|
||||
*
|
||||
* @param <C> the sender type
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public final class Vec2Argument<C> extends CommandArgument<C, Coordinates.CoordinatesXZ> {
|
||||
public final class Vec2dArgument<C> extends CommandArgument<C, Coordinates.CoordinatesXZ> {
|
||||
|
||||
private final boolean centerIntegers;
|
||||
|
||||
Vec2Argument(
|
||||
Vec2dArgument(
|
||||
final boolean required,
|
||||
final @NonNull String name,
|
||||
final @NonNull String defaultValue,
|
||||
|
|
@ -76,31 +76,31 @@ public final class Vec2Argument<C> extends CommandArgument<C, Coordinates.Coordi
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new builder.
|
||||
* Create a new {@link Builder}.
|
||||
*
|
||||
* @param name Name of the argument
|
||||
* @param <C> Command sender type
|
||||
* @return Created builder
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> Vec2Argument.@NonNull Builder<C> newBuilder(final @NonNull String name) {
|
||||
return new Vec2Argument.Builder<>(name);
|
||||
public static <C> @NonNull Builder<C> builder(final @NonNull String name) {
|
||||
return new Builder<>(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new required command argument.
|
||||
* Create a new required {@link Vec2dArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
* @return Created argument
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull Vec2Argument<C> of(final @NonNull String name) {
|
||||
return Vec2Argument.<C>newBuilder(name).asRequired().build();
|
||||
public static <C> @NonNull Vec2dArgument<C> of(final @NonNull String name) {
|
||||
return Vec2dArgument.<C>builder(name).asRequired().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new required command argument.
|
||||
* Create a new required {@link Vec2dArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param centerIntegers whether to center integers to x.5.
|
||||
|
|
@ -108,24 +108,24 @@ public final class Vec2Argument<C> extends CommandArgument<C, Coordinates.Coordi
|
|||
* @return Created argument
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull Vec2Argument<C> of(final @NonNull String name, final boolean centerIntegers) {
|
||||
return Vec2Argument.<C>newBuilder(name).centerIntegers(centerIntegers).asRequired().build();
|
||||
public static <C> @NonNull Vec2dArgument<C> of(final @NonNull String name, final boolean centerIntegers) {
|
||||
return Vec2dArgument.<C>builder(name).centerIntegers(centerIntegers).asRequired().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument
|
||||
* Create a new optional {@link Vec2dArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
* @return Created argument
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull Vec2Argument<C> optional(final @NonNull String name) {
|
||||
return Vec2Argument.<C>newBuilder(name).asOptional().build();
|
||||
public static <C> @NonNull Vec2dArgument<C> optional(final @NonNull String name) {
|
||||
return Vec2dArgument.<C>builder(name).asOptional().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument
|
||||
* Create a new optional {@link Vec2dArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param centerIntegers whether to center integers to x.5.
|
||||
|
|
@ -133,12 +133,12 @@ public final class Vec2Argument<C> extends CommandArgument<C, Coordinates.Coordi
|
|||
* @return Created argument
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull Vec2Argument<C> optional(final @NonNull String name, final boolean centerIntegers) {
|
||||
return Vec2Argument.<C>newBuilder(name).centerIntegers(centerIntegers).asOptional().build();
|
||||
public static <C> @NonNull Vec2dArgument<C> optional(final @NonNull String name, final boolean centerIntegers) {
|
||||
return Vec2dArgument.<C>builder(name).centerIntegers(centerIntegers).asOptional().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument
|
||||
* Create a new optional {@link Vec2dArgument} with the specified default value.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param defaultValue default value, y will be ignored as it is always 0
|
||||
|
|
@ -146,14 +146,12 @@ public final class Vec2Argument<C> extends CommandArgument<C, Coordinates.Coordi
|
|||
* @return Created argument
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull Vec2Argument<C> optional(final @NonNull String name, final @NonNull Vec3d defaultValue) {
|
||||
return Vec2Argument.<C>newBuilder(name)
|
||||
.asOptionalWithDefault(serializeXandZ(defaultValue))
|
||||
.build();
|
||||
public static <C> @NonNull Vec2dArgument<C> optional(final @NonNull String name, final @NonNull Vec3d defaultValue) {
|
||||
return Vec2dArgument.<C>builder(name).asOptionalWithDefault(defaultValue).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument
|
||||
* Create a new optional {@link Vec2dArgument} with the specified default value.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param defaultValue default value, y will be ignored as it is always 0
|
||||
|
|
@ -162,27 +160,16 @@ public final class Vec2Argument<C> extends CommandArgument<C, Coordinates.Coordi
|
|||
* @return Created argument
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull Vec2Argument<C> optional(
|
||||
public static <C> @NonNull Vec2dArgument<C> optional(
|
||||
final @NonNull String name,
|
||||
final boolean centerIntegers,
|
||||
final @NonNull Vec3d defaultValue
|
||||
) {
|
||||
return Vec2Argument.<C>newBuilder(name)
|
||||
.centerIntegers(centerIntegers)
|
||||
.asOptionalWithDefault(serializeXandZ(defaultValue))
|
||||
.build();
|
||||
}
|
||||
|
||||
private static @NonNull String serializeXandZ(final @NonNull Vec3d vec3d) {
|
||||
return String.format(
|
||||
"%.10f %.10f",
|
||||
vec3d.x,
|
||||
vec3d.z
|
||||
);
|
||||
return Vec2dArgument.<C>builder(name).centerIntegers(centerIntegers).asOptionalWithDefault(defaultValue).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Builder for {@link Vec2Argument}.
|
||||
* Builder for {@link Vec2dArgument}.
|
||||
*
|
||||
* @param <C> sender type
|
||||
* @since 1.5.0
|
||||
|
|
@ -218,14 +205,30 @@ public final class Vec2Argument<C> extends CommandArgument<C, Coordinates.Coordi
|
|||
}
|
||||
|
||||
/**
|
||||
* Build a vec2 argument.
|
||||
* Sets the command argument to be optional, with the specified default value.
|
||||
*
|
||||
* @param defaultValue default value, y will be ignored as it is always 0
|
||||
* @return this builder
|
||||
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final @NonNull Vec3d defaultValue) {
|
||||
return this.asOptionalWithDefault(String.format(
|
||||
"%.10f %.10f",
|
||||
defaultValue.x,
|
||||
defaultValue.z
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a new {@link Vec2dArgument}.
|
||||
*
|
||||
* @return Constructed argument
|
||||
* @since 1.5.0
|
||||
*/
|
||||
@Override
|
||||
public @NonNull Vec2Argument<C> build() {
|
||||
return new Vec2Argument<>(
|
||||
public @NonNull Vec2dArgument<C> build() {
|
||||
return new Vec2dArgument<>(
|
||||
this.isRequired(),
|
||||
this.getName(),
|
||||
this.getDefaultValue(),
|
||||
|
|
@ -36,16 +36,16 @@ import java.util.List;
|
|||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* An argument for resolving coordinates from 3 doubles.
|
||||
* An argument for resolving {@link Coordinates} from 3 doubles.
|
||||
*
|
||||
* @param <C> the sender type
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public final class Vec3Argument<C> extends CommandArgument<C, Coordinates> {
|
||||
public final class Vec3dArgument<C> extends CommandArgument<C, Coordinates> {
|
||||
|
||||
private final boolean centerIntegers;
|
||||
|
||||
Vec3Argument(
|
||||
Vec3dArgument(
|
||||
final boolean required,
|
||||
final @NonNull String name,
|
||||
final @NonNull String defaultValue,
|
||||
|
|
@ -76,31 +76,31 @@ public final class Vec3Argument<C> extends CommandArgument<C, Coordinates> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new builder.
|
||||
* Create a new {@link Builder}.
|
||||
*
|
||||
* @param name Name of the argument
|
||||
* @param <C> Command sender type
|
||||
* @return Created builder
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> Vec3Argument.@NonNull Builder<C> newBuilder(final @NonNull String name) {
|
||||
return new Vec3Argument.Builder<>(name);
|
||||
public static <C> @NonNull Builder<C> builder(final @NonNull String name) {
|
||||
return new Builder<>(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new required command argument.
|
||||
* Create a new required {@link Vec3dArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
* @return Created argument
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull Vec3Argument<C> of(final @NonNull String name) {
|
||||
return Vec3Argument.<C>newBuilder(name).asRequired().build();
|
||||
public static <C> @NonNull Vec3dArgument<C> of(final @NonNull String name) {
|
||||
return Vec3dArgument.<C>builder(name).asRequired().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new required command argument.
|
||||
* Create a new required {@link Vec3dArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param centerIntegers whether to center integers to x.5.
|
||||
|
|
@ -108,24 +108,24 @@ public final class Vec3Argument<C> extends CommandArgument<C, Coordinates> {
|
|||
* @return Created argument
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull Vec3Argument<C> of(final @NonNull String name, final boolean centerIntegers) {
|
||||
return Vec3Argument.<C>newBuilder(name).centerIntegers(centerIntegers).asRequired().build();
|
||||
public static <C> @NonNull Vec3dArgument<C> of(final @NonNull String name, final boolean centerIntegers) {
|
||||
return Vec3dArgument.<C>builder(name).centerIntegers(centerIntegers).asRequired().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument
|
||||
* Create a new optional {@link Vec3dArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
* @return Created argument
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull Vec3Argument<C> optional(final @NonNull String name) {
|
||||
return Vec3Argument.<C>newBuilder(name).asOptional().build();
|
||||
public static <C> @NonNull Vec3dArgument<C> optional(final @NonNull String name) {
|
||||
return Vec3dArgument.<C>builder(name).asOptional().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument
|
||||
* Create a new optional {@link Vec3dArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param centerIntegers whether to center integers to x.5.
|
||||
|
|
@ -133,12 +133,12 @@ public final class Vec3Argument<C> extends CommandArgument<C, Coordinates> {
|
|||
* @return Created argument
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull Vec3Argument<C> optional(final @NonNull String name, final boolean centerIntegers) {
|
||||
return Vec3Argument.<C>newBuilder(name).centerIntegers(centerIntegers).asOptional().build();
|
||||
public static <C> @NonNull Vec3dArgument<C> optional(final @NonNull String name, final boolean centerIntegers) {
|
||||
return Vec3dArgument.<C>builder(name).centerIntegers(centerIntegers).asOptional().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument
|
||||
* Create a new optional {@link Vec3dArgument} with the specified default value.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param defaultValue default value
|
||||
|
|
@ -146,14 +146,12 @@ public final class Vec3Argument<C> extends CommandArgument<C, Coordinates> {
|
|||
* @return Created argument
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull Vec3Argument<C> optional(final @NonNull String name, final @NonNull Vec3d defaultValue) {
|
||||
return Vec3Argument.<C>newBuilder(name)
|
||||
.asOptionalWithDefault(serializeVec3(defaultValue))
|
||||
.build();
|
||||
public static <C> @NonNull Vec3dArgument<C> optional(final @NonNull String name, final @NonNull Vec3d defaultValue) {
|
||||
return Vec3dArgument.<C>builder(name).asOptionalWithDefault(defaultValue).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional command argument
|
||||
* Create a new optional {@link Vec3dArgument} with the specified default value.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param defaultValue default value
|
||||
|
|
@ -162,28 +160,16 @@ public final class Vec3Argument<C> extends CommandArgument<C, Coordinates> {
|
|||
* @return Created argument
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull Vec3Argument<C> optional(
|
||||
public static <C> @NonNull Vec3dArgument<C> optional(
|
||||
final @NonNull String name,
|
||||
final boolean centerIntegers,
|
||||
final @NonNull Vec3d defaultValue
|
||||
) {
|
||||
return Vec3Argument.<C>newBuilder(name)
|
||||
.centerIntegers(centerIntegers)
|
||||
.asOptionalWithDefault(serializeVec3(defaultValue))
|
||||
.build();
|
||||
}
|
||||
|
||||
private static @NonNull String serializeVec3(final @NonNull Vec3d vec3d) {
|
||||
return String.format(
|
||||
"%.10f %.10f %.10f",
|
||||
vec3d.x,
|
||||
vec3d.y,
|
||||
vec3d.z
|
||||
);
|
||||
return Vec3dArgument.<C>builder(name).centerIntegers(centerIntegers).asOptionalWithDefault(defaultValue).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Builder for {@link Vec3Argument}.
|
||||
* Builder for {@link Vec3dArgument}.
|
||||
*
|
||||
* @param <C> sender type
|
||||
* @since 1.5.0
|
||||
|
|
@ -219,14 +205,31 @@ public final class Vec3Argument<C> extends CommandArgument<C, Coordinates> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Build a vec3 argument.
|
||||
* Sets the command argument to be optional, with the specified default value.
|
||||
*
|
||||
* @param defaultValue default value
|
||||
* @return this builder
|
||||
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final @NonNull Vec3d defaultValue) {
|
||||
return this.asOptionalWithDefault(String.format(
|
||||
"%.10f %.10f %.10f",
|
||||
defaultValue.x,
|
||||
defaultValue.y,
|
||||
defaultValue.z
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a new {@link Vec3dArgument}.
|
||||
*
|
||||
* @return Constructed argument
|
||||
* @since 1.5.0
|
||||
*/
|
||||
@Override
|
||||
public @NonNull Vec3Argument<C> build() {
|
||||
return new Vec3Argument<>(
|
||||
public @NonNull Vec3dArgument<C> build() {
|
||||
return new Vec3dArgument<>(
|
||||
this.isRequired(),
|
||||
this.getName(),
|
||||
this.getDefaultValue(),
|
||||
|
|
@ -84,7 +84,7 @@ public interface Coordinates {
|
|||
* @return the base coordinates
|
||||
* @since 1.5.0
|
||||
*/
|
||||
@NonNull PosArgument getWrappedCoordinates();
|
||||
@NonNull PosArgument wrappedCoordinates();
|
||||
|
||||
/**
|
||||
* A specialized version of {@link Coordinates} for representing the result of the vanilla {@link Vec2ArgumentType},
|
||||
|
|
|
|||
|
|
@ -44,15 +44,15 @@ public interface Selector<V> {
|
|||
* @return the input
|
||||
* @since 1.5.0
|
||||
*/
|
||||
@NonNull String getInput();
|
||||
@NonNull String inputString();
|
||||
|
||||
/**
|
||||
* If this value came from a parsed selector, this will provide the details of that selector.
|
||||
* If this value came from a parsed {@link EntitySelector}, this will provide the details of that selector.
|
||||
*
|
||||
* @return the selector
|
||||
* @since 1.5.0
|
||||
*/
|
||||
@Nullable EntitySelector getSelector();
|
||||
@Nullable EntitySelector selector();
|
||||
|
||||
/**
|
||||
* Resolve the value of this selector.
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ import cloud.commandframework.fabric.argument.ItemDataArgument;
|
|||
import cloud.commandframework.fabric.argument.server.ColumnPosArgument;
|
||||
import cloud.commandframework.fabric.argument.server.MultipleEntitySelectorArgument;
|
||||
import cloud.commandframework.fabric.argument.server.MultiplePlayerSelectorArgument;
|
||||
import cloud.commandframework.fabric.argument.server.Vec3Argument;
|
||||
import cloud.commandframework.fabric.argument.server.Vec3dArgument;
|
||||
import cloud.commandframework.fabric.data.Coordinates;
|
||||
import cloud.commandframework.fabric.data.Coordinates.ColumnCoordinates;
|
||||
import cloud.commandframework.fabric.data.MultipleEntitySelector;
|
||||
|
|
@ -56,6 +56,7 @@ import net.minecraft.text.HoverEvent;
|
|||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.MutableText;
|
||||
import net.minecraft.text.TextColor;
|
||||
import net.minecraft.text.Texts;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
|
|
@ -118,7 +119,7 @@ public final class FabricExample implements ModInitializer {
|
|||
));
|
||||
ctx.getSender().sendFeedback(
|
||||
new LiteralText(String.format("Waved at %d players (%s)", selected.size(),
|
||||
selector.getInput()
|
||||
selector.inputString()
|
||||
)),
|
||||
false
|
||||
);
|
||||
|
|
@ -229,7 +230,7 @@ public final class FabricExample implements ModInitializer {
|
|||
manager.command(base.literal("teleport")
|
||||
.permission("cloud.teleport")
|
||||
.argument(MultipleEntitySelectorArgument.of("targets"))
|
||||
.argument(Vec3Argument.of("location"))
|
||||
.argument(Vec3dArgument.of("location"))
|
||||
.handler(ctx -> {
|
||||
final MultipleEntitySelector selector = ctx.get("targets");
|
||||
final Vec3d location = ctx.<Coordinates>get("location").position();
|
||||
|
|
@ -245,7 +246,7 @@ public final class FabricExample implements ModInitializer {
|
|||
try {
|
||||
player = ctx.getSender().getPlayer();
|
||||
} catch (final CommandSyntaxException e) {
|
||||
ctx.getSender().sendFeedback(new LiteralText("Must be a player to use this command"), false);
|
||||
ctx.getSender().sendFeedback(Texts.toText(e.getRawMessage()), false);
|
||||
return;
|
||||
}
|
||||
final Vec3d vec = ctx.<ColumnCoordinates>get("chunk_position").position();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue