diff --git a/api/pom.xml b/api/pom.xml index 2bb85be2..2d4b1239 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -14,7 +14,7 @@ org.projectlombok lombok 1.18.4 - compile + provided com.google.code.gson diff --git a/bootstrap/bukkit/pom.xml b/bootstrap/bukkit/pom.xml index 02b7d9a2..cbc0ef15 100644 --- a/bootstrap/bukkit/pom.xml +++ b/bootstrap/bukkit/pom.xml @@ -11,12 +11,6 @@ bootstrap-bukkit - - org.geysermc - common - 1.0-SNAPSHOT - compile - org.geysermc connector @@ -54,7 +48,6 @@ ${outputName}-Bukkit - false true diff --git a/bootstrap/bungeecord/pom.xml b/bootstrap/bungeecord/pom.xml new file mode 100644 index 00000000..3f26909e --- /dev/null +++ b/bootstrap/bungeecord/pom.xml @@ -0,0 +1,56 @@ + + + 4.0.0 + + org.geysermc + bootstrap-parent + 1.0-SNAPSHOT + ../ + + bootstrap-bungeecord + + + org.geysermc + connector + 1.0-SNAPSHOT + compile + + + net.md-5 + bungeecord-api + 1.14-SNAPSHOT + provided + + + + ${outputName}-BungeeCord-noshade + clean install + + + src/main/resources/ + true + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.1.0 + + + package + + shade + + + + + ${outputName}-BungeeCord + true + + + + + \ No newline at end of file diff --git a/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeeConfiguration.java b/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeeConfiguration.java new file mode 100644 index 00000000..931a09fa --- /dev/null +++ b/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeeConfiguration.java @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2019 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; + +import net.md_5.bungee.config.Configuration; + +import org.geysermc.common.IGeyserConfiguration; + +import java.util.HashMap; +import java.util.Map; + +public class GeyserBungeeConfiguration implements IGeyserConfiguration { + + private Configuration config; + + private BungeeBedrockConfiguration bedrockConfig; + private BungeeRemoteConfiguration remoteConfig; + private BungeeMetricsInfo metricsInfo; + + private Map userAuthInfo = new HashMap<>(); + + public GeyserBungeeConfiguration(Configuration config) { + this.config = config; + + bedrockConfig = new BungeeBedrockConfiguration(); + remoteConfig = new BungeeRemoteConfiguration(); + metricsInfo = new BungeeMetricsInfo(); + + if (!config.contains("userAuths")) + return; + + for (String key : config.getSection("userAuths").getKeys()) { + userAuthInfo.put(key, new BungeeUserAuthenticationInfo(key)); + } + } + + @Override + public BungeeBedrockConfiguration getBedrock() { + return bedrockConfig; + } + + @Override + public BungeeRemoteConfiguration getRemote() { + return remoteConfig; + } + + @Override + public Map getUserAuths() { + return userAuthInfo; + } + + @Override + public boolean isPingPassthrough() { + return config.getBoolean("ping-passthrough", false); + } + + @Override + public int getMaxPlayers() { + return config.getInt("max-players", 10); + } + + @Override + public boolean isDebugMode() { + return config.getBoolean("debug-mode", false); + } + + @Override + public int getGeneralThreadPool() { + return config.getInt("general-thread-pool", 32); + } + + @Override + public boolean isAllowThirdPartyCapes() { + return config.getBoolean("allow-third-party-capes", true); + } + + @Override + public BungeeMetricsInfo getMetrics() { + return metricsInfo; + } + + public class BungeeBedrockConfiguration implements IBedrockConfiguration { + + @Override + public String getAddress() { + return config.getString("bedrock.address", "0.0.0.0"); + } + + @Override + public int getPort() { + return config.getInt("bedrock.port", 25565); + } + + @Override + public String getMotd1() { + return config.getString("bedrock.motd1", "GeyserMC"); + } + + @Override + public String getMotd2() { + return config.getString("bedrock.motd2", "GeyserMC"); + } + } + + public class BungeeRemoteConfiguration implements IRemoteConfiguration { + + @Override + public String getAddress() { + return config.getString("remote.address", "127.0.0.1"); + } + + @Override + public int getPort() { + return config.getInt("remote.port", 25565); + } + + @Override + public String getAuthType() { + return config.getString("remote.auth-type", "online"); + } + } + + public class BungeeUserAuthenticationInfo implements IUserAuthenticationInfo { + + private String key; + + public BungeeUserAuthenticationInfo(String key) { + this.key = key; + } + + @Override + public String getEmail() { + return config.getString("userAuths." + key + ".email"); + } + + @Override + public String getPassword() { + return config.getString("userAuths." + key + ".password"); + } + } + + public class BungeeMetricsInfo implements IMetricsInfo { + + @Override + public boolean isEnabled() { + return config.getBoolean("metrics.enabled", true); + } + + @Override + public String getUniqueId() { + return config.getString("metrics.uuid", "generateduuid"); + } + } +} diff --git a/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeeLogger.java b/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeeLogger.java new file mode 100644 index 00000000..671f055d --- /dev/null +++ b/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeeLogger.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2019 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; + +import java.util.logging.Level; +import java.util.logging.Logger; + +public class GeyserBungeeLogger implements org.geysermc.api.logger.Logger { + + private Logger logger; + private boolean debugMode; + + public GeyserBungeeLogger(Logger logger, boolean debugMode) { + this.logger = logger; + this.debugMode = debugMode; + } + + @Override + public void severe(String message) { + logger.severe(message); + } + + @Override + public void severe(String message, Throwable error) { + logger.log(Level.SEVERE, message, error); + } + + @Override + public void error(String message) { + logger.warning(message); + } + + @Override + public void error(String message, Throwable error) { + logger.log(Level.WARNING, message, error); + } + + @Override + public void warning(String message) { + error(message); + } + + @Override + public void info(String message) { + logger.info(message); + } + + @Override + public void debug(String message) { + if (debugMode) + info(message); + } + + @Override + public void setDebug(boolean debug) { + debugMode = debug; + } +} diff --git a/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeePlugin.java b/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeePlugin.java new file mode 100644 index 00000000..0a97230d --- /dev/null +++ b/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeePlugin.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2019 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; + +import net.md_5.bungee.api.plugin.Plugin; +import net.md_5.bungee.config.Configuration; +import net.md_5.bungee.config.ConfigurationProvider; +import net.md_5.bungee.config.YamlConfiguration; + +import org.geysermc.connector.GeyserConnector; +import org.geysermc.common.bootstrap.IGeyserBootstrap; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.util.UUID; + +public class GeyserBungeePlugin extends Plugin implements IGeyserBootstrap { + + private GeyserBungeeConfiguration geyserConfig; + private GeyserBungeeLogger geyserLogger; + + @Override + public void onEnable() { + if (!getDataFolder().exists()) + getDataFolder().mkdir(); + + File file = new File(getDataFolder(), "config.yml"); + Configuration configuration = null; + + if (!file.exists()) { + try (InputStream in = getResourceAsStream("config.yml")) { + Files.copy(in, file.toPath()); + configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(getDataFolder(), "config.yml")); + } catch (IOException ex) { + geyserLogger.severe("Failed to read/create config.yml! Make sure it's up to date and/or readable+writable!", ex); + return; + } + } + + if (configuration == null) { + geyserLogger.severe("Failed to read/create config.yml! Make sure it's up to date and/or readable+writable!"); + return; + } + + geyserConfig = new GeyserBungeeConfiguration(configuration); + + if (geyserConfig.getMetrics().getUniqueId().equals("generateduuid")) { + configuration.set("metrics.uuid", UUID.randomUUID().toString()); + try { + ConfigurationProvider.getProvider(YamlConfiguration.class).save(configuration, new File(getDataFolder(), "config.yml")); + } catch (IOException ex) { + geyserLogger.severe("Failed to read/create config.yml! Make sure it's up to date and/or readable+writable!", ex); + return; + } + } + + geyserLogger = new GeyserBungeeLogger(getLogger(), geyserConfig.isDebugMode()); + + GeyserConnector.start(this, false); + } + + @Override + public void onDisable() { + GeyserConnector.stop(); + } + + @Override + public GeyserBungeeConfiguration getGeyserConfig() { + return geyserConfig; + } + + @Override + public GeyserBungeeLogger getGeyserLogger() { + return geyserLogger; + } +} diff --git a/bootstrap/bungeecord/src/main/resources/bungee.yml b/bootstrap/bungeecord/src/main/resources/bungee.yml new file mode 100644 index 00000000..8781ea31 --- /dev/null +++ b/bootstrap/bungeecord/src/main/resources/bungee.yml @@ -0,0 +1,5 @@ +main: org.geysermc.platform.bungeecord.GeyserBungeePlugin +name: ${outputName}-BungeeCord +author: ${project.organization.name} +website: ${project.organization.url} +version: ${project.version} \ No newline at end of file diff --git a/bootstrap/pom.xml b/bootstrap/pom.xml index 5c91b817..7cc7e2ba 100644 --- a/bootstrap/pom.xml +++ b/bootstrap/pom.xml @@ -25,11 +25,15 @@ sponge-repo https://repo.spongepowered.org/maven + + bungeecord-repo + https://oss.sonatype.org/content/repositories/snapshots + bukkit - + bungeecord + standalone diff --git a/bootstrap/standalone/pom.xml b/bootstrap/standalone/pom.xml index 3c38a6c0..122b29ab 100644 --- a/bootstrap/standalone/pom.xml +++ b/bootstrap/standalone/pom.xml @@ -11,12 +11,6 @@ bootstrap-standalone - - org.geysermc - common - 1.0-SNAPSHOT - compile - org.geysermc connector @@ -54,7 +48,6 @@ ${outputName} - false true diff --git a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserBootstrap.java b/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserBootstrap.java index 014cf83e..f769c52f 100644 --- a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserBootstrap.java +++ b/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserBootstrap.java @@ -56,7 +56,7 @@ public class GeyserBootstrap implements IGeyserBootstrap { File configFile = FileUtils.fileOrCopiedFromResource("config.yml", (x) -> x.replaceAll("generateduuid", UUID.randomUUID().toString())); geyserConfig = FileUtils.loadConfig(configFile, GeyserConfiguration.class); } catch (IOException ex) { - getGeyserLogger().severe("Failed to read/create config.yml! Make sure it's up to date and/or readable+writable!", ex); + geyserLogger.severe("Failed to read/create config.yml! Make sure it's up to date and/or readable+writable!", ex); System.exit(0); } diff --git a/connector/pom.xml b/connector/pom.xml index c0008f35..d8c42bcf 100644 --- a/connector/pom.xml +++ b/connector/pom.xml @@ -12,12 +12,6 @@ connector 1.0-SNAPSHOT - - org.geysermc - api - 1.0-SNAPSHOT - compile - org.geysermc common @@ -49,18 +43,6 @@ jar compile - - org.slf4j - slf4j-api - 1.7.5 - compile - - - org.slf4j - slf4j-simple - 1.6.4 - compile - org.projectlombok lombok @@ -146,7 +128,6 @@ - true true diff --git a/pom.xml b/pom.xml index f02c509a..ce4ad9e9 100644 --- a/pom.xml +++ b/pom.xml @@ -106,7 +106,6 @@ maven-shade-plugin 3.1.0 - false true