diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 61e1289..69c7878 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -38,18 +38,18 @@ jobs:
mvn -B versions:set -DnewVersion=${MAVEN_VERSION}
# Set Plugin Version
- sed -i "/version = .*/ s/version = \"[^\"]*\"/version = \"${MAVEN_VERSION}\"/" src/main/java/au/com/grieve/edusupport/EduSupport.java
+ sed -i "/version = .*/ s/version = \"[^\"]*\"/version = \"${MAVEN_VERSION}\"/" geyser-reversion/src/main/java/au/com/grieve/geyser/reversion/GeyserReversionPlugin.java
- name: Update Version for Developmental Build
if: "!startsWith(github.ref,'refs/tags/v')"
run: |
- sed -i "/version = .*/ s/-dev/-b${GITHUB_RUN_NUMBER}/" src/main/java/au/com/grieve/edusupport/EduSupport.java
+ sed -i "/version = .*/ s/-dev/-b${GITHUB_RUN_NUMBER}/" geyser-reversion/src/main/java/au/com/grieve/geyser/reversion/GeyserReversionPlugin.java
- name: Build with Maven
run: |
mkdir -p build/output
mvn -B package --file pom.xml && \
- cp target/EduSupport-*.jar build/output/
+ cp target/GeyserReversion-*.jar build/output/
- name: Publish to Maven Repo
if: (github.ref == 'refs/heads/master' || startsWith(github.ref,'refs/tags/v'))
@@ -134,7 +134,7 @@ jobs:
for asset in ./build/binary/*.jar; do
assets+=("-a" "$asset")
done
- assets+=("-a" "build/docs/pdf/documentation.pdf#EduSupport-Documentation.pdf")
+ assets+=("-a" "build/docs/pdf/documentation.pdf#GeyserReversion-Documentation.pdf")
tag_name="${GITHUB_REF##*/}"
hub release create \
@@ -143,7 +143,7 @@ jobs:
"$tag_name" << EOF
Release $tag_name
- [Online Documentation](https://bundabrg.github.io/EduSupport)
+ [Online Documentation](https://bundabrg.github.io/GeyserReversion)
Since Last Release:
$(git log $(git describe --tags --abbrev=0 HEAD^ 2> /dev/null || git rev-list --max-parents=0 HEAD)..HEAD --graph --pretty=format:'%h %d %s [%an]' --abbrev-commit)
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..ff1f7e6
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "src/main/resources/mappings"]
+ path = src/main/resources/mappings
+ url = https://github.com/bundabrg/mappings-education.git
diff --git a/.idea/copyright/GLP3.xml b/.idea/copyright/GLP3.xml
index fa2d17b..62e8702 100644
--- a/.idea/copyright/GLP3.xml
+++ b/.idea/copyright/GLP3.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/README.md b/README.md
index ec2cdac..e3653a4 100644
--- a/README.md
+++ b/README.md
@@ -1,28 +1,28 @@
-![Logo](https://bundabrg.github.io/EduSupport/img/title.png)
+![Logo](https://bundabrg.github.io/GeyserReversion/img/title.png)
[![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://lbesson.mit-license.org/)
-[![GitHub release](https://img.shields.io/github/release/Bundabrg/EduSupport)](https://GitHub.com/Bundabrg/EduSupport/releases/)
-[![GitHub commits](https://img.shields.io/github/commits-since/Bundabrg/EduSupport/latest)](https://GitHub.com/Bundabrg/EduSupport/commit/)
-[![Github all releases](https://img.shields.io/github/downloads/Bundabrg/EduSupport/total.svg)](https://GitHub.com/Bundabrg/EduSupport/releases/)
-![HitCount](http://hits.dwyl.com/bundabrg/EduSupport.svg)
-
-![Workflow](https://github.com/bundabrg/EduSupport/workflows/build/badge.svg)
-[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://GitHub.com/Bundabrg/EduSupport/graphs/commit-activity)
-[![GitHub contributors](https://img.shields.io/github/contributors/Bundabrg/EduSupport)](https://GitHub.com/Bundabrg/EduSupport/graphs/contributors/)
-[![GitHub issues](https://img.shields.io/github/issues/Bundabrg/EduSupport)](https://GitHub.com/Bundabrg/EduSupport/issues/)
-[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/Bundabrg/EduSupport.svg)](http://isitmaintained.com/project/Bundabrg/EduSupport "Average time to resolve an issue")
-[![GitHub pull-requests](https://img.shields.io/github/issues-pr/Bundabrg/EduSupport)](https://GitHub.com/Bundabrg/EduSupport/pull/)
+[![GitHub release](https://img.shields.io/github/release/Bundabrg/GeyserReversion)](https://GitHub.com/Bundabrg/GeyserReversion/releases/)
+[![GitHub commits](https://img.shields.io/github/commits-since/Bundabrg/GeyserReversion/latest)](https://GitHub.com/Bundabrg/GeyserReversion/commit/)
+[![Github all releases](https://img.shields.io/github/downloads/Bundabrg/GeyserReversion/total.svg)](https://GitHub.com/Bundabrg/GeyserReversion/releases/)
+![HitCount](http://hits.dwyl.com/bundabrg/GeyserReversion.svg)
+
+![Workflow](https://github.com/bundabrg/GeyserReversion/workflows/build/badge.svg)
+[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://GitHub.com/Bundabrg/GeyserReversion/graphs/commit-activity)
+[![GitHub contributors](https://img.shields.io/github/contributors/Bundabrg/GeyserReversion)](https://GitHub.com/Bundabrg/GeyserReversion/graphs/contributors/)
+[![GitHub issues](https://img.shields.io/github/issues/Bundabrg/GeyserReversion)](https://GitHub.com/Bundabrg/GeyserReversion/issues/)
+[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/Bundabrg/GeyserReversion.svg)](http://isitmaintained.com/project/Bundabrg/GeyserReversion "Average time to resolve an issue")
+[![GitHub pull-requests](https://img.shields.io/github/issues-pr/Bundabrg/GeyserReversion)](https://GitHub.com/Bundabrg/GeyserReversion/pull/)
---
-[**Documentation**](https://bundabrg.github.io/EduSupport/)
+[**Documentation**](https://bundabrg.github.io/GeyserReversion/)
-[**Source Code**](https://github.com/bundabrg/EduSupport/)
+[**Source Code**](https://github.com/bundabrg/GeyserReversion/)
---
-EduSupport is a Geyser Plugin that provides protocol support for Minecraft Educational Edition.
+GeyserReversion is a Geyser Plugin that provides multiversion support for Geyser.
## Features
diff --git a/geyser-reversion/pom.xml b/geyser-reversion/pom.xml
new file mode 100644
index 0000000..a05c64a
--- /dev/null
+++ b/geyser-reversion/pom.xml
@@ -0,0 +1,101 @@
+
+
+
+
+
+ parent
+ au.com.grieve.geyser.reversion
+ 1.1.0-SNAPSHOT
+
+ 4.0.0
+
+ geyser-reversion
+
+
+
+
+ org.geysermc
+ connector
+ 1.2.0-SNAPSHOT
+ provided
+
+
+
+ au.com.grieve.reversion
+ translator-v390ee_to_v408be
+ 1.1.0-SNAPSHOT
+ compile
+
+
+ au.com.grieve.reversion
+ common
+ 1.1.0-SNAPSHOT
+ compile
+
+
+ au.com.grieve.reversion
+ edition-education
+ 1.1.0-SNAPSHOT
+ compile
+
+
+ au.com.grieve.reversion
+ edition-bedrock
+ 1.1.0-SNAPSHOT
+ compile
+
+
+
+
+ ../target
+ GeyserReversion-${project.parent.version}
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 3.2.3
+
+
+ package
+
+ shade
+
+
+
+
+
+
+
+
+
+
+
+
+ it.unimi.dsi.fastutil:*
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/geyser-reversion/src/main/java/au/com/grieve/geyser/reversion/GeyserReversionPlugin.java b/geyser-reversion/src/main/java/au/com/grieve/geyser/reversion/GeyserReversionPlugin.java
new file mode 100644
index 0000000..6a596ec
--- /dev/null
+++ b/geyser-reversion/src/main/java/au/com/grieve/geyser/reversion/GeyserReversionPlugin.java
@@ -0,0 +1,169 @@
+/*
+ * EduSupport - Minecraft Protocol Support for MultiVersion in Geyser
+ * Copyright (C) 2020 GeyserReversion Developers
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package au.com.grieve.geyser.reversion;
+
+import au.com.grieve.geyser.reversion.api.Edition;
+import au.com.grieve.geyser.reversion.config.Configuration;
+import au.com.grieve.geyser.reversion.editions.bedrock.BedrockEdition;
+import au.com.grieve.geyser.reversion.editions.education.EducationEdition;
+import au.com.grieve.reversion.ReversionServer;
+import au.com.grieve.reversion.api.BaseTranslator;
+import au.com.grieve.reversion.api.TranslatorException;
+import au.com.grieve.reversion.translators.v390ee_to_v408be.Translator_v390ee_to_v408be;
+import lombok.Getter;
+import org.geysermc.connector.GeyserConnector;
+import org.geysermc.connector.event.annotations.GeyserEventHandler;
+import org.geysermc.connector.event.events.geyser.GeyserStartEvent;
+import org.geysermc.connector.event.handlers.EventHandler;
+import org.geysermc.connector.plugin.GeyserPlugin;
+import org.geysermc.connector.plugin.PluginClassLoader;
+import org.geysermc.connector.plugin.PluginManager;
+import org.geysermc.connector.plugin.annotations.Plugin;
+import org.geysermc.connector.utils.LanguageUtils;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Field;
+import java.net.InetSocketAddress;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Plugin(
+ name = "GeyserReversion",
+ version = "1.1.0-dev",
+ authors = {"bundabrg"},
+ description = "Provides multiversion protocol support for Geyser"
+)
+@Getter
+public class GeyserReversionPlugin extends GeyserPlugin {
+ @Getter
+ private static GeyserReversionPlugin instance;
+
+ private final Map registeredEditions = new HashMap<>();
+ private final List> registeredTranslators = new ArrayList<>();
+
+ private Configuration config;
+
+ public GeyserReversionPlugin(PluginManager pluginManager, PluginClassLoader pluginClassLoader) {
+ super(pluginManager, pluginClassLoader);
+ instance = this;
+
+ loadConfig();
+ registerEditions();
+ registerTranslators();
+ }
+
+ /**
+ * Register built-in editions
+ */
+ private void registerEditions() {
+ registerEdition("bedrock", new BedrockEdition(this));
+ registerEdition("education", new EducationEdition(this));
+ }
+
+ /**
+ * Register built-in translators
+ */
+ private void registerTranslators() {
+ registerTranslator(Translator_v390ee_to_v408be.class);
+ }
+
+
+ /**
+ * Register an Edition
+ */
+ public void registerEdition(String name, Edition edition) {
+ registeredEditions.put(name, edition);
+ getLogger().debug("Registered Edition: " + name);
+ }
+
+ /**
+ * Register a Translator
+ */
+ public void registerTranslator(Class extends BaseTranslator> translatorClass) {
+ registeredTranslators.add(translatorClass);
+ getLogger().debug("Registered Translator: " + translatorClass.getSimpleName());
+ }
+
+ /**
+ * Load our config, generating it if necessary
+ */
+ private void loadConfig() {
+ File configFile = new File(getDataFolder(), "config.yml");
+ if (!configFile.exists()) {
+ //noinspection ResultOfMethodCallIgnored
+ configFile.getParentFile().mkdirs();
+
+ try (FileOutputStream fos = new FileOutputStream(configFile);
+ InputStream fis = getResourceAsStream("config.yml")) {
+ fis.transferTo(fos);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ config = Configuration.loadFromFile(configFile);
+ }
+
+ /**
+ * Replace Geyser BedrockServer with one provided by an edition
+ */
+ @GeyserEventHandler(priority = EventHandler.PRIORITY.HIGH)
+ public void onGeyserStart(GeyserStartEvent event) {
+ Edition edition = registeredEditions.get(config.getEdition());
+
+ if (edition == null) {
+ getLogger().error(String.format("Invalid Edition '%s'. Plugin disabled.", config.getEdition()));
+ return;
+ }
+
+ InetSocketAddress address = GeyserConnector.getInstance().getBedrockServer().getBindAddress();
+
+ try {
+ Field bedrockServer = GeyserConnector.class.getDeclaredField("bedrockServer");
+ bedrockServer.setAccessible(true);
+
+ ReversionServer server = edition.createReversionServer(GeyserConnector.getInstance().getBedrockServer().getBindAddress());
+ for (Class extends BaseTranslator> translatorClass : getRegisteredTranslators()) {
+ try {
+ server.registerTranslator(translatorClass);
+ getLogger().debug("Registered Translator: " + translatorClass.getSimpleName());
+ } catch (TranslatorException e) {
+ getLogger().error(String.format("Unable to register Translator: %s", translatorClass.getName()), e);
+ }
+ }
+
+ GeyserConnector.getInstance().getBedrockServer().close();
+ bedrockServer.set(GeyserConnector.getInstance(), server);
+
+ } catch (NoSuchFieldException | IllegalAccessException e) {
+ getLogger().error(String.format("Unable to set Edition '%s'. Plugin disabled.", config.getEdition()), e);
+ }
+
+ GeyserConnector.getInstance().getBedrockServer().bind().whenComplete((avoid, throwable) -> {
+ if (throwable != null) {
+ getLogger().severe(LanguageUtils.getLocaleStringLog("geyser.core.fail", address.getAddress().toString(), address.getPort()));
+ throwable.printStackTrace();
+ }
+ }).join();
+ }
+}
diff --git a/geyser-reversion/src/main/java/au/com/grieve/geyser/reversion/api/Edition.java b/geyser-reversion/src/main/java/au/com/grieve/geyser/reversion/api/Edition.java
new file mode 100644
index 0000000..fad2546
--- /dev/null
+++ b/geyser-reversion/src/main/java/au/com/grieve/geyser/reversion/api/Edition.java
@@ -0,0 +1,27 @@
+/*
+ * EduSupport - Minecraft Protocol Support for MultiVersion in Geyser
+ * Copyright (C) 2020 GeyserReversion Developers
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package au.com.grieve.geyser.reversion.api;
+
+import au.com.grieve.reversion.ReversionServer;
+
+import java.net.InetSocketAddress;
+
+public interface Edition {
+ ReversionServer createReversionServer(InetSocketAddress address);
+}
diff --git a/geyser-reversion/src/main/java/au/com/grieve/geyser/reversion/config/Configuration.java b/geyser-reversion/src/main/java/au/com/grieve/geyser/reversion/config/Configuration.java
new file mode 100644
index 0000000..d856b2c
--- /dev/null
+++ b/geyser-reversion/src/main/java/au/com/grieve/geyser/reversion/config/Configuration.java
@@ -0,0 +1,44 @@
+/*
+ * EduSupport - Minecraft Protocol Support for MultiVersion in Geyser
+ * Copyright (C) 2020 GeyserReversion Developers
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package au.com.grieve.geyser.reversion.config;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
+import lombok.Getter;
+
+import java.io.File;
+import java.io.IOException;
+
+@Getter
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Configuration {
+ private int version;
+
+ private String edition;
+
+ public static Configuration loadFromFile(File configFile) {
+ ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
+ try {
+ return mapper.readValue(configFile, Configuration.class);
+ } catch (IOException e) {
+ return new Configuration();
+ }
+ }
+}
diff --git a/geyser-reversion/src/main/java/au/com/grieve/geyser/reversion/editions/bedrock/BedrockEdition.java b/geyser-reversion/src/main/java/au/com/grieve/geyser/reversion/editions/bedrock/BedrockEdition.java
new file mode 100644
index 0000000..be5326f
--- /dev/null
+++ b/geyser-reversion/src/main/java/au/com/grieve/geyser/reversion/editions/bedrock/BedrockEdition.java
@@ -0,0 +1,43 @@
+/*
+ * EduSupport - Minecraft Protocol Support for MultiVersion in Geyser
+ * Copyright (C) 2020 GeyserReversion Developers
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package au.com.grieve.geyser.reversion.editions.bedrock;
+
+import au.com.grieve.geyser.reversion.api.Edition;
+import au.com.grieve.geyser.reversion.editions.bedrock.handlers.BedrockServerEventHandler;
+import au.com.grieve.reversion.ReversionServer;
+import au.com.grieve.reversion.editions.bedrock.BedrockReversionServer;
+import lombok.RequiredArgsConstructor;
+import org.geysermc.connector.GeyserConnector;
+import org.geysermc.connector.network.BedrockProtocol;
+import org.geysermc.connector.plugin.GeyserPlugin;
+
+import java.net.InetSocketAddress;
+
+@RequiredArgsConstructor
+public class BedrockEdition implements Edition {
+ private final GeyserPlugin plugin;
+
+ @Override
+ public ReversionServer createReversionServer(InetSocketAddress address) {
+ plugin.getLogger().info("BedrockServer listening on " + address.toString());
+ ReversionServer server = new BedrockReversionServer("bedrock", BedrockProtocol.DEFAULT_BEDROCK_CODEC.getProtocolVersion(), address);
+ server.setHandler(new BedrockServerEventHandler(GeyserConnector.getInstance()));
+ return server;
+ }
+}
diff --git a/geyser-reversion/src/main/java/au/com/grieve/geyser/reversion/editions/bedrock/handlers/BedrockServerEventHandler.java b/geyser-reversion/src/main/java/au/com/grieve/geyser/reversion/editions/bedrock/handlers/BedrockServerEventHandler.java
new file mode 100644
index 0000000..77ec2eb
--- /dev/null
+++ b/geyser-reversion/src/main/java/au/com/grieve/geyser/reversion/editions/bedrock/handlers/BedrockServerEventHandler.java
@@ -0,0 +1,42 @@
+/*
+ * EduSupport - Minecraft Protocol Support for MultiVersion in Geyser
+ * Copyright (C) 2020 GeyserReversion Developers
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package au.com.grieve.geyser.reversion.editions.bedrock.handlers;
+
+import au.com.grieve.reversion.ReversionServerSession;
+import com.nukkitx.protocol.bedrock.BedrockServerSession;
+import lombok.Getter;
+import org.geysermc.connector.GeyserConnector;
+import org.geysermc.connector.network.ConnectorServerEventHandler;
+import org.geysermc.connector.network.session.GeyserSession;
+
+@Getter
+public class BedrockServerEventHandler extends ConnectorServerEventHandler {
+ private final GeyserConnector connector;
+
+ public BedrockServerEventHandler(GeyserConnector connector) {
+ super(connector);
+ this.connector = connector;
+ }
+
+ @Override
+ public void onSessionCreation(BedrockServerSession bedrockServerSession) {
+ bedrockServerSession.setLogging(true);
+ bedrockServerSession.setPacketHandler(new BedrockUpstreamPacketHandler((ReversionServerSession) bedrockServerSession, this.connector, new GeyserSession(this.connector, bedrockServerSession)));
+ }
+}
diff --git a/geyser-reversion/src/main/java/au/com/grieve/geyser/reversion/editions/bedrock/handlers/BedrockUpstreamPacketHandler.java b/geyser-reversion/src/main/java/au/com/grieve/geyser/reversion/editions/bedrock/handlers/BedrockUpstreamPacketHandler.java
new file mode 100644
index 0000000..b9e9d87
--- /dev/null
+++ b/geyser-reversion/src/main/java/au/com/grieve/geyser/reversion/editions/bedrock/handlers/BedrockUpstreamPacketHandler.java
@@ -0,0 +1,79 @@
+/*
+ * EduSupport - Minecraft Protocol Support for MultiVersion in Geyser
+ * Copyright (C) 2020 GeyserReversion Developers
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package au.com.grieve.geyser.reversion.editions.bedrock.handlers;
+
+import au.com.grieve.reversion.LoginData;
+import au.com.grieve.reversion.ReversionServerSession;
+import com.nukkitx.protocol.bedrock.BedrockPacketCodec;
+import com.nukkitx.protocol.bedrock.packet.LoginPacket;
+import com.nukkitx.protocol.bedrock.packet.PlayStatusPacket;
+import com.nukkitx.protocol.bedrock.packet.ResourcePacksInfoPacket;
+import com.nukkitx.protocol.bedrock.packet.ServerToClientHandshakePacket;
+import org.geysermc.connector.GeyserConnector;
+import org.geysermc.connector.network.BedrockProtocol;
+import org.geysermc.connector.network.UpstreamPacketHandler;
+import org.geysermc.connector.network.session.GeyserSession;
+import org.geysermc.connector.utils.LanguageUtils;
+
+
+public class BedrockUpstreamPacketHandler extends UpstreamPacketHandler {
+ private final ReversionServerSession serverSession;
+
+ public BedrockUpstreamPacketHandler(ReversionServerSession serverSession, GeyserConnector connector, GeyserSession session) {
+ super(connector, session);
+ this.serverSession = serverSession;
+ }
+
+ @Override
+ public boolean handle(LoginPacket loginPacket) {
+ // Check that we support the codec
+ BedrockPacketCodec packetCodec = BedrockProtocol.getBedrockCodec(loginPacket.getProtocolVersion());
+ if (packetCodec == null) {
+ if (loginPacket.getProtocolVersion() > BedrockProtocol.DEFAULT_BEDROCK_CODEC.getProtocolVersion()) {
+ this.session.disconnect(LanguageUtils.getLocaleStringLog("geyser.network.outdated.server", BedrockProtocol.DEFAULT_BEDROCK_CODEC.getMinecraftVersion()));
+ return true;
+ }
+
+ if (loginPacket.getProtocolVersion() < BedrockProtocol.DEFAULT_BEDROCK_CODEC.getProtocolVersion()) {
+ this.session.disconnect(LanguageUtils.getLocaleStringLog("geyser.network.outdated.client", BedrockProtocol.DEFAULT_BEDROCK_CODEC.getMinecraftVersion()));
+ return true;
+ }
+ }
+
+ // Encrypt Connection
+ serverSession.enableEncryption(serverSession.getLoginData().getEncryptionKey());
+
+ try {
+ ServerToClientHandshakePacket packet = new ServerToClientHandshakePacket();
+ packet.setJwt(serverSession.getLoginData().getHandshakeJwt().serialize());
+ session.sendUpstreamPacketImmediately(packet);
+ } catch (LoginData.LoginException e) {
+ session.disconnect("disconnectionScreen.internalError.cantConnect");
+ session.getConnector().getLogger().error("Failed to encrypt connection", e);
+ }
+
+ PlayStatusPacket playStatus = new PlayStatusPacket();
+ playStatus.setStatus(PlayStatusPacket.Status.LOGIN_SUCCESS);
+ session.sendUpstreamPacket(playStatus);
+
+ ResourcePacksInfoPacket resourcePacksInfo = new ResourcePacksInfoPacket();
+ session.sendUpstreamPacket(resourcePacksInfo);
+ return true;
+ }
+}
diff --git a/geyser-reversion/src/main/java/au/com/grieve/geyser/reversion/editions/education/EducationEdition.java b/geyser-reversion/src/main/java/au/com/grieve/geyser/reversion/editions/education/EducationEdition.java
new file mode 100644
index 0000000..36ac275
--- /dev/null
+++ b/geyser-reversion/src/main/java/au/com/grieve/geyser/reversion/editions/education/EducationEdition.java
@@ -0,0 +1,65 @@
+/*
+ * EduSupport - Minecraft Protocol Support for MultiVersion in Geyser
+ * Copyright (C) 2020 GeyserReversion Developers
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package au.com.grieve.geyser.reversion.editions.education;
+
+import au.com.grieve.geyser.reversion.api.Edition;
+import au.com.grieve.geyser.reversion.editions.bedrock.handlers.BedrockServerEventHandler;
+import au.com.grieve.geyser.reversion.editions.education.commands.EducationCommand;
+import au.com.grieve.reversion.ReversionServer;
+import au.com.grieve.reversion.editions.education.EducationReversionServer;
+import au.com.grieve.reversion.editions.education.utils.TokenManager;
+import lombok.Getter;
+import org.geysermc.connector.GeyserConnector;
+import org.geysermc.connector.event.annotations.GeyserEventHandler;
+import org.geysermc.connector.event.events.geyser.GeyserStartEvent;
+import org.geysermc.connector.network.BedrockProtocol;
+import org.geysermc.connector.plugin.GeyserPlugin;
+
+import java.io.File;
+import java.net.InetSocketAddress;
+
+@Getter
+public class EducationEdition implements Edition {
+ private final GeyserPlugin plugin;
+ private final TokenManager tokenManager;
+
+ public EducationEdition(GeyserPlugin plugin) {
+ this.plugin = plugin;
+
+ this.tokenManager = new TokenManager(new File(plugin.getDataFolder(), "tokens.yml"));
+
+ // Register Events
+ plugin.registerEvents(this);
+ }
+
+ @GeyserEventHandler
+ public void onGeyserStart(GeyserStartEvent event) {
+ // Register Education command
+ GeyserConnector.getInstance().getBootstrap().getGeyserCommandManager().registerCommand(
+ new EducationCommand("education", "Education Commands", "geyser.command.education", this));
+ }
+
+ @Override
+ public ReversionServer createReversionServer(InetSocketAddress address) {
+ plugin.getLogger().info("EducationServer listening on " + address.toString());
+ ReversionServer server = new EducationReversionServer("bedrock", BedrockProtocol.DEFAULT_BEDROCK_CODEC.getProtocolVersion(), tokenManager, address);
+ server.setHandler(new BedrockServerEventHandler(GeyserConnector.getInstance()));
+ return server;
+ }
+}
diff --git a/geyser-reversion/src/main/java/au/com/grieve/geyser/reversion/editions/education/commands/EducationCommand.java b/geyser-reversion/src/main/java/au/com/grieve/geyser/reversion/editions/education/commands/EducationCommand.java
new file mode 100644
index 0000000..845df04
--- /dev/null
+++ b/geyser-reversion/src/main/java/au/com/grieve/geyser/reversion/editions/education/commands/EducationCommand.java
@@ -0,0 +1,79 @@
+/*
+ * EduSupport - Minecraft Protocol Support for MultiVersion in Geyser
+ * Copyright (C) 2020 GeyserReversion Developers
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package au.com.grieve.geyser.reversion.editions.education.commands;
+
+import au.com.grieve.geyser.reversion.editions.education.EducationEdition;
+import au.com.grieve.reversion.editions.education.utils.TokenManager;
+import org.geysermc.connector.command.CommandSender;
+import org.geysermc.connector.command.GeyserCommand;
+import org.geysermc.connector.common.ChatColor;
+
+public class EducationCommand extends GeyserCommand {
+
+ private final EducationEdition edition;
+
+ public EducationCommand(String name, String description, String permission, EducationEdition edition) {
+ super(name, description, permission);
+ this.edition = edition;
+ }
+
+ private void showHelp(CommandSender sender) {
+ sender.sendMessage("---- Education SubCommands ----");
+ sender.sendMessage(ChatColor.YELLOW + "/education new" + ChatColor.WHITE + " - Create new Authorization URL");
+ sender.sendMessage(ChatColor.YELLOW + "/education confirm" + ChatColor.WHITE + " - Confirm an Authorization Response");
+ sender.sendMessage("");
+ sender.sendMessage("Use '" + ChatColor.YELLOW + "new" + ChatColor.WHITE + "' to generate a URL that you copy into your browser.");
+ sender.sendMessage("This will allow you to log into your MCEE account. Once done you will have a white page with a URL both in");
+ sender.sendMessage("its title as well as address bar. Copy the full address and provide it as a parameter to '" + ChatColor.YELLOW + "confirm" + ChatColor.WHITE + "'.");
+ }
+
+ @Override
+ public void execute(CommandSender sender, String[] args) {
+ if (!sender.isConsole()) {
+ return;
+ }
+
+ if (args.length == 0) {
+ showHelp(sender);
+ return;
+ }
+
+ switch (args[0].toLowerCase()) {
+ case "new":
+ sender.sendMessage("Copy and paste the following into your web browser:");
+ sender.sendMessage("");
+ sender.sendMessage(" " + ChatColor.YELLOW + edition.getTokenManager().getNewAuthorizationUrl().toString());
+ break;
+ case "confirm":
+ if (args.length < 2) {
+ sender.sendMessage("Missing parameter");
+ return;
+ }
+ try {
+ edition.getTokenManager().createInitialToken(args[1]);
+ } catch (TokenManager.TokenException e) {
+ sender.sendMessage("Error: " + e.getMessage());
+ }
+ sender.sendMessage("Successfully created new token");
+ break;
+ default:
+ showHelp(sender);
+ }
+ }
+}
diff --git a/geyser-reversion/src/main/resources/config.yml b/geyser-reversion/src/main/resources/config.yml
new file mode 100644
index 0000000..6b8fa85
--- /dev/null
+++ b/geyser-reversion/src/main/resources/config.yml
@@ -0,0 +1,5 @@
+# Edition supported. One of [bedrock, education]. Default: bedrock
+edition: education
+
+# Don't touch
+version: 1
\ No newline at end of file
diff --git a/mkdocs.yml b/mkdocs.yml
index ef7de52..5304cd7 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -1,11 +1,11 @@
-site_name: EduSupport
+site_name: GeyserReversion
site_author: Bundabrg
-site_url: https://github.com/Bundabrg/EduSupport
+site_url: https://github.com/Bundabrg/GeyserReversion
site_dir: build/docs
-repo_name: Bundabrg/EduSupport
-repo_url: https://github.com/Bundabrg/EduSupport
+repo_name: Bundabrg/GeyserReversion
+repo_url: https://github.com/Bundabrg/GeyserReversion
edit_uri: ""
-copyright: 'Copyright (C) 2020 EduSupport Developers'
+copyright: 'Copyright (C) 2020 GeyserReversion Developers'
extra_css:
- 'css/mkpdf.css'
@@ -59,13 +59,13 @@ plugins:
- exclude:
glob:
- 'theme/*'
- - git-revision-date-localized:
- type: timeago
- - mkpdfs:
- author: EduSupport Developers
- toc_title: Table of contents
- output_path: pdf/documentation.pdf
- design: docs/css/pdf.css
+# - git-revision-date-localized:
+# type: timeago
+# - mkpdfs:
+# author: GeyserReversion Developers
+# toc_title: Table of contents
+# output_path: pdf/documentation.pdf
+# design: docs/css/pdf.css
# Discord not yet supported but it will be soon
#extra:
diff --git a/pom.xml b/pom.xml
index 75a88ee..cb8db49 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,7 +1,7 @@
11org.apache.maven.plugins
- maven-shade-plugin
- 3.2.3
-
-
- package
-
- shade
-
-
-
+ maven-resources-plugin
+ 3.1.0
-
-
- au.com.grieve.bcf
- ${project.groupId}.${project.artifactId}.bcf
-
-
+
+ dat
+
@@ -105,15 +99,9 @@
1.18.2provided
-
-
- org.geysermc
- connector
- 1.1.0-SNAPSHOT
- provided
-
+
bundabrg-repo
diff --git a/requirements.txt b/requirements.txt
index be09120..a0d3602 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -2,6 +2,6 @@ mkdocs==1.1
mkdocs-exclude==1.0.2
mkdocs-material==5.1.3
#mkpdfs-mkdocs==1.0.1
-git+https://github.com/jwaschkau/mkpdfs-mkdocs-plugin.git@fix/string-types
+# git+https://github.com/jwaschkau/mkpdfs-mkdocs-plugin.git@fix/string-types
mkdocs-git-revision-date-localized-plugin==0.5.0
diff --git a/src/main/java/au/com/grieve/edusupport/EduSupportPlugin.java b/src/main/java/au/com/grieve/edusupport/EduSupportPlugin.java
deleted file mode 100644
index c0b54dd..0000000
--- a/src/main/java/au/com/grieve/edusupport/EduSupportPlugin.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * EduSupport - Minecraft Educational Support for Geyser
- * Copyright (C) 2020 EduSupport Developers
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package au.com.grieve.edusupport;
-
-import org.geysermc.connector.event.annotations.Event;
-import org.geysermc.connector.event.events.PluginDisableEvent;
-import org.geysermc.connector.event.events.PluginEnableEvent;
-import org.geysermc.connector.plugin.GeyserPlugin;
-import org.geysermc.connector.plugin.PluginClassLoader;
-import org.geysermc.connector.plugin.PluginManager;
-import org.geysermc.connector.plugin.annotations.Plugin;
-
-@Plugin(
- name = "EduSupport",
- version = "1.1.0-dev",
- authors = {"Bundabrg"},
- description = "Provides protocol support for Minecraft Educational Edition"
-)
-public class EduSupportPlugin extends GeyserPlugin {
-
- public EduSupportPlugin(PluginManager pluginManager, PluginClassLoader pluginClassLoader) {
- super(pluginManager, pluginClassLoader);
- }
-
- @Event
- public void onEnable(PluginEnableEvent event) {
- System.err.println("I'm alive");
- }
-
- @Event
- public void onDisable(PluginDisableEvent event) {
- System.err.println("I'm dead");
- }
-}