From 717f2a070dd215902424804581df77288f999466 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Tue, 11 Aug 2020 13:24:05 -0400 Subject: [PATCH] Remove any use of the word "dummy" --- .../LegacyForgeHandshakeBackendPhase.java | 2 +- .../protocol/packet/AvailableCommands.java | 2 +- .../proxy/protocol/packet/JoinGame.java | 8 +- .../brigadier/ArgumentPropertyRegistry.java | 94 ++++++++++--------- ...a => EmptyArgumentPropertySerializer.java} | 8 +- ...=> GenericArgumentPropertySerializer.java} | 6 +- ...Property.java => PassthroughProperty.java} | 4 +- 7 files changed, 64 insertions(+), 60 deletions(-) rename proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/{DummyVoidArgumentPropertySerializer.java => EmptyArgumentPropertySerializer.java} (62%) rename proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/{VoidArgumentPropertySerializer.java => GenericArgumentPropertySerializer.java} (76%) rename proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/{DummyProperty.java => PassthroughProperty.java} (82%) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/forge/legacy/LegacyForgeHandshakeBackendPhase.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/forge/legacy/LegacyForgeHandshakeBackendPhase.java index c0da5ba99..cab0da94d 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/forge/legacy/LegacyForgeHandshakeBackendPhase.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/forge/legacy/LegacyForgeHandshakeBackendPhase.java @@ -15,7 +15,7 @@ import javax.annotation.Nullable; public enum LegacyForgeHandshakeBackendPhase implements BackendConnectionPhase { /** - * Dummy phase for use with {@link BackendConnectionPhases#UNKNOWN}. + * Indicates that the handshake has not started, used for {@link BackendConnectionPhases#UNKNOWN}. */ NOT_STARTED(LegacyForgeConstants.SERVER_HELLO_DISCRIMINATOR) { @Override diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/AvailableCommands.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/AvailableCommands.java index 4e72276ef..abab244fb 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/AvailableCommands.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/AvailableCommands.java @@ -246,7 +246,7 @@ public class AvailableCommands implements MinecraftPacket { } } - // If executable, add a dummy command + // If executable, add an empty command if ((flags & FLAG_EXECUTABLE) != 0) { args.executes((Command) context -> 0); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/JoinGame.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/JoinGame.java index bd4001cf1..1b8f3c175 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/JoinGame.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/JoinGame.java @@ -251,10 +251,10 @@ public class JoinGame implements MinecraftPacket { CompoundBinaryTag.Builder registryContainer = CompoundBinaryTag.builder(); ListBinaryTag encodedDimensionRegistry = dimensionRegistry.encodeRegistry(version); if (version.compareTo(ProtocolVersion.MINECRAFT_1_16_2) >= 0) { - CompoundBinaryTag.Builder dimensionRegistryDummy = CompoundBinaryTag.builder(); - dimensionRegistryDummy.putString("type", "minecraft:dimension_type"); - dimensionRegistryDummy.put("value", encodedDimensionRegistry); - registryContainer.put("minecraft:dimension_type", dimensionRegistryDummy.build()); + CompoundBinaryTag.Builder dimensionRegistryEntry = CompoundBinaryTag.builder(); + dimensionRegistryEntry.putString("type", "minecraft:dimension_type"); + dimensionRegistryEntry.put("value", encodedDimensionRegistry); + registryContainer.put("minecraft:dimension_type", dimensionRegistryEntry.build()); registryContainer.put("minecraft:worldgen/biome", biomeRegistry); } else { registryContainer.put("dimension", encodedDimensionRegistry); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/ArgumentPropertyRegistry.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/ArgumentPropertyRegistry.java index 4baa0a3cd..0fa649cc4 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/ArgumentPropertyRegistry.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/ArgumentPropertyRegistry.java @@ -1,7 +1,7 @@ package com.velocitypowered.proxy.protocol.packet.brigadier; import static com.velocitypowered.proxy.protocol.packet.brigadier.DoubleArgumentPropertySerializer.DOUBLE; -import static com.velocitypowered.proxy.protocol.packet.brigadier.DummyVoidArgumentPropertySerializer.DUMMY; +import static com.velocitypowered.proxy.protocol.packet.brigadier.EmptyArgumentPropertySerializer.EMPTY; import static com.velocitypowered.proxy.protocol.packet.brigadier.FloatArgumentPropertySerializer.FLOAT; import static com.velocitypowered.proxy.protocol.packet.brigadier.IntegerArgumentPropertySerializer.INTEGER; import static com.velocitypowered.proxy.protocol.packet.brigadier.LongArgumentPropertySerializer.LONG; @@ -36,7 +36,11 @@ public class ArgumentPropertyRegistry { classToId.put(klazz, identifier); } - private static void dummy(String identifier, ArgumentPropertySerializer serializer) { + private static void empty(String identifier) { + empty(identifier, EMPTY); + } + + private static void empty(String identifier, ArgumentPropertySerializer serializer) { byId.put(identifier, serializer); } @@ -56,7 +60,7 @@ public class ArgumentPropertyRegistry { if (result instanceof ArgumentType) { return (ArgumentType) result; } else { - return new DummyProperty(identifier, serializer, result); + return new PassthroughProperty(identifier, serializer, result); } } @@ -66,8 +70,8 @@ public class ArgumentPropertyRegistry { * @param type the type to serialize */ public static void serialize(ByteBuf buf, ArgumentType type) { - if (type instanceof DummyProperty) { - DummyProperty property = (DummyProperty) type; + if (type instanceof PassthroughProperty) { + PassthroughProperty property = (PassthroughProperty) type; ProtocolUtils.writeString(buf, property.getIdentifier()); if (property.getResult() != null) { property.getSerializer().serialize(property.getResult(), buf); @@ -91,50 +95,50 @@ public class ArgumentPropertyRegistry { register("brigadier:float", FloatArgumentType.class, FLOAT); register("brigadier:double", DoubleArgumentType.class, DOUBLE); register("brigadier:bool", BoolArgumentType.class, - VoidArgumentPropertySerializer.create(BoolArgumentType::bool)); + GenericArgumentPropertySerializer.create(BoolArgumentType::bool)); register("brigadier:long", LongArgumentType.class, LONG); // Minecraft argument types with extra properties - dummy("minecraft:entity", ByteArgumentPropertySerializer.BYTE); - dummy("minecraft:score_holder", ByteArgumentPropertySerializer.BYTE); + empty("minecraft:entity", ByteArgumentPropertySerializer.BYTE); + empty("minecraft:score_holder", ByteArgumentPropertySerializer.BYTE); // Minecraft argument types - dummy("minecraft:game_profile", DUMMY); - dummy("minecraft:block_pos", DUMMY); - dummy("minecraft:column_pos", DUMMY); - dummy("minecraft:vec3", DUMMY); - dummy("minecraft:vec2", DUMMY); - dummy("minecraft:block_state", DUMMY); - dummy("minecraft:block_predicate", DUMMY); - dummy("minecraft:item_stack", DUMMY); - dummy("minecraft:item_predicate", DUMMY); - dummy("minecraft:color", DUMMY); - dummy("minecraft:component", DUMMY); - dummy("minecraft:message", DUMMY); - dummy("minecraft:nbt", DUMMY); - dummy("minecraft:nbt_compound_tag", DUMMY); // added in 1.14 - dummy("minecraft:nbt_tag", DUMMY); // added in 1.14 - dummy("minecraft:nbt_path", DUMMY); - dummy("minecraft:objective", DUMMY); - dummy("minecraft:objective_criteria", DUMMY); - dummy("minecraft:operation", DUMMY); - dummy("minecraft:particle", DUMMY); - dummy("minecraft:rotation", DUMMY); - dummy("minecraft:scoreboard_slot", DUMMY); - dummy("minecraft:swizzle", DUMMY); - dummy("minecraft:team", DUMMY); - dummy("minecraft:item_slot", DUMMY); - dummy("minecraft:resource_location", DUMMY); - dummy("minecraft:mob_effect", DUMMY); - dummy("minecraft:function", DUMMY); - dummy("minecraft:entity_anchor", DUMMY); - dummy("minecraft:item_enchantment", DUMMY); - dummy("minecraft:entity_summon", DUMMY); - dummy("minecraft:dimension", DUMMY); - dummy("minecraft:int_range", DUMMY); - dummy("minecraft:float_range", DUMMY); - dummy("minecraft:time", DUMMY); // added in 1.14 - dummy("minecraft:uuid", DUMMY); // added in 1.16 - dummy("minecraft:angle", DUMMY); // added in 1.16.2 + empty("minecraft:game_profile"); + empty("minecraft:block_pos"); + empty("minecraft:column_pos"); + empty("minecraft:vec3"); + empty("minecraft:vec2"); + empty("minecraft:block_state"); + empty("minecraft:block_predicate"); + empty("minecraft:item_stack"); + empty("minecraft:item_predicate"); + empty("minecraft:color"); + empty("minecraft:component"); + empty("minecraft:message"); + empty("minecraft:nbt"); + empty("minecraft:nbt_compound_tag"); // added in 1.14 + empty("minecraft:nbt_tag"); // added in 1.14 + empty("minecraft:nbt_path"); + empty("minecraft:objective"); + empty("minecraft:objective_criteria"); + empty("minecraft:operation"); + empty("minecraft:particle"); + empty("minecraft:rotation"); + empty("minecraft:scoreboard_slot"); + empty("minecraft:swizzle"); + empty("minecraft:team"); + empty("minecraft:item_slot"); + empty("minecraft:resource_location"); + empty("minecraft:mob_effect"); + empty("minecraft:function"); + empty("minecraft:entity_anchor"); + empty("minecraft:item_enchantment"); + empty("minecraft:entity_summon"); + empty("minecraft:dimension"); + empty("minecraft:int_range"); + empty("minecraft:float_range"); + empty("minecraft:time", EMPTY); // added in 1.14 + empty("minecraft:uuid", EMPTY); // added in 1.16 + empty("minecraft:angle", EMPTY); // added in 1.16.2 } } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/DummyVoidArgumentPropertySerializer.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/EmptyArgumentPropertySerializer.java similarity index 62% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/DummyVoidArgumentPropertySerializer.java rename to proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/EmptyArgumentPropertySerializer.java index c134cc3cd..f101484a7 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/DummyVoidArgumentPropertySerializer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/EmptyArgumentPropertySerializer.java @@ -6,12 +6,12 @@ import org.checkerframework.checker.nullness.qual.Nullable; /** * An argument property serializer that will serialize and deserialize nothing. */ -class DummyVoidArgumentPropertySerializer implements ArgumentPropertySerializer { +class EmptyArgumentPropertySerializer implements ArgumentPropertySerializer { - static final ArgumentPropertySerializer DUMMY = - new DummyVoidArgumentPropertySerializer(); + static final ArgumentPropertySerializer EMPTY = + new EmptyArgumentPropertySerializer(); - private DummyVoidArgumentPropertySerializer() { + private EmptyArgumentPropertySerializer() { } @Override diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/VoidArgumentPropertySerializer.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/GenericArgumentPropertySerializer.java similarity index 76% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/VoidArgumentPropertySerializer.java rename to proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/GenericArgumentPropertySerializer.java index 848d8999c..f4e27dbf6 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/VoidArgumentPropertySerializer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/GenericArgumentPropertySerializer.java @@ -5,18 +5,18 @@ import io.netty.buffer.ByteBuf; import java.util.function.Supplier; import org.checkerframework.checker.nullness.qual.Nullable; -class VoidArgumentPropertySerializer> +class GenericArgumentPropertySerializer> implements ArgumentPropertySerializer { private final Supplier argumentSupplier; - private VoidArgumentPropertySerializer(Supplier argumentSupplier) { + private GenericArgumentPropertySerializer(Supplier argumentSupplier) { this.argumentSupplier = argumentSupplier; } public static > ArgumentPropertySerializer create( Supplier supplier) { - return new VoidArgumentPropertySerializer(supplier); + return new GenericArgumentPropertySerializer<>(supplier); } @Override diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/DummyProperty.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/PassthroughProperty.java similarity index 82% rename from proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/DummyProperty.java rename to proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/PassthroughProperty.java index 40ac9fd5c..0679e18d4 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/DummyProperty.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/PassthroughProperty.java @@ -4,13 +4,13 @@ import com.mojang.brigadier.StringReader; import com.mojang.brigadier.arguments.ArgumentType; import org.checkerframework.checker.nullness.qual.Nullable; -class DummyProperty implements ArgumentType { +class PassthroughProperty implements ArgumentType { private final String identifier; private final ArgumentPropertySerializer serializer; private final @Nullable T result; - DummyProperty(String identifier, ArgumentPropertySerializer serializer, @Nullable T result) { + PassthroughProperty(String identifier, ArgumentPropertySerializer serializer, @Nullable T result) { this.identifier = identifier; this.serializer = serializer; this.result = result;