From 8460284ea02d4ac4fad4be4aff06904b65b61af6 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Mon, 28 Jun 2021 00:49:30 -0700 Subject: [PATCH] fabric: Remove get prefixes from new methods --- .../fabric/FabricCaptionKeys.java | 2 +- .../fabric/FabricCommandManager.java | 10 +++++----- .../fabric/FabricCommandPreprocessor.java | 2 +- .../FabricCommandRegistrationHandler.java | 20 +++++++++---------- .../fabric/FabricExecutor.java | 2 +- .../fabric/FabricServerCommandManager.java | 2 +- .../argument/FabricArgumentParsers.java | 18 ++++++++--------- .../fabric/argument/ItemInputArgument.java | 1 + .../argument/RegistryEntryArgument.java | 8 ++++---- .../commandframework/fabric/data/Message.java | 4 ++-- .../fabric/data/MinecraftTime.java | 6 +++--- 11 files changed, 38 insertions(+), 37 deletions(-) diff --git a/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/FabricCaptionKeys.java b/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/FabricCaptionKeys.java index 1eedfb49..801ee8bc 100644 --- a/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/FabricCaptionKeys.java +++ b/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/FabricCaptionKeys.java @@ -71,7 +71,7 @@ public final class FabricCaptionKeys { * @return Immutable collection of keys * @since 1.5.0 */ - public static @NonNull Collection<@NonNull Caption> getFabricCaptionKeys() { + public static @NonNull Collection<@NonNull Caption> fabricCaptionKeys() { return Collections.unmodifiableCollection(RECOGNIZED_CAPTIONS); } diff --git a/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/FabricCommandManager.java b/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/FabricCommandManager.java index 9d9fd962..ef88d515 100644 --- a/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/FabricCommandManager.java +++ b/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/FabricCommandManager.java @@ -211,7 +211,7 @@ public abstract class FabricCommandManager builder.to(argument -> { /* several registries have specialized argument types, so let's use those where possible */ - final ResourceKey> registry = argument.getRegistry(); + final ResourceKey> registry = argument.registryKey(); if (registry.equals(Registry.ENTITY_TYPE_REGISTRY)) { return EntitySummonArgument.id(); } else if (registry.equals(Registry.ENCHANTMENT_REGISTRY)) { @@ -226,7 +226,7 @@ public abstract class FabricCommandManager { /* A few other registries have client-side suggestion providers but no argument type */ /* Type parameters are messed up here for some reason */ - final ResourceKey> registry = argument.getRegistry(); + final ResourceKey> registry = argument.registryKey(); if (registry.equals(Registry.SOUND_EVENT_REGISTRY)) { return (SuggestionProvider) SuggestionProviders.AVAILABLE_SOUNDS; } else if (registry.equals(Registry.BIOME_REGISTRY)) { @@ -331,7 +331,7 @@ public abstract class FabricCommandManager getCommandSourceMapper() { + public final @NonNull Function<@NonNull S, @NonNull C> commandSourceMapper() { return this.commandSourceMapper; } @@ -341,7 +341,7 @@ public abstract class FabricCommandManager getBackwardsCommandSourceMapper() { + public final @NonNull Function<@NonNull C, @NonNull S> backwardsCommandSourceMapper() { return this.backwardsCommandSourceMapper; } @@ -363,7 +363,7 @@ public abstract class FabricCommandManager permissionLevel(final int permissionLevel) { - return sender -> this.getBackwardsCommandSourceMapper() + return sender -> this.backwardsCommandSourceMapper() .apply(sender) .hasPermission(permissionLevel); } diff --git a/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/FabricCommandPreprocessor.java b/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/FabricCommandPreprocessor.java index 83691b39..cede0936 100644 --- a/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/FabricCommandPreprocessor.java +++ b/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/FabricCommandPreprocessor.java @@ -39,7 +39,7 @@ final class FabricCommandPreprocessor implements CommandPreprocessor { public void accept(@NonNull final CommandPreprocessingContext context) { context.getCommandContext().store( FabricCommandContextKeys.NATIVE_COMMAND_SOURCE, - this.manager.getBackwardsCommandSourceMapper().apply(context.getCommandContext().getSender()) + this.manager.backwardsCommandSourceMapper().apply(context.getCommandContext().getSender()) ); } diff --git a/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/FabricCommandRegistrationHandler.java b/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/FabricCommandRegistrationHandler.java index 61dff759..8ca06038 100644 --- a/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/FabricCommandRegistrationHandler.java +++ b/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/FabricCommandRegistrationHandler.java @@ -58,7 +58,7 @@ abstract class FabricCommandRegistrationHandler getCommandManager() { + FabricCommandManager commandManager() { return this.commandManager; } @@ -110,18 +110,18 @@ abstract class FabricCommandRegistrationHandler rootNode = ClientCommandManager.DISPATCHER.getRoot(); final StaticArgument first = ((StaticArgument) command.getArguments().get(0)); final CommandNode baseNode = this - .getCommandManager() + .commandManager() .brigadierManager() .createLiteralCommandNode( first.getName(), command, - (src, perm) -> this.getCommandManager().hasPermission( - this.getCommandManager().getCommandSourceMapper().apply(src), + (src, perm) -> this.commandManager().hasPermission( + this.commandManager().commandSourceMapper().apply(src), perm ), true, new FabricExecutor<>( - this.getCommandManager(), + this.commandManager(), source -> source.getPlayer().getGameProfile().getName(), FabricClientCommandSource::sendError ) @@ -152,7 +152,7 @@ abstract class FabricCommandRegistrationHandler dispatcher, final boolean isDedicated) { - this.getCommandManager().registrationCalled(); + this.commandManager().registrationCalled(); for (final Command command : this.registeredCommands) { /* Only register commands in the declared environment */ final CommandSelection env = command.getCommandMeta().getOrDefault( @@ -171,15 +171,15 @@ abstract class FabricCommandRegistrationHandler dispatcher, final Command command) { @SuppressWarnings("unchecked") final StaticArgument first = ((StaticArgument) command.getArguments().get(0)); - final CommandNode baseNode = this.getCommandManager().brigadierManager().createLiteralCommandNode( + final CommandNode baseNode = this.commandManager().brigadierManager().createLiteralCommandNode( first.getName(), command, - (src, perm) -> this.getCommandManager().hasPermission( - this.getCommandManager().getCommandSourceMapper().apply(src), + (src, perm) -> this.commandManager().hasPermission( + this.commandManager().commandSourceMapper().apply(src), perm ), true, - new FabricExecutor<>(this.getCommandManager(), CommandSourceStack::getTextName, CommandSourceStack::sendFailure)); + new FabricExecutor<>(this.commandManager(), CommandSourceStack::getTextName, CommandSourceStack::sendFailure)); dispatcher.addChild(baseNode); diff --git a/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/FabricExecutor.java b/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/FabricExecutor.java index 9206041d..10edc946 100644 --- a/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/FabricExecutor.java +++ b/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/FabricExecutor.java @@ -79,7 +79,7 @@ final class FabricExecutor implements Com public int run(final @NonNull CommandContext ctx) { final S source = ctx.getSource(); final String input = ctx.getInput().substring(ctx.getLastChild().getNodes().get(0).getRange().getStart()); - final C sender = this.manager.getCommandSourceMapper().apply(source); + final C sender = this.manager.commandSourceMapper().apply(source); this.manager.executeCommand(sender, input).whenComplete((result, throwable) -> { if (throwable == null) { return; diff --git a/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/FabricServerCommandManager.java b/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/FabricServerCommandManager.java index 0bd347f9..cb5578e8 100644 --- a/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/FabricServerCommandManager.java +++ b/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/FabricServerCommandManager.java @@ -199,7 +199,7 @@ public final class FabricServerCommandManager extends FabricCommandManager ctx, final net.minecraft.commands.arguments.coordinates.@NonNull Coordinates posArgument ) { - return requireServerCommandSource( + return requireCommandSourceStack( ctx, serverCommandSource -> ArgumentParseResult.success((O) new CoordinatesImpl( serverCommandSource, @@ -153,7 +153,7 @@ public final class FabricArgumentParsers { */ public static @NonNull ArgumentParser singlePlayerSelector() { return new WrappedBrigadierParser(EntityArgument.player()) - .map((ctx, entitySelector) -> requireServerCommandSource( + .map((ctx, entitySelector) -> requireCommandSourceStack( ctx, serverCommandSource -> handleCommandSyntaxExceptionAsFailure( () -> ArgumentParseResult.success(new SinglePlayerSelectorImpl( @@ -174,7 +174,7 @@ public final class FabricArgumentParsers { */ public static @NonNull ArgumentParser multiplePlayerSelector() { return new WrappedBrigadierParser(EntityArgument.players()) - .map((ctx, entitySelector) -> requireServerCommandSource( + .map((ctx, entitySelector) -> requireCommandSourceStack( ctx, serverCommandSource -> handleCommandSyntaxExceptionAsFailure( () -> ArgumentParseResult.success(new MultiplePlayerSelectorImpl( @@ -195,7 +195,7 @@ public final class FabricArgumentParsers { */ public static @NonNull ArgumentParser singleEntitySelector() { return new WrappedBrigadierParser(EntityArgument.entity()) - .map((ctx, entitySelector) -> requireServerCommandSource( + .map((ctx, entitySelector) -> requireCommandSourceStack( ctx, serverCommandSource -> handleCommandSyntaxExceptionAsFailure( () -> ArgumentParseResult.success(new SingleEntitySelectorImpl( @@ -216,7 +216,7 @@ public final class FabricArgumentParsers { */ public static @NonNull ArgumentParser multipleEntitySelector() { return new WrappedBrigadierParser(EntityArgument.entities()) - .map((ctx, entitySelector) -> requireServerCommandSource( + .map((ctx, entitySelector) -> requireCommandSourceStack( ctx, serverCommandSource -> handleCommandSyntaxExceptionAsFailure( () -> ArgumentParseResult.success(new MultipleEntitySelectorImpl( @@ -237,7 +237,7 @@ public final class FabricArgumentParsers { */ public static @NonNull ArgumentParser message() { return new WrappedBrigadierParser(MessageArgument.message()) - .map((ctx, format) -> requireServerCommandSource( + .map((ctx, format) -> requireCommandSourceStack( ctx, serverCommandSource -> handleCommandSyntaxExceptionAsFailure( () -> ArgumentParseResult.success(MessageImpl.from( @@ -270,7 +270,7 @@ public final class FabricArgumentParsers { return new IllegalStateException("This command argument type is server-only."); } - private static @NonNull ArgumentParseResult requireServerCommandSource( + private static @NonNull ArgumentParseResult requireCommandSourceStack( final @NonNull CommandContext context, final @NonNull Function> resultFunction ) { @@ -315,12 +315,12 @@ public final class FabricArgumentParsers { } @Override - public @NonNull Collection getMentionedEntities() { + public @NonNull Collection mentionedEntities() { return this.mentionedEntities; } @Override - public @NonNull Component getContents() { + public @NonNull Component contents() { return this.contents; } diff --git a/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/argument/ItemInputArgument.java b/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/argument/ItemInputArgument.java index ce414a79..85f4d65e 100644 --- a/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/argument/ItemInputArgument.java +++ b/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/argument/ItemInputArgument.java @@ -117,6 +117,7 @@ public final class ItemInputArgument extends CommandArgument { * Builder for {@link ItemInputArgument}. * * @param sender type + * @since 1.5.0 */ public static final class Builder extends TypedBuilder> { diff --git a/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/argument/RegistryEntryArgument.java b/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/argument/RegistryEntryArgument.java index e07a8d60..5bb68186 100644 --- a/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/argument/RegistryEntryArgument.java +++ b/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/argument/RegistryEntryArgument.java @@ -222,7 +222,7 @@ public class RegistryEntryArgument extends CommandArgument { } inputQueue.poll(); - final Registry registry = this.getRegistry(commandContext); + final Registry registry = this.resolveRegistry(commandContext); if (registry == null) { return ArgumentParseResult.failure(new IllegalArgumentException("Unknown registry " + this.registryIdent)); } @@ -236,7 +236,7 @@ public class RegistryEntryArgument extends CommandArgument { } @SuppressWarnings("unchecked") - Registry getRegistry(final CommandContext ctx) { + Registry resolveRegistry(final CommandContext ctx) { final SharedSuggestionProvider reverseMapped = ctx.get(FabricCommandContextKeys.NATIVE_COMMAND_SOURCE); // First try dynamic registries (for things loaded from data-packs) Registry registry = reverseMapped.registryAccess().registry(this.registryIdent).orElse(null); @@ -252,7 +252,7 @@ public class RegistryEntryArgument extends CommandArgument { final @NonNull CommandContext commandContext, final @NonNull String input ) { - final Set ids = this.getRegistry(commandContext).keySet(); + final Set ids = this.resolveRegistry(commandContext).keySet(); final List results = new ArrayList<>(ids.size()); for (final ResourceLocation entry : ids) { if (entry.getNamespace().equals(NAMESPACE_MINECRAFT)) { @@ -275,7 +275,7 @@ public class RegistryEntryArgument extends CommandArgument { * @return the registry * @since 1.5.0 */ - public ResourceKey> getRegistry() { + public ResourceKey> registryKey() { return this.registryIdent; } diff --git a/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/data/Message.java b/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/data/Message.java index 0206353f..cc5d03b4 100644 --- a/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/data/Message.java +++ b/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/data/Message.java @@ -42,7 +42,7 @@ public interface Message { * @return the mentioned entities * @since 1.5.0 */ - @NonNull Collection getMentionedEntities(); + @NonNull Collection mentionedEntities(); /** * Get the parsed text contents of this message. @@ -50,6 +50,6 @@ public interface Message { * @return the parsed text * @since 1.5.0 */ - @NonNull Component getContents(); + @NonNull Component contents(); } diff --git a/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/data/MinecraftTime.java b/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/data/MinecraftTime.java index 7b7aae0f..61f7246d 100644 --- a/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/data/MinecraftTime.java +++ b/cloud-minecraft/cloud-fabric/src/main/java/cloud/commandframework/fabric/data/MinecraftTime.java @@ -89,12 +89,12 @@ public final class MinecraftTime { * Get the number of in-game ticks represented by this time. * *

This time will be truncated to the maximum value of an integer. - * See {@link #getLongTicks()} for the full contents.

+ * See {@link #ticksLong()} for the full contents.

* * @return the time in ticks * @since 1.5.0 */ - public int getTicks() { + public int ticks() { return (int) this.ticks; } @@ -104,7 +104,7 @@ public final class MinecraftTime { * @return the time in ticks * @since 1.5.0 */ - public long getLongTicks() { + public long ticksLong() { return this.ticks; }