Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-04 23:30:17 +01:00
Pull command descriptions from Bukkit and Sponge versions when listing commands
This allows the description of the commands to display when listing the commands in bedrock by tab-completing. This is currently only available on Sponge and Bukkit versions as there is no support in BungeeCord and Velocity to get these values. This data is also not sent in any packet, so we cannot retrieve that from standalone either.
Dieser Commit ist enthalten in:
Ursprung
672024c718
Commit
bab2b4a420
@ -27,14 +27,18 @@ package org.geysermc.platform.bukkit;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.geysermc.common.PlatformType;
|
||||
import org.geysermc.common.command.ICommandManager;
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
import org.geysermc.common.bootstrap.IGeyserBootstrap;
|
||||
import org.geysermc.connector.command.CommandManager;
|
||||
import org.geysermc.platform.bukkit.command.GeyserBukkitCommandExecutor;
|
||||
import org.geysermc.platform.bukkit.command.GeyserBukkitCommandManager;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class GeyserBukkitPlugin extends JavaPlugin implements IGeyserBootstrap {
|
||||
|
||||
private GeyserBukkitCommandManager geyserCommandManager;
|
||||
private GeyserBukkitConfiguration geyserConfig;
|
||||
private GeyserBukkitLogger geyserLogger;
|
||||
|
||||
@ -53,6 +57,8 @@ public class GeyserBukkitPlugin extends JavaPlugin implements IGeyserBootstrap {
|
||||
this.geyserLogger = new GeyserBukkitLogger(getLogger(), geyserConfig.isDebugMode());
|
||||
this.connector = GeyserConnector.start(PlatformType.BUKKIT, this);
|
||||
|
||||
this.geyserCommandManager = new GeyserBukkitCommandManager(this, connector);
|
||||
|
||||
this.getCommand("geyser").setExecutor(new GeyserBukkitCommandExecutor(connector));
|
||||
}
|
||||
|
||||
@ -70,4 +76,9 @@ public class GeyserBukkitPlugin extends JavaPlugin implements IGeyserBootstrap {
|
||||
public GeyserBukkitLogger getGeyserLogger() {
|
||||
return geyserLogger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandManager getGeyserCommandManager() {
|
||||
return this.geyserCommandManager;
|
||||
}
|
||||
}
|
||||
|
@ -70,6 +70,6 @@ public class GeyserBukkitCommandExecutor implements TabExecutor {
|
||||
}
|
||||
|
||||
private GeyserCommand getCommand(String label) {
|
||||
return connector.getCommandMap().getCommands().get(label);
|
||||
return connector.getCommandManager().getCommands().get(label);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Geyser
|
||||
*/
|
||||
|
||||
package org.geysermc.platform.bukkit.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandMap;
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
import org.geysermc.connector.command.CommandManager;
|
||||
import org.geysermc.platform.bukkit.GeyserBukkitPlugin;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class GeyserBukkitCommandManager extends CommandManager {
|
||||
|
||||
private static CommandMap COMMAND_MAP;
|
||||
|
||||
static {
|
||||
try {
|
||||
Field cmdMapField = Bukkit.getServer().getClass().getDeclaredField("commandMap");
|
||||
cmdMapField.setAccessible(true);
|
||||
COMMAND_MAP = (CommandMap) cmdMapField.get(Bukkit.getServer());
|
||||
} catch (NoSuchFieldException | IllegalAccessException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private GeyserBukkitPlugin plugin;
|
||||
|
||||
public GeyserBukkitCommandManager(GeyserBukkitPlugin plugin, GeyserConnector connector) {
|
||||
super(connector);
|
||||
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription(String command) {
|
||||
Command cmd = COMMAND_MAP.getCommand(command.replace("/", ""));
|
||||
return cmd != null ? cmd.getDescription() : "";
|
||||
}
|
||||
}
|
@ -33,7 +33,9 @@ import net.md_5.bungee.config.YamlConfiguration;
|
||||
import org.geysermc.common.PlatformType;
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
import org.geysermc.common.bootstrap.IGeyserBootstrap;
|
||||
import org.geysermc.connector.command.CommandManager;
|
||||
import org.geysermc.platform.bungeecord.command.GeyserBungeeCommandExecutor;
|
||||
import org.geysermc.platform.bungeecord.command.GeyserBungeeCommandManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -44,6 +46,7 @@ import java.util.logging.Level;
|
||||
|
||||
public class GeyserBungeePlugin extends Plugin implements IGeyserBootstrap {
|
||||
|
||||
private GeyserBungeeCommandManager geyserCommandManager;
|
||||
private GeyserBungeeConfiguration geyserConfig;
|
||||
private GeyserBungeeLogger geyserLogger;
|
||||
|
||||
@ -91,6 +94,8 @@ public class GeyserBungeePlugin extends Plugin implements IGeyserBootstrap {
|
||||
this.geyserLogger = new GeyserBungeeLogger(getLogger(), geyserConfig.isDebugMode());
|
||||
this.connector = GeyserConnector.start(PlatformType.BUNGEECORD, this);
|
||||
|
||||
this.geyserCommandManager = new GeyserBungeeCommandManager(connector);
|
||||
|
||||
this.getProxy().getPluginManager().registerCommand(this, new GeyserBungeeCommandExecutor(connector));
|
||||
}
|
||||
|
||||
@ -108,4 +113,9 @@ public class GeyserBungeePlugin extends Plugin implements IGeyserBootstrap {
|
||||
public GeyserBungeeLogger getGeyserLogger() {
|
||||
return geyserLogger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandManager getGeyserCommandManager() {
|
||||
return this.geyserCommandManager;
|
||||
}
|
||||
}
|
||||
|
@ -71,6 +71,6 @@ public class GeyserBungeeCommandExecutor extends Command implements TabExecutor
|
||||
}
|
||||
|
||||
private GeyserCommand getCommand(String label) {
|
||||
return connector.getCommandMap().getCommands().get(label);
|
||||
return connector.getCommandManager().getCommands().get(label);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Geyser
|
||||
*/
|
||||
|
||||
package org.geysermc.platform.bungeecord.command;
|
||||
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
import org.geysermc.connector.command.CommandManager;
|
||||
|
||||
public class GeyserBungeeCommandManager extends CommandManager {
|
||||
|
||||
public GeyserBungeeCommandManager(GeyserConnector connector) {
|
||||
super(connector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription(String command) {
|
||||
return ""; // no support for command descriptions in bungee
|
||||
}
|
||||
}
|
@ -32,9 +32,12 @@ import ninja.leaping.configurate.yaml.YAMLConfigurationLoader;
|
||||
|
||||
import org.geysermc.common.PlatformType;
|
||||
import org.geysermc.common.bootstrap.IGeyserBootstrap;
|
||||
import org.geysermc.common.command.ICommandManager;
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
import org.geysermc.connector.command.CommandManager;
|
||||
import org.geysermc.connector.utils.FileUtils;
|
||||
import org.geysermc.platform.sponge.command.GeyserSpongeCommandExecutor;
|
||||
import org.geysermc.platform.sponge.command.GeyserSpongeCommandManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.spongepowered.api.Sponge;
|
||||
import org.spongepowered.api.config.ConfigDir;
|
||||
@ -57,6 +60,7 @@ public class GeyserSpongePlugin implements IGeyserBootstrap {
|
||||
@ConfigDir(sharedRoot = false)
|
||||
private File configDir;
|
||||
|
||||
private GeyserSpongeCommandManager geyserCommandManager;
|
||||
private GeyserSpongeConfiguration geyserConfig;
|
||||
private GeyserSpongeLogger geyserLogger;
|
||||
|
||||
@ -86,6 +90,7 @@ public class GeyserSpongePlugin implements IGeyserBootstrap {
|
||||
|
||||
this.geyserLogger = new GeyserSpongeLogger(logger, geyserConfig.isDebugMode());
|
||||
this.connector = GeyserConnector.start(PlatformType.SPONGE, this);
|
||||
this.geyserCommandManager = new GeyserSpongeCommandManager(Sponge.getCommandManager(), connector);
|
||||
|
||||
Sponge.getCommandManager().register(this, new GeyserSpongeCommandExecutor(connector), "geyser");
|
||||
}
|
||||
@ -105,6 +110,11 @@ public class GeyserSpongePlugin implements IGeyserBootstrap {
|
||||
return geyserLogger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandManager getGeyserCommandManager() {
|
||||
return this.geyserCommandManager;
|
||||
}
|
||||
|
||||
@Listener
|
||||
public void onServerStart(GameStartedServerEvent event) {
|
||||
onEnable();
|
||||
|
@ -95,6 +95,6 @@ public class GeyserSpongeCommandExecutor implements CommandCallable {
|
||||
}
|
||||
|
||||
private GeyserCommand getCommand(String label) {
|
||||
return connector.getCommandMap().getCommands().get(label);
|
||||
return connector.getCommandManager().getCommands().get(label);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Geyser
|
||||
*/
|
||||
|
||||
package org.geysermc.platform.sponge.command;
|
||||
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
import org.geysermc.connector.command.CommandManager;
|
||||
import org.spongepowered.api.Sponge;
|
||||
import org.spongepowered.api.command.CommandMapping;
|
||||
import org.spongepowered.api.text.Text;
|
||||
|
||||
public class GeyserSpongeCommandManager extends CommandManager {
|
||||
|
||||
private org.spongepowered.api.command.CommandManager handle;
|
||||
|
||||
public GeyserSpongeCommandManager(org.spongepowered.api.command.CommandManager handle, GeyserConnector connector) {
|
||||
super(connector);
|
||||
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
@Override
|
||||
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();
|
||||
}
|
||||
}
|
@ -32,11 +32,14 @@ import java.util.UUID;
|
||||
import org.geysermc.common.PlatformType;
|
||||
import org.geysermc.common.bootstrap.IGeyserBootstrap;
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
import org.geysermc.connector.command.CommandManager;
|
||||
import org.geysermc.connector.utils.FileUtils;
|
||||
import org.geysermc.platform.standalone.command.GeyserCommandManager;
|
||||
import org.geysermc.platform.standalone.console.GeyserLogger;
|
||||
|
||||
public class GeyserBootstrap implements IGeyserBootstrap {
|
||||
|
||||
|
||||
private GeyserCommandManager geyserCommandManager;
|
||||
private GeyserConfiguration geyserConfig;
|
||||
private GeyserLogger geyserLogger;
|
||||
|
||||
@ -49,7 +52,7 @@ public class GeyserBootstrap implements IGeyserBootstrap {
|
||||
@Override
|
||||
public void onEnable() {
|
||||
geyserLogger = new GeyserLogger();
|
||||
|
||||
|
||||
LoopbackUtil.checkLoopback(geyserLogger);
|
||||
|
||||
try {
|
||||
@ -62,6 +65,7 @@ public class GeyserBootstrap implements IGeyserBootstrap {
|
||||
|
||||
connector = GeyserConnector.start(PlatformType.STANDALONE, this);
|
||||
geyserLogger.start();
|
||||
geyserCommandManager = new GeyserCommandManager(connector);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -79,4 +83,9 @@ public class GeyserBootstrap implements IGeyserBootstrap {
|
||||
public GeyserLogger getGeyserLogger() {
|
||||
return geyserLogger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandManager getGeyserCommandManager() {
|
||||
return geyserCommandManager;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Geyser
|
||||
*/
|
||||
|
||||
package org.geysermc.platform.standalone.command;
|
||||
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
import org.geysermc.connector.command.CommandManager;
|
||||
|
||||
public class GeyserCommandManager extends CommandManager {
|
||||
|
||||
public GeyserCommandManager(GeyserConnector connector) {
|
||||
super(connector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription(String command) {
|
||||
return ""; // this is not sent over the protocol, so we return none
|
||||
}
|
||||
}
|
@ -47,7 +47,7 @@ public class GeyserLogger extends SimpleTerminalConsole implements IGeyserLogger
|
||||
|
||||
@Override
|
||||
protected void runCommand(String line) {
|
||||
GeyserConnector.getInstance().getCommandMap().runCommand(this, line);
|
||||
GeyserConnector.getInstance().getCommandManager().runCommand(this, line);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -38,6 +38,7 @@ import org.geysermc.common.bootstrap.IGeyserBootstrap;
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
import org.geysermc.connector.utils.FileUtils;
|
||||
import org.geysermc.platform.velocity.command.GeyserVelocityCommandExecutor;
|
||||
import org.geysermc.platform.velocity.command.GeyserVelocityCommandManager;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
@ -53,6 +54,7 @@ public class GeyserVelocityPlugin implements IGeyserBootstrap {
|
||||
@Inject
|
||||
private CommandManager commandManager;
|
||||
|
||||
private GeyserVelocityCommandManager geyserCommandManager;
|
||||
private GeyserVelocityConfiguration geyserConfig;
|
||||
private GeyserVelocityLogger geyserLogger;
|
||||
|
||||
@ -74,6 +76,7 @@ public class GeyserVelocityPlugin implements IGeyserBootstrap {
|
||||
this.geyserLogger = new GeyserVelocityLogger(logger, geyserConfig.isDebugMode());
|
||||
this.connector = GeyserConnector.start(PlatformType.VELOCITY, this);
|
||||
|
||||
this.geyserCommandManager = new GeyserVelocityCommandManager(connector);
|
||||
this.commandManager.register(new GeyserVelocityCommandExecutor(connector), "geyser");
|
||||
}
|
||||
|
||||
@ -92,6 +95,11 @@ public class GeyserVelocityPlugin implements IGeyserBootstrap {
|
||||
return geyserLogger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.geysermc.connector.command.CommandManager getGeyserCommandManager() {
|
||||
return this.geyserCommandManager;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onInit(ProxyInitializeEvent event) {
|
||||
onEnable();
|
||||
|
@ -57,6 +57,6 @@ public class GeyserVelocityCommandExecutor implements Command {
|
||||
}
|
||||
|
||||
private GeyserCommand getCommand(String label) {
|
||||
return connector.getCommandMap().getCommands().get(label);
|
||||
return connector.getCommandManager().getCommands().get(label);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Geyser
|
||||
*/
|
||||
|
||||
package org.geysermc.platform.velocity.command;
|
||||
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
import org.geysermc.connector.command.CommandManager;
|
||||
|
||||
public class GeyserVelocityCommandManager extends CommandManager {
|
||||
|
||||
public GeyserVelocityCommandManager(GeyserConnector connector) {
|
||||
super(connector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription(String command) {
|
||||
return ""; // no support for command descriptions in velocity
|
||||
}
|
||||
}
|
@ -26,6 +26,7 @@
|
||||
package org.geysermc.common.bootstrap;
|
||||
|
||||
import org.geysermc.common.IGeyserConfiguration;
|
||||
import org.geysermc.common.command.ICommandManager;
|
||||
import org.geysermc.common.logger.IGeyserLogger;
|
||||
|
||||
public interface IGeyserBootstrap {
|
||||
@ -37,4 +38,6 @@ public interface IGeyserBootstrap {
|
||||
IGeyserConfiguration getGeyserConfig();
|
||||
|
||||
IGeyserLogger getGeyserLogger();
|
||||
|
||||
ICommandManager getGeyserCommandManager();
|
||||
}
|
||||
|
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Geyser
|
||||
*/
|
||||
|
||||
package org.geysermc.common.command;
|
||||
|
||||
public interface ICommandManager {
|
||||
|
||||
String getDescription(String command);
|
||||
}
|
@ -35,7 +35,7 @@ import org.geysermc.common.AuthType;
|
||||
import org.geysermc.common.PlatformType;
|
||||
import org.geysermc.common.bootstrap.IGeyserBootstrap;
|
||||
import org.geysermc.common.logger.IGeyserLogger;
|
||||
import org.geysermc.connector.command.GeyserCommandMap;
|
||||
import org.geysermc.connector.command.CommandManager;
|
||||
import org.geysermc.connector.metrics.Metrics;
|
||||
import org.geysermc.connector.network.ConnectorServerEventHandler;
|
||||
import org.geysermc.connector.network.remote.RemoteServer;
|
||||
@ -50,7 +50,6 @@ import java.text.DecimalFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@ -70,8 +69,6 @@ public class GeyserConnector {
|
||||
private RemoteServer remoteServer;
|
||||
private AuthType authType;
|
||||
|
||||
private GeyserCommandMap commandMap;
|
||||
|
||||
private boolean shuttingDown = false;
|
||||
|
||||
private final ScheduledExecutorService generalThreadPool;
|
||||
@ -108,7 +105,6 @@ public class GeyserConnector {
|
||||
Toolbox.init();
|
||||
Translators.start();
|
||||
|
||||
commandMap = new GeyserCommandMap(this);
|
||||
remoteServer = new RemoteServer(config.getRemote().getAddress(), config.getRemote().getPort());
|
||||
authType = AuthType.getByName(config.getRemote().getAuthType());
|
||||
|
||||
@ -182,8 +178,7 @@ public class GeyserConnector {
|
||||
players.clear();
|
||||
remoteServer = null;
|
||||
authType = null;
|
||||
commandMap.getCommands().clear();
|
||||
commandMap = null;
|
||||
this.getCommandManager().getCommands().clear();
|
||||
|
||||
bootstrap.getGeyserLogger().info("Geyser shutdown successfully.");
|
||||
}
|
||||
@ -213,6 +208,10 @@ public class GeyserConnector {
|
||||
return bootstrap.getGeyserConfig();
|
||||
}
|
||||
|
||||
public CommandManager getCommandManager() {
|
||||
return (CommandManager) bootstrap.getGeyserCommandManager();
|
||||
}
|
||||
|
||||
public static GeyserConnector getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
@ -26,6 +26,7 @@
|
||||
package org.geysermc.connector.command;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.geysermc.common.command.ICommandManager;
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
import org.geysermc.connector.command.defaults.HelpCommand;
|
||||
import org.geysermc.connector.command.defaults.ReloadCommand;
|
||||
@ -35,14 +36,14 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class GeyserCommandMap {
|
||||
public abstract class CommandManager implements ICommandManager {
|
||||
|
||||
@Getter
|
||||
private final Map<String, GeyserCommand> commands = Collections.synchronizedMap(new HashMap<>());
|
||||
|
||||
private GeyserConnector connector;
|
||||
|
||||
public GeyserCommandMap(GeyserConnector connector) {
|
||||
public CommandManager(GeyserConnector connector) {
|
||||
this.connector = connector;
|
||||
|
||||
registerCommand(new HelpCommand(connector, "help", "Shows help for all registered commands.", "geyser.command.help"));
|
@ -49,8 +49,8 @@ public class HelpCommand extends GeyserCommand {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
sender.sendMessage("---- Showing Help For: Geyser (Page 1/1) ----");
|
||||
Map<String, GeyserCommand> cmds = connector.getCommandMap().getCommands();
|
||||
List<String> commands = connector.getCommandMap().getCommands().keySet().stream().sorted().collect(Collectors.toList());
|
||||
Map<String, GeyserCommand> cmds = connector.getCommandManager().getCommands();
|
||||
List<String> commands = connector.getCommandManager().getCommands().keySet().stream().sorted().collect(Collectors.toList());
|
||||
commands.forEach(cmd -> sender.sendMessage(ChatColor.YELLOW + "/geyser " + cmd + ChatColor.WHITE + ": " + cmds.get(cmd).getDescription()));
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ package org.geysermc.connector.network.translators.bedrock;
|
||||
|
||||
import org.geysermc.common.PlatformType;
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
import org.geysermc.connector.command.GeyserCommandMap;
|
||||
import org.geysermc.connector.command.CommandManager;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.network.translators.Translator;
|
||||
@ -42,9 +42,9 @@ public class BedrockCommandRequestTranslator extends PacketTranslator<CommandReq
|
||||
@Override
|
||||
public void translate(CommandRequestPacket packet, GeyserSession session) {
|
||||
String command = packet.getCommand().replace("/", "");
|
||||
GeyserCommandMap commandMap = GeyserConnector.getInstance().getCommandMap();
|
||||
if (session.getConnector().getPlatformType() == PlatformType.STANDALONE && command.startsWith("geyser ") && commandMap.getCommands().containsKey(command.split(" ")[1])) {
|
||||
commandMap.runCommand(session, command);
|
||||
CommandManager commandManager = GeyserConnector.getInstance().getCommandManager();
|
||||
if (session.getConnector().getPlatformType() == PlatformType.STANDALONE && command.startsWith("geyser ") && commandManager.getCommands().containsKey(command.split(" ")[1])) {
|
||||
commandManager.runCommand(session, command);
|
||||
} else {
|
||||
String message = packet.getCommand().trim();
|
||||
|
||||
|
@ -84,7 +84,7 @@ public class JavaServerDeclareCommandsTranslator extends PacketTranslator<Server
|
||||
CommandParamData[][] params = getParams(commandID, packet.getNodes()[commandID], packet.getNodes());
|
||||
|
||||
// Build the completed command and add it to the final list
|
||||
CommandData data = new CommandData(commandName, "A Java server command", flags, (byte) 0, aliases, params);
|
||||
CommandData data = new CommandData(commandName, session.getConnector().getCommandManager().getDescription(commandName), flags, (byte) 0, aliases, params);
|
||||
commandData.add(data);
|
||||
}
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren