mirror of
https://github.com/PaperMC/Velocity.git
synced 2026-02-19 07:27:42 +01:00
Bump to 2.0.0-SNAPSHOT, remove deprecated text API and toml4j
This commit is contained in:
@@ -18,20 +18,10 @@ dependencies {
|
|||||||
api 'com.google.code.gson:gson:2.8.6'
|
api 'com.google.code.gson:gson:2.8.6'
|
||||||
api "com.google.guava:guava:${guavaVersion}"
|
api "com.google.guava:guava:${guavaVersion}"
|
||||||
|
|
||||||
// DEPRECATED: Will be removed in Velocity 2.0.0
|
|
||||||
api "net.kyori:text-api:${textVersion}"
|
|
||||||
api "net.kyori:text-serializer-gson:${textVersion}"
|
|
||||||
api "net.kyori:text-serializer-legacy:${textVersion}"
|
|
||||||
api "net.kyori:text-serializer-plain:${textVersion}"
|
|
||||||
|
|
||||||
// DEPRECATED: Will be removed in Velocity 2.0.0
|
|
||||||
api 'com.moandjiezana.toml:toml4j:0.7.2'
|
|
||||||
|
|
||||||
api "net.kyori:adventure-api:${adventureVersion}"
|
api "net.kyori:adventure-api:${adventureVersion}"
|
||||||
api "net.kyori:adventure-text-serializer-gson:${adventureVersion}"
|
api "net.kyori:adventure-text-serializer-gson:${adventureVersion}"
|
||||||
api "net.kyori:adventure-text-serializer-legacy:${adventureVersion}"
|
api "net.kyori:adventure-text-serializer-legacy:${adventureVersion}"
|
||||||
api "net.kyori:adventure-text-serializer-plain:${adventureVersion}"
|
api "net.kyori:adventure-text-serializer-plain:${adventureVersion}"
|
||||||
api "net.kyori:adventure-text-serializer-legacy-text3:${adventurePlatformVersion}"
|
|
||||||
|
|
||||||
api "org.slf4j:slf4j-api:${slf4jVersion}"
|
api "org.slf4j:slf4j-api:${slf4jVersion}"
|
||||||
api 'com.google.inject:guice:4.2.3'
|
api 'com.google.inject:guice:4.2.3'
|
||||||
|
|||||||
@@ -2,31 +2,9 @@ package com.velocitypowered.api.command;
|
|||||||
|
|
||||||
import com.velocitypowered.api.permission.PermissionSubject;
|
import com.velocitypowered.api.permission.PermissionSubject;
|
||||||
import net.kyori.adventure.audience.Audience;
|
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}.
|
* Represents something that can be used to run a {@link Command}.
|
||||||
*/
|
*/
|
||||||
public interface CommandSource extends Audience, PermissionSubject {
|
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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package com.velocitypowered.api.event;
|
|||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.serializer.legacytext3.LegacyText3ComponentSerializer;
|
|
||||||
import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
|
import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
@@ -93,12 +92,7 @@ public interface ResultedEvent<R extends ResultedEvent.Result> {
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
public Optional<Component> getReason() {
|
||||||
public Optional<net.kyori.text.Component> getReason() {
|
|
||||||
return Optional.ofNullable(reason).map(LegacyText3ComponentSerializer.get()::serialize);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Optional<Component> getReasonComponent() {
|
|
||||||
return Optional.ofNullable(reason);
|
return Optional.ofNullable(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,12 +115,5 @@ public interface ResultedEvent<R extends ResultedEvent.Result> {
|
|||||||
Preconditions.checkNotNull(reason, "reason");
|
Preconditions.checkNotNull(reason, "reason");
|
||||||
return new ComponentResult(false, 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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import com.google.common.base.Preconditions;
|
|||||||
import com.velocitypowered.api.event.ResultedEvent;
|
import com.velocitypowered.api.event.ResultedEvent;
|
||||||
import com.velocitypowered.api.proxy.InboundConnection;
|
import com.velocitypowered.api.proxy.InboundConnection;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import net.kyori.adventure.text.serializer.legacytext3.LegacyText3ComponentSerializer;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
@@ -71,10 +71,10 @@ public final class PreLoginEvent implements ResultedEvent<PreLoginEvent.PreLogin
|
|||||||
Result.FORCE_OFFLINE, null);
|
Result.FORCE_OFFLINE, null);
|
||||||
|
|
||||||
private final Result result;
|
private final Result result;
|
||||||
private final net.kyori.adventure.text.Component reason;
|
private final Component reason;
|
||||||
|
|
||||||
private PreLoginComponentResult(Result result,
|
private PreLoginComponentResult(Result result,
|
||||||
net.kyori.adventure.text.@Nullable Component reason) {
|
@Nullable Component reason) {
|
||||||
this.result = result;
|
this.result = result;
|
||||||
this.reason = reason;
|
this.reason = reason;
|
||||||
}
|
}
|
||||||
@@ -84,12 +84,7 @@ public final class PreLoginEvent implements ResultedEvent<PreLoginEvent.PreLogin
|
|||||||
return result != Result.DISALLOWED;
|
return result != Result.DISALLOWED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
public Optional<Component> getReason() {
|
||||||
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);
|
return Optional.ofNullable(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,23 +144,9 @@ public final class PreLoginEvent implements ResultedEvent<PreLoginEvent.PreLogin
|
|||||||
* Denies the login with the specified reason.
|
* Denies the login with the specified reason.
|
||||||
*
|
*
|
||||||
* @param reason the reason for disallowing the connection
|
* @param reason the reason for disallowing the connection
|
||||||
* @deprecated Use {@link #denied(net.kyori.adventure.text.Component)}
|
|
||||||
* @return a new result
|
* @return a new result
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
public static PreLoginComponentResult denied(Component reason) {
|
||||||
public static PreLoginComponentResult denied(net.kyori.text.Component reason) {
|
|
||||||
Preconditions.checkNotNull(reason, "reason");
|
|
||||||
return new PreLoginComponentResult(Result.DISALLOWED, LegacyText3ComponentSerializer.get()
|
|
||||||
.deserialize(reason));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Denies the login with the specified reason.
|
|
||||||
*
|
|
||||||
* @param reason the reason for disallowing the connection
|
|
||||||
* @return a new result
|
|
||||||
*/
|
|
||||||
public static PreLoginComponentResult denied(net.kyori.adventure.text.Component reason) {
|
|
||||||
Preconditions.checkNotNull(reason, "reason");
|
Preconditions.checkNotNull(reason, "reason");
|
||||||
return new PreLoginComponentResult(Result.DISALLOWED, reason);
|
return new PreLoginComponentResult(Result.DISALLOWED, reason);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,7 @@ import com.velocitypowered.api.event.ResultedEvent;
|
|||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import net.kyori.adventure.text.serializer.legacytext3.LegacyText3ComponentSerializer;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.text.Component;
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
@@ -21,39 +20,10 @@ public final class KickedFromServerEvent implements
|
|||||||
|
|
||||||
private final Player player;
|
private final Player player;
|
||||||
private final RegisteredServer server;
|
private final RegisteredServer server;
|
||||||
private final net.kyori.adventure.text.@Nullable Component originalReason;
|
private final @Nullable Component originalReason;
|
||||||
private final boolean duringServerConnect;
|
private final boolean duringServerConnect;
|
||||||
private ServerKickResult result;
|
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.
|
* Creates a {@code KickedFromServerEvent} instance.
|
||||||
* @param player the player affected
|
* @param player the player affected
|
||||||
@@ -93,14 +63,8 @@ public final class KickedFromServerEvent implements
|
|||||||
/**
|
/**
|
||||||
* Gets the reason the server kicked the player from the server.
|
* Gets the reason the server kicked the player from the server.
|
||||||
* @return 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> getServerKickReason() {
|
||||||
public Optional<Component> getOriginalReason() {
|
|
||||||
return Optional.ofNullable(originalReason).map(LegacyText3ComponentSerializer.get()::serialize);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Optional<net.kyori.adventure.text.Component> getServerKickReason() {
|
|
||||||
return Optional.ofNullable(originalReason);
|
return Optional.ofNullable(originalReason);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,18 +77,6 @@ public final class KickedFromServerEvent implements
|
|||||||
return duringServerConnect;
|
return duringServerConnect;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether or not the player got kicked while logging in.
|
|
||||||
*
|
|
||||||
* @return whether or not the player got kicked
|
|
||||||
* @deprecated {@link #kickedDuringServerConnect()} has a better name and reflects the actual
|
|
||||||
* result
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public boolean kickedDuringLogin() {
|
|
||||||
return duringServerConnect;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the base interface for {@link KickedFromServerEvent} results.
|
* Represents the base interface for {@link KickedFromServerEvent} results.
|
||||||
*/
|
*/
|
||||||
@@ -137,9 +89,9 @@ public final class KickedFromServerEvent implements
|
|||||||
*/
|
*/
|
||||||
public static final class DisconnectPlayer implements ServerKickResult {
|
public static final class DisconnectPlayer implements ServerKickResult {
|
||||||
|
|
||||||
private final net.kyori.adventure.text.Component component;
|
private final Component component;
|
||||||
|
|
||||||
private DisconnectPlayer(net.kyori.adventure.text.Component component) {
|
private DisconnectPlayer(Component component) {
|
||||||
this.component = Preconditions.checkNotNull(component, "component");
|
this.component = Preconditions.checkNotNull(component, "component");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,12 +100,7 @@ public final class KickedFromServerEvent implements
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public Component getReason() {
|
public Component getReason() {
|
||||||
return LegacyText3ComponentSerializer.get().serialize(component);
|
|
||||||
}
|
|
||||||
|
|
||||||
public net.kyori.adventure.text.Component getReasonComponent() {
|
|
||||||
return component;
|
return component;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,20 +109,8 @@ public final class KickedFromServerEvent implements
|
|||||||
*
|
*
|
||||||
* @param reason the reason to use when disconnecting the player
|
* @param reason the reason to use when disconnecting the player
|
||||||
* @return the disconnect result
|
* @return the disconnect result
|
||||||
* @deprecated Use {@link #create(net.kyori.adventure.text.Component)} instead
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
|
||||||
public static DisconnectPlayer create(Component reason) {
|
public static DisconnectPlayer create(Component reason) {
|
||||||
return new DisconnectPlayer(LegacyText3ComponentSerializer.get().deserialize(reason));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new {@link DisconnectPlayer} with the specified reason.
|
|
||||||
*
|
|
||||||
* @param reason the reason to use when disconnecting the player
|
|
||||||
* @return the disconnect result
|
|
||||||
*/
|
|
||||||
public static DisconnectPlayer create(net.kyori.adventure.text.Component reason) {
|
|
||||||
return new DisconnectPlayer(reason);
|
return new DisconnectPlayer(reason);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -186,7 +121,7 @@ public final class KickedFromServerEvent implements
|
|||||||
*/
|
*/
|
||||||
public static final class RedirectPlayer implements ServerKickResult {
|
public static final class RedirectPlayer implements ServerKickResult {
|
||||||
|
|
||||||
private final net.kyori.adventure.text.Component message;
|
private final Component message;
|
||||||
private final RegisteredServer server;
|
private final RegisteredServer server;
|
||||||
|
|
||||||
private RedirectPlayer(RegisteredServer server,
|
private RedirectPlayer(RegisteredServer server,
|
||||||
@@ -204,30 +139,10 @@ public final class KickedFromServerEvent implements
|
|||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public Component getMessage() {
|
public Component getMessage() {
|
||||||
return LegacyText3ComponentSerializer.get().serialize(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public net.kyori.adventure.text.@Nullable Component getMessageComponent() {
|
|
||||||
return message;
|
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}.
|
* Creates a new redirect result to forward the player to the specified {@code server}.
|
||||||
*
|
*
|
||||||
@@ -235,7 +150,7 @@ public final class KickedFromServerEvent implements
|
|||||||
* @return the redirect result
|
* @return the redirect result
|
||||||
*/
|
*/
|
||||||
public static RedirectPlayer create(RegisteredServer server,
|
public static RedirectPlayer create(RegisteredServer server,
|
||||||
net.kyori.adventure.text.Component message) {
|
Component message) {
|
||||||
return new RedirectPlayer(server, message);
|
return new RedirectPlayer(server, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,9 +166,9 @@ public final class KickedFromServerEvent implements
|
|||||||
*/
|
*/
|
||||||
public static final class Notify implements ServerKickResult {
|
public static final class Notify implements ServerKickResult {
|
||||||
|
|
||||||
private final net.kyori.adventure.text.Component message;
|
private final Component message;
|
||||||
|
|
||||||
private Notify(net.kyori.adventure.text.Component message) {
|
private Notify(Component message) {
|
||||||
this.message = Preconditions.checkNotNull(message, "message");
|
this.message = Preconditions.checkNotNull(message, "message");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,12 +177,7 @@ public final class KickedFromServerEvent implements
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public Component getMessage() {
|
public Component getMessage() {
|
||||||
return LegacyText3ComponentSerializer.get().serialize(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public net.kyori.adventure.text.Component getMessageComponent() {
|
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,20 +186,8 @@ public final class KickedFromServerEvent implements
|
|||||||
*
|
*
|
||||||
* @param message the server to send the player to
|
* @param message the server to send the player to
|
||||||
* @return the redirect result
|
* @return the redirect result
|
||||||
* @deprecated Use {@link #create(net.kyori.adventure.text.Component)} instead
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
|
||||||
public static Notify create(Component message) {
|
public static Notify create(Component message) {
|
||||||
return new Notify(LegacyText3ComponentSerializer.get().deserialize(message));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Notifies the player with the specified message but does nothing else.
|
|
||||||
*
|
|
||||||
* @param message the server to send the player to
|
|
||||||
* @return the redirect result
|
|
||||||
*/
|
|
||||||
public static Notify create(net.kyori.adventure.text.Component message) {
|
|
||||||
return new Notify(message);
|
return new Notify(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package com.velocitypowered.api.proxy;
|
|||||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import net.kyori.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a fluent interface to send a connection request to another server on the proxy. A
|
* Provides a fluent interface to send a connection request to another server on the proxy. A
|
||||||
@@ -67,18 +67,9 @@ public interface ConnectionRequestBuilder {
|
|||||||
* Returns an (optional) textual reason for the failure to connect to the server.
|
* 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
|
* @return the reason why the user could not connect to the server
|
||||||
* @deprecated Use {@link #getReasonComponent()} instead
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
|
||||||
Optional<Component> getReason();
|
Optional<Component> getReason();
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns an (optional) textual reason for the failure to connect to the server.
|
|
||||||
*
|
|
||||||
* @return the reason why the user could not connect to the server
|
|
||||||
*/
|
|
||||||
Optional<net.kyori.adventure.text.Component> getReasonComponent();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the server we actually tried to connect to.
|
* Returns the server we actually tried to connect to.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -8,14 +8,11 @@ import com.velocitypowered.api.proxy.player.PlayerSettings;
|
|||||||
import com.velocitypowered.api.proxy.player.TabList;
|
import com.velocitypowered.api.proxy.player.TabList;
|
||||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||||
import com.velocitypowered.api.util.GameProfile;
|
import com.velocitypowered.api.util.GameProfile;
|
||||||
import com.velocitypowered.api.util.MessagePosition;
|
|
||||||
import com.velocitypowered.api.util.ModInfo;
|
import com.velocitypowered.api.util.ModInfo;
|
||||||
import com.velocitypowered.api.util.title.Title;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import net.kyori.adventure.identity.Identified;
|
import net.kyori.adventure.identity.Identified;
|
||||||
import net.kyori.adventure.identity.Identity;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -74,31 +71,6 @@ public interface Player extends CommandSource, Identified, InboundConnection,
|
|||||||
*/
|
*/
|
||||||
boolean isOnlineMode();
|
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.
|
* Creates a new connection request so that the player can connect to another server.
|
||||||
*
|
*
|
||||||
@@ -128,24 +100,6 @@ public interface Player extends CommandSource, Identified, InboundConnection,
|
|||||||
*/
|
*/
|
||||||
GameProfile getGameProfile();
|
GameProfile getGameProfile();
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the tab list header and footer for the player.
|
|
||||||
*
|
|
||||||
* @param header the header component
|
|
||||||
* @param footer the footer component
|
|
||||||
* @deprecated Use {@link TabList#setHeaderAndFooter(Component, Component)}.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
void setHeaderAndFooter(net.kyori.text.Component header, net.kyori.text.Component footer);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clears the tab list header and footer for the player.
|
|
||||||
*
|
|
||||||
* @deprecated Use {@link TabList#clearHeaderAndFooter()}.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
void clearHeaderAndFooter();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the player's tab list.
|
* Returns the player's tab list.
|
||||||
*
|
*
|
||||||
@@ -158,27 +112,8 @@ public interface Player extends CommandSource, Identified, InboundConnection,
|
|||||||
* other {@link Player} methods will become undefined.
|
* other {@link Player} methods will become undefined.
|
||||||
*
|
*
|
||||||
* @param reason component with the reason
|
* @param reason component with the reason
|
||||||
* @deprecated Use {@link #disconnect(Component)} instead
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
void disconnect(Component reason);
|
||||||
void disconnect(net.kyori.text.Component reason);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disconnects the player with the specified reason. Once this method is called, further calls to
|
|
||||||
* other {@link Player} methods will become undefined.
|
|
||||||
*
|
|
||||||
* @param reason component with the reason
|
|
||||||
*/
|
|
||||||
void disconnect(net.kyori.adventure.text.Component reason);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends the specified title to the client.
|
|
||||||
*
|
|
||||||
* @param title the title to send
|
|
||||||
* @deprecated Use {@link #showTitle(net.kyori.adventure.title.Title)} and {@link #resetTitle()}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
void sendTitle(Title title);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends chat input onto the players current server as if they typed it into the client chat box.
|
* Sends chat input onto the players current server as if they typed it into the client chat box.
|
||||||
|
|||||||
@@ -10,18 +10,11 @@ import com.velocitypowered.api.proxy.server.RegisteredServer;
|
|||||||
import com.velocitypowered.api.proxy.server.ServerInfo;
|
import com.velocitypowered.api.proxy.server.ServerInfo;
|
||||||
import com.velocitypowered.api.scheduler.Scheduler;
|
import com.velocitypowered.api.scheduler.Scheduler;
|
||||||
import com.velocitypowered.api.util.ProxyVersion;
|
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.net.InetSocketAddress;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import net.kyori.adventure.audience.Audience;
|
import net.kyori.adventure.audience.Audience;
|
||||||
import net.kyori.adventure.identity.Identified;
|
|
||||||
import net.kyori.adventure.identity.Identity;
|
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides an interface to a Minecraft server proxy.
|
* Provides an interface to a Minecraft server proxy.
|
||||||
@@ -57,16 +50,6 @@ public interface ProxyServer extends Audience {
|
|||||||
*/
|
*/
|
||||||
Optional<Player> getPlayer(UUID uuid);
|
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
|
* Retrieves all players currently connected to this proxy. This call may or may not be a snapshot
|
||||||
* of all players online.
|
* of all players online.
|
||||||
@@ -195,19 +178,4 @@ public interface ProxyServer extends Audience {
|
|||||||
* @return the proxy version
|
* @return the proxy version
|
||||||
*/
|
*/
|
||||||
ProxyVersion getVersion();
|
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);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,15 +39,6 @@ public interface ProxyConfig {
|
|||||||
*/
|
*/
|
||||||
boolean shouldQueryShowPlugins();
|
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.
|
* Get the MOTD component shown in the tab list.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -13,16 +13,6 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||||||
*/
|
*/
|
||||||
public interface TabList {
|
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.
|
* Sets the tab list header and footer for the player.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package com.velocitypowered.api.proxy.player;
|
|||||||
import com.velocitypowered.api.util.GameProfile;
|
import com.velocitypowered.api.util.GameProfile;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.serializer.legacytext3.LegacyText3ComponentSerializer;
|
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -28,37 +27,14 @@ public interface TabListEntry {
|
|||||||
GameProfile getProfile();
|
GameProfile getProfile();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns {@link Optional} text {@link net.kyori.text.Component}, which if present is the text
|
* Returns {@link Optional} text {@link Component}, which if present is the text
|
||||||
* displayed for {@code this} entry in the {@link TabList}, otherwise
|
* displayed for {@code this} entry in the {@link TabList}, otherwise
|
||||||
* {@link GameProfile#getName()} is shown.
|
* {@link GameProfile#getName()} is shown.
|
||||||
*
|
*
|
||||||
* @return {@link Optional} text {@link net.kyori.text.Component} of name displayed in the tab
|
* @return {@link Optional} text {@link Component} of name displayed in the tab
|
||||||
* list
|
|
||||||
* @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
|
* list
|
||||||
*/
|
*/
|
||||||
Optional<Component> getDisplayNameComponent();
|
Optional<Component> getDisplayName();
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
* Sets the text {@link Component} to be displayed for {@code this} {@link TabListEntry}. If
|
||||||
@@ -175,19 +151,6 @@ public interface TabListEntry {
|
|||||||
* @param displayName to set
|
* @param displayName to set
|
||||||
* @return {@code this}, for chaining
|
* @return {@code this}, for chaining
|
||||||
* @see TabListEntry#getDisplayName()
|
* @see TabListEntry#getDisplayName()
|
||||||
* @deprecated Use {@link #displayName(Component)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public Builder displayName(net.kyori.text.Component displayName) {
|
|
||||||
return displayName(LegacyText3ComponentSerializer.get().deserialize(displayName));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the displayed name of the {@link TabListEntry}.
|
|
||||||
*
|
|
||||||
* @param displayName to set
|
|
||||||
* @return {@code this}, for chaining
|
|
||||||
* @see TabListEntry#getDisplayNameComponent() ()
|
|
||||||
*/
|
*/
|
||||||
public Builder displayName(@Nullable Component displayName) {
|
public Builder displayName(@Nullable Component displayName) {
|
||||||
this.displayName = displayName;
|
this.displayName = displayName;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import java.util.Objects;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import net.kyori.adventure.text.serializer.legacytext3.LegacyText3ComponentSerializer;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -22,19 +22,12 @@ public final class ServerPing {
|
|||||||
|
|
||||||
private final Version version;
|
private final Version version;
|
||||||
private final @Nullable Players players;
|
private final @Nullable Players players;
|
||||||
private final net.kyori.adventure.text.Component description;
|
private final Component description;
|
||||||
private final @Nullable Favicon favicon;
|
private final @Nullable Favicon favicon;
|
||||||
private final @Nullable ModInfo modinfo;
|
private final @Nullable ModInfo modinfo;
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public ServerPing(Version version, @Nullable Players players,
|
public ServerPing(Version version, @Nullable Players players,
|
||||||
net.kyori.text.Component description, @Nullable Favicon favicon) {
|
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);
|
this(version, players, description, favicon, ModInfo.DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,25 +40,8 @@ public final class ServerPing {
|
|||||||
* @param favicon the server's favicon
|
* @param favicon the server's favicon
|
||||||
* @param modinfo the mods this server runs
|
* @param modinfo the mods this server runs
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
|
||||||
public ServerPing(Version version, @Nullable Players players,
|
public ServerPing(Version version, @Nullable Players players,
|
||||||
net.kyori.text.Component description, @Nullable Favicon favicon,
|
Component description, @Nullable Favicon favicon,
|
||||||
@Nullable ModInfo modinfo) {
|
|
||||||
this(version, players, LegacyText3ComponentSerializer.get().deserialize(description), favicon,
|
|
||||||
modinfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a ServerPing instance.
|
|
||||||
*
|
|
||||||
* @param version the version of the server
|
|
||||||
* @param players the players on the server
|
|
||||||
* @param description the MOTD for the server
|
|
||||||
* @param favicon the server's favicon
|
|
||||||
* @param modinfo the mods this server runs
|
|
||||||
*/
|
|
||||||
public ServerPing(Version version, @Nullable Players players,
|
|
||||||
net.kyori.adventure.text.Component description, @Nullable Favicon favicon,
|
|
||||||
@Nullable ModInfo modinfo) {
|
@Nullable ModInfo modinfo) {
|
||||||
this.version = Preconditions.checkNotNull(version, "version");
|
this.version = Preconditions.checkNotNull(version, "version");
|
||||||
this.players = players;
|
this.players = players;
|
||||||
@@ -82,12 +58,7 @@ public final class ServerPing {
|
|||||||
return Optional.ofNullable(players);
|
return Optional.ofNullable(players);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
public Component getDescription() {
|
||||||
public net.kyori.text.Component getDescription() {
|
|
||||||
return LegacyText3ComponentSerializer.get().serialize(description);
|
|
||||||
}
|
|
||||||
|
|
||||||
public net.kyori.adventure.text.Component getDescriptionComponent() {
|
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,7 +144,7 @@ public final class ServerPing {
|
|||||||
private final List<SamplePlayer> samplePlayers = new ArrayList<>();
|
private final List<SamplePlayer> samplePlayers = new ArrayList<>();
|
||||||
private String modType = "FML";
|
private String modType = "FML";
|
||||||
private final List<ModInfo.Mod> mods = new ArrayList<>();
|
private final List<ModInfo.Mod> mods = new ArrayList<>();
|
||||||
private net.kyori.adventure.text.Component description;
|
private Component description;
|
||||||
private @Nullable Favicon favicon;
|
private @Nullable Favicon favicon;
|
||||||
private boolean nullOutPlayers;
|
private boolean nullOutPlayers;
|
||||||
private boolean nullOutModinfo;
|
private boolean nullOutModinfo;
|
||||||
@@ -245,13 +216,7 @@ public final class ServerPing {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
public Builder description(Component description) {
|
||||||
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");
|
this.description = Preconditions.checkNotNull(description, "description");
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -294,12 +259,7 @@ public final class ServerPing {
|
|||||||
return samplePlayers;
|
return samplePlayers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
public Optional<Component> getDescription() {
|
||||||
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);
|
return Optional.ofNullable(description);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
package com.velocitypowered.api.util;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents where a chat message is going to be sent.
|
|
||||||
*/
|
|
||||||
public enum MessagePosition {
|
|
||||||
/**
|
|
||||||
* The chat message will appear in the client's HUD. These messages can be filtered out by the
|
|
||||||
* client.
|
|
||||||
*/
|
|
||||||
CHAT,
|
|
||||||
/**
|
|
||||||
* The chat message will appear in the client's HUD and can't be dismissed.
|
|
||||||
*/
|
|
||||||
SYSTEM,
|
|
||||||
/**
|
|
||||||
* The chat message will appear above the player's main HUD. This text format doesn't support many
|
|
||||||
* component features, such as hover events.
|
|
||||||
*/
|
|
||||||
ACTION_BAR
|
|
||||||
}
|
|
||||||
@@ -1,162 +0,0 @@
|
|||||||
package com.velocitypowered.api.util.bossbar;
|
|
||||||
|
|
||||||
import com.velocitypowered.api.proxy.Player;
|
|
||||||
import java.util.Collection;
|
|
||||||
import net.kyori.text.Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a boss bar, which can be send to a (group of) player(s).
|
|
||||||
* <b>Boss bars only work on 1.9 and above.</b>
|
|
||||||
*
|
|
||||||
* @deprecated Replaced with {@link net.kyori.adventure.bossbar.BossBar}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public interface BossBar {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds all specified players to this boss bar.
|
|
||||||
*
|
|
||||||
* @param players players
|
|
||||||
* @see #addPlayer(Player)
|
|
||||||
*/
|
|
||||||
void addPlayers(Iterable<Player> players);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds player to this boss bar. This adds the player to the {@link #getPlayers()} and makes him
|
|
||||||
* see the boss bar.
|
|
||||||
*
|
|
||||||
* @param player the player you wish to add
|
|
||||||
*/
|
|
||||||
void addPlayer(Player player);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes player from this boss bar. This removes the player from {@link #getPlayers()} and makes
|
|
||||||
* him not see the boss bar.
|
|
||||||
*
|
|
||||||
* @param player the player you wish to remove
|
|
||||||
*/
|
|
||||||
void removePlayer(Player player);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes all specified players from this boss bar.
|
|
||||||
*
|
|
||||||
* @param players players
|
|
||||||
* @see #removePlayer(Player)
|
|
||||||
*/
|
|
||||||
void removePlayers(Iterable<Player> players);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes all players, that see this boss bar.
|
|
||||||
*
|
|
||||||
* @see #removePlayer(Player)
|
|
||||||
*/
|
|
||||||
void removeAllPlayers();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the title of this boss bar.
|
|
||||||
*
|
|
||||||
* @return title
|
|
||||||
*/
|
|
||||||
Component getTitle();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets a new title of the boss bar.
|
|
||||||
*
|
|
||||||
* @param title new title
|
|
||||||
*/
|
|
||||||
void setTitle(Component title);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the boss bar's percent.
|
|
||||||
*
|
|
||||||
* @return percent
|
|
||||||
*/
|
|
||||||
float getPercent();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets a new percent of the boss bar.
|
|
||||||
*
|
|
||||||
* @param percent a float between 0 and 1, representing boss bar's percent
|
|
||||||
* @throws IllegalArgumentException if the new percent is not between 0 and 1
|
|
||||||
*/
|
|
||||||
void setPercent(float percent);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a copy of the {@link Collection} of all {@link Player} added to the boss bar.
|
|
||||||
* <i>Can be empty.</i>
|
|
||||||
*
|
|
||||||
* @return players
|
|
||||||
*/
|
|
||||||
Collection<Player> getPlayers();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the color of the boss bar.
|
|
||||||
*
|
|
||||||
* @return boss bar color
|
|
||||||
*/
|
|
||||||
BossBarColor getColor();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets a new color of the boss bar.
|
|
||||||
*
|
|
||||||
* @param color the color you wish the boss bar be displayed with
|
|
||||||
*/
|
|
||||||
void setColor(BossBarColor color);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the overlay of the boss bar.
|
|
||||||
*
|
|
||||||
* @return boss bar overlay
|
|
||||||
*/
|
|
||||||
BossBarOverlay getOverlay();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets a new overlay of the boss bar.
|
|
||||||
*
|
|
||||||
* @param overlay the overlay you wish the boss bar be displayed with
|
|
||||||
*/
|
|
||||||
void setOverlay(BossBarOverlay overlay);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whenever this boss bar is visible to all added {@link #getPlayers()}. By default, it
|
|
||||||
* returns <code>true</code>.
|
|
||||||
*
|
|
||||||
* @return <code>true</code> if visible, otherwise <code>false</code>
|
|
||||||
*/
|
|
||||||
boolean isVisible();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets a new visibility to the boss bar.
|
|
||||||
*
|
|
||||||
* @param visible boss bar visibility value
|
|
||||||
*/
|
|
||||||
void setVisible(boolean visible);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a copy of of the {@link Collection} of all {@link BossBarFlag}s added to the boss bar.
|
|
||||||
*
|
|
||||||
* @return flags
|
|
||||||
*/
|
|
||||||
Collection<BossBarFlag> getFlags();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds new flags to the boss bar.
|
|
||||||
*
|
|
||||||
* @param flags the flags you wish to add
|
|
||||||
*/
|
|
||||||
void addFlags(BossBarFlag... flags);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes flag from the boss bar.
|
|
||||||
*
|
|
||||||
* @param flag the flag you wish to remove
|
|
||||||
*/
|
|
||||||
void removeFlag(BossBarFlag flag);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes flags from the boss bar.
|
|
||||||
*
|
|
||||||
* @param flags the flags you wish to remove
|
|
||||||
*/
|
|
||||||
void removeFlags(BossBarFlag... flags);
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package com.velocitypowered.api.util.bossbar;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a color of a {@link BossBar}.
|
|
||||||
*
|
|
||||||
* @deprecated Replaced with {@link net.kyori.adventure.bossbar.BossBar.Color}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public enum BossBarColor {
|
|
||||||
PINK,
|
|
||||||
BLUE,
|
|
||||||
RED,
|
|
||||||
GREEN,
|
|
||||||
YELLOW,
|
|
||||||
PURPLE,
|
|
||||||
WHITE
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package com.velocitypowered.api.util.bossbar;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents any {@link BossBar}'s flags.
|
|
||||||
*
|
|
||||||
* @deprecated Replaced with {@link net.kyori.adventure.bossbar.BossBar.Flag}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public enum BossBarFlag {
|
|
||||||
DARKEN_SCREEN,
|
|
||||||
PLAY_BOSS_MUSIC,
|
|
||||||
CREATE_WORLD_FOG
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package com.velocitypowered.api.util.bossbar;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a overlay of a {@link BossBar}.
|
|
||||||
*
|
|
||||||
* @deprecated Replaced with {@link net.kyori.adventure.bossbar.BossBar.Overlay}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public enum BossBarOverlay {
|
|
||||||
PROGRESS,
|
|
||||||
NOTCHED_6,
|
|
||||||
NOTCHED_10,
|
|
||||||
NOTCHED_12,
|
|
||||||
NOTCHED_20
|
|
||||||
}
|
|
||||||
@@ -1,257 +0,0 @@
|
|||||||
package com.velocitypowered.api.util.title;
|
|
||||||
|
|
||||||
import com.google.common.base.MoreObjects;
|
|
||||||
import com.google.common.base.Preconditions;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Optional;
|
|
||||||
import net.kyori.text.Component;
|
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a "full" title, including all components. This class is immutable.
|
|
||||||
*
|
|
||||||
* @deprecated Replaced with {@link net.kyori.adventure.title.Title}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public final class TextTitle implements Title {
|
|
||||||
|
|
||||||
private final @Nullable Component title;
|
|
||||||
private final @Nullable Component subtitle;
|
|
||||||
private final int stay;
|
|
||||||
private final int fadeIn;
|
|
||||||
private final int fadeOut;
|
|
||||||
private final boolean resetBeforeSend;
|
|
||||||
|
|
||||||
private TextTitle(Builder builder) {
|
|
||||||
this.title = builder.title;
|
|
||||||
this.subtitle = builder.subtitle;
|
|
||||||
this.stay = builder.stay;
|
|
||||||
this.fadeIn = builder.fadeIn;
|
|
||||||
this.fadeOut = builder.fadeOut;
|
|
||||||
this.resetBeforeSend = builder.resetBeforeSend;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the main title this title has, if any.
|
|
||||||
*
|
|
||||||
* @return the main title of this title
|
|
||||||
*/
|
|
||||||
public Optional<Component> getTitle() {
|
|
||||||
return Optional.ofNullable(title);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the subtitle this title has, if any.
|
|
||||||
*
|
|
||||||
* @return the subtitle
|
|
||||||
*/
|
|
||||||
public Optional<Component> getSubtitle() {
|
|
||||||
return Optional.ofNullable(subtitle);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the number of ticks this title will stay up.
|
|
||||||
*
|
|
||||||
* @return how long the title will stay, in ticks
|
|
||||||
*/
|
|
||||||
public int getStay() {
|
|
||||||
return stay;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the number of ticks over which this title will fade in.
|
|
||||||
*
|
|
||||||
* @return how long the title will fade in, in ticks
|
|
||||||
*/
|
|
||||||
public int getFadeIn() {
|
|
||||||
return fadeIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the number of ticks over which this title will fade out.
|
|
||||||
*
|
|
||||||
* @return how long the title will fade out, in ticks
|
|
||||||
*/
|
|
||||||
public int getFadeOut() {
|
|
||||||
return fadeOut;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether or not a reset packet will be sent before this title is sent. By default,
|
|
||||||
* unless explicitly disabled, this is enabled by default.
|
|
||||||
*
|
|
||||||
* @return whether or not a reset packet will be sent before this title is sent
|
|
||||||
*/
|
|
||||||
public boolean isResetBeforeSend() {
|
|
||||||
return resetBeforeSend;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determines whether or not this title has times set on it. If none are set, it will update the
|
|
||||||
* previous title set on the client.
|
|
||||||
*
|
|
||||||
* @return whether or not this title has times set on it
|
|
||||||
*/
|
|
||||||
public boolean areTimesSet() {
|
|
||||||
return stay != 0 || fadeIn != 0 || fadeOut != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new builder from the contents of this title so that it may be changed.
|
|
||||||
*
|
|
||||||
* @return a builder instance with the contents of this title
|
|
||||||
*/
|
|
||||||
public Builder toBuilder() {
|
|
||||||
return new Builder(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(@Nullable Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (o == null || getClass() != o.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
TextTitle textTitle = (TextTitle) o;
|
|
||||||
return stay == textTitle.stay
|
|
||||||
&& fadeIn == textTitle.fadeIn
|
|
||||||
&& fadeOut == textTitle.fadeOut
|
|
||||||
&& resetBeforeSend == textTitle.resetBeforeSend
|
|
||||||
&& Objects.equals(title, textTitle.title)
|
|
||||||
&& Objects.equals(subtitle, textTitle.subtitle);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return MoreObjects.toStringHelper(this)
|
|
||||||
.add("title", title)
|
|
||||||
.add("subtitle", subtitle)
|
|
||||||
.add("stay", stay)
|
|
||||||
.add("fadeIn", fadeIn)
|
|
||||||
.add("fadeOut", fadeOut)
|
|
||||||
.add("resetBeforeSend", resetBeforeSend)
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(title, subtitle, stay, fadeIn, fadeOut, resetBeforeSend);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new builder for constructing titles.
|
|
||||||
*
|
|
||||||
* @return a builder for constructing titles
|
|
||||||
*/
|
|
||||||
public static Builder builder() {
|
|
||||||
return new Builder();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Builder {
|
|
||||||
|
|
||||||
private @Nullable Component title;
|
|
||||||
private @Nullable Component subtitle;
|
|
||||||
private int stay;
|
|
||||||
private int fadeIn;
|
|
||||||
private int fadeOut;
|
|
||||||
private boolean resetBeforeSend = true;
|
|
||||||
|
|
||||||
private Builder() {
|
|
||||||
}
|
|
||||||
|
|
||||||
private Builder(TextTitle copy) {
|
|
||||||
this.title = copy.title;
|
|
||||||
this.subtitle = copy.subtitle;
|
|
||||||
this.stay = copy.stay;
|
|
||||||
this.fadeIn = copy.fadeIn;
|
|
||||||
this.fadeOut = copy.fadeOut;
|
|
||||||
this.resetBeforeSend = copy.resetBeforeSend;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder title(Component title) {
|
|
||||||
this.title = Preconditions.checkNotNull(title, "title");
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder clearTitle() {
|
|
||||||
this.title = null;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder subtitle(Component subtitle) {
|
|
||||||
this.subtitle = Preconditions.checkNotNull(subtitle, "subtitle");
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder clearSubtitle() {
|
|
||||||
this.subtitle = null;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int checkTicks(int ticks) {
|
|
||||||
Preconditions.checkArgument(ticks >= 0, "ticks value %s is negative", ticks);
|
|
||||||
return ticks;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder stay(int ticks) {
|
|
||||||
this.stay = checkTicks(ticks);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder fadeIn(int ticks) {
|
|
||||||
this.fadeIn = checkTicks(ticks);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder fadeOut(int ticks) {
|
|
||||||
this.fadeOut = checkTicks(ticks);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder resetBeforeSend(boolean b) {
|
|
||||||
this.resetBeforeSend = b;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Optional<Component> getTitle() {
|
|
||||||
return Optional.ofNullable(title);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Optional<Component> getSubtitle() {
|
|
||||||
return Optional.ofNullable(subtitle);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getStay() {
|
|
||||||
return stay;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFadeIn() {
|
|
||||||
return fadeIn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFadeOut() {
|
|
||||||
return fadeOut;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isResetBeforeSend() {
|
|
||||||
return resetBeforeSend;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TextTitle build() {
|
|
||||||
return new TextTitle(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return MoreObjects.toStringHelper(this)
|
|
||||||
.add("title", title)
|
|
||||||
.add("subtitle", subtitle)
|
|
||||||
.add("stay", stay)
|
|
||||||
.add("fadeIn", fadeIn)
|
|
||||||
.add("fadeOut", fadeOut)
|
|
||||||
.add("resetBeforeSend", resetBeforeSend)
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package com.velocitypowered.api.util.title;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a title that can be sent to a Minecraft client.
|
|
||||||
*
|
|
||||||
* @deprecated Replaced with {@link net.kyori.adventure.title.Title}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public interface Title {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
package com.velocitypowered.api.util.title;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provides special-purpose titles.
|
|
||||||
*
|
|
||||||
* @deprecated Replaced with {@link net.kyori.adventure.title.Title}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public final class Titles {
|
|
||||||
|
|
||||||
private Titles() {
|
|
||||||
throw new AssertionError();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final Title RESET = new Title() {
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "reset title";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private static final Title HIDE = new Title() {
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "hide title";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a title that, when sent to the client, will cause all title data to be reset and any
|
|
||||||
* existing title to be hidden.
|
|
||||||
*
|
|
||||||
* @return the reset title
|
|
||||||
*/
|
|
||||||
public static Title reset() {
|
|
||||||
return RESET;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a title that, when sent to the client, will cause any existing title to be hidden. The
|
|
||||||
* title may be restored by a {@link TextTitle} with no title or subtitle (only a time).
|
|
||||||
*
|
|
||||||
* @return the hide title
|
|
||||||
*/
|
|
||||||
public static Title hide() {
|
|
||||||
return HIDE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a builder for {@link TextTitle}s.
|
|
||||||
*
|
|
||||||
* @return a builder for text titles
|
|
||||||
*/
|
|
||||||
public static TextTitle.Builder text() {
|
|
||||||
return TextTitle.builder();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
/**
|
|
||||||
* Provides data structures for creating and manipulating titles.
|
|
||||||
*
|
|
||||||
* @deprecated Replaced with {@link net.kyori.adventure.title.Title}
|
|
||||||
*/
|
|
||||||
package com.velocitypowered.api.util.title;
|
|
||||||
@@ -7,7 +7,7 @@ import com.velocitypowered.api.proxy.server.ServerPing.Players;
|
|||||||
import com.velocitypowered.api.proxy.server.ServerPing.SamplePlayer;
|
import com.velocitypowered.api.proxy.server.ServerPing.SamplePlayer;
|
||||||
import com.velocitypowered.api.proxy.server.ServerPing.Version;
|
import com.velocitypowered.api.proxy.server.ServerPing.Version;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import net.kyori.text.TextComponent;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
class ServerPingTest {
|
class ServerPingTest {
|
||||||
@@ -16,7 +16,7 @@ class ServerPingTest {
|
|||||||
void asBuilderConsistency() {
|
void asBuilderConsistency() {
|
||||||
ServerPing ping = new ServerPing(new Version(404, "1.13.2"),
|
ServerPing ping = new ServerPing(new Version(404, "1.13.2"),
|
||||||
new Players(1, 1, ImmutableList.of(new SamplePlayer("tuxed", UUID.randomUUID()))),
|
new Players(1, 1, ImmutableList.of(new SamplePlayer("tuxed", UUID.randomUUID()))),
|
||||||
TextComponent.of("test"), null);
|
Component.text("test"), null);
|
||||||
assertEquals(ping, ping.asBuilder().build());
|
assertEquals(ping, ping.asBuilder().build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16,7 +16,7 @@ allprojects {
|
|||||||
apply plugin: "com.github.spotbugs"
|
apply plugin: "com.github.spotbugs"
|
||||||
|
|
||||||
group 'com.velocitypowered'
|
group 'com.velocitypowered'
|
||||||
version '1.1.0-SNAPSHOT'
|
version '2.0.0-SNAPSHOT'
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
// dependency versions
|
// dependency versions
|
||||||
|
|||||||
@@ -18,9 +18,6 @@ import com.velocitypowered.api.proxy.server.ServerInfo;
|
|||||||
import com.velocitypowered.api.util.Favicon;
|
import com.velocitypowered.api.util.Favicon;
|
||||||
import com.velocitypowered.api.util.GameProfile;
|
import com.velocitypowered.api.util.GameProfile;
|
||||||
import com.velocitypowered.api.util.ProxyVersion;
|
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.VelocityCommandManager;
|
||||||
import com.velocitypowered.proxy.command.builtin.GlistCommand;
|
import com.velocitypowered.proxy.command.builtin.GlistCommand;
|
||||||
import com.velocitypowered.proxy.command.builtin.ServerCommand;
|
import com.velocitypowered.proxy.command.builtin.ServerCommand;
|
||||||
@@ -42,7 +39,6 @@ import com.velocitypowered.proxy.util.AddressUtil;
|
|||||||
import com.velocitypowered.proxy.util.EncryptionUtils;
|
import com.velocitypowered.proxy.util.EncryptionUtils;
|
||||||
import com.velocitypowered.proxy.util.VelocityChannelRegistrar;
|
import com.velocitypowered.proxy.util.VelocityChannelRegistrar;
|
||||||
import com.velocitypowered.proxy.util.bossbar.AdventureBossBarManager;
|
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.Ratelimiter;
|
||||||
import com.velocitypowered.proxy.util.ratelimit.Ratelimiters;
|
import com.velocitypowered.proxy.util.ratelimit.Ratelimiters;
|
||||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||||
@@ -77,8 +73,6 @@ import java.util.stream.Collectors;
|
|||||||
import net.kyori.adventure.audience.Audience;
|
import net.kyori.adventure.audience.Audience;
|
||||||
import net.kyori.adventure.audience.ForwardingAudience;
|
import net.kyori.adventure.audience.ForwardingAudience;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
|
||||||
import net.kyori.adventure.text.TranslatableComponent;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.asynchttpclient.AsyncHttpClient;
|
import org.asynchttpclient.AsyncHttpClient;
|
||||||
@@ -166,15 +160,6 @@ public class VelocityServer implements ProxyServer, ForwardingAudience {
|
|||||||
return new ProxyVersion(implName, implVendor, implVersion);
|
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
|
@Override
|
||||||
public VelocityCommandManager getCommandManager() {
|
public VelocityCommandManager getCommandManager() {
|
||||||
return commandManager;
|
return commandManager;
|
||||||
@@ -557,15 +542,6 @@ public class VelocityServer implements ProxyServer, ForwardingAudience {
|
|||||||
return Optional.ofNullable(connectionsByUuid.get(uuid));
|
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
|
@Override
|
||||||
public Collection<Player> matchPlayer(String partialName) {
|
public Collection<Player> matchPlayer(String partialName) {
|
||||||
Objects.requireNonNull(partialName);
|
Objects.requireNonNull(partialName);
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ import java.util.UUID;
|
|||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
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.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||||
@@ -237,16 +236,6 @@ public class VelocityConfiguration implements ProxyConfig {
|
|||||||
return query.shouldQueryShowPlugins();
|
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
|
@Override
|
||||||
public net.kyori.adventure.text.Component getMotd() {
|
public net.kyori.adventure.text.Component getMotd() {
|
||||||
if (motdAsComponent == null) {
|
if (motdAsComponent == null) {
|
||||||
|
|||||||
@@ -27,11 +27,7 @@ import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
|
|||||||
import com.velocitypowered.api.proxy.player.PlayerSettings;
|
import com.velocitypowered.api.proxy.player.PlayerSettings;
|
||||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||||
import com.velocitypowered.api.util.GameProfile;
|
import com.velocitypowered.api.util.GameProfile;
|
||||||
import com.velocitypowered.api.util.MessagePosition;
|
|
||||||
import com.velocitypowered.api.util.ModInfo;
|
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.VelocityServer;
|
||||||
import com.velocitypowered.proxy.config.VelocityConfiguration;
|
import com.velocitypowered.proxy.config.VelocityConfiguration;
|
||||||
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
||||||
@@ -229,40 +225,6 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
|||||||
return connection.getProtocolVersion();
|
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
|
@Override
|
||||||
public void sendMessage(@NonNull Identity identity, @NonNull Component message) {
|
public void sendMessage(@NonNull Identity identity, @NonNull Component message) {
|
||||||
connection.write(Chat.createClientbound(identity, message, this.getProtocolVersion()));
|
connection.write(Chat.createClientbound(identity, message, this.getProtocolVersion()));
|
||||||
@@ -369,16 +331,6 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
|||||||
this.profile = profile.withProperties(Preconditions.checkNotNull(properties));
|
this.profile = profile.withProperties(Preconditions.checkNotNull(properties));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setHeaderAndFooter(net.kyori.text.Component header, net.kyori.text.Component footer) {
|
|
||||||
tabList.setHeaderAndFooter(header, footer);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clearHeaderAndFooter() {
|
|
||||||
tabList.clearHeaderAndFooter();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VelocityTabList getTabList() {
|
public VelocityTabList getTabList() {
|
||||||
return tabList;
|
return tabList;
|
||||||
@@ -393,26 +345,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.
|
* Disconnects the player from the proxy.
|
||||||
* @param reason the reason for disconnecting the player
|
* @param reason the reason for disconnecting the player
|
||||||
@@ -424,54 +356,6 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
|||||||
connection.closeWith(Disconnect.create(reason, this.getProtocolVersion()));
|
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() {
|
public @Nullable VelocityServerConnection getConnectedServer() {
|
||||||
return connectedServer;
|
return connectedServer;
|
||||||
}
|
}
|
||||||
@@ -610,7 +494,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
|||||||
|
|
||||||
if (event.getResult() instanceof DisconnectPlayer) {
|
if (event.getResult() instanceof DisconnectPlayer) {
|
||||||
DisconnectPlayer res = (DisconnectPlayer) event.getResult();
|
DisconnectPlayer res = (DisconnectPlayer) event.getResult();
|
||||||
disconnect(res.getReasonComponent());
|
disconnect(res.getReason());
|
||||||
} else if (event.getResult() instanceof RedirectPlayer) {
|
} else if (event.getResult() instanceof RedirectPlayer) {
|
||||||
RedirectPlayer res = (RedirectPlayer) event.getResult();
|
RedirectPlayer res = (RedirectPlayer) event.getResult();
|
||||||
createConnectionRequest(res.getServer())
|
createConnectionRequest(res.getServer())
|
||||||
@@ -628,10 +512,10 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
|||||||
case CONNECTION_IN_PROGRESS:
|
case CONNECTION_IN_PROGRESS:
|
||||||
// Fatal case
|
// Fatal case
|
||||||
case CONNECTION_CANCELLED:
|
case CONNECTION_CANCELLED:
|
||||||
disconnect(status.getReasonComponent().orElse(res.getMessageComponent()));
|
disconnect(status.getReason().orElse(res.getMessage()));
|
||||||
break;
|
break;
|
||||||
case SERVER_DISCONNECTED:
|
case SERVER_DISCONNECTED:
|
||||||
Component reason = status.getReasonComponent()
|
Component reason = status.getReason()
|
||||||
.orElse(ConnectionMessages.INTERNAL_SERVER_CONNECTION_ERROR);
|
.orElse(ConnectionMessages.INTERNAL_SERVER_CONNECTION_ERROR);
|
||||||
handleConnectionException(res.getServer(), Disconnect.create(reason,
|
handleConnectionException(res.getServer(), Disconnect.create(reason,
|
||||||
getProtocolVersion()), ((Impl) status).isSafe());
|
getProtocolVersion()), ((Impl) status).isSafe());
|
||||||
@@ -648,9 +532,9 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
|||||||
} else if (event.getResult() instanceof Notify) {
|
} else if (event.getResult() instanceof Notify) {
|
||||||
Notify res = (Notify) event.getResult();
|
Notify res = (Notify) event.getResult();
|
||||||
if (event.kickedDuringServerConnect() && previouslyConnected) {
|
if (event.kickedDuringServerConnect() && previouslyConnected) {
|
||||||
sendMessage(Identity.nil(), res.getMessageComponent());
|
sendMessage(Identity.nil(), res.getMessage());
|
||||||
} else {
|
} else {
|
||||||
disconnect(res.getMessageComponent());
|
disconnect(res.getMessage());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// In case someone gets creative, assume we want to disconnect the player.
|
// In case someone gets creative, assume we want to disconnect the player.
|
||||||
@@ -997,7 +881,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
|||||||
// Ignored; the plugin probably already handled this.
|
// Ignored; the plugin probably already handled this.
|
||||||
break;
|
break;
|
||||||
case SERVER_DISCONNECTED:
|
case SERVER_DISCONNECTED:
|
||||||
Component reason = status.getReasonComponent()
|
Component reason = status.getReason()
|
||||||
.orElse(ConnectionMessages.INTERNAL_SERVER_CONNECTION_ERROR);
|
.orElse(ConnectionMessages.INTERNAL_SERVER_CONNECTION_ERROR);
|
||||||
handleConnectionException(toConnect, Disconnect.create(reason,
|
handleConnectionException(toConnect, Disconnect.create(reason,
|
||||||
getProtocolVersion()), status.isSafe());
|
getProtocolVersion()), status.isSafe());
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PreLoginComponentResult result = event.getResult();
|
PreLoginComponentResult result = event.getResult();
|
||||||
Optional<Component> disconnectReason = result.getReasonComponent();
|
Optional<Component> disconnectReason = result.getReason();
|
||||||
if (disconnectReason.isPresent()) {
|
if (disconnectReason.isPresent()) {
|
||||||
// The component is guaranteed to be provided if the connection was denied.
|
// The component is guaranteed to be provided if the connection was denied.
|
||||||
mcConnection.closeWith(Disconnect.create(disconnectReason.get(),
|
mcConnection.closeWith(Disconnect.create(disconnectReason.get(),
|
||||||
@@ -260,7 +260,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<Component> reason = event.getResult().getReasonComponent();
|
Optional<Component> reason = event.getResult().getReason();
|
||||||
if (reason.isPresent()) {
|
if (reason.isPresent()) {
|
||||||
player.disconnect0(reason.get(), true);
|
player.disconnect0(reason.get(), true);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ public class StatusSessionHandler implements MinecraftSessionHandler {
|
|||||||
return new ServerPing(
|
return new ServerPing(
|
||||||
fallback.getVersion(),
|
fallback.getVersion(),
|
||||||
fallback.getPlayers().orElse(null),
|
fallback.getPlayers().orElse(null),
|
||||||
response.getDescriptionComponent(),
|
response.getDescription(),
|
||||||
fallback.getFavicon().orElse(null),
|
fallback.getFavicon().orElse(null),
|
||||||
response.getModinfo().orElse(null)
|
response.getModinfo().orElse(null)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import java.util.Optional;
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
import net.kyori.adventure.text.serializer.legacytext3.LegacyText3ComponentSerializer;
|
|
||||||
|
|
||||||
public class ConnectionRequestResults {
|
public class ConnectionRequestResults {
|
||||||
|
|
||||||
@@ -73,12 +72,7 @@ public class ConnectionRequestResults {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<net.kyori.text.Component> getReason() {
|
public Optional<Component> getReason() {
|
||||||
return Optional.ofNullable(component).map(LegacyText3ComponentSerializer.get()::serialize);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<Component> getReasonComponent() {
|
|
||||||
return Optional.ofNullable(component);
|
return Optional.ofNullable(component);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ import com.velocitypowered.proxy.VelocityServer;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import net.kyori.adventure.identity.Identity;
|
import net.kyori.adventure.identity.Identity;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.text.TextComponent;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.kyori.text.format.TextColor;
|
|
||||||
import net.minecrell.terminalconsole.SimpleTerminalConsole;
|
import net.minecrell.terminalconsole.SimpleTerminalConsole;
|
||||||
import org.apache.logging.log4j.Level;
|
import org.apache.logging.log4j.Level;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
@@ -33,12 +32,6 @@ public final class VelocityConsole extends SimpleTerminalConsole implements Cons
|
|||||||
this.server = server;
|
this.server = server;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendMessage(net.kyori.text.Component component) {
|
|
||||||
logger.info(net.kyori.text.serializer.legacy.LegacyComponentSerializer.legacy()
|
|
||||||
.serialize(component));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(@NonNull Identity identity, @NonNull Component message) {
|
public void sendMessage(@NonNull Identity identity, @NonNull Component message) {
|
||||||
logger.info(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection()
|
logger.info(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection()
|
||||||
@@ -95,7 +88,7 @@ public final class VelocityConsole extends SimpleTerminalConsole implements Cons
|
|||||||
protected void runCommand(String command) {
|
protected void runCommand(String command) {
|
||||||
try {
|
try {
|
||||||
if (!this.server.getCommandManager().execute(this, command)) {
|
if (!this.server.getCommandManager().execute(this, command)) {
|
||||||
sendMessage(TextComponent.of("Command not found.", TextColor.RED));
|
sendMessage(Component.text("Command not found.", NamedTextColor.RED));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("An error occurred while running this command.", e);
|
logger.error("An error occurred while running this command.", e);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
|||||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import net.kyori.adventure.identity.Identity;
|
import net.kyori.adventure.identity.Identity;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@@ -99,24 +100,12 @@ public class Chat implements MinecraftPacket {
|
|||||||
return handler.handle(this);
|
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,
|
public static Chat createClientbound(Identity identity,
|
||||||
net.kyori.adventure.text.Component component, ProtocolVersion version) {
|
Component component, ProtocolVersion version) {
|
||||||
return createClientbound(component, CHAT_TYPE, identity.uuid(), version);
|
return createClientbound(component, CHAT_TYPE, identity.uuid(), version);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Chat createClientbound(net.kyori.adventure.text.Component component, byte type,
|
public static Chat createClientbound(Component component, byte type,
|
||||||
UUID sender, ProtocolVersion version) {
|
UUID sender, ProtocolVersion version) {
|
||||||
Preconditions.checkNotNull(component, "component");
|
Preconditions.checkNotNull(component, "component");
|
||||||
return new Chat(ProtocolUtils.getJsonChatSerializer(version).serialize(component), type,
|
return new Chat(ProtocolUtils.getJsonChatSerializer(version).serialize(component), type,
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
|||||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import net.kyori.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.text.serializer.gson.GsonComponentSerializer;
|
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public class Disconnect implements MinecraftPacket {
|
public class Disconnect implements MinecraftPacket {
|
||||||
@@ -57,14 +56,7 @@ public class Disconnect implements MinecraftPacket {
|
|||||||
return handler.handle(this);
|
return handler.handle(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
public static Disconnect create(Component component, ProtocolVersion version) {
|
||||||
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");
|
Preconditions.checkNotNull(component, "component");
|
||||||
return new Disconnect(ProtocolUtils.getJsonChatSerializer(version).serialize(component));
|
return new Disconnect(ProtocolUtils.getJsonChatSerializer(version).serialize(component));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,13 +51,6 @@ public class HeaderAndFooter implements MinecraftPacket {
|
|||||||
return handler.handle(this);
|
return handler.handle(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HeaderAndFooter create(net.kyori.text.Component header,
|
|
||||||
net.kyori.text.Component footer) {
|
|
||||||
return new HeaderAndFooter(
|
|
||||||
net.kyori.text.serializer.gson.GsonComponentSerializer.INSTANCE.serialize(header),
|
|
||||||
net.kyori.text.serializer.gson.GsonComponentSerializer.INSTANCE.serialize(footer));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HeaderAndFooter create(net.kyori.adventure.text.Component header,
|
public static HeaderAndFooter create(net.kyori.adventure.text.Component header,
|
||||||
net.kyori.adventure.text.Component footer, ProtocolVersion protocolVersion) {
|
net.kyori.adventure.text.Component footer, ProtocolVersion protocolVersion) {
|
||||||
GsonComponentSerializer serializer = ProtocolUtils.getJsonChatSerializer(protocolVersion);
|
GsonComponentSerializer serializer = ProtocolUtils.getJsonChatSerializer(protocolVersion);
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public class LegacyDisconnect {
|
|||||||
// MOTD.
|
// MOTD.
|
||||||
return new LegacyDisconnect(String.join(LEGACY_COLOR_CODE,
|
return new LegacyDisconnect(String.join(LEGACY_COLOR_CODE,
|
||||||
cleanSectionSymbol(getFirstLine(PlainComponentSerializer.plain().serialize(
|
cleanSectionSymbol(getFirstLine(PlainComponentSerializer.plain().serialize(
|
||||||
response.getDescriptionComponent()))),
|
response.getDescription()))),
|
||||||
Integer.toString(players.getOnline()),
|
Integer.toString(players.getOnline()),
|
||||||
Integer.toString(players.getMax())));
|
Integer.toString(players.getMax())));
|
||||||
case MINECRAFT_1_4:
|
case MINECRAFT_1_4:
|
||||||
@@ -49,7 +49,7 @@ public class LegacyDisconnect {
|
|||||||
Integer.toString(response.getVersion().getProtocol()),
|
Integer.toString(response.getVersion().getProtocol()),
|
||||||
response.getVersion().getName(),
|
response.getVersion().getName(),
|
||||||
getFirstLine(LegacyComponentSerializer.legacySection().serialize(response
|
getFirstLine(LegacyComponentSerializer.legacySection().serialize(response
|
||||||
.getDescriptionComponent())),
|
.getDescription())),
|
||||||
Integer.toString(players.getOnline()),
|
Integer.toString(players.getOnline()),
|
||||||
Integer.toString(players.getMax())
|
Integer.toString(players.getMax())
|
||||||
));
|
));
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ public class PlayerListItem implements MinecraftPacket {
|
|||||||
.setProperties(entry.getProfile().getProperties())
|
.setProperties(entry.getProfile().getProperties())
|
||||||
.setLatency(entry.getLatency())
|
.setLatency(entry.getLatency())
|
||||||
.setGameMode(entry.getGameMode())
|
.setGameMode(entry.getGameMode())
|
||||||
.setDisplayName(entry.getDisplayNameComponent().orElse(null));
|
.setDisplayName(entry.getDisplayName().orElse(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable UUID getUuid() {
|
public @Nullable UUID getUuid() {
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
|||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import net.kyori.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.text.serializer.gson.GsonComponentSerializer;
|
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public class TabCompleteResponse implements MinecraftPacket {
|
public class TabCompleteResponse implements MinecraftPacket {
|
||||||
@@ -68,8 +67,8 @@ public class TabCompleteResponse implements MinecraftPacket {
|
|||||||
int offersAvailable = ProtocolUtils.readVarInt(buf);
|
int offersAvailable = ProtocolUtils.readVarInt(buf);
|
||||||
for (int i = 0; i < offersAvailable; i++) {
|
for (int i = 0; i < offersAvailable; i++) {
|
||||||
String offer = ProtocolUtils.readString(buf);
|
String offer = ProtocolUtils.readString(buf);
|
||||||
Component tooltip = buf.readBoolean() ? GsonComponentSerializer.INSTANCE.deserialize(
|
Component tooltip = buf.readBoolean() ? ProtocolUtils.getJsonChatSerializer(version)
|
||||||
ProtocolUtils.readString(buf)) : null;
|
.deserialize(ProtocolUtils.readString(buf)) : null;
|
||||||
offers.add(new Offer(offer, tooltip));
|
offers.add(new Offer(offer, tooltip));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -91,7 +90,8 @@ public class TabCompleteResponse implements MinecraftPacket {
|
|||||||
ProtocolUtils.writeString(buf, offer.text);
|
ProtocolUtils.writeString(buf, offer.text);
|
||||||
buf.writeBoolean(offer.tooltip != null);
|
buf.writeBoolean(offer.tooltip != null);
|
||||||
if (offer.tooltip != null) {
|
if (offer.tooltip != null) {
|
||||||
ProtocolUtils.writeString(buf, GsonComponentSerializer.INSTANCE.serialize(offer.tooltip));
|
ProtocolUtils.writeString(buf, ProtocolUtils.getJsonChatSerializer(version)
|
||||||
|
.serialize(offer.tooltip));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import java.util.Map;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import net.kyori.text.Component;
|
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public class VelocityTabList implements TabList {
|
public class VelocityTabList implements TabList {
|
||||||
@@ -27,13 +26,6 @@ public class VelocityTabList implements TabList {
|
|||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setHeaderAndFooter(Component header, Component footer) {
|
|
||||||
Preconditions.checkNotNull(header, "header");
|
|
||||||
Preconditions.checkNotNull(footer, "footer");
|
|
||||||
connection.write(HeaderAndFooter.create(header, footer));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setHeaderAndFooter(net.kyori.adventure.text.Component header,
|
public void setHeaderAndFooter(net.kyori.adventure.text.Component header,
|
||||||
net.kyori.adventure.text.Component footer) {
|
net.kyori.adventure.text.Component footer) {
|
||||||
|
|||||||
@@ -5,8 +5,7 @@ import com.velocitypowered.api.proxy.player.TabListEntry;
|
|||||||
import com.velocitypowered.api.util.GameProfile;
|
import com.velocitypowered.api.util.GameProfile;
|
||||||
import com.velocitypowered.proxy.protocol.packet.PlayerListItem;
|
import com.velocitypowered.proxy.protocol.packet.PlayerListItem;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import net.kyori.adventure.text.serializer.legacytext3.LegacyText3ComponentSerializer;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.text.Component;
|
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public class VelocityTabListEntry implements TabListEntry {
|
public class VelocityTabListEntry implements TabListEntry {
|
||||||
@@ -38,22 +37,9 @@ public class VelocityTabListEntry implements TabListEntry {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<Component> getDisplayName() {
|
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);
|
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
|
@Override
|
||||||
public TabListEntry setDisplayName(net.kyori.adventure.text.@Nullable Component displayName) {
|
public TabListEntry setDisplayName(net.kyori.adventure.text.@Nullable Component displayName) {
|
||||||
this.displayName = displayName;
|
this.displayName = displayName;
|
||||||
|
|||||||
@@ -12,12 +12,6 @@ public class VelocityTabListEntryLegacy extends VelocityTabListEntry {
|
|||||||
super(tabList, profile, displayName, latency, gameMode);
|
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
|
@Override
|
||||||
public TabListEntry setDisplayName(@Nullable Component displayName) {
|
public TabListEntry setDisplayName(@Nullable Component displayName) {
|
||||||
getTabList().removeEntry(getProfile().getId()); // We have to remove first if updating
|
getTabList().removeEntry(getProfile().getId()); // We have to remove first if updating
|
||||||
|
|||||||
@@ -22,10 +22,6 @@ public class VelocityTabListLegacy extends VelocityTabList {
|
|||||||
super(connection);
|
super(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setHeaderAndFooter(net.kyori.text.Component header, net.kyori.text.Component footer) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setHeaderAndFooter(Component header, Component footer) {
|
public void setHeaderAndFooter(Component header, Component footer) {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,276 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,17 +2,11 @@ package com.velocitypowered.proxy.command;
|
|||||||
|
|
||||||
import com.velocitypowered.api.command.CommandSource;
|
import com.velocitypowered.api.command.CommandSource;
|
||||||
import com.velocitypowered.api.permission.Tristate;
|
import com.velocitypowered.api.permission.Tristate;
|
||||||
import net.kyori.text.Component;
|
|
||||||
|
|
||||||
public class MockCommandSource implements CommandSource {
|
public class MockCommandSource implements CommandSource {
|
||||||
|
|
||||||
public static final CommandSource INSTANCE = new MockCommandSource();
|
public static final CommandSource INSTANCE = new MockCommandSource();
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendMessage(final Component component) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Tristate getPermissionValue(final String permission) {
|
public Tristate getPermissionValue(final String permission) {
|
||||||
return Tristate.UNDEFINED;
|
return Tristate.UNDEFINED;
|
||||||
|
|||||||
Reference in New Issue
Block a user