Merge remote-tracking branch 'upstream/dev/3.0.0' into upstream

# Conflicts:
#	proxy/src/main/java/com/velocitypowered/proxy/protocol/StateRegistry.java
This commit is contained in:
Lixfel
2024-11-10 18:32:48 +01:00
85 changed files with 1479 additions and 605 deletions

View File

@@ -0,0 +1 @@
com.velocitypowered.api.plugin.ap.PluginAnnotationProcessor,isolating

View File

@@ -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);
}
@@ -55,7 +57,9 @@ public interface CommandManager {
*
* @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);
/**

View File

@@ -45,10 +45,28 @@ public interface EventManager {
* @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

View File

@@ -12,6 +12,6 @@ package com.velocitypowered.api.event;
*/
public enum PostOrder {
FIRST, EARLY, NORMAL, LATE, LAST
FIRST, EARLY, NORMAL, LATE, LAST, CUSTOM
}

View File

@@ -22,24 +22,38 @@ public @interface Subscribe {
/**
* 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>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>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>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
*/

View File

@@ -51,6 +51,13 @@ public final class PlayerChatEvent implements ResultedEvent<PlayerChatEvent.Chat
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");

View File

@@ -87,7 +87,8 @@ public enum ProtocolVersion implements Ordered<ProtocolVersion> {
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;

View File

@@ -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.
*

View File

@@ -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.
*/
@@ -84,4 +98,13 @@ public interface PlayerSettings {
LEFT,
RIGHT
}
/**
* The client's current "Particles" option state.
*/
enum ParticleStatus {
ALL,
DECREASED,
MINIMAL
}
}

View File

@@ -168,6 +168,25 @@ public interface TabList {
* @deprecated Internal usage. Use {@link TabListEntry.Builder} instead.
*/
@Deprecated
default TabListEntry buildEntry(GameProfile profile, @Nullable Component displayName, int latency,
int gameMode, @Nullable ChatSession chatSession, boolean listed) {
return buildEntry(profile, displayName, latency, gameMode, chatSession, listed, 0);
}
/**
* Represents an entry in a {@link Player}'s tab list.
*
* @param profile the profile
* @param displayName the display name
* @param latency the latency
* @param gameMode the game mode
* @param chatSession the chat session
* @param listed the visible status of entry
* @param listOrder the order/priority of entry in the tab list
* @return the entry
* @deprecated Internal usage. Use {@link TabListEntry.Builder} instead.
*/
@Deprecated
TabListEntry buildEntry(GameProfile profile, @Nullable Component displayName, int latency,
int gameMode, @Nullable ChatSession chatSession, boolean listed);
int gameMode, @Nullable ChatSession chatSession, boolean listed, int listOrder);
}

View File

@@ -139,6 +139,27 @@ public interface TabListEntry extends KeyIdentifiable {
return this;
}
/**
* Returns the order/priority of this entry in the tab list.
*
* @return order of this entry
* @sinceMinecraft 1.21.2
*/
default int getListOrder() {
return 0;
}
/**
* Sets the order/priority of this entry in the tab list.
*
* @param order order of this entry
* @return {@code this}, for chaining
* @sinceMinecraft 1.21.2
*/
default TabListEntry setListOrder(int order) {
return this;
}
/**
* Returns a {@link Builder} to create a {@link TabListEntry}.
*
@@ -161,6 +182,7 @@ public interface TabListEntry extends KeyIdentifiable {
private int latency = 0;
private int gameMode = 0;
private boolean listed = true;
private int listOrder = 0;
private @Nullable ChatSession chatSession;
@@ -243,7 +265,7 @@ public interface TabListEntry extends KeyIdentifiable {
}
/**
* Sets wether this entry should be visible.
* Sets whether this entry should be visible.
*
* @param listed to set
* @return ${code this}, for chaining
@@ -254,6 +276,19 @@ public interface TabListEntry extends KeyIdentifiable {
return this;
}
/**
* Sets the order/priority of this entry in the tab list.
*
* @param order to set
* @return ${code this}, for chaining
* @sinceMinecraft 1.21.2
* @see TabListEntry#getListOrder()
*/
public Builder listOrder(int order) {
this.listOrder = order;
return this;
}
/**
* Constructs the {@link TabListEntry} specified by {@code this} {@link Builder}.
*
@@ -266,7 +301,7 @@ public interface TabListEntry extends KeyIdentifiable {
if (profile == null) {
throw new IllegalStateException("The GameProfile must be set when building a TabListEntry");
}
return tabList.buildEntry(profile, displayName, latency, gameMode, chatSession, listed);
return tabList.buildEntry(profile, displayName, latency, gameMode, chatSession, listed, listOrder);
}
}
}