3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-17 05:20:14 +01:00

Fix Javadocs for PairedPluginChannelId and KeyedPluginChannelId

Dieser Commit ist enthalten in:
Andrew Steinborn 2021-04-17 06:19:29 -04:00
Ursprung ec6fb80d6c
Commit 4318c179a4
6 geänderte Dateien mit 20 neuen und 25 gelöschten Zeilen

Datei anzeigen

@ -8,20 +8,16 @@
package com.velocitypowered.api.proxy.messages;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import java.util.Objects;
import java.util.regex.Pattern;
import net.kyori.adventure.key.Key;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Represents a Minecraft 1.13+ channel identifier.
* Represents a modern namespaced channel identifier.
*/
public final class MinecraftPluginChannelId implements PluginChannelId {
public final class KeyedPluginChannelId implements PluginChannelId {
private final Key key;
MinecraftPluginChannelId(Key key) {
KeyedPluginChannelId(Key key) {
this.key = Preconditions.checkNotNull(key, "key");
}
@ -38,7 +34,7 @@ public final class MinecraftPluginChannelId implements PluginChannelId {
return false;
}
MinecraftPluginChannelId that = (MinecraftPluginChannelId) o;
KeyedPluginChannelId that = (KeyedPluginChannelId) o;
return key.equals(that.key);
}

Datei anzeigen

@ -12,9 +12,8 @@ import com.google.common.base.Strings;
import net.kyori.adventure.key.Key;
/**
* Reperesents a legacy channel identifier (for Minecraft 1.12 and below). For modern 1.13 plugin
* messages, please see {@link MinecraftPluginChannelId}. This class is immutable and safe for
* multi-threaded use.
* Reperesents a legacy channel identifier (for Minecraft 1.12 and below) paired with a namespaced
* key for 1.13 and above. This class is immutable and safe for multi-threaded use.
*/
public final class PairedPluginChannelId implements PluginChannelId {

Datei anzeigen

@ -22,8 +22,8 @@ public interface PluginChannelId {
* @param key the key instance to wrap
* @return a wrapped plugin channel ID
*/
static MinecraftPluginChannelId wrap(Key key) {
return new MinecraftPluginChannelId(key);
static KeyedPluginChannelId wrap(Key key) {
return new KeyedPluginChannelId(key);
}
/**

Datei anzeigen

@ -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();

Datei anzeigen

@ -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;

Datei anzeigen

@ -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"));