diff --git a/Paper-MojangAPI/build.gradle.kts b/Paper-MojangAPI/build.gradle.kts deleted file mode 100644 index e60be45e2513e..0000000000000 --- a/Paper-MojangAPI/build.gradle.kts +++ /dev/null @@ -1,36 +0,0 @@ -plugins { - `java-library` - `maven-publish` -} - -java { - withSourcesJar() - withJavadocJar() -} - -dependencies { - implementation(project(":paper-api")) - api("com.mojang:brigadier:1.0.18") - - compileOnly("it.unimi.dsi:fastutil:8.5.6") - compileOnly("org.jetbrains:annotations:23.0.0") - - testImplementation("junit:junit:4.13.2") - testImplementation("org.hamcrest:hamcrest-library:1.3") - testImplementation("org.ow2.asm:asm-tree:9.7") -} - -configure { - publications.create("maven") { - from(components["java"]) - } -} - -val scanJar = tasks.register("scanJarForBadCalls", io.papermc.paperweight.tasks.ScanJarForBadCalls::class) { - badAnnotations.add("Lio/papermc/paper/annotation/DoNotUse;") - jarToScan.set(tasks.jar.flatMap { it.archiveFile }) - classpath.from(configurations.compileClasspath) -} -tasks.check { - dependsOn(scanJar) -} diff --git a/Paper-MojangAPI/src/main/java/com/destroystokyo/paper/brigadier/BukkitBrigadierCommand.java b/Paper-MojangAPI/src/main/java/com/destroystokyo/paper/brigadier/BukkitBrigadierCommand.java deleted file mode 100644 index 03a1078446f84..0000000000000 --- a/Paper-MojangAPI/src/main/java/com/destroystokyo/paper/brigadier/BukkitBrigadierCommand.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.destroystokyo.paper.brigadier; - -import com.mojang.brigadier.Command; -import com.mojang.brigadier.suggestion.SuggestionProvider; - -import java.util.function.Predicate; - -/** - * Brigadier {@link Command}, {@link SuggestionProvider}, and permission checker for Bukkit {@link Command}s. - * - * @param command source type - * @deprecated For removal, see {@link io.papermc.paper.command.brigadier.Commands} on how to use the new Brigadier API. - */ -@Deprecated(forRemoval = true, since = "1.20.6") -public interface BukkitBrigadierCommand extends Command, Predicate, SuggestionProvider { -} diff --git a/Paper-MojangAPI/src/main/java/com/destroystokyo/paper/brigadier/BukkitBrigadierCommandSource.java b/Paper-MojangAPI/src/main/java/com/destroystokyo/paper/brigadier/BukkitBrigadierCommandSource.java deleted file mode 100644 index 28b44789e3be5..0000000000000 --- a/Paper-MojangAPI/src/main/java/com/destroystokyo/paper/brigadier/BukkitBrigadierCommandSource.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.destroystokyo.paper.brigadier; - -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Entity; -import org.jetbrains.annotations.Nullable; - -/** - * @deprecated For removal, see {@link io.papermc.paper.command.brigadier.Commands} on how to use the new Brigadier API. - */ -@Deprecated(forRemoval = true) -public interface BukkitBrigadierCommandSource { - - @Nullable - Entity getBukkitEntity(); - - @Nullable - World getBukkitWorld(); - - @Nullable - Location getBukkitLocation(); - - CommandSender getBukkitSender(); -} diff --git a/Paper-MojangAPI/src/main/java/com/destroystokyo/paper/event/brigadier/AsyncPlayerSendCommandsEvent.java b/Paper-MojangAPI/src/main/java/com/destroystokyo/paper/event/brigadier/AsyncPlayerSendCommandsEvent.java deleted file mode 100644 index 495b0f0d2f29b..0000000000000 --- a/Paper-MojangAPI/src/main/java/com/destroystokyo/paper/event/brigadier/AsyncPlayerSendCommandsEvent.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.destroystokyo.paper.event.brigadier; - -import com.destroystokyo.paper.brigadier.BukkitBrigadierCommandSource; -import com.mojang.brigadier.tree.RootCommandNode; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.event.HandlerList; -import org.bukkit.event.player.PlayerEvent; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; - -/** - * Fired any time a Brigadier RootCommandNode is generated for a player to inform the client of commands. - * You may manipulate this CommandNode to change what the client sees. - * - *

This event may fire on login, world change, and permission rebuilds, by plugin request, and potentially future means.

- * - *

This event will fire before {@link org.bukkit.event.player.PlayerCommandSendEvent}, so no filtering has been done by - * other plugins yet.

- * - *

WARNING: This event will potentially (and most likely) fire twice! Once for Async, and once again for Sync. - * It is important that you check event.isAsynchronous() and event.hasFiredAsync() to ensure you only act once. - * If for some reason we are unable to send this asynchronously in the future, only the sync method will fire.

- * - *

Your logic should look like this: - * {@code if (event.isAsynchronous() || !event.hasFiredAsync()) { // do stuff }}

- * - *

If your logic is not safe to run asynchronously, only react to the synchronous version.

- * - *

This is a draft/experimental API and is subject to change.

- */ -@ApiStatus.Experimental -public class AsyncPlayerSendCommandsEvent extends PlayerEvent { - - private static final HandlerList handlers = new HandlerList(); - private final RootCommandNode node; - private final boolean hasFiredAsync; - - public AsyncPlayerSendCommandsEvent(Player player, RootCommandNode node, boolean hasFiredAsync) { - super(player, !Bukkit.isPrimaryThread()); - this.node = node; - this.hasFiredAsync = hasFiredAsync; - } - - /** - * Gets the full Root Command Node being sent to the client, which is mutable. - * - * @return the root command node - */ - public RootCommandNode getCommandNode() { - return node; - } - - /** - * Gets if this event has already fired asynchronously. - * - * @return whether this event has already fired asynchronously - */ - public boolean hasFiredAsync() { - return hasFiredAsync; - } - - @NotNull - public HandlerList getHandlers() { - return handlers; - } - - @NotNull - public static HandlerList getHandlerList() { - return handlers; - } -} diff --git a/Paper-MojangAPI/src/main/java/com/destroystokyo/paper/event/brigadier/AsyncPlayerSendSuggestionsEvent.java b/Paper-MojangAPI/src/main/java/com/destroystokyo/paper/event/brigadier/AsyncPlayerSendSuggestionsEvent.java deleted file mode 100644 index 4755ab24a66de..0000000000000 --- a/Paper-MojangAPI/src/main/java/com/destroystokyo/paper/event/brigadier/AsyncPlayerSendSuggestionsEvent.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.destroystokyo.paper.event.brigadier; - -import com.mojang.brigadier.suggestion.Suggestions; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.event.Cancellable; -import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; -import org.bukkit.event.player.PlayerEvent; -import org.jetbrains.annotations.NotNull; - -/** - * Called when sending {@link Suggestions} to the client. Will be called asynchronously if a plugin - * marks the {@link com.destroystokyo.paper.event.server.AsyncTabCompleteEvent} event handled asynchronously, - * otherwise called synchronously. - */ -public class AsyncPlayerSendSuggestionsEvent extends PlayerEvent implements Cancellable { - - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled = false; - - private Suggestions suggestions; - private final String buffer; - - public AsyncPlayerSendSuggestionsEvent(Player player, Suggestions suggestions, String buffer) { - super(player, !Bukkit.isPrimaryThread()); - this.suggestions = suggestions; - this.buffer = buffer; - } - - /** - * Gets the input buffer sent to request these suggestions. - * - * @return the input buffer - */ - public String getBuffer() { - return buffer; - } - - /** - * Gets the suggestions to be sent to client. - * - * @return the suggestions - */ - public Suggestions getSuggestions() { - return suggestions; - } - - /** - * Sets the suggestions to be sent to client. - * - * @param suggestions suggestions - */ - public void setSuggestions(Suggestions suggestions) { - this.suggestions = suggestions; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isCancelled() { - return this.cancelled; - } - - /** - * Cancels sending suggestions to the client. - * {@inheritDoc} - */ - @Override - public void setCancelled(boolean cancel) { - this.cancelled = cancel; - } - - @NotNull - public HandlerList getHandlers() { - return handlers; - } - - @NotNull - public static HandlerList getHandlerList() { - return handlers; - } -} diff --git a/Paper-MojangAPI/src/main/java/com/destroystokyo/paper/event/brigadier/CommandRegisteredEvent.java b/Paper-MojangAPI/src/main/java/com/destroystokyo/paper/event/brigadier/CommandRegisteredEvent.java deleted file mode 100644 index ef361473a21a5..0000000000000 --- a/Paper-MojangAPI/src/main/java/com/destroystokyo/paper/event/brigadier/CommandRegisteredEvent.java +++ /dev/null @@ -1,170 +0,0 @@ -package com.destroystokyo.paper.event.brigadier; - -import com.destroystokyo.paper.brigadier.BukkitBrigadierCommand; -import com.destroystokyo.paper.brigadier.BukkitBrigadierCommandSource; -import com.mojang.brigadier.tree.ArgumentCommandNode; -import com.mojang.brigadier.tree.LiteralCommandNode; -import com.mojang.brigadier.tree.RootCommandNode; -import org.bukkit.command.Command; -import org.bukkit.event.Cancellable; -import org.bukkit.event.HandlerList; -import org.bukkit.event.server.ServerEvent; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.NotNull; - -/** - * Fired anytime the server synchronizes Bukkit commands to Brigadier. - * - *

Allows a plugin to control the command node structure for its commands. - * This is done at Plugin Enable time after commands have been registered, but may also - * run at a later point in the server lifetime due to plugins, a server reload, etc.

- * - *

This is a draft/experimental API and is subject to change.

- * @deprecated For removal, use the new brigadier api. - */ -@ApiStatus.Experimental -@Deprecated(since = "1.20.6") -public class CommandRegisteredEvent extends ServerEvent implements Cancellable { - - private static final HandlerList handlers = new HandlerList(); - private final String commandLabel; - private final Command command; - private final BukkitBrigadierCommand brigadierCommand; - private final RootCommandNode root; - private final ArgumentCommandNode defaultArgs; - private LiteralCommandNode literal; - private boolean rawCommand = false; - private boolean cancelled = false; - - public CommandRegisteredEvent(String commandLabel, BukkitBrigadierCommand brigadierCommand, Command command, RootCommandNode root, LiteralCommandNode literal, ArgumentCommandNode defaultArgs) { - this.commandLabel = commandLabel; - this.brigadierCommand = brigadierCommand; - this.command = command; - this.root = root; - this.literal = literal; - this.defaultArgs = defaultArgs; - } - - /** - * Gets the command label of the {@link Command} being registered. - * - * @return the command label - */ - public String getCommandLabel() { - return this.commandLabel; - } - - /** - * Gets the {@link BukkitBrigadierCommand} for the {@link Command} being registered. This can be used - * as the {@link com.mojang.brigadier.Command command executor} or - * {@link com.mojang.brigadier.suggestion.SuggestionProvider} of a {@link com.mojang.brigadier.tree.CommandNode} - * to delegate to the {@link Command} being registered. - * - * @return the {@link BukkitBrigadierCommand} - */ - public BukkitBrigadierCommand getBrigadierCommand() { - return this.brigadierCommand; - } - - /** - * Gets the {@link Command} being registered. - * - * @return the {@link Command} - */ - public Command getCommand() { - return this.command; - } - - /** - * Gets the {@link RootCommandNode} which is being registered to. - * - * @return the {@link RootCommandNode} - */ - public RootCommandNode getRoot() { - return this.root; - } - - /** - * Gets the Bukkit APIs default arguments node (greedy string), for if - * you wish to reuse it. - * - * @return default arguments node - */ - public ArgumentCommandNode getDefaultArgs() { - return this.defaultArgs; - } - - /** - * Gets the {@link LiteralCommandNode} to be registered for the {@link Command}. - * - * @return the {@link LiteralCommandNode} - */ - public LiteralCommandNode getLiteral() { - return this.literal; - } - - /** - * Sets the {@link LiteralCommandNode} used to register this command. The default literal is mutable, so - * this is primarily if you want to completely replace the object. - * - * @param literal new node - */ - public void setLiteral(LiteralCommandNode literal) { - this.literal = literal; - } - - /** - * Gets whether this command should is treated as "raw". - * - * @see #setRawCommand(boolean) - * @return whether this command is treated as "raw" - */ - public boolean isRawCommand() { - return this.rawCommand; - } - - /** - * Sets whether this command should be treated as "raw". - * - *

A "raw" command will only use the node provided by this event for - * sending the command tree to the client. For execution purposes, the default - * greedy string execution of a standard Bukkit {@link Command} is used.

- * - *

On older versions of Paper, this was the default and only behavior of this - * event.

- * - * @param rawCommand whether this command should be treated as "raw" - */ - public void setRawCommand(final boolean rawCommand) { - this.rawCommand = rawCommand; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isCancelled() { - return this.cancelled; - } - - /** - * Cancels registering this command to Brigadier, but will remain in Bukkit Command Map. Can be used to hide a - * command from all players. - * - * {@inheritDoc} - */ - @Override - public void setCancelled(boolean cancel) { - this.cancelled = cancel; - } - - @NotNull - public HandlerList getHandlers() { - return handlers; - } - - @NotNull - public static HandlerList getHandlerList() { - return handlers; - } -} diff --git a/Paper-MojangAPI/src/main/java/io/papermc/paper/brigadier/PaperBrigadier.java b/Paper-MojangAPI/src/main/java/io/papermc/paper/brigadier/PaperBrigadier.java deleted file mode 100644 index 9df87708206e2..0000000000000 --- a/Paper-MojangAPI/src/main/java/io/papermc/paper/brigadier/PaperBrigadier.java +++ /dev/null @@ -1,47 +0,0 @@ -package io.papermc.paper.brigadier; - -import com.mojang.brigadier.Message; -import io.papermc.paper.command.brigadier.MessageComponentSerializer; -import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.ComponentLike; -import net.kyori.adventure.text.TextComponent; -import org.checkerframework.checker.nullness.qual.NonNull; - -/** - * Helper methods to bridge the gaps between Brigadier and Paper-MojangAPI. - * @deprecated for removal. See {@link MessageComponentSerializer} for a direct replacement of functionality found in - * this class. - * As a general entrypoint to brigadier on paper, see {@link io.papermc.paper.command.brigadier.Commands}. - */ -@Deprecated(forRemoval = true, since = "1.20.6") -public final class PaperBrigadier { - private PaperBrigadier() { - throw new RuntimeException("PaperBrigadier is not to be instantiated!"); - } - - /** - * Create a new Brigadier {@link Message} from a {@link ComponentLike}. - * - *

Mostly useful for creating rich suggestion tooltips in combination with other Paper-MojangAPI APIs.

- * - * @param componentLike The {@link ComponentLike} to use for the {@link Message} contents - * @return A new Brigadier {@link Message} - */ - public static @NonNull Message message(final @NonNull ComponentLike componentLike) { - return MessageComponentSerializer.message().serialize(componentLike.asComponent()); - } - - /** - * Create a new {@link Component} from a Brigadier {@link Message}. - * - *

If the {@link Message} was created from a {@link Component}, it will simply be - * converted back, otherwise a new {@link TextComponent} will be created with the - * content of {@link Message#getString()}

- * - * @param message The {@link Message} to create a {@link Component} from - * @return The created {@link Component} - */ - public static @NonNull Component componentFromMessage(final @NonNull Message message) { - return MessageComponentSerializer.message().deserialize(message); - } -} diff --git a/patches/api/0481-temp-Paper-MojangAPI.patch b/patches/api/0481-temp-Paper-MojangAPI.patch new file mode 100644 index 0000000000000..59e020e5c7dd8 --- /dev/null +++ b/patches/api/0481-temp-Paper-MojangAPI.patch @@ -0,0 +1,487 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jake Potrebic +Date: Sat, 11 May 2024 12:00:37 -0700 +Subject: [PATCH] temp: Paper-MojangAPI + + +diff --git a/build.gradle.kts b/build.gradle.kts +index 538736cf17592829f0f26477c2bf8d80f3714d9a..aed3440e6496f049a30107197e1f6d96487bf300 100644 +--- a/build.gradle.kts ++++ b/build.gradle.kts +@@ -93,9 +93,29 @@ sourceSets { + } + } + // Paper end ++// Paper start - brigadier API ++val outgoingVariants = arrayOf("runtimeElements", "apiElements", "sourcesElements", "javadocElements") ++configurations { ++ val outgoing = outgoingVariants.map { named(it) } ++ for (config in outgoing) { ++ config { ++ outgoing { ++ capability("${project.group}:${project.name}:${project.version}") ++ capability("io.papermc.paper:paper-mojangapi:${project.version}") ++ capability("com.destroystokyo:paper-mojangapi:${project.version}") ++ } ++ } ++ } ++} ++// Paper end + + configure { + publications.create("maven") { ++ // Paper start - brigadier API ++ outgoingVariants.forEach { ++ suppressPomMetadataWarningsFor(it) ++ } ++ // Paper end + from(components["java"]) + } + } +diff --git a/src/main/java/com/destroystokyo/paper/brigadier/BukkitBrigadierCommand.java b/src/main/java/com/destroystokyo/paper/brigadier/BukkitBrigadierCommand.java +new file mode 100644 +index 0000000000000000000000000000000000000000..03a1078446f84b998cd7fe8d64abecb2e36bab0a +--- /dev/null ++++ b/src/main/java/com/destroystokyo/paper/brigadier/BukkitBrigadierCommand.java +@@ -0,0 +1,16 @@ ++package com.destroystokyo.paper.brigadier; ++ ++import com.mojang.brigadier.Command; ++import com.mojang.brigadier.suggestion.SuggestionProvider; ++ ++import java.util.function.Predicate; ++ ++/** ++ * Brigadier {@link Command}, {@link SuggestionProvider}, and permission checker for Bukkit {@link Command}s. ++ * ++ * @param command source type ++ * @deprecated For removal, see {@link io.papermc.paper.command.brigadier.Commands} on how to use the new Brigadier API. ++ */ ++@Deprecated(forRemoval = true, since = "1.20.6") ++public interface BukkitBrigadierCommand extends Command, Predicate, SuggestionProvider { ++} +diff --git a/src/main/java/com/destroystokyo/paper/brigadier/BukkitBrigadierCommandSource.java b/src/main/java/com/destroystokyo/paper/brigadier/BukkitBrigadierCommandSource.java +new file mode 100644 +index 0000000000000000000000000000000000000000..28b44789e3be586c4b680fff56e5d2ff095f9ac2 +--- /dev/null ++++ b/src/main/java/com/destroystokyo/paper/brigadier/BukkitBrigadierCommandSource.java +@@ -0,0 +1,25 @@ ++package com.destroystokyo.paper.brigadier; ++ ++import org.bukkit.Location; ++import org.bukkit.World; ++import org.bukkit.command.CommandSender; ++import org.bukkit.entity.Entity; ++import org.jetbrains.annotations.Nullable; ++ ++/** ++ * @deprecated For removal, see {@link io.papermc.paper.command.brigadier.Commands} on how to use the new Brigadier API. ++ */ ++@Deprecated(forRemoval = true) ++public interface BukkitBrigadierCommandSource { ++ ++ @Nullable ++ Entity getBukkitEntity(); ++ ++ @Nullable ++ World getBukkitWorld(); ++ ++ @Nullable ++ Location getBukkitLocation(); ++ ++ CommandSender getBukkitSender(); ++} +diff --git a/src/main/java/com/destroystokyo/paper/event/brigadier/AsyncPlayerSendCommandsEvent.java b/src/main/java/com/destroystokyo/paper/event/brigadier/AsyncPlayerSendCommandsEvent.java +new file mode 100644 +index 0000000000000000000000000000000000000000..70ac52f3864ac6e9603d527338bbc015a12f5711 +--- /dev/null ++++ b/src/main/java/com/destroystokyo/paper/event/brigadier/AsyncPlayerSendCommandsEvent.java +@@ -0,0 +1,71 @@ ++package com.destroystokyo.paper.event.brigadier; ++ ++import com.mojang.brigadier.tree.RootCommandNode; ++import org.bukkit.Bukkit; ++import org.bukkit.entity.Player; ++import org.bukkit.event.HandlerList; ++import org.bukkit.event.player.PlayerEvent; ++import org.jetbrains.annotations.ApiStatus; ++import org.jetbrains.annotations.NotNull; ++ ++/** ++ * Fired any time a Brigadier RootCommandNode is generated for a player to inform the client of commands. ++ * You may manipulate this CommandNode to change what the client sees. ++ * ++ *

This event may fire on login, world change, and permission rebuilds, by plugin request, and potentially future means.

++ * ++ *

This event will fire before {@link org.bukkit.event.player.PlayerCommandSendEvent}, so no filtering has been done by ++ * other plugins yet.

++ * ++ *

WARNING: This event will potentially (and most likely) fire twice! Once for Async, and once again for Sync. ++ * It is important that you check event.isAsynchronous() and event.hasFiredAsync() to ensure you only act once. ++ * If for some reason we are unable to send this asynchronously in the future, only the sync method will fire.

++ * ++ *

Your logic should look like this: ++ * {@code if (event.isAsynchronous() || !event.hasFiredAsync()) { // do stuff }}

++ * ++ *

If your logic is not safe to run asynchronously, only react to the synchronous version.

++ * ++ *

This is a draft/experimental API and is subject to change.

++ */ ++@ApiStatus.Experimental ++public class AsyncPlayerSendCommandsEvent extends PlayerEvent { ++ ++ private static final HandlerList handlers = new HandlerList(); ++ private final RootCommandNode node; ++ private final boolean hasFiredAsync; ++ ++ public AsyncPlayerSendCommandsEvent(Player player, RootCommandNode node, boolean hasFiredAsync) { ++ super(player, !Bukkit.isPrimaryThread()); ++ this.node = node; ++ this.hasFiredAsync = hasFiredAsync; ++ } ++ ++ /** ++ * Gets the full Root Command Node being sent to the client, which is mutable. ++ * ++ * @return the root command node ++ */ ++ public RootCommandNode getCommandNode() { ++ return node; ++ } ++ ++ /** ++ * Gets if this event has already fired asynchronously. ++ * ++ * @return whether this event has already fired asynchronously ++ */ ++ public boolean hasFiredAsync() { ++ return hasFiredAsync; ++ } ++ ++ @NotNull ++ public HandlerList getHandlers() { ++ return handlers; ++ } ++ ++ @NotNull ++ public static HandlerList getHandlerList() { ++ return handlers; ++ } ++} +diff --git a/src/main/java/com/destroystokyo/paper/event/brigadier/AsyncPlayerSendSuggestionsEvent.java b/src/main/java/com/destroystokyo/paper/event/brigadier/AsyncPlayerSendSuggestionsEvent.java +new file mode 100644 +index 0000000000000000000000000000000000000000..6b0dcc60fc097675b19c7389f30b96e8680ec52d +--- /dev/null ++++ b/src/main/java/com/destroystokyo/paper/event/brigadier/AsyncPlayerSendSuggestionsEvent.java +@@ -0,0 +1,83 @@ ++package com.destroystokyo.paper.event.brigadier; ++ ++import com.mojang.brigadier.suggestion.Suggestions; ++import org.bukkit.Bukkit; ++import org.bukkit.entity.Player; ++import org.bukkit.event.Cancellable; ++import org.bukkit.event.HandlerList; ++import org.bukkit.event.player.PlayerEvent; ++import org.jetbrains.annotations.NotNull; ++ ++/** ++ * Called when sending {@link Suggestions} to the client. Will be called asynchronously if a plugin ++ * marks the {@link com.destroystokyo.paper.event.server.AsyncTabCompleteEvent} event handled asynchronously, ++ * otherwise called synchronously. ++ */ ++public class AsyncPlayerSendSuggestionsEvent extends PlayerEvent implements Cancellable { ++ ++ private static final HandlerList handlers = new HandlerList(); ++ private boolean cancelled = false; ++ ++ private Suggestions suggestions; ++ private final String buffer; ++ ++ public AsyncPlayerSendSuggestionsEvent(Player player, Suggestions suggestions, String buffer) { ++ super(player, !Bukkit.isPrimaryThread()); ++ this.suggestions = suggestions; ++ this.buffer = buffer; ++ } ++ ++ /** ++ * Gets the input buffer sent to request these suggestions. ++ * ++ * @return the input buffer ++ */ ++ public String getBuffer() { ++ return buffer; ++ } ++ ++ /** ++ * Gets the suggestions to be sent to client. ++ * ++ * @return the suggestions ++ */ ++ public Suggestions getSuggestions() { ++ return suggestions; ++ } ++ ++ /** ++ * Sets the suggestions to be sent to client. ++ * ++ * @param suggestions suggestions ++ */ ++ public void setSuggestions(Suggestions suggestions) { ++ this.suggestions = suggestions; ++ } ++ ++ /** ++ * {@inheritDoc} ++ */ ++ @Override ++ public boolean isCancelled() { ++ return this.cancelled; ++ } ++ ++ /** ++ * Cancels sending suggestions to the client. ++ * {@inheritDoc} ++ */ ++ @Override ++ public void setCancelled(boolean cancel) { ++ this.cancelled = cancel; ++ } ++ ++ @NotNull ++ public HandlerList getHandlers() { ++ return handlers; ++ } ++ ++ @NotNull ++ public static HandlerList getHandlerList() { ++ return handlers; ++ } ++} +diff --git a/src/main/java/com/destroystokyo/paper/event/brigadier/CommandRegisteredEvent.java b/src/main/java/com/destroystokyo/paper/event/brigadier/CommandRegisteredEvent.java +new file mode 100644 +index 0000000000000000000000000000000000000000..8a0c7266cc3fe63d3c6fd83bcd75c54de21038b4 +--- /dev/null ++++ b/src/main/java/com/destroystokyo/paper/event/brigadier/CommandRegisteredEvent.java +@@ -0,0 +1,169 @@ ++package com.destroystokyo.paper.event.brigadier; ++ ++import com.destroystokyo.paper.brigadier.BukkitBrigadierCommand; ++import com.mojang.brigadier.tree.ArgumentCommandNode; ++import com.mojang.brigadier.tree.LiteralCommandNode; ++import com.mojang.brigadier.tree.RootCommandNode; ++import org.bukkit.command.Command; ++import org.bukkit.event.Cancellable; ++import org.bukkit.event.HandlerList; ++import org.bukkit.event.server.ServerEvent; ++import org.jetbrains.annotations.ApiStatus; ++import org.jetbrains.annotations.NotNull; ++ ++/** ++ * Fired anytime the server synchronizes Bukkit commands to Brigadier. ++ * ++ *

Allows a plugin to control the command node structure for its commands. ++ * This is done at Plugin Enable time after commands have been registered, but may also ++ * run at a later point in the server lifetime due to plugins, a server reload, etc.

++ * ++ *

This is a draft/experimental API and is subject to change.

++ * @deprecated For removal, use the new brigadier api. ++ */ ++@ApiStatus.Experimental ++@Deprecated(since = "1.20.6") ++public class CommandRegisteredEvent extends ServerEvent implements Cancellable { ++ ++ private static final HandlerList handlers = new HandlerList(); ++ private final String commandLabel; ++ private final Command command; ++ private final com.destroystokyo.paper.brigadier.BukkitBrigadierCommand brigadierCommand; ++ private final RootCommandNode root; ++ private final ArgumentCommandNode defaultArgs; ++ private LiteralCommandNode literal; ++ private boolean rawCommand = false; ++ private boolean cancelled = false; ++ ++ public CommandRegisteredEvent(String commandLabel, com.destroystokyo.paper.brigadier.BukkitBrigadierCommand brigadierCommand, Command command, RootCommandNode root, LiteralCommandNode literal, ArgumentCommandNode defaultArgs) { ++ this.commandLabel = commandLabel; ++ this.brigadierCommand = brigadierCommand; ++ this.command = command; ++ this.root = root; ++ this.literal = literal; ++ this.defaultArgs = defaultArgs; ++ } ++ ++ /** ++ * Gets the command label of the {@link Command} being registered. ++ * ++ * @return the command label ++ */ ++ public String getCommandLabel() { ++ return this.commandLabel; ++ } ++ ++ /** ++ * Gets the {@link BukkitBrigadierCommand} for the {@link Command} being registered. This can be used ++ * as the {@link com.mojang.brigadier.Command command executor} or ++ * {@link com.mojang.brigadier.suggestion.SuggestionProvider} of a {@link com.mojang.brigadier.tree.CommandNode} ++ * to delegate to the {@link Command} being registered. ++ * ++ * @return the {@link BukkitBrigadierCommand} ++ */ ++ public BukkitBrigadierCommand getBrigadierCommand() { ++ return this.brigadierCommand; ++ } ++ ++ /** ++ * Gets the {@link Command} being registered. ++ * ++ * @return the {@link Command} ++ */ ++ public Command getCommand() { ++ return this.command; ++ } ++ ++ /** ++ * Gets the {@link RootCommandNode} which is being registered to. ++ * ++ * @return the {@link RootCommandNode} ++ */ ++ public RootCommandNode getRoot() { ++ return this.root; ++ } ++ ++ /** ++ * Gets the Bukkit APIs default arguments node (greedy string), for if ++ * you wish to reuse it. ++ * ++ * @return default arguments node ++ */ ++ public ArgumentCommandNode getDefaultArgs() { ++ return this.defaultArgs; ++ } ++ ++ /** ++ * Gets the {@link LiteralCommandNode} to be registered for the {@link Command}. ++ * ++ * @return the {@link LiteralCommandNode} ++ */ ++ public LiteralCommandNode getLiteral() { ++ return this.literal; ++ } ++ ++ /** ++ * Sets the {@link LiteralCommandNode} used to register this command. The default literal is mutable, so ++ * this is primarily if you want to completely replace the object. ++ * ++ * @param literal new node ++ */ ++ public void setLiteral(LiteralCommandNode literal) { ++ this.literal = literal; ++ } ++ ++ /** ++ * Gets whether this command should is treated as "raw". ++ * ++ * @see #setRawCommand(boolean) ++ * @return whether this command is treated as "raw" ++ */ ++ public boolean isRawCommand() { ++ return this.rawCommand; ++ } ++ ++ /** ++ * Sets whether this command should be treated as "raw". ++ * ++ *

A "raw" command will only use the node provided by this event for ++ * sending the command tree to the client. For execution purposes, the default ++ * greedy string execution of a standard Bukkit {@link Command} is used.

++ * ++ *

On older versions of Paper, this was the default and only behavior of this ++ * event.

++ * ++ * @param rawCommand whether this command should be treated as "raw" ++ */ ++ public void setRawCommand(final boolean rawCommand) { ++ this.rawCommand = rawCommand; ++ } ++ ++ /** ++ * {@inheritDoc} ++ */ ++ @Override ++ public boolean isCancelled() { ++ return this.cancelled; ++ } ++ ++ /** ++ * Cancels registering this command to Brigadier, but will remain in Bukkit Command Map. Can be used to hide a ++ * command from all players. ++ * ++ * {@inheritDoc} ++ */ ++ @Override ++ public void setCancelled(boolean cancel) { ++ this.cancelled = cancel; ++ } ++ ++ @NotNull ++ public HandlerList getHandlers() { ++ return handlers; ++ } ++ ++ @NotNull ++ public static HandlerList getHandlerList() { ++ return handlers; ++ } ++} +diff --git a/src/main/java/io/papermc/paper/brigadier/PaperBrigadier.java b/src/main/java/io/papermc/paper/brigadier/PaperBrigadier.java +new file mode 100644 +index 0000000000000000000000000000000000000000..9df87708206e26167a2c4934deff7fc6f1657106 +--- /dev/null ++++ b/src/main/java/io/papermc/paper/brigadier/PaperBrigadier.java +@@ -0,0 +1,47 @@ ++package io.papermc.paper.brigadier; ++ ++import com.mojang.brigadier.Message; ++import io.papermc.paper.command.brigadier.MessageComponentSerializer; ++import net.kyori.adventure.text.Component; ++import net.kyori.adventure.text.ComponentLike; ++import net.kyori.adventure.text.TextComponent; ++import org.checkerframework.checker.nullness.qual.NonNull; ++ ++/** ++ * Helper methods to bridge the gaps between Brigadier and Paper-MojangAPI. ++ * @deprecated for removal. See {@link MessageComponentSerializer} for a direct replacement of functionality found in ++ * this class. ++ * As a general entrypoint to brigadier on paper, see {@link io.papermc.paper.command.brigadier.Commands}. ++ */ ++@Deprecated(forRemoval = true, since = "1.20.6") ++public final class PaperBrigadier { ++ private PaperBrigadier() { ++ throw new RuntimeException("PaperBrigadier is not to be instantiated!"); ++ } ++ ++ /** ++ * Create a new Brigadier {@link Message} from a {@link ComponentLike}. ++ * ++ *

Mostly useful for creating rich suggestion tooltips in combination with other Paper-MojangAPI APIs.

++ * ++ * @param componentLike The {@link ComponentLike} to use for the {@link Message} contents ++ * @return A new Brigadier {@link Message} ++ */ ++ public static @NonNull Message message(final @NonNull ComponentLike componentLike) { ++ return MessageComponentSerializer.message().serialize(componentLike.asComponent()); ++ } ++ ++ /** ++ * Create a new {@link Component} from a Brigadier {@link Message}. ++ * ++ *

If the {@link Message} was created from a {@link Component}, it will simply be ++ * converted back, otherwise a new {@link TextComponent} will be created with the ++ * content of {@link Message#getString()}

++ * ++ * @param message The {@link Message} to create a {@link Component} from ++ * @return The created {@link Component} ++ */ ++ public static @NonNull Component componentFromMessage(final @NonNull Message message) { ++ return MessageComponentSerializer.message().deserialize(message); ++ } ++} diff --git a/patches/server/0282-Brigadier-Mojang-API.patch b/patches/server/0282-Brigadier-Mojang-API.patch index a406a36b2051b..5e4c8c55ffdbf 100644 --- a/patches/server/0282-Brigadier-Mojang-API.patch +++ b/patches/server/0282-Brigadier-Mojang-API.patch @@ -9,18 +9,6 @@ Adds AsyncPlayerSendCommandsEvent Adds CommandRegisteredEvent - Allows manipulating the CommandNode to add more children/metadata for the client -diff --git a/build.gradle.kts b/build.gradle.kts -index e9498f78cb6c0973a820f093ff7a31bef44ba27f..db2d67c98c62aa90591fea82e8fb07270699d96c 100644 ---- a/build.gradle.kts -+++ b/build.gradle.kts -@@ -13,6 +13,7 @@ val alsoShade: Configuration by configurations.creating - - dependencies { - implementation(project(":paper-api")) -+ implementation(project(":paper-mojangapi")) - // Paper start - implementation("org.jline:jline-terminal-jansi:3.21.0") - implementation("net.minecrell:terminalconsoleappender:1.3.0") diff --git a/src/main/java/com/mojang/brigadier/exceptions/CommandSyntaxException.java b/src/main/java/com/mojang/brigadier/exceptions/CommandSyntaxException.java index 3370731ee064d2693b972a0765c13dd4fd69f66a..09d486a05179b9d878e1c33725b4e614c3544da9 100644 --- a/src/main/java/com/mojang/brigadier/exceptions/CommandSyntaxException.java diff --git a/patches/server/0362-Implement-Mob-Goal-API.patch b/patches/server/0362-Implement-Mob-Goal-API.patch index 56f3af0c7361e..2e62f69cbb596 100644 --- a/patches/server/0362-Implement-Mob-Goal-API.patch +++ b/patches/server/0362-Implement-Mob-Goal-API.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Implement Mob Goal API diff --git a/build.gradle.kts b/build.gradle.kts -index db2d67c98c62aa90591fea82e8fb07270699d96c..7a70c2c52dec44d6b6c7acc7140b2619e56646d0 100644 +index 158779a3590f089c4224b2b128c2e653aef42a94..4f8b8839f4d345f448d30de21ad9f3ad7422f98b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -41,6 +41,7 @@ dependencies { +@@ -40,6 +40,7 @@ dependencies { runtimeOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.9.18") runtimeOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.9.18") @@ -773,7 +773,7 @@ index 6667ecc4b7eded4e20a415cef1e1b1179e6710b8..16f9a98b8a939e5ca7e2dc04f87134a7 LOOK, JUMP, diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index c62936e7070d794aeac7e5175757aa045a6afcae..82d462fbc8936b70169ca3b55d488e1ef76aec40 100644 +index 821e50c456679f69a9b6ae058f35b601bf3c759b..bd4c982ba919f0196723b4c45be102b47054a70f 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -2907,5 +2907,11 @@ public final class CraftServer implements Server { diff --git a/patches/server/0722-Add-support-for-Proxy-Protocol.patch b/patches/server/0722-Add-support-for-Proxy-Protocol.patch index 1ffaba0911656..fa64d53a927cf 100644 --- a/patches/server/0722-Add-support-for-Proxy-Protocol.patch +++ b/patches/server/0722-Add-support-for-Proxy-Protocol.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Add support for Proxy Protocol diff --git a/build.gradle.kts b/build.gradle.kts -index 7a70c2c52dec44d6b6c7acc7140b2619e56646d0..9b9e744d18cf66279f51f950b6ecce31415f9fa8 100644 +index 4f8b8839f4d345f448d30de21ad9f3ad7422f98b..1ed8d1ba75fa3a31469a6e8e3b661328b0debf12 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -28,6 +28,7 @@ dependencies { +@@ -27,6 +27,7 @@ dependencies { log4jPlugins.annotationProcessorConfigurationName("org.apache.logging.log4j:log4j-core:2.19.0") // Paper - Needed to generate meta for our Log4j plugins runtimeOnly(log4jPlugins.output) alsoShade(log4jPlugins.output) diff --git a/patches/server/1011-Use-Velocity-compression-and-cipher-natives.patch b/patches/server/1011-Use-Velocity-compression-and-cipher-natives.patch index 95f9b5544d0c0..713ad85d36419 100644 --- a/patches/server/1011-Use-Velocity-compression-and-cipher-natives.patch +++ b/patches/server/1011-Use-Velocity-compression-and-cipher-natives.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Use Velocity compression and cipher natives diff --git a/build.gradle.kts b/build.gradle.kts -index 9b9e744d18cf66279f51f950b6ecce31415f9fa8..5d448d8a7cf6626a11791f30ad52baf41a099272 100644 +index 1ed8d1ba75fa3a31469a6e8e3b661328b0debf12..87bb3fd9b97506f61734ae7f2e6860610ba794e7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -37,6 +37,11 @@ dependencies { +@@ -36,6 +36,11 @@ dependencies { runtimeOnly("org.xerial:sqlite-jdbc:3.45.3.0") runtimeOnly("com.mysql:mysql-connector-j:8.3.0") runtimeOnly("com.lmax:disruptor:3.4.4") // Paper diff --git a/settings.gradle.kts b/settings.gradle.kts index 706a83d5dd660..eb689c22d8b6f 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -33,7 +33,7 @@ if (!file(".git").exists()) { rootProject.name = "paper" -for (name in listOf("Paper-API", "Paper-Server", "Paper-MojangAPI")) { +for (name in listOf("Paper-API", "Paper-Server")) { val projName = name.lowercase(Locale.ENGLISH) include(projName) findProject(":$projName")!!.projectDir = file(name) diff --git a/test-plugin/build.gradle.kts b/test-plugin/build.gradle.kts index 3edf55f2883ff..9f7d9da599e68 100644 --- a/test-plugin/build.gradle.kts +++ b/test-plugin/build.gradle.kts @@ -2,7 +2,6 @@ version = "1.0.0-SNAPSHOT" dependencies { compileOnly(project(":paper-api")) - compileOnly(project(":paper-mojangapi")) } tasks.processResources {