2019-12-01 21:16:52 +00:00
|
|
|
/*
|
2020-04-15 19:39:21 +00:00
|
|
|
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
|
2019-12-01 21:16:52 +00:00
|
|
|
*
|
|
|
|
* 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;
|
|
|
|
|
2020-05-03 20:30:20 +00:00
|
|
|
import org.bukkit.Bukkit;
|
2019-12-01 21:16:52 +00:00
|
|
|
import org.bukkit.configuration.file.FileConfiguration;
|
2020-05-03 20:30:20 +00:00
|
|
|
import org.bukkit.plugin.Plugin;
|
2020-05-04 05:51:22 +00:00
|
|
|
import org.geysermc.connector.FloodgateKeyLoader;
|
2020-04-29 20:01:53 +00:00
|
|
|
import org.geysermc.connector.GeyserConfiguration;
|
2019-12-01 21:16:52 +00:00
|
|
|
|
2020-01-26 04:59:00 +00:00
|
|
|
import java.io.File;
|
2020-01-26 17:22:21 +00:00
|
|
|
import java.nio.file.Path;
|
|
|
|
import java.nio.file.Paths;
|
2019-12-01 21:16:52 +00:00
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Map;
|
|
|
|
|
2020-04-29 20:01:53 +00:00
|
|
|
public class GeyserBukkitConfiguration implements GeyserConfiguration {
|
2019-12-01 21:16:52 +00:00
|
|
|
|
|
|
|
private FileConfiguration config;
|
2020-01-26 04:59:00 +00:00
|
|
|
private File dataFolder;
|
2019-12-01 21:16:52 +00:00
|
|
|
|
|
|
|
private BukkitBedrockConfiguration bedrockConfig;
|
|
|
|
private BukkitRemoteConfiguration remoteConfig;
|
|
|
|
private BukkitMetricsInfo metricsInfo;
|
|
|
|
|
|
|
|
private Map<String, BukkitUserAuthenticationInfo> userAuthInfo = new HashMap<>();
|
|
|
|
|
2020-05-03 20:30:20 +00:00
|
|
|
private Path floodgateKey;
|
|
|
|
|
2020-01-26 04:59:00 +00:00
|
|
|
public GeyserBukkitConfiguration(File dataFolder, FileConfiguration config) {
|
|
|
|
this.dataFolder = dataFolder;
|
2019-12-01 21:16:52 +00:00
|
|
|
this.config = config;
|
|
|
|
|
|
|
|
bedrockConfig = new BukkitBedrockConfiguration();
|
|
|
|
remoteConfig = new BukkitRemoteConfiguration();
|
|
|
|
metricsInfo = new BukkitMetricsInfo();
|
|
|
|
|
|
|
|
if (!config.contains("userAuths"))
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (String key : config.getConfigurationSection("userAuths").getKeys(false)) {
|
|
|
|
userAuthInfo.put(key, new BukkitUserAuthenticationInfo(key));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-03 20:30:20 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2019-12-01 21:16:52 +00:00
|
|
|
@Override
|
|
|
|
public IBedrockConfiguration getBedrock() {
|
|
|
|
return bedrockConfig;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public IRemoteConfiguration getRemote() {
|
|
|
|
return remoteConfig;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Map<String, BukkitUserAuthenticationInfo> getUserAuths() {
|
|
|
|
return userAuthInfo;
|
|
|
|
}
|
|
|
|
|
2020-05-21 03:43:22 +00:00
|
|
|
@Override
|
|
|
|
public boolean isCommandSuggestions() {
|
|
|
|
return config.getBoolean("command-suggestions", true);
|
|
|
|
}
|
|
|
|
|
2019-12-01 21:16:52 +00:00
|
|
|
@Override
|
2020-05-23 21:50:04 +00:00
|
|
|
public boolean isPassthroughMotd() {
|
|
|
|
return config.getBoolean("passthrough-motd", false);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isPassthroughPlayerCounts() {
|
|
|
|
return config.getBoolean("passthrough-player-counts", false);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isLegacyPingPassthrough() {
|
|
|
|
return config.getBoolean("legacy-ping-passthrough", false);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getPingPassthroughInterval() {
|
|
|
|
return config.getInt("ping-passthrough-interval", 3);
|
2019-12-01 21:16:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@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);
|
|
|
|
}
|
|
|
|
|
2020-05-23 21:06:34 +00:00
|
|
|
@Override
|
|
|
|
public boolean isAllowThirdPartyEars() {
|
|
|
|
return config.getBoolean("allow-third-party-ears", false);
|
|
|
|
}
|
|
|
|
|
2020-04-05 01:58:23 +00:00
|
|
|
@Override
|
2020-04-05 09:13:47 +00:00
|
|
|
public String getDefaultLocale() {
|
|
|
|
return config.getString("default-locale", "en_us");
|
|
|
|
}
|
2020-04-05 01:58:23 +00:00
|
|
|
|
2020-01-04 05:58:58 +00:00
|
|
|
@Override
|
2020-01-26 17:22:21 +00:00
|
|
|
public Path getFloodgateKeyFile() {
|
2020-05-03 20:30:20 +00:00
|
|
|
return floodgateKey;
|
2020-01-04 05:58:58 +00:00
|
|
|
}
|
|
|
|
|
2020-04-29 20:01:53 +00:00
|
|
|
@Override
|
|
|
|
public boolean isCacheChunks() {
|
|
|
|
return true; // We override this as with Bukkit, we have direct access to the server implementation
|
|
|
|
}
|
|
|
|
|
2020-05-23 21:02:51 +00:00
|
|
|
@Override
|
|
|
|
public boolean isAboveBedrockNetherBuilding() {
|
|
|
|
return config.getBoolean("above-bedrock-nether-building", false);
|
|
|
|
}
|
|
|
|
|
2019-12-01 21:16:52 +00:00
|
|
|
@Override
|
|
|
|
public IMetricsInfo getMetrics() {
|
|
|
|
return metricsInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
public class BukkitBedrockConfiguration 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 BukkitRemoteConfiguration 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 BukkitUserAuthenticationInfo implements IUserAuthenticationInfo {
|
|
|
|
|
|
|
|
private String key;
|
|
|
|
|
|
|
|
public BukkitUserAuthenticationInfo(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 BukkitMetricsInfo implements IMetricsInfo {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isEnabled() {
|
|
|
|
return config.getBoolean("metrics.enabled", true);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getUniqueId() {
|
|
|
|
return config.getString("metrics.uuid", "generateduuid");
|
|
|
|
}
|
|
|
|
}
|
2020-05-21 03:43:22 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getConfigVersion() {
|
|
|
|
return config.getInt("config-version", 0);
|
|
|
|
}
|
2019-12-01 21:16:52 +00:00
|
|
|
}
|