Merge branch 'dev/1.1.0' into experiment/io_uring

This commit is contained in:
Andrew Steinborn
2020-12-24 16:52:18 -05:00
10 changed files with 58 additions and 30 deletions

View File

@@ -93,9 +93,18 @@ javadoc {
// Disable the crazy super-strict doclint tool in Java 8 // Disable the crazy super-strict doclint tool in Java 8
options.addStringOption('Xdoclint:none', '-quiet') options.addStringOption('Xdoclint:none', '-quiet')
// Mark sources as Java 8 source compatible // Mark sources as Java 8 source compatible
options.source = '8' 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 { publishing {

View File

@@ -26,7 +26,7 @@ allprojects {
junitVersion = '5.7.0' junitVersion = '5.7.0'
slf4jVersion = '1.7.30' slf4jVersion = '1.7.30'
log4jVersion = '2.13.3' log4jVersion = '2.13.3'
nettyVersion = '4.1.55.Final' nettyVersion = '4.1.56.Final'
guavaVersion = '25.1-jre' guavaVersion = '25.1-jre'
checkerFrameworkVersion = '3.6.1' checkerFrameworkVersion = '3.6.1'
configurateVersion = '3.7.1' configurateVersion = '3.7.1'

View File

@@ -21,6 +21,10 @@ dependencies {
testImplementation "org.junit.jupiter:junit-jupiter-engine:${junitVersion}" testImplementation "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
} }
test {
useJUnitPlatform()
}
publishing { publishing {
publications { publications {
mavenJava(MavenPublication) { mavenJava(MavenPublication) {

View File

@@ -82,6 +82,10 @@ dependencies {
testImplementation "org.junit.jupiter:junit-jupiter-engine:${junitVersion}" testImplementation "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
} }
test {
useJUnitPlatform()
}
shadowJar { shadowJar {
exclude 'it/unimi/dsi/fastutil/booleans/**' exclude 'it/unimi/dsi/fastutil/booleans/**'
exclude 'it/unimi/dsi/fastutil/bytes/**' exclude 'it/unimi/dsi/fastutil/bytes/**'

View File

@@ -18,6 +18,7 @@ import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.ThreadLocalRandom;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.zip.GZIPOutputStream; import java.util.zip.GZIPOutputStream;
@@ -33,6 +34,8 @@ import org.asynchttpclient.Response;
*/ */
public class Metrics { public class Metrics {
private static final int ONE_MINUTE_MS = 60_000;
// The version of this bStats class // The version of this bStats class
private static final int B_STATS_METRICS_REVISION = 2; private static final int B_STATS_METRICS_REVISION = 2;
@@ -96,12 +99,14 @@ public class Metrics {
*/ */
private void startSubmitting() { private void startSubmitting() {
final Timer timer = new Timer(true); final Timer timer = new Timer(true);
long initialDelay = ONE_MINUTE_MS * 3 + (((long) (ThreadLocalRandom.current().nextDouble() * 2
* ONE_MINUTE_MS)));
timer.scheduleAtFixedRate(new TimerTask() { timer.scheduleAtFixedRate(new TimerTask() {
@Override @Override
public void run() { public void run() {
submitData(); 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 // Submit the data every 30 minutes, first time after 5 minutes to give other plugins enough
// time to start. // time to start.
// //

View File

@@ -102,11 +102,8 @@ public class VelocityCommandManager implements CommandManager {
} }
if (!(command instanceof BrigadierCommand)) { if (!(command instanceof BrigadierCommand)) {
if (!meta.getHints().isEmpty()) { for (CommandNode<CommandSource> hint : meta.getHints()) {
// If the user specified a hint, then add the hints to the command node directly. node.addChild(BrigadierUtils.wrapForHinting(hint, node.getCommand()));
for (CommandNode<CommandSource> hint : meta.getHints()) {
node.addChild(hint);
}
} }
} }

View File

@@ -569,7 +569,8 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
logger.error("{}: kicked from server {}: {}", this, server.getServerInfo().getName(), logger.error("{}: kicked from server {}: {}", this, server.getServerInfo().getName(),
plainTextReason); plainTextReason);
handleConnectionException(server, disconnectReason, Component.text() handleConnectionException(server, disconnectReason, Component.text()
.append(messages.getKickPrefix(server.getServerInfo().getName())) .append(messages.getKickPrefix(server.getServerInfo().getName())
.colorIfAbsent(NamedTextColor.RED))
.color(NamedTextColor.RED) .color(NamedTextColor.RED)
.append(disconnectReason) .append(disconnectReason)
.build(), safe); .build(), safe);
@@ -577,8 +578,8 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
logger.error("{}: disconnected while connecting to {}: {}", this, logger.error("{}: disconnected while connecting to {}: {}", this,
server.getServerInfo().getName(), plainTextReason); server.getServerInfo().getName(), plainTextReason);
handleConnectionException(server, disconnectReason, Component.text() handleConnectionException(server, disconnectReason, Component.text()
.append(messages.getDisconnectPrefix(server.getServerInfo().getName())) .append(messages.getDisconnectPrefix(server.getServerInfo().getName())
.color(NamedTextColor.RED) .colorIfAbsent(NamedTextColor.RED))
.append(disconnectReason) .append(disconnectReason)
.build(), safe); .build(), safe);
} }

View File

@@ -49,7 +49,7 @@ public class LoginPluginMessage extends DeferredByteBufHolder implements Minecra
this.id = ProtocolUtils.readVarInt(buf); this.id = ProtocolUtils.readVarInt(buf);
this.channel = ProtocolUtils.readString(buf); this.channel = ProtocolUtils.readString(buf);
if (buf.isReadable()) { if (buf.isReadable()) {
this.replace(buf.readSlice(buf.readableBytes())); this.replace(buf.readRetainedSlice(buf.readableBytes()));
} else { } else {
this.replace(Unpooled.EMPTY_BUFFER); this.replace(Unpooled.EMPTY_BUFFER);
} }

View File

@@ -1,8 +1,10 @@
package com.velocitypowered.proxy.util; package com.velocitypowered.proxy.util;
import com.google.common.base.Preconditions;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import com.mojang.brigadier.Command; import com.mojang.brigadier.Command;
import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.ArgumentBuilder;
import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.builder.RequiredArgumentBuilder; import com.mojang.brigadier.builder.RequiredArgumentBuilder;
import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.context.CommandContext;
@@ -11,6 +13,7 @@ import com.mojang.brigadier.tree.CommandNode;
import com.mojang.brigadier.tree.LiteralCommandNode; import com.mojang.brigadier.tree.LiteralCommandNode;
import com.velocitypowered.api.command.CommandSource; import com.velocitypowered.api.command.CommandSource;
import java.util.Locale; import java.util.Locale;
import org.checkerframework.checker.nullness.qual.Nullable;
/** /**
* Provides utilities for working with Brigadier commands. * Provides utilities for working with Brigadier commands.
@@ -124,6 +127,25 @@ 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();
} }

View File

@@ -122,20 +122,6 @@ public class CommandManagerTests {
assertTrue(manager.hasCommand("foO")); 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 @Test
void testBrigadierExecute() { void testBrigadierExecute() {
VelocityCommandManager manager = createManager(); VelocityCommandManager manager = createManager();
@@ -181,9 +167,9 @@ public class CommandManagerTests {
assertTrue(manager.executeImmediatelyAsync(MockCommandSource.INSTANCE, "buy 14").join()); assertTrue(manager.executeImmediatelyAsync(MockCommandSource.INSTANCE, "buy 14").join());
assertTrue(checkedRequires.compareAndSet(true, false)); assertTrue(checkedRequires.compareAndSet(true, false));
assertTrue(executed.get()); assertTrue(executed.get());
assertFalse(manager.execute(MockCommandSource.INSTANCE, "buy 9"), assertTrue(manager.execute(MockCommandSource.INSTANCE, "buy 9"),
"Invalid arg returns false"); "Invalid arg returns false");
assertFalse(manager.executeImmediately(MockCommandSource.INSTANCE, "buy 12 bananas")); assertTrue(manager.executeImmediately(MockCommandSource.INSTANCE, "buy 12 bananas"));
assertTrue(checkedRequires.get()); assertTrue(checkedRequires.get());
} }
@@ -392,7 +378,7 @@ public class CommandManagerTests {
.join().isEmpty()); .join().isEmpty());
assertEquals( assertEquals(
ImmutableList.of("123"), ImmutableList.of("123"),
manager.offerSuggestions(MockCommandSource.INSTANCE, "simPle foo ").join()); manager.offerSuggestions(MockCommandSource.INSTANCE, "simPle foo").join());
assertEquals( assertEquals(
ImmutableList.of("baz", "foo"), ImmutableList.of("baz", "foo"),
manager.offerSuggestions(MockCommandSource.INSTANCE, "raw ").join()); manager.offerSuggestions(MockCommandSource.INSTANCE, "raw ").join());
@@ -411,7 +397,7 @@ public class CommandManagerTests {
.join().isEmpty()); .join().isEmpty());
assertEquals( assertEquals(
ImmutableList.of("123", "456"), 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 ") assertTrue(manager.offerSuggestions(MockCommandSource.INSTANCE, "deprecated foo 789 ")
.join().isEmpty()); .join().isEmpty());
} }