13
0
geforkt von Mirrors/Velocity

Remove text 3.x API and associated deprecated APIs

Dieser Commit ist enthalten in:
Andrew Steinborn 2021-05-23 14:13:51 -04:00
Ursprung 569bb4a16b
Commit 977300cc66
35 geänderte Dateien mit 9 neuen und 1474 gelöschten Zeilen

Datei anzeigen

@ -28,13 +28,7 @@ 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
// DEPRECATED: Will be removed in Velocity Polymer
api 'com.moandjiezana.toml:toml4j:0.7.2'
api(platform("net.kyori:adventure-bom:${adventureVersion}"))
@ -42,9 +36,6 @@ dependencies {
api("net.kyori:adventure-text-serializer-gson")
api("net.kyori:adventure-text-serializer-legacy")
api("net.kyori:adventure-text-serializer-plain")
api("net.kyori:adventure-text-serializer-legacy-text3:${adventurePlatformVersion}") {
transitive = false
}
api "org.slf4j:slf4j-api:${slf4jVersion}"
api 'com.google.inject:guice:4.2.3'

Datei anzeigen

@ -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));
}
}

Datei anzeigen

@ -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));
}
}
}

Datei anzeigen

@ -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.
*

Datei anzeigen

@ -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.
*

Datei anzeigen

@ -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.
*

Datei anzeigen

@ -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.
*

Datei anzeigen

@ -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);
}

Datei anzeigen

@ -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.
*

Datei anzeigen

@ -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

Datei anzeigen

@ -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.
*

Datei anzeigen

@ -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}.
*

Datei anzeigen

@ -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);
}

Datei anzeigen

@ -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);
}

Datei anzeigen

@ -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
}

Datei anzeigen

@ -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
}

Datei anzeigen

@ -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
}

Datei anzeigen

@ -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();
}
}
}

Datei anzeigen

@ -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 {
}

Datei anzeigen

@ -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();
}
}

Datei anzeigen

@ -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;

Datei anzeigen

@ -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());
}
}

Datei anzeigen

