mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Merge remote-tracking branch 'origin/master' into floodgate-2.0
# Conflicts: # bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeeConfiguration.java # bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/GeyserSpigotConfiguration.java # connector/src/main/java/org/geysermc/connector/GeyserConnector.java # connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java
This commit is contained in:
commit
5b317ec595
122 changed files with 3221 additions and 1121 deletions
|
@ -61,14 +61,34 @@
|
|||
<pattern>net.md_5.bungee.jni</pattern>
|
||||
<shadedPattern>org.geysermc.platform.bungeecord.shaded.jni</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.fasterxml.jackson</pattern>
|
||||
<shadedPattern>org.geysermc.platform.bungeecord.shaded.jackson</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>io.netty</pattern>
|
||||
<shadedPattern>org.geysermc.platform.bungeecord.shaded.netty</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.reflections.reflections</pattern>
|
||||
<pattern>org.reflections</pattern>
|
||||
<shadedPattern>org.geysermc.platform.bungeecord.shaded.reflections</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.google.common</pattern>
|
||||
<shadedPattern>org.geysermc.platform.bungeecord.shaded.google.common</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.google.guava</pattern>
|
||||
<shadedPattern>org.geysermc.platform.bungeecord.shaded.google.guava</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.dom4j</pattern>
|
||||
<shadedPattern>org.geysermc.platform.bungeecord.shaded.dom4j</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>net.kyori.adventure</pattern>
|
||||
<shadedPattern>org.geysermc.platform.bungeecord.shaded.adventure</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
|
|
@ -29,27 +29,22 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
|
|||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.Getter;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import net.md_5.bungee.config.Configuration;
|
||||
import org.geysermc.connector.FloodgateKeyLoader;
|
||||
import org.geysermc.connector.configuration.GeyserJacksonConfiguration;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
@Getter
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class GeyserBungeeConfiguration extends GeyserJacksonConfiguration {
|
||||
|
||||
public final class GeyserBungeeConfiguration extends GeyserJacksonConfiguration {
|
||||
@JsonIgnore
|
||||
private Path floodgateKey;
|
||||
private Path floodgateKeyPath;
|
||||
|
||||
public void loadFloodgate(GeyserBungeePlugin plugin, Configuration configuration) {
|
||||
public void loadFloodgate(GeyserBungeePlugin plugin) {
|
||||
Plugin floodgate = plugin.getProxy().getPluginManager().getPlugin("floodgate");
|
||||
floodgateKey = FloodgateKeyLoader.getKey(plugin.getGeyserLogger(), this, Paths.get(plugin.getDataFolder().toString(), configuration.getString("floodgate-key-file"), "public-key.pem"), floodgate, floodgate != null ? floodgate.getDataFolder().toPath() : null);
|
||||
}
|
||||
Path geyserDataFolder = plugin.getDataFolder().toPath();
|
||||
Path floodgateDataFolder = floodgate != null ? floodgate.getDataFolder().toPath() : null;
|
||||
|
||||
@Override
|
||||
public Path getFloodgateKeyFile() {
|
||||
return floodgateKey;
|
||||
floodgateKeyPath = FloodgateKeyLoader.getKeyPath(this, floodgate, floodgateDataFolder, geyserDataFolder, plugin.getGeyserLogger());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,19 +25,21 @@
|
|||
|
||||
package org.geysermc.platform.bungeecord;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.geysermc.connector.GeyserLogger;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class GeyserBungeeLogger implements GeyserLogger {
|
||||
private final Logger logger;
|
||||
@Getter @Setter
|
||||
private boolean debug;
|
||||
|
||||
private Logger logger;
|
||||
private boolean debugMode;
|
||||
|
||||
public GeyserBungeeLogger(Logger logger, boolean debugMode) {
|
||||
public GeyserBungeeLogger(Logger logger, boolean debug) {
|
||||
this.logger = logger;
|
||||
this.debugMode = debugMode;
|
||||
this.debug = debug;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -72,12 +74,8 @@ public class GeyserBungeeLogger implements GeyserLogger {
|
|||
|
||||
@Override
|
||||
public void debug(String message) {
|
||||
if (debugMode)
|
||||
if (debug) {
|
||||
info(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDebug(boolean debug) {
|
||||
debugMode = debug;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,13 +27,10 @@ package org.geysermc.platform.bungeecord;
|
|||
|
||||
import net.md_5.bungee.api.config.ListenerInfo;
|
||||
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.common.PlatformType;
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
import org.geysermc.connector.bootstrap.GeyserBootstrap;
|
||||
import org.geysermc.connector.command.CommandManager;
|
||||
import org.geysermc.connector.common.PlatformType;
|
||||
import org.geysermc.connector.configuration.GeyserConfiguration;
|
||||
import org.geysermc.connector.dump.BootstrapDumpInfo;
|
||||
import org.geysermc.connector.ping.GeyserLegacyPingPassthrough;
|
||||
|
@ -64,13 +61,11 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
|
|||
if (!getDataFolder().exists())
|
||||
getDataFolder().mkdir();
|
||||
|
||||
Configuration configuration = null;
|
||||
try {
|
||||
if (!getDataFolder().exists())
|
||||
getDataFolder().mkdir();
|
||||
File configFile = FileUtils.fileOrCopiedFromResource(new File(getDataFolder(), "config.yml"), "config.yml", (x) -> x.replaceAll("generateduuid", UUID.randomUUID().toString()));
|
||||
this.geyserConfig = FileUtils.loadConfig(configFile, GeyserBungeeConfiguration.class);
|
||||
configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(getDataFolder(), "config.yml"));
|
||||
} catch (IOException ex) {
|
||||
getLogger().log(Level.WARNING, LanguageUtils.getLocaleStringLog("geyser.config.failed"), ex);
|
||||
ex.printStackTrace();
|
||||
|
@ -83,6 +78,11 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
|
|||
|
||||
// By default this should be localhost but may need to be changed in some circumstances
|
||||
if (this.geyserConfig.getRemote().getAddress().equalsIgnoreCase("auto")) {
|
||||
this.geyserConfig.setAutoconfiguredRemote(true);
|
||||
// Don't use localhost if not listening on all interfaces
|
||||
if (!javaAddr.getHostString().equals("0.0.0.0") && !javaAddr.getHostString().equals("")) {
|
||||
this.geyserConfig.getRemote().setAddress(javaAddr.getHostString());
|
||||
}
|
||||
this.geyserConfig.getRemote().setPort(javaAddr.getPort());
|
||||
}
|
||||
|
||||
|
@ -97,9 +97,13 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
|
|||
if (geyserConfig.getRemote().getAuthType().equals("floodgate") && getProxy().getPluginManager().getPlugin("floodgate") == null) {
|
||||
geyserLogger.severe(LanguageUtils.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed") + " " + LanguageUtils.getLocaleStringLog("geyser.bootstrap.floodgate.disabling"));
|
||||
return;
|
||||
} else if (geyserConfig.isAutoconfiguredRemote() && getProxy().getPluginManager().getPlugin("floodgate-bungee") != null) {
|
||||
// Floodgate installed means that the user wants Floodgate authentication
|
||||
geyserLogger.debug("Auto-setting to Floodgate authentication.");
|
||||
geyserConfig.getRemote().setAuthType("floodgate");
|
||||
}
|
||||
|
||||
geyserConfig.loadFloodgate(this, configuration);
|
||||
geyserConfig.loadFloodgate(this);
|
||||
|
||||
this.connector = GeyserConnector.start(PlatformType.BUNGEECORD, this);
|
||||
|
||||
|
|
|
@ -20,13 +20,13 @@
|
|||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.14-R0.1-SNAPSHOT</version>
|
||||
<version>1.15.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>us.myles</groupId>
|
||||
<artifactId>viaversion</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<version>3.1.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -76,9 +76,25 @@
|
|||
<shadedPattern>org.geysermc.platform.spigot.shaded.jackson</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.reflections.reflections</pattern>
|
||||
<pattern>org.reflections</pattern>
|
||||
<shadedPattern>org.geysermc.platform.spigot.shaded.reflections</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.google.common</pattern>
|
||||
<shadedPattern>org.geysermc.platform.spigot.shaded.google.common</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.google.guava</pattern>
|
||||
<shadedPattern>org.geysermc.platform.spigot.shaded.google.guava</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.dom4j</pattern>
|
||||
<shadedPattern>org.geysermc.platform.spigot.shaded.dom4j</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>net.kyori.adventure</pattern>
|
||||
<shadedPattern>org.geysermc.platform.spigot.shaded.adventure</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
|
|
@ -27,7 +27,6 @@ package org.geysermc.platform.spigot;
|
|||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
@ -35,26 +34,19 @@ import org.geysermc.connector.FloodgateKeyLoader;
|
|||
import org.geysermc.connector.configuration.GeyserJacksonConfiguration;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
@Getter
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class GeyserSpigotConfiguration extends GeyserJacksonConfiguration {
|
||||
|
||||
@JsonProperty("floodgate-key-file")
|
||||
private String floodgateKeyFile;
|
||||
|
||||
public final class GeyserSpigotConfiguration extends GeyserJacksonConfiguration {
|
||||
@JsonIgnore
|
||||
private Path floodgateKey;
|
||||
private Path floodgateKeyPath;
|
||||
|
||||
public void loadFloodgate(GeyserSpigotPlugin plugin) {
|
||||
Plugin floodgate = Bukkit.getPluginManager().getPlugin("floodgate");
|
||||
floodgateKey = FloodgateKeyLoader.getKey(plugin.getGeyserLogger(), this, Paths.get(plugin.getDataFolder().toString(), plugin.getConfig().getString("floodgate-key-file", "public-key.pem")), floodgate, floodgate != null ? floodgate.getDataFolder().toPath() : null);
|
||||
}
|
||||
Path geyserDataFolder = plugin.getDataFolder().toPath();
|
||||
Path floodgateDataFolder = floodgate != null ? floodgate.getDataFolder().toPath() : null;
|
||||
|
||||
@Override
|
||||
public Path getFloodgateKeyFile() {
|
||||
return floodgateKey;
|
||||
floodgateKeyPath = FloodgateKeyLoader.getKeyPath(this, floodgate, floodgateDataFolder, geyserDataFolder, plugin.getGeyserLogger());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -26,7 +26,8 @@
|
|||
package org.geysermc.platform.spigot;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.geysermc.connector.GeyserLogger;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
@ -34,9 +35,9 @@ import java.util.logging.Logger;
|
|||
|
||||
@AllArgsConstructor
|
||||
public class GeyserSpigotLogger implements GeyserLogger {
|
||||
|
||||
private Logger logger;
|
||||
private boolean debugMode;
|
||||
private final Logger logger;
|
||||
@Getter @Setter
|
||||
private boolean debug;
|
||||
|
||||
@Override
|
||||
public void severe(String message) {
|
||||
|
@ -70,12 +71,8 @@ public class GeyserSpigotLogger implements GeyserLogger {
|
|||
|
||||
@Override
|
||||
public void debug(String message) {
|
||||
if (debugMode)
|
||||
if (debug) {
|
||||
info(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDebug(boolean debug) {
|
||||
debugMode = debug;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,10 +27,10 @@ package org.geysermc.platform.spigot;
|
|||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.geysermc.connector.common.PlatformType;
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
import org.geysermc.connector.bootstrap.GeyserBootstrap;
|
||||
import org.geysermc.connector.command.CommandManager;
|
||||
import org.geysermc.connector.common.PlatformType;
|
||||
import org.geysermc.connector.configuration.GeyserConfiguration;
|
||||
import org.geysermc.connector.dump.BootstrapDumpInfo;
|
||||
import org.geysermc.connector.network.translators.world.WorldManager;
|
||||
|
@ -56,7 +56,6 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
|
|||
private GeyserSpigotConfiguration geyserConfig;
|
||||
private GeyserSpigotLogger geyserLogger;
|
||||
private IGeyserPingPassthrough geyserSpigotPingPassthrough;
|
||||
private GeyserSpigotBlockPlaceListener blockPlaceListener;
|
||||
private GeyserSpigotWorldManager geyserWorldManager;
|
||||
|
||||
private GeyserConnector connector;
|
||||
|
@ -83,6 +82,11 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
|
|||
|
||||
// By default this should be localhost but may need to be changed in some circumstances
|
||||
if (this.geyserConfig.getRemote().getAddress().equalsIgnoreCase("auto")) {
|
||||
geyserConfig.setAutoconfiguredRemote(true);
|
||||
// Don't use localhost if not listening on all interfaces
|
||||
if (!Bukkit.getIp().equals("0.0.0.0") && !Bukkit.getIp().equals("")) {
|
||||
geyserConfig.getRemote().setAddress(Bukkit.getIp());
|
||||
}
|
||||
geyserConfig.getRemote().setPort(Bukkit.getPort());
|
||||
}
|
||||
|
||||
|
@ -97,6 +101,10 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
|
|||
geyserLogger.severe(LanguageUtils.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed") + " " + LanguageUtils.getLocaleStringLog("geyser.bootstrap.floodgate.disabling"));
|
||||
this.getPluginLoader().disablePlugin(this);
|
||||
return;
|
||||
} else if (geyserConfig.isAutoconfiguredRemote() && Bukkit.getPluginManager().getPlugin("floodgate-bukkit") != null) {
|
||||
// Floodgate installed means that the user wants Floodgate authentication
|
||||
geyserLogger.debug("Auto-setting to Floodgate authentication.");
|
||||
geyserConfig.getRemote().setAuthType("floodgate");
|
||||
}
|
||||
|
||||
geyserConfig.loadFloodgate(this);
|
||||
|
@ -115,10 +123,15 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
|
|||
// Used to determine if Block.getBlockData() is present.
|
||||
boolean isLegacy = !isCompatible(Bukkit.getServer().getVersion(), "1.13.0");
|
||||
if (isLegacy)
|
||||
geyserLogger.debug("Legacy version of Minecraft (1.12.2 or older) detected.");
|
||||
geyserLogger.debug("Legacy version of Minecraft (1.12.2 or older) detected; falling back to ViaVersion for block state retrieval.");
|
||||
|
||||
this.geyserWorldManager = new GeyserSpigotWorldManager(isLegacy, isViaVersion);
|
||||
this.blockPlaceListener = new GeyserSpigotBlockPlaceListener(connector, isLegacy, isViaVersion);
|
||||
boolean use3dBiomes = isCompatible(Bukkit.getServer().getVersion(), "1.16.0");
|
||||
if (!use3dBiomes) {
|
||||
geyserLogger.debug("Legacy version of Minecraft (1.15.2 or older) detected; not using 3D biomes.");
|
||||
}
|
||||
|
||||
this.geyserWorldManager = new GeyserSpigotWorldManager(isLegacy, use3dBiomes, isViaVersion);
|
||||
GeyserSpigotBlockPlaceListener blockPlaceListener = new GeyserSpigotBlockPlaceListener(connector, isLegacy, isViaVersion);
|
||||
|
||||
Bukkit.getServer().getPluginManager().registerEvents(blockPlaceListener, this);
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ public class GeyserSpigotBlockPlaceListener implements Listener {
|
|||
} else {
|
||||
javaBlockId = event.getBlockPlaced().getBlockData().getAsString();
|
||||
}
|
||||
placeBlockSoundPacket.setExtraData(BlockTranslator.getBedrockBlockId(BlockTranslator.getJavaIdBlockMap().get(javaBlockId)));
|
||||
placeBlockSoundPacket.setExtraData(BlockTranslator.getBedrockBlockId(BlockTranslator.getJavaIdBlockMap().getOrDefault(javaBlockId, 0)));
|
||||
placeBlockSoundPacket.setIdentifier(":");
|
||||
session.sendUpstreamPacket(placeBlockSoundPacket);
|
||||
session.setLastBlockPlacePosition(null);
|
||||
|
|
|
@ -25,34 +25,85 @@
|
|||
|
||||
package org.geysermc.platform.spigot.world;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
|
||||
import lombok.AllArgsConstructor;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.world.GeyserWorldManager;
|
||||
import org.geysermc.connector.network.translators.world.block.BlockTranslator;
|
||||
import org.geysermc.connector.utils.FileUtils;
|
||||
import org.geysermc.connector.utils.GameRule;
|
||||
import org.geysermc.connector.utils.LanguageUtils;
|
||||
import us.myles.ViaVersion.protocols.protocol1_13_1to1_13.Protocol1_13_1To1_13;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.data.MappingData;
|
||||
|
||||
@AllArgsConstructor
|
||||
import java.io.InputStream;
|
||||
|
||||
public class GeyserSpigotWorldManager extends GeyserWorldManager {
|
||||
|
||||
private final boolean isLegacy;
|
||||
// You need ViaVersion to connect to an older server with Geyser.
|
||||
// However, we still check for ViaVersion in case there's some other way that gets Geyser on a pre-1.13 Bukkit server
|
||||
private final boolean use3dBiomes;
|
||||
/**
|
||||
* You need ViaVersion to connect to an older server with Geyser.
|
||||
* However, we still check for ViaVersion in case there's some other way that gets Geyser on a pre-1.13 Bukkit server
|
||||
*/
|
||||
private final boolean isViaVersion;
|
||||
/**
|
||||
* Stores a list of {@link Biome} ordinal numbers to Minecraft biome numeric IDs.
|
||||
*
|
||||
* Working with the Biome enum in Spigot poses two problems:
|
||||
* 1: The Biome enum values change in both order and names over the years.
|
||||
* 2: There is no way to get the Minecraft biome ID from the name itself with Spigot.
|
||||
* To solve both of these problems, we store a JSON file of every Biome enum that has existed,
|
||||
* along with its 1.16 biome number.
|
||||
*
|
||||
* The key is the Spigot Biome ordinal; the value is the Minecraft Java biome numerical ID
|
||||
*/
|
||||
private final Int2IntMap biomeToIdMap = new Int2IntOpenHashMap(Biome.values().length);
|
||||
|
||||
public GeyserSpigotWorldManager(boolean isLegacy, boolean use3dBiomes, boolean isViaVersion) {
|
||||
this.isLegacy = isLegacy;
|
||||
this.use3dBiomes = use3dBiomes;
|
||||
this.isViaVersion = isViaVersion;
|
||||
|
||||
// Load the values into the biome-to-ID map
|
||||
InputStream biomeStream = FileUtils.getResource("biomes.json");
|
||||
JsonNode biomes;
|
||||
try {
|
||||
biomes = GeyserConnector.JSON_MAPPER.readTree(biomeStream);
|
||||
} catch (Exception e) {
|
||||
throw new AssertionError(LanguageUtils.getLocaleStringLog("geyser.toolbox.fail.runtime_java"), e);
|
||||
}
|
||||
// Only load in the biomes that are present in this version of Minecraft
|
||||
for (Biome enumBiome : Biome.values()) {
|
||||
if (biomes.has(enumBiome.toString())) {
|
||||
biomeToIdMap.put(enumBiome.ordinal(), biomes.get(enumBiome.toString()).intValue());
|
||||
} else {
|
||||
GeyserConnector.getInstance().getLogger().debug("No biome mapping found for " + enumBiome.toString() +
|
||||
", defaulting to 0");
|
||||
biomeToIdMap.put(enumBiome.ordinal(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockAt(GeyserSession session, int x, int y, int z) {
|
||||
if (session.getPlayerEntity() == null) {
|
||||
return BlockTranslator.AIR;
|
||||
}
|
||||
if (Bukkit.getPlayer(session.getPlayerEntity().getUsername()) == null) {
|
||||
return BlockTranslator.AIR;
|
||||
}
|
||||
if (isLegacy) {
|
||||
return getLegacyBlock(session, x, y, z, isViaVersion);
|
||||
}
|
||||
return BlockTranslator.getJavaIdBlockMap().get(Bukkit.getPlayer(session.getPlayerEntity().getUsername()).getWorld().getBlockAt(x, y, z).getBlockData().getAsString());
|
||||
//TODO possibly: detect server version for all versions and use ViaVersion for block state mappings like below
|
||||
return BlockTranslator.getJavaIdBlockMap().getOrDefault(Bukkit.getPlayer(session.getPlayerEntity().getUsername()).getWorld().getBlockAt(x, y, z).getBlockData().getAsString(), 0);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
@ -74,6 +125,43 @@ public class GeyserSpigotWorldManager extends GeyserWorldManager {
|
|||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public int[] getBiomeDataAt(GeyserSession session, int x, int z) {
|
||||
if (session.getPlayerEntity() == null) {
|
||||
return new int[1024];
|
||||
}
|
||||
int[] biomeData = new int[1024];
|
||||
World world = Bukkit.getPlayer(session.getPlayerEntity().getUsername()).getWorld();
|
||||
int chunkX = x << 4;
|
||||
int chunkZ = z << 4;
|
||||
int chunkXmax = chunkX + 16;
|
||||
int chunkZmax = chunkZ + 16;
|
||||
// 3D biomes didn't exist until 1.15
|
||||
if (use3dBiomes) {
|
||||
for (int localX = chunkX; localX < chunkXmax; localX += 4) {
|
||||
for (int localY = 0; localY < 255; localY += + 4) {
|
||||
for (int localZ = chunkZ; localZ < chunkZmax; localZ += 4) {
|
||||
// Index is based on wiki.vg's index requirements
|
||||
final int i = ((localY >> 2) & 63) << 4 | ((localZ >> 2) & 3) << 2 | ((localX >> 2) & 3);
|
||||
biomeData[i] = biomeToIdMap.getOrDefault(world.getBiome(localX, localY, localZ).ordinal(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Looks like the same code, but we're not checking the Y coordinate here
|
||||
for (int localX = chunkX; localX < chunkXmax; localX += 4) {
|
||||
for (int localY = 0; localY < 255; localY += + 4) {
|
||||
for (int localZ = chunkZ; localZ < chunkZmax; localZ += 4) {
|
||||
// Index is based on wiki.vg's index requirements
|
||||
final int i = ((localY >> 2) & 63) << 4 | ((localZ >> 2) & 3) << 2 | ((localX >> 2) & 3);
|
||||
biomeData[i] = biomeToIdMap.getOrDefault(world.getBiome(localX, localZ).ordinal(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return biomeData;
|
||||
}
|
||||
|
||||
public Boolean getGameRuleBool(GeyserSession session, GameRule gameRule) {
|
||||
return Boolean.parseBoolean(Bukkit.getPlayer(session.getPlayerEntity().getUsername()).getWorld().getGameRuleValue(gameRule.getJavaID()));
|
||||
}
|
||||
|
|
155
bootstrap/spigot/src/main/resources/biomes.json
Normal file
155
bootstrap/spigot/src/main/resources/biomes.json
Normal file
|
@ -0,0 +1,155 @@
|
|||
{
|
||||
"MUTATED_ICE_FLATS" : 140,
|
||||
"MUTATED_TAIGA" : 133,
|
||||
"SAVANNA_PLATEAU_MOUNTAINS" : 164,
|
||||
"DEEP_WARM_OCEAN" : 47,
|
||||
"REDWOOD_TAIGA_HILLS" : 33,
|
||||
"THE_VOID" : 127,
|
||||
"COLD_TAIGA_MOUNTAINS" : 158,
|
||||
"BAMBOO_JUNGLE_HILLS" : 169,
|
||||
"MOUNTAINS" : 3,
|
||||
"MESA_PLATEAU" : 39,
|
||||
"SNOWY_TAIGA_HILLS" : 31,
|
||||
"DEEP_FROZEN_OCEAN" : 50,
|
||||
"EXTREME_HILLS" : 3,
|
||||
"BIRCH_FOREST_MOUNTAINS" : 155,
|
||||
"FOREST" : 4,
|
||||
"BIRCH_FOREST" : 27,
|
||||
"SNOWY_TUNDRA" : 12,
|
||||
"ICE_SPIKES" : 140,
|
||||
"FROZEN_OCEAN" : 10,
|
||||
"WARPED_FOREST" : 172,
|
||||
"WOODED_BADLANDS_PLATEAU" : 38,
|
||||
"BADLANDS_PLATEAU" : 39,
|
||||
"ICE_PLAINS_SPIKES" : 140,
|
||||
"MEGA_TAIGA" : 32,
|
||||
"MUTATED_SAVANNA_ROCK" : 164,
|
||||
"SAVANNA_PLATEAU" : 36,
|
||||
"DARK_FOREST_HILLS" : 157,
|
||||
"END_MIDLANDS" : 41,
|
||||
"SHATTERED_SAVANNA_PLATEAU" : 164,
|
||||
"SAVANNA" : 35,
|
||||
"MUSHROOM_ISLAND_SHORE" : 15,
|
||||
"SWAMP" : 6,
|
||||
"ICE_MOUNTAINS" : 13,
|
||||
"BEACH" : 16,
|
||||
"MUTATED_MESA_CLEAR_ROCK" : 167,
|
||||
"END_HIGHLANDS" : 42,
|
||||
"COLD_BEACH" : 26,
|
||||
"JUNGLE" : 21,
|
||||
"MUTATED_TAIGA_COLD" : 158,
|
||||
"TALL_BIRCH_HILLS" : 156,
|
||||
"DARK_FOREST" : 29,
|
||||
"WOODED_HILLS" : 18,
|
||||
"HELL" : 8,
|
||||
"MUTATED_REDWOOD_TAIGA" : 160,
|
||||
"MESA_PLATEAU_FOREST" : 38,
|
||||
"MUSHROOM_ISLAND" : 14,
|
||||
"BADLANDS" : 37,
|
||||
"END_BARRENS" : 43,
|
||||
"MUTATED_EXTREME_HILLS_WITH_TREES" : 162,
|
||||
"MUTATED_JUNGLE_EDGE" : 151,
|
||||
"MODIFIED_BADLANDS_PLATEAU" : 167,
|
||||
"ROOFED_FOREST_MOUNTAINS" : 157,
|
||||
"SOUL_SAND_VALLEY" : 170,
|
||||
"DESERT" : 2,
|
||||
"MUTATED_PLAINS" : 129,
|
||||
"MUTATED_BIRCH_FOREST" : 155,
|
||||
"WOODED_MOUNTAINS" : 34,
|
||||
"TAIGA_HILLS" : 19,
|
||||
"BAMBOO_JUNGLE" : 168,
|
||||
"SWAMPLAND_MOUNTAINS" : 134,
|
||||
"DESERT_MOUNTAINS" : 130,
|
||||
"REDWOOD_TAIGA" : 32,
|
||||
"MUSHROOM_FIELDS" : 14,
|
||||
"GIANT_TREE_TAIGA_HILLS" : 33,
|
||||
"PLAINS" : 1,
|
||||
"JUNGLE_EDGE" : 23,
|
||||
"SAVANNA_MOUNTAINS" : 163,
|
||||
"DEEP_COLD_OCEAN" : 49,
|
||||
"DESERT_LAKES" : 130,
|
||||
"MOUNTAIN_EDGE" : 20,
|
||||
"SNOWY_MOUNTAINS" : 13,
|
||||
"MESA_PLATEAU_MOUNTAINS" : 167,
|
||||
"JUNGLE_MOUNTAINS" : 149,
|
||||
"SMALLER_EXTREME_HILLS" : 20,
|
||||
"MESA_PLATEAU_FOREST_MOUNTAINS" : 166,
|
||||
"NETHER_WASTES" : 8,
|
||||
"BIRCH_FOREST_HILLS_MOUNTAINS" : 156,
|
||||
"MUTATED_JUNGLE" : 149,
|
||||
"WARM_OCEAN" : 44,
|
||||
"DEEP_OCEAN" : 24,
|
||||
"STONE_BEACH" : 25,
|
||||
"MODIFIED_JUNGLE" : 149,
|
||||
"MUTATED_SAVANNA" : 163,
|
||||
"TAIGA_COLD_HILLS" : 31,
|
||||
"OCEAN" : 0,
|
||||
"SMALL_END_ISLANDS" : 40,
|
||||
"MUSHROOM_FIELD_SHORE" : 15,
|
||||
"GRAVELLY_MOUNTAINS" : 131,
|
||||
"FROZEN_RIVER" : 11,
|
||||
"TAIGA_COLD" : 30,
|
||||
"BASALT_DELTAS" : 173,
|
||||
"EXTREME_HILLS_WITH_TREES" : 34,
|
||||
"MEGA_TAIGA_HILLS" : 33,
|
||||
"MUTATED_FOREST" : 132,
|
||||
"MUTATED_BIRCH_FOREST_HILLS" : 156,
|
||||
"SKY" : 9,
|
||||
"LUKEWARM_OCEAN" : 45,
|
||||
"EXTREME_HILLS_MOUNTAINS" : 131,
|
||||
"COLD_TAIGA_HILLS" : 31,
|
||||
"THE_END" : 9,
|
||||
"SUNFLOWER_PLAINS" : 129,
|
||||
"SAVANNA_ROCK" : 36,
|
||||
"ERODED_BADLANDS" : 165,
|
||||
"STONE_SHORE" : 25,
|
||||
"EXTREME_HILLS_PLUS_MOUNTAINS" : 162,
|
||||
"CRIMSON_FOREST" : 171,
|
||||
"VOID" : 127,
|
||||
"SNOWY_TAIGA" : 30,
|
||||
"SNOWY_TAIGA_MOUNTAINS" : 158,
|
||||
"FLOWER_FOREST" : 132,
|
||||
"COLD_OCEAN" : 46,
|
||||
"BEACHES" : 16,
|
||||
"MESA" : 37,
|
||||
"MUSHROOM_SHORE" : 15,
|
||||
"MESA_CLEAR_ROCK" : 39,
|
||||
"NETHER" : 8,
|
||||
"ICE_PLAINS" : 12,
|
||||
"SHATTERED_SAVANNA" : 163,
|
||||
"ROOFED_FOREST" : 29,
|
||||
"GIANT_SPRUCE_TAIGA_HILLS" : 161,
|
||||
"SNOWY_BEACH" : 26,
|
||||
"MESA_BRYCE" : 165,
|
||||
"JUNGLE_EDGE_MOUNTAINS" : 151,
|
||||
"MUTATED_DESERT" : 130,
|
||||
"MODIFIED_GRAVELLY_MOUNTAINS" : 158,
|
||||
"MEGA_SPRUCE_TAIGA" : 160,
|
||||
"TAIGA_MOUNTAINS" : 133,
|
||||
"SMALL_MOUNTAINS" : 20,
|
||||
"EXTREME_HILLS_PLUS" : 34,
|
||||
"GIANT_SPRUCE_TAIGA" : 160,
|
||||
"FOREST_HILLS" : 18,
|
||||
"DESERT_HILLS" : 17,
|
||||
"MUTATED_REDWOOD_TAIGA_HILLS" : 161,
|
||||
"MEGA_SPRUCE_TAIGA_HILLS" : 161,
|
||||
"RIVER" : 7,
|
||||
"GIANT_TREE_TAIGA" : 32,
|
||||
"SWAMPLAND" : 6,
|
||||
"JUNGLE_HILLS" : 22,
|
||||
"TALL_BIRCH_FOREST" : 155,
|
||||
"DEEP_LUKEWARM_OCEAN" : 48,
|
||||
"MESA_ROCK" : 38,
|
||||
"SWAMP_HILLS" : 134,
|
||||
"MODIFIED_WOODED_BADLANDS_PLATEAU" : 166,
|
||||
"MODIFIED_JUNGLE_EDGE" : 151,
|
||||
"BIRCH_FOREST_HILLS" : 28,
|
||||
"COLD_TAIGA" : 30,
|
||||
"TAIGA" : 5,
|
||||
"MUTATED_MESA_ROCK" : 166,
|
||||
"MUTATED_SWAMPLAND" : 134,
|
||||
"ICE_FLATS" : 12,
|
||||
"MUTATED_ROOFED_FOREST" : 157,
|
||||
"MUTATED_MESA" : 165,
|
||||
"MUTATED_EXTREME_HILLS" : 131
|
||||
}
|
|
@ -70,9 +70,25 @@
|
|||
<shadedPattern>org.geysermc.platform.sponge.shaded.fastutil</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.reflections.reflections</pattern>
|
||||
<pattern>org.reflections</pattern>
|
||||
<shadedPattern>org.geysermc.platform.sponge.shaded.reflections</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.google.common</pattern>
|
||||
<shadedPattern>org.geysermc.platform.sponge.shaded.google.common</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.google.guava</pattern>
|
||||
<shadedPattern>org.geysermc.platform.sponge.shaded.google.guava</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.dom4j</pattern>
|
||||
<shadedPattern>org.geysermc.platform.sponge.shaded.dom4j</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>net.kyori.adventure</pattern>
|
||||
<shadedPattern>org.geysermc.platform.sponge.shaded.adventure</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
|
|
@ -25,256 +25,13 @@
|
|||
|
||||
package org.geysermc.platform.sponge;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.geysermc.connector.configuration.GeyserJacksonConfiguration;
|
||||
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
|
||||
import org.geysermc.connector.configuration.GeyserConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.*;
|
||||
|
||||
public class GeyserSpongeConfiguration implements GeyserConfiguration {
|
||||
|
||||
private File dataFolder;
|
||||
private ConfigurationNode node;
|
||||
|
||||
private SpongeBedrockConfiguration bedrockConfig;
|
||||
private SpongeRemoteConfiguration remoteConfig;
|
||||
private SpongeMetricsInfo metricsInfo;
|
||||
|
||||
private Map<String, SpongeUserAuthenticationInfo> userAuthInfo = new HashMap<>();
|
||||
|
||||
public GeyserSpongeConfiguration(File dataFolder, ConfigurationNode node) {
|
||||
this.dataFolder = dataFolder;
|
||||
this.node = node;
|
||||
|
||||
this.bedrockConfig = new SpongeBedrockConfiguration(node.getNode("bedrock"));
|
||||
this.remoteConfig = new SpongeRemoteConfiguration(node.getNode("remote"));
|
||||
this.metricsInfo = new SpongeMetricsInfo();
|
||||
|
||||
if (node.getNode("userAuths").getValue() == null)
|
||||
return;
|
||||
|
||||
List<String> userAuths = new ArrayList<String>(((LinkedHashMap)node.getNode("userAuths").getValue()).keySet());
|
||||
for (String key : userAuths) {
|
||||
userAuthInfo.put(key, new SpongeUserAuthenticationInfo(key));
|
||||
}
|
||||
}
|
||||
|
||||
public final class GeyserSpongeConfiguration extends GeyserJacksonConfiguration {
|
||||
@Override
|
||||
public SpongeBedrockConfiguration getBedrock() {
|
||||
return bedrockConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpongeRemoteConfiguration getRemote() {
|
||||
return remoteConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, SpongeUserAuthenticationInfo> getUserAuths() {
|
||||
return userAuthInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommandSuggestions() {
|
||||
return node.getNode("command-suggestions").getBoolean(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPassthroughMotd() {
|
||||
return node.getNode("passthrough-motd").getBoolean(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPassthroughProtocolName() {
|
||||
return node.getNode("passthrough-protocol-name").getBoolean(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPassthroughPlayerCounts() {
|
||||
return node.getNode("passthrough-player-counts").getBoolean(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLegacyPingPassthrough() {
|
||||
return node.getNode("legacy-ping-passthrough").getBoolean(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPingPassthroughInterval() {
|
||||
return node.getNode("ping-passthrough-interval").getInt(3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxPlayers() {
|
||||
return node.getNode("max-players").getInt(100);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDebugMode() {
|
||||
return node.getNode("debug-mode").getBoolean(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGeneralThreadPool() {
|
||||
return node.getNode("genereal-thread-pool").getInt(32);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAllowThirdPartyCapes() {
|
||||
return node.getNode("allow-third-party-capes").getBoolean(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAllowThirdPartyEars() {
|
||||
return node.getNode("allow-third-party-ears").getBoolean(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShowCooldown() {
|
||||
return node.getNode("show-cooldown").getBoolean(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultLocale() {
|
||||
return node.getNode("default-locale").getString("en_us");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getFloodgateKeyFile() {
|
||||
return Paths.get(dataFolder.toString(), node.getNode("floodgate-key-file").getString("public-key.pem"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCacheChunks() {
|
||||
return node.getNode("cache-chunks").getBoolean(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCacheImages() {
|
||||
return node.getNode("cache-skins").getInt(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAboveBedrockNetherBuilding() {
|
||||
return node.getNode("above-bedrock-nether-building").getBoolean(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpongeMetricsInfo getMetrics() {
|
||||
return metricsInfo;
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
public class SpongeBedrockConfiguration implements IBedrockConfiguration {
|
||||
|
||||
private ConfigurationNode node;
|
||||
|
||||
@Override
|
||||
public String getAddress() {
|
||||
return node.getNode("address").getString("0.0.0.0");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPort() {
|
||||
return node.getNode("port").getInt(19132);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCloneRemotePort() {
|
||||
return node.getNode("clone-remote-port").getBoolean(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMotd1() {
|
||||
return node.getNode("motd1").getString("GeyserMC");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMotd2() {
|
||||
return node.getNode("motd2").getString("GeyserMC");
|
||||
}
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
public class SpongeRemoteConfiguration implements IRemoteConfiguration {
|
||||
|
||||
private ConfigurationNode node;
|
||||
|
||||
@Override
|
||||
public String getAddress() {
|
||||
return node.getNode("address").getString("127.0.0.1");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAddress(String address) {
|
||||
node.getNode("address").setValue(address);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPort() {
|
||||
return node.getNode("port").getInt(25565);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPort(int port) {
|
||||
node.getNode("port").setValue(port);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthType() {
|
||||
return node.getNode("auth-type").getString("online");
|
||||
}
|
||||
}
|
||||
|
||||
public class SpongeUserAuthenticationInfo implements IUserAuthenticationInfo {
|
||||
|
||||
private String key;
|
||||
|
||||
public SpongeUserAuthenticationInfo(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEmail() {
|
||||
return node.getNode("userAuths").getNode(key).getNode("email").getString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPassword() {
|
||||
return node.getNode("userAuths").getNode(key).getNode("password").getString();
|
||||
}
|
||||
}
|
||||
|
||||
public class SpongeMetricsInfo implements IMetricsInfo {
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return node.getNode("metrics").getNode("enabled").getBoolean(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUniqueId() {
|
||||
return node.getNode("metrics").getNode("uuid").getString("generateduuid");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnableProxyConnections() {
|
||||
return node.getNode("enable-proxy-connections").getBoolean(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMtu() {
|
||||
return node.getNode("mtu").getInt(1400);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getConfigVersion() {
|
||||
return node.getNode("config-version").getInt(0);
|
||||
public Path getFloodgateKeyPath() {
|
||||
return null; //floodgate isn't available for Sponge
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,15 +26,16 @@
|
|||
package org.geysermc.platform.sponge;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.geysermc.connector.GeyserLogger;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class GeyserSpongeLogger implements GeyserLogger {
|
||||
|
||||
private Logger logger;
|
||||
private boolean debugMode;
|
||||
private final Logger logger;
|
||||
@Getter @Setter
|
||||
private boolean debug;
|
||||
|
||||
@Override
|
||||
public void severe(String message) {
|
||||
|
@ -68,12 +69,8 @@ public class GeyserSpongeLogger implements GeyserLogger {
|
|||
|
||||
@Override
|
||||
public void debug(String message) {
|
||||
if (debugMode)
|
||||
if (debug) {
|
||||
info(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDebug(boolean debugMode) {
|
||||
this.debugMode = debugMode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,14 +26,11 @@
|
|||
package org.geysermc.platform.sponge;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
import ninja.leaping.configurate.loader.ConfigurationLoader;
|
||||
import ninja.leaping.configurate.yaml.YAMLConfigurationLoader;
|
||||
import org.geysermc.connector.common.PlatformType;
|
||||
import org.geysermc.connector.configuration.GeyserConfiguration;
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
import org.geysermc.connector.bootstrap.GeyserBootstrap;
|
||||
import org.geysermc.connector.command.CommandManager;
|
||||
import org.geysermc.connector.common.PlatformType;
|
||||
import org.geysermc.connector.configuration.GeyserConfiguration;
|
||||
import org.geysermc.connector.dump.BootstrapDumpInfo;
|
||||
import org.geysermc.connector.ping.GeyserLegacyPingPassthrough;
|
||||
import org.geysermc.connector.ping.IGeyserPingPassthrough;
|
||||
|
@ -85,33 +82,27 @@ public class GeyserSpongePlugin implements GeyserBootstrap {
|
|||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
ConfigurationLoader loader = YAMLConfigurationLoader.builder().setPath(configFile.toPath()).build();
|
||||
ConfigurationNode config;
|
||||
try {
|
||||
config = loader.load();
|
||||
this.geyserConfig = new GeyserSpongeConfiguration(configDir, config);
|
||||
this.geyserConfig = FileUtils.loadConfig(configFile, GeyserSpongeConfiguration.class);
|
||||
} catch (IOException ex) {
|
||||
logger.warn(LanguageUtils.getLocaleStringLog("geyser.config.failed"));
|
||||
ex.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
ConfigurationNode serverIP = config.getNode("remote").getNode("address");
|
||||
ConfigurationNode serverPort = config.getNode("remote").getNode("port");
|
||||
|
||||
if (Sponge.getServer().getBoundAddress().isPresent()) {
|
||||
InetSocketAddress javaAddr = Sponge.getServer().getBoundAddress().get();
|
||||
|
||||
// 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
|
||||
if (this.geyserConfig.getRemote().getAddress().equalsIgnoreCase("auto")) {
|
||||
serverPort.setValue(javaAddr.getPort());
|
||||
this.geyserConfig.setAutoconfiguredRemote(true);
|
||||
geyserConfig.getRemote().setPort(javaAddr.getPort());
|
||||
}
|
||||
}
|
||||
|
||||
ConfigurationNode bedrockPort = config.getNode("bedrock").getNode("port");
|
||||
if (geyserConfig.getBedrock().isCloneRemotePort()){
|
||||
bedrockPort.setValue(serverPort.getValue());
|
||||
geyserConfig.getBedrock().setPort(geyserConfig.getRemote().getPort());
|
||||
}
|
||||
|
||||
this.geyserLogger = new GeyserSpongeLogger(logger, geyserConfig.isDebugMode());
|
||||
|
|
|
@ -33,8 +33,8 @@ import org.apache.logging.log4j.core.Logger;
|
|||
import org.apache.logging.log4j.core.appender.ConsoleAppender;
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
import org.geysermc.connector.bootstrap.GeyserBootstrap;
|
||||
import org.geysermc.connector.common.PlatformType;
|
||||
import org.geysermc.connector.command.CommandManager;
|
||||
import org.geysermc.connector.common.PlatformType;
|
||||
import org.geysermc.connector.configuration.GeyserConfiguration;
|
||||
import org.geysermc.connector.dump.BootstrapDumpInfo;
|
||||
import org.geysermc.connector.ping.GeyserLegacyPingPassthrough;
|
||||
|
@ -49,6 +49,7 @@ import java.io.IOException;
|
|||
import java.lang.reflect.Method;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.UUID;
|
||||
|
||||
public class GeyserStandaloneBootstrap implements GeyserBootstrap {
|
||||
|
@ -62,22 +63,61 @@ public class GeyserStandaloneBootstrap implements GeyserBootstrap {
|
|||
|
||||
@Getter
|
||||
private boolean useGui = System.console() == null && !isHeadless();
|
||||
private String configFilename = "config.yml";
|
||||
|
||||
private GeyserConnector connector;
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
for (String arg : args) {
|
||||
GeyserStandaloneBootstrap bootstrap = new GeyserStandaloneBootstrap();
|
||||
// Set defaults
|
||||
boolean useGuiOpts = bootstrap.useGui;
|
||||
String configFilenameOpt = bootstrap.configFilename;
|
||||
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
// By default, standalone Geyser will check if it should open the GUI based on if the GUI is null
|
||||
// Optionally, you can force the use of a GUI or no GUI by specifying args
|
||||
if (arg.equals("gui")) {
|
||||
new GeyserStandaloneBootstrap().onEnable(true);
|
||||
return;
|
||||
} else if (arg.equals("nogui")) {
|
||||
new GeyserStandaloneBootstrap().onEnable(false);
|
||||
return;
|
||||
// Allows gui and nogui without options, for backwards compatibility
|
||||
String arg = args[i];
|
||||
switch (arg) {
|
||||
case "--gui":
|
||||
case "gui":
|
||||
useGuiOpts = true;
|
||||
break;
|
||||
case "--nogui":
|
||||
case "nogui":
|
||||
useGuiOpts = false;
|
||||
break;
|
||||
case "--config":
|
||||
case "-c":
|
||||
if (i >= args.length - 1) {
|
||||
System.err.println(MessageFormat.format(LanguageUtils.getLocaleStringLog("geyser.bootstrap.args.confignotspecified"), "-c"));
|
||||
return;
|
||||
}
|
||||
configFilenameOpt = args[i+1]; i++;
|
||||
System.out.println(MessageFormat.format(LanguageUtils.getLocaleStringLog("geyser.bootstrap.args.configspecified"), configFilenameOpt));
|
||||
break;
|
||||
case "--help":
|
||||
case "-h":
|
||||
System.out.println(MessageFormat.format(LanguageUtils.getLocaleStringLog("geyser.bootstrap.args.usage"), "[java -jar] Geyser.jar [opts]"));
|
||||
System.out.println(" " + LanguageUtils.getLocaleStringLog("geyser.bootstrap.args.options"));
|
||||
System.out.println(" -c, --config [file] " + LanguageUtils.getLocaleStringLog("geyser.bootstrap.args.config"));
|
||||
System.out.println(" -h, --help " + LanguageUtils.getLocaleStringLog("geyser.bootstrap.args.help"));
|
||||
System.out.println(" --gui, --nogui " + LanguageUtils.getLocaleStringLog("geyser.bootstrap.args.gui"));
|
||||
return;
|
||||
default:
|
||||
String badArgMsg = LanguageUtils.getLocaleStringLog("geyser.bootstrap.args.unrecognised");
|
||||
System.err.println(MessageFormat.format(badArgMsg, arg));
|
||||
return;
|
||||
}
|
||||
}
|
||||
new GeyserStandaloneBootstrap().onEnable();
|
||||
bootstrap.onEnable(useGuiOpts, configFilenameOpt);
|
||||
}
|
||||
|
||||
public void onEnable(boolean useGui, String configFilename) {
|
||||
this.configFilename = configFilename;
|
||||
this.useGui = useGui;
|
||||
this.onEnable();
|
||||
}
|
||||
|
||||
public void onEnable(boolean useGui) {
|
||||
|
@ -106,9 +146,10 @@ public class GeyserStandaloneBootstrap implements GeyserBootstrap {
|
|||
LoopbackUtil.checkLoopback(geyserLogger);
|
||||
|
||||
try {
|
||||
File configFile = FileUtils.fileOrCopiedFromResource("config.yml", (x) -> x.replaceAll("generateduuid", UUID.randomUUID().toString()));
|
||||
File configFile = FileUtils.fileOrCopiedFromResource(new File(configFilename), "config.yml", (x) -> x.replaceAll("generateduuid", UUID.randomUUID().toString()));
|
||||
geyserConfig = FileUtils.loadConfig(configFile, GeyserStandaloneConfiguration.class);
|
||||
if (this.geyserConfig.getRemote().getAddress().equalsIgnoreCase("auto")) {
|
||||
geyserConfig.setAutoconfiguredRemote(true); // Doesn't really need to be set but /shrug
|
||||
geyserConfig.getRemote().setAddress("127.0.0.1");
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
package org.geysermc.platform.standalone;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Getter;
|
||||
import org.geysermc.connector.configuration.GeyserJacksonConfiguration;
|
||||
|
||||
|
@ -35,13 +34,9 @@ import java.nio.file.Paths;
|
|||
|
||||
@Getter
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class GeyserStandaloneConfiguration extends GeyserJacksonConfiguration {
|
||||
|
||||
@JsonProperty("floodgate-key-file")
|
||||
private String floodgateKeyFile;
|
||||
|
||||
public final class GeyserStandaloneConfiguration extends GeyserJacksonConfiguration {
|
||||
@Override
|
||||
public Path getFloodgateKeyFile() {
|
||||
return Paths.get(floodgateKeyFile);
|
||||
public Path getFloodgateKeyPath() {
|
||||
return Paths.get(getFloodgateKeyFile());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,18 +26,16 @@
|
|||
package org.geysermc.platform.standalone;
|
||||
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
|
||||
import net.minecrell.terminalconsole.SimpleTerminalConsole;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.core.config.Configurator;
|
||||
import org.geysermc.connector.common.ChatColor;
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
import org.geysermc.connector.GeyserLogger;
|
||||
import org.geysermc.connector.command.CommandSender;
|
||||
import org.geysermc.connector.common.ChatColor;
|
||||
|
||||
@Log4j2
|
||||
public class GeyserStandaloneLogger extends SimpleTerminalConsole implements org.geysermc.connector.GeyserLogger, CommandSender {
|
||||
|
||||
public class GeyserStandaloneLogger extends SimpleTerminalConsole implements GeyserLogger, CommandSender {
|
||||
private boolean colored = true;
|
||||
|
||||
@Override
|
||||
|
@ -99,10 +97,6 @@ public class GeyserStandaloneLogger extends SimpleTerminalConsole implements org
|
|||
Configurator.setLevel(log.getName(), debug ? Level.DEBUG : Level.INFO);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for setting debug mode in GUI mode
|
||||
* @return if debug is enabled
|
||||
*/
|
||||
public boolean isDebug() {
|
||||
return log.isDebugEnabled();
|
||||
}
|
||||
|
|
|
@ -57,14 +57,34 @@
|
|||
</goals>
|
||||
<configuration>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>com.fasterxml.jackson</pattern>
|
||||
<shadedPattern>org.geysermc.platform.velocity.shaded.jackson</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>it.unimi.dsi.fastutil</pattern>
|
||||
<shadedPattern>org.geysermc.platform.velocity.shaded.fastutil</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.reflections.reflections</pattern>
|
||||
<pattern>org.reflections</pattern>
|
||||
<shadedPattern>org.geysermc.platform.velocity.shaded.reflections</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.google.common</pattern>
|
||||
<shadedPattern>org.geysermc.platform.velocity.shaded.google.common</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.google.guava</pattern>
|
||||
<shadedPattern>org.geysermc.platform.velocity.shaded.google.guava</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.dom4j</pattern>
|
||||
<shadedPattern>org.geysermc.platform.velocity.shaded.dom4j</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>net.kyori.adventure</pattern>
|
||||
<shadedPattern>org.geysermc.platform.velocity.shaded.adventure</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
|
|
@ -27,7 +27,6 @@ package org.geysermc.platform.velocity;
|
|||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.velocitypowered.api.plugin.PluginContainer;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import lombok.Getter;
|
||||
|
@ -37,25 +36,15 @@ import org.geysermc.connector.configuration.GeyserJacksonConfiguration;
|
|||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Optional;
|
||||
|
||||
@Getter
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class GeyserVelocityConfiguration extends GeyserJacksonConfiguration {
|
||||
|
||||
@JsonProperty("floodgate-key-file")
|
||||
private String floodgateKeyFile;
|
||||
|
||||
public final class GeyserVelocityConfiguration extends GeyserJacksonConfiguration {
|
||||
@JsonIgnore
|
||||
private Path floodgateKey;
|
||||
|
||||
@Override
|
||||
public Path getFloodgateKeyFile() {
|
||||
return floodgateKey;
|
||||
}
|
||||
private Path floodgateKeyPath;
|
||||
|
||||
public void loadFloodgate(GeyserVelocityPlugin plugin, ProxyServer proxyServer, File dataFolder) {
|
||||
Optional<PluginContainer> floodgate = proxyServer.getPluginManager().getPlugin("floodgate");
|
||||
floodgate.ifPresent(it -> floodgateKey = FloodgateKeyLoader.getKey(plugin.getGeyserLogger(), this, Paths.get(dataFolder.toString(), floodgateKeyFile.isEmpty() ? floodgateKeyFile : "public-key.pem"), it, Paths.get("plugins/floodgate/")));
|
||||
PluginContainer floodgate = proxyServer.getPluginManager().getPlugin("floodgate").orElse(null);
|
||||
floodgateKeyPath = FloodgateKeyLoader.getKeyPath(this, floodgate, Paths.get("plugins/floodgate/"), dataFolder.toPath(), plugin.getGeyserLogger());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,15 +26,16 @@
|
|||
package org.geysermc.platform.velocity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.geysermc.connector.GeyserLogger;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class GeyserVelocityLogger implements GeyserLogger {
|
||||
|
||||
private Logger logger;
|
||||
private boolean debugMode;
|
||||
private final Logger logger;
|
||||
@Getter @Setter
|
||||
private boolean debug;
|
||||
|
||||
@Override
|
||||
public void severe(String message) {
|
||||
|
@ -68,12 +69,8 @@ public class GeyserVelocityLogger implements GeyserLogger {
|
|||
|
||||
@Override
|
||||
public void debug(String message) {
|
||||
if (debugMode)
|
||||
if (debug) {
|
||||
info(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDebug(boolean debugMode) {
|
||||
this.debugMode = debugMode;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -26,19 +26,17 @@
|
|||
package org.geysermc.platform.velocity;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import com.velocitypowered.api.command.CommandManager;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||
import com.velocitypowered.api.event.proxy.ProxyShutdownEvent;
|
||||
import com.velocitypowered.api.plugin.Plugin;
|
||||
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import lombok.Getter;
|
||||
import org.geysermc.connector.common.PlatformType;
|
||||
import org.geysermc.connector.configuration.GeyserConfiguration;
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
import org.geysermc.connector.bootstrap.GeyserBootstrap;
|
||||
import org.geysermc.connector.common.PlatformType;
|
||||
import org.geysermc.connector.configuration.GeyserConfiguration;
|
||||
import org.geysermc.connector.dump.BootstrapDumpInfo;
|
||||
import org.geysermc.connector.ping.GeyserLegacyPingPassthrough;
|
||||
import org.geysermc.connector.ping.IGeyserPingPassthrough;
|
||||
|
@ -94,6 +92,11 @@ public class GeyserVelocityPlugin implements GeyserBootstrap {
|
|||
|
||||
// By default this should be localhost but may need to be changed in some circumstances
|
||||
if (this.geyserConfig.getRemote().getAddress().equalsIgnoreCase("auto")) {
|
||||
this.geyserConfig.setAutoconfiguredRemote(true);
|
||||
// Don't use localhost if not listening on all interfaces
|
||||
if (!javaAddr.getHostString().equals("0.0.0.0") && !javaAddr.getHostString().equals("")) {
|
||||
this.geyserConfig.getRemote().setAddress(javaAddr.getHostString());
|
||||
}
|
||||
geyserConfig.getRemote().setPort(javaAddr.getPort());
|
||||
}
|
||||
|
||||
|
@ -107,6 +110,10 @@ public class GeyserVelocityPlugin implements GeyserBootstrap {
|
|||
if (geyserConfig.getRemote().getAuthType().equals("floodgate") && !proxyServer.getPluginManager().getPlugin("floodgate").isPresent()) {
|
||||
geyserLogger.severe(LanguageUtils.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed") + " " + LanguageUtils.getLocaleStringLog("geyser.bootstrap.floodgate.disabling"));
|
||||
return;
|
||||
} else if (geyserConfig.isAutoconfiguredRemote() && proxyServer.getPluginManager().getPlugin("floodgate").isPresent()) {
|
||||
// Floodgate installed means that the user wants Floodgate authentication
|
||||
geyserLogger.debug("Auto-setting to Floodgate authentication.");
|
||||
geyserConfig.getRemote().setAuthType("floodgate");
|
||||
}
|
||||
|
||||
geyserConfig.loadFloodgate(this, proxyServer, configFolder.toFile());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue