mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-01 05:58:00 +01:00
Add onWrite method with CommandSender in CommandProcessor
This commit is contained in:
parent
ca3667732f
commit
e911612ad6
@ -81,4 +81,20 @@ public interface CommandProcessor {
|
|||||||
default String[] onWrite(@NotNull String text) {
|
default String[] onWrite(@NotNull String text) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows for tab auto completion, this is called everytime the player press a key in the chat.
|
||||||
|
* <p>
|
||||||
|
* WARNING: {@link #enableWritingTracking()} needs to return true, you need to override it by default.
|
||||||
|
* This does not work if {@link #onWrite(String) is overriden}
|
||||||
|
*
|
||||||
|
* @param sender the command sender
|
||||||
|
* @param text the whole player text
|
||||||
|
* @return the array containing all the suggestions for the current arg (split " "), can be null
|
||||||
|
* @see #enableWritingTracking()
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
default String[] onWrite(@NotNull CommandSender sender, String text) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,10 @@ public class TabCompleteListener {
|
|||||||
final CommandProcessor commandProcessor = COMMAND_MANAGER.getCommandProcessor(commandName);
|
final CommandProcessor commandProcessor = COMMAND_MANAGER.getCommandProcessor(commandName);
|
||||||
if (commandProcessor != null) {
|
if (commandProcessor != null) {
|
||||||
final int start = findStart(text, split);
|
final int start = findStart(text, split);
|
||||||
final String[] matches = commandProcessor.onWrite(text);
|
String[] matches = commandProcessor.onWrite(text);
|
||||||
|
if (matches == null) {
|
||||||
|
matches = commandProcessor.onWrite(player, text);
|
||||||
|
}
|
||||||
if (matches != null && matches.length > 0) {
|
if (matches != null && matches.length > 0) {
|
||||||
sendTabCompletePacket(packet.transactionId, start, matches, player);
|
sendTabCompletePacket(packet.transactionId, start, matches, player);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user