Add a commands.yml file for specifying custom command descriptions

This commit is contained in:
Camotoy 2021-12-26 14:57:17 -05:00
parent b70e2645c8
commit 3061481a1a
No known key found for this signature in database
GPG key ID: 7EEFB66FE798081F
16 changed files with 123 additions and 165 deletions

View file

@ -63,7 +63,6 @@ import java.util.UUID;
import java.util.logging.Level;
public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
private GeyserSpigotCommandManager geyserCommandManager;
private GeyserSpigotConfiguration geyserConfig;
private GeyserSpigotInjector geyserInjector;
private GeyserSpigotLogger geyserLogger;
@ -160,8 +159,6 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
this.geyserSpigotPingPassthrough = new GeyserSpigotPingPassthrough(geyserLogger);
}
this.geyserCommandManager = new GeyserSpigotCommandManager(geyser);
boolean isViaVersion = Bukkit.getPluginManager().getPlugin("ViaVersion") != null;
if (isViaVersion) {
try {
@ -265,8 +262,8 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
}
@Override
public CommandManager getGeyserCommandManager() {
return this.geyserCommandManager;
public CommandManager createGeyserCommandManager(GeyserImpl geyser) {
return new GeyserSpigotCommandManager(geyser);
}
@Override

View file

@ -31,6 +31,7 @@ import org.bukkit.command.CommandMap;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.command.CommandManager;
import javax.annotation.Nonnull;
import java.lang.reflect.Field;
public class GeyserSpigotCommandManager extends CommandManager {
@ -52,8 +53,14 @@ public class GeyserSpigotCommandManager extends CommandManager {
}
@Override
@Nonnull
public String getDescription(String command) {
Command cmd = COMMAND_MAP.getCommand(command.replace("/", ""));
return cmd != null ? cmd.getDescription() : "";
String description = super.getDescription(command);
if (description.isEmpty()) {
Command cmd = COMMAND_MAP.getCommand(command.replace("/", ""));
return cmd != null ? cmd.getDescription() : "";
} else {
return description;
}
}
}