From 3acba1b8e235fa44d9b81ad19039161a75482e78 Mon Sep 17 00:00:00 2001 From: creeper123123321 Date: Sun, 9 Jun 2019 12:23:25 -0300 Subject: [PATCH] ViaFabric platform --- all/pom.xml | 8 +- bukkit/src/main/resources/plugin.yml | 2 +- fabric/pom.xml | 62 +++++++++++++++ .../nl/matsv/viabackwards/ViaFabricAddon.java | 34 ++++++++ .../fabric/util/LoggerWrapper.java | 78 +++++++++++++++++++ fabric/src/main/resources/fabric.mod.json | 29 +++++++ pom.xml | 1 + .../nl/matsv/viabackwards/SpongePlugin.java | 2 +- .../nl/matsv/viabackwards/VelocityPlugin.java | 2 +- 9 files changed, 214 insertions(+), 4 deletions(-) create mode 100644 fabric/pom.xml create mode 100644 fabric/src/main/java/nl/matsv/viabackwards/ViaFabricAddon.java create mode 100644 fabric/src/main/java/nl/matsv/viabackwards/fabric/util/LoggerWrapper.java create mode 100644 fabric/src/main/resources/fabric.mod.json diff --git a/all/pom.xml b/all/pom.xml index 8aecf596..5982b98a 100644 --- a/all/pom.xml +++ b/all/pom.xml @@ -104,6 +104,12 @@ ${project.parent.version} + + nl.matsv + viabackwards-fabric + ${project.parent.version} + + nl.matsv viabackwards-sponge @@ -116,4 +122,4 @@ ${project.parent.version} - \ No newline at end of file + diff --git a/bukkit/src/main/resources/plugin.yml b/bukkit/src/main/resources/plugin.yml index 8dd6f4ba..20c3585f 100644 --- a/bukkit/src/main/resources/plugin.yml +++ b/bukkit/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: ViaBackwards version: ${project.version} -description: Allows 1.9.x on a 1.10 Spigot server +description: Allow older Minecraft versions to connect to a newer server version. main: nl.matsv.viabackwards.BukkitPlugin authors: [Matsv] diff --git a/fabric/pom.xml b/fabric/pom.xml new file mode 100644 index 00000000..24c5a2ee --- /dev/null +++ b/fabric/pom.xml @@ -0,0 +1,62 @@ + + + + + + viabackwards-parent + nl.matsv + 2.4.0-SNAPSHOT + + 4.0.0 + + viabackwards-fabric + + + + fabric-repo + https://maven.fabricmc.net/ + + + + + + net.fabricmc + fabric-loader + 0.4.8+build.154 + provided + + + org.apache.logging.log4j + log4j-api + 2.8.1 + + + nl.matsv + viabackwards-core + ${project.parent.version} + + + + + + + . + true + src/main/resources/ + + * + + + + + diff --git a/fabric/src/main/java/nl/matsv/viabackwards/ViaFabricAddon.java b/fabric/src/main/java/nl/matsv/viabackwards/ViaFabricAddon.java new file mode 100644 index 00000000..254d6d71 --- /dev/null +++ b/fabric/src/main/java/nl/matsv/viabackwards/ViaFabricAddon.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2016 Matsv + * + * 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. + */ + +package nl.matsv.viabackwards; + +import lombok.Getter; +import net.fabricmc.loader.api.FabricLoader; +import nl.matsv.viabackwards.api.ViaBackwardsPlatform; +import nl.matsv.viabackwards.fabric.util.LoggerWrapper; +import org.apache.logging.log4j.LogManager; + +import java.util.logging.Logger; + +public class ViaFabricAddon implements ViaBackwardsPlatform, Runnable { + @Getter + private final Logger logger = new LoggerWrapper(LogManager.getLogger("ViaRewind")); + + @Override + public void run() { + this.init(); + } + + @Override + public void disable() { + // Not possible + } +} diff --git a/fabric/src/main/java/nl/matsv/viabackwards/fabric/util/LoggerWrapper.java b/fabric/src/main/java/nl/matsv/viabackwards/fabric/util/LoggerWrapper.java new file mode 100644 index 00000000..e4b65e92 --- /dev/null +++ b/fabric/src/main/java/nl/matsv/viabackwards/fabric/util/LoggerWrapper.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2016 Matsv + * + * 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. + */ + +package nl.matsv.viabackwards.fabric.util; + +import java.text.MessageFormat; +import java.util.logging.Level; +import java.util.logging.LogRecord; +import java.util.logging.Logger; + +public class LoggerWrapper extends Logger { + private final org.apache.logging.log4j.Logger base; + + public LoggerWrapper(org.apache.logging.log4j.Logger logger) { + super("logger", null); + this.base = logger; + } + + public void log(LogRecord record) { + this.log(record.getLevel(), record.getMessage()); + } + + public void log(Level level, String msg) { + if (level == Level.FINE) { + this.base.debug(msg); + } else if (level == Level.WARNING) { + this.base.warn(msg); + } else if (level == Level.SEVERE) { + this.base.error(msg); + } else if (level == Level.INFO) { + this.base.info(msg); + } else { + this.base.trace(msg); + } + + } + + public void log(Level level, String msg, Object param1) { + if (level == Level.FINE) { + this.base.debug(msg, param1); + } else if (level == Level.WARNING) { + this.base.warn(msg, param1); + } else if (level == Level.SEVERE) { + this.base.error(msg, param1); + } else if (level == Level.INFO) { + this.base.info(msg, param1); + } else { + this.base.trace(msg, param1); + } + + } + + public void log(Level level, String msg, Object[] params) { + log(level, MessageFormat.format(msg, params)); + } + + public void log(Level level, String msg, Throwable params) { + if (level == Level.FINE) { + this.base.debug(msg, params); + } else if (level == Level.WARNING) { + this.base.warn(msg, params); + } else if (level == Level.SEVERE) { + this.base.error(msg, params); + } else if (level == Level.INFO) { + this.base.info(msg, params); + } else { + this.base.trace(msg, params); + } + + } +} diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json new file mode 100644 index 00000000..6f5120a7 --- /dev/null +++ b/fabric/src/main/resources/fabric.mod.json @@ -0,0 +1,29 @@ +{ + "schemaVersion": 1, + "id": "viabackwards", + "name": "ViaBackwards", + "version": "${project.version}", + "description": "Allow older Minecraft versions to connect to a newer server version.", + "license": "MIT", + "contact": { + "homepage": "https://github.com/ViaVersion/ViaBackwards", + "issues": "https://github.com/ViaVersion/ViaBackwards/issues", + "sources": "https://github.com/ViaVersion/ViaBackwards" + }, + "environment": "*", + "authors": [ + "Matsv" + ], + "entrypoints": { + "viafabric:via_api_initialized": [ + "nl.matsv.viabackwards.ViaFabricAddon" + ] + }, + "requires": { + "fabricloader": ">=0.4.0", + "viafabric": "*" + }, + "recommended": { + "viarewind": "*" + } +} diff --git a/pom.xml b/pom.xml index e01455df..e6db8b88 100644 --- a/pom.xml +++ b/pom.xml @@ -27,6 +27,7 @@ core bukkit bungee + fabric sponge velocity all diff --git a/sponge/src/main/java/nl/matsv/viabackwards/SpongePlugin.java b/sponge/src/main/java/nl/matsv/viabackwards/SpongePlugin.java index 090ea4df..f3c43287 100644 --- a/sponge/src/main/java/nl/matsv/viabackwards/SpongePlugin.java +++ b/sponge/src/main/java/nl/matsv/viabackwards/SpongePlugin.java @@ -27,7 +27,7 @@ import java.util.logging.Logger; name = "ViaBackwards", version = VersionInfo.VERSION, authors = {"Matsv"}, - description = "Allow older Minecraft versions to connect to an newer server version.", + description = "Allow older Minecraft versions to connect to a newer server version.", dependencies = {@Dependency(id = "viaversion")} ) public class SpongePlugin implements ViaBackwardsPlatform { diff --git a/velocity/src/main/java/nl/matsv/viabackwards/VelocityPlugin.java b/velocity/src/main/java/nl/matsv/viabackwards/VelocityPlugin.java index f20d6f58..5ff4691e 100644 --- a/velocity/src/main/java/nl/matsv/viabackwards/VelocityPlugin.java +++ b/velocity/src/main/java/nl/matsv/viabackwards/VelocityPlugin.java @@ -27,7 +27,7 @@ import java.util.logging.Logger; name = "ViaBackwards", version = VersionInfo.VERSION, authors = {"Matsv"}, - description = "Allow older Minecraft versions to connect to an newer server version.", + description = "Allow older Minecraft versions to connect to a newer server version.", dependencies = {@Dependency(id = "viaversion")} ) public class VelocityPlugin implements ViaBackwardsPlatform {