Bump to 2.0.0-SNAPSHOT, remove deprecated text API and toml4j

This commit is contained in:
Andrew Steinborn
2020-10-21 23:57:53 -04:00
parent a6e708c98e
commit 9dfe44b125
42 changed files with 57 additions and 1488 deletions

View File

@@ -18,20 +18,10 @@ dependencies {
api 'com.google.code.gson:gson:2.8.6'
api "com.google.guava:guava:${guavaVersion}"
// DEPRECATED: Will be removed in Velocity 2.0.0
api "net.kyori:text-api:${textVersion}"
api "net.kyori:text-serializer-gson:${textVersion}"
api "net.kyori:text-serializer-legacy:${textVersion}"
api "net.kyori:text-serializer-plain:${textVersion}"
// DEPRECATED: Will be removed in Velocity 2.0.0
api 'com.moandjiezana.toml:toml4j:0.7.2'
api "net.kyori:adventure-api:${adventureVersion}"
api "net.kyori:adventure-text-serializer-gson:${adventureVersion}"
api "net.kyori:adventure-text-serializer-legacy:${adventureVersion}"
api "net.kyori:adventure-text-serializer-plain:${adventureVersion}"
api "net.kyori:adventure-text-serializer-legacy-text3:${adventurePlatformVersion}"
api "org.slf4j:slf4j-api:${slf4jVersion}"
api 'com.google.inject:guice:4.2.3'

View File

@@ -2,31 +2,9 @@ package com.velocitypowered.api.command;
import com.velocitypowered.api.permission.PermissionSubject;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.audience.MessageType;
import net.kyori.adventure.identity.Identified;
import net.kyori.adventure.identity.Identity;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.legacytext3.LegacyText3ComponentSerializer;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Represents something that can be used to run a {@link Command}.
*/
public interface CommandSource extends Audience, PermissionSubject {
/**
* Sends the specified {@code component} to the invoker.
*
* @param component the text component to send
* @deprecated Use {@link #sendMessage(Identified, Component)}
* or {@link #sendMessage(Identity, Component)} instead
*/
@Deprecated
void sendMessage(net.kyori.text.Component component);
@Override
default void sendMessage(@NonNull Identity identity, @NonNull Component message,
@NonNull MessageType type) {
this.sendMessage(LegacyText3ComponentSerializer.get().serialize(message));
}
}

View File

@@ -3,7 +3,6 @@ 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.legacytext3.LegacyText3ComponentSerializer;
import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -93,12 +92,7 @@ public interface ResultedEvent<R extends ResultedEvent.Result> {
return status;
}
@Deprecated
public Optional<net.kyori.text.Component> getReason() {
return Optional.ofNullable(reason).map(LegacyText3ComponentSerializer.get()::serialize);
}
public Optional<Component> getReasonComponent() {
public Optional<Component> getReason() {
return Optional.ofNullable(reason);
}
@@ -121,12 +115,5 @@ public interface ResultedEvent<R extends ResultedEvent.Result> {
Preconditions.checkNotNull(reason, "reason");
return new ComponentResult(false, reason);
}
@Deprecated
public static ComponentResult denied(net.kyori.text.Component reason) {
Preconditions.checkNotNull(reason, "reason");
return new ComponentResult(false, LegacyText3ComponentSerializer.get()
.deserialize(reason));
}
}
}

View File

@@ -4,7 +4,7 @@ import com.google.common.base.Preconditions;
import com.velocitypowered.api.event.ResultedEvent;
import com.velocitypowered.api.proxy.InboundConnection;
import java.util.Optional;
import net.kyori.adventure.text.serializer.legacytext3.LegacyText3ComponentSerializer;
import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -71,10 +71,10 @@ public final class PreLoginEvent implements ResultedEvent<PreLoginEvent.PreLogin
Result.FORCE_OFFLINE, null);
private final Result result;
private final net.kyori.adventure.text.Component reason;
private final Component reason;
private PreLoginComponentResult(Result result,
net.kyori.adventure.text.@Nullable Component reason) {
@Nullable Component reason) {
this.result = result;
this.reason = reason;
}
@@ -84,12 +84,7 @@ public final class PreLoginEvent implements ResultedEvent<PreLoginEvent.PreLogin
return result != Result.DISALLOWED;
}
@Deprecated
public Optional<net.kyori.text.Component> getReason() {
return Optional.ofNullable(reason).map(LegacyText3ComponentSerializer.get()::serialize);
}
public Optional<net.kyori.adventure.text.Component> getReasonComponent() {
public Optional<Component> getReason() {
return Optional.ofNullable(reason);
}
@@ -149,23 +144,9 @@ public final class PreLoginEvent implements ResultedEvent<PreLoginEvent.PreLogin
* Denies the login with the specified reason.
*
* @param reason the reason for disallowing the connection
* @deprecated Use {@link #denied(net.kyori.adventure.text.Component)}
* @return a new result
*/
@Deprecated
public static PreLoginComponentResult denied(net.kyori.text.Component reason) {
Preconditions.checkNotNull(reason, "reason");
return new PreLoginComponentResult(Result.DISALLOWED, LegacyText3ComponentSerializer.get()
.deserialize(reason));
}
/**
* Denies the login with the specified reason.
*
* @param reason the reason for disallowing the connection
* @return a new result
*/
public static PreLoginComponentResult denied(net.kyori.adventure.text.Component reason) {
public static PreLoginComponentResult denied(Component reason) {
Preconditions.checkNotNull(reason, "reason");
return new PreLoginComponentResult(Result.DISALLOWED, reason);
}

View File

@@ -5,8 +5,7 @@ import com.velocitypowered.api.event.ResultedEvent;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import java.util.Optional;
import net.kyori.adventure.text.serializer.legacytext3.LegacyText3ComponentSerializer;
import net.kyori.text.Component;
import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -21,39 +20,10 @@ public final class KickedFromServerEvent implements
private final Player player;
private final RegisteredServer server;
private final net.kyori.adventure.text.@Nullable Component originalReason;
private final @Nullable Component originalReason;
private final boolean duringServerConnect;
private ServerKickResult result;
/**
* Creates a {@code KickedFromServerEvent} instance.
* @param player the player affected
* @param server the server the player disconnected from
* @param originalReason the reason for being kicked, optional
* @param duringServerConnect whether or not the player was kicked during the connection process
* @param fancyReason a fancy reason for being disconnected, used for the initial result
*/
@Deprecated
public KickedFromServerEvent(Player player, RegisteredServer server,
@Nullable Component originalReason, boolean duringServerConnect, Component fancyReason) {
this(player, server, originalReason, duringServerConnect, Notify.create(fancyReason));
}
/**
* Creates a {@code KickedFromServerEvent} instance.
* @param player the player affected
* @param server the server the player disconnected from
* @param originalReason the reason for being kicked, optional
* @param duringServerConnect whether or not the player was kicked during the connection process
* @param result the initial result
*/
@Deprecated
public KickedFromServerEvent(Player player, RegisteredServer server,
@Nullable Component originalReason, boolean duringServerConnect, ServerKickResult result) {
this(player, server, originalReason == null ? null : LegacyText3ComponentSerializer.get()
.deserialize(originalReason), duringServerConnect, result);
}
/**
* Creates a {@code KickedFromServerEvent} instance.
* @param player the player affected
@@ -93,14 +63,8 @@ public final class KickedFromServerEvent implements
/**
* Gets the reason the server kicked the player from the server.
* @return the server kicked the player from the server
* @deprecated Use {@link #getServerKickReason()} instead
*/
@Deprecated
public Optional<Component> getOriginalReason() {
return Optional.ofNullable(originalReason).map(LegacyText3ComponentSerializer.get()::serialize);
}
public Optional<net.kyori.adventure.text.Component> getServerKickReason() {
public Optional<Component> getServerKickReason() {
return Optional.ofNullable(originalReason);
}
@@ -113,18 +77,6 @@ public final class KickedFromServerEvent implements
return duringServerConnect;
}
/**
* Returns whether or not the player got kicked while logging in.
*
* @return whether or not the player got kicked
* @deprecated {@link #kickedDuringServerConnect()} has a better name and reflects the actual
* result
*/
@Deprecated
public boolean kickedDuringLogin() {
return duringServerConnect;
}
/**
* Represents the base interface for {@link KickedFromServerEvent} results.
*/
@@ -137,9 +89,9 @@ public final class KickedFromServerEvent implements
*/
public static final class DisconnectPlayer implements ServerKickResult {
private final net.kyori.adventure.text.Component component;
private final Component component;
private DisconnectPlayer(net.kyori.adventure.text.Component component) {
private DisconnectPlayer(Component component) {
this.component = Preconditions.checkNotNull(component, "component");
}
@@ -148,12 +100,7 @@ public final class KickedFromServerEvent implements
return true;
}
@Deprecated
public Component getReason() {
return LegacyText3ComponentSerializer.get().serialize(component);
}
public net.kyori.adventure.text.Component getReasonComponent() {
return component;
}
@@ -162,20 +109,8 @@ public final class KickedFromServerEvent implements
*
* @param reason the reason to use when disconnecting the player
* @return the disconnect result
* @deprecated Use {@link #create(net.kyori.adventure.text.Component)} instead
*/
@Deprecated
public static DisconnectPlayer create(Component reason) {
return new DisconnectPlayer(LegacyText3ComponentSerializer.get().deserialize(reason));
}
/**
* Creates a new {@link DisconnectPlayer} with the specified reason.
*
* @param reason the reason to use when disconnecting the player
* @return the disconnect result
*/
public static DisconnectPlayer create(net.kyori.adventure.text.Component reason) {
return new DisconnectPlayer(reason);
}
}
@@ -186,7 +121,7 @@ public final class KickedFromServerEvent implements
*/
public static final class RedirectPlayer implements ServerKickResult {
private final net.kyori.adventure.text.Component message;
private final Component message;
private final RegisteredServer server;
private RedirectPlayer(RegisteredServer server,
@@ -204,30 +139,10 @@ public final class KickedFromServerEvent implements
return server;
}
@Deprecated
public Component getMessage() {
return LegacyText3ComponentSerializer.get().serialize(message);
}
public net.kyori.adventure.text.@Nullable Component getMessageComponent() {
return message;
}
/**
* Creates a new redirect result to forward the player to the specified {@code server}.
*
* @param server the server to send the player to
* @return the redirect result
* @deprecated Use {@link #create(RegisteredServer, net.kyori.adventure.text.Component)}
*/
@Deprecated
public static RedirectPlayer create(RegisteredServer server, net.kyori.text.Component message) {
if (message == null) {
return new RedirectPlayer(server, null);
}
return new RedirectPlayer(server, LegacyText3ComponentSerializer.get().deserialize(message));
}
/**
* Creates a new redirect result to forward the player to the specified {@code server}.
*
@@ -235,7 +150,7 @@ public final class KickedFromServerEvent implements
* @return the redirect result
*/
public static RedirectPlayer create(RegisteredServer server,
net.kyori.adventure.text.Component message) {
Component message) {
return new RedirectPlayer(server, message);
}
@@ -251,9 +166,9 @@ public final class KickedFromServerEvent implements
*/
public static final class Notify implements ServerKickResult {
private final net.kyori.adventure.text.Component message;
private final Component message;
private Notify(net.kyori.adventure.text.Component message) {
private Notify(Component message) {
this.message = Preconditions.checkNotNull(message, "message");
}
@@ -262,12 +177,7 @@ public final class KickedFromServerEvent implements
return false;
}
@Deprecated
public Component getMessage() {
return LegacyText3ComponentSerializer.get().serialize(message);
}
public net.kyori.adventure.text.Component getMessageComponent() {
return message;
}
@@ -276,20 +186,8 @@ public final class KickedFromServerEvent implements
*
* @param message the server to send the player to
* @return the redirect result
* @deprecated Use {@link #create(net.kyori.adventure.text.Component)} instead
*/
@Deprecated
public static Notify create(Component message) {
return new Notify(LegacyText3ComponentSerializer.get().deserialize(message));
}
/**
* Notifies the player with the specified message but does nothing else.
*
* @param message the server to send the player to
* @return the redirect result
*/
public static Notify create(net.kyori.adventure.text.Component message) {
return new Notify(message);
}
}

View File

@@ -3,7 +3,7 @@ package com.velocitypowered.api.proxy;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import net.kyori.text.Component;
import net.kyori.adventure.text.Component;
/**
* Provides a fluent interface to send a connection request to another server on the proxy. A
@@ -67,18 +67,9 @@ public interface ConnectionRequestBuilder {
* Returns an (optional) textual reason for the failure to connect to the server.
*
* @return the reason why the user could not connect to the server
* @deprecated Use {@link #getReasonComponent()} instead
*/
@Deprecated
Optional<Component> getReason();
/**
* Returns an (optional) textual reason for the failure to connect to the server.
*
* @return the reason why the user could not connect to the server
*/
Optional<net.kyori.adventure.text.Component> getReasonComponent();
/**
* Returns the server we actually tried to connect to.
*

View File

@@ -8,14 +8,11 @@ import com.velocitypowered.api.proxy.player.PlayerSettings;
import com.velocitypowered.api.proxy.player.TabList;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import com.velocitypowered.api.util.GameProfile;
import com.velocitypowered.api.util.MessagePosition;
import com.velocitypowered.api.util.ModInfo;
import com.velocitypowered.api.util.title.Title;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import net.kyori.adventure.identity.Identified;
import net.kyori.adventure.identity.Identity;
import net.kyori.adventure.text.Component;
/**
@@ -74,31 +71,6 @@ public interface Player extends CommandSource, Identified, InboundConnection,
*/
boolean isOnlineMode();
/**
* Sends a chat message to the player's client.
*
* @param component the chat message to send
* @deprecated Use {@link #sendMessage(Identified, Component)}
* or {@link #sendMessage(Identity, Component)} instead
*/
@Deprecated
@Override
default void sendMessage(net.kyori.text.Component component) {
sendMessage(component, MessagePosition.CHAT);
}
/**
* Sends a chat message to the player's client in the specified position.
*
* @param component the chat message to send
* @param position the position for the message
* @deprecated Use @deprecated Use {@link #sendMessage(Identified, Component)} or
* {@link #sendMessage(Identity, Component)} for chat messages, or
* {@link #sendActionBar(net.kyori.adventure.text.Component)} for action bar messages
*/
@Deprecated
void sendMessage(net.kyori.text.Component component, MessagePosition position);
/**
* Creates a new connection request so that the player can connect to another server.
*
@@ -128,24 +100,6 @@ public interface Player extends CommandSource, Identified, InboundConnection,
*/
GameProfile getGameProfile();
/**
* Sets the tab list header and footer for the player.
*
* @param header the header component
* @param footer the footer component
* @deprecated Use {@link TabList#setHeaderAndFooter(Component, Component)}.
*/
@Deprecated
void setHeaderAndFooter(net.kyori.text.Component header, net.kyori.text.Component footer);
/**
* Clears the tab list header and footer for the player.
*
* @deprecated Use {@link TabList#clearHeaderAndFooter()}.
*/
@Deprecated
void clearHeaderAndFooter();
/**
* Returns the player's tab list.
*
@@ -158,27 +112,8 @@ public interface Player extends CommandSource, Identified, InboundConnection,
* other {@link Player} methods will become undefined.
*
* @param reason component with the reason
* @deprecated Use {@link #disconnect(Component)} instead
*/
@Deprecated
void disconnect(net.kyori.text.Component reason);
/**
* Disconnects the player with the specified reason. Once this method is called, further calls to
* other {@link Player} methods will become undefined.
*
* @param reason component with the reason
*/
void disconnect(net.kyori.adventure.text.Component reason);
/**
* Sends the specified title to the client.
*
* @param title the title to send
* @deprecated Use {@link #showTitle(net.kyori.adventure.title.Title)} and {@link #resetTitle()}
*/
@Deprecated
void sendTitle(Title title);
void disconnect(Component reason);
/**
* Sends chat input onto the players current server as if they typed it into the client chat box.

View File

@@ -10,18 +10,11 @@ import com.velocitypowered.api.proxy.server.RegisteredServer;
import com.velocitypowered.api.proxy.server.ServerInfo;
import com.velocitypowered.api.scheduler.Scheduler;
import com.velocitypowered.api.util.ProxyVersion;
import com.velocitypowered.api.util.bossbar.BossBar;
import com.velocitypowered.api.util.bossbar.BossBarColor;
import com.velocitypowered.api.util.bossbar.BossBarOverlay;
import java.net.InetSocketAddress;
import java.util.Collection;
import java.util.Optional;
import java.util.UUID;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.identity.Identified;
import net.kyori.adventure.identity.Identity;
import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.NonNull;
/**
* Provides an interface to a Minecraft server proxy.
@@ -57,16 +50,6 @@ public interface ProxyServer extends Audience {
*/
Optional<Player> getPlayer(UUID uuid);
/**
* Broadcasts a message to all players currently online.
*
* @param component the message to send
* @deprecated Use {@link #sendMessage(Identified, Component)}
* or {@link #sendMessage(Identity, Component)} instead
*/
@Deprecated
void broadcast(net.kyori.text.Component component);
/**
* Retrieves all players currently connected to this proxy. This call may or may not be a snapshot
* of all players online.
@@ -195,19 +178,4 @@ public interface ProxyServer extends Audience {
* @return the proxy version
*/
ProxyVersion getVersion();
/**
* Creates a new {@link BossBar}.
*
* @param title boss bar title
* @param color boss bar color
* @param overlay boss bar overlay
* @param progress boss bar progress
* @return a completely new and fresh boss bar
* @deprecated Use {@link net.kyori.adventure.bossbar.BossBar} instead
*/
@Deprecated
@NonNull
BossBar createBossBar(net.kyori.text.Component title, @NonNull BossBarColor color,
@NonNull BossBarOverlay overlay, float progress);
}

View File

@@ -39,15 +39,6 @@ public interface ProxyConfig {
*/
boolean shouldQueryShowPlugins();
/**
* Get the MOTD component shown in the tab list.
*
* @return the motd component
* @deprecated Use {@link #getMotd()} instead
*/
@Deprecated
net.kyori.text.Component getMotdComponent();
/**
* Get the MOTD component shown in the tab list.
*

View File

@@ -13,16 +13,6 @@ import org.checkerframework.checker.nullness.qual.Nullable;
*/
public interface TabList {
/**
* Sets the tab list header and footer for the player.
*
* @param header the header component
* @param footer the footer component
* @deprecated Use {@link #setHeaderAndFooter(Component, Component)} instead
*/
@Deprecated
void setHeaderAndFooter(net.kyori.text.Component header, net.kyori.text.Component footer);
/**
* Sets the tab list header and footer for the player.
*

View File

@@ -3,7 +3,6 @@ package com.velocitypowered.api.proxy.player;
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;
/**
@@ -28,37 +27,14 @@ public interface TabListEntry {
GameProfile getProfile();
/**
* Returns {@link Optional} text {@link net.kyori.text.Component}, which if present is the text
* Returns {@link Optional} text {@link Component}, which if present is the text
* displayed for {@code this} entry in the {@link TabList}, otherwise
* {@link GameProfile#getName()} is shown.
*
* @return {@link Optional} text {@link net.kyori.text.Component} of name displayed in the tab
* list
* @deprecated Use {@link #getDisplayNameComponent()} instead
*/
@Deprecated
Optional<net.kyori.text.Component> getDisplayName();
/**
* Returns {@link Optional} text {@link net.kyori.text.Component}, which if present is the text
* displayed for {@code this} entry in the {@link TabList}, otherwise
* {@link GameProfile#getName()} is shown.
*
* @return {@link Optional} text {@link net.kyori.text.Component} of name displayed in the tab
* @return {@link Optional} text {@link Component} of name displayed in the tab
* list
*/
Optional<Component> getDisplayNameComponent();
/**
* Sets the text {@link net.kyori.text.Component} to be displayed for {@code this}
* {@link TabListEntry}. If {@code null}, {@link GameProfile#getName()} will be shown.
*
* @param displayName to show in the {@link TabList} for {@code this} entry
* @return {@code this}, for chaining
* @deprecated Use {@link #setDisplayName(Component)} instead
*/
@Deprecated
TabListEntry setDisplayName(net.kyori.text.Component displayName);
Optional<Component> getDisplayName();
/**
* Sets the text {@link Component} to be displayed for {@code this} {@link TabListEntry}. If
@@ -175,19 +151,6 @@ public interface TabListEntry {
* @param displayName to set
* @return {@code this}, for chaining
* @see TabListEntry#getDisplayName()
* @deprecated Use {@link #displayName(Component)} instead
*/
@Deprecated
public Builder displayName(net.kyori.text.Component displayName) {
return displayName(LegacyText3ComponentSerializer.get().deserialize(displayName));
}
/**
* Sets the displayed name of the {@link TabListEntry}.
*
* @param displayName to set
* @return {@code this}, for chaining
* @see TabListEntry#getDisplayNameComponent() ()
*/
public Builder displayName(@Nullable Component displayName) {
this.displayName = displayName;

View File

@@ -12,7 +12,7 @@ import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
import net.kyori.adventure.text.serializer.legacytext3.LegacyText3ComponentSerializer;
import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -22,19 +22,12 @@ public final class ServerPing {
private final Version version;
private final @Nullable Players players;
private final net.kyori.adventure.text.Component description;
private final Component description;
private final @Nullable Favicon favicon;
private final @Nullable ModInfo modinfo;
@Deprecated
public ServerPing(Version version, @Nullable Players players,
net.kyori.text.Component description, @Nullable Favicon favicon) {
this(version, players, LegacyText3ComponentSerializer.get().deserialize(description), favicon,
ModInfo.DEFAULT);
}
public ServerPing(Version version, @Nullable Players players,
net.kyori.adventure.text.Component description, @Nullable Favicon favicon) {
Component description, @Nullable Favicon favicon) {
this(version, players, description, favicon, ModInfo.DEFAULT);
}
@@ -47,25 +40,8 @@ public final class ServerPing {
* @param favicon the server's favicon
* @param modinfo the mods this server runs
*/
@Deprecated
public ServerPing(Version version, @Nullable Players players,
net.kyori.text.Component description, @Nullable Favicon favicon,
@Nullable ModInfo modinfo) {
this(version, players, LegacyText3ComponentSerializer.get().deserialize(description), favicon,
modinfo);
}
/**
* Constructs a ServerPing instance.
*
* @param version the version of the server
* @param players the players on the server
* @param description the MOTD for the server
* @param favicon the server's favicon
* @param modinfo the mods this server runs
*/
public ServerPing(Version version, @Nullable Players players,
net.kyori.adventure.text.Component description, @Nullable Favicon favicon,
Component description, @Nullable Favicon favicon,
@Nullable ModInfo modinfo) {
this.version = Preconditions.checkNotNull(version, "version");
this.players = players;
@@ -82,12 +58,7 @@ public final class ServerPing {
return Optional.ofNullable(players);
}
@Deprecated
public net.kyori.text.Component getDescription() {
return LegacyText3ComponentSerializer.get().serialize(description);
}
public net.kyori.adventure.text.Component getDescriptionComponent() {
public Component getDescription() {
return description;
}
@@ -173,7 +144,7 @@ public final class ServerPing {
private final List<SamplePlayer> samplePlayers = new ArrayList<>();
private String modType = "FML";
private final List<ModInfo.Mod> mods = new ArrayList<>();
private net.kyori.adventure.text.Component description;
private Component description;
private @Nullable Favicon favicon;
private boolean nullOutPlayers;
private boolean nullOutModinfo;
@@ -245,13 +216,7 @@ public final class ServerPing {
return this;
}
@Deprecated
public Builder description(net.kyori.text.Component description) {
this.description(LegacyText3ComponentSerializer.get().deserialize(description));
return this;
}
public Builder description(net.kyori.adventure.text.Component description) {
public Builder description(Component description) {
this.description = Preconditions.checkNotNull(description, "description");
return this;
}
@@ -294,12 +259,7 @@ public final class ServerPing {
return samplePlayers;
}
@Deprecated
public Optional<net.kyori.text.Component> getDescription() {
return Optional.ofNullable(description).map(LegacyText3ComponentSerializer.get()::serialize);
}
public Optional<net.kyori.adventure.text.Component> getDescriptionComponent() {
public Optional<Component> getDescription() {
return Optional.ofNullable(description);
}

View File

@@ -1,21 +0,0 @@
package com.velocitypowered.api.util;
/**
* Represents where a chat message is going to be sent.
*/
public enum MessagePosition {
/**
* The chat message will appear in the client's HUD. These messages can be filtered out by the
* client.
*/
CHAT,
/**
* The chat message will appear in the client's HUD and can't be dismissed.
*/
SYSTEM,
/**
* The chat message will appear above the player's main HUD. This text format doesn't support many
* component features, such as hover events.
*/
ACTION_BAR
}

View File

@@ -1,162 +0,0 @@
package com.velocitypowered.api.util.bossbar;
import com.velocitypowered.api.proxy.Player;
import java.util.Collection;
import net.kyori.text.Component;
/**
* Represents a boss bar, which can be send to a (group of) player(s).
* <b>Boss bars only work on 1.9 and above.</b>
*
* @deprecated Replaced with {@link net.kyori.adventure.bossbar.BossBar}
*/
@Deprecated
public interface BossBar {
/**
* Adds all specified players to this boss bar.
*
* @param players players
* @see #addPlayer(Player)
*/
void addPlayers(Iterable<Player> players);
/**
* Adds player to this boss bar. This adds the player to the {@link #getPlayers()} and makes him
* see the boss bar.
*
* @param player the player you wish to add
*/
void addPlayer(Player player);
/**
* Removes player from this boss bar. This removes the player from {@link #getPlayers()} and makes
* him not see the boss bar.
*
* @param player the player you wish to remove
*/
void removePlayer(Player player);
/**
* Removes all specified players from this boss bar.
*
* @param players players
* @see #removePlayer(Player)
*/
void removePlayers(Iterable<Player> players);
/**
* Removes all players, that see this boss bar.
*
* @see #removePlayer(Player)
*/
void removeAllPlayers();
/**
* Gets the title of this boss bar.
*
* @return title
*/
Component getTitle();
/**
* Sets a new title of the boss bar.
*
* @param title new title
*/
void setTitle(Component title);
/**
* Gets the boss bar's percent.
*
* @return percent
*/
float getPercent();
/**
* Sets a new percent of the boss bar.
*
* @param percent a float between 0 and 1, representing boss bar's percent
* @throws IllegalArgumentException if the new percent is not between 0 and 1
*/
void setPercent(float percent);
/**
* Returns a copy of the {@link Collection} of all {@link Player} added to the boss bar.
* <i>Can be empty.</i>
*
* @return players
*/
Collection<Player> getPlayers();
/**
* Gets the color of the boss bar.
*
* @return boss bar color
*/
BossBarColor getColor();
/**
* Sets a new color of the boss bar.
*
* @param color the color you wish the boss bar be displayed with
*/
void setColor(BossBarColor color);
/**
* Gets the overlay of the boss bar.
*
* @return boss bar overlay
*/
BossBarOverlay getOverlay();
/**
* Sets a new overlay of the boss bar.
*
* @param overlay the overlay you wish the boss bar be displayed with
*/
void setOverlay(BossBarOverlay overlay);
/**
* Returns whenever this boss bar is visible to all added {@link #getPlayers()}. By default, it
* returns <code>true</code>.
*
* @return <code>true</code> if visible, otherwise <code>false</code>
*/
boolean isVisible();
/**
* Sets a new visibility to the boss bar.
*
* @param visible boss bar visibility value
*/
void setVisible(boolean visible);
/**
* Returns a copy of of the {@link Collection} of all {@link BossBarFlag}s added to the boss bar.
*
* @return flags
*/
Collection<BossBarFlag> getFlags();
/**
* Adds new flags to the boss bar.
*
* @param flags the flags you wish to add
*/
void addFlags(BossBarFlag... flags);
/**
* Removes flag from the boss bar.
*
* @param flag the flag you wish to remove
*/
void removeFlag(BossBarFlag flag);
/**
* Removes flags from the boss bar.
*
* @param flags the flags you wish to remove
*/
void removeFlags(BossBarFlag... flags);
}

View File

@@ -1,17 +0,0 @@
package com.velocitypowered.api.util.bossbar;
/**
* Represents a color of a {@link BossBar}.
*
* @deprecated Replaced with {@link net.kyori.adventure.bossbar.BossBar.Color}
*/
@Deprecated
public enum BossBarColor {
PINK,
BLUE,
RED,
GREEN,
YELLOW,
PURPLE,
WHITE
}

View File

@@ -1,13 +0,0 @@
package com.velocitypowered.api.util.bossbar;
/**
* Represents any {@link BossBar}'s flags.
*
* @deprecated Replaced with {@link net.kyori.adventure.bossbar.BossBar.Flag}
*/
@Deprecated
public enum BossBarFlag {
DARKEN_SCREEN,
PLAY_BOSS_MUSIC,
CREATE_WORLD_FOG
}

View File

@@ -1,15 +0,0 @@
package com.velocitypowered.api.util.bossbar;
/**
* Represents a overlay of a {@link BossBar}.
*
* @deprecated Replaced with {@link net.kyori.adventure.bossbar.BossBar.Overlay}
*/
@Deprecated
public enum BossBarOverlay {
PROGRESS,
NOTCHED_6,
NOTCHED_10,
NOTCHED_12,
NOTCHED_20
}

View File

@@ -1,257 +0,0 @@
package com.velocitypowered.api.util.title;
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import java.util.Objects;
import java.util.Optional;
import net.kyori.text.Component;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Represents a "full" title, including all components. This class is immutable.
*
* @deprecated Replaced with {@link net.kyori.adventure.title.Title}
*/
@Deprecated
public final class TextTitle implements Title {
private final @Nullable Component title;
private final @Nullable Component subtitle;
private final int stay;
private final int fadeIn;
private final int fadeOut;
private final boolean resetBeforeSend;
private TextTitle(Builder builder) {
this.title = builder.title;
this.subtitle = builder.subtitle;
this.stay = builder.stay;
this.fadeIn = builder.fadeIn;
this.fadeOut = builder.fadeOut;
this.resetBeforeSend = builder.resetBeforeSend;
}
/**
* Returns the main title this title has, if any.
*
* @return the main title of this title
*/
public Optional<Component> getTitle() {
return Optional.ofNullable(title);
}
/**
* Returns the subtitle this title has, if any.
*
* @return the subtitle
*/
public Optional<Component> getSubtitle() {
return Optional.ofNullable(subtitle);
}
/**
* Returns the number of ticks this title will stay up.
*
* @return how long the title will stay, in ticks
*/
public int getStay() {
return stay;
}
/**
* Returns the number of ticks over which this title will fade in.
*
* @return how long the title will fade in, in ticks
*/
public int getFadeIn() {
return fadeIn;
}
/**
* Returns the number of ticks over which this title will fade out.
*
* @return how long the title will fade out, in ticks
*/
public int getFadeOut() {
return fadeOut;
}
/**
* Returns whether or not a reset packet will be sent before this title is sent. By default,
* unless explicitly disabled, this is enabled by default.
*
* @return whether or not a reset packet will be sent before this title is sent
*/
public boolean isResetBeforeSend() {
return resetBeforeSend;
}
/**
* Determines whether or not this title has times set on it. If none are set, it will update the
* previous title set on the client.
*
* @return whether or not this title has times set on it
*/
public boolean areTimesSet() {
return stay != 0 || fadeIn != 0 || fadeOut != 0;
}
/**
* Creates a new builder from the contents of this title so that it may be changed.
*
* @return a builder instance with the contents of this title
*/
public Builder toBuilder() {
return new Builder(this);
}
@Override
public boolean equals(@Nullable Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
TextTitle textTitle = (TextTitle) o;
return stay == textTitle.stay
&& fadeIn == textTitle.fadeIn
&& fadeOut == textTitle.fadeOut
&& resetBeforeSend == textTitle.resetBeforeSend
&& Objects.equals(title, textTitle.title)
&& Objects.equals(subtitle, textTitle.subtitle);
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("title", title)
.add("subtitle", subtitle)
.add("stay", stay)
.add("fadeIn", fadeIn)
.add("fadeOut", fadeOut)
.add("resetBeforeSend", resetBeforeSend)
.toString();
}
@Override
public int hashCode() {
return Objects.hash(title, subtitle, stay, fadeIn, fadeOut, resetBeforeSend);
}
/**
* Creates a new builder for constructing titles.
*
* @return a builder for constructing titles
*/
public static Builder builder() {
return new Builder();
}
public static class Builder {
private @Nullable Component title;
private @Nullable Component subtitle;
private int stay;
private int fadeIn;
private int fadeOut;
private boolean resetBeforeSend = true;
private Builder() {
}
private Builder(TextTitle copy) {
this.title = copy.title;
this.subtitle = copy.subtitle;
this.stay = copy.stay;
this.fadeIn = copy.fadeIn;
this.fadeOut = copy.fadeOut;
this.resetBeforeSend = copy.resetBeforeSend;
}
public Builder title(Component title) {
this.title = Preconditions.checkNotNull(title, "title");
return this;
}
public Builder clearTitle() {
this.title = null;
return this;
}
public Builder subtitle(Component subtitle) {
this.subtitle = Preconditions.checkNotNull(subtitle, "subtitle");
return this;
}
public Builder clearSubtitle() {
this.subtitle = null;
return this;
}
private int checkTicks(int ticks) {
Preconditions.checkArgument(ticks >= 0, "ticks value %s is negative", ticks);
return ticks;
}
public Builder stay(int ticks) {
this.stay = checkTicks(ticks);
return this;
}
public Builder fadeIn(int ticks) {
this.fadeIn = checkTicks(ticks);
return this;
}
public Builder fadeOut(int ticks) {
this.fadeOut = checkTicks(ticks);
return this;
}
public Builder resetBeforeSend(boolean b) {
this.resetBeforeSend = b;
return this;
}
public Optional<Component> getTitle() {
return Optional.ofNullable(title);
}
public Optional<Component> getSubtitle() {
return Optional.ofNullable(subtitle);
}
public int getStay() {
return stay;
}
public int getFadeIn() {
return fadeIn;
}
public int getFadeOut() {
return fadeOut;
}
public boolean isResetBeforeSend() {
return resetBeforeSend;
}
public TextTitle build() {
return new TextTitle(this);
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("title", title)
.add("subtitle", subtitle)
.add("stay", stay)
.add("fadeIn", fadeIn)
.add("fadeOut", fadeOut)
.add("resetBeforeSend", resetBeforeSend)
.toString();
}
}
}

View File

@@ -1,11 +0,0 @@
package com.velocitypowered.api.util.title;
/**
* Represents a title that can be sent to a Minecraft client.
*
* @deprecated Replaced with {@link net.kyori.adventure.title.Title}
*/
@Deprecated
public interface Title {
}

View File

@@ -1,57 +0,0 @@
package com.velocitypowered.api.util.title;
/**
* Provides special-purpose titles.
*
* @deprecated Replaced with {@link net.kyori.adventure.title.Title}
*/
@Deprecated
public final class Titles {
private Titles() {
throw new AssertionError();
}
private static final Title RESET = new Title() {
@Override
public String toString() {
return "reset title";
}
};
private static final Title HIDE = new Title() {
@Override
public String toString() {
return "hide title";
}
};
/**
* Returns a title that, when sent to the client, will cause all title data to be reset and any
* existing title to be hidden.
*
* @return the reset title
*/
public static Title reset() {
return RESET;
}
/**
* Returns a title that, when sent to the client, will cause any existing title to be hidden. The
* title may be restored by a {@link TextTitle} with no title or subtitle (only a time).
*
* @return the hide title
*/
public static Title hide() {
return HIDE;
}
/**
* Returns a builder for {@link TextTitle}s.
*
* @return a builder for text titles
*/
public static TextTitle.Builder text() {
return TextTitle.builder();
}
}

View File

@@ -1,6 +0,0 @@
/**
* Provides data structures for creating and manipulating titles.
*
* @deprecated Replaced with {@link net.kyori.adventure.title.Title}
*/
package com.velocitypowered.api.util.title;

View File

@@ -7,7 +7,7 @@ import com.velocitypowered.api.proxy.server.ServerPing.Players;
import com.velocitypowered.api.proxy.server.ServerPing.SamplePlayer;
import com.velocitypowered.api.proxy.server.ServerPing.Version;
import java.util.UUID;
import net.kyori.text.TextComponent;
import net.kyori.adventure.text.Component;
import org.junit.jupiter.api.Test;
class ServerPingTest {
@@ -16,7 +16,7 @@ class ServerPingTest {
void asBuilderConsistency() {
ServerPing ping = new ServerPing(new Version(404, "1.13.2"),
new Players(1, 1, ImmutableList.of(new SamplePlayer("tuxed", UUID.randomUUID()))),
TextComponent.of("test"), null);
Component.text("test"), null);
assertEquals(ping, ping.asBuilder().build());
}
}