From a0a0966f99bff672b9a28d55b464a4ffd5ee4d2e Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Wed, 23 Sep 2020 01:02:19 -0400 Subject: [PATCH] Minor code cleanup --- .../com/velocitypowered/proxy/protocol/ProtocolUtils.java | 6 +----- .../proxy/protocol/util/ByteBufDataOutput.java | 2 +- .../java/com/velocitypowered/proxy/util/BrigadierUtils.java | 3 --- .../proxy/util/VelocityChannelRegistrar.java | 3 +-- 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/ProtocolUtils.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/ProtocolUtils.java index 2fa1e759a..a7e0bd437 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/ProtocolUtils.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/ProtocolUtils.java @@ -271,10 +271,6 @@ public enum ProtocolUtils { * @param stringArray the array to write */ public static void writeStringArray(ByteBuf buf, String[] stringArray) { - if (stringArray == null) { - writeVarInt(buf, 0); - return; - } writeVarInt(buf, stringArray.length); for (String s : stringArray) { writeString(buf, s); @@ -292,7 +288,7 @@ public enum ProtocolUtils { writeString(buf, property.getName()); writeString(buf, property.getValue()); String signature = property.getSignature(); - if (signature != null) { + if (signature != null && !signature.isEmpty()) { buf.writeBoolean(true); writeString(buf, signature); } else { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/ByteBufDataOutput.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/ByteBufDataOutput.java index ff8149332..644c1e3c6 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/ByteBufDataOutput.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/util/ByteBufDataOutput.java @@ -10,7 +10,7 @@ import java.io.OutputStream; import java.nio.charset.StandardCharsets; /** - * A {@link DataOutput} equivalent to {@link ByteBufDataInput}. + * A {@link ByteArrayDataOutput} equivalent to {@link ByteBufDataInput}. */ public class ByteBufDataOutput extends OutputStream implements ByteArrayDataOutput { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/util/BrigadierUtils.java b/proxy/src/main/java/com/velocitypowered/proxy/util/BrigadierUtils.java index 5d753c155..1bad01978 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/util/BrigadierUtils.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/util/BrigadierUtils.java @@ -1,10 +1,8 @@ package com.velocitypowered.proxy.util; -import com.google.common.base.Preconditions; import com.google.common.base.Splitter; import com.mojang.brigadier.Command; import com.mojang.brigadier.arguments.StringArgumentType; -import com.mojang.brigadier.builder.ArgumentBuilder; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.builder.RequiredArgumentBuilder; import com.mojang.brigadier.context.CommandContext; @@ -13,7 +11,6 @@ import com.mojang.brigadier.tree.CommandNode; import com.mojang.brigadier.tree.LiteralCommandNode; import com.velocitypowered.api.command.CommandSource; import java.util.Locale; -import org.checkerframework.checker.nullness.qual.Nullable; /** * Provides utilities for working with Brigadier commands. diff --git a/proxy/src/main/java/com/velocitypowered/proxy/util/VelocityChannelRegistrar.java b/proxy/src/main/java/com/velocitypowered/proxy/util/VelocityChannelRegistrar.java index bb7c383bf..b07e4815f 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/util/VelocityChannelRegistrar.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/util/VelocityChannelRegistrar.java @@ -21,8 +21,7 @@ public class VelocityChannelRegistrar implements ChannelRegistrar { public void register(ChannelIdentifier... identifiers) { for (ChannelIdentifier identifier : identifiers) { Preconditions.checkArgument(identifier instanceof LegacyChannelIdentifier - || identifier instanceof MinecraftChannelIdentifier, - "identifier is unknown"); + || identifier instanceof MinecraftChannelIdentifier, "identifier is unknown"); } for (ChannelIdentifier identifier : identifiers) {