mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Add a commands.yml file for specifying custom command descriptions
This commit is contained in:
parent
b70e2645c8
commit
3061481a1a
16 changed files with 123 additions and 165 deletions
|
@ -62,7 +62,6 @@ public class GeyserSpongePlugin implements GeyserBootstrap {
|
|||
@ConfigDir(sharedRoot = false)
|
||||
private File configDir;
|
||||
|
||||
private GeyserSpongeCommandManager geyserCommandManager;
|
||||
private GeyserSpongeConfiguration geyserConfig;
|
||||
private GeyserSpongeLogger geyserLogger;
|
||||
private IGeyserPingPassthrough geyserSpongePingPassthrough;
|
||||
|
@ -119,7 +118,6 @@ public class GeyserSpongePlugin implements GeyserBootstrap {
|
|||
this.geyserSpongePingPassthrough = new GeyserSpongePingPassthrough();
|
||||
}
|
||||
|
||||
this.geyserCommandManager = new GeyserSpongeCommandManager(Sponge.getCommandManager(), geyser);
|
||||
Sponge.getCommandManager().register(this, new GeyserSpongeCommandExecutor(geyser), "geyser");
|
||||
}
|
||||
|
||||
|
@ -139,8 +137,8 @@ public class GeyserSpongePlugin implements GeyserBootstrap {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CommandManager getGeyserCommandManager() {
|
||||
return this.geyserCommandManager;
|
||||
public CommandManager createGeyserCommandManager(GeyserImpl geyser) {
|
||||
return new GeyserSpongeCommandManager(Sponge.getCommandManager(), geyser);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -31,6 +31,8 @@ import org.spongepowered.api.Sponge;
|
|||
import org.spongepowered.api.command.CommandMapping;
|
||||
import org.spongepowered.api.text.Text;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class GeyserSpongeCommandManager extends CommandManager {
|
||||
private final org.spongepowered.api.command.CommandManager handle;
|
||||
|
||||
|
@ -41,9 +43,15 @@ public class GeyserSpongeCommandManager extends CommandManager {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public String getDescription(String command) {
|
||||
return handle.get(command).map(CommandMapping::getCallable)
|
||||
.map(callable -> callable.getShortDescription(Sponge.getServer().getConsole()).orElse(Text.EMPTY))
|
||||
.orElse(Text.EMPTY).toPlain();
|
||||
String description = super.getDescription(command);
|
||||
if (description.isEmpty()) {
|
||||
return handle.get(command).map(CommandMapping::getCallable)
|
||||
.map(callable -> callable.getShortDescription(Sponge.getServer().getConsole()).orElse(Text.EMPTY))
|
||||
.orElse(Text.EMPTY).toPlain();
|
||||
} else {
|
||||
return description;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue