mirror of
https://github.com/PaperMC/Waterfall.git
synced 2025-01-03 22:47:38 +01:00
Implement full console command completion
Drop the original console command completion patch and rewrite it for JLine 3. Add support to complete command names instead of just command arguments. The additional single thread executor for command completion was dropped because it's redundant: since the command completer needs to wait for it to complete anyway, we might as well do the completion directly from the console thread.
This commit is contained in:
parent
ab5021987d
commit
d3dc2d3748
@ -1,4 +1,4 @@
|
||||
From 5e8db527fef5b35b6ac96b4be5b41aae8a5ede9c Mon Sep 17 00:00:00 2001
|
||||
From 1a06b2d13126b3873c8b3395c33db92b5e2d4821 Mon Sep 17 00:00:00 2001
|
||||
From: Troy Frew <fuzzy_bot@arenaga.me>
|
||||
Date: Wed, 29 Jun 2016 04:29:25 +0200
|
||||
Subject: [PATCH] Add dynamic server addition/removal api.
|
||||
@ -8,7 +8,7 @@ The provided methods will not move a player if a server is removed or the server
|
||||
Thanks to Overcast for the idea
|
||||
|
||||
diff --git a/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java b/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java
|
||||
index 5a49050..f04e2bf 100644
|
||||
index 5a49050a..f04e2bf4 100644
|
||||
--- a/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java
|
||||
+++ b/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java
|
||||
@@ -32,9 +32,83 @@ public interface ProxyConfig
|
||||
@ -96,7 +96,7 @@ index 5a49050..f04e2bf 100644
|
||||
* Does the server authenticate with mojang
|
||||
*/
|
||||
diff --git a/api/src/main/java/net/md_5/bungee/api/ProxyServer.java b/api/src/main/java/net/md_5/bungee/api/ProxyServer.java
|
||||
index 11c5b68..1c011d0 100644
|
||||
index 11c5b685..1c011d08 100644
|
||||
--- a/api/src/main/java/net/md_5/bungee/api/ProxyServer.java
|
||||
+++ b/api/src/main/java/net/md_5/bungee/api/ProxyServer.java
|
||||
@@ -93,9 +93,25 @@ public abstract class ProxyServer
|
||||
@ -126,7 +126,7 @@ index 11c5b68..1c011d0 100644
|
||||
* Gets the server info of a server.
|
||||
*
|
||||
diff --git a/config/src/main/java/net/md_5/bungee/config/Configuration.java b/config/src/main/java/net/md_5/bungee/config/Configuration.java
|
||||
index 967a1b2..08aa698 100644
|
||||
index 967a1b2a..08aa6981 100644
|
||||
--- a/config/src/main/java/net/md_5/bungee/config/Configuration.java
|
||||
+++ b/config/src/main/java/net/md_5/bungee/config/Configuration.java
|
||||
@@ -44,6 +44,13 @@ public final class Configuration
|
||||
@ -144,10 +144,10 @@ index 967a1b2..08aa698 100644
|
||||
{
|
||||
int index = path.indexOf( SEPARATOR );
|
||||
diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
||||
index a5d63d6..a446b09 100644
|
||||
index 952a1fe8..cb9a58fc 100644
|
||||
--- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
||||
+++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
||||
@@ -570,10 +570,18 @@ public class BungeeCord extends ProxyServer
|
||||
@@ -569,10 +569,18 @@ public class BungeeCord extends ProxyServer
|
||||
return config.getServers();
|
||||
}
|
||||
|
||||
@ -168,7 +168,7 @@ index a5d63d6..a446b09 100644
|
||||
|
||||
@Override
|
||||
diff --git a/proxy/src/main/java/net/md_5/bungee/conf/Configuration.java b/proxy/src/main/java/net/md_5/bungee/conf/Configuration.java
|
||||
index b3ff144..669720a 100644
|
||||
index d131c02c..a755121a 100644
|
||||
--- a/proxy/src/main/java/net/md_5/bungee/conf/Configuration.java
|
||||
+++ b/proxy/src/main/java/net/md_5/bungee/conf/Configuration.java
|
||||
@@ -1,6 +1,7 @@
|
||||
@ -285,5 +285,5 @@ index b3ff144..669720a 100644
|
||||
+ // Waterfall end
|
||||
}
|
||||
--
|
||||
2.7.4 (Apple Git-66)
|
||||
2.14.1
|
||||
|
@ -1,99 +0,0 @@
|
||||
From 1ec9c98ab715ee1884239da6c0e3b4957235ed46 Mon Sep 17 00:00:00 2001
|
||||
From: Mystiflow <mystiflow@gmail.com>
|
||||
Date: Sun, 14 Feb 2016 15:54:40 +0000
|
||||
Subject: [PATCH] Allow the console to tab complete commands
|
||||
|
||||
|
||||
diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
||||
index 9d7a25ab..8a4b2283 100644
|
||||
--- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
||||
+++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
||||
@@ -210,6 +210,7 @@ public class BungeeCord extends ProxyServer
|
||||
AnsiConsole.systemInstall();
|
||||
consoleReader = new ConsoleReader();
|
||||
consoleReader.setExpandEvents( false );
|
||||
+ consoleReader.addCompleter( new ConsoleCommandCompleter( this ) );
|
||||
|
||||
logger = new BungeeLogger( "BungeeCord", System.getProperty("bungee.log-file", "proxy.log"), consoleReader );
|
||||
System.setErr( new PrintStream( new LoggingOutputStream( logger, Level.SEVERE ), true ) );
|
||||
diff --git a/proxy/src/main/java/net/md_5/bungee/ConsoleCommandCompleter.java b/proxy/src/main/java/net/md_5/bungee/ConsoleCommandCompleter.java
|
||||
new file mode 100644
|
||||
index 00000000..455b0787
|
||||
--- /dev/null
|
||||
+++ b/proxy/src/main/java/net/md_5/bungee/ConsoleCommandCompleter.java
|
||||
@@ -0,0 +1,72 @@
|
||||
+package net.md_5.bungee;
|
||||
+
|
||||
+import com.google.common.collect.Iterables;
|
||||
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
+import jline.console.completer.Completer;
|
||||
+import net.md_5.bungee.api.ProxyServer;
|
||||
+
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.List;
|
||||
+import java.util.concurrent.Callable;
|
||||
+import java.util.concurrent.ExecutionException;
|
||||
+import java.util.concurrent.ExecutorService;
|
||||
+import java.util.concurrent.Executors;
|
||||
+import java.util.concurrent.Future;
|
||||
+import java.util.logging.Level;
|
||||
+
|
||||
+public class ConsoleCommandCompleter implements Completer
|
||||
+{
|
||||
+
|
||||
+ private final ExecutorService executor = Executors.newSingleThreadExecutor(
|
||||
+ new ThreadFactoryBuilder().setNameFormat( "Console Command Completer Thread - %1$d" ).build() );
|
||||
+
|
||||
+ private final ProxyServer proxy;
|
||||
+
|
||||
+ public ConsoleCommandCompleter( ProxyServer proxy )
|
||||
+ {
|
||||
+ this.proxy = proxy;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int complete( String buffer, int cursor, List<CharSequence> candidates )
|
||||
+ {
|
||||
+ Future<Iterable<String>> future = executor.submit( new Callable<Iterable<String>>()
|
||||
+ {
|
||||
+ @Override
|
||||
+ public Iterable<String> call() throws Exception
|
||||
+ {
|
||||
+ List<String> results = new ArrayList<>();
|
||||
+ proxy.getPluginManager().dispatchCommand( proxy.getConsole(), buffer, results );
|
||||
+ return results;
|
||||
+ }
|
||||
+ } );
|
||||
+
|
||||
+ try
|
||||
+ {
|
||||
+ Iterable<String> offers = future.get();
|
||||
+ if ( offers == null )
|
||||
+ {
|
||||
+ return cursor;
|
||||
+ }
|
||||
+
|
||||
+ Iterables.addAll( candidates, offers );
|
||||
+
|
||||
+ final int lastSpace = buffer.lastIndexOf( ' ' );
|
||||
+ if ( lastSpace == -1 )
|
||||
+ {
|
||||
+ return cursor - buffer.length();
|
||||
+ } else
|
||||
+ {
|
||||
+ return cursor - ( buffer.length() - lastSpace - 1 );
|
||||
+ }
|
||||
+ } catch ( ExecutionException ex )
|
||||
+ {
|
||||
+ proxy.getLogger().log( Level.WARNING, "Unhandled exception when tab completing", ex );
|
||||
+ } catch ( InterruptedException ex )
|
||||
+ {
|
||||
+ Thread.currentThread().interrupt();
|
||||
+ }
|
||||
+
|
||||
+ return cursor;
|
||||
+ }
|
||||
+}
|
||||
--
|
||||
2.12.0
|
||||
|
@ -1,4 +1,4 @@
|
||||
From b48386b19c09d782f6474f759f0805232741710d Mon Sep 17 00:00:00 2001
|
||||
From 98d47da42ffb889bcba6546fbdcd3f3b48b504fc Mon Sep 17 00:00:00 2001
|
||||
From: Techcable <Techcable@techcable.net>
|
||||
Date: Mon, 6 Jun 2016 13:36:10 -0600
|
||||
Subject: [PATCH] Don't send KICK packets while in HANDSHAKE state
|
||||
@ -27,5 +27,5 @@ index bf450f98..9e501c00 100644
|
||||
ch.delayedClose( new Kick( ComponentSerializer.toString( reason ) ) );
|
||||
} else
|
||||
--
|
||||
2.13.4
|
||||
2.14.1
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 55096ef5dba0f4d8a11db03b2a757f0245429193 Mon Sep 17 00:00:00 2001
|
||||
From 10c501498457416b64ead41ca3aed3a22cbc6675 Mon Sep 17 00:00:00 2001
|
||||
From: Nathan Poirier <nathan@poirier.io>
|
||||
Date: Tue, 28 Jun 2016 23:00:49 -0500
|
||||
Subject: [PATCH] Improve ServerKickEvent
|
||||
@ -75,7 +75,7 @@ index 79e88cc5..38361c2b 100644
|
||||
{
|
||||
// Pre cancel the event if we are going to try another server
|
||||
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 c2e751be..0d8ae30f 100644
|
||||
index dcd6924d..de905b83 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
|
||||
@@ -4,6 +4,7 @@ import com.google.common.base.Preconditions;
|
@ -1,11 +1,11 @@
|
||||
From d22587da29905588035c8bd58a039b49ed7dc049 Mon Sep 17 00:00:00 2001
|
||||
From 11d3fad8b239a4cc4535dfa7bf58127f99effcef Mon Sep 17 00:00:00 2001
|
||||
From: Troy Frew <fuzzy_bot@arenaga.me>
|
||||
Date: Wed, 29 Jun 2016 13:56:57 -0500
|
||||
Subject: [PATCH] Configurable server version in ping response
|
||||
|
||||
|
||||
diff --git a/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java b/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java
|
||||
index f04e2bf..a443614 100644
|
||||
index f04e2bf4..a4436141 100644
|
||||
--- a/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java
|
||||
+++ b/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java
|
||||
@@ -168,6 +168,11 @@ public interface ProxyConfig
|
||||
@ -21,7 +21,7 @@ index f04e2bf..a443614 100644
|
||||
|
||||
/**
|
||||
diff --git a/proxy/src/main/java/io/github/waterfallmc/waterfall/conf/WaterfallConfiguration.java b/proxy/src/main/java/io/github/waterfallmc/waterfall/conf/WaterfallConfiguration.java
|
||||
index 68f2546..5983581 100644
|
||||
index 68f25460..59835815 100644
|
||||
--- a/proxy/src/main/java/io/github/waterfallmc/waterfall/conf/WaterfallConfiguration.java
|
||||
+++ b/proxy/src/main/java/io/github/waterfallmc/waterfall/conf/WaterfallConfiguration.java
|
||||
@@ -4,8 +4,11 @@ import lombok.*;
|
||||
@ -59,10 +59,10 @@ index 68f2546..5983581 100644
|
||||
|
||||
@Override
|
||||
diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
||||
index a446b09..60f3925 100644
|
||||
index cb9a58fc..f23288f4 100644
|
||||
--- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
||||
+++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
||||
@@ -619,7 +619,7 @@ public class BungeeCord extends ProxyServer
|
||||
@@ -618,7 +618,7 @@ public class BungeeCord extends ProxyServer
|
||||
@Override
|
||||
public String getGameVersion()
|
||||
{
|
||||
@ -72,5 +72,5 @@ index a446b09..60f3925 100644
|
||||
|
||||
@Override
|
||||
--
|
||||
2.7.4 (Apple Git-66)
|
||||
2.14.1
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 728532bc0e6953a2b212e4da09e0ec54bd3a1955 Mon Sep 17 00:00:00 2001
|
||||
From 08bb549760fa6d35bcbc1af98240459fc27efb6a Mon Sep 17 00:00:00 2001
|
||||
From: Ichbinjoe <joe@ibj.io>
|
||||
Date: Sat, 16 Jul 2016 20:44:01 -0400
|
||||
Subject: [PATCH] Add timeout variant to connect methods
|
@ -1,4 +1,4 @@
|
||||
From 525fdfdfc386c3fb335f162ad1c665bd8406669d Mon Sep 17 00:00:00 2001
|
||||
From 0497395a9022b1969c5a7b22514e147091a85311 Mon Sep 17 00:00:00 2001
|
||||
From: minecrafter <unknown@unknown>
|
||||
Date: Sun, 3 Jul 2016 04:03:21 -0400
|
||||
Subject: [PATCH] Proxy query event
|
||||
@ -6,7 +6,7 @@ Subject: [PATCH] Proxy query event
|
||||
|
||||
diff --git a/api/src/main/java/io/github/waterfallmc/waterfall/QueryResult.java b/api/src/main/java/io/github/waterfallmc/waterfall/QueryResult.java
|
||||
new file mode 100644
|
||||
index 0000000..1e33cd1
|
||||
index 00000000..1e33cd19
|
||||
--- /dev/null
|
||||
+++ b/api/src/main/java/io/github/waterfallmc/waterfall/QueryResult.java
|
||||
@@ -0,0 +1,62 @@
|
||||
@ -74,7 +74,7 @@ index 0000000..1e33cd1
|
||||
+}
|
||||
diff --git a/api/src/main/java/io/github/waterfallmc/waterfall/event/ProxyQueryEvent.java b/api/src/main/java/io/github/waterfallmc/waterfall/event/ProxyQueryEvent.java
|
||||
new file mode 100644
|
||||
index 0000000..220d59f
|
||||
index 00000000..220d59f0
|
||||
--- /dev/null
|
||||
+++ b/api/src/main/java/io/github/waterfallmc/waterfall/event/ProxyQueryEvent.java
|
||||
@@ -0,0 +1,28 @@
|
||||
@ -107,7 +107,7 @@ index 0000000..220d59f
|
||||
+ private QueryResult result;
|
||||
+}
|
||||
diff --git a/query/src/main/java/net/md_5/bungee/query/QueryHandler.java b/query/src/main/java/net/md_5/bungee/query/QueryHandler.java
|
||||
index 614dd94..8d28867 100644
|
||||
index 79d6886a..a72cfd92 100644
|
||||
--- a/query/src/main/java/net/md_5/bungee/query/QueryHandler.java
|
||||
+++ b/query/src/main/java/net/md_5/bungee/query/QueryHandler.java
|
||||
@@ -2,6 +2,8 @@ package net.md_5.bungee.query;
|
||||
@ -214,5 +214,5 @@ index 614dd94..8d28867 100644
|
||||
} else
|
||||
{
|
||||
--
|
||||
2.10.0
|
||||
2.14.1
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 5f8c4b7ed6415798499ade8311473717685ac93f Mon Sep 17 00:00:00 2001
|
||||
From 7697b2135fd87a5e280b75a9fe9bc5a61ce6d3b7 Mon Sep 17 00:00:00 2001
|
||||
From: Techcable <Techcable@techcable.net>
|
||||
Date: Thu, 4 Aug 2016 19:30:49 -0700
|
||||
Subject: [PATCH] Dump the raw hex of a packet on a decoding error
|
||||
@ -53,5 +53,5 @@ index 447eaae7..0b780e2e 100644
|
||||
{
|
||||
if ( slice != null )
|
||||
--
|
||||
2.11.0
|
||||
2.14.1
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 066f5b27e7c360d88363420dfb72c31030318975 Mon Sep 17 00:00:00 2001
|
||||
From 4caf149392f27d94afea5b2636b7e7f6c3010bec Mon Sep 17 00:00:00 2001
|
||||
From: Aaron Hill <aa1ronham@gmail.com>
|
||||
Date: Thu, 15 Sep 2016 22:38:37 +0200
|
||||
Subject: [PATCH] Fix potion race condition on Forge 1.8.9
|
@ -1,4 +1,4 @@
|
||||
From 2ea46da982edc6ff0c8e60c7d47f57c89ac1193c Mon Sep 17 00:00:00 2001
|
||||
From efc2b1364b45ef31545017819c23775e0ad31f41 Mon Sep 17 00:00:00 2001
|
||||
From: Tux <write@imaginarycode.com>
|
||||
Date: Wed, 21 Dec 2016 03:13:03 -0500
|
||||
Subject: [PATCH] Optionally use async Netty DNS resolver
|
||||
@ -157,7 +157,7 @@ index 2feb4d66..b265bb43 100644
|
||||
+ // Waterfall End
|
||||
}
|
||||
diff --git a/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java b/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java
|
||||
index 81927f7f..4e0ae3dc 100644
|
||||
index 0cad5c89..3af6a1db 100644
|
||||
--- a/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java
|
||||
+++ b/proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java
|
||||
@@ -112,7 +112,7 @@ public class PipelineUtils
|
@ -1,4 +1,4 @@
|
||||
From 55ff4996e61c50acad85f3e3609c6563e2acc3ee Mon Sep 17 00:00:00 2001
|
||||
From 31b6661d262db0de374de7b35bef7d83913ad8e8 Mon Sep 17 00:00:00 2001
|
||||
From: Tux <write@imaginarycode.com>
|
||||
Date: Wed, 21 Dec 2016 04:07:26 -0500
|
||||
Subject: [PATCH] Security enhancements for EncryptionUtil
|
||||
@ -6,7 +6,7 @@ Subject: [PATCH] Security enhancements for EncryptionUtil
|
||||
Use a constant-time comparison in getSecret() and use SecureRandom for EncryptionRequest.
|
||||
|
||||
diff --git a/proxy/src/main/java/net/md_5/bungee/EncryptionUtil.java b/proxy/src/main/java/net/md_5/bungee/EncryptionUtil.java
|
||||
index 871e4ad..622a21d 100644
|
||||
index 871e4ad0..622a21da 100644
|
||||
--- a/proxy/src/main/java/net/md_5/bungee/EncryptionUtil.java
|
||||
+++ b/proxy/src/main/java/net/md_5/bungee/EncryptionUtil.java
|
||||
@@ -27,7 +27,7 @@ import net.md_5.bungee.protocol.packet.EncryptionRequest;
|
||||
@ -28,5 +28,5 @@ index 871e4ad..622a21d 100644
|
||||
throw new IllegalStateException( "Key pairs do not match!" );
|
||||
}
|
||||
--
|
||||
2.7.4
|
||||
2.14.1
|
||||
|
@ -1,4 +1,4 @@
|
||||
From f63e39c39c6bb7705cfe798189a01579beab115a Mon Sep 17 00:00:00 2001
|
||||
From edd32b49c7f0183aa11cad5dcb660900cf3420b0 Mon Sep 17 00:00:00 2001
|
||||
From: Jamie Mansfield <dev@jamierocks.uk>
|
||||
Date: Sat, 10 Jun 2017 20:56:02 +0100
|
||||
Subject: [PATCH] Improve outdated build message
|
||||
@ -22,5 +22,5 @@ index 8766e04b..ce1dd7a3 100644
|
||||
Thread.sleep( TimeUnit.SECONDS.toMillis( 10 ) );
|
||||
}
|
||||
--
|
||||
2.13.0
|
||||
2.14.1
|
||||
|
@ -1,4 +1,4 @@
|
||||
From eb1a75325f83a7eabb72d503f6438fecd65bfd98 Mon Sep 17 00:00:00 2001
|
||||
From dbbaeb6cf456ef94b5dba1bc5461ff69b3617838 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Naylor <git@drnaylor.co.uk>
|
||||
Date: Mon, 17 Jul 2017 20:24:17 +0100
|
||||
Subject: [PATCH] Fix some forge plugin message packets not being forwarded
|
||||
@ -55,5 +55,5 @@ index 3fe5ec5f..a0c07874 100644
|
||||
synchronized ( packetQueue )
|
||||
{
|
||||
--
|
||||
2.11.0
|
||||
2.14.1
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 51290fa75163f0f8ddcb508aa0b0aa20ffb00db1 Mon Sep 17 00:00:00 2001
|
||||
From d125a3031c8ddab6f9b4dff4e02a366bdea56335 Mon Sep 17 00:00:00 2001
|
||||
From: Minecrell <dev@minecrell.net>
|
||||
Date: Fri, 22 Sep 2017 12:46:47 +0200
|
||||
Subject: [PATCH] Use Log4j2 for logging and TerminalConsoleAppender for
|
||||
@ -28,7 +28,7 @@ index 7bc2dff7..6e8dd81e 100644
|
||||
</plugins>
|
||||
</build>
|
||||
diff --git a/bootstrap/src/main/java/net/md_5/bungee/BungeeCordLauncher.java b/bootstrap/src/main/java/net/md_5/bungee/BungeeCordLauncher.java
|
||||
index ce1dd7a3..3d09b86a 100644
|
||||
index ce1dd7a3..af4c024e 100644
|
||||
--- a/bootstrap/src/main/java/net/md_5/bungee/BungeeCordLauncher.java
|
||||
+++ b/bootstrap/src/main/java/net/md_5/bungee/BungeeCordLauncher.java
|
||||
@@ -56,6 +56,9 @@ public class BungeeCordLauncher
|
||||
@ -36,7 +36,7 @@ index ce1dd7a3..3d09b86a 100644
|
||||
if ( !options.has( "noconsole" ) )
|
||||
{
|
||||
+ // Waterfall start - Use TerminalConsoleAppender
|
||||
+ io.github.waterfallmc.waterfall.WaterfallConsole.readCommands();
|
||||
+ io.github.waterfallmc.waterfall.console.WaterfallConsole.readCommands();
|
||||
+ /*
|
||||
String line;
|
||||
while ( bungee.isRunning && ( line = bungee.getConsoleReader().readLine( ">" ) ) != null )
|
||||
@ -274,7 +274,7 @@ index 1a5d036d..78326e6c 100644
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
diff --git a/proxy/src/main/java/Test.java b/proxy/src/main/java/Test.java
|
||||
index 446dfe2f..7e7841a3 100644
|
||||
index 446dfe2f..c3cb5aaa 100644
|
||||
--- a/proxy/src/main/java/Test.java
|
||||
+++ b/proxy/src/main/java/Test.java
|
||||
@@ -22,6 +22,9 @@ public class Test
|
||||
@ -282,31 +282,29 @@ index 446dfe2f..7e7841a3 100644
|
||||
bungee.start();
|
||||
|
||||
+ // Waterfall start - Use TerminalConsoleAppender
|
||||
+ io.github.waterfallmc.waterfall.WaterfallConsole.readCommands();
|
||||
+ io.github.waterfallmc.waterfall.console.WaterfallConsole.readCommands();
|
||||
+ /*
|
||||
while ( bungee.isRunning )
|
||||
{
|
||||
String line = bungee.getConsoleReader().readLine( ">" );
|
||||
@@ -32,6 +35,7 @@ public class Test
|
||||
bungee.getConsole().sendMessage( ChatColor.RED + "Command not found" );
|
||||
@@ -33,5 +36,7 @@ public class Test
|
||||
}
|
||||
}
|
||||
- }
|
||||
+ }*/
|
||||
}
|
||||
+ */
|
||||
+ // Waterfall end
|
||||
}
|
||||
}
|
||||
diff --git a/proxy/src/main/java/io/github/waterfallmc/waterfall/WaterfallConsole.java b/proxy/src/main/java/io/github/waterfallmc/waterfall/WaterfallConsole.java
|
||||
diff --git a/proxy/src/main/java/io/github/waterfallmc/waterfall/console/WaterfallConsole.java b/proxy/src/main/java/io/github/waterfallmc/waterfall/console/WaterfallConsole.java
|
||||
new file mode 100644
|
||||
index 00000000..ed33462e
|
||||
index 00000000..a8a94749
|
||||
--- /dev/null
|
||||
+++ b/proxy/src/main/java/io/github/waterfallmc/waterfall/WaterfallConsole.java
|
||||
@@ -0,0 +1,95 @@
|
||||
+package io.github.waterfallmc.waterfall;
|
||||
+++ b/proxy/src/main/java/io/github/waterfallmc/waterfall/console/WaterfallConsole.java
|
||||
@@ -0,0 +1,93 @@
|
||||
+package io.github.waterfallmc.waterfall.console;
|
||||
+
|
||||
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
+import net.md_5.bungee.BungeeCord;
|
||||
+import net.md_5.bungee.ConsoleCommandCompleter;
|
||||
+import net.md_5.bungee.api.ChatColor;
|
||||
+import net.md_5.bungee.api.ProxyServer;
|
||||
+import net.minecrell.terminalconsole.TerminalConsoleAppender;
|
||||
@ -356,7 +354,6 @@ index 00000000..ed33462e
|
||||
+ final LineReader reader = LineReaderBuilder.builder()
|
||||
+ .appName(ProxyServer.getInstance().getName())
|
||||
+ .terminal(terminal)
|
||||
+ .completer(new ConsoleCommandCompleter(bungee))
|
||||
+ .build();
|
||||
+
|
||||
+ reader.unsetOpt(LineReader.Option.INSERT_TAB);
|
||||
@ -398,7 +395,7 @@ index 00000000..ed33462e
|
||||
+
|
||||
+}
|
||||
diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
||||
index 5e9484b7..b5d81439 100644
|
||||
index f23288f4..0a69d24e 100644
|
||||
--- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
||||
+++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
|
||||
@@ -45,7 +45,6 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
@ -448,7 +445,7 @@ index 5e9484b7..b5d81439 100644
|
||||
// This is a workaround for quite possibly the weirdest bug I have ever encountered in my life!
|
||||
// When jansi attempts to extract its natives, by default it tries to extract a specific version,
|
||||
// using the loading class's implementation version. Normally this works completely fine,
|
||||
@@ -215,6 +217,9 @@ public class BungeeCord extends ProxyServer
|
||||
@@ -214,6 +216,9 @@ public class BungeeCord extends ProxyServer
|
||||
logger = new BungeeLogger( "BungeeCord", System.getProperty("bungee.log-file", "proxy.log"), consoleReader );
|
||||
System.setErr( new PrintStream( new LoggingOutputStream( logger, Level.SEVERE ), true ) );
|
||||
System.setOut( new PrintStream( new LoggingOutputStream( logger, Level.INFO ), true ) );
|
||||
@ -458,59 +455,6 @@ index 5e9484b7..b5d81439 100644
|
||||
|
||||
if ( !Boolean.getBoolean( "net.md_5.bungee.native.disable" ) )
|
||||
{
|
||||
diff --git a/proxy/src/main/java/net/md_5/bungee/ConsoleCommandCompleter.java b/proxy/src/main/java/net/md_5/bungee/ConsoleCommandCompleter.java
|
||||
index 455b0787..9b57fc48 100644
|
||||
--- a/proxy/src/main/java/net/md_5/bungee/ConsoleCommandCompleter.java
|
||||
+++ b/proxy/src/main/java/net/md_5/bungee/ConsoleCommandCompleter.java
|
||||
@@ -2,7 +2,7 @@ package net.md_5.bungee;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
-import jline.console.completer.Completer;
|
||||
+import org.jline.reader.Completer; // Waterfall - Update to JLine 3
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -28,8 +28,9 @@ public class ConsoleCommandCompleter implements Completer
|
||||
}
|
||||
|
||||
@Override
|
||||
- public int complete( String buffer, int cursor, List<CharSequence> candidates )
|
||||
+ public void complete( org.jline.reader.LineReader reader, org.jline.reader.ParsedLine line, List<org.jline.reader.Candidate> candidates ) // Waterfall
|
||||
{
|
||||
+ final String buffer = line.line(); // Waterfall
|
||||
Future<Iterable<String>> future = executor.submit( new Callable<Iterable<String>>()
|
||||
{
|
||||
@Override
|
||||
@@ -44,6 +45,11 @@ public class ConsoleCommandCompleter implements Completer
|
||||
try
|
||||
{
|
||||
Iterable<String> offers = future.get();
|
||||
+ // Waterfall start - Update to JLine 3
|
||||
+ for (String completion : offers) {
|
||||
+ candidates.add(new org.jline.reader.Candidate(completion));
|
||||
+ }
|
||||
+ /*
|
||||
if ( offers == null )
|
||||
{
|
||||
return cursor;
|
||||
@@ -59,6 +65,8 @@ public class ConsoleCommandCompleter implements Completer
|
||||
{
|
||||
return cursor - ( buffer.length() - lastSpace - 1 );
|
||||
}
|
||||
+ */
|
||||
+ // Waterfall end
|
||||
} catch ( ExecutionException ex )
|
||||
{
|
||||
proxy.getLogger().log( Level.WARNING, "Unhandled exception when tab completing", ex );
|
||||
@@ -67,6 +75,6 @@ public class ConsoleCommandCompleter implements Completer
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
|
||||
- return cursor;
|
||||
+ //return cursor; // Waterfall
|
||||
}
|
||||
}
|
||||
diff --git a/proxy/src/main/java/net/md_5/bungee/module/ModuleManager.java b/proxy/src/main/java/net/md_5/bungee/module/ModuleManager.java
|
||||
index 901fc5a3..8bb88bd4 100644
|
||||
--- a/proxy/src/main/java/net/md_5/bungee/module/ModuleManager.java
|
@ -1,4 +1,4 @@
|
||||
From 135570bf38bcf55248ff39becce8e8af625a0a13 Mon Sep 17 00:00:00 2001
|
||||
From c71a21cf7a460fe1aa7bdc2d4a58892e264b550f Mon Sep 17 00:00:00 2001
|
||||
From: Minecrell <dev@minecrell.net>
|
||||
Date: Fri, 22 Sep 2017 13:07:31 +0200
|
||||
Subject: [PATCH] Handle plugin prefixes using Log4J
|
@ -1,4 +1,4 @@
|
||||
From ad4690306c4a0c322abb7f098a0f539740660b4a Mon Sep 17 00:00:00 2001
|
||||
From 63cc4ea5e8cfa3859cc98e54f5dd5eb44943a5cb Mon Sep 17 00:00:00 2001
|
||||
From: Minecrell <dev@minecrell.net>
|
||||
Date: Fri, 22 Sep 2017 13:15:09 +0200
|
||||
Subject: [PATCH] Allow plugins to use SLF4J for logging
|
@ -1,4 +1,4 @@
|
||||
From 45cd32b2caf6c3a092a5425b7c7d563f44127fa9 Mon Sep 17 00:00:00 2001
|
||||
From 1db80ba96f8379988a09d4d869c80d04579fddc0 Mon Sep 17 00:00:00 2001
|
||||
From: Minecrell <dev@minecrell.net>
|
||||
Date: Sun, 24 Sep 2017 12:06:49 +0200
|
||||
Subject: [PATCH] Add Log4j configuration that replicates the old BungeeCord
|
106
BungeeCord-Patches/0047-Add-console-command-completion.patch
Normal file
106
BungeeCord-Patches/0047-Add-console-command-completion.patch
Normal file
@ -0,0 +1,106 @@
|
||||
From a40f6085c979862514bde11a195f2c398d90bc37 Mon Sep 17 00:00:00 2001
|
||||
From: Minecrell <dev@minecrell.net>
|
||||
Date: Tue, 26 Sep 2017 18:59:37 +0200
|
||||
Subject: [PATCH] Add console command completion
|
||||
|
||||
Register command completer for JLine to complete command names and
|
||||
command arguments (if supported).
|
||||
|
||||
diff --git a/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java b/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java
|
||||
index 520ee315..302981d0 100644
|
||||
--- a/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java
|
||||
+++ b/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java
|
||||
@@ -181,6 +181,41 @@ public class PluginManager
|
||||
return true;
|
||||
}
|
||||
|
||||
+ // Waterfall start - Add method to tab-complete command names
|
||||
+ /**
|
||||
+ * Searches for tab-complete suggestions for the given command line.
|
||||
+ *
|
||||
+ * <p>This is similar to {@link #dispatchCommand(CommandSender, String, List)}
|
||||
+ * called with a list, but it also handles completing the command names itself
|
||||
+ * instead of just the arguments.</p>
|
||||
+ *
|
||||
+ * @param sender The command sender
|
||||
+ * @param commandLine The current command line
|
||||
+ * @return The tab-complete suggestions
|
||||
+ */
|
||||
+ public List<String> tabCompleteCommand(CommandSender sender, String commandLine) {
|
||||
+ List<String> suggestions = new java.util.ArrayList<>();
|
||||
+
|
||||
+ if (commandLine.indexOf(' ') == -1) {
|
||||
+ // Complete command name
|
||||
+ for (Command command : this.commandMap.values()) {
|
||||
+ if (command.getName().startsWith(commandLine)) {
|
||||
+ // Check command permissions before adding it to the suggestions
|
||||
+ String permission = command.getPermission();
|
||||
+ if (permission == null || permission.isEmpty() || sender.hasPermission(permission)) {
|
||||
+ suggestions.add(command.getName());
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ } else {
|
||||
+ // Complete command arguments
|
||||
+ dispatchCommand(sender, commandLine, suggestions);
|
||||
+ }
|
||||
+
|
||||
+ return suggestions;
|
||||
+ }
|
||||
+ // Waterfall end
|
||||
+
|
||||
/**
|
||||
* Returns the {@link Plugin} objects corresponding to all loaded plugins.
|
||||
*
|
||||
diff --git a/proxy/src/main/java/io/github/waterfallmc/waterfall/console/ConsoleCommandCompleter.java b/proxy/src/main/java/io/github/waterfallmc/waterfall/console/ConsoleCommandCompleter.java
|
||||
new file mode 100644
|
||||
index 00000000..bfcb6e9f
|
||||
--- /dev/null
|
||||
+++ b/proxy/src/main/java/io/github/waterfallmc/waterfall/console/ConsoleCommandCompleter.java
|
||||
@@ -0,0 +1,31 @@
|
||||
+package io.github.waterfallmc.waterfall.console;
|
||||
+
|
||||
+import net.md_5.bungee.api.ProxyServer;
|
||||
+import org.jline.reader.Candidate;
|
||||
+import org.jline.reader.Completer;
|
||||
+import org.jline.reader.LineReader;
|
||||
+import org.jline.reader.ParsedLine;
|
||||
+
|
||||
+import java.util.List;
|
||||
+
|
||||
+final class ConsoleCommandCompleter implements Completer {
|
||||
+
|
||||
+ private final ProxyServer proxy;
|
||||
+
|
||||
+ ConsoleCommandCompleter(ProxyServer proxy) {
|
||||
+ this.proxy = proxy;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void complete(LineReader reader, ParsedLine line, List<Candidate> candidates) {
|
||||
+ List<String> suggestions = this.proxy.getPluginManager().tabCompleteCommand(this.proxy.getConsole(), line.line());
|
||||
+ if (suggestions.isEmpty()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ for (String suggestion : suggestions) {
|
||||
+ candidates.add(new Candidate(suggestion));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/proxy/src/main/java/io/github/waterfallmc/waterfall/console/WaterfallConsole.java b/proxy/src/main/java/io/github/waterfallmc/waterfall/console/WaterfallConsole.java
|
||||
index a8a94749..ea52c674 100644
|
||||
--- a/proxy/src/main/java/io/github/waterfallmc/waterfall/console/WaterfallConsole.java
|
||||
+++ b/proxy/src/main/java/io/github/waterfallmc/waterfall/console/WaterfallConsole.java
|
||||
@@ -51,6 +51,7 @@ public final class WaterfallConsole {
|
||||
final LineReader reader = LineReaderBuilder.builder()
|
||||
.appName(ProxyServer.getInstance().getName())
|
||||
.terminal(terminal)
|
||||
+ .completer(new ConsoleCommandCompleter(bungee))
|
||||
.build();
|
||||
|
||||
reader.unsetOpt(LineReader.Option.INSERT_TAB);
|
||||
--
|
||||
2.14.1
|
||||
|
Loading…
Reference in New Issue
Block a user