mirror of
https://github.com/PaperMC/Velocity.git
synced 2026-02-17 14:37:43 +01:00
Merge branch 'dev/1.1.0' into experiment/io_uring
This commit is contained in:
@@ -93,9 +93,18 @@ javadoc {
|
||||
|
||||
// Disable the crazy super-strict doclint tool in Java 8
|
||||
options.addStringOption('Xdoclint:none', '-quiet')
|
||||
|
||||
|
||||
// Mark sources as Java 8 source compatible
|
||||
options.source = '8'
|
||||
|
||||
// Remove 'undefined' from seach paths when generating javadoc for a non-modular project (JDK-8215291)
|
||||
if (JavaVersion.current() >= JavaVersion.VERSION_1_9 && JavaVersion.current() < JavaVersion.VERSION_12) {
|
||||
options.addBooleanOption('-no-module-directories', true)
|
||||
}
|
||||
}
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
publishing {
|
||||
|
||||
@@ -26,7 +26,7 @@ allprojects {
|
||||
junitVersion = '5.7.0'
|
||||
slf4jVersion = '1.7.30'
|
||||
log4jVersion = '2.13.3'
|
||||
nettyVersion = '4.1.55.Final'
|
||||
nettyVersion = '4.1.56.Final'
|
||||
guavaVersion = '25.1-jre'
|
||||
checkerFrameworkVersion = '3.6.1'
|
||||
configurateVersion = '3.7.1'
|
||||
|
||||
@@ -21,6 +21,10 @@ dependencies {
|
||||
testImplementation "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
|
||||
}
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
|
||||
@@ -82,6 +82,10 @@ dependencies {
|
||||
testImplementation "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
|
||||
}
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
exclude 'it/unimi/dsi/fastutil/booleans/**'
|
||||
exclude 'it/unimi/dsi/fastutil/bytes/**'
|
||||
|
||||
@@ -18,6 +18,7 @@ import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
@@ -33,6 +34,8 @@ import org.asynchttpclient.Response;
|
||||
*/
|
||||
public class Metrics {
|
||||
|
||||
private static final int ONE_MINUTE_MS = 60_000;
|
||||
|
||||
// The version of this bStats class
|
||||
private static final int B_STATS_METRICS_REVISION = 2;
|
||||
|
||||
@@ -96,12 +99,14 @@ public class Metrics {
|
||||
*/
|
||||
private void startSubmitting() {
|
||||
final Timer timer = new Timer(true);
|
||||
long initialDelay = ONE_MINUTE_MS * 3 + (((long) (ThreadLocalRandom.current().nextDouble() * 2
|
||||
* ONE_MINUTE_MS)));
|
||||
timer.scheduleAtFixedRate(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
submitData();
|
||||
}
|
||||
}, 1000, 1000 * 60 * 30);
|
||||
}, initialDelay, 1000 * 60 * 30);
|
||||
// Submit the data every 30 minutes, first time after 5 minutes to give other plugins enough
|
||||
// time to start.
|
||||
//
|
||||
|
||||
@@ -102,11 +102,8 @@ public class VelocityCommandManager implements CommandManager {
|
||||
}
|
||||
|
||||
if (!(command instanceof BrigadierCommand)) {
|
||||
if (!meta.getHints().isEmpty()) {
|
||||
// If the user specified a hint, then add the hints to the command node directly.
|
||||
for (CommandNode<CommandSource> hint : meta.getHints()) {
|
||||
node.addChild(hint);
|
||||
}
|
||||
for (CommandNode<CommandSource> hint : meta.getHints()) {
|
||||
node.addChild(BrigadierUtils.wrapForHinting(hint, node.getCommand()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -569,7 +569,8 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
logger.error("{}: kicked from server {}: {}", this, server.getServerInfo().getName(),
|
||||
plainTextReason);
|
||||
handleConnectionException(server, disconnectReason, Component.text()
|
||||
.append(messages.getKickPrefix(server.getServerInfo().getName()))
|
||||
.append(messages.getKickPrefix(server.getServerInfo().getName())
|
||||
.colorIfAbsent(NamedTextColor.RED))
|
||||
.color(NamedTextColor.RED)
|
||||
.append(disconnectReason)
|
||||
.build(), safe);
|
||||
@@ -577,8 +578,8 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
logger.error("{}: disconnected while connecting to {}: {}", this,
|
||||
server.getServerInfo().getName(), plainTextReason);
|
||||
handleConnectionException(server, disconnectReason, Component.text()
|
||||
.append(messages.getDisconnectPrefix(server.getServerInfo().getName()))
|
||||
.color(NamedTextColor.RED)
|
||||
.append(messages.getDisconnectPrefix(server.getServerInfo().getName())
|
||||
.colorIfAbsent(NamedTextColor.RED))
|
||||
.append(disconnectReason)
|
||||
.build(), safe);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class LoginPluginMessage extends DeferredByteBufHolder implements Minecra
|
||||
this.id = ProtocolUtils.readVarInt(buf);
|
||||
this.channel = ProtocolUtils.readString(buf);
|
||||
if (buf.isReadable()) {
|
||||
this.replace(buf.readSlice(buf.readableBytes()));
|
||||
this.replace(buf.readRetainedSlice(buf.readableBytes()));
|
||||
} else {
|
||||
this.replace(Unpooled.EMPTY_BUFFER);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.velocitypowered.proxy.util;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.builder.ArgumentBuilder;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
@@ -11,6 +13,7 @@ import com.mojang.brigadier.tree.CommandNode;
|
||||
import com.mojang.brigadier.tree.LiteralCommandNode;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import java.util.Locale;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
* Provides utilities for working with Brigadier commands.
|
||||
@@ -124,6 +127,25 @@ public final class BrigadierUtils {
|
||||
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() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@@ -122,20 +122,6 @@ public class CommandManagerTests {
|
||||
assertTrue(manager.hasCommand("foO"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAlreadyRegisteredThrows() {
|
||||
VelocityCommandManager manager = createManager();
|
||||
manager.register("bar", new NoopDeprecatedCommand());
|
||||
assertThrows(IllegalArgumentException.class, () ->
|
||||
manager.register("BAR", new NoopSimpleCommand()));
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
CommandMeta meta = manager.metaBuilder("baz")
|
||||
.aliases("BAr")
|
||||
.build();
|
||||
manager.register(meta, new NoopRawCommand());
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBrigadierExecute() {
|
||||
VelocityCommandManager manager = createManager();
|
||||
@@ -181,9 +167,9 @@ public class CommandManagerTests {
|
||||
assertTrue(manager.executeImmediatelyAsync(MockCommandSource.INSTANCE, "buy 14").join());
|
||||
assertTrue(checkedRequires.compareAndSet(true, false));
|
||||
assertTrue(executed.get());
|
||||
assertFalse(manager.execute(MockCommandSource.INSTANCE, "buy 9"),
|
||||
assertTrue(manager.execute(MockCommandSource.INSTANCE, "buy 9"),
|
||||
"Invalid arg returns false");
|
||||
assertFalse(manager.executeImmediately(MockCommandSource.INSTANCE, "buy 12 bananas"));
|
||||
assertTrue(manager.executeImmediately(MockCommandSource.INSTANCE, "buy 12 bananas"));
|
||||
assertTrue(checkedRequires.get());
|
||||
}
|
||||
|
||||
@@ -392,7 +378,7 @@ public class CommandManagerTests {
|
||||
.join().isEmpty());
|
||||
assertEquals(
|
||||
ImmutableList.of("123"),
|
||||
manager.offerSuggestions(MockCommandSource.INSTANCE, "simPle foo ").join());
|
||||
manager.offerSuggestions(MockCommandSource.INSTANCE, "simPle foo").join());
|
||||
assertEquals(
|
||||
ImmutableList.of("baz", "foo"),
|
||||
manager.offerSuggestions(MockCommandSource.INSTANCE, "raw ").join());
|
||||
@@ -411,7 +397,7 @@ public class CommandManagerTests {
|
||||
.join().isEmpty());
|
||||
assertEquals(
|
||||
ImmutableList.of("123", "456"),
|
||||
manager.offerSuggestions(MockCommandSource.INSTANCE, "deprEcated foo ").join());
|
||||
manager.offerSuggestions(MockCommandSource.INSTANCE, "deprEcated foo").join());
|
||||
assertTrue(manager.offerSuggestions(MockCommandSource.INSTANCE, "deprecated foo 789 ")
|
||||
.join().isEmpty());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user