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; package com.velocitypowered.api.proxy.messages;
import com.google.common.base.Preconditions; 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 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; private final Key key;
MinecraftPluginChannelId(Key key) { KeyedPluginChannelId(Key key) {
this.key = Preconditions.checkNotNull(key, "key"); this.key = Preconditions.checkNotNull(key, "key");
} }
@ -38,7 +34,7 @@ public final class MinecraftPluginChannelId implements PluginChannelId {
return false; return false;
} }
MinecraftPluginChannelId that = (MinecraftPluginChannelId) o; KeyedPluginChannelId that = (KeyedPluginChannelId) o;
return key.equals(that.key); return key.equals(that.key);
} }

Datei anzeigen

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

Datei anzeigen

@ -22,8 +22,8 @@ public interface PluginChannelId {
* @param key the key instance to wrap * @param key the key instance to wrap
* @return a wrapped plugin channel ID * @return a wrapped plugin channel ID
*/ */
static MinecraftPluginChannelId wrap(Key key) { static KeyedPluginChannelId wrap(Key key) {
return new MinecraftPluginChannelId(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.google.common.collect.ImmutableList;
import com.velocitypowered.api.network.ProtocolVersion; 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.PairedPluginChannelId;
import com.velocitypowered.api.proxy.messages.PluginChannelId; import com.velocitypowered.api.proxy.messages.PluginChannelId;
import com.velocitypowered.api.util.ProxyVersion; import com.velocitypowered.api.util.ProxyVersion;
@ -178,8 +178,8 @@ public final class PluginMessageUtil {
} }
public static String channelIdForVersion(PluginChannelId id, ProtocolVersion version) { public static String channelIdForVersion(PluginChannelId id, ProtocolVersion version) {
if (id instanceof MinecraftPluginChannelId) { if (id instanceof KeyedPluginChannelId) {
return ((MinecraftPluginChannelId) id).key().asString(); return ((KeyedPluginChannelId) id).key().asString();
} else if (id instanceof PairedPluginChannelId) { } else if (id instanceof PairedPluginChannelId) {
if (version.gte(ProtocolVersion.MINECRAFT_1_13)) { if (version.gte(ProtocolVersion.MINECRAFT_1_13)) {
return ((PairedPluginChannelId) id).modernChannelKey().asString(); 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.google.common.collect.ImmutableSet;
import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.api.network.ProtocolVersion;
import com.velocitypowered.api.proxy.messages.ChannelRegistrar; 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.PairedPluginChannelId;
import com.velocitypowered.api.proxy.messages.PluginChannelId; import com.velocitypowered.api.proxy.messages.PluginChannelId;
import java.util.Collection; import java.util.Collection;
@ -38,12 +38,12 @@ public class VelocityChannelRegistrar implements ChannelRegistrar {
public void register(PluginChannelId... identifiers) { public void register(PluginChannelId... identifiers) {
for (PluginChannelId identifier : identifiers) { for (PluginChannelId identifier : identifiers) {
Preconditions.checkArgument(identifier instanceof PairedPluginChannelId Preconditions.checkArgument(identifier instanceof PairedPluginChannelId
|| identifier instanceof MinecraftPluginChannelId, "identifier is unknown"); || identifier instanceof KeyedPluginChannelId, "identifier is unknown");
} }
for (PluginChannelId identifier : identifiers) { for (PluginChannelId identifier : identifiers) {
if (identifier instanceof MinecraftPluginChannelId) { if (identifier instanceof KeyedPluginChannelId) {
MinecraftPluginChannelId modern = (MinecraftPluginChannelId) identifier; KeyedPluginChannelId modern = (KeyedPluginChannelId) identifier;
byLegacyId.put(modern.key().asString(), identifier); byLegacyId.put(modern.key().asString(), identifier);
byKey.put(modern.key().asString(), identifier); byKey.put(modern.key().asString(), identifier);
} else { } else {
@ -58,13 +58,13 @@ public class VelocityChannelRegistrar implements ChannelRegistrar {
public void unregister(PluginChannelId... identifiers) { public void unregister(PluginChannelId... identifiers) {
for (PluginChannelId identifier : identifiers) { for (PluginChannelId identifier : identifiers) {
Preconditions.checkArgument(identifier instanceof PairedPluginChannelId Preconditions.checkArgument(identifier instanceof PairedPluginChannelId
|| identifier instanceof MinecraftPluginChannelId, || identifier instanceof KeyedPluginChannelId,
"identifier is unknown"); "identifier is unknown");
} }
for (PluginChannelId identifier : identifiers) { for (PluginChannelId identifier : identifiers) {
if (identifier instanceof MinecraftPluginChannelId) { if (identifier instanceof KeyedPluginChannelId) {
MinecraftPluginChannelId modern = (MinecraftPluginChannelId) identifier; KeyedPluginChannelId modern = (KeyedPluginChannelId) identifier;
byKey.remove(modern.key().asString(), identifier); byKey.remove(modern.key().asString(), identifier);
} else { } else {
PairedPluginChannelId paired = (PairedPluginChannelId) identifier; PairedPluginChannelId paired = (PairedPluginChannelId) identifier;

Datei anzeigen

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