Remove text 3.x API and associated deprecated APIs

This commit is contained in:
Andrew Steinborn
2021-05-23 14:13:51 -04:00
parent 569bb4a16b
commit 977300cc66
35 changed files with 9 additions and 1474 deletions

View File

@@ -9,31 +9,10 @@ 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

@@ -10,7 +10,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;
@@ -100,11 +99,6 @@ 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() {
return Optional.ofNullable(reason);
}
@@ -128,12 +122,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

@@ -11,7 +11,6 @@ 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 org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -91,11 +90,6 @@ 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() {
return Optional.ofNullable(reason);
}
@@ -152,20 +146,6 @@ public final class PreLoginEvent implements ResultedEvent<PreLoginEvent.PreLogin
return FORCE_OFFLINEMODE;
}
/**
* 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.
*

View File

@@ -12,8 +12,6 @@ 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 org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -32,35 +30,6 @@ public final class KickedFromServerEvent implements
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
@@ -97,16 +66,6 @@ public final class KickedFromServerEvent implements
return server;
}
/**
* 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() {
return Optional.ofNullable(originalReason);
}
@@ -155,27 +114,10 @@ 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;
}
/**
* Creates a new {@link DisconnectPlayer} with the specified reason.
*
* @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.
*
@@ -211,30 +153,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}.
*
@@ -269,27 +191,10 @@ 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;
}
/**
* Notifies the player with the specified message but does nothing else.
*
* @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.
*

View File

@@ -10,7 +10,6 @@ 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;
/**
* Provides a fluent interface to send a connection request to another server on the proxy. A
@@ -70,15 +69,6 @@ public interface ConnectionRequestBuilder {
*/
Status getStatus();
/**
* 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.
*

View File

@@ -16,14 +16,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;
/**
@@ -82,31 +79,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.
*
@@ -136,16 +108,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.
*
@@ -175,16 +137,6 @@ public interface Player extends CommandSource, Identified, InboundConnection,
*/
TabList getTabList();
/**
* 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
* @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.
@@ -193,15 +145,6 @@ public interface Player extends CommandSource, Identified, InboundConnection,
*/
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);
/**
* Sends chat input onto the players current server as if they typed it into the client chat box.
*

View File

@@ -17,17 +17,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;
/**
@@ -64,16 +58,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.
@@ -202,19 +186,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

@@ -46,15 +46,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

@@ -11,7 +11,7 @@ import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import java.util.Objects;
import java.util.regex.Pattern;
import net.kyori.minecraft.Key;
import net.kyori.adventure.key.Key;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
@@ -96,7 +96,7 @@ public final class MinecraftChannelIdentifier implements ChannelIdentifier {
}
public Key asKey() {
return Key.of(namespace, name);
return Key.key(namespace, name);
}
@Override

View File

@@ -20,16 +20,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

@@ -10,7 +10,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;
/**
@@ -35,38 +34,15 @@ public interface TabListEntry {
GameProfile getProfile();
/**
* 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
* Returns {@link Optional} text {@link net.kyori.adventure.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
* 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
* list
* @return {@link Optional} text {@link net.kyori.adventure.text.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);
/**
* Sets the text {@link Component} to be displayed for {@code this} {@link TabListEntry}. If
* {@code null}, {@link GameProfile#getName()} will be shown.
@@ -176,19 +152,6 @@ public interface TabListEntry {
return this;
}
/**
* Sets the displayed name of the {@link 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}.
*

View File

@@ -19,7 +19,6 @@ 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;
/**
@@ -33,35 +32,11 @@ public final class ServerPing {
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) {
this(version, players, description, favicon, ModInfo.DEFAULT);
}
/**
* 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
*/
@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.
*
@@ -89,11 +64,6 @@ 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() {
return description;
}
@@ -253,12 +223,6 @@ 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) {
this.description = Preconditions.checkNotNull(description, "description");
return this;
@@ -307,11 +271,6 @@ 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() {
return Optional.ofNullable(description);
}

View File

@@ -1,169 +0,0 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
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,24 +0,0 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
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,20 +0,0 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
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,22 +0,0 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
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,264 +0,0 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
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,18 +0,0 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
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,64 +0,0 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
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,13 +0,0 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
/**
* 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

@@ -14,7 +14,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 {
@@ -23,7 +23,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());
}
}