Skip to content

Commit

Permalink
Merge branch 'refs/heads/dev/3.0.0' into fix/shutdownstyle
Browse files Browse the repository at this point in the history
  • Loading branch information
456dev committed Oct 31, 2024
2 parents 59e19f6 + 08a42b3 commit 3dfba06
Show file tree
Hide file tree
Showing 51 changed files with 970 additions and 364 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ body:
```
[17:44:10 INFO]: Velocity 3.3.0-SNAPSHOT (git-9d25d309-b400)
[17:44:10 INFO]: Copyright 2018-2023 Velocity Contributors. Velocity is licensed under the terms of the GNU General Public License v3.
[17:44:10 INFO]: velocitypowered.com - GitHub
[17:44:10 INFO]: PaperMC - GitHub
```
</details>
validations:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
com.velocitypowered.api.plugin.ap.PluginAnnotationProcessor,isolating
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ public interface CommandManager {
* @throws IllegalArgumentException if one of the given aliases is already registered, or
* the given command does not implement a registrable {@link Command} subinterface
* @see Command for a list of registrable Command subinterfaces
* @deprecated use {@link #register(CommandMeta, Command)} instead with a plugin specified
*/
@Deprecated
default void register(String alias, Command command, String... otherAliases) {
register(metaBuilder(alias).aliases(otherAliases).build(), command);
}
Expand All @@ -55,7 +57,9 @@ default void register(String alias, Command command, String... otherAliases) {
*
* @param command the command to register
* @throws IllegalArgumentException if the node alias is already registered
* @deprecated use {@link #register(CommandMeta, Command)} instead with a plugin specified
*/
@Deprecated
void register(BrigadierCommand command);

/**
Expand Down
18 changes: 18 additions & 0 deletions api/src/main/java/com/velocitypowered/api/event/EventManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,28 @@ default <E> void register(Object plugin, Class<E> eventClass, EventHandler<E> ha
* @param postOrder the order in which events should be posted to the handler
* @param handler the handler to register
* @param <E> the event type to handle
* @deprecated use {@link #register(Object, Class, short, EventHandler)} instead
*/
@Deprecated
<E> void register(Object plugin, Class<E> eventClass, PostOrder postOrder,
EventHandler<E> handler);

/**
* Requests that the specified {@code handler} listen for events and associate it with the {@code
* plugin}.
*
* <p>Note that this method will register a non-asynchronous listener by default. If you want to
* use an asynchronous event handler, return {@link EventTask#async(Runnable)} from the handler.</p>
*
* @param plugin the plugin to associate with the handler
* @param eventClass the class for the event handler to register
* @param postOrder the relative order in which events should be posted to the handler
* @param handler the handler to register
* @param <E> the event type to handle
*/
<E> void register(Object plugin, Class<E> eventClass, short postOrder,
EventHandler<E> handler);

/**
* Fires the specified event to the event bus asynchronously. This allows Velocity to continue
* servicing connections while a plugin handles a potentially long-running operation such as a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
*/
public enum PostOrder {

FIRST, EARLY, NORMAL, LATE, LAST
FIRST, EARLY, NORMAL, LATE, LAST, CUSTOM

}
34 changes: 24 additions & 10 deletions api/src/main/java/com/velocitypowered/api/event/Subscribe.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,38 @@
/**
* The order events will be posted to this listener.
*
* @deprecated specify the order using {@link #priority()} instead
* @return the order
*/
@Deprecated
PostOrder order() default PostOrder.NORMAL;

/**
* Whether the handler must be called asynchronously.
* The priority of this event handler. Priorities are used to determine the order in which event
* handlers are called. The higher the priority, the earlier the event handler will be called.
*
* <p><strong>This option currently has no effect, but in the future it will. In Velocity 3.0.0,
* all event handlers run asynchronously by default. You are encouraged to determine whether or
* not to enable it now. This option is being provided as a migration aid.</strong></p>
* <p>Note that due to compatibility constraints, you must specify {@link PostOrder#CUSTOM}
* in order to use this field.</p>
*
* <p>If this method returns {@code true}, the method is guaranteed to be executed
* asynchronously. Otherwise, the handler may be executed on the current thread or
* asynchronously. <strong>This still means you must consider thread-safety in your
* event listeners</strong> as the "current thread" can and will be different each time.</p>
* @return the priority
*/
short priority() default Short.MIN_VALUE;

/**
* Whether the handler must be called asynchronously. By default, all event handlers are called
* asynchronously.
*
* <p>For performance (for instance, if you use {@link EventTask#withContinuation}), you can
* optionally specify <code>false</code>. This option will become {@code false} by default
* in a future release of Velocity.</p>
*
* <p>If this is {@code true}, the method is guaranteed to be executed asynchronously. Otherwise,
* the handler may be executed on the current thread or asynchronously. <strong>This still means
* you must consider thread-safety in your event listeners</strong> as the "current thread" can
* and will be different each time.</p>
*
* <p>If any method handler targeting an event type is marked with {@code true}, then every
* handler targeting that event type will be executed asynchronously.</p>
* <p>Note that if any method handler targeting an event type is marked with {@code true}, then
* every handler targeting that event type will be executed asynchronously.</p>
*
* @return Requires async
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ public ChatResult getResult() {
return result;
}

/**
* Set result for the event.
*
* @param result the result of event
* @deprecated for 1.19.1 and newer, set this as denied will kick users
*/
@Deprecated
@Override
public void setResult(ChatResult result) {
this.result = Preconditions.checkNotNull(result, "result");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ public boolean isSupported() {
MINECRAFT_1_20_2(764, "1.20.2"),
MINECRAFT_1_20_3(765, "1.20.3", "1.20.4"),
MINECRAFT_1_20_5(766, "1.20.5", "1.20.6"),
MINECRAFT_1_21(767, "1.21", "1.21.1");
MINECRAFT_1_21(767, "1.21", "1.21.1"),
MINECRAFT_1_21_2(768, "1.21.2", "1.21.3");

private static final int SNAPSHOT_BIT = 30;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,20 @@ public interface InboundConnection {

/**
* Returns the hostname that the user entered into the client, if applicable.
*
* <br/>
* This is partially processed, including removing a trailing dot, and discarding data after a null byte.
* @return the hostname from the client
*/
Optional<InetSocketAddress> getVirtualHost();

/**
* Returns the raw hostname that the client sent, if applicable.
*
* @return the raw hostname from the client
*/
Optional<String> getRawVirtualHost();

/**
* Determine whether or not the player remains online.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,20 @@ public interface PlayerSettings {
*/
boolean isClientListingAllowed();

/**
* Returns if the client has text filtering enabled.
*
* @return if text filtering is enabled
*/
boolean isTextFilteringEnabled();

/**
* Returns the selected "Particles" option state.
*
* @return the particle option
*/
ParticleStatus getParticleStatus();

/**
* The client's current chat display mode.
*/
Expand All @@ -84,4 +98,13 @@ enum MainHand {
LEFT,
RIGHT
}

/**
* The client's current "Particles" option state.
*/
enum ParticleStatus {
ALL,
DECREASED,
MINIMAL
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
group=com.velocitypowered
version=3.3.0-SNAPSHOT
version=3.4.0-SNAPSHOT
17 changes: 9 additions & 8 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
configurate3 = "3.7.3"
configurate4 = "4.1.2"
flare = "2.0.1"
log4j = "2.22.1"
netty = "4.1.106.Final"
log4j = "2.24.1"
netty = "4.1.114.Final"

[plugins]
indra-publishing = "net.kyori.indra.publishing:2.0.6"
Expand All @@ -12,13 +12,14 @@ spotless = "com.diffplug.spotless:6.25.0"

[libraries]
adventure-bom = "net.kyori:adventure-bom:4.17.0"
adventure-facet = "net.kyori:adventure-platform-facet:4.3.2"
adventure-text-serializer-json-legacy-impl = "net.kyori:adventure-text-serializer-json-legacy-impl:4.17.0"
adventure-facet = "net.kyori:adventure-platform-facet:4.3.4"
asm = "org.ow2.asm:asm:9.6"
auto-service = "com.google.auto.service:auto-service:1.0.1"
auto-service-annotations = "com.google.auto.service:auto-service-annotations:1.0.1"
brigadier = "com.velocitypowered:velocity-brigadier:1.0.0-SNAPSHOT"
bstats = "org.bstats:bstats-base:3.0.2"
caffeine = "com.github.ben-manes.caffeine:caffeine:3.1.5"
caffeine = "com.github.ben-manes.caffeine:caffeine:3.1.8"
checker-qual = "org.checkerframework:checker-qual:3.42.0"
checkstyle = "com.puppycrawl.tools:checkstyle:10.9.3"
completablefutures = "com.spotify:completable-futures:0.3.6"
Expand All @@ -28,15 +29,15 @@ configurate3-gson = { module = "org.spongepowered:configurate-gson", version.ref
configurate4-hocon = { module = "org.spongepowered:configurate-hocon", version.ref = "configurate4" }
configurate4-yaml = { module = "org.spongepowered:configurate-yaml", version.ref = "configurate4" }
configurate4-gson = { module = "org.spongepowered:configurate-gson", version.ref = "configurate4" }
disruptor = "com.lmax:disruptor:3.4.4"
fastutil = "it.unimi.dsi:fastutil:8.5.12"
disruptor = "com.lmax:disruptor:4.0.0"
fastutil = "it.unimi.dsi:fastutil:8.5.15"
flare-core = { module = "space.vectrix.flare:flare", version.ref = "flare" }
flare-fastutil = { module = "space.vectrix.flare:flare-fastutil", version.ref = "flare" }
jline = "org.jline:jline-terminal-jansi:3.23.0"
jline = "org.jline:jline-terminal-jansi:3.27.1"
jopt = "net.sf.jopt-simple:jopt-simple:5.0.4"
junit = "org.junit.jupiter:junit-jupiter:5.10.2"
jspecify = "org.jspecify:jspecify:0.3.0"
kyori-ansi = "net.kyori:ansi:1.0.3"
kyori-ansi = "net.kyori:ansi:1.1.0"
guava = "com.google.guava:guava:25.1-jre"
gson = "com.google.code.gson:gson:2.10.1"
guice = "com.google.inject:guice:6.0.0"
Expand Down
11 changes: 10 additions & 1 deletion proxy/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ tasks {
dependsOn(configurateBuildTask)
from(zipTree(configurateBuildTask.map { it.outputs.files.singleFile }))
}

runShadow {
workingDir = file("run").also(File::mkdirs)
standardInput = System.`in`
}
named<JavaExec>("run") {
workingDir = file("run").also(File::mkdirs)
standardInput = System.`in` // Doesn't work?
}
}

dependencies {
Expand All @@ -118,7 +127,7 @@ dependencies {
runtimeOnly(libs.disruptor)
implementation(libs.fastutil)
implementation(platform(libs.adventure.bom))
implementation("net.kyori:adventure-nbt")
implementation(libs.adventure.text.serializer.json.legacy.impl)
implementation(libs.adventure.facet)
implementation(libs.completablefutures)
implementation(libs.nightconfig)
Expand Down
53 changes: 53 additions & 0 deletions proxy/src/main/java/com/velocitypowered/proxy/ProxyOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,17 @@

package com.velocitypowered.proxy;

import com.velocitypowered.api.proxy.server.ServerInfo;
import com.velocitypowered.proxy.util.AddressUtil;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.Arrays;
import java.util.List;
import joptsimple.OptionParser;
import joptsimple.OptionSet;
import joptsimple.OptionSpec;
import joptsimple.ValueConversionException;
import joptsimple.ValueConverter;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.checkerframework.checker.nullness.qual.Nullable;
Expand All @@ -35,6 +41,8 @@ public final class ProxyOptions {
private final boolean help;
private final @Nullable Integer port;
private final @Nullable Boolean haproxy;
private final boolean ignoreConfigServers;
private final List<ServerInfo> servers;

ProxyOptions(final String[] args) {
final OptionParser parser = new OptionParser();
Expand All @@ -49,11 +57,20 @@ public final class ProxyOptions {
"Choose whether to enable haproxy protocol. "
+ "The configuration haproxy protocol will be ignored.")
.withRequiredArg().ofType(Boolean.class);
final OptionSpec<ServerInfo> servers = parser.accepts("add-server",
"Define a server mapping. "
+ "You must ensure that server name is not also registered in the config or use --ignore-config-servers.")
.withRequiredArg().withValuesConvertedBy(new ServerInfoConverter());
final OptionSpec<Void> ignoreConfigServers = parser.accepts("ignore-config-servers",
"Skip registering servers from the config file. "
+ "Useful in dynamic setups or with the --add-server flag.");
final OptionSet set = parser.parse(args);

this.help = set.has(help);
this.port = port.value(set);
this.haproxy = haproxy.value(set);
this.servers = servers.values(set);
this.ignoreConfigServers = set.has(ignoreConfigServers);

if (this.help) {
try {
Expand All @@ -75,4 +92,40 @@ boolean isHelp() {
public @Nullable Boolean isHaproxy() {
return this.haproxy;
}

public boolean isIgnoreConfigServers() {
return this.ignoreConfigServers;
}

public List<ServerInfo> getServers() {
return this.servers;
}

private static class ServerInfoConverter implements ValueConverter<ServerInfo> {

@Override
public ServerInfo convert(String s) {
String[] split = s.split(":", 2);
if (split.length < 2) {
throw new ValueConversionException("Invalid server format. Use <name>:<address>");
}
InetSocketAddress address;
try {
address = AddressUtil.parseAddress(split[1]);
} catch (IllegalStateException e) {
throw new ValueConversionException("Invalid hostname for server flag with name: " + split[0]);
}
return new ServerInfo(split[0], address);
}

@Override
public Class<? extends ServerInfo> valueType() {
return ServerInfo.class;
}

@Override
public String valuePattern() {
return "name>:<address";
}
}
}
Loading

0 comments on commit 3dfba06

Please sign in to comment.