mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Merge branch 'master' into feature/sounds
This commit is contained in:
commit
7d67b65777
8 changed files with 98 additions and 9 deletions
|
@ -25,7 +25,10 @@
|
||||||
|
|
||||||
package org.geysermc.platform.bukkit;
|
package org.geysermc.platform.bukkit;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.geysermc.connector.FloodgateKeyLoader;
|
||||||
import org.geysermc.connector.GeyserConfiguration;
|
import org.geysermc.connector.GeyserConfiguration;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -45,6 +48,8 @@ public class GeyserBukkitConfiguration implements GeyserConfiguration {
|
||||||
|
|
||||||
private Map<String, BukkitUserAuthenticationInfo> userAuthInfo = new HashMap<>();
|
private Map<String, BukkitUserAuthenticationInfo> userAuthInfo = new HashMap<>();
|
||||||
|
|
||||||
|
private Path floodgateKey;
|
||||||
|
|
||||||
public GeyserBukkitConfiguration(File dataFolder, FileConfiguration config) {
|
public GeyserBukkitConfiguration(File dataFolder, FileConfiguration config) {
|
||||||
this.dataFolder = dataFolder;
|
this.dataFolder = dataFolder;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
@ -61,6 +66,11 @@ public class GeyserBukkitConfiguration implements GeyserConfiguration {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void loadFloodgate(GeyserBukkitPlugin plugin) {
|
||||||
|
Plugin floodgate = Bukkit.getPluginManager().getPlugin("floodgate-bukkit");
|
||||||
|
floodgateKey = FloodgateKeyLoader.getKey(plugin.getGeyserLogger(), this, Paths.get(dataFolder.toString(), config.getString("floodgate-key-file", "public-key.pem")), floodgate, floodgate != null ? floodgate.getDataFolder().toPath() : null);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBedrockConfiguration getBedrock() {
|
public IBedrockConfiguration getBedrock() {
|
||||||
return bedrockConfig;
|
return bedrockConfig;
|
||||||
|
@ -108,7 +118,7 @@ public class GeyserBukkitConfiguration implements GeyserConfiguration {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Path getFloodgateKeyFile() {
|
public Path getFloodgateKeyFile() {
|
||||||
return Paths.get(dataFolder.toString(), config.getString("floodgate-key-file", "public-key.pem"));
|
return floodgateKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -67,6 +67,9 @@ public class GeyserBukkitPlugin extends JavaPlugin implements GeyserBootstrap {
|
||||||
saveConfig();
|
saveConfig();
|
||||||
|
|
||||||
this.geyserLogger = new GeyserBukkitLogger(getLogger(), geyserConfig.isDebugMode());
|
this.geyserLogger = new GeyserBukkitLogger(getLogger(), geyserConfig.isDebugMode());
|
||||||
|
|
||||||
|
geyserConfig.loadFloodgate(this);
|
||||||
|
|
||||||
this.connector = GeyserConnector.start(PlatformType.BUKKIT, this);
|
this.connector = GeyserConnector.start(PlatformType.BUKKIT, this);
|
||||||
|
|
||||||
this.geyserCommandManager = new GeyserBukkitCommandManager(this, connector);
|
this.geyserCommandManager = new GeyserBukkitCommandManager(this, connector);
|
||||||
|
|
|
@ -25,8 +25,9 @@
|
||||||
|
|
||||||
package org.geysermc.platform.bungeecord;
|
package org.geysermc.platform.bungeecord;
|
||||||
|
|
||||||
|
import net.md_5.bungee.api.plugin.Plugin;
|
||||||
import net.md_5.bungee.config.Configuration;
|
import net.md_5.bungee.config.Configuration;
|
||||||
|
import org.geysermc.connector.FloodgateKeyLoader;
|
||||||
import org.geysermc.connector.GeyserConfiguration;
|
import org.geysermc.connector.GeyserConfiguration;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -46,6 +47,8 @@ public class GeyserBungeeConfiguration implements GeyserConfiguration {
|
||||||
|
|
||||||
private Map<String, BungeeUserAuthenticationInfo> userAuthInfo = new HashMap<>();
|
private Map<String, BungeeUserAuthenticationInfo> userAuthInfo = new HashMap<>();
|
||||||
|
|
||||||
|
private Path floodgateKey;
|
||||||
|
|
||||||
public GeyserBungeeConfiguration(File dataFolder, Configuration config) {
|
public GeyserBungeeConfiguration(File dataFolder, Configuration config) {
|
||||||
this.dataFolder = dataFolder;
|
this.dataFolder = dataFolder;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
@ -62,6 +65,11 @@ public class GeyserBungeeConfiguration implements GeyserConfiguration {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void loadFloodgate(GeyserBungeePlugin plugin) {
|
||||||
|
Plugin floodgate = plugin.getProxy().getPluginManager().getPlugin("floodgate-bungee");
|
||||||
|
floodgateKey = FloodgateKeyLoader.getKey(plugin.getGeyserLogger(), this, Paths.get(dataFolder.toString(), config.getString("floodgate-key-file", "public-key.pem")), floodgate, floodgate != null ? floodgate.getDataFolder().toPath() : null);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BungeeBedrockConfiguration getBedrock() {
|
public BungeeBedrockConfiguration getBedrock() {
|
||||||
return bedrockConfig;
|
return bedrockConfig;
|
||||||
|
@ -109,7 +117,7 @@ public class GeyserBungeeConfiguration implements GeyserConfiguration {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Path getFloodgateKeyFile() {
|
public Path getFloodgateKeyFile() {
|
||||||
return Paths.get(dataFolder.toString(), config.getString("floodgate-key-file", "public-key.pem"));
|
return floodgateKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -116,6 +116,9 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.geyserLogger = new GeyserBungeeLogger(getLogger(), geyserConfig.isDebugMode());
|
this.geyserLogger = new GeyserBungeeLogger(getLogger(), geyserConfig.isDebugMode());
|
||||||
|
|
||||||
|
geyserConfig.loadFloodgate(this);
|
||||||
|
|
||||||
this.connector = GeyserConnector.start(PlatformType.BUNGEECORD, this);
|
this.connector = GeyserConnector.start(PlatformType.BUNGEECORD, this);
|
||||||
|
|
||||||
this.geyserCommandManager = new GeyserBungeeCommandManager(connector);
|
this.geyserCommandManager = new GeyserBungeeCommandManager(connector);
|
||||||
|
|
|
@ -27,15 +27,18 @@ package org.geysermc.platform.velocity;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.velocitypowered.api.plugin.PluginContainer;
|
||||||
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import org.geysermc.connector.FloodgateKeyLoader;
|
||||||
import org.geysermc.connector.GeyserConfiguration;
|
import org.geysermc.connector.GeyserConfiguration;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
@Getter
|
@Getter
|
||||||
|
@ -72,9 +75,16 @@ public class GeyserVelocityConfiguration implements GeyserConfiguration {
|
||||||
|
|
||||||
private MetricsInfo metrics;
|
private MetricsInfo metrics;
|
||||||
|
|
||||||
|
private Path floodgateKey;
|
||||||
|
|
||||||
|
public void loadFloodgate(GeyserVelocityPlugin plugin, ProxyServer proxyServer, File dataFolder) {
|
||||||
|
Optional<PluginContainer> floodgate = proxyServer.getPluginManager().getPlugin("floodgate");
|
||||||
|
floodgateKey = FloodgateKeyLoader.getKey(plugin.getGeyserLogger(), this, Paths.get(dataFolder.toString(), floodgateKeyFile.isEmpty() ? floodgateKeyFile : "public-key.pem"), floodgate.get(), Paths.get("plugins/floodgate/"));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Path getFloodgateKeyFile() {
|
public Path getFloodgateKeyFile() {
|
||||||
return Paths.get(floodgateKeyFile);
|
return floodgateKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class GeyserVelocityPlugin implements GeyserBootstrap {
|
||||||
private Logger logger;
|
private Logger logger;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ProxyServer server;
|
private ProxyServer proxyServer;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private CommandManager commandManager;
|
private CommandManager commandManager;
|
||||||
|
@ -67,8 +67,9 @@ public class GeyserVelocityPlugin implements GeyserBootstrap {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
File configDir = new File("plugins/" + GeyserConnector.NAME + "-Velocity/");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
File configDir = new File("plugins/" + GeyserConnector.NAME + "-Velocity/");
|
|
||||||
if (!configDir.exists())
|
if (!configDir.exists())
|
||||||
configDir.mkdir();
|
configDir.mkdir();
|
||||||
File configFile = FileUtils.fileOrCopiedFromResource(new File(configDir, "config.yml"), "config.yml", (x) -> x.replaceAll("generateduuid", UUID.randomUUID().toString()));
|
File configFile = FileUtils.fileOrCopiedFromResource(new File(configDir, "config.yml"), "config.yml", (x) -> x.replaceAll("generateduuid", UUID.randomUUID().toString()));
|
||||||
|
@ -78,7 +79,7 @@ public class GeyserVelocityPlugin implements GeyserBootstrap {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
InetSocketAddress javaAddr = server.getBoundAddress();
|
InetSocketAddress javaAddr = proxyServer.getBoundAddress();
|
||||||
|
|
||||||
// Don't change the ip if its listening on all interfaces
|
// Don't change the ip if its listening on all interfaces
|
||||||
// By default this should be 127.0.0.1 but may need to be changed in some circumstances
|
// By default this should be 127.0.0.1 but may need to be changed in some circumstances
|
||||||
|
@ -89,6 +90,9 @@ public class GeyserVelocityPlugin implements GeyserBootstrap {
|
||||||
geyserConfig.getRemote().setPort(javaAddr.getPort());
|
geyserConfig.getRemote().setPort(javaAddr.getPort());
|
||||||
|
|
||||||
this.geyserLogger = new GeyserVelocityLogger(logger, geyserConfig.isDebugMode());
|
this.geyserLogger = new GeyserVelocityLogger(logger, geyserConfig.isDebugMode());
|
||||||
|
|
||||||
|
geyserConfig.loadFloodgate(this, proxyServer, configDir);
|
||||||
|
|
||||||
this.connector = GeyserConnector.start(PlatformType.VELOCITY, this);
|
this.connector = GeyserConnector.start(PlatformType.VELOCITY, this);
|
||||||
|
|
||||||
this.geyserCommandManager = new GeyserVelocityCommandManager(connector);
|
this.geyserCommandManager = new GeyserVelocityCommandManager(connector);
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
/*
|
||||||
|
* 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.connector;
|
||||||
|
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
public class FloodgateKeyLoader {
|
||||||
|
public static Path getKey(GeyserLogger logger, GeyserConfiguration config, Path floodgateKey, Object floodgate, Path floodgateFolder) {
|
||||||
|
if (!Files.exists(floodgateKey) && config.getRemote().getAuthType().equals("floodgate")) {
|
||||||
|
if (floodgate != null) {
|
||||||
|
Path autoKey = floodgateFolder.resolve("public-key.pem");
|
||||||
|
if (Files.exists(autoKey)) {
|
||||||
|
logger.info("Auto-loaded floodgate key");
|
||||||
|
floodgateKey = autoKey;
|
||||||
|
} else {
|
||||||
|
logger.error("Auth-type set to floodgate and the public key is missing!");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.error("Auth-type set to floodgate but floodgate is not installed!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return floodgateKey;
|
||||||
|
}
|
||||||
|
}
|
|
@ -59,6 +59,7 @@ public class JavaServerDeclareCommandsTranslator extends PacketTranslator<Server
|
||||||
|
|
||||||
// Make sure we don't have duplicated commands (happens if there is more than 1 root node)
|
// Make sure we don't have duplicated commands (happens if there is more than 1 root node)
|
||||||
if (commands.containsKey(nodeIndex)) { continue; }
|
if (commands.containsKey(nodeIndex)) { continue; }
|
||||||
|
if (commands.containsValue(node.getName())) { continue; }
|
||||||
|
|
||||||
// Get and update the commandArgs list with the found arguments
|
// Get and update the commandArgs list with the found arguments
|
||||||
if (node.getChildIndices().length >= 1) {
|
if (node.getChildIndices().length >= 1) {
|
||||||
|
|
Loading…
Reference in a new issue