From 84ad01d7750ce121b10185ebb969ddd9abb2a24b Mon Sep 17 00:00:00 2001 From: Redned Date: Wed, 25 Sep 2019 22:11:31 -0500 Subject: [PATCH 01/17] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 0ec6f094..eabc65b4 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,9 @@ The ultimate goal of this project is to allow Minecraft: Bedrock Edition users t ### Please note, this project is still a work in progress and should not be used on production. +## Setting Up +Please note, Geyser is **not** a plugin. Take a look [here](https://github.com/GeyserMC/Geyser/wiki#Setup) for how to set it up. + Links: - Website: https://geysermc.org - Docs: https://geysermc.org/docs From 3d986c47fafad2c1be58eeb19cd6318a20b5c11b Mon Sep 17 00:00:00 2001 From: EOT3000 <43685885+EOT3000@users.noreply.github.com> Date: Fri, 27 Sep 2019 16:50:48 -0400 Subject: [PATCH 02/17] Block place supported --- .../connector/metrics/SentryMetrics.java | 107 ++++++++++++++++++ .../bedrock/BedrockActionTranslator.java | 15 ++- 2 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 connector/src/main/java/org/geysermc/connector/metrics/SentryMetrics.java diff --git a/connector/src/main/java/org/geysermc/connector/metrics/SentryMetrics.java b/connector/src/main/java/org/geysermc/connector/metrics/SentryMetrics.java new file mode 100644 index 00000000..88926fd5 --- /dev/null +++ b/connector/src/main/java/org/geysermc/connector/metrics/SentryMetrics.java @@ -0,0 +1,107 @@ +package org.geysermc.connector.metrics; + +import io.sentry.Sentry; +import io.sentry.SentryClient; +import io.sentry.SentryClientFactory; +import io.sentry.context.Context; +import io.sentry.event.BreadcrumbBuilder; +import io.sentry.event.UserBuilder; + +public class SentryMetrics { + private static SentryClient sentry; + + public static void init() { + /* + It is recommended that you use the DSN detection system, which + will check the environment variable "SENTRY_DSN", the Java + System Property "sentry.dsn", or the "sentry.properties" file + in your classpath. This makes it easier to provide and adjust + your DSN without needing to change your code. See the configuration + page for more information. + */ + Sentry.init(); + + // You can also manually provide the DSN to the ``init`` method. + Sentry.init(); + + /* + It is possible to go around the static ``Sentry`` API, which means + you are responsible for making the SentryClient instance available + to your code. + */ + sentry = SentryClientFactory.sentryClient(); + + SentryMetrics metrics = new SentryMetrics(); + metrics.logWithStaticAPI(); + metrics.logWithInstanceAPI(); + } + + /** + * An example method that throws an exception. + */ + void unsafeMethod() { + throw new UnsupportedOperationException("You shouldn't call this!"); + } + + /** + * Examples using the (recommended) static API. + */ + void logWithStaticAPI() { + // Note that all fields set on the context are optional. Context data is copied onto + // all future events in the current context (until the context is cleared). + + // Record a breadcrumb in the current context. By default the last 100 breadcrumbs are kept. + Sentry.getContext().recordBreadcrumb( + new BreadcrumbBuilder().setMessage("User made an action").build() + ); + + // Set the user in the current context. + Sentry.getContext().setUser( + new UserBuilder().setEmail("hello@sentry.io").build() + ); + + // Add extra data to future events in this context. + Sentry.getContext().addExtra("extra", "thing"); + + // Add an additional tag to future events in this context. + Sentry.getContext().addTag("tagName", "tagValue"); + + /* + This sends a simple event to Sentry using the statically stored instance + that was created in the ``main`` method. + */ + Sentry.capture("This is a test"); + + try { + unsafeMethod(); + } catch (Exception e) { + // This sends an exception event to Sentry using the statically stored instance + // that was created in the ``main`` method. + Sentry.capture(e); + } + } + + /** + * Examples that use the SentryClient instance directly. + */ + void logWithInstanceAPI() { + // Retrieve the current context. + Context context = sentry.getContext(); + + // Record a breadcrumb in the current context. By default the last 100 breadcrumbs are kept. + context.recordBreadcrumb(new BreadcrumbBuilder().setMessage("User made an action").build()); + + // Set the user in the current context. + context.setUser(new UserBuilder().setEmail("geyser.project@gmail.com").build()); + + // This sends a simple event to Sentry. + sentry.sendMessage("This is a test"); + + try { + unsafeMethod(); + } catch (Exception e) { + // This sends an exception event to Sentry. + sentry.sendException(e); + } + } +} 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 d0b2989d..15befd4a 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 @@ -25,11 +25,14 @@ package org.geysermc.connector.network.translators.bedrock; +import com.flowpowered.math.vector.Vector3i; import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position; +import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerAction; import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerState; import com.github.steveice10.mc.protocol.data.game.world.block.BlockFace; import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerActionPacket; +import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerPlaceBlockPacket; import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerStatePacket; import com.nukkitx.protocol.bedrock.packet.PlayerActionPacket; import org.geysermc.connector.entity.Entity; @@ -44,6 +47,9 @@ public class BedrockActionTranslator extends PacketTranslator Date: Fri, 27 Sep 2019 17:38:52 -0400 Subject: [PATCH 03/17] Block break supported. Ignore the exceptions --- .../translators/bedrock/BedrockActionTranslator.java | 12 ++++++++++++ .../translators/java/JavaJoinGameTranslator.java | 1 + 2 files changed, 13 insertions(+) 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 15befd4a..a2423825 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 @@ -90,6 +90,18 @@ public class BedrockActionTranslator extends PacketTranslator Date: Fri, 27 Sep 2019 16:41:55 -0500 Subject: [PATCH 04/17] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index eabc65b4..8d45c4fa 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ Links: - [ ] Block entities - [ ] Extra data - [ ] Biome colors -- [ ] Block break/place support +- [x] Block break/place support ## Compiling 1. Clone the repo to your computer From a18bbaf9ea556ecb67212c878ef867a5809db5ae Mon Sep 17 00:00:00 2001 From: Redned Date: Fri, 27 Sep 2019 18:04:58 -0500 Subject: [PATCH 05/17] Break all the bedrock action switch cases --- .../translators/bedrock/BedrockActionTranslator.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 a2423825..c0973a04 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 @@ -90,18 +90,19 @@ public class BedrockActionTranslator extends PacketTranslator Date: Sat, 28 Sep 2019 00:03:24 -0500 Subject: [PATCH 06/17] Add YouTube tutorial video to setting up --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8d45c4fa..5370b9b2 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,9 @@ The ultimate goal of this project is to allow Minecraft: Bedrock Edition users t ### Please note, this project is still a work in progress and should not be used on production. ## Setting Up -Please note, Geyser is **not** a plugin. Take a look [here](https://github.com/GeyserMC/Geyser/wiki#Setup) for how to set it up. +Please note, Geyser is **not** a plugin. Take watch the video below or take a look [here](https://github.com/GeyserMC/Geyser/wiki#Setup) for how to set it up. + +[![YouTube Video](https://img.youtube.com/vi/OmLxwl7_UzQ/0.jpg)](https://www.youtube.com/watch?v=OmLxwl7_UzQ) Links: - Website: https://geysermc.org From 2fb0b99696b200f17b8d5a9ff5d1864a4cd1aaa6 Mon Sep 17 00:00:00 2001 From: Redned Date: Sat, 28 Sep 2019 00:03:58 -0500 Subject: [PATCH 07/17] Fix grammar in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5370b9b2..2bc12b6e 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ The ultimate goal of this project is to allow Minecraft: Bedrock Edition users t ### Please note, this project is still a work in progress and should not be used on production. ## Setting Up -Please note, Geyser is **not** a plugin. Take watch the video below or take a look [here](https://github.com/GeyserMC/Geyser/wiki#Setup) for how to set it up. +Please note, Geyser is **not** a plugin. Watch the video below or take a look [here](https://github.com/GeyserMC/Geyser/wiki#Setup) for how to set it up. [![YouTube Video](https://img.youtube.com/vi/OmLxwl7_UzQ/0.jpg)](https://www.youtube.com/watch?v=OmLxwl7_UzQ) From 79ce4e2e8e45e792bfd815554d503719e1fa9a5a Mon Sep 17 00:00:00 2001 From: Redned Date: Sun, 29 Sep 2019 11:59:30 -0500 Subject: [PATCH 08/17] Fix logo in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2bc12b6e..722f6d44 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Geyser +Geyser [![forthebadge made-with-java](http://ForTheBadge.com/images/badges/made-with-java.svg)](https://java.com/) From 06125238fb5d67af99288529b69bf49b6f19269b Mon Sep 17 00:00:00 2001 From: Redned Date: Sun, 29 Sep 2019 12:00:00 -0500 Subject: [PATCH 09/17] Fix invalid docs link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 722f6d44..f37c1373 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Please note, Geyser is **not** a plugin. Watch the video below or take a look [h Links: - Website: https://geysermc.org -- Docs: https://geysermc.org/docs +- Docs: https://github.com/GeyserMC/Geyser/wiki - Download: http://ci.geysermc.org - Discord: http://discord.geysermc.org/ From c8404d15c1b5de60d7e3f37ae1be01ae03c5b7a5 Mon Sep 17 00:00:00 2001 From: WesleyVanNeck Date: Sun, 29 Sep 2019 20:05:41 +0200 Subject: [PATCH 10/17] fix that unknown Configuration crashes geyser --- .../geysermc/connector/configuration/GeyserConfiguration.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/connector/src/main/java/org/geysermc/connector/configuration/GeyserConfiguration.java b/connector/src/main/java/org/geysermc/connector/configuration/GeyserConfiguration.java index d90f2576..5962ab08 100644 --- a/connector/src/main/java/org/geysermc/connector/configuration/GeyserConfiguration.java +++ b/connector/src/main/java/org/geysermc/connector/configuration/GeyserConfiguration.java @@ -25,11 +25,13 @@ package org.geysermc.connector.configuration; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Getter; import java.util.Map; +@JsonIgnoreProperties(ignoreUnknown = true) @Getter public class GeyserConfiguration { @@ -51,4 +53,4 @@ public class GeyserConfiguration { private int generalThreadPool; private MetricInfo metrics; -} \ No newline at end of file +} From 1364eb1df7581701fa384f095180d039b401712e Mon Sep 17 00:00:00 2001 From: AJ Ferguson Date: Sun, 29 Sep 2019 15:25:42 -0800 Subject: [PATCH 11/17] Add ability to use items Now able to use bows, eat food, throw ender pearls, etc. --- .../network/UpstreamPacketHandler.java | 5 ++ .../network/translators/TranslatorsInit.java | 1 + ...BedrockInventoryTransactionTranslator.java | 57 +++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockInventoryTransactionTranslator.java diff --git a/connector/src/main/java/org/geysermc/connector/network/UpstreamPacketHandler.java b/connector/src/main/java/org/geysermc/connector/network/UpstreamPacketHandler.java index 929ed9d5..02611f2f 100644 --- a/connector/src/main/java/org/geysermc/connector/network/UpstreamPacketHandler.java +++ b/connector/src/main/java/org/geysermc/connector/network/UpstreamPacketHandler.java @@ -150,4 +150,9 @@ public class UpstreamPacketHandler extends LoggingPacketHandler { public boolean handle(PlayerActionPacket packet) { return translateAndDefault(packet); } + + @Override + public boolean handle(InventoryTransactionPacket packet) { + return translateAndDefault(packet); + } } \ No newline at end of file diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/TranslatorsInit.java b/connector/src/main/java/org/geysermc/connector/network/translators/TranslatorsInit.java index 88e142cd..fc949851 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/TranslatorsInit.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/TranslatorsInit.java @@ -150,6 +150,7 @@ public class TranslatorsInit { Registry.registerBedrock(MobEquipmentPacket.class, new BedrockMobEquipmentTranslator()); Registry.registerBedrock(PlayerActionPacket.class, new BedrockActionTranslator()); Registry.registerBedrock(MovePlayerPacket.class, new BedrockMovePlayerTranslator()); + Registry.registerBedrock(InventoryTransactionPacket.class, new BedrockInventoryTransactionTranslator()); itemTranslator = new ItemTranslator(); blockTranslator = new BlockTranslator(); 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 new file mode 100644 index 00000000..4fdb7c69 --- /dev/null +++ b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockInventoryTransactionTranslator.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2019 GeyserMC. http://geysermc.org + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * @author GeyserMC + * @link https://github.com/GeyserMC/Geyser + */ + +package org.geysermc.connector.network.translators.bedrock; + +import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position; +import com.github.steveice10.mc.protocol.data.game.entity.player.Hand; +import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerAction; +import com.github.steveice10.mc.protocol.data.game.world.block.BlockFace; +import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerActionPacket; +import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerUseItemPacket; +import com.nukkitx.protocol.bedrock.packet.InventoryTransactionPacket; +import org.geysermc.connector.network.session.GeyserSession; +import org.geysermc.connector.network.translators.PacketTranslator; + +public class BedrockInventoryTransactionTranslator extends PacketTranslator { + + @Override + public void translate(InventoryTransactionPacket packet, GeyserSession session) { + switch (packet.getTransactionType()) { + case ITEM_USE: + switch (packet.getActionType()) { + case 1: + ClientPlayerUseItemPacket useItemPacket = new ClientPlayerUseItemPacket(Hand.MAIN_HAND); + session.getDownstream().getSession().send(useItemPacket); + break; + } + break; + case ITEM_RELEASE: + ClientPlayerActionPacket releaseItemPacket = new ClientPlayerActionPacket(PlayerAction.RELEASE_USE_ITEM, new Position(0,0,0), BlockFace.DOWN); + session.getDownstream().getSession().send(releaseItemPacket); + break; + } + } +} From 6fa25aa2647609ac102d5e46384b4a8a2863aa1d Mon Sep 17 00:00:00 2001 From: AJ Ferguson Date: Sun, 29 Sep 2019 15:39:03 -0800 Subject: [PATCH 12/17] Only send release packet if action type is 0 Needed for eating to work correctly --- .../BedrockInventoryTransactionTranslator.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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 4fdb7c69..dd6b9c07 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 @@ -41,16 +41,16 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator Date: Mon, 30 Sep 2019 12:44:25 -0400 Subject: [PATCH 13/17] Try fixing block break (didn't work). Also add more metrics --- .gitignore | 226 ------------------ connector/pom.xml | 1 + .../geysermc/connector/GeyserConnector.java | 2 + .../geysermc/connector/metrics/Metrics.java | 2 +- .../network/session/GeyserSession.java | 12 + .../bedrock/BedrockActionTranslator.java | 57 ++++- .../bedrock/BedrockInteractTranslator.java | 64 +++++ 7 files changed, 129 insertions(+), 235 deletions(-) delete mode 100644 .gitignore create mode 100644 connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockInteractTranslator.java diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 42797ab5..00000000 --- a/.gitignore +++ /dev/null @@ -1,226 +0,0 @@ - -# Created by https://www.gitignore.io/api/git,java,maven,eclipse,netbeans,jetbrains+all -# Edit at https://www.gitignore.io/?templates=git,java,maven,eclipse,netbeans,jetbrains+all - -### Eclipse ### -.metadata -bin/ -tmp/ -*.tmp -*.bak -*.swp -*~.nib -local.properties -.settings/ -.loadpath -.recommenders - -# External tool builders -.externalToolBuilders/ - -# Locally stored "Eclipse launch configurations" -*.launch - -# PyDev specific (Python IDE for Eclipse) -*.pydevproject - -# CDT-specific (C/C++ Development Tooling) -.cproject - -# CDT- autotools -.autotools - -# Java annotation processor (APT) -.factorypath - -# PDT-specific (PHP Development Tools) -.buildpath - -# sbteclipse plugin -.target - -# Tern plugin -.tern-project - -# TeXlipse plugin -.texlipse - -# STS (Spring Tool Suite) -.springBeans - -# Code Recommenders -.recommenders/ - -# Annotation Processing -.apt_generated/ - -# Scala IDE specific (Scala & Java development for Eclipse) -.cache-main -.scala_dependencies -.worksheet - -### Eclipse Patch ### -# Eclipse Core -.project - -# JDT-specific (Eclipse Java Development Tools) -.classpath - -# Annotation Processing -.apt_generated - -.sts4-cache/ - -### Git ### -# Created by git for backups. To disable backups in Git: -# $ git config --global mergetool.keepBackup false -*.orig - -# Created by git when using merge tools for conflicts -*.BACKUP.* -*.BASE.* -*.LOCAL.* -*.REMOTE.* -*_BACKUP_*.txt -*_BASE_*.txt -*_LOCAL_*.txt -*_REMOTE_*.txt - -### Java ### -# Compiled class file -*.class - -# Log file -*.log - -# BlueJ files -*.ctxt - -# Mobile Tools for Java (J2ME) -.mtj.tmp/ - -# Package Files # -*.jar -*.war -*.nar -*.ear -*.zip -*.tar.gz -*.rar - -# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml -hs_err_pid* - -### JetBrains+all ### -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/**/usage.statistics.xml -.idea/**/dictionaries -.idea/**/shelf - -# Generated files -.idea/**/contentModel.xml - -# Sensitive or high-churn files -.idea/**/dataSources/ -.idea/**/dataSources.ids -.idea/**/dataSources.local.xml -.idea/**/sqlDataSources.xml -.idea/**/dynamic.xml -.idea/**/uiDesigner.xml -.idea/**/dbnavigator.xml - -# Gradle -.idea/**/gradle.xml -.idea/**/libraries - -# Gradle and Maven with auto-import -# When using Gradle or Maven with auto-import, you should exclude module files, -# since they will be recreated, and may cause churn. Uncomment if using -# auto-import. -# .idea/modules.xml -# .idea/*.iml -# .idea/modules -# *.iml -# *.ipr - -# CMake -cmake-build-*/ - -# Mongo Explorer plugin -.idea/**/mongoSettings.xml - -# File-based project format -*.iws - -# IntelliJ -out/ - -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Cursive Clojure plugin -.idea/replstate.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties - -# Editor-based Rest Client -.idea/httpRequests - -# Android studio 3.1+ serialized cache file -.idea/caches/build_file_checksums.ser - -### JetBrains+all Patch ### -# Ignores the whole .idea folder and all .iml files -# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360 - -.idea/ - -# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023 - -*.iml -modules.xml -.idea/misc.xml -*.ipr - -# Sonarlint plugin -.idea/sonarlint - -### Maven ### -target/ -pom.xml.tag -pom.xml.releaseBackup -pom.xml.versionsBackup -pom.xml.next -release.properties -dependency-reduced-pom.xml -buildNumber.properties -.mvn/timing.properties -.mvn/wrapper/maven-wrapper.jar - -### NetBeans ### -**/nbproject/private/ -**/nbproject/Makefile-*.mk -**/nbproject/Package-*.bash -build/ -nbbuild/ -dist/ -nbdist/ -.nb-gradle/ - -# End of https://www.gitignore.io/api/git,java,maven,eclipse,netbeans,jetbrains+all - -### Geyser ### -config.yml -logs/ \ No newline at end of file diff --git a/connector/pom.xml b/connector/pom.xml index cea7aebf..e344370f 100644 --- a/connector/pom.xml +++ b/connector/pom.xml @@ -11,6 +11,7 @@ connector + org.geysermc api 1.0-SNAPSHOT diff --git a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java index 6cede858..1a192892 100644 --- a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java +++ b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java @@ -96,6 +96,7 @@ public class GeyserConnector implements Connector { } private GeyserConnector() { + long startupTime = System.currentTimeMillis(); // Metric @@ -159,6 +160,7 @@ public class GeyserConnector implements Connector { metrics = new Metrics("GeyserMC", config.getMetrics().getUUID(), true, java.util.logging.Logger.getLogger("")); metrics.addCustomChart(new Metrics.SingleLineChart("servers", () -> 1)); metrics.addCustomChart(new Metrics.SingleLineChart("players", Geyser::getPlayerCount)); + metrics.addCustomChart(new Metrics.SimplePie("authMode", config.getRemote()::getAuthType)); } double completeTime = (System.currentTimeMillis() - startupTime) / 1000D; diff --git a/connector/src/main/java/org/geysermc/connector/metrics/Metrics.java b/connector/src/main/java/org/geysermc/connector/metrics/Metrics.java index e0cd6baa..9b149ba1 100644 --- a/connector/src/main/java/org/geysermc/connector/metrics/Metrics.java +++ b/connector/src/main/java/org/geysermc/connector/metrics/Metrics.java @@ -81,7 +81,7 @@ public class Metrics { * Starts the Scheduler which submits our data every 30 minutes. */ private void startSubmitting() { - Geyser.getGeneralThreadPool().scheduleAtFixedRate(this::submitData, 5, 30, TimeUnit.MINUTES); + Geyser.getGeneralThreadPool().scheduleAtFixedRate(this::submitData, 1, 30, TimeUnit.MINUTES); // Submit the data every 30 minutes, first time after 5 minutes to give other plugins enough time to start // WARNING: Changing the frequency has no effect but your plugin WILL be blocked/deleted! // WARNING: Just don't do it! 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 0ad983b5..5fa40ade 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 @@ -64,6 +64,14 @@ import java.util.UUID; @Getter public class GeyserSession implements Player { + @Getter + @Setter + private volatile boolean breaking; + + @Getter + @Setter + private volatile boolean threadStop; + private final GeyserConnector connector; private final BedrockServerSession upstream; private RemoteServer remoteServer; @@ -93,6 +101,10 @@ public class GeyserSession implements Player { private boolean spawned; private boolean closed; + @Getter + @Setter + private Thread breakThread; + public GeyserSession(GeyserConnector connector, BedrockServerSession bedrockServerSession) { this.connector = connector; this.upstream = bedrockServerSession; 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 c0973a04..06f06981 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 @@ -80,10 +80,12 @@ public class BedrockActionTranslator extends PacketTranslator { + + @Override + public void translate(InteractPacket packet, GeyserSession session) { + Vector3f vector = packet.getMousePosition(); + InteractAction action; + + if(packet.getAction() == 1) { + action = InteractAction.ATTACK; + } else { + action = InteractAction.INTERACT; + } + + ClientPlayerInteractEntityPacket entityPacket = new ClientPlayerInteractEntityPacket((int) packet.getRuntimeEntityId(), + action, vector.getX(), vector.getY(), vector.getZ(), Hand.MAIN_HAND); + + session.getDownstream().getSession().send(entityPacket); + } +} From fe845710b65c8ec0a0646f4299b7a65f2cafc8bf Mon Sep 17 00:00:00 2001 From: AJ Ferguson Date: Mon, 30 Sep 2019 14:17:36 -0800 Subject: [PATCH 14/17] Fix for block breaking --- .../network/session/GeyserSession.java | 13 ++-- .../bedrock/BedrockActionTranslator.java | 67 +++++-------------- 2 files changed, 21 insertions(+), 59 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 5fa40ade..0b5b3250 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 @@ -32,6 +32,7 @@ import com.flowpowered.math.vector.Vector3i; import com.github.steveice10.mc.auth.data.GameProfile; import com.github.steveice10.mc.auth.exception.request.RequestException; import com.github.steveice10.mc.protocol.MinecraftProtocol; +import com.github.steveice10.mc.protocol.data.game.world.block.BlockFace; import com.github.steveice10.packetlib.Client; import com.github.steveice10.packetlib.event.session.ConnectedEvent; import com.github.steveice10.packetlib.event.session.DisconnectedEvent; @@ -64,13 +65,6 @@ import java.util.UUID; @Getter public class GeyserSession implements Player { - @Getter - @Setter - private volatile boolean breaking; - - @Getter - @Setter - private volatile boolean threadStop; private final GeyserConnector connector; private final BedrockServerSession upstream; @@ -101,9 +95,10 @@ public class GeyserSession implements Player { private boolean spawned; private boolean closed; - @Getter @Setter - private Thread breakThread; + private Vector3i blockDiggingPos = Vector3i.ZERO; + @Setter + private BlockFace blockDiggingFace = BlockFace.DOWN; public GeyserSession(GeyserConnector connector, BedrockServerSession bedrockServerSession) { this.connector = connector; 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 06f06981..fdab51ba 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 @@ -80,69 +80,36 @@ public class BedrockActionTranslator extends PacketTranslator Date: Mon, 30 Sep 2019 14:18:29 -0800 Subject: [PATCH 15/17] Handle digging acknowledgement from server --- .../network/translators/TranslatorsInit.java | 3 ++ .../player/JavaPlayerActionAckTranslator.java | 51 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 connector/src/main/java/org/geysermc/connector/network/translators/java/entity/player/JavaPlayerActionAckTranslator.java diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/TranslatorsInit.java b/connector/src/main/java/org/geysermc/connector/network/translators/TranslatorsInit.java index fc949851..e89ab4f7 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/TranslatorsInit.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/TranslatorsInit.java @@ -28,6 +28,7 @@ package org.geysermc.connector.network.translators; import com.github.steveice10.mc.protocol.data.game.window.WindowType; import com.github.steveice10.mc.protocol.packet.ingame.server.*; import com.github.steveice10.mc.protocol.packet.ingame.server.entity.*; +import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerActionAckPacket; import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerHealthPacket; import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerPositionRotationPacket; import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerSetExperiencePacket; @@ -56,6 +57,7 @@ import org.geysermc.connector.network.translators.java.JavaJoinGameTranslator; import org.geysermc.connector.network.translators.java.JavaRespawnTranslator; import org.geysermc.connector.network.translators.java.JavaTitleTranslator; import org.geysermc.connector.network.translators.java.entity.*; +import org.geysermc.connector.network.translators.java.entity.player.JavaPlayerActionAckTranslator; import org.geysermc.connector.network.translators.java.entity.player.JavaPlayerHealthTranslator; import org.geysermc.connector.network.translators.java.entity.player.JavaPlayerPositionRotationTranslator; import org.geysermc.connector.network.translators.java.entity.player.JavaPlayerSetExperienceTranslator; @@ -131,6 +133,7 @@ public class TranslatorsInit { Registry.registerJava(ServerPlayerPositionRotationPacket.class, new JavaPlayerPositionRotationTranslator()); Registry.registerJava(ServerPlayerSetExperiencePacket.class, new JavaPlayerSetExperienceTranslator()); Registry.registerJava(ServerPlayerHealthPacket.class, new JavaPlayerHealthTranslator()); + Registry.registerJava(ServerPlayerActionAckPacket.class, new JavaPlayerActionAckTranslator()); Registry.registerJava(ServerNotifyClientPacket.class, new JavaNotifyClientTranslator()); Registry.registerJava(ServerChunkDataPacket.class, new JavaChunkDataTranslator()); diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/player/JavaPlayerActionAckTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/player/JavaPlayerActionAckTranslator.java new file mode 100644 index 00000000..73e812f0 --- /dev/null +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/player/JavaPlayerActionAckTranslator.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2019 GeyserMC. http://geysermc.org + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * @author GeyserMC + * @link https://github.com/GeyserMC/Geyser + */ + +package org.geysermc.connector.network.translators.java.entity.player; + +import com.flowpowered.math.vector.Vector3i; +import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerActionAckPacket; +import com.nukkitx.protocol.bedrock.packet.UpdateBlockPacket; +import org.geysermc.connector.network.session.GeyserSession; +import org.geysermc.connector.network.translators.PacketTranslator; +import org.geysermc.connector.network.translators.TranslatorsInit; +import org.geysermc.connector.network.translators.item.BedrockItem; +import org.geysermc.connector.world.GlobalBlockPalette; + +public class JavaPlayerActionAckTranslator extends PacketTranslator { + + @Override + public void translate(ServerPlayerActionAckPacket packet, GeyserSession session) { + switch (packet.getAction()) { + case FINISH_DIGGING: + UpdateBlockPacket updateBlockPacket = new UpdateBlockPacket(); + BedrockItem bedrockItem = TranslatorsInit.getBlockTranslator().getBedrockBlock(packet.getNewState()); + updateBlockPacket.setBlockPosition(Vector3i.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ())); + updateBlockPacket.setRuntimeId(GlobalBlockPalette.getOrCreateRuntimeId(bedrockItem.hashCode())); + session.getUpstream().sendPacket(updateBlockPacket); + break; + } + } +} From 0a961fd2f7b2727c261f5ff7f6c8a1159c4db04a Mon Sep 17 00:00:00 2001 From: Nicolas Znamenski Date: Mon, 30 Sep 2019 20:40:07 -0400 Subject: [PATCH 16/17] Added parameters on dolphin and added support for Drowned, Pandas and Turtles --- .../org/geysermc/connector/entity/type/EntityType.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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 b0f62d62..3bb1b82c 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 @@ -51,7 +51,7 @@ public enum EntityType { POLAR_BEAR(28, 1.4f, 1.3f), LLAMA(29, 1.87f, 0.9f), PARROT(30, 0.9f, 0.5f), - DOLPHIN(31, 0f), //TODO + DOLPHIN(31, 0.6f, 0.9f), ZOMBIE(32, 1.8f, 0.6f, 0.6f, 1.62f), CREEPER(33, 1.7f, 0.6f, 0.6f, 1.62f), SKELETON(34, 1.8f, 0.6f, 0.6f, 1.62f), @@ -96,6 +96,8 @@ public enum EntityType { ENDER_CRYSTAL(71, 0f), FIREWORK_ROCKET(72, 0f), TRIDENT(73, 0f), + TURTLE(74, 0.4f, 1.2f), + // TODO CAT (need to figure out how to deal with baby cats) https://github.com/NukkitX/Nukkit/blob/master/src/main/java/cn/nukkit/entity/passive/EntityCat.java SHULKER_BULLET(76, 0f), FISHING_HOOK(77, 0f), @@ -130,8 +132,10 @@ public enum EntityType { BALLOON(107, 0f), //TODO PUFFERFISH(108, 0.7f, 0.7f), SALMON(109, 0.5f, 0.7f), + DROWNED(110, 1.95f, 0.6f), TROPICAL_FISH(111, 0.6f, 0.6f), - COD(112, 0.25f, 0.5f); + COD(112, 0.25f, 0.5f), + PANDA(113, 1.25f, 1.125f, 1.825f); private final int type; private final float height; From 4b0d7771285b678abf53e63e93c627d65559f85d Mon Sep 17 00:00:00 2001 From: AJ Ferguson Date: Tue, 1 Oct 2019 15:36:33 -0800 Subject: [PATCH 17/17] Fix crash after first disconnect --- .gitignore | 226 ++++++++++++++++++ .../network/session/GeyserSession.java | 2 +- 2 files changed, 227 insertions(+), 1 deletion(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..f003e014 --- /dev/null +++ b/.gitignore @@ -0,0 +1,226 @@ + +# Created by https://www.gitignore.io/api/git,java,maven,eclipse,netbeans,jetbrains+all +# Edit at https://www.gitignore.io/?templates=git,java,maven,eclipse,netbeans,jetbrains+all + +### Eclipse ### +.metadata +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.settings/ +.loadpath +.recommenders + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# PyDev specific (Python IDE for Eclipse) +*.pydevproject + +# CDT-specific (C/C++ Development Tooling) +.cproject + +# CDT- autotools +.autotools + +# Java annotation processor (APT) +.factorypath + +# PDT-specific (PHP Development Tools) +.buildpath + +# sbteclipse plugin +.target + +# Tern plugin +.tern-project + +# TeXlipse plugin +.texlipse + +# STS (Spring Tool Suite) +.springBeans + +# Code Recommenders +.recommenders/ + +# Annotation Processing +.apt_generated/ + +# Scala IDE specific (Scala & Java development for Eclipse) +.cache-main +.scala_dependencies +.worksheet + +### Eclipse Patch ### +# Eclipse Core +.project + +# JDT-specific (Eclipse Java Development Tools) +.classpath + +# Annotation Processing +.apt_generated + +.sts4-cache/ + +### Git ### +# Created by git for backups. To disable backups in Git: +# $ git config --global mergetool.keepBackup false +*.orig + +# Created by git when using merge tools for conflicts +*.BACKUP.* +*.BASE.* +*.LOCAL.* +*.REMOTE.* +*_BACKUP_*.txt +*_BASE_*.txt +*_LOCAL_*.txt +*_REMOTE_*.txt + +### Java ### +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +### JetBrains+all ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### JetBrains+all Patch ### +# Ignores the whole .idea folder and all .iml files +# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360 + +.idea/ + +# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023 + +*.iml +modules.xml +.idea/misc.xml +*.ipr + +# Sonarlint plugin +.idea/sonarlint + +### Maven ### +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties +.mvn/wrapper/maven-wrapper.jar + +### NetBeans ### +**/nbproject/private/ +**/nbproject/Makefile-*.mk +**/nbproject/Package-*.bash +build/ +nbbuild/ +dist/ +nbdist/ +.nb-gradle/ + +# End of https://www.gitignore.io/api/git,java,maven,eclipse,netbeans,jetbrains+all + +### Geyser ### +config.yml +logs/ 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 0b5b3250..a4cf425d 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 @@ -297,7 +297,7 @@ public class GeyserSession implements Player { startGamePacket.setCurrentTick(0); startGamePacket.setEnchantmentSeed(0); startGamePacket.setMultiplayerCorrelationId(""); - startGamePacket.setCachedPalette(Toolbox.CACHED_PALLETE); + startGamePacket.setCachedPalette(Toolbox.CACHED_PALLETE.copy()); startGamePacket.setItemEntries(Toolbox.ITEMS); upstream.sendPacket(startGamePacket);