@ -35,9 +35,6 @@ import com.velocitypowered.api.proxy.server.ServerInfo;
import com.velocitypowered.api.util.Favicon;
import com.velocitypowered.api.util.GameProfile;
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 com.velocitypowered.proxy.command.VelocityCommandManager;
import com.velocitypowered.proxy.command.builtin.GlistCommand;
import com.velocitypowered.proxy.command.builtin.ServerCommand;
@ -50,7 +47,6 @@ import com.velocitypowered.proxy.network.ConnectionManager;
import com.velocitypowered.proxy.plugin.VelocityEventManager;
import com.velocitypowered.proxy.plugin.VelocityPluginManager;
import com.velocitypowered.proxy.protocol.ProtocolUtils;
import com.velocitypowered.proxy.protocol.packet.Chat;
import com.velocitypowered.proxy.protocol.util.FaviconSerializer;
import com.velocitypowered.proxy.protocol.util.GameProfileSerializer;
import com.velocitypowered.proxy.scheduler.VelocityScheduler;
@ -59,7 +55,6 @@ import com.velocitypowered.proxy.util.AddressUtil;
import com.velocitypowered.proxy.util.EncryptionUtils;
import com.velocitypowered.proxy.util.VelocityChannelRegistrar;
import com.velocitypowered.proxy.util.bossbar.AdventureBossBarManager;
import com.velocitypowered.proxy.util.bossbar.VelocityBossBar;
import com.velocitypowered.proxy.util.ratelimit.Ratelimiter;
import com.velocitypowered.proxy.util.ratelimit.Ratelimiters;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
@ -181,15 +176,6 @@ public class VelocityServer implements ProxyServer, ForwardingAudience {
return new ProxyVersion(implName, implVendor, implVersion);
}
@Override
public @NonNull BossBar createBossBar(
net.kyori.text.@NonNull Component title,
@NonNull BossBarColor color,
@NonNull BossBarOverlay overlay,
float progress) {
return new VelocityBossBar(title, color, overlay, progress);
}
@Override
public VelocityCommandManager getCommandManager() {
return commandManager;
@ -575,15 +561,6 @@ public class VelocityServer implements ProxyServer, ForwardingAudience {
return Optional.ofNullable(connectionsByUuid.get(uuid));
}
@Override
public void broadcast(net.kyori.text.Component component) {
Preconditions.checkNotNull(component, "component");
Chat chat = Chat.createClientbound(component);
for (ConnectedPlayer player : connectionsByUuid.values()) {
player.getConnection().write(chat);
}
}
@Override
public Collection<Player> matchPlayer(String partialName) {
Objects.requireNonNull(partialName);

Datei anzeigen

@ -50,7 +50,6 @@ import java.util.Random;
import net.kyori.adventure.text.Component;
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;
@ -255,16 +254,6 @@ public class VelocityConfiguration implements ProxyConfig {
return query.shouldQueryShowPlugins();
}
/**
* Returns the proxy's MOTD.
*
* @return the MOTD
*/
@Override
public net.kyori.text.Component getMotdComponent() {
return LegacyText3ComponentSerializer.get().serialize(this.getMotd());
}
@Override
public net.kyori.adventure.text.Component getMotd() {
if (motdAsComponent == null) {

Datei anzeigen

@ -44,11 +44,7 @@ import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
import com.velocitypowered.api.proxy.player.PlayerSettings;
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.TextTitle;
import com.velocitypowered.api.util.title.Title;
import com.velocitypowered.api.util.title.Titles;
import com.velocitypowered.proxy.VelocityServer;
import com.velocitypowered.proxy.config.VelocityConfiguration;
import com.velocitypowered.proxy.connection.MinecraftConnection;
@ -252,40 +248,6 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
return connection.getProtocolVersion();
}
@Override
public void sendMessage(net.kyori.text.Component component, MessagePosition position) {
Preconditions.checkNotNull(component, "component");
Preconditions.checkNotNull(position, "position");
byte pos = (byte) position.ordinal();
String json;
if (position == MessagePosition.ACTION_BAR) {
if (getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_11) >= 0) {
// We can use the title packet instead.
TitlePacket pkt = new TitlePacket();
pkt.setAction(TitlePacket.SET_ACTION_BAR);
pkt.setComponent(net.kyori.text.serializer.gson.GsonComponentSerializer.INSTANCE
.serialize(component));
connection.write(pkt);
return;
} else {
// Due to issues with action bar packets, we'll need to convert the text message into a
// legacy message and then inject the legacy text into a component... yuck!
JsonObject object = new JsonObject();
object.addProperty("text", net.kyori.text.serializer.legacy
.LegacyComponentSerializer.legacy().serialize(component));
json = object.toString();
}
} else {
json = net.kyori.text.serializer.gson.GsonComponentSerializer.INSTANCE.serialize(component);
}
Chat chat = new Chat();
chat.setType(pos);
chat.setMessage(json);
connection.write(chat);
}
@Override
public void sendMessage(@NonNull Identity identity, @NonNull Component message) {
connection.write(Chat.createClientbound(identity, message, this.getProtocolVersion()));
@ -425,12 +387,6 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
this.profile = profile.withProperties(Preconditions.checkNotNull(properties));
}
@Deprecated
@Override
public void setHeaderAndFooter(net.kyori.text.Component header, net.kyori.text.Component footer) {
tabList.setHeaderAndFooter(header, footer);
}
@Override
public void clearHeaderAndFooter() {
tabList.clearHeaderAndFooter();
@ -450,26 +406,6 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
}
}
@Override
public void disconnect(net.kyori.text.Component reason) {
if (connection.eventLoop().inEventLoop()) {
disconnect0(reason, false);
} else {
connection.eventLoop().execute(() -> disconnect0(reason, false));
}
}
/**
* Disconnects the player from the proxy.
* @param reason the reason for disconnecting the player
* @param duringLogin whether the disconnect happened during login
*/
public void disconnect0(net.kyori.text.Component reason, boolean duringLogin) {
logger.info("{} has disconnected: {}", this,
net.kyori.text.serializer.legacy.LegacyComponentSerializer.legacy().serialize(reason));
connection.closeWith(Disconnect.create(reason));
}
/**
* Disconnects the player from the proxy.
* @param reason the reason for disconnecting the player
@ -481,54 +417,6 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
connection.closeWith(Disconnect.create(reason, this.getProtocolVersion()));
}
@Override
public void sendTitle(Title title) {
Preconditions.checkNotNull(title, "title");
ProtocolVersion protocolVersion = connection.getProtocolVersion();
if (title.equals(Titles.reset())) {
connection.write(TitlePacket.resetForProtocolVersion(protocolVersion));
} else if (title.equals(Titles.hide())) {
connection.write(TitlePacket.hideForProtocolVersion(protocolVersion));
} else if (title instanceof TextTitle) {
TextTitle tt = (TextTitle) title;
if (tt.isResetBeforeSend()) {
connection.delayedWrite(TitlePacket.resetForProtocolVersion(protocolVersion));
}
Optional<net.kyori.text.Component> titleText = tt.getTitle();
if (titleText.isPresent()) {
TitlePacket titlePkt = new TitlePacket();
titlePkt.setAction(TitlePacket.SET_TITLE);
titlePkt.setComponent(net.kyori.text.serializer.gson.GsonComponentSerializer.INSTANCE
.serialize(titleText.get()));
connection.delayedWrite(titlePkt);
}
Optional<net.kyori.text.Component> subtitleText = tt.getSubtitle();
if (subtitleText.isPresent()) {
TitlePacket titlePkt = new TitlePacket();
titlePkt.setAction(TitlePacket.SET_SUBTITLE);
titlePkt.setComponent(net.kyori.text.serializer.gson.GsonComponentSerializer.INSTANCE
.serialize(subtitleText.get()));
connection.delayedWrite(titlePkt);
}
if (tt.areTimesSet()) {
TitlePacket timesPkt = TitlePacket.timesForProtocolVersion(protocolVersion);
timesPkt.setFadeIn(tt.getFadeIn());
timesPkt.setStay(tt.getStay());
timesPkt.setFadeOut(tt.getFadeOut());
connection.delayedWrite(timesPkt);
}
connection.flush();
} else {
throw new IllegalArgumentException("Unknown title class " + title.getClass().getName());
}
}
public @Nullable VelocityServerConnection getConnectedServer() {
return connectedServer;
}

Datei anzeigen

@ -25,7 +25,6 @@ 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 {
@ -89,11 +88,6 @@ public class ConnectionRequestResults {
return status;
}
@Override
public Optional<net.kyori.text.Component> getReason() {
return Optional.ofNullable(component).map(LegacyText3ComponentSerializer.get()::serialize);
}
@Override
public Optional<Component> getReasonComponent() {
return Optional.ofNullable(component);

Datei anzeigen

@ -28,8 +28,6 @@ import java.util.List;
import net.kyori.adventure.identity.Identity;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.text.TextComponent;
import net.kyori.text.format.TextColor;
import net.minecrell.terminalconsole.SimpleTerminalConsole;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
@ -51,12 +49,6 @@ public final class VelocityConsole extends SimpleTerminalConsole implements Cons
this.server = server;
}
@Override
public void sendMessage(net.kyori.text.Component component) {
logger.info(net.kyori.text.serializer.legacy.LegacyComponentSerializer.legacy()
.serialize(component));
}
@Override
public void sendMessage(@NonNull Identity identity, @NonNull Component message) {
logger.info(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection()

Datei anzeigen

@ -116,18 +116,6 @@ public class Chat implements MinecraftPacket {
return handler.handle(this);
}
@Deprecated
public static Chat createClientbound(net.kyori.text.Component component) {
return createClientbound(component, CHAT_TYPE, EMPTY_SENDER);
}
@Deprecated
public static Chat createClientbound(net.kyori.text.Component component, byte type, UUID sender) {
Preconditions.checkNotNull(component, "component");
return new Chat(net.kyori.text.serializer.gson.GsonComponentSerializer.INSTANCE
.serialize(component), type, sender);
}
public static Chat createClientbound(Identity identity,
net.kyori.adventure.text.Component component, ProtocolVersion version) {
return createClientbound(component, CHAT_TYPE, identity.uuid(), version);

Datei anzeigen

@ -23,8 +23,6 @@ import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
import com.velocitypowered.proxy.protocol.MinecraftPacket;
import com.velocitypowered.proxy.protocol.ProtocolUtils;
import io.netty.buffer.ByteBuf;
import net.kyori.text.Component;
import net.kyori.text.serializer.gson.GsonComponentSerializer;
import org.checkerframework.checker.nullness.qual.Nullable;
public class Disconnect implements MinecraftPacket {
@ -74,12 +72,6 @@ public class Disconnect implements MinecraftPacket {
return handler.handle(this);
}
@Deprecated
public static Disconnect create(Component component) {
Preconditions.checkNotNull(component, "component");
return new Disconnect(GsonComponentSerializer.INSTANCE.serialize(component));
}
public static Disconnect create(net.kyori.adventure.text.Component component,
ProtocolVersion version) {
Preconditions.checkNotNull(component, "component");

Datei anzeigen

@ -34,7 +34,6 @@ import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.legacytext3.LegacyText3ComponentSerializer;
import org.checkerframework.checker.nullness.qual.Nullable;
public class VelocityTabList implements TabList {
@ -48,18 +47,6 @@ public class VelocityTabList implements TabList {
this.connection = player.getConnection();
}
@Deprecated
@Override
public void setHeaderAndFooter(net.kyori.text.Component header,
net.kyori.text.Component footer) {
Preconditions.checkNotNull(header, "header");
Preconditions.checkNotNull(footer, "footer");
this.player.sendPlayerListHeaderAndFooter(
LegacyText3ComponentSerializer.get().deserialize(header),
LegacyText3ComponentSerializer.get().deserialize(footer)
);
}
@Deprecated
@Override
public void setHeaderAndFooter(Component header, Component footer) {

Datei anzeigen

@ -22,8 +22,6 @@ import com.velocitypowered.api.proxy.player.TabListEntry;
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;
public class VelocityTabListEntry implements TabListEntry {
@ -53,24 +51,11 @@ public class VelocityTabListEntry implements TabListEntry {
return profile;
}
@Override
public Optional<Component> getDisplayName() {
return Optional.ofNullable(displayName).map(LegacyText3ComponentSerializer.get()::serialize);
}
@Override
public Optional<net.kyori.adventure.text.Component> getDisplayNameComponent() {
return Optional.ofNullable(displayName);
}
@Override
public TabListEntry setDisplayName(@Nullable Component displayName) {
if (displayName == null) {
return this.setDisplayName((net.kyori.adventure.text.Component) null);
}
return this.setDisplayName(LegacyText3ComponentSerializer.get().deserialize(displayName));
}
@Override
public TabListEntry setDisplayName(net.kyori.adventure.text.@Nullable Component displayName) {
this.displayName = displayName;

Datei anzeigen

@ -29,12 +29,6 @@ public class VelocityTabListEntryLegacy extends VelocityTabListEntry {
super(tabList, profile, displayName, latency, gameMode);
}
@Override
public TabListEntry setDisplayName(net.kyori.text.@Nullable Component displayName) {
getTabList().removeEntry(getProfile().getId()); // We have to remove first if updating
return super.setDisplayName(displayName);
}
@Override
public TabListEntry setDisplayName(@Nullable Component displayName) {
getTabList().removeEntry(getProfile().getId()); // We have to remove first if updating

Datei anzeigen

@ -39,11 +39,6 @@ public class VelocityTabListLegacy extends VelocityTabList {
super(player);
}
@Deprecated
@Override
public void setHeaderAndFooter(net.kyori.text.Component header, net.kyori.text.Component footer) {
}
@Deprecated
@Override
public void setHeaderAndFooter(Component header, Component footer) {

Datei anzeigen

@ -1,293 +0,0 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.velocitypowered.proxy.util.bossbar;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.ImmutableList;
import com.velocitypowered.api.network.ProtocolVersion;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.util.bossbar.BossBarColor;
import com.velocitypowered.api.util.bossbar.BossBarFlag;
import com.velocitypowered.api.util.bossbar.BossBarOverlay;
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
import com.velocitypowered.proxy.protocol.MinecraftPacket;
import com.velocitypowered.proxy.protocol.packet.BossBar;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import net.kyori.text.Component;
import net.kyori.text.serializer.gson.GsonComponentSerializer;
public class VelocityBossBar implements com.velocitypowered.api.util.bossbar.BossBar {
private final List<Player> players;
private final Set<BossBarFlag> flags;
private final UUID uuid;
private boolean visible;
private Component title;
private float percent;
private BossBarColor color;
private BossBarOverlay overlay;
/**
* Creates a new boss bar.
* @param title the title for the bar
* @param color the color of the bar
* @param overlay the overlay to use
* @param percent the percent of the bar
*/
public VelocityBossBar(
Component title, BossBarColor color, BossBarOverlay overlay, float percent) {
this.title = checkNotNull(title, "title");
this.color = checkNotNull(color, "color");
this.overlay = checkNotNull(overlay, "overlay");
this.percent = percent;
checkPercent(percent);
this.uuid = UUID.randomUUID();
visible = true;
players = new ArrayList<>();
flags = EnumSet.noneOf(BossBarFlag.class);
}
@Override
public void addPlayers(Iterable<Player> players) {
checkNotNull(players, "players");
for (Player player : players) {
addPlayer(player);
}
}
@Override
public void addPlayer(Player player) {
checkNotNull(player, "player");
if (!players.contains(player)) {
players.add(player);
}
if (player.isActive() && visible) {
sendPacket(player, addPacket());
}
}
@Override
public void removePlayer(Player player) {
checkNotNull(player, "player");
players.remove(player);
if (player.isActive()) {
sendPacket(player, removePacket());
}
}
@Override
public void removePlayers(Iterable<Player> players) {
checkNotNull(players, "players");
for (Player player : players) {
removePlayer(player);
}
}
@Override
public void removeAllPlayers() {
removePlayers(ImmutableList.copyOf(players));
}
@Override
public Component getTitle() {
return title;
}
@Override
public void setTitle(Component title) {
this.title = checkNotNull(title, "title");
if (visible) {
BossBar bar = new BossBar();
bar.setUuid(uuid);
bar.setAction(BossBar.UPDATE_NAME);
bar.setName(GsonComponentSerializer.INSTANCE.serialize(title));
sendToAffected(bar);
}
}
@Override
public float getPercent() {
return percent;
}
@Override
public void setPercent(float percent) {
checkPercent(percent);
this.percent = percent;
if (visible) {
BossBar bar = new BossBar();
bar.setUuid(uuid);
bar.setAction(BossBar.UPDATE_PERCENT);
bar.setPercent(percent);
sendToAffected(bar);
}
}
private void checkPercent(final float percent) {
if (percent < 0f || percent > 1f) {
throw new IllegalArgumentException("Percent must be between 0 and 1");
}
}
@Override
public Collection<Player> getPlayers() {
return ImmutableList.copyOf(players);
}
@Override
public BossBarColor getColor() {
return color;
}
@Override
public void setColor(BossBarColor color) {
this.color = checkNotNull(color, "color");
if (visible) {
sendDivisions(color, overlay);
}
}
@Override
public BossBarOverlay getOverlay() {
return overlay;
}
@Override
public void setOverlay(BossBarOverlay overlay) {
this.overlay = checkNotNull(overlay, "overlay");
if (visible) {
sendDivisions(color, overlay);
}
}
private void sendDivisions(BossBarColor color, BossBarOverlay overlay) {
BossBar bar = new BossBar();
bar.setUuid(uuid);
bar.setAction(BossBar.UPDATE_STYLE);
bar.setColor(color.ordinal());
bar.setOverlay(overlay.ordinal());
sendToAffected(bar);
}
@Override
public boolean isVisible() {
return visible;
}
@Override
public void setVisible(boolean visible) {
boolean previous = this.visible;
if (previous && !visible) {
// The bar is being hidden
sendToAffected(removePacket());
} else if (!previous && visible) {
// The bar is being shown
sendToAffected(addPacket());
}
this.visible = visible;
}
@Override
public Collection<BossBarFlag> getFlags() {
return ImmutableList.copyOf(flags);
}
@Override
public void addFlags(BossBarFlag... flags) {
if (this.flags.addAll(Arrays.asList(flags)) && visible) {
sendToAffected(updateFlags());
}
}
@Override
public void removeFlag(BossBarFlag flag) {
checkNotNull(flag, "flag");
if (this.flags.remove(flag) && visible) {
sendToAffected(updateFlags());
}
}
@Override
public void removeFlags(BossBarFlag... flags) {
if (this.flags.removeAll(Arrays.asList(flags)) && visible) {
sendToAffected(updateFlags());
}
}
private short serializeFlags() {
short flagMask = 0x0;
if (flags.contains(BossBarFlag.DARKEN_SCREEN)) {
flagMask |= 0x1;
}
if (flags.contains(BossBarFlag.PLAY_BOSS_MUSIC)) {
flagMask |= 0x2;
}
if (flags.contains(BossBarFlag.CREATE_WORLD_FOG)) {
flagMask |= 0x4;
}
return flagMask;
}
private BossBar addPacket() {
BossBar bossBar = new BossBar();
bossBar.setUuid(uuid);
bossBar.setAction(BossBar.ADD);
bossBar.setName(GsonComponentSerializer.INSTANCE.serialize(title));
bossBar.setColor(color.ordinal());
bossBar.setOverlay(overlay.ordinal());
bossBar.setPercent(percent);
bossBar.setFlags(serializeFlags());
return bossBar;
}
private BossBar removePacket() {
BossBar bossBar = new BossBar();
bossBar.setUuid(uuid);
bossBar.setAction(BossBar.REMOVE);
return bossBar;
}
private BossBar updateFlags() {
BossBar bossBar = new BossBar();
bossBar.setUuid(uuid);
bossBar.setAction(BossBar.UPDATE_PROPERTIES);
bossBar.setFlags(serializeFlags());
return bossBar;
}
private void sendToAffected(MinecraftPacket packet) {
for (Player player : players) {
if (player.isActive() && player.getProtocolVersion().getProtocol()
>= ProtocolVersion.MINECRAFT_1_9.getProtocol()) {
sendPacket(player, packet);
}
}
}
private void sendPacket(Player player, MinecraftPacket packet) {
ConnectedPlayer connected = (ConnectedPlayer) player;
connected.getConnection().write(packet);
}
}

Datei anzeigen

@ -19,17 +19,11 @@ package com.velocitypowered.proxy.command;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.permission.Tristate;
import net.kyori.text.Component;
public class MockCommandSource implements CommandSource {
public static final CommandSource INSTANCE = new MockCommandSource();
@Override
public void sendMessage(final Component component) {
}
@Override
public Tristate getPermissionValue(final String permission) {
return Tristate.UNDEFINED;