3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-12-23 23:00:35 +01:00

Merge branch 'dev/1.1.0' into decode-multiple

Dieser Commit ist enthalten in:
Andrew Steinborn 2020-05-29 19:03:03 -04:00
Commit 9f6d8e1840
3 geänderte Dateien mit 44 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -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}"

Datei anzeigen

@ -0,0 +1,37 @@
package com.velocitypowered.api.event.command;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.Beta;
import com.mojang.brigadier.tree.RootCommandNode;
import com.velocitypowered.api.proxy.Player;
/**
* Allows plugins to modify the packet indicating commands available on the server to a
* Minecraft 1.13+ client.
*/
@Beta
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;
}
}

Datei anzeigen

@ -7,6 +7,7 @@ import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
import com.mojang.brigadier.tree.LiteralCommandNode;
import com.velocitypowered.api.event.command.PlayerAvailableCommandsEvent;
import com.velocitypowered.api.event.connection.PluginMessageEvent;
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
import com.velocitypowered.proxy.VelocityServer;
@ -175,7 +176,11 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
.build();
commands.getRootNode().addChild(root);
}
return false;
server.getEventManager().fire(
new PlayerAvailableCommandsEvent(serverConn.getPlayer(), commands.getRootNode()))
.thenAcceptAsync(event -> playerConnection.write(commands), playerConnection.eventLoop());
return true;
}
@Override