13
0
geforkt von Mirrors/Velocity

Replacement of some deprecated method (#672)

- PlainComponentSerializer -> PlainTextComponentSerializer
- BinaryTagHolder#of -> BinaryTagHolder#binaryTagHolder
Dieser Commit ist enthalten in:
4drian3d 2022-03-31 21:09:44 -05:00 committet von GitHub
Ursprung 9f77431f36
Commit 9fc4341f40
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
6 geänderte Dateien mit 22 neuen und 14 gelöschten Zeilen

Datei anzeigen

@ -10,7 +10,8 @@ package com.velocitypowered.api.event;
import com.google.common.base.Preconditions;
import java.util.Optional;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@ -109,7 +110,7 @@ public interface ResultedEvent<R extends ResultedEvent.Result> {
return "allowed";
}
if (reason != null) {
return "denied: " + PlainComponentSerializer.plain().serialize(reason);
return "denied: " + PlainTextComponentSerializer.plainText().serialize(reason);
}
return "denied";
}

Datei anzeigen

@ -282,7 +282,7 @@ public class VelocityServer implements ProxyServer, ForwardingAudience {
logger.error("Encountered an I/O error whilst loading translations", e);
return;
}
GlobalTranslator.get().addSource(translationRegistry);
GlobalTranslator.translator().addSource(translationRegistry);
}
@SuppressFBWarnings("DM_EXIT")

Datei anzeigen

@ -92,11 +92,13 @@ import net.kyori.adventure.platform.facet.FacetPointers;
import net.kyori.adventure.platform.facet.FacetPointers.Type;
import net.kyori.adventure.pointer.Pointers;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.KeybindComponent;
import net.kyori.adventure.text.TranslatableComponent;
import net.kyori.adventure.text.flattener.ComponentFlattener;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
import net.kyori.adventure.title.Title.Times;
import net.kyori.adventure.title.TitlePart;
import net.kyori.adventure.translation.GlobalTranslator;
@ -110,8 +112,12 @@ import org.jetbrains.annotations.NotNull;
public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
private static final int MAX_PLUGIN_CHANNELS = 1024;
private static final PlainComponentSerializer PASS_THRU_TRANSLATE = new PlainComponentSerializer(
c -> "", TranslatableComponent::key);
private static final PlainTextComponentSerializer PASS_THRU_TRANSLATE = PlainTextComponentSerializer.builder()
.flattener(ComponentFlattener.basic().toBuilder()
.mapper(KeybindComponent.class, c -> "")
.mapper(TranslatableComponent.class, TranslatableComponent::key)
.build())
.build();
static final PermissionProvider DEFAULT_PERMISSIONS = s -> PermissionFunction.ALWAYS_UNDEFINED;
private static final Logger logger = LogManager.getLogger(ConnectedPlayer.class);

Datei anzeigen

@ -45,7 +45,8 @@ import java.util.List;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
import org.apache.logging.log4j.LogManager;
public class GS4QueryHandler extends SimpleChannelInboundHandler<DatagramPacket> {
@ -83,7 +84,7 @@ public class GS4QueryHandler extends SimpleChannelInboundHandler<DatagramPacket>
private QueryResponse createInitialResponse() {
return QueryResponse.builder()
.hostname(PlainComponentSerializer.plain().serialize(server.getConfiguration().getMotd()))
.hostname(PlainTextComponentSerializer.plainText().serialize(server.getConfiguration().getMotd()))
.gameVersion(ProtocolVersion.SUPPORTED_VERSION_STRING)
.map(server.getConfiguration().getQueryMap())
.currentPlayers(server.getPlayerCount())

Datei anzeigen

@ -23,7 +23,7 @@ import com.velocitypowered.api.proxy.server.ServerPing.Players;
import com.velocitypowered.proxy.protocol.packet.legacyping.LegacyMinecraftPingVersion;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
public class LegacyDisconnect {
@ -54,7 +54,7 @@ public class LegacyDisconnect {
// remove all section symbols, along with fetching just the first line of an (unformatted)
// MOTD.
return new LegacyDisconnect(String.join(LEGACY_COLOR_CODE,
cleanSectionSymbol(getFirstLine(PlainComponentSerializer.plain().serialize(
cleanSectionSymbol(getFirstLine(PlainTextComponentSerializer.plainText().serialize(
response.getDescriptionComponent()))),
Integer.toString(players.getOnline()),
Integer.toString(players.getMax())));

Datei anzeigen

@ -29,7 +29,7 @@ import net.kyori.adventure.text.event.HoverEvent;
import net.kyori.adventure.text.event.HoverEvent.ShowEntity;
import net.kyori.adventure.text.event.HoverEvent.ShowItem;
import net.kyori.adventure.text.serializer.gson.LegacyHoverEventSerializer;
import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
import net.kyori.adventure.util.Codec.Decoder;
import net.kyori.adventure.util.Codec.Encoder;
import org.checkerframework.checker.nullness.qual.NonNull;
@ -54,7 +54,7 @@ public class VelocityLegacyHoverEventSerializer implements LegacyHoverEventSeria
@Override
public HoverEvent.@NonNull ShowItem deserializeShowItem(@NonNull Component input)
throws IOException {
String snbt = PlainComponentSerializer.plain().serialize(input);
String snbt = PlainTextComponentSerializer.plainText().serialize(input);
CompoundBinaryTag item = TagStringIO.get().asCompound(snbt);
Key key;
@ -66,13 +66,13 @@ public class VelocityLegacyHoverEventSerializer implements LegacyHoverEventSeria
}
byte count = item.getByte("Count", (byte) 1);
return ShowItem.of(key, count, BinaryTagHolder.of(snbt));
return ShowItem.of(key, count, BinaryTagHolder.binaryTagHolder(snbt));
}
@Override
public HoverEvent.@NonNull ShowEntity deserializeShowEntity(@NonNull Component input,
Decoder<Component, String, ? extends RuntimeException> componentDecoder) throws IOException {
String snbt = PlainComponentSerializer.plain().serialize(input);
String snbt = PlainTextComponentSerializer.plainText().serialize(input);
CompoundBinaryTag item = TagStringIO.get().asCompound(snbt);
Component name;