mirror of
https://github.com/DiscordSRV/Ascension.git
synced 2024-12-28 17:37:52 +01:00
Tweak main command initialization a bit
This commit is contained in:
parent
8c81873f92
commit
cb1538d376
@ -39,8 +39,8 @@ public class GameCommandModule extends AbstractModule<DiscordSRV> {
|
||||
|
||||
public GameCommandModule(DiscordSRV discordSRV) {
|
||||
super(discordSRV);
|
||||
this.primaryCommand = DiscordSRVCommand.get(discordSRV);
|
||||
this.discordAlias = GameCommand.literal("discord").redirect(primaryCommand);
|
||||
this.primaryCommand = DiscordSRVCommand.get(discordSRV, "discordsrv");
|
||||
this.discordAlias = DiscordSRVCommand.get(discordSRV, "discord");
|
||||
this.linkCommand = LinkCommand.get(discordSRV);
|
||||
|
||||
registerCommand(primaryCommand);
|
||||
|
@ -27,13 +27,16 @@ import com.discordsrv.common.command.game.command.subcommand.*;
|
||||
import com.discordsrv.common.command.game.sender.ICommandSender;
|
||||
import com.discordsrv.common.component.util.ComponentUtil;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class DiscordSRVCommand implements GameCommandExecutor {
|
||||
|
||||
private static GameCommand INSTANCE;
|
||||
private static Map<String, GameCommand> INSTANCES = new ConcurrentHashMap<>();
|
||||
|
||||
public static GameCommand get(DiscordSRV discordSRV) {
|
||||
if (INSTANCE == null) {
|
||||
INSTANCE = GameCommand.literal("discordsrv")
|
||||
public static GameCommand get(DiscordSRV discordSRV, String alias) {
|
||||
return INSTANCES.computeIfAbsent(alias, key ->
|
||||
GameCommand.literal(alias)
|
||||
.requiredPermission("discordsrv.player.command")
|
||||
.executor(new DiscordSRVCommand(discordSRV))
|
||||
.then(BroadcastCommand.discord(discordSRV))
|
||||
@ -43,9 +46,8 @@ public class DiscordSRVCommand implements GameCommandExecutor {
|
||||
.then(LinkCommand.get(discordSRV))
|
||||
.then(ReloadCommand.get(discordSRV))
|
||||
.then(ResyncCommand.get(discordSRV))
|
||||
.then(VersionCommand.get(discordSRV));
|
||||
}
|
||||
return INSTANCE;
|
||||
.then(VersionCommand.get(discordSRV))
|
||||
);
|
||||
}
|
||||
|
||||
private final DiscordSRV discordSRV;
|
||||
|
Loading…
Reference in New Issue
Block a user