Fix Javadocs for PairedPluginChannelId and KeyedPluginChannelId

This commit is contained in:
Andrew Steinborn
2021-04-17 06:19:29 -04:00
parent ec6fb80d6c
commit 4318c179a4
6 changed files with 20 additions and 25 deletions

View File

@@ -22,7 +22,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.ImmutableList;
import com.velocitypowered.api.network.ProtocolVersion;
import com.velocitypowered.api.proxy.messages.MinecraftPluginChannelId;
import com.velocitypowered.api.proxy.messages.KeyedPluginChannelId;
import com.velocitypowered.api.proxy.messages.PairedPluginChannelId;
import com.velocitypowered.api.proxy.messages.PluginChannelId;
import com.velocitypowered.api.util.ProxyVersion;
@@ -178,8 +178,8 @@ public final class PluginMessageUtil {
}
public static String channelIdForVersion(PluginChannelId id, ProtocolVersion version) {
if (id instanceof MinecraftPluginChannelId) {
return ((MinecraftPluginChannelId) id).key().asString();
if (id instanceof KeyedPluginChannelId) {
return ((KeyedPluginChannelId) id).key().asString();
} else if (id instanceof PairedPluginChannelId) {
if (version.gte(ProtocolVersion.MINECRAFT_1_13)) {
return ((PairedPluginChannelId) id).modernChannelKey().asString();

View File

@@ -21,7 +21,7 @@ import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
import com.velocitypowered.api.network.ProtocolVersion;
import com.velocitypowered.api.proxy.messages.ChannelRegistrar;
import com.velocitypowered.api.proxy.messages.MinecraftPluginChannelId;
import com.velocitypowered.api.proxy.messages.KeyedPluginChannelId;
import com.velocitypowered.api.proxy.messages.PairedPluginChannelId;
import com.velocitypowered.api.proxy.messages.PluginChannelId;
import java.util.Collection;
@@ -38,12 +38,12 @@ public class VelocityChannelRegistrar implements ChannelRegistrar {
public void register(PluginChannelId... identifiers) {
for (PluginChannelId identifier : identifiers) {
Preconditions.checkArgument(identifier instanceof PairedPluginChannelId
|| identifier instanceof MinecraftPluginChannelId, "identifier is unknown");
|| identifier instanceof KeyedPluginChannelId, "identifier is unknown");
}
for (PluginChannelId identifier : identifiers) {
if (identifier instanceof MinecraftPluginChannelId) {
MinecraftPluginChannelId modern = (MinecraftPluginChannelId) identifier;
if (identifier instanceof KeyedPluginChannelId) {
KeyedPluginChannelId modern = (KeyedPluginChannelId) identifier;
byLegacyId.put(modern.key().asString(), identifier);
byKey.put(modern.key().asString(), identifier);
} else {
@@ -58,13 +58,13 @@ public class VelocityChannelRegistrar implements ChannelRegistrar {
public void unregister(PluginChannelId... identifiers) {
for (PluginChannelId identifier : identifiers) {
Preconditions.checkArgument(identifier instanceof PairedPluginChannelId
|| identifier instanceof MinecraftPluginChannelId,
|| identifier instanceof KeyedPluginChannelId,
"identifier is unknown");
}
for (PluginChannelId identifier : identifiers) {
if (identifier instanceof MinecraftPluginChannelId) {
MinecraftPluginChannelId modern = (MinecraftPluginChannelId) identifier;
if (identifier instanceof KeyedPluginChannelId) {
KeyedPluginChannelId modern = (KeyedPluginChannelId) identifier;
byKey.remove(modern.key().asString(), identifier);
} else {
PairedPluginChannelId paired = (PairedPluginChannelId) identifier;

View File

@@ -20,7 +20,7 @@ package com.velocitypowered.proxy.util;
import static org.junit.jupiter.api.Assertions.assertEquals;
import com.google.common.collect.ImmutableSet;
import com.velocitypowered.api.proxy.messages.MinecraftPluginChannelId;
import com.velocitypowered.api.proxy.messages.KeyedPluginChannelId;
import com.velocitypowered.api.proxy.messages.PairedPluginChannelId;
import com.velocitypowered.api.proxy.messages.PluginChannelId;
import net.kyori.adventure.key.Key;
@@ -28,7 +28,7 @@ import org.junit.jupiter.api.Test;
class VelocityChannelRegistrarTest {
private static final MinecraftPluginChannelId MODERN = PluginChannelId.wrap(
private static final KeyedPluginChannelId MODERN = PluginChannelId.wrap(
Key.key("velocity", "moderntest"));
private static final PairedPluginChannelId SIMPLE_LEGACY =
PluginChannelId.withLegacy("VelocityTest", Key.key("velocity", "test"));