From c1c2e3baa48f16aea4ffdd104b71bcb7b67ea7df Mon Sep 17 00:00:00 2001
From: Camotoy <20743703+DoctorMacc@users.noreply.github.com>
Date: Wed, 24 Jun 2020 17:38:41 -0400
Subject: [PATCH 01/35] Allow for newest ViaVersion to work with Geyser (#805)
* Allow for newest ViaVersion to work with Geyser
Most users should now just not use 2.2.3.
* Update ViaVersion dependency
---
bootstrap/bukkit/pom.xml | 2 +-
.../java/org/geysermc/platform/bukkit/GeyserBukkitPlugin.java | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/bootstrap/bukkit/pom.xml b/bootstrap/bukkit/pom.xml
index 95926854dec..ca8188126ef 100644
--- a/bootstrap/bukkit/pom.xml
+++ b/bootstrap/bukkit/pom.xml
@@ -26,7 +26,7 @@
us.myles
viaversion
- 3.0.0-SNAPSHOT
+ 3.0.1
provided
diff --git a/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitPlugin.java b/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitPlugin.java
index 3a13777b47c..1507f9ee45e 100644
--- a/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitPlugin.java
+++ b/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitPlugin.java
@@ -110,8 +110,8 @@ public void onEnable() {
if (Bukkit.getPluginManager().getPlugin("ViaVersion") != null) {
// TODO: Update when ViaVersion updates
// API changes between 2.2.3 and 3.0.0-SNAPSHOT require this check
- if (!Via.getAPI().getVersion().equals("3.0.0-SNAPSHOT") && isLegacy) {
- geyserLogger.info("ViaVersion detected but not ViaVersion-ABSTRACTION. Please update your ViaVersion plugin for compatibility with Geyser.");
+ if (Via.getAPI().getVersion().contains("2.2.3") && isLegacy) {
+ geyserLogger.info("ViaVersion detected but not the newest version of ViaVersion. Please update your ViaVersion plugin for compatibility with Geyser.");
} else {
isViaVersion = true;
}
From e81c6f21bf264a4a38e7c8448121009c3cfdf4a1 Mon Sep 17 00:00:00 2001
From: D3ATHBRINGER13 <53559772+D3ATHBRINGER13@users.noreply.github.com>
Date: Thu, 25 Jun 2020 00:32:07 +0100
Subject: [PATCH 02/35] Bump action versions (#810)
---
.github/workflows/pullrequest.yml | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/.github/workflows/pullrequest.yml b/.github/workflows/pullrequest.yml
index 7f941da6b32..4a570df56bf 100644
--- a/.github/workflows/pullrequest.yml
+++ b/.github/workflows/pullrequest.yml
@@ -8,8 +8,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v1
- - uses: actions/cache@v1
+ - uses: actions/checkout@v2
+ - uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
@@ -24,31 +24,31 @@ jobs:
- name: Build with Maven
run: mvn -B package
- name: Archive artifacts (Geyser Standalone)
- uses: actions/upload-artifact@v1
+ uses: actions/upload-artifact@v2
if: success()
with:
name: Geyser Standalone
path: bootstrap/standalone/target/Geyser.jar
- name: Archive artifacts (Geyser Bukkit)
- uses: actions/upload-artifact@v1
+ uses: actions/upload-artifact@v2
if: success()
with:
name: Geyser Bukkit
path: bootstrap/bukkit/target/Geyser-Bukkit.jar
- name: Archive artifacts (Geyser BungeeCord)
- uses: actions/upload-artifact@v1
+ uses: actions/upload-artifact@v2
if: success()
with:
name: Geyser BungeeCord
path: bootstrap/bungeecord/target/Geyser-BungeeCord.jar
- name: Archive artifacts (Geyser Sponge)
- uses: actions/upload-artifact@v1
+ uses: actions/upload-artifact@v2
if: success()
with:
name: Geyser Sponge
path: bootstrap/sponge/target/Geyser-Sponge.jar
- name: Archive artifacts (Geyser Velocity)
- uses: actions/upload-artifact@v1
+ uses: actions/upload-artifact@v2
if: success()
with:
name: Geyser Velocity
From 61bfd46a15828dc69f816e366c86a3716c305619 Mon Sep 17 00:00:00 2001
From: rtm516
Date: Sat, 27 Jun 2020 06:58:52 +0100
Subject: [PATCH 03/35] Fix en_us locale downloading (#809)
Fixes occasional inventories not working because of being unable to read the locale.
---
.../geysermc/connector/utils/LocaleUtils.java | 43 ++++++++++---------
1 file changed, 22 insertions(+), 21 deletions(-)
diff --git a/connector/src/main/java/org/geysermc/connector/utils/LocaleUtils.java b/connector/src/main/java/org/geysermc/connector/utils/LocaleUtils.java
index e213fe6cc95..78752591359 100644
--- a/connector/src/main/java/org/geysermc/connector/utils/LocaleUtils.java
+++ b/connector/src/main/java/org/geysermc/connector/utils/LocaleUtils.java
@@ -28,6 +28,7 @@
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode;
+import com.github.steveice10.mc.protocol.MinecraftConstants;
import lombok.Getter;
import org.geysermc.connector.GeyserConnector;
@@ -35,7 +36,10 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
-import java.util.*;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import java.util.zip.ZipFile;
public class LocaleUtils {
@@ -70,7 +74,7 @@ private static void generateAssetCache() {
// Get the url for the latest version of the games manifest
String latestInfoURL = "";
for (Version version : versionManifest.getVersions()) {
- if (version.getId().equals(versionManifest.getLatestVersion().getRelease())) {
+ if (version.getId().equals(MinecraftConstants.GAME_VERSION)) {
latestInfoURL = version.getUrl();
break;
}
@@ -84,14 +88,11 @@ private static void generateAssetCache() {
// Get the individual version manifest
VersionInfo versionInfo = GeyserConnector.JSON_MAPPER.readValue(WebUtils.getBody(latestInfoURL), VersionInfo.class);
- // Get the smallest jar for use when downloading the en_us locale, will be either the server or client
- int currentSize = Integer.MAX_VALUE;
- for (VersionDownload download : versionInfo.getDownloads().values()) {
- if (download.getUrl().endsWith(".jar") && download.getSize() < currentSize) {
- smallestURL = download.getUrl();
- currentSize = download.getSize();
- }
- }
+ // Get the client jar for use when downloading the en_us locale
+ GeyserConnector.getInstance().getLogger().debug(GeyserConnector.JSON_MAPPER.writeValueAsString(versionInfo.getDownloads()));
+ VersionDownload download = versionInfo.getDownloads().get("client");
+ GeyserConnector.getInstance().getLogger().debug(GeyserConnector.JSON_MAPPER.writeValueAsString(download));
+ smallestURL = download.getUrl();
// Get the assets list
JsonNode assets = GeyserConnector.JSON_MAPPER.readTree(WebUtils.getBody(versionInfo.getAssetIndex().getUrl())).get("objects");
@@ -160,7 +161,7 @@ private static void downloadLocale(String locale) {
* @param locale Locale to load
*/
private static void loadLocale(String locale) {
- File localeFile = new File("locales/" + locale + ".json");
+ File localeFile = GeyserConnector.getInstance().getBootstrap().getConfigFolder().resolve("locales/" + locale + ".json").toFile();
// Load the locale
if (localeFile.exists()) {
@@ -212,21 +213,21 @@ private static void downloadEN_US(File localeFile) {
// Load in the JAR as a zip and extract the file
ZipFile localeJar = new ZipFile(tmpFilePath.toString());
- InputStream inputStream = localeJar.getInputStream(localeJar.getEntry("assets/minecraft/lang/en_us.json"));
- FileOutputStream outputStream = new FileOutputStream(localeFile);
+ InputStream fileStream = localeJar.getInputStream(localeJar.getEntry("assets/minecraft/lang/en_us.json"));
+ FileOutputStream outStream = new FileOutputStream(localeFile);
// Write the file to the locale dir
- int data = inputStream.read();
- while(data != -1){
- outputStream.write(data);
- data = inputStream.read();
+ byte[] buf = new byte[fileStream.available()];
+ int length;
+ while ((length = fileStream.read(buf)) != -1) {
+ outStream.write(buf, 0, length);
}
// Flush all changes to disk and cleanup
- outputStream.flush();
- outputStream.close();
+ outStream.flush();
+ outStream.close();
- inputStream.close();
+ fileStream.close();
localeJar.close();
// Delete the nolonger needed client/server jar
@@ -357,4 +358,4 @@ class Asset {
@JsonProperty("size")
private int size;
-}
+}
\ No newline at end of file
From ed3fbf3ee0b2d71b3062bec316c901fc41abe2a8 Mon Sep 17 00:00:00 2001
From: Camotoy <20743703+DoctorMacc@users.noreply.github.com>
Date: Tue, 30 Jun 2020 11:27:28 -0400
Subject: [PATCH 04/35] Add message about 'outdated' Geyser. (#877)
Ensures people are aware of a 1.16 build.
---
.../src/main/java/org/geysermc/connector/GeyserConnector.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java
index d201656ad25..3d55845dc43 100644
--- a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java
+++ b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java
@@ -110,6 +110,7 @@ private GeyserConnector(PlatformType platformType, GeyserBootstrap bootstrap) {
logger.info("Loading " + NAME + " version " + VERSION);
logger.info("");
logger.info("******************************************");
+ logger.warning("This build is for connecting to Java 1.15.2 servers and from Bedrock 1.14.60 clients. Please join our Discord (https://discord.geysermc.org) for up-to-date information about where to download 1.16.");
this.generalThreadPool = Executors.newScheduledThreadPool(config.getGeneralThreadPool());
From 4c74f82c1984906cdfebea2f11f310bef2d9d280 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Thu, 2 Jul 2020 19:18:44 -0500
Subject: [PATCH 05/35] Bump log4j-core from 2.13.1 to 2.13.2 in
/bootstrap/standalone (#886)
Bumps log4j-core from 2.13.1 to 2.13.2.
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
---
bootstrap/standalone/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bootstrap/standalone/pom.xml b/bootstrap/standalone/pom.xml
index 770ca1009ed..df75f753325 100644
--- a/bootstrap/standalone/pom.xml
+++ b/bootstrap/standalone/pom.xml
@@ -63,7 +63,7 @@
org.apache.logging.log4j
log4j-core
- 2.13.1
+ 2.13.2
org.apache.logging.log4j
From ad751ecb5b55e2a43f5e77c36f272354f3e3aac7 Mon Sep 17 00:00:00 2001
From: rtm516
Date: Mon, 6 Jul 2020 11:18:17 +0100
Subject: [PATCH 06/35] Fix ping passthrough throwing errors on unknown
properties (Fixes #903)
---
.../java/org/geysermc/connector/common/ping/GeyserPingInfo.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/connector/src/main/java/org/geysermc/connector/common/ping/GeyserPingInfo.java b/connector/src/main/java/org/geysermc/connector/common/ping/GeyserPingInfo.java
index eff1fe49dca..246a3c6e31f 100644
--- a/connector/src/main/java/org/geysermc/connector/common/ping/GeyserPingInfo.java
+++ b/connector/src/main/java/org/geysermc/connector/common/ping/GeyserPingInfo.java
@@ -36,6 +36,7 @@
import java.util.Collection;
@Data
+@JsonIgnoreProperties(ignoreUnknown = true)
public class GeyserPingInfo {
private String description;
From b0e291edc4c62e303cba7002ea47ffde8550d4a1 Mon Sep 17 00:00:00 2001
From: rtm516
Date: Mon, 6 Jul 2020 12:18:14 +0100
Subject: [PATCH 07/35] Fix version checking and add failed language string
---
.../connector/command/defaults/VersionCommand.java | 14 +++++++++-----
connector/src/main/resources/languages | 2 +-
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/connector/src/main/java/org/geysermc/connector/command/defaults/VersionCommand.java b/connector/src/main/java/org/geysermc/connector/command/defaults/VersionCommand.java
index e29e164b3cb..7dd59712ad2 100644
--- a/connector/src/main/java/org/geysermc/connector/command/defaults/VersionCommand.java
+++ b/connector/src/main/java/org/geysermc/connector/command/defaults/VersionCommand.java
@@ -33,6 +33,9 @@
import org.geysermc.connector.utils.LanguageUtils;
import org.geysermc.connector.utils.WebUtils;
+import java.io.IOException;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
import java.util.Properties;
public class VersionCommand extends GeyserCommand {
@@ -56,9 +59,9 @@ public void execute(CommandSender sender, String[] args) {
Properties gitProp = new Properties();
gitProp.load(FileUtils.getResource("git.properties"));
- String buildXML = WebUtils.getBody("https://ci.nukkitx.com/job/GeyserMC/job/Geyser/job/" + gitProp.getProperty("git.branch") + "/lastSuccessfulBuild/api/xml?xpath=//master/buildNumber");
+ String buildXML = WebUtils.getBody("https://ci.nukkitx.com/job/GeyserMC/job/Geyser/job/" + URLEncoder.encode(gitProp.getProperty("git.branch"), StandardCharsets.UTF_8.toString()) + "/lastSuccessfulBuild/api/xml?xpath=//buildNumber");
if (buildXML.startsWith("")) {
- int latestBuildNum = Integer.parseInt(buildXML.replaceAll("<(\\\\)?buildNumber>", ""));
+ int latestBuildNum = Integer.parseInt(buildXML.replaceAll("<(\\\\)?(/)?buildNumber>", "").trim());
int buildNum = Integer.parseInt(gitProp.getProperty("git.build.number"));
if (latestBuildNum != buildNum) {
sender.sendMessage(LanguageUtils.getLocaleStringLog("geyser.commands.version.no_updates"));
@@ -66,10 +69,11 @@ public void execute(CommandSender sender, String[] args) {
sender.sendMessage(LanguageUtils.getLocaleStringLog("geyser.commands.version.outdated", (latestBuildNum - buildNum), "http://ci.geysermc.org/"));
}
} else {
- throw new AssertionError();
+ throw new AssertionError("buildNumber missing");
}
- } catch (Exception e) {
- sender.sendMessage("Failed to check for updates");
+ } catch (IOException | AssertionError | NumberFormatException e) {
+ GeyserConnector.getInstance().getLogger().error(LanguageUtils.getLocaleStringLog("geyser.commands.version.failed"), e);
+ sender.sendMessage(LanguageUtils.getLocaleStringLog("geyser.commands.version.failed"));
}
}
}
diff --git a/connector/src/main/resources/languages b/connector/src/main/resources/languages
index c199011b6c1..fc8f930a238 160000
--- a/connector/src/main/resources/languages
+++ b/connector/src/main/resources/languages
@@ -1 +1 @@
-Subproject commit c199011b6c131b195e94d4785abbc3dd73ca19cd
+Subproject commit fc8f930a238a375c7e3be6e5c7ea1720b61d0cca
From 66570a623d2d61674724e0e7e72fef9ce0fbe02f Mon Sep 17 00:00:00 2001
From: theminecoder
Date: Mon, 6 Jul 2020 23:10:36 +1000
Subject: [PATCH 08/35] Fix scoreboards bleeding into other servers (#902)
---
.../network/translators/java/JavaJoinGameTranslator.java | 3 +++
1 file changed, 3 insertions(+)
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaJoinGameTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaJoinGameTranslator.java
index 5c94d6afb44..01f6b0b92e3 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaJoinGameTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaJoinGameTranslator.java
@@ -31,6 +31,7 @@
import com.github.steveice10.mc.protocol.packet.ingame.client.ClientSettingsPacket;
import org.geysermc.connector.entity.PlayerEntity;
import org.geysermc.connector.network.session.GeyserSession;
+import org.geysermc.connector.network.session.cache.ScoreboardCache;
import org.geysermc.connector.network.translators.PacketTranslator;
import org.geysermc.connector.network.translators.Translator;
import org.geysermc.connector.utils.DimensionUtils;
@@ -58,6 +59,8 @@ public void translate(ServerJoinGamePacket packet, GeyserSession session) {
String fakeDim = entity.getDimension().equals(DimensionUtils.OVERWORLD) ? DimensionUtils.NETHER : DimensionUtils.OVERWORLD;
DimensionUtils.switchDimension(session, fakeDim);
DimensionUtils.switchDimension(session, packet.getDimension());
+
+ session.getScoreboardCache().removeScoreboard();
}
AdventureSettingsPacket bedrockPacket = new AdventureSettingsPacket();
From 3cdc208174d91d7a04cda0b7637b1598c9f2dfc7 Mon Sep 17 00:00:00 2001
From: James Harrison
Date: Mon, 6 Jul 2020 14:26:00 +0100
Subject: [PATCH 09/35] Update MinecraftCapes endpoints (#907)
Updates the mccapes endpoints with the new domain.
---
.../main/java/org/geysermc/connector/utils/SkinProvider.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/connector/src/main/java/org/geysermc/connector/utils/SkinProvider.java b/connector/src/main/java/org/geysermc/connector/utils/SkinProvider.java
index aea9ba1892b..aa01ada8142 100644
--- a/connector/src/main/java/org/geysermc/connector/utils/SkinProvider.java
+++ b/connector/src/main/java/org/geysermc/connector/utils/SkinProvider.java
@@ -537,7 +537,7 @@ public enum CapeProvider {
OPTIFINE("http://s.optifine.net/capes/%s.png", CapeUrlType.USERNAME),
LABYMOD("https://www.labymod.net/page/php/getCapeTexture.php?uuid=%s", CapeUrlType.UUID_DASHED),
FIVEZIG("https://textures.5zigreborn.eu/profile/%s", CapeUrlType.UUID_DASHED),
- MINECRAFTCAPES("https://www.minecraftcapes.co.uk/getCape/%s", CapeUrlType.UUID);
+ MINECRAFTCAPES("https://minecraftcapes.net/profile/%s/cape", CapeUrlType.UUID);
public static final CapeProvider[] VALUES = Arrays.copyOfRange(values(), 1, 5);
private String url;
@@ -573,7 +573,7 @@ public enum CapeUrlType {
@NoArgsConstructor
@Getter
public enum EarsProvider {
- MINECRAFTCAPES("https://www.minecraftcapes.co.uk/getEars/%s", CapeUrlType.UUID);
+ MINECRAFTCAPES("https://minecraftcapes.net/profile/%s/ears", CapeUrlType.UUID);
public static final EarsProvider[] VALUES = values();
private String url;
From 7e51040a8e0081854d852ceda709e91169fd82b6 Mon Sep 17 00:00:00 2001
From: rtm516
Date: Mon, 6 Jul 2020 14:41:55 +0100
Subject: [PATCH 10/35] Fix fallback locale not loading
---
.../main/java/org/geysermc/connector/utils/LanguageUtils.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/connector/src/main/java/org/geysermc/connector/utils/LanguageUtils.java b/connector/src/main/java/org/geysermc/connector/utils/LanguageUtils.java
index 6172cc9e8b0..9dabc387161 100644
--- a/connector/src/main/java/org/geysermc/connector/utils/LanguageUtils.java
+++ b/connector/src/main/java/org/geysermc/connector/utils/LanguageUtils.java
@@ -173,6 +173,7 @@ public static String getDefaultLocale() {
locale = formatLocale(Locale.getDefault().getLanguage() + "_" + Locale.getDefault().getCountry());
if (!isValidLanguage(locale)) { // Bedrock does not support this language
locale = "en_US";
+ loadGeyserLocale(locale);
}
if (GeyserConnector.getInstance() != null &&
GeyserConnector.getInstance().getConfig() != null && (GeyserConnector.getInstance().getConfig().getDefaultLocale() == null || !isValid)) { // Means we should use the system locale for sure
From 82c6276794b3f3b26e9cbc3b5e5f9688ed097d13 Mon Sep 17 00:00:00 2001
From: DoctorMacc
Date: Mon, 6 Jul 2020 15:19:48 -0400
Subject: [PATCH 11/35] Move back to using the main repository for
MCProtocolLib
---
connector/pom.xml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/connector/pom.xml b/connector/pom.xml
index b2bc15263cc..b9bf67cef91 100644
--- a/connector/pom.xml
+++ b/connector/pom.xml
@@ -103,9 +103,9 @@
compile
- com.github.GeyserMC
- MCProtocolLib
- feature~1.16-1.12.1-1-g10bb8e2-319
+ com.github.steveice10
+ mcprotocollib
+ 7545884a2d
compile
From 545dfa38f0db781fc6199ee9a8efcccb1815b1f4 Mon Sep 17 00:00:00 2001
From: DoctorMacc
Date: Mon, 6 Jul 2020 16:22:07 -0400
Subject: [PATCH 12/35] JavaUpdateTileEntityTranslator improvements
- Remove the use of deprecated functions
- Check for empty NBT (fixes errors on CubeCraft)
---
.../java/world/JavaUpdateTileEntityTranslator.java | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaUpdateTileEntityTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaUpdateTileEntityTranslator.java
index 822be8c8939..ae4ed779296 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaUpdateTileEntityTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaUpdateTileEntityTranslator.java
@@ -40,12 +40,17 @@ public class JavaUpdateTileEntityTranslator extends PacketTranslator
Date: Mon, 6 Jul 2020 23:36:04 +0100
Subject: [PATCH 13/35] Fix RGB colors on signs causing chunk issues, fix items
names not being displayed correctly
---
connector/pom.xml | 12 +++++-----
.../translators/item/ItemTranslator.java | 23 +++++++++----------
.../translators/nbt/BasicItemTranslator.java | 12 +++++-----
.../connector/utils/MessageUtils.java | 10 ++++----
4 files changed, 28 insertions(+), 29 deletions(-)
diff --git a/connector/pom.xml b/connector/pom.xml
index b9bf67cef91..3fdd5f37a96 100644
--- a/connector/pom.xml
+++ b/connector/pom.xml
@@ -127,20 +127,20 @@
net.kyori
- text-api
- 3.0.3
+ adventure-api
+ 4.0.0-SNAPSHOT
compile
net.kyori
- text-serializer-gson
- 3.0.3
+ adventure-text-serializer-gson
+ 4.0.0-SNAPSHOT
compile
net.kyori
- text-serializer-legacy
- 3.0.3
+ adventure-text-serializer-legacy
+ 4.0.0-SNAPSHOT
compile
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemTranslator.java
index 7811d9c0ae2..fde799fe497 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemTranslator.java
@@ -28,17 +28,7 @@
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
import com.github.steveice10.mc.protocol.data.message.MessageSerializer;
-import com.github.steveice10.opennbt.tag.builtin.ByteArrayTag;
-import com.github.steveice10.opennbt.tag.builtin.ByteTag;
-import com.github.steveice10.opennbt.tag.builtin.DoubleTag;
-import com.github.steveice10.opennbt.tag.builtin.FloatTag;
-import com.github.steveice10.opennbt.tag.builtin.IntArrayTag;
-import com.github.steveice10.opennbt.tag.builtin.IntTag;
-import com.github.steveice10.opennbt.tag.builtin.ListTag;
-import com.github.steveice10.opennbt.tag.builtin.LongArrayTag;
-import com.github.steveice10.opennbt.tag.builtin.LongTag;
-import com.github.steveice10.opennbt.tag.builtin.ShortTag;
-import com.github.steveice10.opennbt.tag.builtin.StringTag;
+import com.github.steveice10.opennbt.tag.builtin.*;
import com.nukkitx.nbt.NbtList;
import com.nukkitx.nbt.NbtMap;
import com.nukkitx.nbt.NbtMapBuilder;
@@ -46,11 +36,14 @@
import com.nukkitx.protocol.bedrock.data.inventory.ItemData;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
+import net.kyori.adventure.text.TextComponent;
+import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
+import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.ItemRemapper;
-import org.geysermc.connector.utils.MessageUtils;
import org.geysermc.connector.utils.LanguageUtils;
+import org.geysermc.connector.utils.MessageUtils;
import org.reflections.Reflections;
import java.util.*;
@@ -167,6 +160,12 @@ public static ItemData translateToBedrock(GeyserSession session, ItemStack stack
if (display != null) {
String name = display.getString("Name");
+ // If its not a message convert it
+ if (!MessageUtils.isMessage(name)) {
+ TextComponent component = LegacyComponentSerializer.legacy().deserialize(name);
+ name = GsonComponentSerializer.gson().serialize(component);
+ }
+
// Check if its a message to translate
if (MessageUtils.isMessage(name)) {
// Get the translated name
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/item/translators/nbt/BasicItemTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/item/translators/nbt/BasicItemTranslator.java
index 776cec72912..34c7f43dc57 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/item/translators/nbt/BasicItemTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/item/translators/nbt/BasicItemTranslator.java
@@ -29,13 +29,13 @@
import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
-import net.kyori.text.Component;
-import net.kyori.text.TextComponent;
-import net.kyori.text.serializer.gson.GsonComponentSerializer;
-import net.kyori.text.serializer.legacy.LegacyComponentSerializer;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.TextComponent;
+import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
+import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.geysermc.connector.network.translators.ItemRemapper;
-import org.geysermc.connector.network.translators.item.NbtItemStackTranslator;
import org.geysermc.connector.network.translators.item.ItemEntry;
+import org.geysermc.connector.network.translators.item.NbtItemStackTranslator;
import org.geysermc.connector.utils.MessageUtils;
import java.util.ArrayList;
@@ -101,7 +101,7 @@ private String toJavaMessage(StringTag tag) {
message = message.replaceFirst("§r", "");
}
Component component = TextComponent.of(message);
- return GsonComponentSerializer.INSTANCE.serialize(component);
+ return GsonComponentSerializer.gson().serialize(component);
}
private String toBedrockMessage(StringTag tag) {
diff --git a/connector/src/main/java/org/geysermc/connector/utils/MessageUtils.java b/connector/src/main/java/org/geysermc/connector/utils/MessageUtils.java
index 3a35782d4da..bf19622466a 100644
--- a/connector/src/main/java/org/geysermc/connector/utils/MessageUtils.java
+++ b/connector/src/main/java/org/geysermc/connector/utils/MessageUtils.java
@@ -35,9 +35,9 @@
import com.github.steveice10.mc.protocol.data.message.style.MessageStyle;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
-import net.kyori.text.Component;
-import net.kyori.text.serializer.gson.GsonComponentSerializer;
-import net.kyori.text.serializer.legacy.LegacyComponentSerializer;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
+import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.geysermc.connector.network.session.GeyserSession;
import java.util.*;
@@ -263,12 +263,12 @@ public static String getBedrockMessage(String message) {
}
public static Component phraseJavaMessage(String message) {
- return GsonComponentSerializer.INSTANCE.deserialize(message);
+ return GsonComponentSerializer.gson().deserialize(message);
}
public static String getJavaMessage(String message) {
Component component = LegacyComponentSerializer.legacy().deserialize(message);
- return GsonComponentSerializer.INSTANCE.serialize(component);
+ return GsonComponentSerializer.gson().serialize(component);
}
/**
From c454e443df0fc2829732d8b44d425619be79e44a Mon Sep 17 00:00:00 2001
From: rtm516
Date: Mon, 6 Jul 2020 23:36:31 +0100
Subject: [PATCH 14/35] Fix maps with negative IDs causing out of bounds errors
---
.../bedrock/BedrockMapInfoRequestTranslator.java | 8 ++++++--
.../translators/java/world/JavaMapDataTranslator.java | 6 +++++-
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockMapInfoRequestTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockMapInfoRequestTranslator.java
index 3c7efa18bf0..247021f10c9 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockMapInfoRequestTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockMapInfoRequestTranslator.java
@@ -39,12 +39,16 @@ public class BedrockMapInfoRequestTranslator extends PacketTranslator {
- session.sendUpstreamPacket(session.getStoredMaps().get(mapID));
- session.getStoredMaps().remove(mapID);
+ session.sendUpstreamPacket(session.getStoredMaps().get(finalMapID));
+ session.getStoredMaps().remove(finalMapID);
}, 100, TimeUnit.MILLISECONDS);
}
}
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaMapDataTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaMapDataTranslator.java
index 2aee7bc0276..12ef1053b92 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaMapDataTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaMapDataTranslator.java
@@ -85,7 +85,11 @@ public void translate(ServerMapDataPacket packet, GeyserSession session) {
// Store the map to send when the client requests it, as bedrock expects the data after a MapInfoRequestPacket
if (shouldStore) {
- session.getStoredMaps().put(mapItemDataPacket.getUniqueMapId(), mapItemDataPacket);
+ long uniqueMapId = mapItemDataPacket.getUniqueMapId();
+ if (uniqueMapId <= -1l) {
+ uniqueMapId = 0l;
+ }
+ session.getStoredMaps().put(uniqueMapId, mapItemDataPacket);
}
// Send anyway just in case
From 02905c2a355d53df805d7b8d52b2f0b92dd08912 Mon Sep 17 00:00:00 2001
From: rtm516
Date: Mon, 6 Jul 2020 23:41:54 +0100
Subject: [PATCH 15/35] Add the adventure-api maven repo
---
pom.xml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/pom.xml b/pom.xml
index 3e119eb1197..acfdc3d6346 100644
--- a/pom.xml
+++ b/pom.xml
@@ -65,6 +65,10 @@
viaversion-repo
https://repo.viaversion.com
+
+ sonatype
+ https://oss.sonatype.org/content/repositories/snapshots/
+
From 699402e635919fdd1680cf7361cd4042264c382c Mon Sep 17 00:00:00 2001
From: AJ Ferguson
Date: Mon, 6 Jul 2020 15:52:38 -0800
Subject: [PATCH 16/35] Fix bug with maps
---
.../connector/network/session/GeyserSession.java | 3 ++-
.../bedrock/BedrockMapInfoRequestTranslator.java | 11 +++++------
.../translators/java/world/JavaMapDataTranslator.java | 6 +-----
3 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java
index 666820cc290..6b51c8921ea 100644
--- a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java
+++ b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java
@@ -48,6 +48,7 @@
import com.nukkitx.protocol.bedrock.data.*;
import com.nukkitx.protocol.bedrock.packet.*;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
+import it.unimi.dsi.fastutil.longs.Long2ObjectMaps;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.Object2LongMap;
import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap;
@@ -107,7 +108,7 @@ public class GeyserSession implements CommandSender {
private TeleportCache teleportCache;
@Getter
- private final Long2ObjectMap storedMaps = new Long2ObjectOpenHashMap<>();
+ private final Long2ObjectMap storedMaps = Long2ObjectMaps.synchronize(new Long2ObjectOpenHashMap<>());
/**
* A map of Vector3i positions to Java entity IDs.
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockMapInfoRequestTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockMapInfoRequestTranslator.java
index 247021f10c9..11dfe46e091 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockMapInfoRequestTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockMapInfoRequestTranslator.java
@@ -25,6 +25,7 @@
package org.geysermc.connector.network.translators.bedrock;
+import com.nukkitx.protocol.bedrock.packet.ClientboundMapItemDataPacket;
import com.nukkitx.protocol.bedrock.packet.MapInfoRequestPacket;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.network.session.GeyserSession;
@@ -39,16 +40,14 @@ public class BedrockMapInfoRequestTranslator extends PacketTranslator {
- session.sendUpstreamPacket(session.getStoredMaps().get(finalMapID));
- session.getStoredMaps().remove(finalMapID);
+ ClientboundMapItemDataPacket mapPacket = session.getStoredMaps().remove(mapID);
+ if (mapPacket != null) {
+ session.sendUpstreamPacket(mapPacket);
+ }
}, 100, TimeUnit.MILLISECONDS);
}
}
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaMapDataTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaMapDataTranslator.java
index 12ef1053b92..2aee7bc0276 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaMapDataTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaMapDataTranslator.java
@@ -85,11 +85,7 @@ public void translate(ServerMapDataPacket packet, GeyserSession session) {
// Store the map to send when the client requests it, as bedrock expects the data after a MapInfoRequestPacket
if (shouldStore) {
- long uniqueMapId = mapItemDataPacket.getUniqueMapId();
- if (uniqueMapId <= -1l) {
- uniqueMapId = 0l;
- }
- session.getStoredMaps().put(uniqueMapId, mapItemDataPacket);
+ session.getStoredMaps().put(mapItemDataPacket.getUniqueMapId(), mapItemDataPacket);
}
// Send anyway just in case
From 24f9651cc6e6279e3a2b709c0cf6766c2032fb4a Mon Sep 17 00:00:00 2001
From: RednedEpic
Date: Mon, 6 Jul 2020 20:11:34 -0500
Subject: [PATCH 17/35] Convert map of players to list (may address #833)
---
.../spigot/world/GeyserSpigotBlockPlaceListener.java | 2 +-
.../platform/standalone/gui/GeyserStandaloneGUI.java | 7 +++----
.../java/org/geysermc/connector/GeyserConnector.java | 12 ++++++------
.../connector/command/defaults/ListCommand.java | 4 ++--
.../connector/command/defaults/OffhandCommand.java | 2 +-
.../connector/command/defaults/ReloadCommand.java | 2 +-
.../geysermc/connector/entity/FishingHookEntity.java | 2 +-
.../network/ConnectorServerEventHandler.java | 9 ---------
.../connector/network/session/GeyserSession.java | 9 ++++++++-
9 files changed, 23 insertions(+), 26 deletions(-)
diff --git a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/GeyserSpigotBlockPlaceListener.java b/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/GeyserSpigotBlockPlaceListener.java
index f17a97e3766..4fe93d45920 100644
--- a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/GeyserSpigotBlockPlaceListener.java
+++ b/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/GeyserSpigotBlockPlaceListener.java
@@ -47,7 +47,7 @@ public class GeyserSpigotBlockPlaceListener implements Listener {
@EventHandler
public void place(final BlockPlaceEvent event) {
- for (GeyserSession session : connector.getPlayers().values()) {
+ for (GeyserSession session : connector.getPlayers()) {
if (event.getPlayer() == Bukkit.getPlayer(session.getPlayerEntity().getUsername())) {
LevelSoundEventPacket placeBlockSoundPacket = new LevelSoundEventPacket();
placeBlockSoundPacket.setSound(SoundEvent.PLACE);
diff --git a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/gui/GeyserStandaloneGUI.java b/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/gui/GeyserStandaloneGUI.java
index 9be0e1c6a1f..0c0ec112702 100644
--- a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/gui/GeyserStandaloneGUI.java
+++ b/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/gui/GeyserStandaloneGUI.java
@@ -42,7 +42,6 @@
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
-import java.net.InetSocketAddress;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
@@ -292,10 +291,10 @@ public void startUpdateThread() {
// Update player table
playerTableModel.getDataVector().removeAllElements();
- for (Map.Entry player : GeyserConnector.getInstance().getPlayers().entrySet()) {
+ for (GeyserSession player : GeyserConnector.getInstance().getPlayers()) {
Vector row = new Vector();
- row.add(player.getKey().getHostName());
- row.add(player.getValue().getPlayerEntity().getUsername());
+ row.add(player.getSocketAddress().getHostName());
+ row.add(player.getPlayerEntity().getUsername());
playerTableModel.addRow(row);
}
diff --git a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java
index 298f5bc8270..675c2b9a290 100644
--- a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java
+++ b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java
@@ -59,8 +59,8 @@
import java.net.InetSocketAddress;
import java.text.DecimalFormat;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.ArrayList;
+import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
@@ -76,7 +76,7 @@ public class GeyserConnector {
public static final String NAME = "Geyser";
public static final String VERSION = "DEV"; // A fallback for running in IDEs
- private final Map players = new HashMap<>();
+ private final List players = new ArrayList<>();
private static GeyserConnector instance;
@@ -185,7 +185,7 @@ public void shutdown() {
if (players.size() >= 1) {
bootstrap.getGeyserLogger().info(LanguageUtils.getLocaleStringLog("geyser.core.shutdown.kick.log", players.size()));
- for (GeyserSession playerSession : players.values()) {
+ for (GeyserSession playerSession : players) {
playerSession.disconnect(LanguageUtils.getPlayerLocaleString("geyser.core.shutdown.kick.message", playerSession.getClientData().getLanguageCode()));
}
@@ -227,11 +227,11 @@ public void run() {
}
public void addPlayer(GeyserSession player) {
- players.put(player.getSocketAddress(), player);
+ players.add(player);
}
public void removePlayer(GeyserSession player) {
- players.remove(player.getSocketAddress());
+ players.remove(player);
}
public static GeyserConnector start(PlatformType platformType, GeyserBootstrap bootstrap) {
diff --git a/connector/src/main/java/org/geysermc/connector/command/defaults/ListCommand.java b/connector/src/main/java/org/geysermc/connector/command/defaults/ListCommand.java
index 0de73a5d154..3c78c554000 100644
--- a/connector/src/main/java/org/geysermc/connector/command/defaults/ListCommand.java
+++ b/connector/src/main/java/org/geysermc/connector/command/defaults/ListCommand.java
@@ -47,9 +47,9 @@ public ListCommand(GeyserConnector connector, String name, String description, S
public void execute(CommandSender sender, String[] args) {
String message = "";
if (sender instanceof GeyserSession) {
- message = LanguageUtils.getPlayerLocaleString("geyser.commands.list.message", ((GeyserSession) sender).getClientData().getLanguageCode(), connector.getPlayers().size(), connector.getPlayers().values().stream().map(GeyserSession::getName).collect(Collectors.joining(" ")));
+ message = LanguageUtils.getPlayerLocaleString("geyser.commands.list.message", ((GeyserSession) sender).getClientData().getLanguageCode(), connector.getPlayers().size(), connector.getPlayers().stream().map(GeyserSession::getName).collect(Collectors.joining(" ")));
} else {
- message = LanguageUtils.getLocaleStringLog("geyser.commands.list.message", connector.getPlayers().size(), connector.getPlayers().values().stream().map(GeyserSession::getName).collect(Collectors.joining(" ")));
+ message = LanguageUtils.getLocaleStringLog("geyser.commands.list.message", connector.getPlayers().size(), connector.getPlayers().stream().map(GeyserSession::getName).collect(Collectors.joining(" ")));
}
sender.sendMessage(message);
diff --git a/connector/src/main/java/org/geysermc/connector/command/defaults/OffhandCommand.java b/connector/src/main/java/org/geysermc/connector/command/defaults/OffhandCommand.java
index a49506b0f0f..b1b6013286d 100644
--- a/connector/src/main/java/org/geysermc/connector/command/defaults/OffhandCommand.java
+++ b/connector/src/main/java/org/geysermc/connector/command/defaults/OffhandCommand.java
@@ -59,7 +59,7 @@ public void execute(CommandSender sender, String[] args) {
return;
}
// Needed for Bukkit - sender is not an instance of GeyserSession
- for (GeyserSession session : connector.getPlayers().values()) {
+ for (GeyserSession session : connector.getPlayers()) {
if (sender.getName().equals(session.getPlayerEntity().getUsername())) {
ClientPlayerActionPacket releaseItemPacket = new ClientPlayerActionPacket(PlayerAction.SWAP_HANDS, new Position(0,0,0),
BlockFace.DOWN);
diff --git a/connector/src/main/java/org/geysermc/connector/command/defaults/ReloadCommand.java b/connector/src/main/java/org/geysermc/connector/command/defaults/ReloadCommand.java
index d8bf8583b03..9c24fa2be15 100644
--- a/connector/src/main/java/org/geysermc/connector/command/defaults/ReloadCommand.java
+++ b/connector/src/main/java/org/geysermc/connector/command/defaults/ReloadCommand.java
@@ -56,7 +56,7 @@ public void execute(CommandSender sender, String[] args) {
sender.sendMessage(message);
- for (GeyserSession session : connector.getPlayers().values()) {
+ for (GeyserSession session : connector.getPlayers()) {
session.disconnect(LanguageUtils.getPlayerLocaleString("geyser.commands.reload.kick", session.getClientData().getLanguageCode()));
}
connector.reload();
diff --git a/connector/src/main/java/org/geysermc/connector/entity/FishingHookEntity.java b/connector/src/main/java/org/geysermc/connector/entity/FishingHookEntity.java
index cc7d749d99d..4d0eb202f24 100644
--- a/connector/src/main/java/org/geysermc/connector/entity/FishingHookEntity.java
+++ b/connector/src/main/java/org/geysermc/connector/entity/FishingHookEntity.java
@@ -37,7 +37,7 @@ public class FishingHookEntity extends Entity {
public FishingHookEntity(long entityId, long geyserId, EntityType entityType, Vector3f position, Vector3f motion, Vector3f rotation, ProjectileData data) {
super(entityId, geyserId, entityType, position, motion, rotation);
- for (GeyserSession session : GeyserConnector.getInstance().getPlayers().values()) {
+ for (GeyserSession session : GeyserConnector.getInstance().getPlayers()) {
Entity entity = session.getEntityCache().getEntityByJavaId(data.getOwnerId());
if (entity == null && session.getPlayerEntity().getEntityId() == data.getOwnerId()) {
entity = session.getPlayerEntity();
diff --git a/connector/src/main/java/org/geysermc/connector/network/ConnectorServerEventHandler.java b/connector/src/main/java/org/geysermc/connector/network/ConnectorServerEventHandler.java
index ad5cb42aa9b..6ca9063c222 100644
--- a/connector/src/main/java/org/geysermc/connector/network/ConnectorServerEventHandler.java
+++ b/connector/src/main/java/org/geysermc/connector/network/ConnectorServerEventHandler.java
@@ -108,15 +108,6 @@ public BedrockPong onQuery(InetSocketAddress inetSocketAddress) {
public void onSessionCreation(BedrockServerSession bedrockServerSession) {
bedrockServerSession.setLogging(true);
bedrockServerSession.setPacketHandler(new UpstreamPacketHandler(connector, new GeyserSession(connector, bedrockServerSession)));
- bedrockServerSession.addDisconnectHandler(disconnectReason -> {
- connector.getLogger().info(LanguageUtils.getLocaleStringLog("geyser.network.disconnect", bedrockServerSession.getAddress().getAddress(), disconnectReason));
-
- GeyserSession player = connector.getPlayers().get(bedrockServerSession.getAddress());
- if (player != null) {
- player.disconnect(disconnectReason.name());
- connector.removePlayer(player);
- }
- });
bedrockServerSession.setPacketCodec(GeyserConnector.BEDROCK_PACKET_CODEC);
}
diff --git a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java
index 6b51c8921ea..0aa0ceaae1e 100644
--- a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java
+++ b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java
@@ -210,6 +210,13 @@ public GeyserSession(GeyserConnector connector, BedrockServerSession bedrockServ
this.loggedIn = false;
this.inventoryCache.getInventories().put(0, inventory);
+
+ bedrockServerSession.addDisconnectHandler(disconnectReason -> {
+ connector.getLogger().info(LanguageUtils.getLocaleStringLog("geyser.network.disconnect", bedrockServerSession.getAddress().getAddress(), disconnectReason));
+
+ disconnect(disconnectReason.name());
+ connector.removePlayer(this);
+ });
}
public void connect(RemoteServer remoteServer) {
@@ -428,7 +435,7 @@ public void disconnect(String reason) {
downstream.getSession().disconnect(reason);
}
if (upstream != null && !upstream.isClosed()) {
- connector.getPlayers().remove(this.upstream.getAddress());
+ connector.getPlayers().remove(this);
upstream.disconnect(reason);
}
}
From f68632f43349816528efc8719e01817ff4d518fc Mon Sep 17 00:00:00 2001
From: DoctorMacc
Date: Mon, 6 Jul 2020 21:38:10 -0400
Subject: [PATCH 18/35] Block-related updates
- Fix block breaking animation
- Fix block breaking particles
- Don't initialize Geyser's chunk cache if using Spigot
---
.../connector/network/session/cache/ChunkCache.java | 11 +++++++----
.../translators/bedrock/BedrockActionTranslator.java | 2 +-
.../BedrockInventoryTransactionTranslator.java | 2 +-
3 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/connector/src/main/java/org/geysermc/connector/network/session/cache/ChunkCache.java b/connector/src/main/java/org/geysermc/connector/network/session/cache/ChunkCache.java
index a7b0c96653f..9601a2981c5 100644
--- a/connector/src/main/java/org/geysermc/connector/network/session/cache/ChunkCache.java
+++ b/connector/src/main/java/org/geysermc/connector/network/session/cache/ChunkCache.java
@@ -29,6 +29,7 @@
import com.github.steveice10.mc.protocol.data.game.chunk.Column;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
import lombok.Getter;
+import org.geysermc.connector.bootstrap.GeyserBootstrap;
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.world.block.BlockTranslator;
import org.geysermc.connector.network.translators.world.chunk.ChunkPosition;
@@ -38,15 +39,17 @@
public class ChunkCache {
- private boolean cache;
- private final GeyserSession session;
+ private final boolean cache;
@Getter
private Map chunks = new HashMap<>();
public ChunkCache(GeyserSession session) {
- this.session = session;
- this.cache = session.getConnector().getConfig().isCacheChunks();
+ if (session.getConnector().getWorldManager().getClass() == GeyserBootstrap.DEFAULT_CHUNK_MANAGER.getClass()) {
+ this.cache = session.getConnector().getConfig().isCacheChunks();
+ } else {
+ this.cache = false; // To prevent Spigot from initializing
+ }
}
public void addToCache(Column chunk) {
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockActionTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockActionTranslator.java
index 7d8772fbdfb..dfd49f2ee1a 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockActionTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockActionTranslator.java
@@ -112,7 +112,7 @@ public void translate(PlayerActionPacket packet, GeyserSession session) {
break;
case CONTINUE_BREAK:
LevelEventPacket continueBreakPacket = new LevelEventPacket();
- continueBreakPacket.setType(LevelEventType.BLOCK_UPDATE_BREAK); //TODO: There are now level event types for all breaks. Important?
+ continueBreakPacket.setType(LevelEventType.PARTICLE_CRACK_BLOCK);
continueBreakPacket.setData(BlockTranslator.getBedrockBlockId(session.getBreakingBlock()));
continueBreakPacket.setPosition(packet.getBlockPosition().toFloat());
session.sendUpstreamPacket(continueBreakPacket);
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockInventoryTransactionTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockInventoryTransactionTranslator.java
index f05c46f2497..25e1c54e2a5 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockInventoryTransactionTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockInventoryTransactionTranslator.java
@@ -152,7 +152,7 @@ public void translate(InventoryTransactionPacket packet, GeyserSession session)
session.setLastBlockPlacePosition(null);
LevelEventPacket blockBreakPacket = new LevelEventPacket();
- blockBreakPacket.setType(LevelEventType.BLOCK_STOP_BREAK); //TODO: Make sure this is the right new enum
+ blockBreakPacket.setType(LevelEventType.PARTICLE_DESTROY_BLOCK);
blockBreakPacket.setPosition(packet.getBlockPosition().toFloat());
blockBreakPacket.setData(BlockTranslator.getBedrockBlockId(blockState));
session.sendUpstreamPacket(blockBreakPacket);
From 4353c184d9d9962769baf330181dcac9f89b9989 Mon Sep 17 00:00:00 2001
From: DoctorMacc
Date: Mon, 6 Jul 2020 21:42:12 -0400
Subject: [PATCH 19/35] Revert all 1.14.60-specific changes
---
bootstrap/bukkit/pom.xml | 2 +-
.../java/org/geysermc/platform/bukkit/GeyserBukkitPlugin.java | 4 ++--
.../src/main/java/org/geysermc/connector/GeyserConnector.java | 1 -
3 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/bootstrap/bukkit/pom.xml b/bootstrap/bukkit/pom.xml
index ca8188126ef..95926854dec 100644
--- a/bootstrap/bukkit/pom.xml
+++ b/bootstrap/bukkit/pom.xml
@@ -26,7 +26,7 @@
us.myles
viaversion
- 3.0.1
+ 3.0.0-SNAPSHOT
provided
diff --git a/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitPlugin.java b/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitPlugin.java
index 1507f9ee45e..3a13777b47c 100644
--- a/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitPlugin.java
+++ b/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitPlugin.java
@@ -110,8 +110,8 @@ public void onEnable() {
if (Bukkit.getPluginManager().getPlugin("ViaVersion") != null) {
// TODO: Update when ViaVersion updates
// API changes between 2.2.3 and 3.0.0-SNAPSHOT require this check
- if (Via.getAPI().getVersion().contains("2.2.3") && isLegacy) {
- geyserLogger.info("ViaVersion detected but not the newest version of ViaVersion. Please update your ViaVersion plugin for compatibility with Geyser.");
+ if (!Via.getAPI().getVersion().equals("3.0.0-SNAPSHOT") && isLegacy) {
+ geyserLogger.info("ViaVersion detected but not ViaVersion-ABSTRACTION. Please update your ViaVersion plugin for compatibility with Geyser.");
} else {
isViaVersion = true;
}
diff --git a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java
index 3d55845dc43..d201656ad25 100644
--- a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java
+++ b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java
@@ -110,7 +110,6 @@ private GeyserConnector(PlatformType platformType, GeyserBootstrap bootstrap) {
logger.info("Loading " + NAME + " version " + VERSION);
logger.info("");
logger.info("******************************************");
- logger.warning("This build is for connecting to Java 1.15.2 servers and from Bedrock 1.14.60 clients. Please join our Discord (https://discord.geysermc.org) for up-to-date information about where to download 1.16.");
this.generalThreadPool = Executors.newScheduledThreadPool(config.getGeneralThreadPool());
From 9359f401f86fa591af8ac6d968eb6fa70312c983 Mon Sep 17 00:00:00 2001
From: DoctorMacc
Date: Mon, 6 Jul 2020 21:54:33 -0400
Subject: [PATCH 20/35] Don't use 1.16 branch of mappings
---
.gitmodules | 1 -
1 file changed, 1 deletion(-)
diff --git a/.gitmodules b/.gitmodules
index 35887822e5c..0c014712bd7 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,7 +1,6 @@
[submodule "connector/src/main/resources/mappings"]
path = connector/src/main/resources/mappings
url = https://github.com/GeyserMC/mappings.git
- branch = feature/1.16
[submodule "connector/src/main/resources/languages"]
path = connector/src/main/resources/languages
url = https://github.com/GeyserMC/languages.git
From 50176e10a87ea4a566e373389f88a6d770cff6a2 Mon Sep 17 00:00:00 2001
From: AJ Ferguson
Date: Mon, 6 Jul 2020 23:44:39 -0800
Subject: [PATCH 21/35] Fix inabilty to place items into brewing stand
---
.../geysermc/connector/GeyserConnector.java | 2 +
.../translators/item/PotionMixRegistry.java | 113 ++++++++++++++++++
.../java/JavaDeclareRecipesTranslator.java | 8 +-
3 files changed, 117 insertions(+), 6 deletions(-)
create mode 100644 connector/src/main/java/org/geysermc/connector/network/translators/item/PotionMixRegistry.java
diff --git a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java
index 675c2b9a290..601421303f1 100644
--- a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java
+++ b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java
@@ -47,6 +47,7 @@
import org.geysermc.connector.network.translators.effect.EffectRegistry;
import org.geysermc.connector.network.translators.item.ItemRegistry;
import org.geysermc.connector.network.translators.item.ItemTranslator;
+import org.geysermc.connector.network.translators.item.PotionMixRegistry;
import org.geysermc.connector.network.translators.sound.SoundHandlerRegistry;
import org.geysermc.connector.network.translators.sound.SoundRegistry;
import org.geysermc.connector.network.translators.world.WorldManager;
@@ -127,6 +128,7 @@ private GeyserConnector(PlatformType platformType, GeyserBootstrap bootstrap) {
ItemRegistry.init();
ItemTranslator.init();
LocaleUtils.init();
+ PotionMixRegistry.init();
SoundRegistry.init();
SoundHandlerRegistry.init();
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/item/PotionMixRegistry.java b/connector/src/main/java/org/geysermc/connector/network/translators/item/PotionMixRegistry.java
new file mode 100644
index 00000000000..02e01d83c9a
--- /dev/null
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/item/PotionMixRegistry.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * @author GeyserMC
+ * @link https://github.com/GeyserMC/Geyser
+ *
+ */
+
+package org.geysermc.connector.network.translators.item;
+
+import com.nukkitx.protocol.bedrock.data.inventory.PotionMixData;
+
+import java.util.*;
+
+/**
+ * Generates a {@link Collection} of {@link PotionMixData} that enables the
+ * Bedrock client to place brewing items into the brewing stand.
+ * (Does not contain actual potion mixes.)
+ *
+ * Designed to replicate Java Edition behavior.
+ * (Ex: Bedrock cannot normally place glass bottles or fully upgraded
+ * potions into the brewing stand, but Java can.)
+ */
+public class PotionMixRegistry {
+ public static final Collection POTION_MIXES;
+
+ private PotionMixRegistry() {
+ }
+
+ public static void init() {
+ // no-op
+ }
+
+ static {
+ List ingredients = new ArrayList<>();
+ ingredients.add(getNonNull("minecraft:nether_wart"));
+ ingredients.add(getNonNull("minecraft:redstone"));
+ ingredients.add(getNonNull("minecraft:glowstone_dust"));
+ ingredients.add(getNonNull("minecraft:fermented_spider_eye"));
+ ingredients.add(getNonNull("minecraft:gunpowder"));
+ ingredients.add(getNonNull("minecraft:dragon_breath"));
+ ingredients.add(getNonNull("minecraft:sugar"));
+ ingredients.add(getNonNull("minecraft:rabbit_foot"));
+ ingredients.add(getNonNull("minecraft:glistering_melon_slice"));
+ ingredients.add(getNonNull("minecraft:spider_eye"));
+ ingredients.add(getNonNull("minecraft:pufferfish"));
+ ingredients.add(getNonNull("minecraft:magma_cream"));
+ ingredients.add(getNonNull("minecraft:golden_carrot"));
+ ingredients.add(getNonNull("minecraft:blaze_powder"));
+ ingredients.add(getNonNull("minecraft:ghast_tear"));
+ ingredients.add(getNonNull("minecraft:turtle_helmet"));
+ ingredients.add(getNonNull("minecraft:phantom_membrane"));
+
+ List inputs = new ArrayList<>();
+ inputs.add(getNonNull("minecraft:potion"));
+ inputs.add(getNonNull("minecraft:splash_potion"));
+ inputs.add(getNonNull("minecraft:lingering_potion"));
+
+ ItemEntry glassBottle = getNonNull("minecraft:glass_bottle");
+
+ Set potionMixes = new HashSet<>();
+
+ // Add all types of potions as inputs
+ ItemEntry fillerIngredient = ingredients.get(0);
+ for (ItemEntry input : inputs) {
+ for (Potion potion : Potion.values()) {
+ potionMixes.add(new PotionMixData(
+ input.getBedrockId(), potion.getBedrockId(),
+ fillerIngredient.getBedrockId(), fillerIngredient.getBedrockData(),
+ glassBottle.getBedrockId(), glassBottle.getBedrockData())
+ );
+ }
+ }
+
+ // Add all brewing ingredients
+ // Also adds glass bottle as input
+ for (ItemEntry ingredient : ingredients) {
+ potionMixes.add(new PotionMixData(
+ glassBottle.getBedrockId(), glassBottle.getBedrockData(),
+ ingredient.getBedrockId(), ingredient.getBedrockData(),
+ glassBottle.getBedrockId(), glassBottle.getBedrockData())
+ );
+ }
+
+ POTION_MIXES = potionMixes;
+ }
+
+ private static ItemEntry getNonNull(String javaIdentifier) {
+ ItemEntry itemEntry = ItemRegistry.getItemEntry(javaIdentifier);
+ if (itemEntry == null)
+ throw new NullPointerException("No item entry exists for java identifier: " + javaIdentifier);
+
+ return itemEntry;
+ }
+}
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaDeclareRecipesTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaDeclareRecipesTranslator.java
index 08022640f2c..75ccc0a5a0a 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaDeclareRecipesTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaDeclareRecipesTranslator.java
@@ -33,7 +33,6 @@
import com.nukkitx.nbt.NbtMap;
import com.nukkitx.protocol.bedrock.data.inventory.CraftingData;
import com.nukkitx.protocol.bedrock.data.inventory.ItemData;
-import com.nukkitx.protocol.bedrock.data.inventory.PotionMixData;
import com.nukkitx.protocol.bedrock.packet.CraftingDataPacket;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import it.unimi.dsi.fastutil.ints.IntSet;
@@ -45,16 +44,13 @@
import org.geysermc.connector.network.translators.item.ItemEntry;
import org.geysermc.connector.network.translators.item.ItemRegistry;
import org.geysermc.connector.network.translators.item.ItemTranslator;
+import org.geysermc.connector.network.translators.item.PotionMixRegistry;
import java.util.*;
import java.util.stream.Collectors;
@Translator(packet = ServerDeclareRecipesPacket.class)
public class JavaDeclareRecipesTranslator extends PacketTranslator {
- private static final Collection POTION_MIXES =
- Arrays.stream(new int[]{372, 331, 348, 376, 289, 437, 353, 414, 382, 375, 462, 378, 396, 377, 370, 469, 470})
- .mapToObj(ingredient -> new PotionMixData(0, ingredient, 0, 0, 0, 0)) //TODO: Confirm this is correct behavior.
- .collect(Collectors.toList());
@Override
public void translate(ServerDeclareRecipesPacket packet, GeyserSession session) {
@@ -89,7 +85,7 @@ public void translate(ServerDeclareRecipesPacket packet, GeyserSession session)
}
}
}
- craftingDataPacket.getPotionMixData().addAll(POTION_MIXES);
+ craftingDataPacket.getPotionMixData().addAll(PotionMixRegistry.POTION_MIXES);
session.sendUpstreamPacket(craftingDataPacket);
}
From f9760b721c62749141e8bf07b58a393480661f0b Mon Sep 17 00:00:00 2001
From: DoctorMacc
Date: Tue, 7 Jul 2020 08:30:11 -0400
Subject: [PATCH 22/35] Don't process the display tag if it's empty
---
.../connector/network/translators/item/ItemTranslator.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemTranslator.java
index fde799fe497..e28e8b0c8c7 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemTranslator.java
@@ -157,7 +157,7 @@ public static ItemData translateToBedrock(GeyserSession session, ItemStack stack
NbtMap tag = itemData.getTag();
if (tag != null) {
NbtMap display = tag.getCompound("display");
- if (display != null) {
+ if (display != null && !display.isEmpty()) {
String name = display.getString("Name");
// If its not a message convert it
From 8807d5d9c6b96180ffc14517b07c9933318aac01 Mon Sep 17 00:00:00 2001
From: rtm516
Date: Tue, 7 Jul 2020 14:30:33 +0100
Subject: [PATCH 23/35] Fix banner block patterns
---
.../world/block/entity/BannerBlockEntityTranslator.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/BannerBlockEntityTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/BannerBlockEntityTranslator.java
index e2a555090d9..9e86cb4cfb6 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/BannerBlockEntityTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/BannerBlockEntityTranslator.java
@@ -55,7 +55,7 @@ public Map translateTag(CompoundTag tag, int blockState) {
if (tag.contains("Patterns")) {
ListTag patterns = tag.get("Patterns");
- tags.put("", BannerTranslator.convertBannerPattern(patterns));
+ tags.put("Patterns", BannerTranslator.convertBannerPattern(patterns));
}
if (tag.contains("CustomName")) {
From 75f2891ec0fe093ff88891434e7a24df58591ea2 Mon Sep 17 00:00:00 2001
From: rtm516
Date: Tue, 7 Jul 2020 14:47:56 +0100
Subject: [PATCH 24/35] Fix map_uuid nbt type
---
.../translators/item/translators/nbt/MapItemTranslator.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/item/translators/nbt/MapItemTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/item/translators/nbt/MapItemTranslator.java
index 51029b83dcb..4a36880c900 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/item/translators/nbt/MapItemTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/item/translators/nbt/MapItemTranslator.java
@@ -28,10 +28,10 @@
import com.github.steveice10.opennbt.tag.builtin.ByteTag;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.IntTag;
-import com.github.steveice10.opennbt.tag.builtin.StringTag;
+import com.github.steveice10.opennbt.tag.builtin.LongTag;
import org.geysermc.connector.network.translators.ItemRemapper;
-import org.geysermc.connector.network.translators.item.NbtItemStackTranslator;
import org.geysermc.connector.network.translators.item.ItemEntry;
+import org.geysermc.connector.network.translators.item.NbtItemStackTranslator;
@ItemRemapper
public class MapItemTranslator extends NbtItemStackTranslator {
@@ -41,7 +41,7 @@ public void translateToBedrock(CompoundTag itemTag, ItemEntry itemEntry) {
IntTag mapId = itemTag.get("map");
if (mapId != null) {
- itemTag.put(new StringTag("map_uuid", mapId.getValue().toString()));
+ itemTag.put(new LongTag("map_uuid", mapId.getValue()));
itemTag.put(new IntTag("map_name_index", mapId.getValue()));
itemTag.put(new ByteTag("map_display_players", (byte) 1));
itemTag.remove("map");
From a16deb269a1f4553d9277ee998f71be67b89f74a Mon Sep 17 00:00:00 2001
From: rtm516
Date: Tue, 7 Jul 2020 15:09:24 +0100
Subject: [PATCH 25/35] Fix exact color matches not being formatted correctly
(Fixes #912)
---
.../main/java/org/geysermc/connector/utils/MessageUtils.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/connector/src/main/java/org/geysermc/connector/utils/MessageUtils.java b/connector/src/main/java/org/geysermc/connector/utils/MessageUtils.java
index bf19622466a..44536ccf602 100644
--- a/connector/src/main/java/org/geysermc/connector/utils/MessageUtils.java
+++ b/connector/src/main/java/org/geysermc/connector/utils/MessageUtils.java
@@ -391,7 +391,8 @@ private static String getClosestColor(String color) {
for (Map.Entry testColor : COLORS.entrySet()) {
if (testColor.getValue() == rgb) {
- return testColor.getKey();
+ closest = testColor.getKey();
+ break;
}
int testR = (testColor.getValue() >> 16) & 0xFF;
From c2be7a181da8c72bbb143aed318b185b62b77dda Mon Sep 17 00:00:00 2001
From: rtm516
Date: Tue, 7 Jul 2020 16:11:52 +0100
Subject: [PATCH 26/35] Fix Piglin bartering animation (Fixes #863)
---
.../connector/entity/living/monster/PiglinEntity.java | 10 ++++++++++
.../network/translators/item/ItemRegistry.java | 2 ++
2 files changed, 12 insertions(+)
diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/monster/PiglinEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/monster/PiglinEntity.java
index 78a420b8c40..ae9319efa9f 100644
--- a/connector/src/main/java/org/geysermc/connector/entity/living/monster/PiglinEntity.java
+++ b/connector/src/main/java/org/geysermc/connector/entity/living/monster/PiglinEntity.java
@@ -31,6 +31,7 @@
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
import org.geysermc.connector.entity.type.EntityType;
import org.geysermc.connector.network.session.GeyserSession;
+import org.geysermc.connector.network.translators.item.ItemRegistry;
public class PiglinEntity extends MonsterEntity {
@@ -56,4 +57,13 @@ public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession s
super.updateBedrockMetadata(entityMetadata, session);
}
+
+ @Override
+ public void updateEquipment(GeyserSession session) {
+ // Check if the Piglin is holding Gold and set the ADMIRING flag accordingly
+ metadata.getFlags().setFlag(EntityFlag.ADMIRING, offHand.getId() == ItemRegistry.GOLD);
+ super.updateBedrockMetadata(session);
+
+ super.updateEquipment(session);
+ }
}
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemRegistry.java b/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemRegistry.java
index 23c566d7c9b..bf3769ed993 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemRegistry.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemRegistry.java
@@ -60,6 +60,8 @@ public class ItemRegistry {
public static final int SHIELD = 829;
// Boat ID, used in BedrockInventoryTransactionTranslator.java
public static final int BOAT = 333;
+ // Gold ID, used in PiglinEntity.java
+ public static final int GOLD = 266;
public static int BARRIER_INDEX = 0;
From 5f6566ad0efb147c384f398b76934bb1da251f26 Mon Sep 17 00:00:00 2001
From: rtm516
Date: Tue, 7 Jul 2020 16:23:21 +0100
Subject: [PATCH 27/35] Move to dynamic item ID mapping in ItemRegistry
---
.../translators/item/ItemRegistry.java | 20 ++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemRegistry.java b/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemRegistry.java
index bf3769ed993..b9ce5c6c111 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemRegistry.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemRegistry.java
@@ -57,11 +57,11 @@ public class ItemRegistry {
public static final Int2ObjectMap ITEM_ENTRIES = new Int2ObjectOpenHashMap<>();
// Shield ID, used in Entity.java
- public static final int SHIELD = 829;
+ public static int SHIELD = 0;
// Boat ID, used in BedrockInventoryTransactionTranslator.java
- public static final int BOAT = 333;
+ public static int BOAT = 0;
// Gold ID, used in PiglinEntity.java
- public static final int GOLD = 266;
+ public static int GOLD = 0;
public static int BARRIER_INDEX = 0;
@@ -85,6 +85,20 @@ public static void init() {
for (JsonNode entry : itemEntries) {
ITEMS.add(new StartGamePacket.ItemEntry(entry.get("name").textValue(), (short) entry.get("id").intValue()));
+
+ switch (entry.get("name").textValue()) {
+ case "minecraft:shield":
+ SHIELD = entry.get("id").intValue();
+ break;
+ case "minecraft:boat":
+ BOAT = entry.get("id").intValue();
+ break;
+ case "minecraft:gold_ingot":
+ GOLD = entry.get("id").intValue();
+ break;
+ default:
+ break;
+ }
}
stream = FileUtils.getResource("mappings/items.json");
From 0cea703b465daba3714011fc1fa7b86435581601 Mon Sep 17 00:00:00 2001
From: DoctorMacc
Date: Tue, 7 Jul 2020 16:40:19 -0400
Subject: [PATCH 28/35] Save ItemEntry classes for items
---
.../org/geysermc/connector/entity/Entity.java | 6 +--
.../entity/living/monster/PiglinEntity.java | 2 +-
.../bedrock/BedrockInteractTranslator.java | 2 +-
...BedrockInventoryTransactionTranslator.java | 4 +-
.../network/translators/item/ItemEntry.java | 2 +
.../translators/item/ItemRegistry.java | 37 +++++++++----------
6 files changed, 27 insertions(+), 26 deletions(-)
diff --git a/connector/src/main/java/org/geysermc/connector/entity/Entity.java b/connector/src/main/java/org/geysermc/connector/entity/Entity.java
index ffe13a50d72..1618d6afa36 100644
--- a/connector/src/main/java/org/geysermc/connector/entity/Entity.java
+++ b/connector/src/main/java/org/geysermc/connector/entity/Entity.java
@@ -284,11 +284,11 @@ public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession s
// Shield code
if (session.getPlayerEntity().getEntityId() == entityId && metadata.getFlags().getFlag(EntityFlag.SNEAKING)) {
- if ((session.getInventory().getItemInHand() != null && session.getInventory().getItemInHand().getId() == ItemRegistry.SHIELD) ||
- (session.getInventoryCache().getPlayerInventory().getItem(45) != null && session.getInventoryCache().getPlayerInventory().getItem(45).getId() == ItemRegistry.SHIELD)) {
+ if ((session.getInventory().getItemInHand() != null && session.getInventory().getItemInHand().getId() == ItemRegistry.SHIELD.getJavaId()) ||
+ (session.getInventoryCache().getPlayerInventory().getItem(45) != null && session.getInventoryCache().getPlayerInventory().getItem(45).getId() == ItemRegistry.SHIELD.getJavaId())) {
ClientPlayerUseItemPacket useItemPacket;
metadata.getFlags().setFlag(EntityFlag.BLOCKING, true);
- if (session.getInventory().getItemInHand() != null && session.getInventory().getItemInHand().getId() == ItemRegistry.SHIELD) {
+ if (session.getInventory().getItemInHand() != null && session.getInventory().getItemInHand().getId() == ItemRegistry.SHIELD.getJavaId()) {
useItemPacket = new ClientPlayerUseItemPacket(Hand.MAIN_HAND);
}
// Else we just assume it's the offhand, to simplify logic and to assure the packet gets sent
diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/monster/PiglinEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/monster/PiglinEntity.java
index ae9319efa9f..83027e30e42 100644
--- a/connector/src/main/java/org/geysermc/connector/entity/living/monster/PiglinEntity.java
+++ b/connector/src/main/java/org/geysermc/connector/entity/living/monster/PiglinEntity.java
@@ -61,7 +61,7 @@ public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession s
@Override
public void updateEquipment(GeyserSession session) {
// Check if the Piglin is holding Gold and set the ADMIRING flag accordingly
- metadata.getFlags().setFlag(EntityFlag.ADMIRING, offHand.getId() == ItemRegistry.GOLD);
+ metadata.getFlags().setFlag(EntityFlag.ADMIRING, offHand.getId() == ItemRegistry.GOLD.getBedrockId());
super.updateBedrockMetadata(session);
super.updateEquipment(session);
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockInteractTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockInteractTranslator.java
index 167073273a3..7d03f98328e 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockInteractTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockInteractTranslator.java
@@ -60,7 +60,7 @@ public void translate(InteractPacket packet, GeyserSession session) {
switch (packet.getAction()) {
case INTERACT:
- if (session.getInventory().getItem(session.getInventory().getHeldItemSlot() + 36).getId() == ItemRegistry.SHIELD) {
+ if (session.getInventory().getItem(session.getInventory().getHeldItemSlot() + 36).getId() == ItemRegistry.SHIELD.getJavaId()) {
break;
}
ClientPlayerInteractEntityPacket interactPacket = new ClientPlayerInteractEntityPacket((int) entity.getEntityId(),
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockInventoryTransactionTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockInventoryTransactionTranslator.java
index 25e1c54e2a5..d4168709fd9 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockInventoryTransactionTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockInventoryTransactionTranslator.java
@@ -99,7 +99,7 @@ public void translate(InventoryTransactionPacket packet, GeyserSession session)
session.sendDownstreamPacket(blockPacket);
// Otherwise boats will not be able to be placed in survival
- if (packet.getItemInHand() != null && packet.getItemInHand().getId() == ItemRegistry.BOAT) {
+ if (packet.getItemInHand() != null && packet.getItemInHand().getId() == ItemRegistry.BOAT.getBedrockId()) {
ClientPlayerUseItemPacket itemPacket = new ClientPlayerUseItemPacket(Hand.MAIN_HAND);
session.sendDownstreamPacket(itemPacket);
}
@@ -136,7 +136,7 @@ public void translate(InventoryTransactionPacket packet, GeyserSession session)
break;
case 1:
ItemStack shieldSlot = session.getInventory().getItem(session.getInventory().getHeldItemSlot() + 36);
- if (shieldSlot != null && shieldSlot.getId() == ItemRegistry.SHIELD) {
+ if (shieldSlot != null && shieldSlot.getId() == ItemRegistry.SHIELD.getJavaId()) {
break;
} // Handled in Entity.java
ClientPlayerUseItemPacket useItemPacket = new ClientPlayerUseItemPacket(Hand.MAIN_HAND);
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemEntry.java b/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemEntry.java
index 9c072ad150e..19f83cd963b 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemEntry.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemEntry.java
@@ -27,9 +27,11 @@
import lombok.AllArgsConstructor;
import lombok.Getter;
+import lombok.ToString;
@Getter
@AllArgsConstructor
+@ToString
public class ItemEntry {
public static ItemEntry AIR = new ItemEntry("minecraft:air", 0, 0, 0, false);
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemRegistry.java b/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemRegistry.java
index b9ce5c6c111..8224a52d239 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemRegistry.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemRegistry.java
@@ -57,11 +57,11 @@ public class ItemRegistry {
public static final Int2ObjectMap ITEM_ENTRIES = new Int2ObjectOpenHashMap<>();
// Shield ID, used in Entity.java
- public static int SHIELD = 0;
+ public static ItemEntry SHIELD;
// Boat ID, used in BedrockInventoryTransactionTranslator.java
- public static int BOAT = 0;
+ public static ItemEntry BOAT;
// Gold ID, used in PiglinEntity.java
- public static int GOLD = 0;
+ public static ItemEntry GOLD;
public static int BARRIER_INDEX = 0;
@@ -85,20 +85,6 @@ public static void init() {
for (JsonNode entry : itemEntries) {
ITEMS.add(new StartGamePacket.ItemEntry(entry.get("name").textValue(), (short) entry.get("id").intValue()));
-
- switch (entry.get("name").textValue()) {
- case "minecraft:shield":
- SHIELD = entry.get("id").intValue();
- break;
- case "minecraft:boat":
- BOAT = entry.get("id").intValue();
- break;
- case "minecraft:gold_ingot":
- GOLD = entry.get("id").intValue();
- break;
- default:
- break;
- }
}
stream = FileUtils.getResource("mappings/items.json");
@@ -139,8 +125,21 @@ public static void init() {
entry.getValue().get("bedrock_data").intValue(),
entry.getValue().get("is_block") != null && entry.getValue().get("is_block").booleanValue()));
}
- if (entry.getKey().equals("minecraft:barrier")) {
- BARRIER_INDEX = itemIndex;
+ switch (entry.getKey()) {
+ case "minecraft:barrier":
+ BARRIER_INDEX = itemIndex;
+ break;
+ case "minecraft:oak_boat":
+ BOAT = ITEM_ENTRIES.get(itemIndex);
+ break;
+ case "minecraft:gold_ingot":
+ GOLD = ITEM_ENTRIES.get(itemIndex);
+ break;
+ case "minecraft:shield":
+ SHIELD = ITEM_ENTRIES.get(itemIndex);
+ break;
+ default:
+ break;
}
itemIndex++;
From 40032987faf3d87785f31b232f4e0e797328613b Mon Sep 17 00:00:00 2001
From: DoctorMacc
Date: Tue, 7 Jul 2020 19:27:12 -0400
Subject: [PATCH 29/35] Add magma cube jumping visual
---
.../entity/living/MagmaCubeEntity.java | 65 +++++++++++++++++++
.../connector/entity/type/EntityType.java | 2 +-
2 files changed, 66 insertions(+), 1 deletion(-)
create mode 100644 connector/src/main/java/org/geysermc/connector/entity/living/MagmaCubeEntity.java
diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/MagmaCubeEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/MagmaCubeEntity.java
new file mode 100644
index 00000000000..320f08987e3
--- /dev/null
+++ b/connector/src/main/java/org/geysermc/connector/entity/living/MagmaCubeEntity.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * @author GeyserMC
+ * @link https://github.com/GeyserMC/Geyser
+ *
+ */
+
+package org.geysermc.connector.entity.living;
+
+import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
+import com.nukkitx.math.vector.Vector3f;
+import com.nukkitx.protocol.bedrock.data.entity.EntityData;
+import org.geysermc.connector.entity.type.EntityType;
+import org.geysermc.connector.network.session.GeyserSession;
+
+public class MagmaCubeEntity extends SlimeEntity {
+
+ public MagmaCubeEntity(long entityId, long geyserId, EntityType entityType, Vector3f position, Vector3f motion, Vector3f rotation) {
+ super(entityId, geyserId, entityType, position, motion, rotation);
+ }
+
+ @Override
+ public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) {
+ super.updateBedrockMetadata(entityMetadata, session);
+ }
+
+ @Override
+ public void moveRelative(GeyserSession session, double relX, double relY, double relZ, Vector3f rotation, boolean isOnGround) {
+ updateJump(session, isOnGround);
+ super.moveRelative(session, relX, relY, relZ, rotation, isOnGround);
+ }
+
+ @Override
+ public void moveAbsolute(GeyserSession session, Vector3f position, Vector3f rotation, boolean isOnGround, boolean teleported) {
+ updateJump(session, isOnGround);
+ super.moveAbsolute(session, position, rotation, isOnGround, teleported);
+ }
+
+ public void updateJump(GeyserSession session, boolean newOnGround) {
+ if (newOnGround != onGround) {
+ // Add the jumping effect to the magma cube
+ metadata.put(EntityData.CLIENT_EVENT, (byte) (newOnGround ? 1 : 2));
+ updateBedrockMetadata(session);
+ }
+ }
+}
diff --git a/connector/src/main/java/org/geysermc/connector/entity/type/EntityType.java b/connector/src/main/java/org/geysermc/connector/entity/type/EntityType.java
index 6bc1a1b0bdc..e73fd7aa534 100644
--- a/connector/src/main/java/org/geysermc/connector/entity/type/EntityType.java
+++ b/connector/src/main/java/org/geysermc/connector/entity/type/EntityType.java
@@ -74,7 +74,7 @@ public enum EntityType {
SILVERFISH(MonsterEntity.class, 39, 0.3f, 0.4f),
CAVE_SPIDER(MonsterEntity.class, 40, 0.5f, 0.7f),
GHAST(FlyingEntity.class, 41, 4.0f),
- MAGMA_CUBE(SlimeEntity.class, 42, 0.51f),
+ MAGMA_CUBE(MagmaCubeEntity.class, 42, 0.51f),
BLAZE(BlazeEntity.class, 43, 1.8f, 0.6f),
ZOMBIE_VILLAGER(ZombieEntity.class, 44, 1.8f, 0.6f, 0.6f, 1.62f),
WITCH(RaidParticipantEntity.class, 45, 1.8f, 0.6f, 0.6f, 1.62f),
From 21ea1f2408b674793959be834f9b98115afc207e Mon Sep 17 00:00:00 2001
From: DoctorMacc
Date: Tue, 7 Jul 2020 20:14:50 -0400
Subject: [PATCH 30/35] Update MCProtocolLib to fix #836
---
connector/pom.xml | 2 +-
.../translators/java/JavaJoinGameTranslator.java | 16 +++++++---------
2 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/connector/pom.xml b/connector/pom.xml
index 3fdd5f37a96..9a202d6f5d2 100644
--- a/connector/pom.xml
+++ b/connector/pom.xml
@@ -105,7 +105,7 @@
com.github.steveice10
mcprotocollib
- 7545884a2d
+ ed6e845095
compile
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaJoinGameTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaJoinGameTranslator.java
index 01f6b0b92e3..ca65c2b98cd 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaJoinGameTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaJoinGameTranslator.java
@@ -25,23 +25,21 @@
package org.geysermc.connector.network.translators.java;
-import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
+import com.github.steveice10.mc.protocol.data.game.entity.player.HandPreference;
import com.github.steveice10.mc.protocol.data.game.setting.ChatVisibility;
import com.github.steveice10.mc.protocol.data.game.setting.SkinPart;
import com.github.steveice10.mc.protocol.packet.ingame.client.ClientSettingsPacket;
-import org.geysermc.connector.entity.PlayerEntity;
-import org.geysermc.connector.network.session.GeyserSession;
-import org.geysermc.connector.network.session.cache.ScoreboardCache;
-import org.geysermc.connector.network.translators.PacketTranslator;
-import org.geysermc.connector.network.translators.Translator;
-import org.geysermc.connector.utils.DimensionUtils;
-
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerJoinGamePacket;
import com.nukkitx.protocol.bedrock.data.PlayerPermission;
import com.nukkitx.protocol.bedrock.packet.AdventureSettingsPacket;
import com.nukkitx.protocol.bedrock.packet.PlayStatusPacket;
import com.nukkitx.protocol.bedrock.packet.SetEntityDataPacket;
import com.nukkitx.protocol.bedrock.packet.SetPlayerGameTypePacket;
+import org.geysermc.connector.entity.PlayerEntity;
+import org.geysermc.connector.network.session.GeyserSession;
+import org.geysermc.connector.network.translators.PacketTranslator;
+import org.geysermc.connector.network.translators.Translator;
+import org.geysermc.connector.utils.DimensionUtils;
import java.util.Arrays;
import java.util.List;
@@ -87,7 +85,7 @@ public void translate(ServerJoinGamePacket packet, GeyserSession session) {
// We need to send our skin parts to the server otherwise java sees us with no hat, jacket etc
String locale = session.getClientData().getLanguageCode();
List skinParts = Arrays.asList(SkinPart.values());
- ClientSettingsPacket clientSettingsPacket = new ClientSettingsPacket(locale, (byte) session.getRenderDistance(), ChatVisibility.FULL, true, skinParts, Hand.MAIN_HAND);
+ ClientSettingsPacket clientSettingsPacket = new ClientSettingsPacket(locale, (byte) session.getRenderDistance(), ChatVisibility.FULL, true, skinParts, HandPreference.RIGHT_HAND);
session.sendDownstreamPacket(clientSettingsPacket);
if (!packet.getDimension().equals(entity.getDimension())) {
From 915ad2d0573abfbf8a684d6b179d142ea3082c23 Mon Sep 17 00:00:00 2001
From: DoctorMacc
Date: Wed, 8 Jul 2020 11:31:09 -0400
Subject: [PATCH 31/35] Update languages submodule
---
connector/src/main/resources/languages | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/connector/src/main/resources/languages b/connector/src/main/resources/languages
index 37a10837d1c..3ab423197a4 160000
--- a/connector/src/main/resources/languages
+++ b/connector/src/main/resources/languages
@@ -1 +1 @@
-Subproject commit 37a10837d1cf34b4c28f4879b62fcef200d43e60
+Subproject commit 3ab423197a4a308665ad1dcb28cab522aabc0815
From fe254380dc2c068c91e66d00348d0bba1502036f Mon Sep 17 00:00:00 2001
From: DoctorMacc
Date: Wed, 8 Jul 2020 12:36:26 -0400
Subject: [PATCH 32/35] Clean up some TODOs
---
.../main/java/org/geysermc/connector/entity/Entity.java | 4 ++--
.../org/geysermc/connector/entity/FishingHookEntity.java | 2 --
.../org/geysermc/connector/entity/PaintingEntity.java | 2 +-
.../connector/entity/living/monster/EndermanEntity.java | 2 +-
.../org/geysermc/connector/entity/type/EntityType.java | 8 ++++----
.../java/org/geysermc/connector/utils/InventoryUtils.java | 2 +-
.../java/org/geysermc/connector/utils/MessageUtils.java | 3 +--
7 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/connector/src/main/java/org/geysermc/connector/entity/Entity.java b/connector/src/main/java/org/geysermc/connector/entity/Entity.java
index 1618d6afa36..78d0cd97727 100644
--- a/connector/src/main/java/org/geysermc/connector/entity/Entity.java
+++ b/connector/src/main/java/org/geysermc/connector/entity/Entity.java
@@ -299,7 +299,7 @@ public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession s
}
} else if (session.getPlayerEntity().getEntityId() == entityId && !metadata.getFlags().getFlag(EntityFlag.SNEAKING) && metadata.getFlags().getFlag(EntityFlag.BLOCKING)) {
metadata.getFlags().setFlag(EntityFlag.BLOCKING, false);
- metadata.getFlags().setFlag(EntityFlag.IS_AVOIDING_BLOCK, true); //TODO: CHECK
+ metadata.getFlags().setFlag(EntityFlag.IS_AVOIDING_BLOCK, true);
ClientPlayerActionPacket releaseItemPacket = new ClientPlayerActionPacket(PlayerAction.RELEASE_USE_ITEM, new Position(0, 0, 0), BlockFace.DOWN);
session.sendDownstreamPacket(releaseItemPacket);
}
@@ -337,7 +337,7 @@ public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession s
if (entityMetadata.getValue().equals(Pose.SLEEPING)) {
metadata.getFlags().setFlag(EntityFlag.SLEEPING, true);
// Has to be a byte or it does not work
- metadata.put(EntityData.PLAYER_FLAGS, (byte) 2); //TODO: CHECK
+ metadata.put(EntityData.PLAYER_FLAGS, (byte) 2);
if (entityId == session.getPlayerEntity().getEntityId()) {
Vector3i lastInteractionPos = session.getLastInteractionPosition();
metadata.put(EntityData.BED_POSITION, lastInteractionPos);
diff --git a/connector/src/main/java/org/geysermc/connector/entity/FishingHookEntity.java b/connector/src/main/java/org/geysermc/connector/entity/FishingHookEntity.java
index 4d0eb202f24..2949b57359d 100644
--- a/connector/src/main/java/org/geysermc/connector/entity/FishingHookEntity.java
+++ b/connector/src/main/java/org/geysermc/connector/entity/FishingHookEntity.java
@@ -63,8 +63,6 @@ public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession s
}
}
- //TODO Is ID 8 needed?
-
super.updateBedrockMetadata(entityMetadata, session);
}
}
diff --git a/connector/src/main/java/org/geysermc/connector/entity/PaintingEntity.java b/connector/src/main/java/org/geysermc/connector/entity/PaintingEntity.java
index d509b41f69a..8db7554b2b9 100644
--- a/connector/src/main/java/org/geysermc/connector/entity/PaintingEntity.java
+++ b/connector/src/main/java/org/geysermc/connector/entity/PaintingEntity.java
@@ -52,7 +52,7 @@ public void spawnEntity(GeyserSession session) {
AddPaintingPacket addPaintingPacket = new AddPaintingPacket();
addPaintingPacket.setUniqueEntityId(geyserId);
addPaintingPacket.setRuntimeEntityId(geyserId);
- addPaintingPacket.setMotive(paintingName.getBedrockName()); //TODO: This is what it's called now?
+ addPaintingPacket.setMotive(paintingName.getBedrockName());
addPaintingPacket.setPosition(fixOffset(true));
addPaintingPacket.setDirection(direction);
session.sendUpstreamPacket(addPaintingPacket);
diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/monster/EndermanEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/monster/EndermanEntity.java
index 914b208593e..dfca080419a 100644
--- a/connector/src/main/java/org/geysermc/connector/entity/living/monster/EndermanEntity.java
+++ b/connector/src/main/java/org/geysermc/connector/entity/living/monster/EndermanEntity.java
@@ -43,7 +43,7 @@ public EndermanEntity(long entityId, long geyserId, EntityType entityType, Vecto
public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) {
// Held block
if (entityMetadata.getId() == 15) {
- metadata.put(EntityData.DISPLAY_ITEM, BlockTranslator.getBedrockBlockId((int) entityMetadata.getValue())); //TODO: Check
+ metadata.put(EntityData.CARRIED_BLOCK, BlockTranslator.getBedrockBlockId((int) entityMetadata.getValue()));
}
// 'Angry' - mouth open
if (entityMetadata.getId() == 16) {
diff --git a/connector/src/main/java/org/geysermc/connector/entity/type/EntityType.java b/connector/src/main/java/org/geysermc/connector/entity/type/EntityType.java
index e73fd7aa534..e32de056885 100644
--- a/connector/src/main/java/org/geysermc/connector/entity/type/EntityType.java
+++ b/connector/src/main/java/org/geysermc/connector/entity/type/EntityType.java
@@ -151,10 +151,10 @@ public enum EntityType {
PANDA(PandaEntity.class, 113, 1.25f, 1.125f, 1.825f),
FOX(FoxEntity.class, 121, 0.5f, 1.25f),
BEE(BeeEntity.class, 122, 0.6f, 0.6f),
- STRIDER(StriderEntity.class, 125, 1.7f, 0.9f, 0f, 0f, "minecraft:strider"), //TODO - update entity metadata
- HOGLIN(AnimalEntity.class, 124, 1.4f, 1.3965f, 1.3965f, 0f, "minecraft:hoglin"), //TODO
- ZOGLIN(ZoglinEntity.class, 126, 1.4f, 1.3965f, 1.3965f, 0f, "minecraft:zoglin"), //TODO
- PIGLIN(PiglinEntity.class, 123, 1.95f, 0.6f, 0.6f, 0f, "minecraft:piglin"), //TODO
+ STRIDER(StriderEntity.class, 125, 1.7f, 0.9f, 0f, 0f, "minecraft:strider"),
+ HOGLIN(AnimalEntity.class, 124, 1.4f, 1.3965f, 1.3965f, 0f, "minecraft:hoglin"),
+ ZOGLIN(ZoglinEntity.class, 126, 1.4f, 1.3965f, 1.3965f, 0f, "minecraft:zoglin"),
+ PIGLIN(PiglinEntity.class, 123, 1.95f, 0.6f, 0.6f, 0f, "minecraft:piglin"),
/**
* Item frames are handled differently since they are a block in Bedrock.
diff --git a/connector/src/main/java/org/geysermc/connector/utils/InventoryUtils.java b/connector/src/main/java/org/geysermc/connector/utils/InventoryUtils.java
index 325710c6d6a..c30f4518af9 100644
--- a/connector/src/main/java/org/geysermc/connector/utils/InventoryUtils.java
+++ b/connector/src/main/java/org/geysermc/connector/utils/InventoryUtils.java
@@ -114,7 +114,7 @@ public static void closeWindow(GeyserSession session, int windowId) {
public static void updateCursor(GeyserSession session) {
InventorySlotPacket cursorPacket = new InventorySlotPacket();
- cursorPacket.setContainerId(ContainerId.UI); //TODO: CHECK IF ACCURATE
+ cursorPacket.setContainerId(ContainerId.UI);
cursorPacket.setSlot(0);
cursorPacket.setItem(ItemTranslator.translateToBedrock(session, session.getInventory().getCursor()));
session.sendUpstreamPacket(cursorPacket);
diff --git a/connector/src/main/java/org/geysermc/connector/utils/MessageUtils.java b/connector/src/main/java/org/geysermc/connector/utils/MessageUtils.java
index 44536ccf602..90a21c34568 100644
--- a/connector/src/main/java/org/geysermc/connector/utils/MessageUtils.java
+++ b/connector/src/main/java/org/geysermc/connector/utils/MessageUtils.java
@@ -483,8 +483,7 @@ public static String toChatColor(TeamColor teamColor) {
*/
public static boolean isTooLong(String message, GeyserSession session) {
if (message.length() > 256) {
- // TODO: Add Geyser localization and translate this based on language
- session.sendMessage("Your message is bigger than 256 characters (" + message.length() + ") so it has not been sent.");
+ session.sendMessage(LanguageUtils.getPlayerLocaleString("geyser.chat.too_long", session.getClientData().getLanguageCode(), message.length()));
return true;
}
From bfdc452e3ecd6513e8e47e837459016f97ee4c15 Mon Sep 17 00:00:00 2001
From: DoctorMacc
Date: Wed, 8 Jul 2020 11:06:58 -0400
Subject: [PATCH 33/35] Add emote support for Bedrock-to-Bedrock players
---
.../bedrock/BedrockEmoteTranslator.java | 49 +++++++++++++++++++
1 file changed, 49 insertions(+)
create mode 100644 connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockEmoteTranslator.java
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockEmoteTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockEmoteTranslator.java
new file mode 100644
index 00000000000..3e183df2e11
--- /dev/null
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockEmoteTranslator.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * @author GeyserMC
+ * @link https://github.com/GeyserMC/Geyser
+ *
+ */
+
+package org.geysermc.connector.network.translators.bedrock;
+
+import com.nukkitx.protocol.bedrock.packet.EmotePacket;
+import org.geysermc.connector.GeyserConnector;
+import org.geysermc.connector.network.session.GeyserSession;
+import org.geysermc.connector.network.translators.PacketTranslator;
+import org.geysermc.connector.network.translators.Translator;
+
+@Translator(packet = EmotePacket.class)
+public class BedrockEmoteTranslator extends PacketTranslator {
+
+ @Override
+ public void translate(EmotePacket packet, GeyserSession session) {
+ long javaId = session.getPlayerEntity().getEntityId();
+ for (GeyserSession otherSession : GeyserConnector.getInstance().getPlayers()) {
+ if (otherSession != session) {
+ packet.setRuntimeEntityId(otherSession.getEntityCache().getEntityByJavaId(javaId).getGeyserId());
+ otherSession.sendUpstreamPacket(packet);
+ System.out.println(packet);
+ }
+ }
+ }
+}
From 9cc468cee9e02571cb4fde6ed9d8b89656a8dd50 Mon Sep 17 00:00:00 2001
From: Camotoy <20743703+DoctorMacc@users.noreply.github.com>
Date: Wed, 8 Jul 2020 12:42:20 -0400
Subject: [PATCH 34/35] Remove debug string
---
.../network/translators/bedrock/BedrockEmoteTranslator.java | 1 -
1 file changed, 1 deletion(-)
diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockEmoteTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockEmoteTranslator.java
index 3e183df2e11..42a720c471f 100644
--- a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockEmoteTranslator.java
+++ b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockEmoteTranslator.java
@@ -42,7 +42,6 @@ public void translate(EmotePacket packet, GeyserSession session) {
if (otherSession != session) {
packet.setRuntimeEntityId(otherSession.getEntityCache().getEntityByJavaId(javaId).getGeyserId());
otherSession.sendUpstreamPacket(packet);
- System.out.println(packet);
}
}
}
From cbb2586fba5a21bda372dfd78d19236981eefa65 Mon Sep 17 00:00:00 2001
From: Camotoy <20743703+DoctorMacc@users.noreply.github.com>
Date: Wed, 8 Jul 2020 18:44:10 -0400
Subject: [PATCH 35/35] Don't throw a stack trace when detecting for GUI (#919)
---
.../src/main/java/org/geysermc/connector/GeyserConnector.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java
index 601421303f1..435c1eaad06 100644
--- a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java
+++ b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java
@@ -167,7 +167,9 @@ private GeyserConnector(PlatformType platformType, GeyserBootstrap bootstrap) {
try {
Class> cls = Class.forName("org.geysermc.platform.standalone.GeyserStandaloneBootstrap");
isGui = (boolean) cls.getMethod("isUseGui").invoke(cls.cast(bootstrap));
- } catch (Exception e) { e.printStackTrace(); }
+ } catch (Exception e) {
+ logger.debug("Failed detecting if standalone is using a GUI; if this is a GeyserConnect instance this can be safely ignored.");
+ }
}
double completeTime = (System.currentTimeMillis() - startupTime) / 1000D;