From da0c59446f10a7cf6f906e86f421456f629c4aa0 Mon Sep 17 00:00:00 2001
From: EOT3000 <43685885+EOT3000@users.noreply.github.com>
Date: Mon, 30 Sep 2019 12:44:25 -0400
Subject: [PATCH] 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 42797ab5f..000000000
--- 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 cea7aebfc..e344370fc 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 6cede858e..1a1928922 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 e0cd6baa0..9b149ba12 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 0ad983b53..5fa40ade8 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 c0973a04b..06f06981f 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);
+ }
+}