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) {
|
public GameCommandModule(DiscordSRV discordSRV) {
|
||||||
super(discordSRV);
|
super(discordSRV);
|
||||||
this.primaryCommand = DiscordSRVCommand.get(discordSRV);
|
this.primaryCommand = DiscordSRVCommand.get(discordSRV, "discordsrv");
|
||||||
this.discordAlias = GameCommand.literal("discord").redirect(primaryCommand);
|
this.discordAlias = DiscordSRVCommand.get(discordSRV, "discord");
|
||||||
this.linkCommand = LinkCommand.get(discordSRV);
|
this.linkCommand = LinkCommand.get(discordSRV);
|
||||||
|
|
||||||
registerCommand(primaryCommand);
|
registerCommand(primaryCommand);
|
||||||
|
@ -27,25 +27,27 @@ import com.discordsrv.common.command.game.command.subcommand.*;
|
|||||||
import com.discordsrv.common.command.game.sender.ICommandSender;
|
import com.discordsrv.common.command.game.sender.ICommandSender;
|
||||||
import com.discordsrv.common.component.util.ComponentUtil;
|
import com.discordsrv.common.component.util.ComponentUtil;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public class DiscordSRVCommand implements GameCommandExecutor {
|
public class DiscordSRVCommand implements GameCommandExecutor {
|
||||||
|
|
||||||
private static GameCommand INSTANCE;
|
private static Map<String, GameCommand> INSTANCES = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public static GameCommand get(DiscordSRV discordSRV) {
|
public static GameCommand get(DiscordSRV discordSRV, String alias) {
|
||||||
if (INSTANCE == null) {
|
return INSTANCES.computeIfAbsent(alias, key ->
|
||||||
INSTANCE = GameCommand.literal("discordsrv")
|
GameCommand.literal(alias)
|
||||||
.requiredPermission("discordsrv.player.command")
|
.requiredPermission("discordsrv.player.command")
|
||||||
.executor(new DiscordSRVCommand(discordSRV))
|
.executor(new DiscordSRVCommand(discordSRV))
|
||||||
.then(BroadcastCommand.discord(discordSRV))
|
.then(BroadcastCommand.discord(discordSRV))
|
||||||
.then(BroadcastCommand.minecraft(discordSRV))
|
.then(BroadcastCommand.minecraft(discordSRV))
|
||||||
.then(BroadcastCommand.json(discordSRV))
|
.then(BroadcastCommand.json(discordSRV))
|
||||||
.then(DebugCommand.get(discordSRV))
|
.then(DebugCommand.get(discordSRV))
|
||||||
.then(LinkCommand.get(discordSRV))
|
.then(LinkCommand.get(discordSRV))
|
||||||
.then(ReloadCommand.get(discordSRV))
|
.then(ReloadCommand.get(discordSRV))
|
||||||
.then(ResyncCommand.get(discordSRV))
|
.then(ResyncCommand.get(discordSRV))
|
||||||
.then(VersionCommand.get(discordSRV));
|
.then(VersionCommand.get(discordSRV))
|
||||||
}
|
);
|
||||||
return INSTANCE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private final DiscordSRV discordSRV;
|
private final DiscordSRV discordSRV;
|
||||||
|
Loading…
Reference in New Issue
Block a user