Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-16 21:10:30 +01:00
Small code cleanups
Dieser Commit ist enthalten in:
Ursprung
5a26b4e03d
Commit
5d287306c2
@ -5,6 +5,6 @@ package com.velocitypowered.api.event;
|
|||||||
*/
|
*/
|
||||||
public enum PostOrder {
|
public enum PostOrder {
|
||||||
|
|
||||||
FIRST, EARLY, NORMAL, LATE, LAST;
|
FIRST, EARLY, NORMAL, LATE, LAST
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package com.velocitypowered.api.event.connection;
|
|||||||
|
|
||||||
import static com.velocitypowered.api.event.connection.DisconnectEvent.LoginStatus.CANCELLED_BY_PROXY;
|
import static com.velocitypowered.api.event.connection.DisconnectEvent.LoginStatus.CANCELLED_BY_PROXY;
|
||||||
import static com.velocitypowered.api.event.connection.DisconnectEvent.LoginStatus.CONFLICTING_LOGIN;
|
import static com.velocitypowered.api.event.connection.DisconnectEvent.LoginStatus.CONFLICTING_LOGIN;
|
||||||
import static com.velocitypowered.api.event.connection.DisconnectEvent.LoginStatus.PRE_SERVER_JOIN;
|
|
||||||
import static com.velocitypowered.api.event.connection.DisconnectEvent.LoginStatus.SUCCESSFUL_LOGIN;
|
import static com.velocitypowered.api.event.connection.DisconnectEvent.LoginStatus.SUCCESSFUL_LOGIN;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
|
@ -58,7 +58,7 @@ public interface ProxyServer extends Audience {
|
|||||||
* Broadcasts a message to all players currently online.
|
* Broadcasts a message to all players currently online.
|
||||||
*
|
*
|
||||||
* @param component the message to send
|
* @param component the message to send
|
||||||
* @deprecated Use {@link #sendMessage(Component)} instead
|
* @deprecated Use {@link #sendMessage(net.kyori.adventure.text.Component)} instead
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
void broadcast(net.kyori.text.Component component);
|
void broadcast(net.kyori.text.Component component);
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
package com.velocitypowered.api.util;
|
package com.velocitypowered.api.util;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,9 +42,7 @@ class FastUuidSansHyphens {
|
|||||||
private static final long[] HEX_VALUES = new long[128];
|
private static final long[] HEX_VALUES = new long[128];
|
||||||
|
|
||||||
static {
|
static {
|
||||||
for (int i = 0; i < HEX_VALUES.length; i++) {
|
Arrays.fill(HEX_VALUES, -1);
|
||||||
HEX_VALUES[i] = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
HEX_VALUES['0'] = 0x0;
|
HEX_VALUES['0'] = 0x0;
|
||||||
HEX_VALUES['1'] = 0x1;
|
HEX_VALUES['1'] = 0x1;
|
||||||
|
@ -13,5 +13,5 @@ public enum BossBarColor {
|
|||||||
GREEN,
|
GREEN,
|
||||||
YELLOW,
|
YELLOW,
|
||||||
PURPLE,
|
PURPLE,
|
||||||
WHITE;
|
WHITE
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,6 @@ package com.velocitypowered.natives.encryption;
|
|||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.velocitypowered.natives.util.BufferPreference;
|
import com.velocitypowered.natives.util.BufferPreference;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.ByteBufUtil;
|
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
|
||||||
import java.security.GeneralSecurityException;
|
import java.security.GeneralSecurityException;
|
||||||
import javax.crypto.Cipher;
|
import javax.crypto.Cipher;
|
||||||
import javax.crypto.SecretKey;
|
import javax.crypto.SecretKey;
|
||||||
|
@ -3,8 +3,6 @@ package com.velocitypowered.natives.encryption;
|
|||||||
import com.velocitypowered.natives.Disposable;
|
import com.velocitypowered.natives.Disposable;
|
||||||
import com.velocitypowered.natives.Native;
|
import com.velocitypowered.natives.Native;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
|
||||||
import javax.crypto.ShortBufferException;
|
|
||||||
|
|
||||||
public interface VelocityCipher extends Disposable, Native {
|
public interface VelocityCipher extends Disposable, Native {
|
||||||
void process(ByteBuf source);
|
void process(ByteBuf source);
|
||||||
|
@ -27,19 +27,14 @@ public class NativeConstraints {
|
|||||||
|
|
||||||
static final BooleanSupplier NATIVE_BASE = () -> NATIVES_ENABLED && CAN_GET_MEMORYADDRESS;
|
static final BooleanSupplier NATIVE_BASE = () -> NATIVES_ENABLED && CAN_GET_MEMORYADDRESS;
|
||||||
|
|
||||||
static final BooleanSupplier LINUX_X86_64 = () -> {
|
static final BooleanSupplier LINUX_X86_64 = () -> NATIVE_BASE.getAsBoolean()
|
||||||
return NATIVE_BASE.getAsBoolean()
|
&& System.getProperty("os.name", "").equalsIgnoreCase("Linux")
|
||||||
&& System.getProperty("os.name", "").equalsIgnoreCase("Linux")
|
&& IS_AMD64;
|
||||||
&& IS_AMD64;
|
|
||||||
};
|
|
||||||
|
|
||||||
static final BooleanSupplier LINUX_AARCH64 = () -> {
|
static final BooleanSupplier LINUX_AARCH64 = () -> NATIVE_BASE.getAsBoolean()
|
||||||
return NATIVE_BASE.getAsBoolean()
|
&& System.getProperty("os.name", "").equalsIgnoreCase("Linux")
|
||||||
&& System.getProperty("os.name", "").equalsIgnoreCase("Linux")
|
&& IS_AARCH64;
|
||||||
&& IS_AARCH64;
|
|
||||||
};
|
|
||||||
|
|
||||||
static final BooleanSupplier JAVA_11 = () -> {
|
static final BooleanSupplier JAVA_11 = () -> Double.parseDouble(
|
||||||
return Double.parseDouble(System.getProperty("java.specification.version")) >= 11;
|
System.getProperty("java.specification.version")) >= 11;
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ import org.junit.jupiter.api.condition.JRE;
|
|||||||
|
|
||||||
class VelocityCompressorTest {
|
class VelocityCompressorTest {
|
||||||
|
|
||||||
private static byte[] TEST_DATA = new byte[1 << 14];
|
private static final byte[] TEST_DATA = new byte[1 << 14];
|
||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
static void checkNatives() throws IOException {
|
static void checkNatives() throws IOException {
|
||||||
|
@ -225,8 +225,6 @@ public class Metrics {
|
|||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
VelocityServer.GENERAL_GSON.toJson(object, writer);
|
VelocityServer.GENERAL_GSON.toJson(object, writer);
|
||||||
} catch (IOException e) {
|
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
return os.toByteArray();
|
return os.toByteArray();
|
||||||
}
|
}
|
||||||
|
@ -22,11 +22,10 @@ import java.nio.file.Files;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.nio.file.StandardCopyOption;
|
import java.nio.file.StandardCopyOption;
|
||||||
import java.util.Arrays;
|
import java.security.SecureRandom;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -73,13 +72,15 @@ public class VelocityConfiguration implements ProxyConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private VelocityConfiguration(String bind, String motd, int showMaxPlayers, boolean onlineMode,
|
private VelocityConfiguration(String bind, String motd, int showMaxPlayers, boolean onlineMode,
|
||||||
boolean announceForge, PlayerInfoForwarding playerInfoForwardingMode, byte[] forwardingSecret,
|
boolean preventClientProxyConnections, boolean announceForge,
|
||||||
|
PlayerInfoForwarding playerInfoForwardingMode, byte[] forwardingSecret,
|
||||||
boolean onlineModeKickExistingPlayers, PingPassthroughMode pingPassthrough, Servers servers,
|
boolean onlineModeKickExistingPlayers, PingPassthroughMode pingPassthrough, Servers servers,
|
||||||
ForcedHosts forcedHosts, Advanced advanced, Query query, Metrics metrics, Messages messages) {
|
ForcedHosts forcedHosts, Advanced advanced, Query query, Metrics metrics, Messages messages) {
|
||||||
this.bind = bind;
|
this.bind = bind;
|
||||||
this.motd = motd;
|
this.motd = motd;
|
||||||
this.showMaxPlayers = showMaxPlayers;
|
this.showMaxPlayers = showMaxPlayers;
|
||||||
this.onlineMode = onlineMode;
|
this.onlineMode = onlineMode;
|
||||||
|
this.preventClientProxyConnections = preventClientProxyConnections;
|
||||||
this.announceForge = announceForge;
|
this.announceForge = announceForge;
|
||||||
this.playerInfoForwardingMode = playerInfoForwardingMode;
|
this.playerInfoForwardingMode = playerInfoForwardingMode;
|
||||||
this.forwardingSecret = forwardingSecret;
|
this.forwardingSecret = forwardingSecret;
|
||||||
@ -460,6 +461,8 @@ public class VelocityConfiguration implements ProxyConfig {
|
|||||||
int maxPlayers = config.getIntOrElse("show-max-players", 500);
|
int maxPlayers = config.getIntOrElse("show-max-players", 500);
|
||||||
Boolean onlineMode = config.getOrElse("online-mode", true);
|
Boolean onlineMode = config.getOrElse("online-mode", true);
|
||||||
Boolean announceForge = config.getOrElse("announce-forge", true);
|
Boolean announceForge = config.getOrElse("announce-forge", true);
|
||||||
|
Boolean preventClientProxyConnections = config.getOrElse("prevent-client-proxy-connections",
|
||||||
|
true);
|
||||||
Boolean kickExisting = config.getOrElse("kick-existing-players", false);
|
Boolean kickExisting = config.getOrElse("kick-existing-players", false);
|
||||||
|
|
||||||
return new VelocityConfiguration(
|
return new VelocityConfiguration(
|
||||||
@ -468,6 +471,7 @@ public class VelocityConfiguration implements ProxyConfig {
|
|||||||
maxPlayers,
|
maxPlayers,
|
||||||
onlineMode,
|
onlineMode,
|
||||||
announceForge,
|
announceForge,
|
||||||
|
preventClientProxyConnections,
|
||||||
forwardingMode,
|
forwardingMode,
|
||||||
forwardingSecret,
|
forwardingSecret,
|
||||||
kickExisting,
|
kickExisting,
|
||||||
@ -484,7 +488,7 @@ public class VelocityConfiguration implements ProxyConfig {
|
|||||||
private static String generateRandomString(int length) {
|
private static String generateRandomString(int length) {
|
||||||
String chars = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1234567890";
|
String chars = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1234567890";
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
Random rnd = new Random();
|
Random rnd = new SecureRandom();
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
builder.append(chars.charAt(rnd.nextInt(chars.length())));
|
builder.append(chars.charAt(rnd.nextInt(chars.length())));
|
||||||
}
|
}
|
||||||
@ -502,7 +506,7 @@ public class VelocityConfiguration implements ProxyConfig {
|
|||||||
"factions", "127.0.0.1:30067",
|
"factions", "127.0.0.1:30067",
|
||||||
"minigames", "127.0.0.1:30068"
|
"minigames", "127.0.0.1:30068"
|
||||||
);
|
);
|
||||||
private List<String> attemptConnectionOrder = Arrays.asList("lobby");
|
private List<String> attemptConnectionOrder = ImmutableList.of("lobby");
|
||||||
|
|
||||||
private Servers() {
|
private Servers() {
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,6 @@ import com.velocitypowered.proxy.protocol.netty.MinecraftCompressDecoder;
|
|||||||
import com.velocitypowered.proxy.protocol.netty.MinecraftCompressEncoder;
|
import com.velocitypowered.proxy.protocol.netty.MinecraftCompressEncoder;
|
||||||
import com.velocitypowered.proxy.protocol.netty.MinecraftDecoder;
|
import com.velocitypowered.proxy.protocol.netty.MinecraftDecoder;
|
||||||
import com.velocitypowered.proxy.protocol.netty.MinecraftEncoder;
|
import com.velocitypowered.proxy.protocol.netty.MinecraftEncoder;
|
||||||
import com.velocitypowered.proxy.protocol.packet.Handshake;
|
|
||||||
import com.velocitypowered.proxy.util.except.QuietDecoderException;
|
import com.velocitypowered.proxy.util.except.QuietDecoderException;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
|
@ -173,6 +173,7 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
RootCommandNode<CommandSource> dispatcherRootNode =
|
RootCommandNode<CommandSource> dispatcherRootNode =
|
||||||
(RootCommandNode<CommandSource>)
|
(RootCommandNode<CommandSource>)
|
||||||
filterNode(server.getCommandManager().getDispatcher().getRoot());
|
filterNode(server.getCommandManager().getDispatcher().getRoot());
|
||||||
|
assert dispatcherRootNode != null : "Filtering root node returned null.";
|
||||||
Collection<CommandNode<CommandSource>> proxyNodes = dispatcherRootNode.getChildren();
|
Collection<CommandNode<CommandSource>> proxyNodes = dispatcherRootNode.getChildren();
|
||||||
for (CommandNode<CommandSource> node : proxyNodes) {
|
for (CommandNode<CommandSource> node : proxyNodes) {
|
||||||
CommandNode<CommandSource> existingServerChild = rootNode.getChild(node.getName());
|
CommandNode<CommandSource> existingServerChild = rootNode.getChild(node.getName());
|
||||||
|
@ -19,7 +19,6 @@ import io.netty.buffer.Unpooled;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.StringJoiner;
|
import java.util.StringJoiner;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
|
||||||
import net.kyori.adventure.text.serializer.ComponentSerializer;
|
import net.kyori.adventure.text.serializer.ComponentSerializer;
|
||||||
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;
|
||||||
@ -158,9 +157,7 @@ class BungeeCordMessageResponder {
|
|||||||
if (target.equals("ALL")) {
|
if (target.equals("ALL")) {
|
||||||
proxy.sendMessage(messageComponent);
|
proxy.sendMessage(messageComponent);
|
||||||
} else {
|
} else {
|
||||||
proxy.getPlayer(target).ifPresent(player -> {
|
proxy.getPlayer(target).ifPresent(player -> player.sendMessage(messageComponent));
|
||||||
player.sendMessage(messageComponent);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ public class TransitionSessionHandler implements MinecraftSessionHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Strap on the ClientPlaySessionHandler if required.
|
// Change the client to use the ClientPlaySessionHandler if required.
|
||||||
ClientPlaySessionHandler playHandler;
|
ClientPlaySessionHandler playHandler;
|
||||||
if (serverConn.getPlayer().getConnection().getSessionHandler()
|
if (serverConn.getPlayer().getConnection().getSessionHandler()
|
||||||
instanceof ClientPlaySessionHandler) {
|
instanceof ClientPlaySessionHandler) {
|
||||||
|
@ -14,7 +14,6 @@ import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
|||||||
import com.velocitypowered.proxy.connection.forge.legacy.LegacyForgeConstants;
|
import com.velocitypowered.proxy.connection.forge.legacy.LegacyForgeConstants;
|
||||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||||
import com.velocitypowered.proxy.protocol.StateRegistry;
|
import com.velocitypowered.proxy.protocol.StateRegistry;
|
||||||
import com.velocitypowered.proxy.protocol.packet.Disconnect;
|
|
||||||
import com.velocitypowered.proxy.protocol.packet.Handshake;
|
import com.velocitypowered.proxy.protocol.packet.Handshake;
|
||||||
import com.velocitypowered.proxy.protocol.packet.LegacyDisconnect;
|
import com.velocitypowered.proxy.protocol.packet.LegacyDisconnect;
|
||||||
import com.velocitypowered.proxy.protocol.packet.LegacyHandshake;
|
import com.velocitypowered.proxy.protocol.packet.LegacyHandshake;
|
||||||
@ -23,7 +22,6 @@ import io.netty.buffer.ByteBuf;
|
|||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import net.kyori.adventure.text.TranslatableComponent;
|
import net.kyori.adventure.text.TranslatableComponent;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
@ -42,7 +42,6 @@ import java.util.UUID;
|
|||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
@ -161,10 +161,9 @@ public class StatusSessionHandler implements MinecraftSessionHandler {
|
|||||||
this.pingReceived = true;
|
this.pingReceived = true;
|
||||||
getInitialPing()
|
getInitialPing()
|
||||||
.thenCompose(ping -> server.getEventManager().fire(new ProxyPingEvent(inbound, ping)))
|
.thenCompose(ping -> server.getEventManager().fire(new ProxyPingEvent(inbound, ping)))
|
||||||
.thenAcceptAsync(event -> {
|
.thenAcceptAsync(event -> connection.closeWith(
|
||||||
connection.closeWith(LegacyDisconnect.fromServerPing(event.getPing(),
|
LegacyDisconnect.fromServerPing(event.getPing(), packet.getVersion())),
|
||||||
packet.getVersion()));
|
connection.eventLoop());
|
||||||
}, connection.eventLoop());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ import com.velocitypowered.proxy.plugin.loader.VelocityPluginDescription;
|
|||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
@ -276,8 +276,8 @@ public enum ProtocolUtils {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
writeVarInt(buf, stringArray.length);
|
writeVarInt(buf, stringArray.length);
|
||||||
for (int i = 0; i < stringArray.length; i++) {
|
for (String s : stringArray) {
|
||||||
writeString(buf, stringArray[i]);
|
writeString(buf, s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ package com.velocitypowered.proxy.protocol.netty;
|
|||||||
|
|
||||||
import io.netty.channel.ChannelDuplexHandler;
|
import io.netty.channel.ChannelDuplexHandler;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.channel.ChannelInboundHandler;
|
|
||||||
import io.netty.util.ReferenceCountUtil;
|
import io.netty.util.ReferenceCountUtil;
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
|
@ -15,8 +15,8 @@ public class HeaderAndFooter implements MinecraftPacket {
|
|||||||
private static final String EMPTY_COMPONENT = "{\"translate\":\"\"}";
|
private static final String EMPTY_COMPONENT = "{\"translate\":\"\"}";
|
||||||
private static final HeaderAndFooter RESET = new HeaderAndFooter();
|
private static final HeaderAndFooter RESET = new HeaderAndFooter();
|
||||||
|
|
||||||
private String header;
|
private final String header;
|
||||||
private String footer;
|
private final String footer;
|
||||||
|
|
||||||
public HeaderAndFooter() {
|
public HeaderAndFooter() {
|
||||||
this(EMPTY_COMPONENT, EMPTY_COMPONENT);
|
this(EMPTY_COMPONENT, EMPTY_COMPONENT);
|
||||||
|
@ -246,8 +246,7 @@ public class JoinGame implements MinecraftPacket {
|
|||||||
}
|
}
|
||||||
if (version.compareTo(ProtocolVersion.MINECRAFT_1_16) >= 0) {
|
if (version.compareTo(ProtocolVersion.MINECRAFT_1_16) >= 0) {
|
||||||
buf.writeByte(previousGamemode);
|
buf.writeByte(previousGamemode);
|
||||||
ProtocolUtils.writeStringArray(buf, dimensionRegistry.getLevelNames().toArray(
|
ProtocolUtils.writeStringArray(buf, dimensionRegistry.getLevelNames().toArray(new String[0]));
|
||||||
new String[dimensionRegistry.getLevelNames().size()]));
|
|
||||||
CompoundBinaryTag.Builder registryContainer = CompoundBinaryTag.builder();
|
CompoundBinaryTag.Builder registryContainer = CompoundBinaryTag.builder();
|
||||||
ListBinaryTag encodedDimensionRegistry = dimensionRegistry.encodeRegistry(version);
|
ListBinaryTag encodedDimensionRegistry = dimensionRegistry.encodeRegistry(version);
|
||||||
if (version.compareTo(ProtocolVersion.MINECRAFT_1_16_2) >= 0) {
|
if (version.compareTo(ProtocolVersion.MINECRAFT_1_16_2) >= 0) {
|
||||||
|
@ -4,7 +4,6 @@ import com.google.common.collect.ImmutableList;
|
|||||||
import com.velocitypowered.api.network.ProtocolVersion;
|
import com.velocitypowered.api.network.ProtocolVersion;
|
||||||
import com.velocitypowered.api.proxy.player.TabListEntry;
|
import com.velocitypowered.api.proxy.player.TabListEntry;
|
||||||
import com.velocitypowered.api.util.GameProfile;
|
import com.velocitypowered.api.util.GameProfile;
|
||||||
import com.velocitypowered.proxy.VelocityServer;
|
|
||||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
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;
|
||||||
@ -13,7 +12,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
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.legacy.LegacyComponentSerializer;
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import io.netty.buffer.ByteBuf;
|
|||||||
|
|
||||||
class FloatArgumentPropertySerializer implements ArgumentPropertySerializer<FloatArgumentType> {
|
class FloatArgumentPropertySerializer implements ArgumentPropertySerializer<FloatArgumentType> {
|
||||||
|
|
||||||
static FloatArgumentPropertySerializer FLOAT = new FloatArgumentPropertySerializer();
|
static final FloatArgumentPropertySerializer FLOAT = new FloatArgumentPropertySerializer();
|
||||||
|
|
||||||
private FloatArgumentPropertySerializer() {
|
private FloatArgumentPropertySerializer() {
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ package com.velocitypowered.proxy.protocol.util;
|
|||||||
|
|
||||||
import com.google.common.io.ByteArrayDataInput;
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import java.io.DataInput;
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ package com.velocitypowered.proxy.protocol.util;
|
|||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.velocitypowered.api.network.ProtocolVersion;
|
import com.velocitypowered.api.network.ProtocolVersion;
|
||||||
import com.velocitypowered.api.util.ProxyVersion;
|
import com.velocitypowered.api.util.ProxyVersion;
|
||||||
|
@ -27,7 +27,6 @@ import com.velocitypowered.proxy.protocol.netty.MinecraftVarintLengthEncoder;
|
|||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import io.netty.channel.ChannelFuture;
|
|
||||||
import io.netty.channel.ChannelFutureListener;
|
import io.netty.channel.ChannelFutureListener;
|
||||||
import io.netty.channel.ChannelInitializer;
|
import io.netty.channel.ChannelInitializer;
|
||||||
import io.netty.channel.EventLoop;
|
import io.netty.channel.EventLoop;
|
||||||
@ -39,7 +38,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
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 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;
|
||||||
|
|
||||||
@ -100,16 +98,13 @@ public class VelocityRegisteredServer implements RegisteredServer, ForwardingAud
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.connect(serverInfo.getAddress())
|
.connect(serverInfo.getAddress())
|
||||||
.addListener(new ChannelFutureListener() {
|
.addListener((ChannelFutureListener) future -> {
|
||||||
@Override
|
if (future.isSuccess()) {
|
||||||
public void operationComplete(ChannelFuture future) throws Exception {
|
MinecraftConnection conn = future.channel().pipeline().get(MinecraftConnection.class);
|
||||||
if (future.isSuccess()) {
|
conn.setSessionHandler(new PingSessionHandler(
|
||||||
MinecraftConnection conn = future.channel().pipeline().get(MinecraftConnection.class);
|
pingFuture, VelocityRegisteredServer.this, conn, version));
|
||||||
conn.setSessionHandler(new PingSessionHandler(
|
} else {
|
||||||
pingFuture, VelocityRegisteredServer.this, conn, version));
|
pingFuture.completeExceptionally(future.cause());
|
||||||
} else {
|
|
||||||
pingFuture.completeExceptionally(future.cause());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return pingFuture;
|
return pingFuture;
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
package com.velocitypowered.proxy.tablist;
|
package com.velocitypowered.proxy.tablist;
|
||||||
|
|
||||||
import static com.google.common.base.Verify.verify;
|
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.base.Verify;
|
|
||||||
import com.velocitypowered.api.proxy.player.TabList;
|
import com.velocitypowered.api.proxy.player.TabList;
|
||||||
import com.velocitypowered.api.proxy.player.TabListEntry;
|
import com.velocitypowered.api.proxy.player.TabListEntry;
|
||||||
import com.velocitypowered.api.util.GameProfile;
|
import com.velocitypowered.api.util.GameProfile;
|
||||||
|
@ -127,25 +127,6 @@ public final class BrigadierUtils {
|
|||||||
return command.toLowerCase(Locale.ENGLISH);
|
return command.toLowerCase(Locale.ENGLISH);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Prepares the given command node prior for hinting metadata to
|
|
||||||
* a {@link com.velocitypowered.api.command.Command}.
|
|
||||||
*
|
|
||||||
* @param node the command node to be wrapped
|
|
||||||
* @param command the command to execute
|
|
||||||
* @return the wrapped command node
|
|
||||||
*/
|
|
||||||
public static CommandNode<CommandSource> wrapForHinting(
|
|
||||||
final CommandNode<CommandSource> node, final @Nullable Command<CommandSource> command) {
|
|
||||||
Preconditions.checkNotNull(node, "node");
|
|
||||||
ArgumentBuilder<CommandSource, ?> builder = node.createBuilder();
|
|
||||||
builder.executes(command);
|
|
||||||
for (CommandNode<CommandSource> child : node.getChildren()) {
|
|
||||||
builder.then(wrapForHinting(child, command));
|
|
||||||
}
|
|
||||||
return builder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
private BrigadierUtils() {
|
private BrigadierUtils() {
|
||||||
throw new AssertionError();
|
throw new AssertionError();
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ import com.velocitypowered.api.plugin.PluginDescription;
|
|||||||
import com.velocitypowered.api.plugin.meta.PluginDependency;
|
import com.velocitypowered.api.plugin.meta.PluginDependency;
|
||||||
import com.velocitypowered.proxy.plugin.loader.VelocityPluginDescription;
|
import com.velocitypowered.proxy.plugin.loader.VelocityPluginDescription;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren