fabric: Remap to Mojang names
This commit is contained in:
parent
7dd9517795
commit
28821b5ff1
51 changed files with 656 additions and 670 deletions
|
|
@ -39,7 +39,7 @@ tasks {
|
|||
|
||||
withType(Javadoc::class).configureEach {
|
||||
(options as? StandardJavadocDocletOptions)?.apply {
|
||||
links("https://maven.fabricmc.net/docs/yarn-${Versions.fabricMc}+build.${Versions.fabricYarn}/")
|
||||
//links("https://maven.fabricmc.net/docs/yarn-${Versions.fabricMc}+build.${Versions.fabricYarn}/") // todo
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -60,7 +60,7 @@ tasks {
|
|||
|
||||
dependencies {
|
||||
minecraft("com.mojang", "minecraft", Versions.fabricMc)
|
||||
mappings("net.fabricmc", "yarn", "${Versions.fabricMc}+build.${Versions.fabricYarn}", classifier = "v2")
|
||||
mappings(minecraft.officialMojangMappings())
|
||||
modImplementation("net.fabricmc", "fabric-loader", Versions.fabricLoader)
|
||||
modImplementation(fabricApi.module("fabric-command-api-v1", Versions.fabricApi))
|
||||
modImplementation(fabricApi.module("fabric-lifecycle-events-v1", Versions.fabricApi))
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@ import cloud.commandframework.execution.CommandExecutionCoordinator;
|
|||
import cloud.commandframework.permission.PredicatePermission;
|
||||
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
|
||||
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientCommandSource;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.ClientSuggestionProvider;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
|
@ -88,9 +88,9 @@ public final class FabricClientCommandManager<C> extends FabricCommandManager<C,
|
|||
commandSourceMapper,
|
||||
backwardsCommandSourceMapper,
|
||||
new FabricCommandRegistrationHandler.Client<>(),
|
||||
() -> (FabricClientCommandSource) new ClientCommandSource(
|
||||
MinecraftClient.getInstance().getNetworkHandler(),
|
||||
MinecraftClient.getInstance()
|
||||
() -> (FabricClientCommandSource) new ClientSuggestionProvider(
|
||||
Minecraft.getInstance().getConnection(),
|
||||
Minecraft.getInstance()
|
||||
)
|
||||
);
|
||||
|
||||
|
|
@ -123,7 +123,7 @@ public final class FabricClientCommandManager<C> extends FabricCommandManager<C,
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull PredicatePermission<C> integratedServerRunning() {
|
||||
return sender -> MinecraftClient.getInstance().isIntegratedServerRunning();
|
||||
return sender -> Minecraft.getInstance().hasSingleplayerServer();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -134,7 +134,7 @@ public final class FabricClientCommandManager<C> extends FabricCommandManager<C,
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull PredicatePermission<C> integratedServerNotRunning() {
|
||||
return sender -> !MinecraftClient.getInstance().isIntegratedServerRunning();
|
||||
return sender -> !Minecraft.getInstance().hasSingleplayerServer();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -163,10 +163,10 @@ public final class FabricClientCommandManager<C> extends FabricCommandManager<C,
|
|||
*/
|
||||
public static <C> @NonNull PredicatePermission<C> cheatsAllowed(final boolean allowOnMultiplayer) {
|
||||
return sender -> {
|
||||
if (!MinecraftClient.getInstance().isIntegratedServerRunning()) {
|
||||
if (!Minecraft.getInstance().hasSingleplayerServer()) {
|
||||
return allowOnMultiplayer;
|
||||
}
|
||||
return MinecraftClient.getInstance().getServer().getPlayerManager().areCheatsAllowed();
|
||||
return Minecraft.getInstance().getSingleplayerServer().getPlayerList().isAllowCheatsForAllPlayers();
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -196,10 +196,10 @@ public final class FabricClientCommandManager<C> extends FabricCommandManager<C,
|
|||
*/
|
||||
public static <C> @NonNull PredicatePermission<C> cheatsDisallowed(final boolean allowOnMultiplayer) {
|
||||
return sender -> {
|
||||
if (!MinecraftClient.getInstance().isIntegratedServerRunning()) {
|
||||
if (!Minecraft.getInstance().hasSingleplayerServer()) {
|
||||
return allowOnMultiplayer;
|
||||
}
|
||||
return !MinecraftClient.getInstance().getServer().getPlayerManager().areCheatsAllowed();
|
||||
return !Minecraft.getInstance().getSingleplayerServer().getPlayerList().isAllowCheatsForAllPlayers();
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import cloud.commandframework.context.CommandContext;
|
|||
import cloud.commandframework.keys.CloudKey;
|
||||
import cloud.commandframework.keys.SimpleCloudKey;
|
||||
import io.leangen.geantyref.TypeToken;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
|
||||
/**
|
||||
* Keys used in {@link CommandContext}s available within a {@link FabricCommandManager}
|
||||
|
|
@ -40,13 +40,13 @@ public final class FabricCommandContextKeys {
|
|||
}
|
||||
|
||||
/**
|
||||
* Key used to store the native {@link CommandSource} in the command context.
|
||||
* Key used to store the native {@link SharedSuggestionProvider} in the command context.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static final CloudKey<CommandSource> NATIVE_COMMAND_SOURCE = SimpleCloudKey.of(
|
||||
public static final CloudKey<SharedSuggestionProvider> NATIVE_COMMAND_SOURCE = SimpleCloudKey.of(
|
||||
"cloud:fabric_command_source",
|
||||
TypeToken.get(CommandSource.class)
|
||||
TypeToken.get(SharedSuggestionProvider.class)
|
||||
);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,41 +44,40 @@ import com.mojang.brigadier.suggestion.SuggestionProvider;
|
|||
import com.mojang.serialization.Codec;
|
||||
import io.leangen.geantyref.GenericTypeReflector;
|
||||
import io.leangen.geantyref.TypeToken;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.command.argument.AngleArgumentType;
|
||||
import net.minecraft.command.argument.BlockPredicateArgumentType;
|
||||
import net.minecraft.command.argument.ColorArgumentType;
|
||||
import net.minecraft.command.argument.DimensionArgumentType;
|
||||
import net.minecraft.command.argument.EntityAnchorArgumentType;
|
||||
import net.minecraft.command.argument.EntitySummonArgumentType;
|
||||
import net.minecraft.command.argument.IdentifierArgumentType;
|
||||
import net.minecraft.command.argument.ItemEnchantmentArgumentType;
|
||||
import net.minecraft.command.argument.ItemStackArgument;
|
||||
import net.minecraft.command.argument.ItemStackArgumentType;
|
||||
import net.minecraft.command.argument.MessageArgumentType;
|
||||
import net.minecraft.command.argument.MobEffectArgumentType;
|
||||
import net.minecraft.command.argument.NbtCompoundTagArgumentType;
|
||||
import net.minecraft.command.argument.NbtPathArgumentType;
|
||||
import net.minecraft.command.argument.NbtTagArgumentType;
|
||||
import net.minecraft.command.argument.NumberRangeArgumentType;
|
||||
import net.minecraft.command.argument.ObjectiveCriteriaArgumentType;
|
||||
import net.minecraft.command.argument.OperationArgumentType;
|
||||
import net.minecraft.command.argument.ParticleArgumentType;
|
||||
import net.minecraft.command.argument.SwizzleArgumentType;
|
||||
import net.minecraft.command.argument.TeamArgumentType;
|
||||
import net.minecraft.command.argument.UuidArgumentType;
|
||||
import net.minecraft.command.suggestion.SuggestionProviders;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.advancements.critereon.MinMaxBounds;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.commands.arguments.AngleArgument;
|
||||
import net.minecraft.commands.arguments.ColorArgument;
|
||||
import net.minecraft.commands.arguments.CompoundTagArgument;
|
||||
import net.minecraft.commands.arguments.DimensionArgument;
|
||||
import net.minecraft.commands.arguments.EntityAnchorArgument;
|
||||
import net.minecraft.commands.arguments.EntitySummonArgument;
|
||||
import net.minecraft.commands.arguments.ItemEnchantmentArgument;
|
||||
import net.minecraft.commands.arguments.MessageArgument;
|
||||
import net.minecraft.commands.arguments.MobEffectArgument;
|
||||
import net.minecraft.commands.arguments.NbtPathArgument;
|
||||
import net.minecraft.commands.arguments.NbtTagArgument;
|
||||
import net.minecraft.commands.arguments.ObjectiveCriteriaArgument;
|
||||
import net.minecraft.commands.arguments.OperationArgument;
|
||||
import net.minecraft.commands.arguments.ParticleArgument;
|
||||
import net.minecraft.commands.arguments.RangeArgument;
|
||||
import net.minecraft.commands.arguments.ResourceLocationArgument;
|
||||
import net.minecraft.commands.arguments.UuidArgument;
|
||||
import net.minecraft.commands.arguments.blocks.BlockPredicateArgument;
|
||||
import net.minecraft.commands.arguments.coordinates.SwizzleArgument;
|
||||
import net.minecraft.commands.arguments.item.ItemArgument;
|
||||
import net.minecraft.commands.arguments.item.ItemInput;
|
||||
import net.minecraft.commands.synchronization.SuggestionProviders;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.particles.ParticleOptions;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.particle.ParticleEffect;
|
||||
import net.minecraft.predicate.NumberRange;
|
||||
import net.minecraft.scoreboard.ScoreboardCriterion;
|
||||
import net.minecraft.scoreboard.Team;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.scores.PlayerTeam;
|
||||
import net.minecraft.world.scores.criteria.ObjectiveCriteria;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
|
@ -108,7 +107,7 @@ import java.util.function.Supplier;
|
|||
* @see FabricServerCommandManager for server commands
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public abstract class FabricCommandManager<C, S extends CommandSource> extends CommandManager<C> implements
|
||||
public abstract class FabricCommandManager<C, S extends SharedSuggestionProvider> extends CommandManager<C> implements
|
||||
BrigadierManagerHolder<C> {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
|
@ -130,8 +129,8 @@ public abstract class FabricCommandManager<C, S extends CommandSource> extends C
|
|||
* use a synchronous execution coordinator. In most cases you will want to pick between
|
||||
* {@link CommandExecutionCoordinator#simpleCoordinator()} and
|
||||
* {@link AsynchronousCommandExecutionCoordinator}
|
||||
* @param commandSourceMapper Function that maps {@link CommandSource} to the command sender type
|
||||
* @param backwardsCommandSourceMapper Function that maps the command sender type to {@link CommandSource}
|
||||
* @param commandSourceMapper Function that maps {@link SharedSuggestionProvider} to the command sender type
|
||||
* @param backwardsCommandSourceMapper Function that maps the command sender type to {@link SharedSuggestionProvider}
|
||||
* @param registrationHandler the handler accepting command registrations
|
||||
* @param dummyCommandSourceProvider a provider of a dummy command source, for use with brigadier registration
|
||||
* @since 1.5.0
|
||||
|
|
@ -167,38 +166,38 @@ public abstract class FabricCommandManager<C, S extends CommandSource> extends C
|
|||
private void registerNativeBrigadierMappings(final @NonNull CloudBrigadierManager<C, S> brigadier) {
|
||||
/* Cloud-native argument types */
|
||||
brigadier.registerMapping(new TypeToken<UUIDArgument.UUIDParser<C>>() {
|
||||
}, builder -> builder.toConstant(UuidArgumentType.uuid()));
|
||||
}, builder -> builder.toConstant(UuidArgument.uuid()));
|
||||
this.registerRegistryEntryMappings();
|
||||
brigadier.registerMapping(new TypeToken<TeamArgument.TeamParser<C>>() {
|
||||
}, builder -> builder.toConstant(TeamArgumentType.team()));
|
||||
this.getParserRegistry().registerParserSupplier(TypeToken.get(Team.class), params -> new TeamArgument.TeamParser<>());
|
||||
}, builder -> builder.toConstant(net.minecraft.commands.arguments.TeamArgument.team()));
|
||||
this.getParserRegistry().registerParserSupplier(TypeToken.get(PlayerTeam.class), params -> new TeamArgument.TeamParser<>());
|
||||
|
||||
/* Wrapped/Constant Brigadier types, native value type */
|
||||
this.registerConstantNativeParserSupplier(Formatting.class, ColorArgumentType.color());
|
||||
this.registerConstantNativeParserSupplier(CompoundTag.class, NbtCompoundTagArgumentType.nbtCompound());
|
||||
this.registerConstantNativeParserSupplier(Tag.class, NbtTagArgumentType.nbtTag());
|
||||
this.registerConstantNativeParserSupplier(NbtPathArgumentType.NbtPath.class, NbtPathArgumentType.nbtPath());
|
||||
this.registerConstantNativeParserSupplier(ScoreboardCriterion.class, ObjectiveCriteriaArgumentType.objectiveCriteria());
|
||||
this.registerConstantNativeParserSupplier(OperationArgumentType.Operation.class, OperationArgumentType.operation());
|
||||
this.registerConstantNativeParserSupplier(ParticleEffect.class, ParticleArgumentType.particle());
|
||||
this.registerConstantNativeParserSupplier(AngleArgumentType.Angle.class, AngleArgumentType.angle());
|
||||
this.registerConstantNativeParserSupplier(ChatFormatting.class, ColorArgument.color());
|
||||
this.registerConstantNativeParserSupplier(CompoundTag.class, CompoundTagArgument.compoundTag());
|
||||
this.registerConstantNativeParserSupplier(Tag.class, NbtTagArgument.nbtTag());
|
||||
this.registerConstantNativeParserSupplier(NbtPathArgument.NbtPath.class, NbtPathArgument.nbtPath());
|
||||
this.registerConstantNativeParserSupplier(ObjectiveCriteria.class, ObjectiveCriteriaArgument.criteria());
|
||||
this.registerConstantNativeParserSupplier(OperationArgument.Operation.class, OperationArgument.operation());
|
||||
this.registerConstantNativeParserSupplier(ParticleOptions.class, ParticleArgument.particle());
|
||||
this.registerConstantNativeParserSupplier(AngleArgument.SingleAngle.class, AngleArgument.angle());
|
||||
this.registerConstantNativeParserSupplier(new TypeToken<EnumSet<Direction.Axis>>() {
|
||||
}, SwizzleArgumentType.swizzle());
|
||||
this.registerConstantNativeParserSupplier(Identifier.class, IdentifierArgumentType.identifier());
|
||||
}, SwizzleArgument.swizzle());
|
||||
this.registerConstantNativeParserSupplier(ResourceLocation.class, ResourceLocationArgument.id());
|
||||
this.registerConstantNativeParserSupplier(
|
||||
EntityAnchorArgumentType.EntityAnchor.class,
|
||||
EntityAnchorArgumentType.entityAnchor()
|
||||
EntityAnchorArgument.Anchor.class,
|
||||
EntityAnchorArgument.anchor()
|
||||
);
|
||||
this.registerConstantNativeParserSupplier(NumberRange.IntRange.class, NumberRangeArgumentType.numberRange());
|
||||
this.registerConstantNativeParserSupplier(NumberRange.FloatRange.class, NumberRangeArgumentType.method_30918());
|
||||
this.registerConstantNativeParserSupplier(ItemStackArgument.class, ItemStackArgumentType.itemStack());
|
||||
this.registerConstantNativeParserSupplier(MinMaxBounds.Ints.class, RangeArgument.intRange());
|
||||
this.registerConstantNativeParserSupplier(MinMaxBounds.Floats.class, RangeArgument.floatRange());
|
||||
this.registerConstantNativeParserSupplier(ItemInput.class, ItemArgument.item());
|
||||
|
||||
/* Wrapped/Constant Brigadier types, mapped value type */
|
||||
this.registerConstantNativeParserSupplier(
|
||||
BlockPredicateArgumentType.BlockPredicate.class,
|
||||
BlockPredicateArgumentType.blockPredicate()
|
||||
BlockPredicateArgument.Result.class,
|
||||
BlockPredicateArgument.blockPredicate()
|
||||
);
|
||||
this.registerConstantNativeParserSupplier(MessageArgumentType.MessageFormat.class, MessageArgumentType.message());
|
||||
this.registerConstantNativeParserSupplier(MessageArgument.Message.class, MessageArgument.message());
|
||||
this.getParserRegistry().registerParserSupplier(
|
||||
TypeToken.get(MinecraftTime.class),
|
||||
params -> FabricArgumentParsers.time()
|
||||
|
|
@ -212,30 +211,30 @@ public abstract class FabricCommandManager<C, S extends CommandSource> extends C
|
|||
},
|
||||
builder -> builder.to(argument -> {
|
||||
/* several registries have specialized argument types, so let's use those where possible */
|
||||
final RegistryKey<? extends Registry<?>> registry = argument.getRegistry();
|
||||
if (registry.equals(Registry.ENTITY_TYPE_KEY)) {
|
||||
return EntitySummonArgumentType.entitySummon();
|
||||
} else if (registry.equals(Registry.ENCHANTMENT_KEY)) {
|
||||
return ItemEnchantmentArgumentType.itemEnchantment();
|
||||
} else if (registry.equals(Registry.MOB_EFFECT_KEY)) { // yarn wai
|
||||
return MobEffectArgumentType.mobEffect();
|
||||
} else if (registry.equals(Registry.DIMENSION)) {
|
||||
return DimensionArgumentType.dimension();
|
||||
final ResourceKey<? extends Registry<?>> registry = argument.getRegistry();
|
||||
if (registry.equals(Registry.ENTITY_TYPE_REGISTRY)) {
|
||||
return EntitySummonArgument.id();
|
||||
} else if (registry.equals(Registry.ENCHANTMENT_REGISTRY)) {
|
||||
return ItemEnchantmentArgument.enchantment();
|
||||
} else if (registry.equals(Registry.MOB_EFFECT_REGISTRY)) {
|
||||
return MobEffectArgument.effect();
|
||||
} else if (registry.equals(Registry.DIMENSION_REGISTRY)) {
|
||||
return DimensionArgument.dimension();
|
||||
}
|
||||
return IdentifierArgumentType.identifier();
|
||||
return ResourceLocationArgument.id();
|
||||
}
|
||||
).suggestedBy((argument, useCloud) -> {
|
||||
/* A few other registries have client-side suggestion providers but no argument type */
|
||||
/* Type parameters are messed up here for some reason */
|
||||
final RegistryKey<? extends Registry<?>> registry = argument.getRegistry();
|
||||
if (registry.equals(Registry.SOUND_EVENT_KEY)) {
|
||||
final ResourceKey<? extends Registry<?>> registry = argument.getRegistry();
|
||||
if (registry.equals(Registry.SOUND_EVENT_REGISTRY)) {
|
||||
return (SuggestionProvider<S>) SuggestionProviders.AVAILABLE_SOUNDS;
|
||||
} else if (registry.equals(Registry.BIOME_KEY)) {
|
||||
return (SuggestionProvider<S>) SuggestionProviders.ALL_BIOMES;
|
||||
} else if (registry.equals(Registry.ENTITY_TYPE_KEY)
|
||||
|| registry.equals(Registry.ENCHANTMENT_KEY)
|
||||
|| registry.equals(Registry.MOB_EFFECT_KEY)
|
||||
|| registry.equals(Registry.DIMENSION)) {
|
||||
} else if (registry.equals(Registry.BIOME_REGISTRY)) {
|
||||
return (SuggestionProvider<S>) SuggestionProviders.AVAILABLE_BIOMES;
|
||||
} else if (registry.equals(Registry.ENTITY_TYPE_REGISTRY)
|
||||
|| registry.equals(Registry.ENCHANTMENT_REGISTRY)
|
||||
|| registry.equals(Registry.MOB_EFFECT_REGISTRY)
|
||||
|| registry.equals(Registry.DIMENSION_REGISTRY)) {
|
||||
return null; /* for types with their own argument type, use Brigadier */
|
||||
}
|
||||
return useCloud; /* use cloud suggestions for anything else */
|
||||
|
|
@ -247,13 +246,13 @@ public abstract class FabricCommandManager<C, S extends CommandSource> extends C
|
|||
final Set<Class<?>> seenClasses = new HashSet<>();
|
||||
/* Some registries have types that are too generic... we'll skip those for now.
|
||||
* Eventually, these could be resolved by using ParserParameters in some way? */
|
||||
seenClasses.add(Identifier.class);
|
||||
seenClasses.add(ResourceLocation.class);
|
||||
seenClasses.add(Codec.class);
|
||||
for (final Field field : Registry.class.getDeclaredFields()) {
|
||||
if ((field.getModifiers() & MOD_PUBLIC_STATIC_FINAL) != MOD_PUBLIC_STATIC_FINAL) {
|
||||
continue;
|
||||
}
|
||||
if (!field.getType().equals(RegistryKey.class)) {
|
||||
if (!field.getType().equals(ResourceKey.class)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -271,9 +270,9 @@ public abstract class FabricCommandManager<C, S extends CommandSource> extends C
|
|||
continue;
|
||||
}
|
||||
|
||||
final RegistryKey<?> key;
|
||||
final ResourceKey<?> key;
|
||||
try {
|
||||
key = (RegistryKey<?>) field.get(null);
|
||||
key = (ResourceKey<?>) field.get(null);
|
||||
} catch (final IllegalAccessException ex) {
|
||||
LOGGER.warn("Failed to access value of registry key in field {} of type {}", field.getName(), generic, ex);
|
||||
continue;
|
||||
|
|
@ -327,7 +326,7 @@ public abstract class FabricCommandManager<C, S extends CommandSource> extends C
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the mapper from a game {@link CommandSource} to the manager's {@code C} type.
|
||||
* Gets the mapper from a game {@link SharedSuggestionProvider} to the manager's {@code C} type.
|
||||
*
|
||||
* @return Command source mapper
|
||||
* @since 1.5.0
|
||||
|
|
@ -337,7 +336,7 @@ public abstract class FabricCommandManager<C, S extends CommandSource> extends C
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the mapper from the manager's {@code C} type to a game {@link CommandSource}.
|
||||
* Gets the mapper from the manager's {@code C} type to a game {@link SharedSuggestionProvider}.
|
||||
*
|
||||
* @return Command source mapper
|
||||
* @since 1.5.0
|
||||
|
|
@ -366,7 +365,7 @@ public abstract class FabricCommandManager<C, S extends CommandSource> extends C
|
|||
public @NonNull PredicatePermission<C> permissionLevel(final int permissionLevel) {
|
||||
return sender -> this.getBackwardsCommandSourceMapper()
|
||||
.apply(sender)
|
||||
.hasPermissionLevel(permissionLevel);
|
||||
.hasPermission(permissionLevel);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,9 +34,9 @@ import com.mojang.brigadier.tree.RootCommandNode;
|
|||
import net.fabricmc.fabric.api.client.command.v1.ClientCommandManager;
|
||||
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
|
||||
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.server.command.CommandManager.RegistrationEnvironment;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands.CommandSelection;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
|
|
@ -51,7 +51,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
* @param <C> command sender type
|
||||
* @param <S> native sender type
|
||||
*/
|
||||
abstract class FabricCommandRegistrationHandler<C, S extends CommandSource> implements CommandRegistrationHandler {
|
||||
abstract class FabricCommandRegistrationHandler<C, S extends SharedSuggestionProvider> implements CommandRegistrationHandler {
|
||||
private @MonotonicNonNull FabricCommandManager<C, S> commandManager;
|
||||
|
||||
void initialize(final FabricCommandManager<C, S> manager) {
|
||||
|
|
@ -122,7 +122,7 @@ abstract class FabricCommandRegistrationHandler<C, S extends CommandSource> impl
|
|||
true,
|
||||
new FabricExecutor<>(
|
||||
this.getCommandManager(),
|
||||
source -> source.getPlayer().getName().asString(),
|
||||
source -> source.getPlayer().getGameProfile().getName(),
|
||||
FabricClientCommandSource::sendError
|
||||
)
|
||||
);
|
||||
|
|
@ -136,11 +136,11 @@ abstract class FabricCommandRegistrationHandler<C, S extends CommandSource> impl
|
|||
}
|
||||
}
|
||||
|
||||
static class Server<C> extends FabricCommandRegistrationHandler<C, ServerCommandSource> {
|
||||
static class Server<C> extends FabricCommandRegistrationHandler<C, CommandSourceStack> {
|
||||
private final Set<Command<C>> registeredCommands = ConcurrentHashMap.newKeySet();
|
||||
|
||||
@Override
|
||||
void initialize(final FabricCommandManager<C, ServerCommandSource> manager) {
|
||||
void initialize(final FabricCommandManager<C, CommandSourceStack> manager) {
|
||||
super.initialize(manager);
|
||||
CommandRegistrationCallback.EVENT.register(this::registerAllCommands);
|
||||
}
|
||||
|
|
@ -151,27 +151,27 @@ abstract class FabricCommandRegistrationHandler<C, S extends CommandSource> impl
|
|||
return this.registeredCommands.add((Command<C>) command);
|
||||
}
|
||||
|
||||
private void registerAllCommands(final CommandDispatcher<ServerCommandSource> dispatcher, final boolean isDedicated) {
|
||||
private void registerAllCommands(final CommandDispatcher<CommandSourceStack> dispatcher, final boolean isDedicated) {
|
||||
this.getCommandManager().registrationCalled();
|
||||
for (final Command<C> command : this.registeredCommands) {
|
||||
/* Only register commands in the declared environment */
|
||||
final RegistrationEnvironment env = command.getCommandMeta().getOrDefault(
|
||||
final CommandSelection env = command.getCommandMeta().getOrDefault(
|
||||
FabricServerCommandManager.META_REGISTRATION_ENVIRONMENT,
|
||||
RegistrationEnvironment.ALL
|
||||
CommandSelection.ALL
|
||||
);
|
||||
|
||||
if ((env == RegistrationEnvironment.INTEGRATED && isDedicated)
|
||||
|| (env == RegistrationEnvironment.DEDICATED && !isDedicated)) {
|
||||
if ((env == CommandSelection.INTEGRATED && isDedicated)
|
||||
|| (env == CommandSelection.DEDICATED && !isDedicated)) {
|
||||
continue;
|
||||
}
|
||||
this.registerCommand(dispatcher.getRoot(), command);
|
||||
}
|
||||
}
|
||||
|
||||
private void registerCommand(final RootCommandNode<ServerCommandSource> dispatcher, final Command<C> command) {
|
||||
private void registerCommand(final RootCommandNode<CommandSourceStack> dispatcher, final Command<C> command) {
|
||||
@SuppressWarnings("unchecked")
|
||||
final StaticArgument<C> first = ((StaticArgument<C>) command.getArguments().get(0));
|
||||
final CommandNode<ServerCommandSource> baseNode = this.getCommandManager().brigadierManager().createLiteralCommandNode(
|
||||
final CommandNode<CommandSourceStack> baseNode = this.getCommandManager().brigadierManager().createLiteralCommandNode(
|
||||
first.getName(),
|
||||
command,
|
||||
(src, perm) -> this.getCommandManager().hasPermission(
|
||||
|
|
@ -179,7 +179,7 @@ abstract class FabricCommandRegistrationHandler<C, S extends CommandSource> impl
|
|||
perm
|
||||
),
|
||||
true,
|
||||
new FabricExecutor<>(this.getCommandManager(), ServerCommandSource::getName, ServerCommandSource::sendError));
|
||||
new FabricExecutor<>(this.getCommandManager(), CommandSourceStack::getTextName, CommandSourceStack::sendFailure));
|
||||
|
||||
dispatcher.addChild(baseNode);
|
||||
|
||||
|
|
|
|||
|
|
@ -32,14 +32,14 @@ import cloud.commandframework.exceptions.NoSuchCommandException;
|
|||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.text.ClickEvent;
|
||||
import net.minecraft.text.HoverEvent;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.MutableText;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.Texts;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.ComponentUtils;
|
||||
import net.minecraft.network.chat.HoverEvent;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
|
@ -50,11 +50,11 @@ import java.util.concurrent.CompletionException;
|
|||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
final class FabricExecutor<C, S extends CommandSource> implements Command<S> {
|
||||
final class FabricExecutor<C, S extends SharedSuggestionProvider> implements Command<S> {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private static final Text NEWLINE = new LiteralText("\n");
|
||||
private static final Component NEWLINE = new TextComponent("\n");
|
||||
private static final String MESSAGE_INTERNAL_ERROR = "An internal error occurred while attempting to perform this command.";
|
||||
private static final String MESSAGE_NO_PERMS =
|
||||
"I'm sorry, but you do not have permission to perform this command. "
|
||||
|
|
@ -63,12 +63,12 @@ final class FabricExecutor<C, S extends CommandSource> implements Command<S> {
|
|||
|
||||
private final FabricCommandManager<C, S> manager;
|
||||
private final Function<S, String> getName;
|
||||
private final BiConsumer<S, Text> sendError;
|
||||
private final BiConsumer<S, Component> sendError;
|
||||
|
||||
FabricExecutor(
|
||||
final @NonNull FabricCommandManager<C, S> manager,
|
||||
final @NonNull Function<S, String> getName,
|
||||
final @NonNull BiConsumer<S, Text> sendError
|
||||
final @NonNull BiConsumer<S, Component> sendError
|
||||
) {
|
||||
this.manager = manager;
|
||||
this.getName = getName;
|
||||
|
|
@ -100,9 +100,9 @@ final class FabricExecutor<C, S extends CommandSource> implements Command<S> {
|
|||
(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)))
|
||||
new TextComponent("Invalid Command Syntax. Correct command syntax is: ")
|
||||
.append(new TextComponent(String.format("/%s", e.getCorrectSyntax()))
|
||||
.withStyle(style -> style.withColor(ChatFormatting.GRAY)))
|
||||
)
|
||||
);
|
||||
} else if (throwable instanceof InvalidCommandSenderException) {
|
||||
|
|
@ -110,21 +110,21 @@ final class FabricExecutor<C, S extends CommandSource> implements Command<S> {
|
|||
sender,
|
||||
InvalidCommandSenderException.class,
|
||||
(InvalidCommandSenderException) throwable,
|
||||
(c, e) -> this.sendError.accept(source, new LiteralText(throwable.getMessage()))
|
||||
(c, e) -> this.sendError.accept(source, new TextComponent(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))
|
||||
(c, e) -> this.sendError.accept(source, new TextComponent(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))
|
||||
(c, e) -> this.sendError.accept(source, new TextComponent(MESSAGE_UNKNOWN_COMMAND))
|
||||
);
|
||||
} else if (throwable instanceof ArgumentParseException) {
|
||||
this.manager.handleException(
|
||||
|
|
@ -133,14 +133,14 @@ final class FabricExecutor<C, S extends CommandSource> implements Command<S> {
|
|||
(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)));
|
||||
this.sendError.accept(source, new TextComponent("Invalid Command Argument: ")
|
||||
.append(new TextComponent("")
|
||||
.append(ComponentUtils.fromMessage(((CommandSyntaxException) throwable.getCause()).getRawMessage()))
|
||||
.withStyle(ChatFormatting.GRAY)));
|
||||
} else {
|
||||
this.sendError.accept(source, new LiteralText("Invalid Command Argument: ")
|
||||
.append(new LiteralText(throwable.getCause().getMessage())
|
||||
.formatted(Formatting.GRAY)));
|
||||
this.sendError.accept(source, new TextComponent("Invalid Command Argument: ")
|
||||
.append(new TextComponent(throwable.getCause().getMessage())
|
||||
.withStyle(ChatFormatting.GRAY)));
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
@ -151,7 +151,7 @@ final class FabricExecutor<C, S extends CommandSource> implements Command<S> {
|
|||
(CommandExecutionException) throwable,
|
||||
(c, e) -> {
|
||||
this.sendError.accept(source, this.decorateHoverStacktrace(
|
||||
new LiteralText(MESSAGE_INTERNAL_ERROR),
|
||||
new TextComponent(MESSAGE_INTERNAL_ERROR),
|
||||
throwable.getCause(),
|
||||
sender
|
||||
));
|
||||
|
|
@ -164,7 +164,7 @@ final class FabricExecutor<C, S extends CommandSource> implements Command<S> {
|
|||
);
|
||||
} else {
|
||||
this.sendError.accept(source, this.decorateHoverStacktrace(
|
||||
new LiteralText(MESSAGE_INTERNAL_ERROR),
|
||||
new TextComponent(MESSAGE_INTERNAL_ERROR),
|
||||
throwable,
|
||||
sender
|
||||
));
|
||||
|
|
@ -172,7 +172,7 @@ final class FabricExecutor<C, S extends CommandSource> implements Command<S> {
|
|||
}
|
||||
}
|
||||
|
||||
private MutableText decorateHoverStacktrace(final MutableText input, final Throwable cause, final C sender) {
|
||||
private MutableComponent decorateHoverStacktrace(final MutableComponent input, final Throwable cause, final C sender) {
|
||||
if (!this.manager.hasPermission(sender, "cloud.hover-stacktrace")) {
|
||||
return input;
|
||||
}
|
||||
|
|
@ -180,13 +180,13 @@ final class FabricExecutor<C, S extends CommandSource> implements Command<S> {
|
|||
final StringWriter writer = new StringWriter();
|
||||
cause.printStackTrace(new PrintWriter(writer));
|
||||
final String stackTrace = writer.toString().replace("\t", " ");
|
||||
return input.styled(style -> style
|
||||
return input.withStyle(style -> style
|
||||
.withHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new LiteralText(stackTrace)
|
||||
new TextComponent(stackTrace)
|
||||
.append(NEWLINE)
|
||||
.append(new LiteralText(" Click to copy")
|
||||
.styled(s2 -> s2.withColor(Formatting.GRAY).withItalic(true)))
|
||||
.append(new TextComponent(" Click to copy")
|
||||
.withStyle(s2 -> s2.withColor(ChatFormatting.GRAY).withItalic(true)))
|
||||
))
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.COPY_TO_CLIPBOARD,
|
||||
|
|
|
|||
|
|
@ -40,12 +40,12 @@ import cloud.commandframework.meta.CommandMeta;
|
|||
import io.leangen.geantyref.TypeToken;
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
|
||||
import net.minecraft.server.command.CommandManager;
|
||||
import net.minecraft.server.command.CommandOutput;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.util.math.Vec2f;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.commands.CommandSource;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.world.phys.Vec2;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
|
@ -60,17 +60,17 @@ import java.util.function.Function;
|
|||
* @param <C> the command sender type
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public final class FabricServerCommandManager<C> extends FabricCommandManager<C, ServerCommandSource> {
|
||||
public final class FabricServerCommandManager<C> extends FabricCommandManager<C, CommandSourceStack> {
|
||||
|
||||
/**
|
||||
* A meta attribute specifying which environments a command should be registered in.
|
||||
*
|
||||
* <p>The default value is {@link CommandManager.RegistrationEnvironment#ALL}.</p>
|
||||
* <p>The default value is {@link Commands.CommandSelection#ALL}.</p>
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static final CommandMeta.Key<CommandManager.RegistrationEnvironment> META_REGISTRATION_ENVIRONMENT = CommandMeta.Key.of(
|
||||
CommandManager.RegistrationEnvironment.class,
|
||||
public static final CommandMeta.Key<Commands.CommandSelection> META_REGISTRATION_ENVIRONMENT = CommandMeta.Key.of(
|
||||
Commands.CommandSelection.class,
|
||||
"cloud:registration-environment"
|
||||
);
|
||||
|
||||
|
|
@ -82,9 +82,9 @@ public final class FabricServerCommandManager<C> extends FabricCommandManager<C,
|
|||
* @see #FabricServerCommandManager(Function, Function, Function) for a more thorough explanation
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static @NonNull FabricServerCommandManager<@NonNull ServerCommandSource> createNative(
|
||||
final @NonNull Function<@NonNull CommandTree<@NonNull ServerCommandSource>,
|
||||
@NonNull CommandExecutionCoordinator<@NonNull ServerCommandSource>> execCoordinator
|
||||
public static @NonNull FabricServerCommandManager<@NonNull CommandSourceStack> createNative(
|
||||
final @NonNull Function<@NonNull CommandTree<@NonNull CommandSourceStack>,
|
||||
@NonNull CommandExecutionCoordinator<@NonNull CommandSourceStack>> execCoordinator
|
||||
) {
|
||||
return new FabricServerCommandManager<>(execCoordinator, Function.identity(), Function.identity());
|
||||
}
|
||||
|
|
@ -100,29 +100,29 @@ public final class FabricServerCommandManager<C> extends FabricCommandManager<C,
|
|||
* use a synchronous execution coordinator. In most cases you will want to pick between
|
||||
* {@link CommandExecutionCoordinator#simpleCoordinator()} and
|
||||
* {@link AsynchronousCommandExecutionCoordinator}
|
||||
* @param commandSourceMapper Function that maps {@link ServerCommandSource} to the command sender type
|
||||
* @param backwardsCommandSourceMapper Function that maps the command sender type to {@link ServerCommandSource}
|
||||
* @param commandSourceMapper Function that maps {@link CommandSourceStack} to the command sender type
|
||||
* @param backwardsCommandSourceMapper Function that maps the command sender type to {@link CommandSourceStack}
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public FabricServerCommandManager(
|
||||
final @NonNull Function<@NonNull CommandTree<@NonNull C>,
|
||||
@NonNull CommandExecutionCoordinator<@NonNull C>> commandExecutionCoordinator,
|
||||
final @NonNull Function<@NonNull ServerCommandSource, @NonNull C> commandSourceMapper,
|
||||
final @NonNull Function<@NonNull C, @NonNull ServerCommandSource> backwardsCommandSourceMapper
|
||||
final @NonNull Function<@NonNull CommandSourceStack, @NonNull C> commandSourceMapper,
|
||||
final @NonNull Function<@NonNull C, @NonNull CommandSourceStack> backwardsCommandSourceMapper
|
||||
) {
|
||||
super(
|
||||
commandExecutionCoordinator,
|
||||
commandSourceMapper,
|
||||
backwardsCommandSourceMapper,
|
||||
new FabricCommandRegistrationHandler.Server<>(),
|
||||
() -> new ServerCommandSource(
|
||||
CommandOutput.DUMMY,
|
||||
Vec3d.ZERO,
|
||||
Vec2f.ZERO,
|
||||
() -> new CommandSourceStack(
|
||||
CommandSource.NULL,
|
||||
Vec3.ZERO,
|
||||
Vec2.ZERO,
|
||||
null,
|
||||
4,
|
||||
"",
|
||||
LiteralText.EMPTY,
|
||||
TextComponent.EMPTY,
|
||||
null,
|
||||
null
|
||||
)
|
||||
|
|
@ -199,8 +199,8 @@ public final class FabricServerCommandManager<C> extends FabricCommandManager<C,
|
|||
*/
|
||||
@Override
|
||||
public boolean hasPermission(final @NonNull C sender, final @NonNull String permission) {
|
||||
final ServerCommandSource source = this.getBackwardsCommandSourceMapper().apply(sender);
|
||||
return Permissions.check(source, permission, source.getMinecraftServer().getOpPermissionLevel());
|
||||
final CommandSourceStack source = this.getBackwardsCommandSourceMapper().apply(sender);
|
||||
return Permissions.check(source, permission, source.getServer().getOperatorUserPermissionLevel());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ import cloud.commandframework.ArgumentDescription;
|
|||
import cloud.commandframework.arguments.CommandArgument;
|
||||
import cloud.commandframework.brigadier.argument.WrappedBrigadierParser;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import net.minecraft.command.argument.AngleArgumentType;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
|
|
@ -40,7 +39,7 @@ import java.util.function.BiFunction;
|
|||
* @param <C> the sender type
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public final class AngleArgument<C> extends CommandArgument<C, AngleArgumentType.Angle> {
|
||||
public final class AngleArgument<C> extends CommandArgument<C, net.minecraft.commands.arguments.AngleArgument.SingleAngle> {
|
||||
|
||||
AngleArgument(
|
||||
final boolean required,
|
||||
|
|
@ -52,9 +51,9 @@ public final class AngleArgument<C> extends CommandArgument<C, AngleArgumentType
|
|||
super(
|
||||
required,
|
||||
name,
|
||||
new WrappedBrigadierParser<>(AngleArgumentType.angle()),
|
||||
new WrappedBrigadierParser<>(net.minecraft.commands.arguments.AngleArgument.angle()),
|
||||
defaultValue,
|
||||
AngleArgumentType.Angle.class,
|
||||
net.minecraft.commands.arguments.AngleArgument.SingleAngle.class,
|
||||
suggestionsProvider,
|
||||
defaultDescription
|
||||
);
|
||||
|
|
@ -119,10 +118,10 @@ public final class AngleArgument<C> extends CommandArgument<C, AngleArgumentType
|
|||
* @param <C> sender type
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static final class Builder<C> extends TypedBuilder<C, AngleArgumentType.Angle, Builder<C>> {
|
||||
public static final class Builder<C> extends TypedBuilder<C, net.minecraft.commands.arguments.AngleArgument.SingleAngle, Builder<C>> {
|
||||
|
||||
Builder(final @NonNull String name) {
|
||||
super(AngleArgumentType.Angle.class, name);
|
||||
super(net.minecraft.commands.arguments.AngleArgument.SingleAngle.class, name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ import cloud.commandframework.arguments.CommandArgument;
|
|||
import cloud.commandframework.brigadier.argument.WrappedBrigadierParser;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import io.leangen.geantyref.TypeToken;
|
||||
import net.minecraft.command.argument.SwizzleArgumentType;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.commands.arguments.coordinates.SwizzleArgument;
|
||||
import net.minecraft.core.Direction;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ import java.util.Set;
|
|||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* An argument for a set of {@link net.minecraft.util.math.Direction.Axis axes}, described in Vanilla as a "swizzle".
|
||||
* An argument for a set of {@link net.minecraft.core.Direction.Axis axes}, described in Vanilla as a "swizzle".
|
||||
*
|
||||
* @param <C> the sender type
|
||||
* @since 1.5.0
|
||||
|
|
@ -59,7 +59,7 @@ public final class AxisArgument<C> extends CommandArgument<C, EnumSet<Direction.
|
|||
super(
|
||||
required,
|
||||
name,
|
||||
new WrappedBrigadierParser<>(SwizzleArgumentType.swizzle()),
|
||||
new WrappedBrigadierParser<>(SwizzleArgument.swizzle()),
|
||||
defaultValue,
|
||||
TYPE,
|
||||
suggestionsProvider,
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ import cloud.commandframework.ArgumentDescription;
|
|||
import cloud.commandframework.arguments.CommandArgument;
|
||||
import cloud.commandframework.brigadier.argument.WrappedBrigadierParser;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import net.minecraft.command.argument.NbtCompoundTagArgumentType;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
|
@ -53,7 +52,7 @@ public final class CompoundTagArgument<C> extends CommandArgument<C, CompoundTag
|
|||
super(
|
||||
required,
|
||||
name,
|
||||
new WrappedBrigadierParser<>(NbtCompoundTagArgumentType.nbtCompound()),
|
||||
new WrappedBrigadierParser<>(net.minecraft.commands.arguments.CompoundTagArgument.compoundTag()),
|
||||
defaultValue,
|
||||
CompoundTag.class,
|
||||
suggestionsProvider,
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ import cloud.commandframework.ArgumentDescription;
|
|||
import cloud.commandframework.arguments.CommandArgument;
|
||||
import cloud.commandframework.brigadier.argument.WrappedBrigadierParser;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import net.minecraft.command.argument.EntityAnchorArgumentType;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
|
|
@ -35,12 +34,12 @@ import java.util.List;
|
|||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* An argument parsing an {@link net.minecraft.command.argument.EntityAnchorArgumentType.EntityAnchor}.
|
||||
* An argument parsing an {@link net.minecraft.commands.arguments.EntityAnchorArgument.Anchor}.
|
||||
*
|
||||
* @param <C> the sender type
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public final class EntityAnchorArgument<C> extends CommandArgument<C, EntityAnchorArgumentType.EntityAnchor> {
|
||||
public final class EntityAnchorArgument<C> extends CommandArgument<C, net.minecraft.commands.arguments.EntityAnchorArgument.Anchor> {
|
||||
|
||||
EntityAnchorArgument(
|
||||
final boolean required,
|
||||
|
|
@ -52,9 +51,9 @@ public final class EntityAnchorArgument<C> extends CommandArgument<C, EntityAnch
|
|||
super(
|
||||
required,
|
||||
name,
|
||||
new WrappedBrigadierParser<>(EntityAnchorArgumentType.entityAnchor()),
|
||||
new WrappedBrigadierParser<>(net.minecraft.commands.arguments.EntityAnchorArgument.anchor()),
|
||||
defaultValue,
|
||||
EntityAnchorArgumentType.EntityAnchor.class,
|
||||
net.minecraft.commands.arguments.EntityAnchorArgument.Anchor.class,
|
||||
suggestionsProvider,
|
||||
defaultDescription
|
||||
);
|
||||
|
|
@ -107,7 +106,7 @@ public final class EntityAnchorArgument<C> extends CommandArgument<C, EntityAnch
|
|||
*/
|
||||
public static <C> @NonNull EntityAnchorArgument<C> optional(
|
||||
final @NonNull String name,
|
||||
final EntityAnchorArgumentType.@NonNull EntityAnchor defaultValue
|
||||
final net.minecraft.commands.arguments.EntityAnchorArgument.@NonNull Anchor defaultValue
|
||||
) {
|
||||
return EntityAnchorArgument.<C>builder(name).asOptionalWithDefault(defaultValue).build();
|
||||
}
|
||||
|
|
@ -119,10 +118,10 @@ public final class EntityAnchorArgument<C> extends CommandArgument<C, EntityAnch
|
|||
* @param <C> sender type
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static final class Builder<C> extends TypedBuilder<C, EntityAnchorArgumentType.EntityAnchor, Builder<C>> {
|
||||
public static final class Builder<C> extends TypedBuilder<C, net.minecraft.commands.arguments.EntityAnchorArgument.Anchor, Builder<C>> {
|
||||
|
||||
Builder(final @NonNull String name) {
|
||||
super(EntityAnchorArgumentType.EntityAnchor.class, name);
|
||||
super(net.minecraft.commands.arguments.EntityAnchorArgument.Anchor.class, name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -150,7 +149,7 @@ public final class EntityAnchorArgument<C> extends CommandArgument<C, EntityAnch
|
|||
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final EntityAnchorArgumentType.@NonNull EntityAnchor defaultValue) {
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final net.minecraft.commands.arguments.EntityAnchorArgument.@NonNull Anchor defaultValue) {
|
||||
return this.asOptionalWithDefault(defaultValue.name());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,25 +36,24 @@ import cloud.commandframework.fabric.data.MultiplePlayerSelector;
|
|||
import cloud.commandframework.fabric.data.SingleEntitySelector;
|
||||
import cloud.commandframework.fabric.data.SinglePlayerSelector;
|
||||
import cloud.commandframework.fabric.internal.EntitySelectorAccess;
|
||||
import cloud.commandframework.fabric.mixin.MessageArgumentTypeMessageFormatAccess;
|
||||
import cloud.commandframework.fabric.mixin.MessageArgumentTypeMessageSelectorAccess;
|
||||
import cloud.commandframework.fabric.mixin.MessageArgumentMessageAccess;
|
||||
import cloud.commandframework.fabric.mixin.MessageArgumentPartAccess;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.command.EntitySelector;
|
||||
import net.minecraft.command.argument.BlockPosArgumentType;
|
||||
import net.minecraft.command.argument.ColumnPosArgumentType;
|
||||
import net.minecraft.command.argument.EntityArgumentType;
|
||||
import net.minecraft.command.argument.MessageArgumentType;
|
||||
import net.minecraft.command.argument.PosArgument;
|
||||
import net.minecraft.command.argument.TimeArgumentType;
|
||||
import net.minecraft.command.argument.Vec2ArgumentType;
|
||||
import net.minecraft.command.argument.Vec3ArgumentType;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
import net.minecraft.commands.arguments.MessageArgument;
|
||||
import net.minecraft.commands.arguments.TimeArgument;
|
||||
import net.minecraft.commands.arguments.coordinates.BlockPosArgument;
|
||||
import net.minecraft.commands.arguments.coordinates.ColumnPosArgument;
|
||||
import net.minecraft.commands.arguments.coordinates.Vec2Argument;
|
||||
import net.minecraft.commands.arguments.coordinates.Vec3Argument;
|
||||
import net.minecraft.commands.arguments.selector.EntitySelector;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Collection;
|
||||
|
|
@ -80,7 +79,7 @@ public final class FabricArgumentParsers {
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull ArgumentParser<C, MinecraftTime> time() {
|
||||
return new WrappedBrigadierParser<C, Integer>(TimeArgumentType.time())
|
||||
return new WrappedBrigadierParser<C, Integer>(TimeArgument.time())
|
||||
.map((ctx, val) -> ArgumentParseResult.success(MinecraftTime.of(val)));
|
||||
}
|
||||
|
||||
|
|
@ -91,7 +90,7 @@ public final class FabricArgumentParsers {
|
|||
* @return a parser instance
|
||||
*/
|
||||
public static <C> @NonNull ArgumentParser<C, Coordinates.BlockCoordinates> blockPos() {
|
||||
return new WrappedBrigadierParser<C, PosArgument>(BlockPosArgumentType.blockPos())
|
||||
return new WrappedBrigadierParser<C, net.minecraft.commands.arguments.coordinates.Coordinates>(BlockPosArgument.blockPos())
|
||||
.map(FabricArgumentParsers::mapToCoordinates);
|
||||
}
|
||||
|
||||
|
|
@ -102,7 +101,7 @@ public final class FabricArgumentParsers {
|
|||
* @return a parser instance
|
||||
*/
|
||||
public static <C> @NonNull ArgumentParser<C, Coordinates.ColumnCoordinates> columnPos() {
|
||||
return new WrappedBrigadierParser<C, PosArgument>(ColumnPosArgumentType.columnPos())
|
||||
return new WrappedBrigadierParser<C, net.minecraft.commands.arguments.coordinates.Coordinates>(ColumnPosArgument.columnPos())
|
||||
.map(FabricArgumentParsers::mapToCoordinates);
|
||||
}
|
||||
|
||||
|
|
@ -115,7 +114,7 @@ public final class FabricArgumentParsers {
|
|||
* @return a parser instance
|
||||
*/
|
||||
public static <C> @NonNull ArgumentParser<C, Coordinates.CoordinatesXZ> vec2(final boolean centerIntegers) {
|
||||
return new WrappedBrigadierParser<C, PosArgument>(new Vec2ArgumentType(centerIntegers))
|
||||
return new WrappedBrigadierParser<C, net.minecraft.commands.arguments.coordinates.Coordinates>(new Vec2Argument(centerIntegers))
|
||||
.map(FabricArgumentParsers::mapToCoordinates);
|
||||
}
|
||||
|
||||
|
|
@ -127,14 +126,14 @@ public final class FabricArgumentParsers {
|
|||
* @return a parser instance
|
||||
*/
|
||||
public static <C> @NonNull ArgumentParser<C, Coordinates> vec3(final boolean centerIntegers) {
|
||||
return new WrappedBrigadierParser<C, PosArgument>(Vec3ArgumentType.vec3(centerIntegers))
|
||||
return new WrappedBrigadierParser<C, net.minecraft.commands.arguments.coordinates.Coordinates>(Vec3Argument.vec3(centerIntegers))
|
||||
.map(FabricArgumentParsers::mapToCoordinates);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <C, O extends Coordinates> @NonNull ArgumentParseResult<@NonNull O> mapToCoordinates(
|
||||
final @NonNull CommandContext<C> ctx,
|
||||
final @NonNull PosArgument posArgument
|
||||
final net.minecraft.commands.arguments.coordinates.@NonNull Coordinates posArgument
|
||||
) {
|
||||
return requireServerCommandSource(
|
||||
ctx,
|
||||
|
|
@ -153,14 +152,14 @@ public final class FabricArgumentParsers {
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull ArgumentParser<C, SinglePlayerSelector> singlePlayerSelector() {
|
||||
return new WrappedBrigadierParser<C, EntitySelector>(EntityArgumentType.player())
|
||||
return new WrappedBrigadierParser<C, EntitySelector>(EntityArgument.player())
|
||||
.map((ctx, entitySelector) -> requireServerCommandSource(
|
||||
ctx,
|
||||
serverCommandSource -> handleCommandSyntaxExceptionAsFailure(
|
||||
() -> ArgumentParseResult.success(new SinglePlayerSelectorImpl(
|
||||
((EntitySelectorAccess) entitySelector).inputString(),
|
||||
entitySelector,
|
||||
entitySelector.getPlayer(serverCommandSource)
|
||||
entitySelector.findSinglePlayer(serverCommandSource)
|
||||
))
|
||||
)
|
||||
));
|
||||
|
|
@ -174,14 +173,14 @@ public final class FabricArgumentParsers {
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull ArgumentParser<C, MultiplePlayerSelector> multiplePlayerSelector() {
|
||||
return new WrappedBrigadierParser<C, EntitySelector>(EntityArgumentType.players())
|
||||
return new WrappedBrigadierParser<C, EntitySelector>(EntityArgument.players())
|
||||
.map((ctx, entitySelector) -> requireServerCommandSource(
|
||||
ctx,
|
||||
serverCommandSource -> handleCommandSyntaxExceptionAsFailure(
|
||||
() -> ArgumentParseResult.success(new MultiplePlayerSelectorImpl(
|
||||
((EntitySelectorAccess) entitySelector).inputString(),
|
||||
entitySelector,
|
||||
entitySelector.getPlayers(serverCommandSource)
|
||||
entitySelector.findPlayers(serverCommandSource)
|
||||
))
|
||||
)
|
||||
));
|
||||
|
|
@ -195,14 +194,14 @@ public final class FabricArgumentParsers {
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull ArgumentParser<C, SingleEntitySelector> singleEntitySelector() {
|
||||
return new WrappedBrigadierParser<C, EntitySelector>(EntityArgumentType.entity())
|
||||
return new WrappedBrigadierParser<C, EntitySelector>(EntityArgument.entity())
|
||||
.map((ctx, entitySelector) -> requireServerCommandSource(
|
||||
ctx,
|
||||
serverCommandSource -> handleCommandSyntaxExceptionAsFailure(
|
||||
() -> ArgumentParseResult.success(new SingleEntitySelectorImpl(
|
||||
((EntitySelectorAccess) entitySelector).inputString(),
|
||||
entitySelector,
|
||||
entitySelector.getEntity(serverCommandSource)
|
||||
entitySelector.findSingleEntity(serverCommandSource)
|
||||
))
|
||||
)
|
||||
));
|
||||
|
|
@ -216,14 +215,14 @@ public final class FabricArgumentParsers {
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull ArgumentParser<C, MultipleEntitySelector> multipleEntitySelector() {
|
||||
return new WrappedBrigadierParser<C, EntitySelector>(EntityArgumentType.entities())
|
||||
return new WrappedBrigadierParser<C, EntitySelector>(EntityArgument.entities())
|
||||
.map((ctx, entitySelector) -> requireServerCommandSource(
|
||||
ctx,
|
||||
serverCommandSource -> handleCommandSyntaxExceptionAsFailure(
|
||||
() -> ArgumentParseResult.success(new MultipleEntitySelectorImpl(
|
||||
((EntitySelectorAccess) entitySelector).inputString(),
|
||||
entitySelector,
|
||||
Collections.unmodifiableCollection(entitySelector.getEntities(serverCommandSource))
|
||||
Collections.unmodifiableCollection(entitySelector.findEntities(serverCommandSource))
|
||||
))
|
||||
)
|
||||
));
|
||||
|
|
@ -237,7 +236,7 @@ public final class FabricArgumentParsers {
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull ArgumentParser<C, Message> message() {
|
||||
return new WrappedBrigadierParser<C, MessageArgumentType.MessageFormat>(MessageArgumentType.message())
|
||||
return new WrappedBrigadierParser<C, MessageArgument.Message>(MessageArgument.message())
|
||||
.map((ctx, format) -> requireServerCommandSource(
|
||||
ctx,
|
||||
serverCommandSource -> handleCommandSyntaxExceptionAsFailure(
|
||||
|
|
@ -273,44 +272,44 @@ public final class FabricArgumentParsers {
|
|||
|
||||
private static <C, O> @NonNull ArgumentParseResult<O> requireServerCommandSource(
|
||||
final @NonNull CommandContext<C> context,
|
||||
final @NonNull Function<ServerCommandSource, ArgumentParseResult<O>> resultFunction
|
||||
final @NonNull Function<CommandSourceStack, ArgumentParseResult<O>> resultFunction
|
||||
) {
|
||||
final CommandSource nativeSource = context.get(FabricCommandContextKeys.NATIVE_COMMAND_SOURCE);
|
||||
if (!(nativeSource instanceof ServerCommandSource)) {
|
||||
final SharedSuggestionProvider nativeSource = context.get(FabricCommandContextKeys.NATIVE_COMMAND_SOURCE);
|
||||
if (!(nativeSource instanceof CommandSourceStack)) {
|
||||
return ArgumentParseResult.failure(serverOnly());
|
||||
}
|
||||
return resultFunction.apply((ServerCommandSource) nativeSource);
|
||||
return resultFunction.apply((CommandSourceStack) nativeSource);
|
||||
}
|
||||
|
||||
static final class MessageImpl implements Message {
|
||||
|
||||
private final Collection<Entity> mentionedEntities;
|
||||
private final Text contents;
|
||||
private final Component contents;
|
||||
|
||||
static MessageImpl from(
|
||||
final @NonNull ServerCommandSource source,
|
||||
final MessageArgumentType.@NonNull MessageFormat message,
|
||||
final @NonNull CommandSourceStack source,
|
||||
final MessageArgument.@NonNull Message message,
|
||||
final boolean useSelectors
|
||||
) throws CommandSyntaxException {
|
||||
final Text contents = message.format(source, useSelectors);
|
||||
final MessageArgumentType.MessageSelector[] selectors =
|
||||
((MessageArgumentTypeMessageFormatAccess) message).accessor$selectors();
|
||||
final Component contents = message.toComponent(source, useSelectors);
|
||||
final MessageArgument.Part[] selectors =
|
||||
((MessageArgumentMessageAccess) message).accessor$parts();
|
||||
final Collection<Entity> entities;
|
||||
if (!useSelectors || selectors.length == 0) {
|
||||
entities = Collections.emptySet();
|
||||
} else {
|
||||
entities = new HashSet<>();
|
||||
for (final MessageArgumentType.MessageSelector selector : selectors) {
|
||||
entities.addAll(((MessageArgumentTypeMessageSelectorAccess) selector)
|
||||
for (final MessageArgument.Part selector : selectors) {
|
||||
entities.addAll(((MessageArgumentPartAccess) selector)
|
||||
.accessor$selector()
|
||||
.getEntities(source));
|
||||
.findEntities(source));
|
||||
}
|
||||
}
|
||||
|
||||
return new MessageImpl(entities, contents);
|
||||
}
|
||||
|
||||
MessageImpl(final Collection<Entity> mentionedEntities, final Text contents) {
|
||||
MessageImpl(final Collection<Entity> mentionedEntities, final Component contents) {
|
||||
this.mentionedEntities = mentionedEntities;
|
||||
this.contents = contents;
|
||||
}
|
||||
|
|
@ -321,7 +320,7 @@ public final class FabricArgumentParsers {
|
|||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Text getContents() {
|
||||
public @NonNull Component getContents() {
|
||||
return this.contents;
|
||||
}
|
||||
|
||||
|
|
@ -332,17 +331,17 @@ public final class FabricArgumentParsers {
|
|||
Coordinates.BlockCoordinates,
|
||||
Coordinates.ColumnCoordinates {
|
||||
|
||||
private final ServerCommandSource source;
|
||||
private final PosArgument posArgument;
|
||||
private final CommandSourceStack source;
|
||||
private final net.minecraft.commands.arguments.coordinates.Coordinates posArgument;
|
||||
|
||||
CoordinatesImpl(final @NonNull ServerCommandSource source, final @NonNull PosArgument posArgument) {
|
||||
CoordinatesImpl(final @NonNull CommandSourceStack source, final net.minecraft.commands.arguments.coordinates.@NonNull Coordinates posArgument) {
|
||||
this.source = source;
|
||||
this.posArgument = posArgument;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Vec3d position() {
|
||||
return this.posArgument.toAbsolutePos(this.source);
|
||||
public @NonNull Vec3 position() {
|
||||
return this.posArgument.getPosition(this.source);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -366,7 +365,7 @@ public final class FabricArgumentParsers {
|
|||
}
|
||||
|
||||
@Override
|
||||
public @NonNull PosArgument wrappedCoordinates() {
|
||||
public net.minecraft.commands.arguments.coordinates.@NonNull Coordinates wrappedCoordinates() {
|
||||
return this.posArgument;
|
||||
}
|
||||
|
||||
|
|
@ -442,12 +441,12 @@ public final class FabricArgumentParsers {
|
|||
|
||||
private final String inputString;
|
||||
private final EntitySelector entitySelector;
|
||||
private final ServerPlayerEntity selectedPlayer;
|
||||
private final ServerPlayer selectedPlayer;
|
||||
|
||||
SinglePlayerSelectorImpl(
|
||||
final @NonNull String inputString,
|
||||
final @NonNull EntitySelector entitySelector,
|
||||
final @NonNull ServerPlayerEntity selectedPlayer
|
||||
final @NonNull ServerPlayer selectedPlayer
|
||||
) {
|
||||
this.inputString = inputString;
|
||||
this.entitySelector = entitySelector;
|
||||
|
|
@ -465,7 +464,7 @@ public final class FabricArgumentParsers {
|
|||
}
|
||||
|
||||
@Override
|
||||
public @NonNull ServerPlayerEntity getSingle() {
|
||||
public @NonNull ServerPlayer getSingle() {
|
||||
return this.selectedPlayer;
|
||||
}
|
||||
|
||||
|
|
@ -475,12 +474,12 @@ public final class FabricArgumentParsers {
|
|||
|
||||
private final String inputString;
|
||||
private final EntitySelector entitySelector;
|
||||
private final Collection<ServerPlayerEntity> selectedPlayers;
|
||||
private final Collection<ServerPlayer> selectedPlayers;
|
||||
|
||||
MultiplePlayerSelectorImpl(
|
||||
final @NonNull String inputString,
|
||||
final @NonNull EntitySelector entitySelector,
|
||||
final @NonNull Collection<ServerPlayerEntity> selectedPlayers
|
||||
final @NonNull Collection<ServerPlayer> selectedPlayers
|
||||
) {
|
||||
this.inputString = inputString;
|
||||
this.entitySelector = entitySelector;
|
||||
|
|
@ -498,7 +497,7 @@ public final class FabricArgumentParsers {
|
|||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Collection<ServerPlayerEntity> get() {
|
||||
public @NonNull Collection<ServerPlayer> get() {
|
||||
return this.selectedPlayers;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ import cloud.commandframework.ArgumentDescription;
|
|||
import cloud.commandframework.arguments.CommandArgument;
|
||||
import cloud.commandframework.brigadier.argument.WrappedBrigadierParser;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import net.minecraft.command.argument.NumberRangeArgumentType;
|
||||
import net.minecraft.predicate.NumberRange;
|
||||
import net.minecraft.advancements.critereon.MinMaxBounds;
|
||||
import net.minecraft.commands.arguments.RangeArgument;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
|
|
@ -36,13 +36,13 @@ import java.util.List;
|
|||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* An argument parsing an unbounded {@link net.minecraft.predicate.NumberRange.FloatRange float range}, in the form
|
||||
* An argument parsing an unbounded {@link net.minecraft.advancements.critereon.MinMaxBounds.Floats 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
|
||||
*/
|
||||
public final class FloatRangeArgument<C> extends CommandArgument<C, NumberRange.FloatRange> {
|
||||
public final class FloatRangeArgument<C> extends CommandArgument<C, MinMaxBounds.Floats> {
|
||||
|
||||
FloatRangeArgument(
|
||||
final boolean required,
|
||||
|
|
@ -54,9 +54,9 @@ public final class FloatRangeArgument<C> extends CommandArgument<C, NumberRange.
|
|||
super(
|
||||
required,
|
||||
name,
|
||||
new WrappedBrigadierParser<>(NumberRangeArgumentType.method_30918()),
|
||||
new WrappedBrigadierParser<>(RangeArgument.floatRange()),
|
||||
defaultValue,
|
||||
NumberRange.FloatRange.class,
|
||||
MinMaxBounds.Floats.class,
|
||||
suggestionsProvider,
|
||||
defaultDescription
|
||||
);
|
||||
|
|
@ -109,7 +109,7 @@ public final class FloatRangeArgument<C> extends CommandArgument<C, NumberRange.
|
|||
*/
|
||||
public static <C> @NonNull FloatRangeArgument<C> optional(
|
||||
final @NonNull String name,
|
||||
final NumberRange.@NonNull FloatRange defaultValue
|
||||
final MinMaxBounds.@NonNull Floats defaultValue
|
||||
) {
|
||||
return FloatRangeArgument.<C>builder(name).asOptionalWithDefault(defaultValue).build();
|
||||
}
|
||||
|
|
@ -121,10 +121,10 @@ public final class FloatRangeArgument<C> extends CommandArgument<C, NumberRange.
|
|||
* @param <C> sender type
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static final class Builder<C> extends TypedBuilder<C, NumberRange.FloatRange, Builder<C>> {
|
||||
public static final class Builder<C> extends TypedBuilder<C, MinMaxBounds.Floats, Builder<C>> {
|
||||
|
||||
Builder(final @NonNull String name) {
|
||||
super(NumberRange.FloatRange.class, name);
|
||||
super(MinMaxBounds.Floats.class, name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -152,7 +152,7 @@ public final class FloatRangeArgument<C> extends CommandArgument<C, NumberRange.
|
|||
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final NumberRange.@NonNull FloatRange defaultValue) {
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final MinMaxBounds.@NonNull Floats defaultValue) {
|
||||
final StringBuilder value = new StringBuilder(6);
|
||||
if (defaultValue.getMin() != null) {
|
||||
value.append(defaultValue.getMin());
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ import cloud.commandframework.ArgumentDescription;
|
|||
import cloud.commandframework.arguments.CommandArgument;
|
||||
import cloud.commandframework.brigadier.argument.WrappedBrigadierParser;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import net.minecraft.command.argument.NumberRangeArgumentType;
|
||||
import net.minecraft.predicate.NumberRange;
|
||||
import net.minecraft.advancements.critereon.MinMaxBounds;
|
||||
import net.minecraft.commands.arguments.RangeArgument;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
|
|
@ -36,13 +36,13 @@ import java.util.List;
|
|||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* An argument parsing an unbounded {@link net.minecraft.predicate.NumberRange.IntRange integer range}, in the form
|
||||
* An argument parsing an unbounded {@link net.minecraft.advancements.critereon.MinMaxBounds.Ints 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
|
||||
*/
|
||||
public final class IntRangeArgument<C> extends CommandArgument<C, NumberRange.IntRange> {
|
||||
public final class IntRangeArgument<C> extends CommandArgument<C, MinMaxBounds.Ints> {
|
||||
|
||||
IntRangeArgument(
|
||||
final boolean required,
|
||||
|
|
@ -54,9 +54,9 @@ public final class IntRangeArgument<C> extends CommandArgument<C, NumberRange.In
|
|||
super(
|
||||
required,
|
||||
name,
|
||||
new WrappedBrigadierParser<>(NumberRangeArgumentType.numberRange()),
|
||||
new WrappedBrigadierParser<>(RangeArgument.intRange()),
|
||||
defaultValue,
|
||||
NumberRange.IntRange.class,
|
||||
MinMaxBounds.Ints.class,
|
||||
suggestionsProvider,
|
||||
defaultDescription
|
||||
);
|
||||
|
|
@ -109,7 +109,7 @@ public final class IntRangeArgument<C> extends CommandArgument<C, NumberRange.In
|
|||
*/
|
||||
public static <C> @NonNull IntRangeArgument<C> optional(
|
||||
final @NonNull String name,
|
||||
final NumberRange.@NonNull IntRange defaultValue
|
||||
final MinMaxBounds.@NonNull Ints defaultValue
|
||||
) {
|
||||
return IntRangeArgument.<C>builder(name).asOptionalWithDefault(defaultValue).build();
|
||||
}
|
||||
|
|
@ -121,10 +121,10 @@ public final class IntRangeArgument<C> extends CommandArgument<C, NumberRange.In
|
|||
* @param <C> sender type
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static final class Builder<C> extends TypedBuilder<C, NumberRange.IntRange, Builder<C>> {
|
||||
public static final class Builder<C> extends TypedBuilder<C, MinMaxBounds.Ints, Builder<C>> {
|
||||
|
||||
Builder(final @NonNull String name) {
|
||||
super(NumberRange.IntRange.class, name);
|
||||
super(MinMaxBounds.Ints.class, name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -152,7 +152,7 @@ public final class IntRangeArgument<C> extends CommandArgument<C, NumberRange.In
|
|||
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final NumberRange.@NonNull IntRange defaultValue) {
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final MinMaxBounds.@NonNull Ints defaultValue) {
|
||||
final StringBuilder value = new StringBuilder(6);
|
||||
if (defaultValue.getMin() != null) {
|
||||
value.append(defaultValue.getMin());
|
||||
|
|
|
|||
|
|
@ -27,10 +27,10 @@ import cloud.commandframework.ArgumentDescription;
|
|||
import cloud.commandframework.arguments.CommandArgument;
|
||||
import cloud.commandframework.brigadier.argument.WrappedBrigadierParser;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import net.minecraft.command.argument.ItemStackArgument;
|
||||
import net.minecraft.command.argument.ItemStackArgumentType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.commands.arguments.item.ItemArgument;
|
||||
import net.minecraft.commands.arguments.item.ItemInput;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
|
|
@ -38,14 +38,14 @@ import java.util.List;
|
|||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* An argument parsing an item identifier and optional extra NBT data into an {@link ItemStackArgument}.
|
||||
* An argument parsing an item identifier and optional extra NBT data into an {@link ItemInput}.
|
||||
*
|
||||
* @param <C> the sender type
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public final class ItemDataArgument<C> extends CommandArgument<C, ItemStackArgument> {
|
||||
public final class ItemInputArgument<C> extends CommandArgument<C, ItemInput> {
|
||||
|
||||
ItemDataArgument(
|
||||
ItemInputArgument(
|
||||
final boolean required,
|
||||
final @NonNull String name,
|
||||
final @NonNull String defaultValue,
|
||||
|
|
@ -55,9 +55,9 @@ public final class ItemDataArgument<C> extends CommandArgument<C, ItemStackArgum
|
|||
super(
|
||||
required,
|
||||
name,
|
||||
new WrappedBrigadierParser<>(ItemStackArgumentType.itemStack()),
|
||||
new WrappedBrigadierParser<>(ItemArgument.item()),
|
||||
defaultValue,
|
||||
ItemStackArgument.class,
|
||||
ItemInput.class,
|
||||
suggestionsProvider,
|
||||
defaultDescription
|
||||
);
|
||||
|
|
@ -76,31 +76,31 @@ public final class ItemDataArgument<C> extends CommandArgument<C, ItemStackArgum
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new required {@link ItemDataArgument}.
|
||||
* Create a new required {@link ItemInputArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
* @return Created argument
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull ItemDataArgument<C> of(final @NonNull String name) {
|
||||
return ItemDataArgument.<C>builder(name).asRequired().build();
|
||||
public static <C> @NonNull ItemInputArgument<C> of(final @NonNull String name) {
|
||||
return ItemInputArgument.<C>builder(name).asRequired().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional {@link ItemDataArgument}.
|
||||
* Create a new optional {@link ItemInputArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
* @return Created argument
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull ItemDataArgument<C> optional(final @NonNull String name) {
|
||||
return ItemDataArgument.<C>builder(name).asOptional().build();
|
||||
public static <C> @NonNull ItemInputArgument<C> optional(final @NonNull String name) {
|
||||
return ItemInputArgument.<C>builder(name).asOptional().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional {@link ItemDataArgument} with the specified default value.
|
||||
* Create a new optional {@link ItemInputArgument} with the specified default value.
|
||||
*
|
||||
* @param name Argument name
|
||||
* @param defaultValue Default value
|
||||
|
|
@ -108,31 +108,31 @@ 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) {
|
||||
return ItemDataArgument.<C>builder(name).asOptionalWithDefault(defaultValue).build();
|
||||
public static <C> @NonNull ItemInputArgument<C> optional(final @NonNull String name, final @NonNull ItemStack defaultValue) {
|
||||
return ItemInputArgument.<C>builder(name).asOptionalWithDefault(defaultValue).build();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Builder for {@link ItemDataArgument}.
|
||||
* Builder for {@link ItemInputArgument}.
|
||||
*
|
||||
* @param <C> sender type
|
||||
*/
|
||||
public static final class Builder<C> extends TypedBuilder<C, ItemStackArgument, Builder<C>> {
|
||||
public static final class Builder<C> extends TypedBuilder<C, ItemInput, Builder<C>> {
|
||||
|
||||
Builder(final @NonNull String name) {
|
||||
super(ItemStackArgument.class, name);
|
||||
super(ItemInput.class, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a new {@link ItemDataArgument}.
|
||||
* Build a new {@link ItemInputArgument}.
|
||||
*
|
||||
* @return Constructed argument
|
||||
* @since 1.5.0
|
||||
*/
|
||||
@Override
|
||||
public @NonNull ItemDataArgument<C> build() {
|
||||
return new ItemDataArgument<>(
|
||||
public @NonNull ItemInputArgument<C> build() {
|
||||
return new ItemInputArgument<>(
|
||||
this.isRequired(),
|
||||
this.getName(),
|
||||
this.getDefaultValue(),
|
||||
|
|
@ -152,9 +152,9 @@ public final class ItemDataArgument<C> extends CommandArgument<C, ItemStackArgum
|
|||
public @NonNull Builder<C> asOptionalWithDefault(final @NonNull ItemStack defaultValue) {
|
||||
final String serializedDefault;
|
||||
if (defaultValue.hasTag()) {
|
||||
serializedDefault = Registry.ITEM.getId(defaultValue.getItem()) + defaultValue.getTag().toString();
|
||||
serializedDefault = Registry.ITEM.getKey(defaultValue.getItem()) + defaultValue.getTag().toString();
|
||||
} else {
|
||||
serializedDefault = Registry.ITEM.getId(defaultValue.getItem()).toString();
|
||||
serializedDefault = Registry.ITEM.getKey(defaultValue.getItem()).toString();
|
||||
}
|
||||
return this.asOptionalWithDefault(serializedDefault);
|
||||
}
|
||||
|
|
@ -27,9 +27,8 @@ import cloud.commandframework.ArgumentDescription;
|
|||
import cloud.commandframework.arguments.CommandArgument;
|
||||
import cloud.commandframework.brigadier.argument.WrappedBrigadierParser;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import net.minecraft.command.argument.MobEffectArgumentType;
|
||||
import net.minecraft.entity.effect.StatusEffect;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
|
|
@ -37,14 +36,14 @@ import java.util.List;
|
|||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* An argument parsing a status effect from the {@link net.minecraft.util.registry.Registry#STATUS_EFFECT status effect registry}.
|
||||
* An argument parsing a status effect from the {@link net.minecraft.core.Registry#MOB_EFFECT status effect registry}.
|
||||
*
|
||||
* @param <C> the sender type
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public final class StatusEffectArgument<C> extends CommandArgument<C, StatusEffect> {
|
||||
public final class MobEffectArgument<C> extends CommandArgument<C, MobEffect> {
|
||||
|
||||
StatusEffectArgument(
|
||||
MobEffectArgument(
|
||||
final boolean required,
|
||||
final @NonNull String name,
|
||||
final @NonNull String defaultValue,
|
||||
|
|
@ -54,9 +53,9 @@ public final class StatusEffectArgument<C> extends CommandArgument<C, StatusEffe
|
|||
super(
|
||||
required,
|
||||
name,
|
||||
new WrappedBrigadierParser<>(MobEffectArgumentType.mobEffect()),
|
||||
new WrappedBrigadierParser<>(net.minecraft.commands.arguments.MobEffectArgument.effect()),
|
||||
defaultValue,
|
||||
StatusEffect.class,
|
||||
MobEffect.class,
|
||||
suggestionsProvider,
|
||||
defaultDescription
|
||||
);
|
||||
|
|
@ -71,35 +70,35 @@ public final class StatusEffectArgument<C> extends CommandArgument<C, StatusEffe
|
|||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull Builder<C> builder(final @NonNull String name) {
|
||||
return new StatusEffectArgument.Builder<>(name);
|
||||
return new MobEffectArgument.Builder<>(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new required {@link StatusEffectArgument}.
|
||||
* Create a new required {@link MobEffectArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
* @return Created argument
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull StatusEffectArgument<C> of(final @NonNull String name) {
|
||||
return StatusEffectArgument.<C>builder(name).asRequired().build();
|
||||
public static <C> @NonNull MobEffectArgument<C> of(final @NonNull String name) {
|
||||
return MobEffectArgument.<C>builder(name).asRequired().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional {@link StatusEffectArgument}.
|
||||
* Create a new optional {@link MobEffectArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
* @return Created argument
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull StatusEffectArgument<C> optional(final @NonNull String name) {
|
||||
return StatusEffectArgument.<C>builder(name).asOptional().build();
|
||||
public static <C> @NonNull MobEffectArgument<C> optional(final @NonNull String name) {
|
||||
return MobEffectArgument.<C>builder(name).asOptional().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional {@link StatusEffectArgument} with the specified default value.
|
||||
* Create a new optional {@link MobEffectArgument} with the specified default value.
|
||||
*
|
||||
* @param name Argument name
|
||||
* @param defaultValue Default value
|
||||
|
|
@ -107,35 +106,35 @@ public final class StatusEffectArgument<C> extends CommandArgument<C, StatusEffe
|
|||
* @return Created argument
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull StatusEffectArgument<C> optional(
|
||||
public static <C> @NonNull MobEffectArgument<C> optional(
|
||||
final @NonNull String name,
|
||||
final @NonNull StatusEffect defaultValue
|
||||
final @NonNull MobEffect defaultValue
|
||||
) {
|
||||
return StatusEffectArgument.<C>builder(name).asOptionalWithDefault(defaultValue).build();
|
||||
return MobEffectArgument.<C>builder(name).asOptionalWithDefault(defaultValue).build();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Builder for {@link StatusEffectArgument}.
|
||||
* Builder for {@link MobEffectArgument}.
|
||||
*
|
||||
* @param <C> sender type
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static final class Builder<C> extends TypedBuilder<C, StatusEffect, Builder<C>> {
|
||||
public static final class Builder<C> extends TypedBuilder<C, MobEffect, Builder<C>> {
|
||||
|
||||
Builder(final @NonNull String name) {
|
||||
super(StatusEffect.class, name);
|
||||
super(MobEffect.class, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a new {@link StatusEffectArgument}.
|
||||
* Build a new {@link MobEffectArgument}.
|
||||
*
|
||||
* @return Constructed argument
|
||||
* @since 1.5.0
|
||||
*/
|
||||
@Override
|
||||
public @NonNull StatusEffectArgument<C> build() {
|
||||
return new StatusEffectArgument<>(
|
||||
public @NonNull MobEffectArgument<C> build() {
|
||||
return new MobEffectArgument<>(
|
||||
this.isRequired(),
|
||||
this.getName(),
|
||||
this.getDefaultValue(),
|
||||
|
|
@ -152,8 +151,8 @@ public final class StatusEffectArgument<C> extends CommandArgument<C, StatusEffe
|
|||
* @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());
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final @NonNull MobEffect defaultValue) {
|
||||
return this.asOptionalWithDefault(Registry.MOB_EFFECT.getKey(defaultValue).toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -27,8 +27,7 @@ import cloud.commandframework.ArgumentDescription;
|
|||
import cloud.commandframework.arguments.CommandArgument;
|
||||
import cloud.commandframework.brigadier.argument.WrappedBrigadierParser;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import net.minecraft.command.argument.ColorArgumentType;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
|
|
@ -36,14 +35,14 @@ import java.util.List;
|
|||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* An argument for named colors in the {@link Formatting} enum.
|
||||
* An argument for named colors in the {@link ChatFormatting} enum.
|
||||
*
|
||||
* @param <C> the sender type
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public final class ColorArgument<C> extends CommandArgument<C, Formatting> {
|
||||
public final class NamedColorArgument<C> extends CommandArgument<C, ChatFormatting> {
|
||||
|
||||
ColorArgument(
|
||||
NamedColorArgument(
|
||||
final boolean required,
|
||||
final @NonNull String name,
|
||||
final @NonNull String defaultValue,
|
||||
|
|
@ -53,16 +52,16 @@ public final class ColorArgument<C> extends CommandArgument<C, Formatting> {
|
|||
super(
|
||||
required,
|
||||
name,
|
||||
new WrappedBrigadierParser<>(ColorArgumentType.color()),
|
||||
new WrappedBrigadierParser<>(net.minecraft.commands.arguments.ColorArgument.color()),
|
||||
defaultValue,
|
||||
Formatting.class,
|
||||
ChatFormatting.class,
|
||||
suggestionsProvider,
|
||||
defaultDescription
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link Builder}.
|
||||
* Create a new {@link NamedColorArgument.Builder}.
|
||||
*
|
||||
* @param name Name of the component
|
||||
* @param <C> Command sender type
|
||||
|
|
@ -74,67 +73,67 @@ public final class ColorArgument<C> extends CommandArgument<C, Formatting> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new required {@link ColorArgument}.
|
||||
* Create a new required {@link NamedColorArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
* @return Created component
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull ColorArgument<C> of(final @NonNull String name) {
|
||||
return ColorArgument.<C>builder(name).asRequired().build();
|
||||
public static <C> @NonNull NamedColorArgument<C> of(final @NonNull String name) {
|
||||
return NamedColorArgument.<C>builder(name).asRequired().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional {@link ColorArgument}.
|
||||
* Create a new optional {@link NamedColorArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
* @return Created component
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull ColorArgument<C> optional(final @NonNull String name) {
|
||||
return ColorArgument.<C>builder(name).asOptional().build();
|
||||
public static <C> @NonNull NamedColorArgument<C> optional(final @NonNull String name) {
|
||||
return NamedColorArgument.<C>builder(name).asOptional().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional {@link ColorArgument} with the specified default value.
|
||||
* Create a new optional {@link NamedColorArgument} with the specified default value.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param defaultColor Default colour, must be {@link Formatting#isColor() a color}
|
||||
* @param defaultColor Default colour, must be {@link ChatFormatting#isColor() a color}
|
||||
* @param <C> Command sender type
|
||||
* @return Created component
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull ColorArgument<C> optional(
|
||||
public static <C> @NonNull NamedColorArgument<C> optional(
|
||||
final @NonNull String name,
|
||||
final @NonNull Formatting defaultColor
|
||||
final @NonNull ChatFormatting defaultColor
|
||||
) {
|
||||
return ColorArgument.<C>builder(name).asOptionalWithDefault(defaultColor).build();
|
||||
return NamedColorArgument.<C>builder(name).asOptionalWithDefault(defaultColor).build();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Builder for {@link ColorArgument}.
|
||||
* Builder for {@link NamedColorArgument}.
|
||||
*
|
||||
* @param <C> sender type
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static final class Builder<C> extends CommandArgument.TypedBuilder<C, Formatting, Builder<C>> {
|
||||
public static final class Builder<C> extends CommandArgument.TypedBuilder<C, ChatFormatting, Builder<C>> {
|
||||
|
||||
Builder(final @NonNull String name) {
|
||||
super(Formatting.class, name);
|
||||
super(ChatFormatting.class, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a new {@link ColorArgument}.
|
||||
* Build a new {@link NamedColorArgument}.
|
||||
*
|
||||
* @return Constructed argument
|
||||
* @since 1.5.0
|
||||
*/
|
||||
@Override
|
||||
public @NonNull ColorArgument<C> build() {
|
||||
return new ColorArgument<>(
|
||||
public @NonNull NamedColorArgument<C> build() {
|
||||
return new NamedColorArgument<>(
|
||||
this.isRequired(),
|
||||
this.getName(),
|
||||
this.getDefaultValue(),
|
||||
|
|
@ -146,12 +145,12 @@ 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}
|
||||
* @param defaultColor default value, must be {@link ChatFormatting#isColor() a color}
|
||||
* @return this builder
|
||||
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final @NonNull Formatting defaultColor) {
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final @NonNull ChatFormatting defaultColor) {
|
||||
if (!defaultColor.isColor()) {
|
||||
throw new IllegalArgumentException("Only color types are allowed but " + defaultColor + " was provided");
|
||||
}
|
||||
|
|
@ -27,7 +27,6 @@ import cloud.commandframework.ArgumentDescription;
|
|||
import cloud.commandframework.arguments.CommandArgument;
|
||||
import cloud.commandframework.brigadier.argument.WrappedBrigadierParser;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import net.minecraft.command.argument.NbtPathArgumentType;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
|
|
@ -35,13 +34,13 @@ import java.util.List;
|
|||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* An argument for {@link net.minecraft.command.argument.NbtPathArgumentType.NbtPath NBT paths} to locations within
|
||||
* An argument for {@link net.minecraft.commands.arguments.NbtPathArgument.NbtPath NBT paths} to locations within
|
||||
* {@link net.minecraft.nbt.Tag Tags}.
|
||||
*
|
||||
* @param <C> the sender type
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public final class NbtPathArgument<C> extends CommandArgument<C, NbtPathArgumentType.NbtPath> {
|
||||
public final class NbtPathArgument<C> extends CommandArgument<C, net.minecraft.commands.arguments.NbtPathArgument.NbtPath> {
|
||||
|
||||
NbtPathArgument(
|
||||
final boolean required,
|
||||
|
|
@ -53,9 +52,9 @@ public final class NbtPathArgument<C> extends CommandArgument<C, NbtPathArgument
|
|||
super(
|
||||
required,
|
||||
name,
|
||||
new WrappedBrigadierParser<>(NbtPathArgumentType.nbtPath()),
|
||||
new WrappedBrigadierParser<>(net.minecraft.commands.arguments.NbtPathArgument.nbtPath()),
|
||||
defaultValue,
|
||||
NbtPathArgumentType.NbtPath.class,
|
||||
net.minecraft.commands.arguments.NbtPathArgument.NbtPath.class,
|
||||
suggestionsProvider,
|
||||
defaultDescription
|
||||
);
|
||||
|
|
@ -108,7 +107,7 @@ public final class NbtPathArgument<C> extends CommandArgument<C, NbtPathArgument
|
|||
*/
|
||||
public static <C> @NonNull NbtPathArgument<C> optional(
|
||||
final @NonNull String name,
|
||||
final NbtPathArgumentType.@NonNull NbtPath defaultTag
|
||||
final net.minecraft.commands.arguments.NbtPathArgument.@NonNull NbtPath defaultTag
|
||||
) {
|
||||
return NbtPathArgument.<C>builder(name).asOptionalWithDefault(defaultTag).build();
|
||||
}
|
||||
|
|
@ -120,10 +119,10 @@ public final class NbtPathArgument<C> extends CommandArgument<C, NbtPathArgument
|
|||
* @param <C> sender type
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static final class Builder<C> extends TypedBuilder<C, NbtPathArgumentType.NbtPath, Builder<C>> {
|
||||
public static final class Builder<C> extends TypedBuilder<C, net.minecraft.commands.arguments.NbtPathArgument.NbtPath, Builder<C>> {
|
||||
|
||||
Builder(final @NonNull String name) {
|
||||
super(NbtPathArgumentType.NbtPath.class, name);
|
||||
super(net.minecraft.commands.arguments.NbtPathArgument.NbtPath.class, name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -151,7 +150,7 @@ public final class NbtPathArgument<C> extends CommandArgument<C, NbtPathArgument
|
|||
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final NbtPathArgumentType.@NonNull NbtPath defaultValue) {
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final net.minecraft.commands.arguments.NbtPathArgument.@NonNull NbtPath defaultValue) {
|
||||
return this.asOptionalWithDefault(defaultValue.toString());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ import cloud.commandframework.ArgumentDescription;
|
|||
import cloud.commandframework.arguments.CommandArgument;
|
||||
import cloud.commandframework.brigadier.argument.WrappedBrigadierParser;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import net.minecraft.command.argument.NbtTagArgumentType;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
|
@ -53,7 +52,7 @@ public final class NbtTagArgument<C> extends CommandArgument<C, Tag> {
|
|||
super(
|
||||
required,
|
||||
name,
|
||||
new WrappedBrigadierParser<>(NbtTagArgumentType.nbtTag()),
|
||||
new WrappedBrigadierParser<>(net.minecraft.commands.arguments.NbtTagArgument.nbtTag()),
|
||||
defaultValue,
|
||||
Tag.class,
|
||||
suggestionsProvider,
|
||||
|
|
|
|||
|
|
@ -27,8 +27,7 @@ import cloud.commandframework.ArgumentDescription;
|
|||
import cloud.commandframework.arguments.CommandArgument;
|
||||
import cloud.commandframework.brigadier.argument.WrappedBrigadierParser;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import net.minecraft.command.argument.ObjectiveCriteriaArgumentType;
|
||||
import net.minecraft.scoreboard.ScoreboardCriterion;
|
||||
import net.minecraft.world.scores.criteria.ObjectiveCriteria;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
|
|
@ -36,14 +35,14 @@ import java.util.List;
|
|||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* An argument for a {@linkplain ScoreboardCriterion criterion} in a scoreboard.
|
||||
* An argument for a {@linkplain ObjectiveCriteria criterion} in a scoreboard.
|
||||
*
|
||||
* @param <C> the sender type
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public final class ScoreboardCriterionArgument<C> extends CommandArgument<C, ScoreboardCriterion> {
|
||||
public final class ObjectiveCriteriaArgument<C> extends CommandArgument<C, ObjectiveCriteria> {
|
||||
|
||||
ScoreboardCriterionArgument(
|
||||
ObjectiveCriteriaArgument(
|
||||
final boolean required,
|
||||
final @NonNull String name,
|
||||
final @NonNull String defaultValue,
|
||||
|
|
@ -53,9 +52,9 @@ public final class ScoreboardCriterionArgument<C> extends CommandArgument<C, Sco
|
|||
super(
|
||||
required,
|
||||
name,
|
||||
new WrappedBrigadierParser<>(ObjectiveCriteriaArgumentType.objectiveCriteria()),
|
||||
new WrappedBrigadierParser<>(net.minecraft.commands.arguments.ObjectiveCriteriaArgument.criteria()),
|
||||
defaultValue,
|
||||
ScoreboardCriterion.class,
|
||||
ObjectiveCriteria.class,
|
||||
suggestionsProvider,
|
||||
defaultDescription
|
||||
);
|
||||
|
|
@ -74,31 +73,31 @@ public final class ScoreboardCriterionArgument<C> extends CommandArgument<C, Sco
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new required {@link ScoreboardCriterionArgument}.
|
||||
* Create a new required {@link ObjectiveCriteriaArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
* @return Created argument
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull ScoreboardCriterionArgument<C> of(final @NonNull String name) {
|
||||
return ScoreboardCriterionArgument.<C>builder(name).asRequired().build();
|
||||
public static <C> @NonNull ObjectiveCriteriaArgument<C> of(final @NonNull String name) {
|
||||
return ObjectiveCriteriaArgument.<C>builder(name).asRequired().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional {@link ScoreboardCriterionArgument}.
|
||||
* Create a new optional {@link ObjectiveCriteriaArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
* @return Created argument
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull ScoreboardCriterionArgument<C> optional(final @NonNull String name) {
|
||||
return ScoreboardCriterionArgument.<C>builder(name).asOptional().build();
|
||||
public static <C> @NonNull ObjectiveCriteriaArgument<C> optional(final @NonNull String name) {
|
||||
return ObjectiveCriteriaArgument.<C>builder(name).asOptional().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional {@link ScoreboardCriterionArgument} with the specified default value.
|
||||
* Create a new optional {@link ObjectiveCriteriaArgument} with the specified default value.
|
||||
*
|
||||
* @param name Argument name
|
||||
* @param defaultCriterion Default criterion
|
||||
|
|
@ -106,35 +105,35 @@ public final class ScoreboardCriterionArgument<C> extends CommandArgument<C, Sco
|
|||
* @return Created argument
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull ScoreboardCriterionArgument<C> optional(
|
||||
public static <C> @NonNull ObjectiveCriteriaArgument<C> optional(
|
||||
final @NonNull String name,
|
||||
final @NonNull ScoreboardCriterion defaultCriterion
|
||||
final @NonNull ObjectiveCriteria defaultCriterion
|
||||
) {
|
||||
return ScoreboardCriterionArgument.<C>builder(name).asOptionalWithDefault(defaultCriterion).build();
|
||||
return ObjectiveCriteriaArgument.<C>builder(name).asOptionalWithDefault(defaultCriterion).build();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Builder for {@link ScoreboardCriterionArgument}.
|
||||
* Builder for {@link ObjectiveCriteriaArgument}.
|
||||
*
|
||||
* @param <C> sender type
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static final class Builder<C> extends TypedBuilder<C, ScoreboardCriterion, Builder<C>> {
|
||||
public static final class Builder<C> extends TypedBuilder<C, ObjectiveCriteria, Builder<C>> {
|
||||
|
||||
Builder(final @NonNull String name) {
|
||||
super(ScoreboardCriterion.class, name);
|
||||
super(ObjectiveCriteria.class, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a new {@link ScoreboardCriterionArgument}.
|
||||
* Build a new {@link ObjectiveCriteriaArgument}.
|
||||
*
|
||||
* @return Constructed argument
|
||||
* @since 1.5.0
|
||||
*/
|
||||
@Override
|
||||
public @NonNull ScoreboardCriterionArgument<C> build() {
|
||||
return new ScoreboardCriterionArgument<>(
|
||||
public @NonNull ObjectiveCriteriaArgument<C> build() {
|
||||
return new ObjectiveCriteriaArgument<>(
|
||||
this.isRequired(),
|
||||
this.getName(),
|
||||
this.getDefaultValue(),
|
||||
|
|
@ -151,7 +150,7 @@ public final class ScoreboardCriterionArgument<C> extends CommandArgument<C, Sco
|
|||
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final @NonNull ScoreboardCriterion defaultValue) {
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final @NonNull ObjectiveCriteria defaultValue) {
|
||||
return this.asOptionalWithDefault(defaultValue.getName());
|
||||
}
|
||||
|
||||
|
|
@ -27,8 +27,7 @@ import cloud.commandframework.ArgumentDescription;
|
|||
import cloud.commandframework.arguments.CommandArgument;
|
||||
import cloud.commandframework.brigadier.argument.WrappedBrigadierParser;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import net.minecraft.command.argument.ParticleArgumentType;
|
||||
import net.minecraft.particle.ParticleEffect;
|
||||
import net.minecraft.core.particles.ParticleOptions;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
|
|
@ -36,14 +35,14 @@ import java.util.List;
|
|||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* An argument for any {@link net.minecraft.particle.ParticleEffect}.
|
||||
* An argument for any {@link net.minecraft.core.particles.ParticleOptions}.
|
||||
*
|
||||
* @param <C> the sender type
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public final class ParticleEffectArgument<C> extends CommandArgument<C, ParticleEffect> {
|
||||
public final class ParticleArgument<C> extends CommandArgument<C, ParticleOptions> {
|
||||
|
||||
ParticleEffectArgument(
|
||||
ParticleArgument(
|
||||
final boolean required,
|
||||
final @NonNull String name,
|
||||
final @NonNull String defaultValue,
|
||||
|
|
@ -53,9 +52,9 @@ public final class ParticleEffectArgument<C> extends CommandArgument<C, Particle
|
|||
super(
|
||||
required,
|
||||
name,
|
||||
new WrappedBrigadierParser<>(ParticleArgumentType.particle()),
|
||||
new WrappedBrigadierParser<>(net.minecraft.commands.arguments.ParticleArgument.particle()),
|
||||
defaultValue,
|
||||
ParticleEffect.class,
|
||||
ParticleOptions.class,
|
||||
suggestionsProvider,
|
||||
defaultDescription
|
||||
);
|
||||
|
|
@ -74,31 +73,31 @@ public final class ParticleEffectArgument<C> extends CommandArgument<C, Particle
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new required {@link ParticleEffectArgument}.
|
||||
* Create a new required {@link ParticleArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
* @return Created argument
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull ParticleEffectArgument<C> of(final @NonNull String name) {
|
||||
return ParticleEffectArgument.<C>builder(name).asRequired().build();
|
||||
public static <C> @NonNull ParticleArgument<C> of(final @NonNull String name) {
|
||||
return ParticleArgument.<C>builder(name).asRequired().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional {@link ParticleEffectArgument}.
|
||||
* Create a new optional {@link ParticleArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
* @return Created argument
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull ParticleEffectArgument<C> optional(final @NonNull String name) {
|
||||
return ParticleEffectArgument.<C>builder(name).asOptional().build();
|
||||
public static <C> @NonNull ParticleArgument<C> optional(final @NonNull String name) {
|
||||
return ParticleArgument.<C>builder(name).asOptional().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional {@link ParticleEffectArgument} with the specified default value.
|
||||
* Create a new optional {@link ParticleArgument} with the specified default value.
|
||||
*
|
||||
* @param name Argument name
|
||||
* @param defaultValue Default particle effect value
|
||||
|
|
@ -106,24 +105,24 @@ public final class ParticleEffectArgument<C> extends CommandArgument<C, Particle
|
|||
* @return Created argument
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull ParticleEffectArgument<C> optional(
|
||||
public static <C> @NonNull ParticleArgument<C> optional(
|
||||
final @NonNull String name,
|
||||
final @NonNull ParticleEffect defaultValue
|
||||
final @NonNull ParticleOptions defaultValue
|
||||
) {
|
||||
return ParticleEffectArgument.<C>builder(name).asOptionalWithDefault(defaultValue).build();
|
||||
return ParticleArgument.<C>builder(name).asOptionalWithDefault(defaultValue).build();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Builder for {@link ParticleEffectArgument}.
|
||||
* Builder for {@link ParticleArgument}.
|
||||
*
|
||||
* @param <C> sender type
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static final class Builder<C> extends TypedBuilder<C, ParticleEffect, Builder<C>> {
|
||||
public static final class Builder<C> extends TypedBuilder<C, ParticleOptions, Builder<C>> {
|
||||
|
||||
Builder(final @NonNull String name) {
|
||||
super(ParticleEffect.class, name);
|
||||
super(ParticleOptions.class, name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -133,8 +132,8 @@ public final class ParticleEffectArgument<C> extends CommandArgument<C, Particle
|
|||
* @since 1.5.0
|
||||
*/
|
||||
@Override
|
||||
public @NonNull ParticleEffectArgument<C> build() {
|
||||
return new ParticleEffectArgument<>(
|
||||
public @NonNull ParticleArgument<C> build() {
|
||||
return new ParticleArgument<>(
|
||||
this.isRequired(),
|
||||
this.getName(),
|
||||
this.getDefaultValue(),
|
||||
|
|
@ -151,8 +150,8 @@ public final class ParticleEffectArgument<C> extends CommandArgument<C, Particle
|
|||
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final @NonNull ParticleEffect defaultValue) {
|
||||
return this.asOptionalWithDefault(defaultValue.asString());
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final @NonNull ParticleOptions defaultValue) {
|
||||
return this.asOptionalWithDefault(defaultValue.writeToString());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -36,10 +36,10 @@ import cloud.commandframework.fabric.FabricCommandContextKeys;
|
|||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import io.leangen.geantyref.TypeToken;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ public class RegistryEntryArgument<C, V> extends CommandArgument<C, V> {
|
|||
RegistryEntryArgument(
|
||||
final boolean required,
|
||||
final @NonNull String name,
|
||||
final @NonNull RegistryKey<? extends Registry<V>> registry,
|
||||
final @NonNull ResourceKey<? extends Registry<V>> registry,
|
||||
final @NonNull String defaultValue,
|
||||
final @NonNull TypeToken<V> valueType,
|
||||
final @Nullable BiFunction<CommandContext<C>, String, List<String>> suggestionsProvider,
|
||||
|
|
@ -98,9 +98,9 @@ public class RegistryEntryArgument<C, V> extends CommandArgument<C, V> {
|
|||
public static <C, V> RegistryEntryArgument.@NonNull Builder<C, V> newBuilder(
|
||||
final @NonNull String name,
|
||||
final @NonNull Class<V> type,
|
||||
final @NonNull RegistryKey<? extends Registry<V>> registry
|
||||
final @NonNull ResourceKey<? extends Registry<V>> registry
|
||||
) {
|
||||
return new RegistryEntryArgument.Builder<>(registry, type, name);
|
||||
return new Builder<>(registry, type, name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -117,9 +117,9 @@ public class RegistryEntryArgument<C, V> extends CommandArgument<C, V> {
|
|||
public static <C, V> RegistryEntryArgument.@NonNull Builder<C, V> newBuilder(
|
||||
final @NonNull String name,
|
||||
final @NonNull TypeToken<V> type,
|
||||
final @NonNull RegistryKey<? extends Registry<V>> registry
|
||||
final @NonNull ResourceKey<? extends Registry<V>> registry
|
||||
) {
|
||||
return new RegistryEntryArgument.Builder<>(registry, type, name);
|
||||
return new Builder<>(registry, type, name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -136,7 +136,7 @@ public class RegistryEntryArgument<C, V> extends CommandArgument<C, V> {
|
|||
public static <C, V> @NonNull RegistryEntryArgument<C, V> of(
|
||||
final @NonNull String name,
|
||||
final @NonNull Class<V> type,
|
||||
final @NonNull RegistryKey<? extends Registry<V>> registry
|
||||
final @NonNull ResourceKey<? extends Registry<V>> registry
|
||||
) {
|
||||
return RegistryEntryArgument.<C, V>newBuilder(name, type, registry).asRequired().build();
|
||||
}
|
||||
|
|
@ -155,7 +155,7 @@ public class RegistryEntryArgument<C, V> extends CommandArgument<C, V> {
|
|||
public static <C, V> @NonNull RegistryEntryArgument<C, V> optional(
|
||||
final @NonNull String name,
|
||||
final @NonNull Class<V> type,
|
||||
final @NonNull RegistryKey<? extends Registry<V>> registry
|
||||
final @NonNull ResourceKey<? extends Registry<V>> registry
|
||||
) {
|
||||
return RegistryEntryArgument.<C, V>newBuilder(name, type, registry).asOptional().build();
|
||||
}
|
||||
|
|
@ -175,8 +175,8 @@ public class RegistryEntryArgument<C, V> extends CommandArgument<C, V> {
|
|||
public static <C, V> @NonNull RegistryEntryArgument<C, V> optional(
|
||||
final @NonNull String name,
|
||||
final @NonNull Class<V> type,
|
||||
final @NonNull RegistryKey<? extends Registry<V>> registry,
|
||||
final @NonNull RegistryKey<V> defaultValue
|
||||
final @NonNull ResourceKey<? extends Registry<V>> registry,
|
||||
final @NonNull ResourceKey<V> defaultValue
|
||||
) {
|
||||
return RegistryEntryArgument.<C, V>newBuilder(name, type, registry)
|
||||
.asOptionalWithDefault(defaultValue)
|
||||
|
|
@ -192,7 +192,7 @@ public class RegistryEntryArgument<C, V> extends CommandArgument<C, V> {
|
|||
*/
|
||||
public static final class Parser<C, V> implements ArgumentParser<C, V> {
|
||||
|
||||
private final RegistryKey<? extends Registry<V>> registryIdent;
|
||||
private final ResourceKey<? extends Registry<V>> registryIdent;
|
||||
|
||||
/**
|
||||
* Create a new {@link Parser}.
|
||||
|
|
@ -200,7 +200,7 @@ public class RegistryEntryArgument<C, V> extends CommandArgument<C, V> {
|
|||
* @param registryIdent the registry identifier
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public Parser(final RegistryKey<? extends Registry<V>> registryIdent) {
|
||||
public Parser(final ResourceKey<? extends Registry<V>> registryIdent) {
|
||||
this.registryIdent = requireNonNull(registryIdent, "registryIdent");
|
||||
}
|
||||
|
||||
|
|
@ -214,9 +214,9 @@ public class RegistryEntryArgument<C, V> extends CommandArgument<C, V> {
|
|||
return ArgumentParseResult.failure(new NoInputProvidedException(RegistryEntryArgument.class, commandContext));
|
||||
}
|
||||
|
||||
final Identifier key;
|
||||
final ResourceLocation key;
|
||||
try {
|
||||
key = Identifier.fromCommandInput(new StringReader(possibleIdentifier));
|
||||
key = ResourceLocation.read(new StringReader(possibleIdentifier));
|
||||
} catch (final CommandSyntaxException ex) {
|
||||
return ArgumentParseResult.failure(ex);
|
||||
}
|
||||
|
|
@ -237,12 +237,12 @@ public class RegistryEntryArgument<C, V> extends CommandArgument<C, V> {
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
Registry<V> getRegistry(final CommandContext<C> ctx) {
|
||||
final CommandSource reverseMapped = ctx.get(FabricCommandContextKeys.NATIVE_COMMAND_SOURCE);
|
||||
final SharedSuggestionProvider reverseMapped = ctx.get(FabricCommandContextKeys.NATIVE_COMMAND_SOURCE);
|
||||
// First try dynamic registries (for things loaded from data-packs)
|
||||
Registry<V> registry = reverseMapped.getRegistryManager().getOptional(this.registryIdent).orElse(null);
|
||||
Registry<V> registry = reverseMapped.registryAccess().registry(this.registryIdent).orElse(null);
|
||||
if (registry == null) {
|
||||
// And then static registries
|
||||
registry = (Registry<V>) Registry.REGISTRIES.get(this.registryIdent.getValue());
|
||||
registry = (Registry<V>) Registry.REGISTRY.get(this.registryIdent.location());
|
||||
}
|
||||
return registry;
|
||||
}
|
||||
|
|
@ -252,9 +252,9 @@ public class RegistryEntryArgument<C, V> extends CommandArgument<C, V> {
|
|||
final @NonNull CommandContext<C> commandContext,
|
||||
final @NonNull String input
|
||||
) {
|
||||
final Set<Identifier> ids = this.getRegistry(commandContext).getIds();
|
||||
final Set<ResourceLocation> ids = this.getRegistry(commandContext).keySet();
|
||||
final List<String> results = new ArrayList<>(ids.size());
|
||||
for (final Identifier entry : ids) {
|
||||
for (final ResourceLocation entry : ids) {
|
||||
if (entry.getNamespace().equals(NAMESPACE_MINECRAFT)) {
|
||||
results.add(entry.getPath());
|
||||
}
|
||||
|
|
@ -275,7 +275,7 @@ public class RegistryEntryArgument<C, V> extends CommandArgument<C, V> {
|
|||
* @return the registry
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public RegistryKey<? extends Registry<?>> getRegistry() {
|
||||
public ResourceKey<? extends Registry<?>> getRegistry() {
|
||||
return this.registryIdent;
|
||||
}
|
||||
|
||||
|
|
@ -290,10 +290,10 @@ public class RegistryEntryArgument<C, V> extends CommandArgument<C, V> {
|
|||
*/
|
||||
public static final class Builder<C, V> extends CommandArgument.TypedBuilder<C, V, Builder<C, V>> {
|
||||
|
||||
private final RegistryKey<? extends Registry<V>> registryIdent;
|
||||
private final ResourceKey<? extends Registry<V>> registryIdent;
|
||||
|
||||
Builder(
|
||||
final RegistryKey<? extends Registry<V>> key,
|
||||
final ResourceKey<? extends Registry<V>> key,
|
||||
final @NonNull Class<V> valueType,
|
||||
final @NonNull String name
|
||||
) {
|
||||
|
|
@ -302,7 +302,7 @@ public class RegistryEntryArgument<C, V> extends CommandArgument<C, V> {
|
|||
}
|
||||
|
||||
Builder(
|
||||
final RegistryKey<? extends Registry<V>> key,
|
||||
final ResourceKey<? extends Registry<V>> key,
|
||||
final @NonNull TypeToken<V> valueType,
|
||||
final @NonNull String name
|
||||
) {
|
||||
|
|
@ -331,8 +331,8 @@ public class RegistryEntryArgument<C, V> extends CommandArgument<C, V> {
|
|||
* @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());
|
||||
public @NonNull Builder<C, V> asOptionalWithDefault(final @NonNull ResourceKey<V> defaultValue) {
|
||||
return this.asOptionalWithDefault(defaultValue.location().toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -348,8 +348,8 @@ public class RegistryEntryArgument<C, V> extends CommandArgument<C, V> {
|
|||
|
||||
UnknownEntryException(
|
||||
final CommandContext<?> context,
|
||||
final Identifier key,
|
||||
final RegistryKey<? extends Registry<?>> registry
|
||||
final ResourceLocation key,
|
||||
final ResourceKey<? extends Registry<?>> registry
|
||||
) {
|
||||
super(
|
||||
RegistryEntryArgument.class,
|
||||
|
|
|
|||
|
|
@ -27,8 +27,7 @@ import cloud.commandframework.ArgumentDescription;
|
|||
import cloud.commandframework.arguments.CommandArgument;
|
||||
import cloud.commandframework.brigadier.argument.WrappedBrigadierParser;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import net.minecraft.command.argument.IdentifierArgumentType;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
|
|
@ -36,14 +35,14 @@ import java.util.List;
|
|||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* An argument parsing an {@link Identifier}, or "resource location".
|
||||
* An argument parsing a {@link ResourceLocation}.
|
||||
*
|
||||
* @param <C> the sender type
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public final class IdentifierArgument<C> extends CommandArgument<C, Identifier> {
|
||||
public final class ResourceLocationArgument<C> extends CommandArgument<C, ResourceLocation> {
|
||||
|
||||
IdentifierArgument(
|
||||
ResourceLocationArgument(
|
||||
final boolean required,
|
||||
final @NonNull String name,
|
||||
final @NonNull String defaultValue,
|
||||
|
|
@ -53,9 +52,9 @@ public final class IdentifierArgument<C> extends CommandArgument<C, Identifier>
|
|||
super(
|
||||
required,
|
||||
name,
|
||||
new WrappedBrigadierParser<>(IdentifierArgumentType.identifier()),
|
||||
new WrappedBrigadierParser<>(net.minecraft.commands.arguments.ResourceLocationArgument.id()),
|
||||
defaultValue,
|
||||
Identifier.class,
|
||||
ResourceLocation.class,
|
||||
suggestionsProvider,
|
||||
defaultDescription
|
||||
);
|
||||
|
|
@ -74,31 +73,31 @@ public final class IdentifierArgument<C> extends CommandArgument<C, Identifier>
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new required {@link IdentifierArgument}.
|
||||
* Create a new required {@link ResourceLocationArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
* @return Created argument
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull IdentifierArgument<C> of(final @NonNull String name) {
|
||||
return IdentifierArgument.<C>builder(name).asRequired().build();
|
||||
public static <C> @NonNull ResourceLocationArgument<C> of(final @NonNull String name) {
|
||||
return ResourceLocationArgument.<C>builder(name).asRequired().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional {@link IdentifierArgument}.
|
||||
* Create a new optional {@link ResourceLocationArgument}.
|
||||
*
|
||||
* @param name Component name
|
||||
* @param <C> Command sender type
|
||||
* @return Created argument
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull IdentifierArgument<C> optional(final @NonNull String name) {
|
||||
return IdentifierArgument.<C>builder(name).asOptional().build();
|
||||
public static <C> @NonNull ResourceLocationArgument<C> optional(final @NonNull String name) {
|
||||
return ResourceLocationArgument.<C>builder(name).asOptional().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new optional {@link IdentifierArgument} with the specified default value.
|
||||
* Create a new optional {@link ResourceLocationArgument} with the specified default value.
|
||||
*
|
||||
* @param name Argument name
|
||||
* @param defaultValue Default value
|
||||
|
|
@ -106,35 +105,35 @@ public final class IdentifierArgument<C> extends CommandArgument<C, Identifier>
|
|||
* @return Created argument
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull IdentifierArgument<C> optional(
|
||||
public static <C> @NonNull ResourceLocationArgument<C> optional(
|
||||
final @NonNull String name,
|
||||
final @NonNull Identifier defaultValue
|
||||
final @NonNull ResourceLocation defaultValue
|
||||
) {
|
||||
return IdentifierArgument.<C>builder(name).asOptionalWithDefault(defaultValue).build();
|
||||
return ResourceLocationArgument.<C>builder(name).asOptionalWithDefault(defaultValue).build();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Builder for {@link IdentifierArgument}.
|
||||
* Builder for {@link ResourceLocationArgument}.
|
||||
*
|
||||
* @param <C> sender type
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static final class Builder<C> extends TypedBuilder<C, Identifier, Builder<C>> {
|
||||
public static final class Builder<C> extends TypedBuilder<C, ResourceLocation, Builder<C>> {
|
||||
|
||||
Builder(final @NonNull String name) {
|
||||
super(Identifier.class, name);
|
||||
super(ResourceLocation.class, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a new {@link IdentifierArgument}.
|
||||
* Build a new {@link ResourceLocationArgument}.
|
||||
*
|
||||
* @return Constructed argument
|
||||
* @since 1.5.0
|
||||
*/
|
||||
@Override
|
||||
public @NonNull IdentifierArgument<C> build() {
|
||||
return new IdentifierArgument<>(
|
||||
public @NonNull ResourceLocationArgument<C> build() {
|
||||
return new ResourceLocationArgument<>(
|
||||
this.isRequired(),
|
||||
this.getName(),
|
||||
this.getDefaultValue(),
|
||||
|
|
@ -151,7 +150,7 @@ public final class IdentifierArgument<C> extends CommandArgument<C, Identifier>
|
|||
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final @NonNull Identifier defaultValue) {
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final @NonNull ResourceLocation defaultValue) {
|
||||
return this.asOptionalWithDefault(defaultValue.toString());
|
||||
}
|
||||
|
||||
|
|
@ -27,8 +27,8 @@ import cloud.commandframework.ArgumentDescription;
|
|||
import cloud.commandframework.arguments.CommandArgument;
|
||||
import cloud.commandframework.brigadier.argument.WrappedBrigadierParser;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import net.minecraft.command.argument.OperationArgumentType;
|
||||
import net.minecraft.command.argument.OperationArgumentType.Operation;
|
||||
import net.minecraft.commands.arguments.OperationArgument;
|
||||
import net.minecraft.commands.arguments.OperationArgument.Operation;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ import java.util.function.BiFunction;
|
|||
/**
|
||||
* An argument for selecting any of the logical operations in {@link Operation}.
|
||||
*
|
||||
* <p>These operations can be used to compare scores on a {@link net.minecraft.scoreboard.Scoreboard}.</p>
|
||||
* <p>These operations can be used to compare scores on a {@link net.minecraft.world.scores.Scoreboard}.</p>
|
||||
*
|
||||
* @param <C> the sender type
|
||||
* @since 1.5.0
|
||||
|
|
@ -55,7 +55,7 @@ public final class ScoreboardOperationArgument<C> extends CommandArgument<C, Ope
|
|||
super(
|
||||
required,
|
||||
name,
|
||||
new WrappedBrigadierParser<>(OperationArgumentType.operation()),
|
||||
new WrappedBrigadierParser<>(OperationArgument.operation()),
|
||||
defaultValue,
|
||||
Operation.class,
|
||||
suggestionsProvider,
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ import cloud.commandframework.arguments.parser.ArgumentParser;
|
|||
import cloud.commandframework.context.CommandContext;
|
||||
import cloud.commandframework.fabric.FabricCommandContextKeys;
|
||||
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Queue;
|
||||
|
|
@ -49,12 +49,12 @@ abstract class SidedArgumentParser<C, I, R> implements ArgumentParser<C, R> {
|
|||
@NonNull final CommandContext<@NonNull C> commandContext,
|
||||
@NonNull final Queue<@NonNull String> inputQueue
|
||||
) {
|
||||
final CommandSource source = commandContext.get(FabricCommandContextKeys.NATIVE_COMMAND_SOURCE);
|
||||
final SharedSuggestionProvider source = commandContext.get(FabricCommandContextKeys.NATIVE_COMMAND_SOURCE);
|
||||
final ArgumentParseResult<I> intermediate = this.parseIntermediate(commandContext, inputQueue);
|
||||
|
||||
return intermediate.flatMapParsedValue(value -> {
|
||||
if (source instanceof ServerCommandSource) {
|
||||
return this.resolveServer(commandContext, (ServerCommandSource) source, value);
|
||||
if (source instanceof CommandSourceStack) {
|
||||
return this.resolveServer(commandContext, (CommandSourceStack) source, value);
|
||||
} else if (source instanceof FabricClientCommandSource) {
|
||||
return this.resolveClient(commandContext, (FabricClientCommandSource) source, value);
|
||||
} else {
|
||||
|
|
@ -94,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 ServerCommandSource source,
|
||||
@NonNull CommandSourceStack source,
|
||||
@NonNull I value
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ import cloud.commandframework.exceptions.parsing.ParserException;
|
|||
import cloud.commandframework.fabric.FabricCaptionKeys;
|
||||
import cloud.commandframework.fabric.FabricCommandContextKeys;
|
||||
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
|
||||
import net.minecraft.scoreboard.Team;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.world.scores.PlayerTeam;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
|
|
@ -44,12 +44,12 @@ import java.util.Queue;
|
|||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* An argument for parsing {@link Team Teams}.
|
||||
* An argument for parsing {@link PlayerTeam Teams}.
|
||||
*
|
||||
* @param <C> the sender type
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public final class TeamArgument<C> extends CommandArgument<C, Team> {
|
||||
public final class TeamArgument<C> extends CommandArgument<C, PlayerTeam> {
|
||||
|
||||
TeamArgument(
|
||||
final boolean required,
|
||||
|
|
@ -63,7 +63,7 @@ public final class TeamArgument<C> extends CommandArgument<C, Team> {
|
|||
name,
|
||||
new TeamParser<>(),
|
||||
defaultValue,
|
||||
Team.class,
|
||||
PlayerTeam.class,
|
||||
suggestionsProvider,
|
||||
defaultDescription
|
||||
);
|
||||
|
|
@ -116,25 +116,25 @@ public final class TeamArgument<C> extends CommandArgument<C, Team> {
|
|||
*/
|
||||
public static <C> @NonNull TeamArgument<C> optional(
|
||||
final @NonNull String name,
|
||||
final @NonNull Team defaultValue
|
||||
final @NonNull PlayerTeam defaultValue
|
||||
) {
|
||||
return TeamArgument.<C>builder(name).asOptionalWithDefault(defaultValue).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Argument parser for {@link Team Teams}.
|
||||
* Argument parser for {@link PlayerTeam Teams}.
|
||||
*
|
||||
* @param <C> sender type
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static final class TeamParser<C> extends SidedArgumentParser<C, String, Team> {
|
||||
public static final class TeamParser<C> extends SidedArgumentParser<C, String, PlayerTeam> {
|
||||
|
||||
@Override
|
||||
public @NonNull List<@NonNull String> suggestions(
|
||||
final @NonNull CommandContext<C> commandContext,
|
||||
final @NonNull String input
|
||||
) {
|
||||
return new ArrayList<>(commandContext.get(FabricCommandContextKeys.NATIVE_COMMAND_SOURCE).getTeamNames());
|
||||
return new ArrayList<>(commandContext.get(FabricCommandContextKeys.NATIVE_COMMAND_SOURCE).getAllTeams());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -150,12 +150,12 @@ public final class TeamArgument<C> extends CommandArgument<C, Team> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected @NonNull ArgumentParseResult<Team> resolveClient(
|
||||
protected @NonNull ArgumentParseResult<PlayerTeam> resolveClient(
|
||||
final @NonNull CommandContext<C> context,
|
||||
final @NonNull FabricClientCommandSource source,
|
||||
final @NonNull String value
|
||||
) {
|
||||
final Team result = source.getClient().getNetworkHandler().getWorld().getScoreboard().getTeam(value);
|
||||
final PlayerTeam result = source.getClient().getConnection().getLevel().getScoreboard().getPlayerTeam(value);
|
||||
if (result == null) {
|
||||
return ArgumentParseResult.failure(new UnknownTeamException(context, value));
|
||||
}
|
||||
|
|
@ -163,12 +163,12 @@ public final class TeamArgument<C> extends CommandArgument<C, Team> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected @NonNull ArgumentParseResult<Team> resolveServer(
|
||||
protected @NonNull ArgumentParseResult<PlayerTeam> resolveServer(
|
||||
final @NonNull CommandContext<C> context,
|
||||
final @NonNull ServerCommandSource source,
|
||||
final @NonNull CommandSourceStack source,
|
||||
final @NonNull String value
|
||||
) {
|
||||
final Team result = source.getWorld().getScoreboard().getTeam(value);
|
||||
final PlayerTeam result = source.getLevel().getScoreboard().getPlayerTeam(value);
|
||||
if (result == null) {
|
||||
return ArgumentParseResult.failure(new UnknownTeamException(context, value));
|
||||
}
|
||||
|
|
@ -183,10 +183,10 @@ public final class TeamArgument<C> extends CommandArgument<C, Team> {
|
|||
* @param <C> sender type
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static final class Builder<C> extends TypedBuilder<C, Team, Builder<C>> {
|
||||
public static final class Builder<C> extends TypedBuilder<C, PlayerTeam, Builder<C>> {
|
||||
|
||||
Builder(final @NonNull String name) {
|
||||
super(Team.class, name);
|
||||
super(PlayerTeam.class, name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -214,7 +214,7 @@ public final class TeamArgument<C> extends CommandArgument<C, Team> {
|
|||
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final @NonNull Team defaultValue) {
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final @NonNull PlayerTeam defaultValue) {
|
||||
return this.asOptionalWithDefault(defaultValue.getName());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import cloud.commandframework.arguments.CommandArgument;
|
|||
import cloud.commandframework.context.CommandContext;
|
||||
import cloud.commandframework.fabric.argument.FabricArgumentParsers;
|
||||
import cloud.commandframework.fabric.data.Coordinates.BlockCoordinates;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import cloud.commandframework.arguments.CommandArgument;
|
|||
import cloud.commandframework.context.CommandContext;
|
||||
import cloud.commandframework.fabric.argument.FabricArgumentParsers;
|
||||
import cloud.commandframework.fabric.data.Coordinates.ColumnCoordinates;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
|
|
|
|||
|
|
@ -35,8 +35,8 @@ import java.util.List;
|
|||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* An argument for selecting multiple {@link net.minecraft.entity.Entity entities} using an
|
||||
* {@link net.minecraft.command.EntitySelector}.
|
||||
* An argument for selecting multiple {@link net.minecraft.world.entity.Entity entities} using an
|
||||
* {@link net.minecraft.commands.arguments.selector.EntitySelector}.
|
||||
*
|
||||
* @param <C> the sender type
|
||||
* @since 1.5.0
|
||||
|
|
|
|||
|
|
@ -35,8 +35,8 @@ import java.util.List;
|
|||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* An argument for selecting multiple {@link net.minecraft.server.network.ServerPlayerEntity players} using an
|
||||
* {@link net.minecraft.command.EntitySelector}.
|
||||
* An argument for selecting multiple {@link net.minecraft.server.level.ServerPlayer players} using an
|
||||
* {@link net.minecraft.commands.arguments.selector.EntitySelector}.
|
||||
*
|
||||
* @param <C> the sender type
|
||||
* @since 1.5.0
|
||||
|
|
|
|||
|
|
@ -35,8 +35,8 @@ import java.util.List;
|
|||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* An argument for selecting a single {@link net.minecraft.entity.Entity entity} using an
|
||||
* {@link net.minecraft.command.EntitySelector}.
|
||||
* An argument for selecting a single {@link net.minecraft.world.entity.Entity entity} using an
|
||||
* {@link net.minecraft.commands.arguments.selector.EntitySelector}.
|
||||
*
|
||||
* @param <C> the sender type
|
||||
* @since 1.5.0
|
||||
|
|
|
|||
|
|
@ -35,8 +35,8 @@ import java.util.List;
|
|||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* An argument for selecting a single {@link net.minecraft.server.network.ServerPlayerEntity player} using an
|
||||
* {@link net.minecraft.command.EntitySelector}.
|
||||
* An argument for selecting a single {@link net.minecraft.server.level.ServerPlayer player} using an
|
||||
* {@link net.minecraft.commands.arguments.selector.EntitySelector}.
|
||||
*
|
||||
* @param <C> the sender type
|
||||
* @since 1.5.0
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import cloud.commandframework.arguments.CommandArgument;
|
|||
import cloud.commandframework.context.CommandContext;
|
||||
import cloud.commandframework.fabric.argument.FabricArgumentParsers;
|
||||
import cloud.commandframework.fabric.data.Coordinates;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
|
|
@ -146,7 +146,7 @@ public final class Vec2dArgument<C> extends CommandArgument<C, Coordinates.Coord
|
|||
* @return Created argument
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull Vec2dArgument<C> optional(final @NonNull String name, final @NonNull Vec3d defaultValue) {
|
||||
public static <C> @NonNull Vec2dArgument<C> optional(final @NonNull String name, final @NonNull Vec3 defaultValue) {
|
||||
return Vec2dArgument.<C>builder(name).asOptionalWithDefault(defaultValue).build();
|
||||
}
|
||||
|
||||
|
|
@ -163,7 +163,7 @@ public final class Vec2dArgument<C> extends CommandArgument<C, Coordinates.Coord
|
|||
public static <C> @NonNull Vec2dArgument<C> optional(
|
||||
final @NonNull String name,
|
||||
final boolean centerIntegers,
|
||||
final @NonNull Vec3d defaultValue
|
||||
final @NonNull Vec3 defaultValue
|
||||
) {
|
||||
return Vec2dArgument.<C>builder(name).centerIntegers(centerIntegers).asOptionalWithDefault(defaultValue).build();
|
||||
}
|
||||
|
|
@ -212,7 +212,7 @@ public final class Vec2dArgument<C> extends CommandArgument<C, Coordinates.Coord
|
|||
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final @NonNull Vec3d defaultValue) {
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final @NonNull Vec3 defaultValue) {
|
||||
return this.asOptionalWithDefault(String.format(
|
||||
"%.10f %.10f",
|
||||
defaultValue.x,
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import cloud.commandframework.arguments.CommandArgument;
|
|||
import cloud.commandframework.context.CommandContext;
|
||||
import cloud.commandframework.fabric.argument.FabricArgumentParsers;
|
||||
import cloud.commandframework.fabric.data.Coordinates;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
|
|
@ -146,7 +146,7 @@ public final class Vec3dArgument<C> extends CommandArgument<C, Coordinates> {
|
|||
* @return Created argument
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public static <C> @NonNull Vec3dArgument<C> optional(final @NonNull String name, final @NonNull Vec3d defaultValue) {
|
||||
public static <C> @NonNull Vec3dArgument<C> optional(final @NonNull String name, final @NonNull Vec3 defaultValue) {
|
||||
return Vec3dArgument.<C>builder(name).asOptionalWithDefault(defaultValue).build();
|
||||
}
|
||||
|
||||
|
|
@ -163,7 +163,7 @@ public final class Vec3dArgument<C> extends CommandArgument<C, Coordinates> {
|
|||
public static <C> @NonNull Vec3dArgument<C> optional(
|
||||
final @NonNull String name,
|
||||
final boolean centerIntegers,
|
||||
final @NonNull Vec3d defaultValue
|
||||
final @NonNull Vec3 defaultValue
|
||||
) {
|
||||
return Vec3dArgument.<C>builder(name).centerIntegers(centerIntegers).asOptionalWithDefault(defaultValue).build();
|
||||
}
|
||||
|
|
@ -212,7 +212,7 @@ public final class Vec3dArgument<C> extends CommandArgument<C, Coordinates> {
|
|||
* @see CommandArgument.Builder#asOptionalWithDefault(String)
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final @NonNull Vec3d defaultValue) {
|
||||
public @NonNull Builder<C> asOptionalWithDefault(final @NonNull Vec3 defaultValue) {
|
||||
return this.asOptionalWithDefault(String.format(
|
||||
"%.10f %.10f %.10f",
|
||||
defaultValue.x,
|
||||
|
|
|
|||
|
|
@ -23,16 +23,15 @@
|
|||
//
|
||||
package cloud.commandframework.fabric.data;
|
||||
|
||||
import net.minecraft.command.argument.BlockPosArgumentType;
|
||||
import net.minecraft.command.argument.ColumnPosArgumentType;
|
||||
import net.minecraft.command.argument.PosArgument;
|
||||
import net.minecraft.command.argument.Vec2ArgumentType;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.commands.arguments.coordinates.BlockPosArgument;
|
||||
import net.minecraft.commands.arguments.coordinates.ColumnPosArgument;
|
||||
import net.minecraft.commands.arguments.coordinates.Vec2Argument;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
* A {@link PosArgument} wrapper for easier use with cloud commands.
|
||||
* A {@link net.minecraft.commands.arguments.coordinates.Coordinates} wrapper for easier use with cloud commands.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
|
|
@ -44,7 +43,7 @@ public interface Coordinates {
|
|||
* @return position
|
||||
* @since 1.5.0
|
||||
*/
|
||||
@NonNull Vec3d position();
|
||||
@NonNull Vec3 position();
|
||||
|
||||
/**
|
||||
* Resolve a block position from the parsed coordinates.
|
||||
|
|
@ -84,10 +83,10 @@ public interface Coordinates {
|
|||
* @return the base coordinates
|
||||
* @since 1.5.0
|
||||
*/
|
||||
@NonNull PosArgument wrappedCoordinates();
|
||||
net.minecraft.commands.arguments.coordinates.@NonNull Coordinates wrappedCoordinates();
|
||||
|
||||
/**
|
||||
* A specialized version of {@link Coordinates} for representing the result of the vanilla {@link Vec2ArgumentType},
|
||||
* A specialized version of {@link Coordinates} for representing the result of the vanilla {@link Vec2Argument},
|
||||
* which accepts two doubles for the x and z coordinate, always defaulting to 0 for the y coordinate.
|
||||
*
|
||||
* @since 1.5.0
|
||||
|
|
@ -97,7 +96,7 @@ public interface Coordinates {
|
|||
}
|
||||
|
||||
/**
|
||||
* A specialized version of {@link Coordinates} for representing the result of the vanilla {@link BlockPosArgumentType}.
|
||||
* A specialized version of {@link Coordinates} for representing the result of the vanilla {@link BlockPosArgument}.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
|
|
@ -106,7 +105,7 @@ public interface Coordinates {
|
|||
}
|
||||
|
||||
/**
|
||||
* A specialized version of {@link Coordinates} for representing the result of the vanilla {@link ColumnPosArgumentType}.
|
||||
* A specialized version of {@link Coordinates} for representing the result of the vanilla {@link ColumnPosArgument}.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@
|
|||
//
|
||||
package cloud.commandframework.fabric.data;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Collection;
|
||||
|
|
@ -50,6 +50,6 @@ public interface Message {
|
|||
* @return the parsed text
|
||||
* @since 1.5.0
|
||||
*/
|
||||
@NonNull Text getContents();
|
||||
@NonNull Component getContents();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
//
|
||||
package cloud.commandframework.fabric.data;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
||||
/**
|
||||
* A selector for multiple entities.
|
||||
|
|
|
|||
|
|
@ -23,13 +23,13 @@
|
|||
//
|
||||
package cloud.commandframework.fabric.data;
|
||||
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
/**
|
||||
* A selector for multiple players.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public interface MultiplePlayerSelector extends Selector<ServerPlayerEntity> {
|
||||
public interface MultiplePlayerSelector extends Selector<ServerPlayer> {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
//
|
||||
package cloud.commandframework.fabric.data;
|
||||
|
||||
import net.minecraft.command.EntitySelector;
|
||||
import net.minecraft.commands.arguments.selector.EntitySelector;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
//
|
||||
package cloud.commandframework.fabric.data;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
||||
/**
|
||||
* A selector for a single entity.
|
||||
|
|
|
|||
|
|
@ -23,13 +23,13 @@
|
|||
//
|
||||
package cloud.commandframework.fabric.data;
|
||||
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
/**
|
||||
* A selector for a single player.
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public interface SinglePlayerSelector extends Selector.Single<ServerPlayerEntity> {
|
||||
public interface SinglePlayerSelector extends Selector.Single<ServerPlayer> {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,16 +25,16 @@ package cloud.commandframework.fabric.mixin;
|
|||
|
||||
import cloud.commandframework.fabric.internal.CloudStringReader;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import net.minecraft.server.command.CommandManager;
|
||||
import net.minecraft.commands.Commands;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(CommandManager.class)
|
||||
public class CommandManagerMixin {
|
||||
@Mixin(Commands.class)
|
||||
public class CommandsMixin {
|
||||
|
||||
/* Use our StringReader. This is technically optional, but it's nicer to avoid re-wrapping the object every time */
|
||||
@Redirect(method = "execute", at = @At(value = "NEW", target = "com/mojang/brigadier/StringReader", remap = false), require = 0)
|
||||
@Redirect(method = "performCommand", at = @At(value = "NEW", target = "com/mojang/brigadier/StringReader", remap = false), require = 0)
|
||||
private StringReader cloud$newStringReader(final String arguments) {
|
||||
return new CloudStringReader(arguments);
|
||||
}
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
package cloud.commandframework.fabric.mixin;
|
||||
|
||||
import cloud.commandframework.fabric.internal.EntitySelectorAccess;
|
||||
import net.minecraft.command.EntitySelector;
|
||||
import net.minecraft.commands.arguments.selector.EntitySelector;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.spongepowered.asm.mixin.Implements;
|
||||
import org.spongepowered.asm.mixin.Interface;
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ package cloud.commandframework.fabric.mixin;
|
|||
|
||||
import cloud.commandframework.fabric.internal.EntitySelectorAccess;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import net.minecraft.command.EntitySelector;
|
||||
import net.minecraft.command.EntitySelectorReader;
|
||||
import net.minecraft.commands.arguments.selector.EntitySelector;
|
||||
import net.minecraft.commands.arguments.selector.EntitySelectorParser;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
|
@ -35,20 +35,20 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(EntitySelectorReader.class)
|
||||
abstract class EntitySelectorReaderMixin {
|
||||
@Mixin(EntitySelectorParser.class)
|
||||
abstract class EntitySelectorParserMixin {
|
||||
|
||||
@Shadow
|
||||
private int startCursor;
|
||||
private int startPosition;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private StringReader reader;
|
||||
|
||||
@Inject(method = "read", at = @At("RETURN"))
|
||||
@Inject(method = "parse", at = @At("RETURN"))
|
||||
public void setInputString(final @NonNull CallbackInfoReturnable<EntitySelector> cir) {
|
||||
final EntitySelector selector = cir.getReturnValue();
|
||||
final String inputString = this.reader.getString().substring(this.startCursor, this.reader.getCursor());
|
||||
final String inputString = this.reader.getString().substring(this.startPosition, this.reader.getCursor());
|
||||
((EntitySelectorAccess) selector).inputString(inputString);
|
||||
}
|
||||
|
||||
|
|
@ -23,13 +23,11 @@
|
|||
//
|
||||
package cloud.commandframework.fabric.mixin;
|
||||
|
||||
import net.minecraft.command.argument.MessageArgumentType;
|
||||
import net.minecraft.commands.arguments.MessageArgument;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(MessageArgumentType.MessageFormat.class)
|
||||
public interface MessageArgumentTypeMessageFormatAccess {
|
||||
|
||||
@Accessor("selectors") MessageArgumentType.MessageSelector[] accessor$selectors();
|
||||
|
||||
@Mixin(MessageArgument.Message.class)
|
||||
public interface MessageArgumentMessageAccess {
|
||||
@Accessor("parts") MessageArgument.Part[] accessor$parts();
|
||||
}
|
||||
|
|
@ -23,12 +23,12 @@
|
|||
//
|
||||
package cloud.commandframework.fabric.mixin;
|
||||
|
||||
import net.minecraft.command.EntitySelector;
|
||||
import net.minecraft.command.argument.MessageArgumentType;
|
||||
import net.minecraft.commands.arguments.MessageArgument;
|
||||
import net.minecraft.commands.arguments.selector.EntitySelector;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(MessageArgumentType.MessageSelector.class)
|
||||
public interface MessageArgumentTypeMessageSelectorAccess {
|
||||
@Mixin(MessageArgument.Part.class)
|
||||
public interface MessageArgumentPartAccess {
|
||||
@Accessor("selector") EntitySelector accessor$selector();
|
||||
}
|
||||
|
|
@ -4,11 +4,11 @@
|
|||
"required": true,
|
||||
"mixins": [
|
||||
"CloudStringReaderMixin",
|
||||
"CommandManagerMixin",
|
||||
"CommandsMixin",
|
||||
"EntitySelectorMixin",
|
||||
"EntitySelectorReaderMixin",
|
||||
"MessageArgumentTypeMessageFormatAccess",
|
||||
"MessageArgumentTypeMessageSelectorAccess"
|
||||
"EntitySelectorParserMixin",
|
||||
"MessageArgumentMessageAccess",
|
||||
"MessageArgumentPartAccess"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
|
|
|||
|
|
@ -35,16 +35,16 @@ import com.mojang.brigadier.CommandDispatcher;
|
|||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.SaveLevelScreen;
|
||||
import net.minecraft.client.gui.screen.TitleScreen;
|
||||
import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen;
|
||||
import net.minecraft.client.realms.gui.screen.RealmsBridgeScreen;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.command.argument.ArgumentTypes;
|
||||
import net.minecraft.text.ClickEvent;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.GenericDirtMessageScreen;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import net.minecraft.client.gui.screens.multiplayer.JoinMultiplayerScreen;
|
||||
import net.minecraft.commands.SharedSuggestionProvider;
|
||||
import net.minecraft.commands.synchronization.ArgumentTypes;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.realms.RealmsBridge;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
|
|
@ -69,23 +69,23 @@ public final class FabricClientExample implements ClientModInitializer {
|
|||
"cloud-dump-" + Instant.now().toString().replace(':', '-') + ".json"
|
||||
);
|
||||
ctx.getSender().sendFeedback(
|
||||
new LiteralText("Dumping command output to ")
|
||||
.append(new LiteralText(target.toString())
|
||||
.styled(s -> s.withClickEvent(new ClickEvent(
|
||||
new TextComponent("Dumping command output to ")
|
||||
.append(new TextComponent(target.toString())
|
||||
.withStyle(s -> s.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.OPEN_FILE,
|
||||
target.toAbsolutePath().toString()
|
||||
))))
|
||||
);
|
||||
|
||||
try (BufferedWriter writer = Files.newBufferedWriter(target); JsonWriter json = new JsonWriter(writer)) {
|
||||
final CommandDispatcher<CommandSource> dispatcher = MinecraftClient.getInstance()
|
||||
.getNetworkHandler()
|
||||
.getCommandDispatcher();
|
||||
final JsonObject object = ArgumentTypes.toJson(dispatcher, dispatcher.getRoot());
|
||||
final CommandDispatcher<SharedSuggestionProvider> dispatcher = Minecraft.getInstance()
|
||||
.getConnection()
|
||||
.getCommands();
|
||||
final JsonObject object = ArgumentTypes.serializeNodeToJson(dispatcher, dispatcher.getRoot());
|
||||
json.setIndent(" ");
|
||||
Streams.write(object, json);
|
||||
} catch (final IOException ex) {
|
||||
ctx.getSender().sendError(new LiteralText(
|
||||
ctx.getSender().sendError(new TextComponent(
|
||||
"Unable to write file, see console for details: " + ex.getMessage()
|
||||
));
|
||||
}
|
||||
|
|
@ -94,38 +94,38 @@ public final class FabricClientExample implements ClientModInitializer {
|
|||
commandManager.command(base.literal("say")
|
||||
.argument(StringArgument.greedy("message"))
|
||||
.handler(ctx -> ctx.getSender().sendFeedback(
|
||||
new LiteralText("Cloud client commands says: " + ctx.get("message"))
|
||||
new TextComponent("Cloud client commands says: " + ctx.get("message"))
|
||||
)));
|
||||
|
||||
commandManager.command(base.literal("quit")
|
||||
.handler(ctx -> {
|
||||
final MinecraftClient client = MinecraftClient.getInstance();
|
||||
final Minecraft client = Minecraft.getInstance();
|
||||
disconnectClient(client);
|
||||
client.scheduleStop();
|
||||
client.stop();
|
||||
}));
|
||||
|
||||
commandManager.command(base.literal("disconnect")
|
||||
.handler(ctx -> disconnectClient(MinecraftClient.getInstance())));
|
||||
.handler(ctx -> disconnectClient(Minecraft.getInstance())));
|
||||
|
||||
commandManager.command(base.literal("requires_cheats")
|
||||
.permission(FabricClientCommandManager.cheatsAllowed(false))
|
||||
.handler(ctx -> ctx.getSender().sendFeedback(new LiteralText("Cheats are enabled!"))));
|
||||
.handler(ctx -> ctx.getSender().sendFeedback(new TextComponent("Cheats are enabled!"))));
|
||||
}
|
||||
|
||||
private static void disconnectClient(final @NonNull MinecraftClient client) {
|
||||
boolean singlePlayer = client.isInSingleplayer();
|
||||
client.world.disconnect();
|
||||
private static void disconnectClient(final @NonNull Minecraft client) {
|
||||
boolean singlePlayer = client.hasSingleplayerServer();
|
||||
client.level.disconnect();
|
||||
if (singlePlayer) {
|
||||
client.disconnect(new SaveLevelScreen(new TranslatableText("menu.savingLevel")));
|
||||
client.clearLevel(new GenericDirtMessageScreen(new TranslatableComponent("menu.savingLevel")));
|
||||
} else {
|
||||
client.disconnect();
|
||||
client.clearLevel();
|
||||
}
|
||||
if (singlePlayer) {
|
||||
client.openScreen(new TitleScreen());
|
||||
client.setScreen(new TitleScreen());
|
||||
} else if (client.isConnectedToRealms()) {
|
||||
new RealmsBridgeScreen().switchToRealms(new TitleScreen());
|
||||
new RealmsBridge().switchToRealms(new TitleScreen());
|
||||
} else {
|
||||
client.openScreen(new MultiplayerScreen(new TitleScreen()));
|
||||
client.setScreen(new JoinMultiplayerScreen(new TitleScreen()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@ import cloud.commandframework.arguments.standard.IntegerArgument;
|
|||
import cloud.commandframework.arguments.standard.StringArgument;
|
||||
import cloud.commandframework.execution.CommandExecutionCoordinator;
|
||||
import cloud.commandframework.fabric.FabricServerCommandManager;
|
||||
import cloud.commandframework.fabric.argument.ColorArgument;
|
||||
import cloud.commandframework.fabric.argument.ItemDataArgument;
|
||||
import cloud.commandframework.fabric.argument.ItemInputArgument;
|
||||
import cloud.commandframework.fabric.argument.NamedColorArgument;
|
||||
import cloud.commandframework.fabric.argument.server.ColumnPosArgument;
|
||||
import cloud.commandframework.fabric.argument.server.MultipleEntitySelectorArgument;
|
||||
import cloud.commandframework.fabric.argument.server.MultiplePlayerSelectorArgument;
|
||||
|
|
@ -47,20 +47,20 @@ import net.fabricmc.loader.api.FabricLoader;
|
|||
import net.fabricmc.loader.api.ModContainer;
|
||||
import net.fabricmc.loader.api.metadata.ModMetadata;
|
||||
import net.fabricmc.loader.api.metadata.Person;
|
||||
import net.minecraft.command.argument.ItemStackArgument;
|
||||
import net.minecraft.network.MessageType;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.text.ClickEvent;
|
||||
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;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.arguments.item.ItemInput;
|
||||
import net.minecraft.network.chat.ChatType;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.ComponentUtils;
|
||||
import net.minecraft.network.chat.HoverEvent;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.TextColor;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
|
|
@ -72,13 +72,13 @@ public final class FabricExample implements ModInitializer {
|
|||
@Override
|
||||
public void onInitialize() {
|
||||
// Create a commands manager. We'll use native command source types for this.
|
||||
final FabricServerCommandManager<ServerCommandSource> manager =
|
||||
final FabricServerCommandManager<CommandSourceStack> manager =
|
||||
FabricServerCommandManager.createNative(CommandExecutionCoordinator.simpleCoordinator());
|
||||
|
||||
final Command.Builder<ServerCommandSource> base = manager.commandBuilder("cloudtest");
|
||||
final Command.Builder<CommandSourceStack> base = manager.commandBuilder("cloudtest");
|
||||
|
||||
final CommandArgument<ServerCommandSource, String> name = StringArgument.of("name");
|
||||
final CommandArgument<ServerCommandSource, Integer> hugs = IntegerArgument.<ServerCommandSource>newBuilder("hugs")
|
||||
final CommandArgument<CommandSourceStack, String> name = StringArgument.of("name");
|
||||
final CommandArgument<CommandSourceStack, Integer> hugs = IntegerArgument.<CommandSourceStack>newBuilder("hugs")
|
||||
.asOptionalWithDefault("1")
|
||||
.build();
|
||||
|
||||
|
|
@ -87,38 +87,38 @@ public final class FabricExample implements ModInitializer {
|
|||
.argument(name)
|
||||
.argument(hugs)
|
||||
.handler(ctx -> {
|
||||
ctx.getSender().sendFeedback(new LiteralText("Hello, ")
|
||||
ctx.getSender().sendSuccess(new TextComponent("Hello, ")
|
||||
.append(ctx.get(name))
|
||||
.append(", hope you're doing well!")
|
||||
.styled(style -> style.withColor(TextColor.fromRgb(0xAA22BB))), false);
|
||||
.withStyle(style -> style.withColor(TextColor.fromRgb(0xAA22BB))), false);
|
||||
|
||||
ctx.getSender().sendFeedback(new LiteralText("Cloud would like to give you ")
|
||||
.append(new LiteralText(String.valueOf(ctx.get(hugs)))
|
||||
.styled(style -> style.withColor(TextColor.fromRgb(0xFAB3DA))))
|
||||
ctx.getSender().sendSuccess(new TextComponent("Cloud would like to give you ")
|
||||
.append(new TextComponent(String.valueOf(ctx.get(hugs)))
|
||||
.withStyle(style -> style.withColor(TextColor.fromRgb(0xFAB3DA))))
|
||||
.append(" hug(s) <3")
|
||||
.styled(style -> style.withBold(true)), false);
|
||||
.withStyle(style -> style.withBold(true)), false);
|
||||
}));
|
||||
|
||||
final CommandArgument<ServerCommandSource, MultiplePlayerSelector> playerSelector =
|
||||
final CommandArgument<CommandSourceStack, MultiplePlayerSelector> playerSelector =
|
||||
MultiplePlayerSelectorArgument.of("players");
|
||||
final CommandArgument<ServerCommandSource, Formatting> textColor = ColorArgument.of("color");
|
||||
final CommandArgument<CommandSourceStack, ChatFormatting> textColor = NamedColorArgument.of("color");
|
||||
|
||||
manager.command(base.literal("wave")
|
||||
.argument(playerSelector)
|
||||
.argument(textColor)
|
||||
.handler(ctx -> {
|
||||
final MultiplePlayerSelector selector = ctx.get(playerSelector);
|
||||
final Collection<ServerPlayerEntity> selected = selector.get();
|
||||
final Collection<ServerPlayer> selected = selector.get();
|
||||
selected.forEach(selectedPlayer ->
|
||||
selectedPlayer.sendMessage(
|
||||
new LiteralText("Wave from ")
|
||||
.styled(style -> style.withColor(ctx.get(textColor)))
|
||||
new TextComponent("Wave from ")
|
||||
.withStyle(style -> style.withColor(ctx.get(textColor)))
|
||||
.append(ctx.getSender().getDisplayName()),
|
||||
MessageType.SYSTEM,
|
||||
ChatType.SYSTEM,
|
||||
Util.NIL_UUID
|
||||
));
|
||||
ctx.getSender().sendFeedback(
|
||||
new LiteralText(String.format("Waved at %d players (%s)", selected.size(),
|
||||
ctx.getSender().sendSuccess(
|
||||
new TextComponent(String.format("Waved at %d players (%s)", selected.size(),
|
||||
selector.inputString()
|
||||
)),
|
||||
false
|
||||
|
|
@ -128,15 +128,15 @@ public final class FabricExample implements ModInitializer {
|
|||
manager.command(base.literal("give")
|
||||
.permission("cloud.give")
|
||||
.argument(MultiplePlayerSelectorArgument.of("targets"))
|
||||
.argument(ItemDataArgument.of("item"))
|
||||
.argument(IntegerArgument.<ServerCommandSource>newBuilder("amount")
|
||||
.argument(ItemInputArgument.of("item"))
|
||||
.argument(IntegerArgument.<CommandSourceStack>newBuilder("amount")
|
||||
.withMin(1)
|
||||
.asOptionalWithDefault("1"))
|
||||
.handler(ctx -> {
|
||||
final ItemStackArgument item = ctx.get("item");
|
||||
final ItemInput item = ctx.get("item");
|
||||
final MultiplePlayerSelector targets = ctx.get("targets");
|
||||
final int amount = ctx.get("amount");
|
||||
GiveCommandAccess.give(
|
||||
GiveCommandAccess.giveItem(
|
||||
ctx.getSender(),
|
||||
item,
|
||||
targets.get(),
|
||||
|
|
@ -144,43 +144,45 @@ public final class FabricExample implements ModInitializer {
|
|||
);
|
||||
}));
|
||||
|
||||
final Command.Builder<ServerCommandSource> mods = base.literal("mods").permission("cloud.mods");
|
||||
final Command.Builder<CommandSourceStack> mods = base.literal("mods").permission("cloud.mods");
|
||||
|
||||
manager.command(mods.handler(ctx -> {
|
||||
final List<ModMetadata> modList = FabricLoader.getInstance().getAllMods().stream()
|
||||
.map(ModContainer::getMetadata)
|
||||
.sorted(Comparator.comparing(ModMetadata::getId))
|
||||
.collect(Collectors.toList());
|
||||
final LiteralText text = new LiteralText("");
|
||||
text.append(new LiteralText("Loaded Mods")
|
||||
.styled(style -> style.withColor(Formatting.BLUE).withFormatting(Formatting.BOLD)));
|
||||
text.append(new LiteralText(String.format(" (%s)\n", modList.size()))
|
||||
.styled(style -> style.withColor(Formatting.GRAY).withFormatting(Formatting.ITALIC)));
|
||||
final TextComponent text = new TextComponent("");
|
||||
text.append(new TextComponent("Loaded Mods")
|
||||
.withStyle(style -> style.withColor(ChatFormatting.BLUE).applyFormat(ChatFormatting.BOLD)));
|
||||
text.append(new TextComponent(String.format(" (%s)\n", modList.size()))
|
||||
.withStyle(style -> style.withColor(ChatFormatting.GRAY).applyFormat(ChatFormatting.ITALIC)));
|
||||
for (final ModMetadata mod : modList) {
|
||||
text.append(
|
||||
new LiteralText("")
|
||||
.styled(style -> style.withColor(Formatting.WHITE)
|
||||
new TextComponent("")
|
||||
.withStyle(style -> style.withColor(ChatFormatting.WHITE)
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.SUGGEST_COMMAND,
|
||||
String.format("/cloudtest mods %s", mod.getId())
|
||||
))
|
||||
.withHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new LiteralText("Click for more info")
|
||||
new TextComponent("Click for more info")
|
||||
)))
|
||||
.append(new LiteralText(mod.getName()).styled(style -> style.withColor(Formatting.GREEN)))
|
||||
.append(new LiteralText(String.format(" (%s) ", mod.getId()))
|
||||
.styled(style -> style.withColor(Formatting.GRAY).withFormatting(Formatting.ITALIC)))
|
||||
.append(new LiteralText(String.format("v%s", mod.getVersion())))
|
||||
.append(new TextComponent(mod.getName()).withStyle(style -> style.withColor(ChatFormatting.GREEN)))
|
||||
.append(new TextComponent(String.format(" (%s) ", mod.getId()))
|
||||
.withStyle(style -> style
|
||||
.withColor(ChatFormatting.GRAY)
|
||||
.applyFormat(ChatFormatting.ITALIC)))
|
||||
.append(new TextComponent(String.format("v%s", mod.getVersion())))
|
||||
);
|
||||
if (modList.indexOf(mod) != modList.size() - 1) {
|
||||
text.append(new LiteralText(", ").styled(style -> style.withColor(Formatting.GRAY)));
|
||||
text.append(new TextComponent(", ").withStyle(style -> style.withColor(ChatFormatting.GRAY)));
|
||||
}
|
||||
}
|
||||
ctx.getSender().sendFeedback(text, false);
|
||||
ctx.getSender().sendSuccess(text, false);
|
||||
}));
|
||||
|
||||
final CommandArgument<ServerCommandSource, ModMetadata> modMetadata = manager.argumentBuilder(ModMetadata.class, "mod")
|
||||
final CommandArgument<CommandSourceStack, ModMetadata> modMetadata = manager.argumentBuilder(ModMetadata.class, "mod")
|
||||
.withSuggestionsProvider((ctx, input) -> FabricLoader.getInstance().getAllMods().stream()
|
||||
.map(ModContainer::getMetadata)
|
||||
.map(ModMetadata::getId)
|
||||
|
|
@ -203,25 +205,25 @@ public final class FabricExample implements ModInitializer {
|
|||
manager.command(mods.argument(modMetadata)
|
||||
.handler(ctx -> {
|
||||
final ModMetadata meta = ctx.get(modMetadata);
|
||||
final MutableText text = new LiteralText("")
|
||||
.append(new LiteralText(meta.getName())
|
||||
.styled(style -> style.withColor(Formatting.BLUE).withFormatting(Formatting.BOLD)))
|
||||
.append(new LiteralText("\n modid: " + meta.getId()))
|
||||
.append(new LiteralText("\n version: " + meta.getVersion()))
|
||||
.append(new LiteralText("\n type: " + meta.getType()));
|
||||
final MutableComponent text = new TextComponent("")
|
||||
.append(new TextComponent(meta.getName())
|
||||
.withStyle(style -> style.withColor(ChatFormatting.BLUE).applyFormat(ChatFormatting.BOLD)))
|
||||
.append(new TextComponent("\n modid: " + meta.getId()))
|
||||
.append(new TextComponent("\n version: " + meta.getVersion()))
|
||||
.append(new TextComponent("\n type: " + meta.getType()));
|
||||
|
||||
if (!meta.getDescription().isEmpty()) {
|
||||
text.append(new LiteralText("\n description: " + meta.getDescription()));
|
||||
text.append(new TextComponent("\n description: " + meta.getDescription()));
|
||||
}
|
||||
if (!meta.getAuthors().isEmpty()) {
|
||||
text.append(new LiteralText("\n authors: " + meta.getAuthors().stream()
|
||||
text.append(new TextComponent("\n authors: " + meta.getAuthors().stream()
|
||||
.map(Person::getName)
|
||||
.collect(Collectors.joining(", "))));
|
||||
}
|
||||
if (!meta.getLicense().isEmpty()) {
|
||||
text.append(new LiteralText("\n license: " + String.join(", ", meta.getLicense())));
|
||||
text.append(new TextComponent("\n license: " + String.join(", ", meta.getLicense())));
|
||||
}
|
||||
ctx.getSender().sendFeedback(
|
||||
ctx.getSender().sendSuccess(
|
||||
text,
|
||||
false
|
||||
);
|
||||
|
|
@ -233,25 +235,25 @@ public final class FabricExample implements ModInitializer {
|
|||
.argument(Vec3dArgument.of("location"))
|
||||
.handler(ctx -> {
|
||||
final MultipleEntitySelector selector = ctx.get("targets");
|
||||
final Vec3d location = ctx.<Coordinates>get("location").position();
|
||||
final Vec3 location = ctx.<Coordinates>get("location").position();
|
||||
selector.get().forEach(target ->
|
||||
target.requestTeleport(location.getX(), location.getY(), location.getZ()));
|
||||
target.teleportToWithTicket(location.x(), location.y(), location.z()));
|
||||
}));
|
||||
|
||||
manager.command(base.literal("gotochunk")
|
||||
.permission("cloud.gotochunk")
|
||||
.argument(ColumnPosArgument.of("chunk_position"))
|
||||
.handler(ctx -> {
|
||||
final ServerPlayerEntity player;
|
||||
final ServerPlayer player;
|
||||
try {
|
||||
player = ctx.getSender().getPlayer();
|
||||
player = ctx.getSender().getPlayerOrException();
|
||||
} catch (final CommandSyntaxException e) {
|
||||
ctx.getSender().sendFeedback(Texts.toText(e.getRawMessage()), false);
|
||||
ctx.getSender().sendSuccess(ComponentUtils.fromMessage(e.getRawMessage()), false);
|
||||
return;
|
||||
}
|
||||
final Vec3d vec = ctx.<ColumnCoordinates>get("chunk_position").position();
|
||||
final ChunkPos pos = new ChunkPos((int) vec.getX(), (int) vec.getZ());
|
||||
player.requestTeleport(pos.getStartX(), 128, pos.getStartZ());
|
||||
final Vec3 vec = ctx.<ColumnCoordinates>get("chunk_position").position();
|
||||
final ChunkPos pos = new ChunkPos((int) vec.x(), (int) vec.z());
|
||||
player.teleportToWithTicket(pos.getMinBlockX(), 128, pos.getMinBlockZ());
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,10 +24,10 @@
|
|||
package cloud.commandframework.fabric.testmod.mixin;
|
||||
|
||||
import com.mojang.brigadier.Command;
|
||||
import net.minecraft.command.argument.ItemStackArgument;
|
||||
import net.minecraft.server.command.GiveCommand;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.arguments.item.ItemInput;
|
||||
import net.minecraft.server.commands.GiveCommand;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
|
|
@ -36,11 +36,11 @@ import java.util.Collection;
|
|||
@Mixin(GiveCommand.class)
|
||||
public interface GiveCommandAccess {
|
||||
|
||||
@Invoker("execute")
|
||||
static int give(
|
||||
final ServerCommandSource source,
|
||||
final ItemStackArgument item,
|
||||
final Collection<ServerPlayerEntity> targets,
|
||||
@Invoker("giveItem")
|
||||
static int giveItem(
|
||||
final CommandSourceStack source,
|
||||
final ItemInput item,
|
||||
final Collection<ServerPlayer> targets,
|
||||
final int count
|
||||
) {
|
||||
return Command.SINGLE_SUCCESS;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue