From a0db56ba8727ad58e2fb94dc3f1f445b5f69badf Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Sun, 31 Jan 2021 14:22:26 -0500 Subject: [PATCH 1/5] Fix lightning bolt sound (#1889) --- connector/src/main/resources/mappings | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connector/src/main/resources/mappings b/connector/src/main/resources/mappings index c4f07d67244..2e52b01cc54 160000 --- a/connector/src/main/resources/mappings +++ b/connector/src/main/resources/mappings @@ -1 +1 @@ -Subproject commit c4f07d67244b2746d0a8b2d94cd10cb2833d4018 +Subproject commit 2e52b01cc541c8925346f93be8940087d9af1661 From db38b0d45dcda0e44c4c1322cbd7db7a00b161cd Mon Sep 17 00:00:00 2001 From: Brave Chicken <46161394+BraveChicken1@users.noreply.github.com> Date: Tue, 2 Feb 2021 17:40:28 +0100 Subject: [PATCH 2/5] Fix EndGateway translation issue (#1892) * Fix EndGateway translation issue. * Change contains check to instanceof LongTag as requested. * Add space after if as requested. Co-authored-by: Brave_Chicken --- .../block/entity/EndGatewayBlockEntityTranslator.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/EndGatewayBlockEntityTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/EndGatewayBlockEntityTranslator.java index 2dbd7585215..761d1c3ab2b 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/EndGatewayBlockEntityTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/EndGatewayBlockEntityTranslator.java @@ -27,6 +27,8 @@ import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.IntTag; +import com.github.steveice10.opennbt.tag.builtin.LongTag; +import com.github.steveice10.opennbt.tag.builtin.Tag; import com.nukkitx.nbt.NbtList; import com.nukkitx.nbt.NbtMapBuilder; import com.nukkitx.nbt.NbtType; @@ -39,7 +41,10 @@ public class EndGatewayBlockEntityTranslator extends BlockEntityTranslator { @Override public void translateTag(NbtMapBuilder builder, CompoundTag tag, int blockState) { - builder.put("Age", (int) ((long) tag.get("Age").getValue())); + Tag ageTag = tag.get("Age"); + if (ageTag instanceof LongTag) { + builder.put("Age", (int) ((long) ageTag.getValue())); + } // Java sometimes does not provide this tag, but Bedrock crashes if it doesn't exist // Linked coordinates IntList tagsList = new IntArrayList(); From 27fecd7ff7a762396c1337222ed4c9bd51f03dfe Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Wed, 3 Feb 2021 19:51:11 -0500 Subject: [PATCH 3/5] Update Sponge repository (#1890) See https://discord.com/channels/142425412096491520/303772747907989504/805571283546144808 (Sponge Discord) --- bootstrap/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap/pom.xml b/bootstrap/pom.xml index a5ad53cb544..a6a2a86de76 100644 --- a/bootstrap/pom.xml +++ b/bootstrap/pom.xml @@ -22,7 +22,7 @@ sponge-repo - https://repo.spongepowered.org/maven + https://repo.spongepowered.org/repository/maven-public/ bungeecord-repo From 254990148c42919062a2ecac0edf1d7bd06faa6f Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Wed, 3 Feb 2021 19:54:12 -0500 Subject: [PATCH 4/5] Fix several world-related errors on Spigot 1.12 (#1886) - Fix v1.12R1 not being recognized as a world adapter - Return air if a chunk is not loaded --- bootstrap/spigot/pom.xml | 4 ++-- .../java/org/geysermc/platform/spigot/GeyserSpigotPlugin.java | 2 +- .../world/manager/GeyserSpigot1_12NativeWorldManager.java | 4 ++-- .../spigot/world/manager/GeyserSpigot1_12WorldManager.java | 4 ++++ .../spigot/world/manager/GeyserSpigotNativeWorldManager.java | 4 ++-- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/bootstrap/spigot/pom.xml b/bootstrap/spigot/pom.xml index 93eebc3d2c4..d1cba8aea0c 100644 --- a/bootstrap/spigot/pom.xml +++ b/bootstrap/spigot/pom.xml @@ -30,9 +30,9 @@ provided - org.geysermc.adapters + org.geysermc.geyser.adapters spigot-all - 1.0-SNAPSHOT + 1.1-SNAPSHOT diff --git a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/GeyserSpigotPlugin.java b/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/GeyserSpigotPlugin.java index b85aa313337..2f8e0db24a6 100644 --- a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/GeyserSpigotPlugin.java +++ b/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/GeyserSpigotPlugin.java @@ -28,7 +28,6 @@ import com.github.steveice10.mc.protocol.MinecraftConstants; import org.bukkit.Bukkit; import org.bukkit.plugin.java.JavaPlugin; -import org.geysermc.adapters.spigot.SpigotAdapters; import org.geysermc.common.PlatformType; import org.geysermc.connector.GeyserConnector; import org.geysermc.connector.bootstrap.GeyserBootstrap; @@ -40,6 +39,7 @@ import org.geysermc.connector.ping.IGeyserPingPassthrough; import org.geysermc.connector.utils.FileUtils; import org.geysermc.connector.utils.LanguageUtils; +import org.geysermc.geyser.adapters.spigot.SpigotAdapters; import org.geysermc.platform.spigot.command.GeyserSpigotCommandExecutor; import org.geysermc.platform.spigot.command.GeyserSpigotCommandManager; import org.geysermc.platform.spigot.command.SpigotCommandSender; diff --git a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/manager/GeyserSpigot1_12NativeWorldManager.java b/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/manager/GeyserSpigot1_12NativeWorldManager.java index ae199272716..2cbec3273cd 100644 --- a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/manager/GeyserSpigot1_12NativeWorldManager.java +++ b/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/manager/GeyserSpigot1_12NativeWorldManager.java @@ -27,10 +27,10 @@ import org.bukkit.Bukkit; import org.bukkit.entity.Player; -import org.geysermc.adapters.spigot.SpigotAdapters; -import org.geysermc.adapters.spigot.SpigotWorldAdapter; import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.translators.world.block.BlockTranslator; +import org.geysermc.geyser.adapters.spigot.SpigotAdapters; +import org.geysermc.geyser.adapters.spigot.SpigotWorldAdapter; import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.BlockStorage; diff --git a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/manager/GeyserSpigot1_12WorldManager.java b/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/manager/GeyserSpigot1_12WorldManager.java index cb450f7f901..423156c9738 100644 --- a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/manager/GeyserSpigot1_12WorldManager.java +++ b/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/manager/GeyserSpigot1_12WorldManager.java @@ -75,6 +75,10 @@ public int getBlockAt(GeyserSession session, int x, int y, int z) { if (player == null) { return BlockTranslator.JAVA_AIR_ID; } + if (!player.getWorld().isChunkLoaded(x >> 4, z >> 4)) { + // Prevent nasty async errors if a player is loading in + return BlockTranslator.JAVA_AIR_ID; + } // Get block entity storage BlockStorage storage = Via.getManager().getConnection(player.getUniqueId()).get(BlockStorage.class); Block block = player.getWorld().getBlockAt(x, y, z); diff --git a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/manager/GeyserSpigotNativeWorldManager.java b/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/manager/GeyserSpigotNativeWorldManager.java index c7e3a3d4fac..469a38f17f8 100644 --- a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/manager/GeyserSpigotNativeWorldManager.java +++ b/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/manager/GeyserSpigotNativeWorldManager.java @@ -27,10 +27,10 @@ import org.bukkit.Bukkit; import org.bukkit.entity.Player; -import org.geysermc.adapters.spigot.SpigotAdapters; -import org.geysermc.adapters.spigot.SpigotWorldAdapter; import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.translators.world.block.BlockTranslator; +import org.geysermc.geyser.adapters.spigot.SpigotAdapters; +import org.geysermc.geyser.adapters.spigot.SpigotWorldAdapter; public class GeyserSpigotNativeWorldManager extends GeyserSpigotWorldManager { protected final SpigotWorldAdapter adapter; From c26a2baed6e99d8bc5d27be1b21cb895b5d21ef9 Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Wed, 3 Feb 2021 19:54:35 -0500 Subject: [PATCH 5/5] Add more metrics (#1896) - Add the Java version being used - Add the Minecraft server version being used, alongside the platform type that is using that version. Not used for proxies as those have to be on latest to support the latest Minecraft version --- .../platform/spigot/GeyserSpigotPlugin.java | 18 ++++++++++++++---- .../platform/sponge/GeyserSpongePlugin.java | 5 +++++ .../geysermc/connector/GeyserConnector.java | 14 ++++++++++++++ .../connector/bootstrap/GeyserBootstrap.java | 15 +++++++++++++++ .../geysermc/connector/metrics/Metrics.java | 7 +++++-- 5 files changed, 53 insertions(+), 6 deletions(-) diff --git a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/GeyserSpigotPlugin.java b/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/GeyserSpigotPlugin.java index 2f8e0db24a6..1190057e92f 100644 --- a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/GeyserSpigotPlugin.java +++ b/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/GeyserSpigotPlugin.java @@ -69,6 +69,11 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap { private GeyserConnector connector; + /** + * The Minecraft server version, formatted as 1.#.# + */ + private String minecraftVersion; + @Override public void onEnable() { // This is manually done instead of using Bukkit methods to save the config because otherwise comments get removed @@ -118,6 +123,9 @@ public void onEnable() { geyserConfig.loadFloodgate(this); + // Turn "(MC: 1.16.4)" into 1.16.4. + this.minecraftVersion = Bukkit.getServer().getVersion().split("\\(MC: ")[1].split("\\)")[0]; + this.connector = GeyserConnector.start(PlatformType.SPIGOT, this); if (geyserConfig.isLegacyPingPassthrough()) { @@ -239,6 +247,11 @@ public BootstrapDumpInfo getDumpInfo() { return new GeyserSpigotDumpInfo(); } + @Override + public String getMinecraftServerVersion() { + return this.minecraftVersion; + } + public boolean isCompatible(String version, String whichVersion) { int[] currentVersion = parseVersion(version); int[] otherVersion = parseVersion(whichVersion); @@ -277,10 +290,7 @@ private int[] parseVersion(String versionParam) { * @return the server version before ViaVersion finishes initializing */ public ProtocolVersion getServerProtocolVersion() { - String bukkitVersion = Bukkit.getServer().getVersion(); - // Turn "(MC: 1.16.4)" into 1.16.4. - String version = bukkitVersion.split("\\(MC: ")[1].split("\\)")[0]; - return ProtocolVersion.getClosest(version); + return ProtocolVersion.getClosest(this.minecraftVersion); } /** diff --git a/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongePlugin.java b/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongePlugin.java index 5b8bf54b298..142d48d2918 100644 --- a/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongePlugin.java +++ b/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongePlugin.java @@ -163,4 +163,9 @@ public void onServerStop(GameStoppedEvent event) { public BootstrapDumpInfo getDumpInfo() { return new GeyserSpongeDumpInfo(); } + + @Override + public String getMinecraftServerVersion() { + return Sponge.getPlatform().getMinecraftVersion().getName(); + } } diff --git a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java index d1059627a8d..4ec87d7b620 100644 --- a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java +++ b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java @@ -244,6 +244,20 @@ private GeyserConnector(PlatformType platformType, GeyserBootstrap bootstrap) { } return valueMap; })); + + String minecraftVersion = bootstrap.getMinecraftServerVersion(); + if (minecraftVersion != null) { + Map> versionMap = new HashMap<>(); + Map platformMap = new HashMap<>(); + platformMap.put(platformType.getPlatformName(), 1); + versionMap.put(minecraftVersion, platformMap); + + metrics.addCustomChart(new Metrics.DrilldownPie("minecraftServerVersion", () -> { + // By the end, we should return, for example: + // 1.16.5 => (Spigot, 1) + return versionMap; + })); + } } boolean isGui = false; diff --git a/connector/src/main/java/org/geysermc/connector/bootstrap/GeyserBootstrap.java b/connector/src/main/java/org/geysermc/connector/bootstrap/GeyserBootstrap.java index 7308fb67425..59dc58c2ba3 100644 --- a/connector/src/main/java/org/geysermc/connector/bootstrap/GeyserBootstrap.java +++ b/connector/src/main/java/org/geysermc/connector/bootstrap/GeyserBootstrap.java @@ -33,6 +33,7 @@ import org.geysermc.connector.network.translators.world.GeyserWorldManager; import org.geysermc.connector.network.translators.world.WorldManager; +import javax.annotation.Nullable; import java.nio.file.Path; public interface GeyserBootstrap { @@ -99,4 +100,18 @@ default WorldManager getWorldManager() { * @return The info about the bootstrap */ BootstrapDumpInfo getDumpInfo(); + + /** + * Returns the Minecraft version currently being used on the server. This should be only be implemented on platforms + * that have direct server access - platforms such as proxies always have to be on their latest version to support + * the newest Minecraft version, but older servers can use ViaVersion to enable newer versions to join. + *
+ * If used, this should not be null before {@link org.geysermc.connector.GeyserConnector} initialization. + * + * @return the Minecraft version being used on the server, or null if not applicable + */ + @Nullable + default String getMinecraftServerVersion() { + return null; + } } diff --git a/connector/src/main/java/org/geysermc/connector/metrics/Metrics.java b/connector/src/main/java/org/geysermc/connector/metrics/Metrics.java index 25ae5a36cbe..1457780b1e6 100644 --- a/connector/src/main/java/org/geysermc/connector/metrics/Metrics.java +++ b/connector/src/main/java/org/geysermc/connector/metrics/Metrics.java @@ -36,6 +36,7 @@ import java.io.DataOutputStream; import java.io.IOException; import java.net.URL; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -75,7 +76,7 @@ public class Metrics { private final static ObjectMapper mapper = new ObjectMapper(); - private GeyserConnector connector; + private final GeyserConnector connector; /** * Class constructor. @@ -156,6 +157,7 @@ private ObjectNode getServerData() { String osName = System.getProperty("os.name"); String osArch = System.getProperty("os.arch"); String osVersion = System.getProperty("os.version"); + String javaVersion = System.getProperty("java.version"); int coreCount = Runtime.getRuntime().availableProcessors(); ObjectNode data = mapper.createObjectNode(); @@ -163,6 +165,7 @@ private ObjectNode getServerData() { data.put("serverUUID", serverUUID); data.put("playerAmount", playerAmount); + data.put("javaVersion", javaVersion); data.put("osName", osName); data.put("osArch", osArch); data.put("osVersion", osVersion); @@ -241,7 +244,7 @@ private static byte[] compress(final String str) throws IOException { } ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); GZIPOutputStream gzip = new GZIPOutputStream(outputStream); - gzip.write(str.getBytes("UTF-8")); + gzip.write(str.getBytes(StandardCharsets.UTF_8)); gzip.close(); return outputStream.toByteArray(); }