forked from GeyserMC/Geyser
GUI Improvements (#1462)
- Added `GeyserCommand.isExecutableOnConsole()`. If this is set to false, the command will not appear as an option in the GUI. - Added `GeyserCommand.getSubCommands()`. If not empty, the subcommand options will now appear in the GUI.
This commit is contained in:
parent
04f0318bd0
commit
a2a7e99402
6 changed files with 68 additions and 8 deletions
|
@ -30,6 +30,7 @@ import lombok.RequiredArgsConstructor;
|
|||
import lombok.Setter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
|
@ -44,4 +45,31 @@ public abstract class GeyserCommand {
|
|||
private List<String> aliases = new ArrayList<>();
|
||||
|
||||
public abstract void execute(CommandSender sender, String[] args);
|
||||
|
||||
/**
|
||||
* If false, hides the command from being shown on the Geyser Standalone GUI.
|
||||
*
|
||||
* @return true if the command can be run on the server console
|
||||
*/
|
||||
public boolean isExecutableOnConsole() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used in the GUI to know what subcommands can be run
|
||||
*
|
||||
* @return a list of all possible subcommands, or empty if none.
|
||||
*/
|
||||
public List<String> getSubCommands() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcut to {@link #getSubCommands()}{@code .isEmpty()}.
|
||||
*
|
||||
* @return true if there are subcommand present for this command.
|
||||
*/
|
||||
public boolean hasSubCommands() {
|
||||
return !getSubCommands().isEmpty();
|
||||
}
|
||||
}
|
|
@ -27,12 +27,10 @@ package org.geysermc.connector.command.defaults;
|
|||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
|
||||
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;
|
||||
import org.geysermc.connector.common.ChatColor;
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
import org.geysermc.connector.command.CommandSender;
|
||||
import org.geysermc.connector.command.GeyserCommand;
|
||||
import org.geysermc.connector.common.ChatColor;
|
||||
import org.geysermc.connector.common.serializer.AsteriskSerializer;
|
||||
import org.geysermc.connector.dump.DumpInfo;
|
||||
import org.geysermc.connector.utils.LanguageUtils;
|
||||
|
@ -40,6 +38,8 @@ import org.geysermc.connector.utils.WebUtils;
|
|||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class DumpCommand extends GeyserCommand {
|
||||
|
||||
|
@ -130,4 +130,9 @@ public class DumpCommand extends GeyserCommand {
|
|||
connector.getLogger().info(LanguageUtils.getLocaleStringLog("geyser.commands.dump.created", sender.getName(), uploadedDumpUrl));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSubCommands() {
|
||||
return Arrays.asList("offline", "full");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,4 +68,9 @@ public class OffhandCommand extends GeyserCommand {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExecutableOnConsole() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,4 +66,9 @@ public class StatisticsCommand extends GeyserCommand {
|
|||
ClientRequestPacket clientRequestPacket = new ClientRequestPacket(ClientRequest.STATS);
|
||||
session.sendDownstreamPacket(clientRequestPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExecutableOnConsole() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue