#3418: Add tab completion for bungee command names in pre-1.13 versions
This commit is contained in:
parent
3a6e2631bf
commit
9f5ace9025
@ -124,6 +124,9 @@ public final class UserConnection implements ProxiedPlayer
|
|||||||
private final Scoreboard serverSentScoreboard = new Scoreboard();
|
private final Scoreboard serverSentScoreboard = new Scoreboard();
|
||||||
@Getter
|
@Getter
|
||||||
private final Collection<UUID> sentBossBars = new HashSet<>();
|
private final Collection<UUID> sentBossBars = new HashSet<>();
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private String lastCommandTabbed;
|
||||||
/*========================================================================*/
|
/*========================================================================*/
|
||||||
@Getter
|
@Getter
|
||||||
private String displayName;
|
private String displayName;
|
||||||
|
@ -20,7 +20,9 @@ import java.io.DataInput;
|
|||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import net.md_5.bungee.ServerConnection;
|
import net.md_5.bungee.ServerConnection;
|
||||||
import net.md_5.bungee.ServerConnection.KeepAliveData;
|
import net.md_5.bungee.ServerConnection.KeepAliveData;
|
||||||
@ -646,6 +648,23 @@ public class DownstreamBridge extends PacketHandler
|
|||||||
return input.getText();
|
return input.getText();
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
String last = con.getLastCommandTabbed();
|
||||||
|
if ( last != null )
|
||||||
|
{
|
||||||
|
String commandName = last.toLowerCase( Locale.ROOT );
|
||||||
|
commands.addAll( bungee.getPluginManager().getCommands().stream()
|
||||||
|
.filter( (entry) ->
|
||||||
|
{
|
||||||
|
String lowerCase = entry.getKey().toLowerCase( Locale.ROOT );
|
||||||
|
return lowerCase.startsWith( commandName ) && entry.getValue().hasPermission( con ) && !bungee.getDisabledCommands().contains( lowerCase );
|
||||||
|
} )
|
||||||
|
.map( (stringCommandEntry) -> '/' + stringCommandEntry.getKey() )
|
||||||
|
.collect( Collectors.toList() ) );
|
||||||
|
commands.sort( null );
|
||||||
|
con.setLastCommandTabbed( null );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TabCompleteResponseEvent tabCompleteResponseEvent = new TabCompleteResponseEvent( server, con, new ArrayList<>( commands ) );
|
TabCompleteResponseEvent tabCompleteResponseEvent = new TabCompleteResponseEvent( server, con, new ArrayList<>( commands ) );
|
||||||
|
@ -213,8 +213,9 @@ public class UpstreamBridge extends PacketHandler
|
|||||||
{
|
{
|
||||||
List<String> suggestions = new ArrayList<>();
|
List<String> suggestions = new ArrayList<>();
|
||||||
boolean isRegisteredCommand = false;
|
boolean isRegisteredCommand = false;
|
||||||
|
boolean isCommand = tabComplete.getCursor().startsWith( "/" );
|
||||||
|
|
||||||
if ( tabComplete.getCursor().startsWith( "/" ) )
|
if ( isCommand )
|
||||||
{
|
{
|
||||||
isRegisteredCommand = bungee.getPluginManager().dispatchCommand( con, tabComplete.getCursor().substring( 1 ), suggestions );
|
isRegisteredCommand = bungee.getPluginManager().dispatchCommand( con, tabComplete.getCursor().substring( 1 ), suggestions );
|
||||||
}
|
}
|
||||||
@ -257,6 +258,15 @@ public class UpstreamBridge extends PacketHandler
|
|||||||
{
|
{
|
||||||
throw CancelSendSignal.INSTANCE;
|
throw CancelSendSignal.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( isCommand && con.getPendingConnection().getVersion() < ProtocolConstants.MINECRAFT_1_13 )
|
||||||
|
{
|
||||||
|
int lastSpace = tabComplete.getCursor().lastIndexOf( ' ' );
|
||||||
|
if ( lastSpace == -1 )
|
||||||
|
{
|
||||||
|
con.setLastCommandTabbed( tabComplete.getCursor().substring( 1 ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user