Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-16 21:10:30 +01:00
Remove AdventureCompact in favor of the text 3.x serializer added in KyoriPowered/adventure-platform#23
Dieser Commit ist enthalten in:
Ursprung
5b9dbb74c9
Commit
5285a3c155
@ -32,6 +32,7 @@ dependencies {
|
||||
compile "net.kyori:adventure-text-serializer-gson:${adventureVersion}"
|
||||
compile "net.kyori:adventure-text-serializer-legacy:${adventureVersion}"
|
||||
compile "net.kyori:adventure-text-serializer-plain:${adventureVersion}"
|
||||
compile "net.kyori:adventure-text-serializer-legacy-text3:${adventureVersion}"
|
||||
|
||||
compile "org.slf4j:slf4j-api:${slf4jVersion}"
|
||||
compile 'com.google.inject:guice:4.2.3'
|
||||
|
@ -2,8 +2,8 @@ package com.velocitypowered.api.command;
|
||||
|
||||
import com.velocitypowered.api.permission.PermissionSubject;
|
||||
import com.velocitypowered.api.proxy.ProxyAudience;
|
||||
import com.velocitypowered.api.util.AdventureCompat;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.legacytext3.LegacyText3ComponentSerializer;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
/**
|
||||
@ -22,6 +22,6 @@ public interface CommandSource extends PermissionSubject, ProxyAudience {
|
||||
|
||||
@Override
|
||||
default void sendMessage(@NonNull Component message) {
|
||||
this.sendMessage(AdventureCompat.asOriginalTextComponent(message));
|
||||
this.sendMessage(LegacyText3ComponentSerializer.get().serialize(message));
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.velocitypowered.api.event;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.velocitypowered.api.util.AdventureCompat;
|
||||
import java.util.Optional;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.legacytext3.LegacyText3ComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
@ -95,7 +95,7 @@ public interface ResultedEvent<R extends ResultedEvent.Result> {
|
||||
|
||||
@Deprecated
|
||||
public Optional<net.kyori.text.Component> getReason() {
|
||||
return Optional.ofNullable(reason).map(AdventureCompat::asOriginalTextComponent);
|
||||
return Optional.ofNullable(reason).map(LegacyText3ComponentSerializer.get()::serialize);
|
||||
}
|
||||
|
||||
public Optional<Component> getReasonComponent() {
|
||||
@ -125,7 +125,8 @@ public interface ResultedEvent<R extends ResultedEvent.Result> {
|
||||
@Deprecated
|
||||
public static ComponentResult denied(net.kyori.text.Component reason) {
|
||||
Preconditions.checkNotNull(reason, "reason");
|
||||
return new ComponentResult(false, AdventureCompat.asAdventureComponent(reason));
|
||||
return new ComponentResult(false, LegacyText3ComponentSerializer.get()
|
||||
.deserialize(reason));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,8 +3,8 @@ package com.velocitypowered.api.event.connection;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.velocitypowered.api.event.ResultedEvent;
|
||||
import com.velocitypowered.api.proxy.InboundConnection;
|
||||
import com.velocitypowered.api.util.AdventureCompat;
|
||||
import java.util.Optional;
|
||||
import net.kyori.adventure.text.serializer.legacytext3.LegacyText3ComponentSerializer;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
@ -86,7 +86,7 @@ public final class PreLoginEvent implements ResultedEvent<PreLoginEvent.PreLogin
|
||||
|
||||
@Deprecated
|
||||
public Optional<net.kyori.text.Component> getReason() {
|
||||
return Optional.ofNullable(reason).map(AdventureCompat::asOriginalTextComponent);
|
||||
return Optional.ofNullable(reason).map(LegacyText3ComponentSerializer.get()::serialize);
|
||||
}
|
||||
|
||||
public Optional<net.kyori.adventure.text.Component> getReasonComponent() {
|
||||
@ -155,8 +155,8 @@ public final class PreLoginEvent implements ResultedEvent<PreLoginEvent.PreLogin
|
||||
@Deprecated
|
||||
public static PreLoginComponentResult denied(net.kyori.text.Component reason) {
|
||||
Preconditions.checkNotNull(reason, "reason");
|
||||
return new PreLoginComponentResult(Result.DISALLOWED,
|
||||
AdventureCompat.asAdventureComponent(reason));
|
||||
return new PreLoginComponentResult(Result.DISALLOWED, LegacyText3ComponentSerializer.get()
|
||||
.deserialize(reason));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4,8 +4,8 @@ import com.google.common.base.Preconditions;
|
||||
import com.velocitypowered.api.event.ResultedEvent;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import com.velocitypowered.api.util.AdventureCompat;
|
||||
import java.util.Optional;
|
||||
import net.kyori.adventure.text.serializer.legacytext3.LegacyText3ComponentSerializer;
|
||||
import net.kyori.text.Component;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
@ -50,8 +50,8 @@ public final class KickedFromServerEvent implements
|
||||
@Deprecated
|
||||
public KickedFromServerEvent(Player player, RegisteredServer server,
|
||||
@Nullable Component originalReason, boolean duringServerConnect, ServerKickResult result) {
|
||||
this(player, server, AdventureCompat.asAdventureComponent(originalReason), duringServerConnect,
|
||||
result);
|
||||
this(player, server, originalReason == null ? null : LegacyText3ComponentSerializer.get()
|
||||
.deserialize(originalReason), duringServerConnect, result);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -97,7 +97,7 @@ public final class KickedFromServerEvent implements
|
||||
*/
|
||||
@Deprecated
|
||||
public Optional<Component> getOriginalReason() {
|
||||
return Optional.ofNullable(originalReason).map(AdventureCompat::asOriginalTextComponent);
|
||||
return Optional.ofNullable(originalReason).map(LegacyText3ComponentSerializer.get()::serialize);
|
||||
}
|
||||
|
||||
public Optional<net.kyori.adventure.text.Component> getServerKickReason() {
|
||||
@ -150,7 +150,7 @@ public final class KickedFromServerEvent implements
|
||||
|
||||
@Deprecated
|
||||
public Component getReason() {
|
||||
return AdventureCompat.asOriginalTextComponent(component);
|
||||
return LegacyText3ComponentSerializer.get().serialize(component);
|
||||
}
|
||||
|
||||
public net.kyori.adventure.text.Component getReasonComponent() {
|
||||
@ -166,7 +166,7 @@ public final class KickedFromServerEvent implements
|
||||
*/
|
||||
@Deprecated
|
||||
public static DisconnectPlayer create(Component reason) {
|
||||
return new DisconnectPlayer(AdventureCompat.asAdventureComponent(reason));
|
||||
return new DisconnectPlayer(LegacyText3ComponentSerializer.get().deserialize(reason));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -206,7 +206,7 @@ public final class KickedFromServerEvent implements
|
||||
|
||||
@Deprecated
|
||||
public Component getMessage() {
|
||||
return AdventureCompat.asOriginalTextComponent(message);
|
||||
return LegacyText3ComponentSerializer.get().serialize(message);
|
||||
}
|
||||
|
||||
public net.kyori.adventure.text.Component getMessageComponent() {
|
||||
@ -225,7 +225,7 @@ public final class KickedFromServerEvent implements
|
||||
if (message == null) {
|
||||
return new RedirectPlayer(server, null);
|
||||
}
|
||||
return new RedirectPlayer(server, AdventureCompat.asAdventureComponent(message));
|
||||
return new RedirectPlayer(server, LegacyText3ComponentSerializer.get().deserialize(message));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -264,7 +264,7 @@ public final class KickedFromServerEvent implements
|
||||
|
||||
@Deprecated
|
||||
public Component getMessage() {
|
||||
return AdventureCompat.asOriginalTextComponent(message);
|
||||
return LegacyText3ComponentSerializer.get().serialize(message);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@ -281,7 +281,7 @@ public final class KickedFromServerEvent implements
|
||||
*/
|
||||
@Deprecated
|
||||
public static Notify create(Component message) {
|
||||
return new Notify(AdventureCompat.asAdventureComponent(message));
|
||||
return new Notify(LegacyText3ComponentSerializer.get().deserialize(message));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.velocitypowered.api.proxy.player;
|
||||
|
||||
import com.velocitypowered.api.util.AdventureCompat;
|
||||
import com.velocitypowered.api.util.GameProfile;
|
||||
import java.util.Optional;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.legacytext3.LegacyText3ComponentSerializer;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
@ -179,7 +179,7 @@ public interface TabListEntry {
|
||||
*/
|
||||
@Deprecated
|
||||
public Builder displayName(net.kyori.text.Component displayName) {
|
||||
return displayName(AdventureCompat.asAdventureComponent(displayName));
|
||||
return displayName(LegacyText3ComponentSerializer.get().deserialize(displayName));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3,7 +3,6 @@ package com.velocitypowered.api.proxy.server;
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.velocitypowered.api.util.AdventureCompat;
|
||||
import com.velocitypowered.api.util.Favicon;
|
||||
import com.velocitypowered.api.util.ModInfo;
|
||||
import java.util.ArrayList;
|
||||
@ -13,6 +12,7 @@ import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import net.kyori.adventure.text.serializer.legacytext3.LegacyText3ComponentSerializer;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
@ -29,7 +29,7 @@ public final class ServerPing {
|
||||
@Deprecated
|
||||
public ServerPing(Version version, @Nullable Players players,
|
||||
net.kyori.text.Component description, @Nullable Favicon favicon) {
|
||||
this(version, players, AdventureCompat.asAdventureComponent(description), favicon,
|
||||
this(version, players, LegacyText3ComponentSerializer.get().deserialize(description), favicon,
|
||||
ModInfo.DEFAULT);
|
||||
}
|
||||
|
||||
@ -51,7 +51,8 @@ public final class ServerPing {
|
||||
public ServerPing(Version version, @Nullable Players players,
|
||||
net.kyori.text.Component description, @Nullable Favicon favicon,
|
||||
@Nullable ModInfo modinfo) {
|
||||
this(version, players, AdventureCompat.asAdventureComponent(description), favicon, modinfo);
|
||||
this(version, players, LegacyText3ComponentSerializer.get().deserialize(description), favicon,
|
||||
modinfo);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -83,7 +84,7 @@ public final class ServerPing {
|
||||
|
||||
@Deprecated
|
||||
public net.kyori.text.Component getDescription() {
|
||||
return AdventureCompat.asOriginalTextComponent(description);
|
||||
return LegacyText3ComponentSerializer.get().serialize(description);
|
||||
}
|
||||
|
||||
public net.kyori.adventure.text.Component getDescriptionComponent() {
|
||||
@ -246,7 +247,7 @@ public final class ServerPing {
|
||||
|
||||
@Deprecated
|
||||
public Builder description(net.kyori.text.Component description) {
|
||||
this.description(AdventureCompat.asAdventureComponent(description));
|
||||
this.description(LegacyText3ComponentSerializer.get().deserialize(description));
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -295,7 +296,7 @@ public final class ServerPing {
|
||||
|
||||
@Deprecated
|
||||
public Optional<net.kyori.text.Component> getDescription() {
|
||||
return Optional.ofNullable(description).map(AdventureCompat::asOriginalTextComponent);
|
||||
return Optional.ofNullable(description).map(LegacyText3ComponentSerializer.get()::serialize);
|
||||
}
|
||||
|
||||
public Optional<net.kyori.adventure.text.Component> getDescriptionComponent() {
|
||||
|
@ -1,41 +0,0 @@
|
||||
package com.velocitypowered.api.util;
|
||||
|
||||
/**
|
||||
* Utilities to convert from adventure {@link net.kyori.adventure.text.Component}s to text
|
||||
* {@link net.kyori.text.Component}s and vice versa.
|
||||
*
|
||||
* @deprecated Provided only as a transitional aid, will be removed in Velocity 2.0.0
|
||||
*/
|
||||
@Deprecated
|
||||
public class AdventureCompat {
|
||||
private AdventureCompat() {
|
||||
throw new AssertionError("Do not create instances of this class.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an {@link net.kyori.text.Component} component into an adventure
|
||||
* {@link net.kyori.adventure.text.Component} component.
|
||||
* @param component the component to translate
|
||||
* @return the translated component
|
||||
*/
|
||||
public static net.kyori.adventure.text.Component asAdventureComponent(
|
||||
net.kyori.text.Component component) {
|
||||
String json = net.kyori.text.serializer.gson.GsonComponentSerializer.INSTANCE
|
||||
.serialize(component);
|
||||
return net.kyori.adventure.text.serializer.gson.GsonComponentSerializer.gson()
|
||||
.deserialize(json);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an {@link net.kyori.adventure.text.Component} component into an text
|
||||
* {@link net.kyori.text.Component} component.
|
||||
* @param component the component to translate
|
||||
* @return the translated component
|
||||
*/
|
||||
public static net.kyori.text.Component asOriginalTextComponent(
|
||||
net.kyori.adventure.text.Component component) {
|
||||
String json = net.kyori.adventure.text.serializer.gson.GsonComponentSerializer
|
||||
.colorDownsamplingGson().serialize(component);
|
||||
return net.kyori.text.serializer.gson.GsonComponentSerializer.INSTANCE.deserialize(json);
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ import com.google.common.base.MoreObjects;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.velocitypowered.api.proxy.config.ProxyConfig;
|
||||
import com.velocitypowered.api.util.AdventureCompat;
|
||||
import com.velocitypowered.api.util.Favicon;
|
||||
import com.velocitypowered.proxy.util.AddressUtil;
|
||||
import java.io.IOException;
|
||||
@ -25,6 +24,7 @@ import java.util.Random;
|
||||
import java.util.UUID;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.legacytext3.LegacyText3ComponentSerializer;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
@ -230,7 +230,7 @@ public class VelocityConfiguration implements ProxyConfig {
|
||||
*/
|
||||
@Override
|
||||
public net.kyori.text.Component getMotdComponent() {
|
||||
return AdventureCompat.asOriginalTextComponent(this.getMotd());
|
||||
return LegacyText3ComponentSerializer.get().serialize(this.getMotd());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -3,12 +3,12 @@ package com.velocitypowered.proxy.connection.util;
|
||||
import com.velocitypowered.api.proxy.ConnectionRequestBuilder;
|
||||
import com.velocitypowered.api.proxy.ConnectionRequestBuilder.Status;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import com.velocitypowered.api.util.AdventureCompat;
|
||||
import com.velocitypowered.proxy.protocol.packet.Disconnect;
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Nullable;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.legacytext3.LegacyText3ComponentSerializer;
|
||||
|
||||
public class ConnectionRequestResults {
|
||||
|
||||
@ -74,7 +74,7 @@ public class ConnectionRequestResults {
|
||||
|
||||
@Override
|
||||
public Optional<net.kyori.text.Component> getReason() {
|
||||
return Optional.ofNullable(component).map(AdventureCompat::asOriginalTextComponent);
|
||||
return Optional.ofNullable(component).map(LegacyText3ComponentSerializer.get()::serialize);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,10 +2,10 @@ package com.velocitypowered.proxy.tablist;
|
||||
|
||||
import com.velocitypowered.api.proxy.player.TabList;
|
||||
import com.velocitypowered.api.proxy.player.TabListEntry;
|
||||
import com.velocitypowered.api.util.AdventureCompat;
|
||||
import com.velocitypowered.api.util.GameProfile;
|
||||
import com.velocitypowered.proxy.protocol.packet.PlayerListItem;
|
||||
import java.util.Optional;
|
||||
import net.kyori.adventure.text.serializer.legacytext3.LegacyText3ComponentSerializer;
|
||||
import net.kyori.text.Component;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
@ -38,7 +38,7 @@ public class VelocityTabListEntry implements TabListEntry {
|
||||
|
||||
@Override
|
||||
public Optional<Component> getDisplayName() {
|
||||
return Optional.ofNullable(displayName).map(AdventureCompat::asOriginalTextComponent);
|
||||
return Optional.ofNullable(displayName).map(LegacyText3ComponentSerializer.get()::serialize);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -48,7 +48,10 @@ public class VelocityTabListEntry implements TabListEntry {
|
||||
|
||||
@Override
|
||||
public TabListEntry setDisplayName(@Nullable Component displayName) {
|
||||
return this.setDisplayName(AdventureCompat.asAdventureComponent(displayName));
|
||||
if (displayName == null) {
|
||||
return this.setDisplayName((net.kyori.adventure.text.Component) null);
|
||||
}
|
||||
return this.setDisplayName(LegacyText3ComponentSerializer.get().deserialize(displayName));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren