From 32826d843c4ab859b7addee20055c561429e0cfc Mon Sep 17 00:00:00 2001 From: mohammed jasem alaajel Date: Thu, 18 Apr 2024 12:48:00 +0400 Subject: [PATCH] finsh up command system --- .../api/config/RedisBungeeConfiguration.java | 22 +++++++- .../api/config/loaders/ConfigLoader.java | 37 +++++++++++- RedisBungee-API/src/main/resources/config.yml | 56 ++++++++++++++++++- .../redisbungee/commands/CommandLoader.java | 13 ++++- .../commands/CommandRedisBungee.java | 2 +- .../commands/legacy/CommandFind.java | 34 +++++++++++ .../commands/legacy/CommandGList.java | 34 +++++++++++ .../commands/legacy/CommandIp.java | 34 +++++++++++ .../commands/legacy/CommandLastSeen.java | 34 +++++++++++ .../commands/legacy/CommandPProxy.java | 33 +++++++++++ .../commands/legacy/CommandPlist.java | 35 ++++++++++++ .../commands/legacy/CommandSendToAll.java | 33 +++++++++++ .../commands/legacy/CommandServerId.java | 33 +++++++++++ .../commands/legacy/CommandServerIds.java | 36 ++++++++++++ .../LegacyRedisBungeeCommands.java | 35 +++++++----- 15 files changed, 448 insertions(+), 23 deletions(-) create mode 100644 RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/legacy/CommandFind.java create mode 100644 RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/legacy/CommandGList.java create mode 100644 RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/legacy/CommandIp.java create mode 100644 RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/legacy/CommandLastSeen.java create mode 100644 RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/legacy/CommandPProxy.java create mode 100644 RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/legacy/CommandPlist.java create mode 100644 RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/legacy/CommandSendToAll.java create mode 100644 RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/legacy/CommandServerId.java create mode 100644 RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/legacy/CommandServerIds.java rename RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/{ => legacy}/LegacyRedisBungeeCommands.java (86%) diff --git a/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/config/RedisBungeeConfiguration.java b/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/config/RedisBungeeConfiguration.java index b162c6f..e93d2fb 100644 --- a/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/config/RedisBungeeConfiguration.java +++ b/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/config/RedisBungeeConfiguration.java @@ -13,6 +13,7 @@ package com.imaginarycode.minecraft.redisbungee.api.config; import com.google.common.collect.ImmutableList; import com.google.common.net.InetAddresses; +import javax.annotation.Nullable; import java.net.InetAddress; import java.util.List; @@ -25,8 +26,10 @@ public class RedisBungeeConfiguration { private final boolean handleReconnectToLastServer; private final boolean handleMotd; + private final CommandsConfiguration commandsConfiguration; - public RedisBungeeConfiguration(String proxyId, List exemptAddresses, boolean kickWhenOnline, boolean handleReconnectToLastServer, boolean handleMotd) { + + public RedisBungeeConfiguration(String proxyId, List exemptAddresses, boolean kickWhenOnline, boolean handleReconnectToLastServer, boolean handleMotd, CommandsConfiguration commandsConfiguration) { this.proxyId = proxyId; ImmutableList.Builder addressBuilder = ImmutableList.builder(); for (String s : exemptAddresses) { @@ -36,6 +39,7 @@ public class RedisBungeeConfiguration { this.kickWhenOnline = kickWhenOnline; this.handleReconnectToLastServer = handleReconnectToLastServer; this.handleMotd = handleMotd; + this.commandsConfiguration = commandsConfiguration; } public String getProxyId() { @@ -58,5 +62,21 @@ public class RedisBungeeConfiguration { return this.handleReconnectToLastServer; } + public record CommandsConfiguration(boolean redisbungeeEnabled, boolean redisbungeeLegacyEnabled, + @Nullable LegacySubCommandsConfiguration legacySubCommandsConfiguration) { + } + + public record LegacySubCommandsConfiguration(boolean findEnabled, boolean glistEnabled, boolean ipEnabled, + boolean lastseenEnabled, boolean plistEnabled, boolean pproxyEnabled, + boolean sendtoallEnabled, boolean serveridEnabled, + boolean serveridsEnabled, boolean installFind, boolean installGlist, boolean installIp, + boolean installLastseen, boolean installPlist, boolean installPproxy, + boolean installSendtoall, boolean installServerid, + boolean installServerids) { + } + + public CommandsConfiguration commandsConfiguration() { + return commandsConfiguration; + } } diff --git a/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/config/loaders/ConfigLoader.java b/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/config/loaders/ConfigLoader.java index cba8576..fed44c8 100644 --- a/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/config/loaders/ConfigLoader.java +++ b/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/api/config/loaders/ConfigLoader.java @@ -86,7 +86,42 @@ public interface ConfigLoader extends GenericConfigLoader { plugin.logInfo("handle reconnect to last server: {}", reconnectToLastServer); plugin.logInfo("handle motd: {}", handleMotd); - RedisBungeeConfiguration configuration = new RedisBungeeConfiguration(proxyId, exemptAddresses, kickWhenOnline, reconnectToLastServer, handleMotd); + + // commands + boolean redisBungeeEnabled = node.getNode("commands", "redisbungee", "enabled").getBoolean(); + boolean redisBungeeLegacyEnabled =node.getNode("commands", "redisbungee-legacy", "enabled").getBoolean(); + + boolean glistEnabled = node.getNode("commands", "redisbungee-legacy", "subcommands", "glist", "enabled").getBoolean(); + boolean findEnabled = node.getNode("commands", "redisbungee-legacy", "subcommands", "find", "enabled").getBoolean(); + boolean lastseenEnabled = node.getNode("commands", "redisbungee-legacy", "subcommands", "lastseen", "enabled").getBoolean(); + boolean ipEnabled = node.getNode("commands", "redisbungee-legacy", "subcommands", "ip", "enabled").getBoolean(); + boolean pproxyEnabled = node.getNode("commands", "redisbungee-legacy", "subcommands", "pproxy", "enabled").getBoolean(); + boolean sendToAllEnabled = node.getNode("commands", "redisbungee-legacy", "subcommands", "sendtoall", "enabled").getBoolean(); + boolean serverIdEnabled = node.getNode("commands", "redisbungee-legacy", "subcommands", "serverid", "enabled").getBoolean(); + boolean serverIdsEnabled = node.getNode("commands", "redisbungee-legacy", "subcommands", "serverids", "enabled").getBoolean(); + boolean pListEnabled = node.getNode("commands", "redisbungee-legacy", "subcommands", "plist", "enabled").getBoolean(); + + boolean installGlist = node.getNode("commands", "redisbungee-legacy", "subcommands", "glist", "install").getBoolean(); + boolean installFind = node.getNode("commands", "redisbungee-legacy", "subcommands", "find", "install").getBoolean(); + boolean installLastseen = node.getNode("commands", "redisbungee-legacy", "subcommands", "lastseen", "install").getBoolean(); + boolean installIp = node.getNode("commands", "redisbungee-legacy", "subcommands", "ip", "install").getBoolean(); + boolean installPproxy = node.getNode("commands", "redisbungee-legacy", "subcommands", "pproxy", "install").getBoolean(); + boolean installSendToAll = node.getNode("commands", "redisbungee-legacy", "subcommands", "sendtoall", "install").getBoolean(); + boolean installServerid = node.getNode("commands", "redisbungee-legacy", "subcommands", "serverid", "install").getBoolean(); + boolean installServerIds = node.getNode("commands", "redisbungee-legacy", "subcommands", "serverids", "install").getBoolean(); + boolean installPlist = node.getNode("commands", "redisbungee-legacy", "subcommands", "plist", "install").getBoolean(); + + + RedisBungeeConfiguration configuration = new RedisBungeeConfiguration(proxyId, exemptAddresses, kickWhenOnline, reconnectToLastServer, handleMotd, new RedisBungeeConfiguration.CommandsConfiguration( + redisBungeeEnabled, redisBungeeLegacyEnabled, + new RedisBungeeConfiguration.LegacySubCommandsConfiguration( + findEnabled, glistEnabled, ipEnabled, + lastseenEnabled, pListEnabled, pproxyEnabled, + sendToAllEnabled, serverIdEnabled, serverIdsEnabled, + installFind, installGlist, installIp, + installLastseen, installPlist, installPproxy, + installSendToAll, installServerid, installServerIds) + )); Summoner summoner; RedisBungeeMode redisBungeeMode; if (useSSL) { diff --git a/RedisBungee-API/src/main/resources/config.yml b/RedisBungee-API/src/main/resources/config.yml index 628f6be..a7fea36 100644 --- a/RedisBungee-API/src/main/resources/config.yml +++ b/RedisBungee-API/src/main/resources/config.yml @@ -50,7 +50,7 @@ proxy-id: "proxy-1" # which will break compatibility with old plugins that uses RedisBungee JedisPool # so to mitigate this issue, RedisBungee will create an JedisPool for compatibility reasons. # disabled by default -# ignored when cluster mode is enabled +# Automatically disabled when cluster mode is enabled enable-jedis-pool-compatibility: false # max connections for the compatibility pool @@ -69,12 +69,64 @@ handle-motd: true # A list of IP addresses for which RedisBungee will not modify the response for, useful for automatic # restart scripts. -# ignored if handle-motd is disabled. +# Automatically disabled if handle-motd is disabled. exempt-ip-addresses: [] # disabled by default # RedisBungee will attempt to connect player to last server that was stored. reconnect-to-last-server: false +# For redis bungee legacy commands +# either can be run using '/rbl glist' for example +# or if 'install' is set to true '/glist' can be used. +# 'install' also overrides the proxy installed commands +# +# In legacy commands each command got it own permissions since they had it own permission pre new command system, +# so it's also applied to subcommands in '/rbl'. +commands: + # Permission redisbungee.legacy.use + redisbungee-legacy: + enabled: false + subcommands: + # Permission redisbungee.command.glist + glist: + enabled: false + install: false + # Permission redisbungee.command.find + find: + enabled: false + install: false + # Permission redisbungee.command.lastseen + lastseen: + enabled: false + install: false + # Permission redisbungee.command.ip + ip: + enabled: false + install: false + # Permission redisbungee.command.pproxy + pproxy: + enabled: false + install: false + # Permission redisbungee.command.sendtoall + sendtoall: + enabled: false + install: false + # Permission redisbungee.command.serverid + serverid: + enabled: false + install: false + # Permission redisbungee.command.serverids + serverids: + enabled: false + install: false + # Permission redisbungee.command.plist + plist: + enabled: false + install: false + # Permission redisbungee.command.use + redisbungee: + enabled: true + # Config version DO NOT CHANGE!!!! config-version: 2 diff --git a/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/CommandLoader.java b/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/CommandLoader.java index f883839..5346be9 100644 --- a/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/CommandLoader.java +++ b/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/CommandLoader.java @@ -13,12 +13,19 @@ package com.imaginarycode.minecraft.redisbungee.commands; import co.aikar.commands.CommandManager; import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin; +import com.imaginarycode.minecraft.redisbungee.commands.legacy.LegacyRedisBungeeCommands; + public class CommandLoader { public static void initCommands(CommandManager commandManager, RedisBungeePlugin plugin) { - commandManager.registerCommand(new CommandRedisBungee(plugin)); - // todo: config options to disable each command - commandManager.registerCommand(new LegacyRedisBungeeCommands(plugin)); + var commandsConfiguration = plugin.configuration().commandsConfiguration(); + if (commandsConfiguration.redisbungeeEnabled()) { + commandManager.registerCommand(new CommandRedisBungee(plugin)); + } + if (commandsConfiguration.redisbungeeLegacyEnabled()) { + commandManager.registerCommand(new LegacyRedisBungeeCommands(commandManager,plugin)); + } + } } diff --git a/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/CommandRedisBungee.java b/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/CommandRedisBungee.java index 4684970..a3cc3ac 100644 --- a/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/CommandRedisBungee.java +++ b/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/CommandRedisBungee.java @@ -27,7 +27,7 @@ import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import java.util.Date; @CommandAlias("rb|redisbungee") -@CommandPermission("redisbungee.use") +@CommandPermission("redisbungee.command.use") public class CommandRedisBungee extends AdventureBaseCommand { private final RedisBungeePlugin plugin; diff --git a/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/legacy/CommandFind.java b/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/legacy/CommandFind.java new file mode 100644 index 0000000..0a73d36 --- /dev/null +++ b/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/legacy/CommandFind.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2013-present RedisBungee contributors + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * + * http://www.eclipse.org/legal/epl-v10.html + */ + +package com.imaginarycode.minecraft.redisbungee.commands.legacy; + +import co.aikar.commands.CommandIssuer; +import co.aikar.commands.annotation.CommandAlias; +import co.aikar.commands.annotation.CommandPermission; +import co.aikar.commands.annotation.Default; +import com.imaginarycode.minecraft.redisbungee.commands.utils.AdventureBaseCommand; + +@CommandAlias("find|rfind") +@CommandPermission("redisbungee.command.find") +public class CommandFind extends AdventureBaseCommand { + + private final LegacyRedisBungeeCommands rootCommand; + + public CommandFind(LegacyRedisBungeeCommands rootCommand) { + this.rootCommand = rootCommand; + } + + @Default + public void find(CommandIssuer issuer, String[] args) { + rootCommand.find(issuer, args); + } + +} diff --git a/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/legacy/CommandGList.java b/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/legacy/CommandGList.java new file mode 100644 index 0000000..54cc985 --- /dev/null +++ b/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/legacy/CommandGList.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2013-present RedisBungee contributors + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * + * http://www.eclipse.org/legal/epl-v10.html + */ + +package com.imaginarycode.minecraft.redisbungee.commands.legacy; + +import co.aikar.commands.CommandIssuer; +import co.aikar.commands.annotation.CommandAlias; +import co.aikar.commands.annotation.CommandPermission; +import co.aikar.commands.annotation.Default; +import com.imaginarycode.minecraft.redisbungee.commands.utils.AdventureBaseCommand; + +@CommandAlias("glist|rglist") +@CommandPermission("redisbungee.command.glist") +public class CommandGList extends AdventureBaseCommand { + + private final LegacyRedisBungeeCommands rootCommand; + + public CommandGList(LegacyRedisBungeeCommands rootCommand) { + this.rootCommand = rootCommand; + } + + @Default + public void gList(CommandIssuer issuer, String[] args) { + rootCommand.gList(issuer, args); + } + +} diff --git a/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/legacy/CommandIp.java b/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/legacy/CommandIp.java new file mode 100644 index 0000000..410ae91 --- /dev/null +++ b/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/legacy/CommandIp.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2013-present RedisBungee contributors + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * + * http://www.eclipse.org/legal/epl-v10.html + */ + +package com.imaginarycode.minecraft.redisbungee.commands.legacy; + +import co.aikar.commands.CommandIssuer; +import co.aikar.commands.annotation.CommandAlias; +import co.aikar.commands.annotation.CommandPermission; +import co.aikar.commands.annotation.Default; +import com.imaginarycode.minecraft.redisbungee.commands.utils.AdventureBaseCommand; + +@CommandAlias("ip|playerip|rip|rplayerip") +@CommandPermission("redisbungee.command.ip") +public class CommandIp extends AdventureBaseCommand { + + private final LegacyRedisBungeeCommands rootCommand; + + public CommandIp(LegacyRedisBungeeCommands rootCommand) { + this.rootCommand = rootCommand; + } + + + @Default + public void ip(CommandIssuer issuer, String[] args) { + this.rootCommand.ip(issuer, args); + } +} diff --git a/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/legacy/CommandLastSeen.java b/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/legacy/CommandLastSeen.java new file mode 100644 index 0000000..f44ea8e --- /dev/null +++ b/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/legacy/CommandLastSeen.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2013-present RedisBungee contributors + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * + * http://www.eclipse.org/legal/epl-v10.html + */ + +package com.imaginarycode.minecraft.redisbungee.commands.legacy; + +import co.aikar.commands.CommandIssuer; +import co.aikar.commands.annotation.CommandAlias; +import co.aikar.commands.annotation.CommandPermission; +import co.aikar.commands.annotation.Default; +import com.imaginarycode.minecraft.redisbungee.commands.utils.AdventureBaseCommand; + +@CommandAlias("lastseen|rlastseend") +@CommandPermission("redisbungee.command.lastseen") +public class CommandLastSeen extends AdventureBaseCommand { + + + private final LegacyRedisBungeeCommands rootCommand; + + public CommandLastSeen(LegacyRedisBungeeCommands rootCommand) { + this.rootCommand = rootCommand; + } + + @Default + public void lastSeen(CommandIssuer issuer, String[] args) { + this.rootCommand.lastSeen(issuer,args); + } +} diff --git a/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/legacy/CommandPProxy.java b/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/legacy/CommandPProxy.java new file mode 100644 index 0000000..70a949c --- /dev/null +++ b/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/legacy/CommandPProxy.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2013-present RedisBungee contributors + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * + * http://www.eclipse.org/legal/epl-v10.html + */ + +package com.imaginarycode.minecraft.redisbungee.commands.legacy; + +import co.aikar.commands.CommandIssuer; +import co.aikar.commands.annotation.CommandAlias; +import co.aikar.commands.annotation.CommandPermission; +import co.aikar.commands.annotation.Default; +import com.imaginarycode.minecraft.redisbungee.commands.utils.AdventureBaseCommand; + +@CommandAlias("pproxy") +@CommandPermission("redisbungee.command.pproxy") +public class CommandPProxy extends AdventureBaseCommand { + private final LegacyRedisBungeeCommands rootCommand; + + public CommandPProxy(LegacyRedisBungeeCommands rootCommand) { + this.rootCommand = rootCommand; + } + + @Default + public void playerProxy(CommandIssuer issuer, String[] args) { + this.rootCommand.playerProxy(issuer,args); + } + +} diff --git a/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/legacy/CommandPlist.java b/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/legacy/CommandPlist.java new file mode 100644 index 0000000..04e1609 --- /dev/null +++ b/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/legacy/CommandPlist.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2013-present RedisBungee contributors + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * + * http://www.eclipse.org/legal/epl-v10.html + */ + +package com.imaginarycode.minecraft.redisbungee.commands.legacy; + +import co.aikar.commands.CommandIssuer; +import co.aikar.commands.annotation.CommandAlias; +import co.aikar.commands.annotation.CommandPermission; +import co.aikar.commands.annotation.Default; +import com.imaginarycode.minecraft.redisbungee.commands.utils.AdventureBaseCommand; + +@CommandAlias("plist|rplist") +@CommandPermission("redisbungee.command.plist") +public class CommandPlist extends AdventureBaseCommand { + + + private final LegacyRedisBungeeCommands rootCommand; + + public CommandPlist(LegacyRedisBungeeCommands rootCommand) { + this.rootCommand = rootCommand; + } + + @Default + public void playerList(CommandIssuer issuer, String[] args) { + this.rootCommand.playerList(issuer, args); + } + +} diff --git a/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/legacy/CommandSendToAll.java b/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/legacy/CommandSendToAll.java new file mode 100644 index 0000000..ad9e1da --- /dev/null +++ b/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/legacy/CommandSendToAll.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2013-present RedisBungee contributors + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * + * http://www.eclipse.org/legal/epl-v10.html + */ + +package com.imaginarycode.minecraft.redisbungee.commands.legacy; + +import co.aikar.commands.CommandIssuer; +import co.aikar.commands.annotation.CommandAlias; +import co.aikar.commands.annotation.CommandPermission; +import co.aikar.commands.annotation.Default; +import com.imaginarycode.minecraft.redisbungee.commands.utils.AdventureBaseCommand; + +@CommandAlias("sendtoall|rsendtoall") +@CommandPermission("redisbungee.command.sendtoall") +public class CommandSendToAll extends AdventureBaseCommand { + + + private final LegacyRedisBungeeCommands rootCommand; + + public CommandSendToAll(LegacyRedisBungeeCommands rootCommand) { + this.rootCommand = rootCommand; + } + @Default + public void sendToAll(CommandIssuer issuer, String[] args) { + this.rootCommand.sendToAll(issuer, args); + } +} diff --git a/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/legacy/CommandServerId.java b/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/legacy/CommandServerId.java new file mode 100644 index 0000000..c62c2f5 --- /dev/null +++ b/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/legacy/CommandServerId.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2013-present RedisBungee contributors + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * + * http://www.eclipse.org/legal/epl-v10.html + */ + +package com.imaginarycode.minecraft.redisbungee.commands.legacy; + +import co.aikar.commands.CommandIssuer; +import co.aikar.commands.annotation.CommandAlias; +import co.aikar.commands.annotation.CommandPermission; +import co.aikar.commands.annotation.Default; +import com.imaginarycode.minecraft.redisbungee.commands.utils.AdventureBaseCommand; + +@CommandAlias("serverid|rserverid") +@CommandPermission("redisbungee.command.serverid") +public class CommandServerId extends AdventureBaseCommand { + + + private final LegacyRedisBungeeCommands rootCommand; + + public CommandServerId(LegacyRedisBungeeCommands rootCommand) { + this.rootCommand = rootCommand; + } + @Default + public void serverId(CommandIssuer issuer) { + this.rootCommand.serverId(issuer); + } +} diff --git a/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/legacy/CommandServerIds.java b/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/legacy/CommandServerIds.java new file mode 100644 index 0000000..85b53b7 --- /dev/null +++ b/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/legacy/CommandServerIds.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2013-present RedisBungee contributors + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * + * http://www.eclipse.org/legal/epl-v10.html + */ + +package com.imaginarycode.minecraft.redisbungee.commands.legacy; + +import co.aikar.commands.CommandIssuer; +import co.aikar.commands.annotation.CommandAlias; +import co.aikar.commands.annotation.CommandPermission; +import co.aikar.commands.annotation.Default; +import com.imaginarycode.minecraft.redisbungee.commands.utils.AdventureBaseCommand; + +@CommandAlias("serverids|rserverids") +@CommandPermission("redisbungee.command.serverids") +public class CommandServerIds extends AdventureBaseCommand { + + + private final LegacyRedisBungeeCommands rootCommand; + + public CommandServerIds(LegacyRedisBungeeCommands rootCommand) { + this.rootCommand = rootCommand; + } + + @Default + public void serverIds(CommandIssuer issuer) { + this.rootCommand.serverIds(issuer); + } + + +} diff --git a/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/LegacyRedisBungeeCommands.java b/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/legacy/LegacyRedisBungeeCommands.java similarity index 86% rename from RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/LegacyRedisBungeeCommands.java rename to RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/legacy/LegacyRedisBungeeCommands.java index 930c7e9..6253e96 100644 --- a/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/LegacyRedisBungeeCommands.java +++ b/RedisBungee-Commands/src/main/java/com/imaginarycode/minecraft/redisbungee/commands/legacy/LegacyRedisBungeeCommands.java @@ -8,9 +8,10 @@ * http://www.eclipse.org/legal/epl-v10.html */ -package com.imaginarycode.minecraft.redisbungee.commands; +package com.imaginarycode.minecraft.redisbungee.commands.legacy; import co.aikar.commands.CommandIssuer; +import co.aikar.commands.CommandManager; import co.aikar.commands.annotation.CommandAlias; import co.aikar.commands.annotation.CommandPermission; import co.aikar.commands.annotation.Subcommand; @@ -29,15 +30,27 @@ import java.util.Set; import java.util.TreeSet; import java.util.UUID; -@CommandAlias("rbl|redisbungeeleagacy") -@CommandPermission("redisbungee.leagacy.use") +@CommandAlias("rbl|redisbungeelegacy") +@CommandPermission("redisbungee.legacy.use") public class LegacyRedisBungeeCommands extends AdventureBaseCommand { - private final RedisBungeePlugin plugin; - public LegacyRedisBungeeCommands(RedisBungeePlugin plugin) { + public LegacyRedisBungeeCommands(CommandManager commandManager, RedisBungeePlugin plugin) { this.plugin = plugin; + var commands = plugin.configuration().commandsConfiguration().legacySubCommandsConfiguration(); + if (!plugin.configuration().commandsConfiguration().redisbungeeLegacyEnabled()) throw new IllegalStateException("someone tried to init me while disabled!"); + if (commands == null) throw new NullPointerException("commands config is null!!"); + + if (commands.installGlist()) commandManager.registerCommand(new CommandGList(this)); + if (commands.installFind()) commandManager.registerCommand(new CommandFind(this)); + if (commands.installIp()) commandManager.registerCommand(new CommandIp(this)); + if (commands.installLastseen()) commandManager.registerCommand(new CommandLastSeen(this)); + if (commands.installPlist()) commandManager.registerCommand(new CommandPlist(this)); + if (commands.installPproxy()) commandManager.registerCommand(new CommandPProxy(this)); + if (commands.installSendtoall()) commandManager.registerCommand(new CommandSendToAll(this)); + if (commands.installServerid()) commandManager.registerCommand(new CommandServerId(this)); + if (commands.installServerids()) commandManager.registerCommand(new CommandServerIds(this)); } private static final Component NO_PLAYER_SPECIFIED = @@ -52,7 +65,6 @@ public class LegacyRedisBungeeCommands extends AdventureBaseCommand { } @Subcommand("glist") - @CommandAlias("glist") @CommandPermission("redisbungee.command.glist") public void gList(CommandIssuer issuer, String[] args) { plugin.executeAsync(() -> { @@ -80,8 +92,8 @@ public class LegacyRedisBungeeCommands extends AdventureBaseCommand { }); } + @Subcommand("find") - @CommandAlias("find") @CommandPermission("redisbungee.command.find") public void find(CommandIssuer issuer, String[] args) { plugin.executeAsync(() -> { @@ -107,7 +119,6 @@ public class LegacyRedisBungeeCommands extends AdventureBaseCommand { } @Subcommand("lastseen") - @CommandAlias("lastseen") @CommandPermission("redisbungee.command.lastseen") public void lastSeen(CommandIssuer issuer, String[] args) { plugin.executeAsync(() -> { @@ -139,7 +150,6 @@ public class LegacyRedisBungeeCommands extends AdventureBaseCommand { } @Subcommand("ip") - @CommandAlias("ip") @CommandPermission("redisbungee.command.ip") public void ip(CommandIssuer issuer, String[] args) { plugin.executeAsync(() -> { @@ -163,7 +173,6 @@ public class LegacyRedisBungeeCommands extends AdventureBaseCommand { } @Subcommand("pproxy") - @CommandAlias("pproxy") @CommandPermission("redisbungee.command.pproxy") public void playerProxy(CommandIssuer issuer, String[] args) { plugin.executeAsync(() -> { @@ -188,7 +197,6 @@ public class LegacyRedisBungeeCommands extends AdventureBaseCommand { } @Subcommand("sendtoall") - @CommandAlias("sendtoall") @CommandPermission("redisbungee.command.sendtoall") public void sendToAll(CommandIssuer issuer, String[] args) { if (args.length > 0) { @@ -203,22 +211,19 @@ public class LegacyRedisBungeeCommands extends AdventureBaseCommand { } @Subcommand("serverid") - @CommandAlias("serverid") @CommandPermission("redisbungee.command.serverid") public void serverId(CommandIssuer issuer) { sendMessage(issuer, Component.text("You are on " + plugin.getAbstractRedisBungeeApi().getProxyId() + ".", NamedTextColor.YELLOW)); } @Subcommand("serverids") - @CommandAlias("serverids") @CommandPermission("redisbungee.command.serverids") public void serverIds(CommandIssuer issuer) { - sendMessage(issuer, Component.text("All server IDs: " + Joiner.on(", ").join(plugin.getAbstractRedisBungeeApi().getAllProxies()), NamedTextColor.YELLOW)); + sendMessage(issuer, Component.text("All Proxies IDs: " + Joiner.on(", ").join(plugin.getAbstractRedisBungeeApi().getAllProxies()), NamedTextColor.YELLOW)); } @Subcommand("plist") - @CommandAlias("plist") @CommandPermission("redisbungee.command.plist") public void playerList(CommandIssuer issuer, String[] args) { plugin.executeAsync(() -> {