mirror of
https://github.com/PaperMC/Waterfall.git
synced 2024-11-15 23:06:01 +01:00
25ecd402f3
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing BungeeCord Changes: 1a807731 #3567: Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.6.2 to 3.6.3 772ad995 #3566: Bump actions/setup-java from 3 to 4 2431c40a #3562: Bump io.netty:netty-bom from 4.1.100.Final to 4.1.101.Final 8144ae8d #3555: Bump com.mysql:mysql-connector-j from 8.1.0 to 8.2.0 0757c39a Attempt upgrade of resolver libraries
91 lines
3.7 KiB
Diff
91 lines
3.7 KiB
Diff
From 567777504ad1b5abb4388b7764945d9279c2f3b7 Mon Sep 17 00:00:00 2001
|
|
From: Shane Freeder <theboyetronic@gmail.com>
|
|
Date: Thu, 14 Mar 2019 07:44:06 +0000
|
|
Subject: [PATCH] Add ProxyDefineCommandsEvent
|
|
|
|
provides an event to allow plugins to intercept tab completions
|
|
sent to the client
|
|
|
|
diff --git a/api/src/main/java/io/github/waterfallmc/waterfall/event/ProxyDefineCommandsEvent.java b/api/src/main/java/io/github/waterfallmc/waterfall/event/ProxyDefineCommandsEvent.java
|
|
new file mode 100644
|
|
index 00000000..1fd4fc90
|
|
--- /dev/null
|
|
+++ b/api/src/main/java/io/github/waterfallmc/waterfall/event/ProxyDefineCommandsEvent.java
|
|
@@ -0,0 +1,41 @@
|
|
+package io.github.waterfallmc.waterfall.event;
|
|
+
|
|
+import net.md_5.bungee.api.CommandSender;
|
|
+import net.md_5.bungee.api.connection.Connection;
|
|
+import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
+import net.md_5.bungee.api.event.TargetedEvent;
|
|
+import net.md_5.bungee.api.plugin.Command;
|
|
+import net.md_5.bungee.api.plugin.Event;
|
|
+
|
|
+import java.util.Map;
|
|
+
|
|
+import lombok.Data;
|
|
+import lombok.EqualsAndHashCode;
|
|
+import lombok.ToString;
|
|
+
|
|
+/**
|
|
+ * Called when the proxy intercepts the command packet
|
|
+ * allowing for plugins to prevent commands being added
|
|
+ * to the clients which might not be wanted.
|
|
+ *
|
|
+ *
|
|
+ * <i>Plugin developers, please implement {@link Command#hasPermission(CommandSender)}
|
|
+ * properly in favor of this event.</i>
|
|
+ */
|
|
+@Data
|
|
+@ToString(callSuper = true)
|
|
+@EqualsAndHashCode(callSuper = true)
|
|
+public class ProxyDefineCommandsEvent extends TargetedEvent {
|
|
+
|
|
+
|
|
+ /**
|
|
+ * The map of commands to be sent to the player
|
|
+ */
|
|
+ private final Map<String, Command> commands;
|
|
+
|
|
+ public ProxyDefineCommandsEvent(Connection sender, Connection receiver, Map<String, Command> commands) {
|
|
+ super(sender, receiver);
|
|
+ this.commands = commands;
|
|
+ }
|
|
+
|
|
+}
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
|
|
index 249c3f46..42232443 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
|
|
@@ -792,9 +792,25 @@ public class DownstreamBridge extends PacketHandler
|
|
{
|
|
boolean modified = false;
|
|
|
|
- for ( Map.Entry<String, Command> command : bungee.getPluginManager().getCommands() )
|
|
+ // Waterfall start
|
|
+ Map<String, Command> commandMap = new java.util.HashMap<>();
|
|
+ for ( Map.Entry<String, Command> commandEntry : bungee.getPluginManager().getCommands() ) {
|
|
+ if ( !bungee.getDisabledCommands().contains( commandEntry.getKey() )
|
|
+ && commands.getRoot().getChild( commandEntry.getKey() ) == null
|
|
+ && commandEntry.getValue().hasPermission( this.con ) ) {
|
|
+
|
|
+ commandMap.put( commandEntry.getKey(), commandEntry.getValue() );
|
|
+ }
|
|
+ }
|
|
+
|
|
+ io.github.waterfallmc.waterfall.event.ProxyDefineCommandsEvent event = new io.github.waterfallmc.waterfall.event.ProxyDefineCommandsEvent( this.server, this.con, commandMap );
|
|
+ bungee.getPluginManager().callEvent( event );
|
|
+
|
|
+ for ( Map.Entry<String, Command> command : event.getCommands().entrySet() )
|
|
{
|
|
- if ( !bungee.getDisabledCommands().contains( command.getKey() ) && commands.getRoot().getChild( command.getKey() ) == null && command.getValue().hasPermission( con ) )
|
|
+ //noinspection ConstantConditions
|
|
+ if ( true ) // Moved up
|
|
+ // Waterfall end
|
|
{
|
|
CommandNode dummy = LiteralArgumentBuilder.literal( command.getKey() ).executes( DUMMY_COMMAND )
|
|
.then( RequiredArgumentBuilder.argument( "args", StringArgumentType.greedyString() )
|
|
--
|
|
2.43.0
|
|
|