Allow plugins to mutate available commands sent to the client.

This is the first unstable API being introduced and is primarily to get feedback on the system.
This commit is contained in:
Andrew Steinborn
2020-05-28 07:14:49 -04:00
parent 305949487e
commit cb99b184ed
3 changed files with 44 additions and 1 deletions

View File

@@ -26,6 +26,7 @@ dependencies {
compile "org.slf4j:slf4j-api:${slf4jVersion}"
compile 'com.google.inject:guice:4.2.2'
compile "org.checkerframework:checker-qual:${checkerFrameworkVersion}"
compile 'com.mojang:brigadier:1.0.17'
compile "org.spongepowered:configurate-hocon:${configurateVersion}"
compile "org.spongepowered:configurate-yaml:${configurateVersion}"

View File

@@ -0,0 +1,37 @@
package com.velocitypowered.api.event.command;
import static com.google.common.base.Preconditions.checkNotNull;
import com.mojang.brigadier.tree.RootCommandNode;
import com.velocitypowered.api.annotations.UnstableApi;
import com.velocitypowered.api.proxy.Player;
/**
* Allows plugins to modify the packet indicating commands available on the server to a
* Minecraft 1.13+ client.
*/
@UnstableApi
public class PlayerAvailableCommandsEvent {
private final Player player;
private final RootCommandNode<?> rootNode;
/**
* Constructs an available commands event.
* @param player the targeted player
* @param rootNode the Brigadier root node
*/
public PlayerAvailableCommandsEvent(Player player,
RootCommandNode<?> rootNode) {
this.player = checkNotNull(player, "player");
this.rootNode = checkNotNull(rootNode, "rootNode");
}
public Player getPlayer() {
return player;
}
public RootCommandNode<?> getRootNode() {
return rootNode;
}
}