mirror of
https://github.com/ViaVersion/ViaBackwards.git
synced 2024-12-20 16:37:48 +01:00
🔥 Merge branch 'master' of https://github.com/Matsv/ViaBackwards into dev
# Conflicts: # core/src/main/java/nl/matsv/viabackwards/api/ViaBackwardsPlatform.java
This commit is contained in:
commit
99ffbc1bfa
@ -81,5 +81,11 @@
|
|||||||
<artifactId>viabackwards-sponge</artifactId>
|
<artifactId>viabackwards-sponge</artifactId>
|
||||||
<version>${project.parent.version}</version>
|
<version>${project.parent.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>nl.matsv</groupId>
|
||||||
|
<artifactId>viabackwards-velocity</artifactId>
|
||||||
|
<version>${project.parent.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
@ -22,8 +22,8 @@ import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.Protocol1_13To1_13_1;
|
|||||||
import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1_10;
|
import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1_10;
|
||||||
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
||||||
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
|
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
|
||||||
|
import us.myles.ViaVersion.update.Version;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@ -54,21 +54,22 @@ public interface ViaBackwardsPlatform {
|
|||||||
*/
|
*/
|
||||||
Logger getLogger();
|
Logger getLogger();
|
||||||
|
|
||||||
// TODO remove or better implement later
|
|
||||||
default boolean isOutdated() {
|
default boolean isOutdated() {
|
||||||
|
String minimumVVVersion = "2.0.0";
|
||||||
boolean upToDate = false;
|
boolean upToDate = false;
|
||||||
try {
|
try {
|
||||||
Class<?> clazz = Class.forName("us.myles.ViaVersion.api.protocol.ProtocolVersion");
|
Class<?> vvVersionInfo = Class.forName("us.myles.ViaVersion.sponge.VersionInfo");
|
||||||
Field v1_13 = clazz.getField("v1_13");
|
String vvVersion = (String) vvVersionInfo.getField("VERSION").get(null);
|
||||||
|
|
||||||
upToDate = (v1_13 != null);
|
upToDate = (vvVersion != null
|
||||||
} catch (ClassNotFoundException | NoSuchFieldException ignored) {
|
&& new Version(vvVersion).compareTo(new Version(minimumVVVersion + "--")) >= 0);
|
||||||
|
} catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException ignored) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!upToDate) {
|
if (!upToDate) {
|
||||||
getLogger().severe("================================");
|
getLogger().severe("================================");
|
||||||
getLogger().severe("YOUR VIAVERSION IS OUTDATED");
|
getLogger().severe("YOUR VIAVERSION IS OUTDATED");
|
||||||
getLogger().severe("PLEASE USE THE LATEST VERSION");
|
getLogger().severe("PLEASE USE VIAVERSION " + minimumVVVersion + " OR NEWER");
|
||||||
getLogger().severe("LINK: https://viaversion.com");
|
getLogger().severe("LINK: https://viaversion.com");
|
||||||
getLogger().severe("VIABACKWARDS WILL NOW DISABLE");
|
getLogger().severe("VIABACKWARDS WILL NOW DISABLE");
|
||||||
getLogger().severe("================================");
|
getLogger().severe("================================");
|
||||||
|
1
pom.xml
1
pom.xml
@ -28,6 +28,7 @@
|
|||||||
<module>bukkit</module>
|
<module>bukkit</module>
|
||||||
<module>bungee</module>
|
<module>bungee</module>
|
||||||
<module>sponge</module>
|
<module>sponge</module>
|
||||||
|
<module>velocity</module>
|
||||||
<module>all</module>
|
<module>all</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
|
@ -11,14 +11,14 @@
|
|||||||
package nl.matsv.viabackwards;
|
package nl.matsv.viabackwards;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
import lombok.Getter;
|
||||||
import nl.matsv.viabackwards.api.ViaBackwardsPlatform;
|
import nl.matsv.viabackwards.api.ViaBackwardsPlatform;
|
||||||
import nl.matsv.viabackwards.sponge.VersionInfo;
|
import nl.matsv.viabackwards.sponge.VersionInfo;
|
||||||
import org.spongepowered.api.event.Listener;
|
import org.spongepowered.api.event.Listener;
|
||||||
import org.spongepowered.api.event.Order;
|
import org.spongepowered.api.event.Order;
|
||||||
import org.spongepowered.api.event.game.state.GameAboutToStartServerEvent;
|
import org.spongepowered.api.event.game.state.GameInitializationEvent;
|
||||||
import org.spongepowered.api.plugin.Dependency;
|
import org.spongepowered.api.plugin.Dependency;
|
||||||
import org.spongepowered.api.plugin.Plugin;
|
import org.spongepowered.api.plugin.Plugin;
|
||||||
import org.spongepowered.api.plugin.PluginContainer;
|
|
||||||
import us.myles.ViaVersion.sponge.util.LoggerWrapper;
|
import us.myles.ViaVersion.sponge.util.LoggerWrapper;
|
||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@ -31,26 +31,21 @@ import java.util.logging.Logger;
|
|||||||
dependencies = {@Dependency(id = "viaversion")}
|
dependencies = {@Dependency(id = "viaversion")}
|
||||||
)
|
)
|
||||||
public class SpongePlugin implements ViaBackwardsPlatform {
|
public class SpongePlugin implements ViaBackwardsPlatform {
|
||||||
|
@Getter
|
||||||
private Logger logger;
|
private Logger logger;
|
||||||
@Inject
|
@Inject
|
||||||
private PluginContainer container;
|
private org.slf4j.Logger loggerSlf4j;
|
||||||
|
|
||||||
@Listener(order = Order.LATE)
|
@Listener(order = Order.LATE)
|
||||||
public void onServerStart(GameAboutToStartServerEvent e) {
|
public void onGameStart(GameInitializationEvent e) {
|
||||||
// Setup Logger
|
// Setup Logger
|
||||||
this.logger = new LoggerWrapper(container.getLogger());
|
this.logger = new LoggerWrapper(loggerSlf4j);
|
||||||
// Init!
|
// Init!
|
||||||
this.init();
|
this.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Logger getLogger() {
|
|
||||||
return logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO check how to for sponge, site was offline
|
|
||||||
@Override
|
@Override
|
||||||
public void disable() {
|
public void disable() {
|
||||||
|
// Not possible
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
83
velocity/pom.xml
Normal file
83
velocity/pom.xml
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
~ 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>viabackwards-parent</artifactId>
|
||||||
|
<groupId>nl.matsv</groupId>
|
||||||
|
<version>2.4.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>viabackwards-velocity</artifactId>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<targetPath>.</targetPath>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
<directory>src/main/resources/</directory>
|
||||||
|
<includes>
|
||||||
|
<include>*</include>
|
||||||
|
</includes>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
<!-- Stolen from ViaVersion ;) -->
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>templating-maven-plugin</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>filter-src</id>
|
||||||
|
<goals>
|
||||||
|
<goal>filter-sources</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>velocity-maven-repo</id>
|
||||||
|
<name>Velocity maven repo</name>
|
||||||
|
<url>https://repo.velocitypowered.com/snapshots/</url>
|
||||||
|
<releases>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<!-- Common Module -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>nl.matsv</groupId>
|
||||||
|
<artifactId>viabackwards-core</artifactId>
|
||||||
|
<version>${project.parent.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Velocity API -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.velocitypowered</groupId>
|
||||||
|
<artifactId>velocity-api</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
@ -0,0 +1,15 @@
|
|||||||
|
/*
|
||||||
|
* 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.velocity;
|
||||||
|
|
||||||
|
public class VersionInfo {
|
||||||
|
public static final String VERSION = "${project.version}";
|
||||||
|
}
|
@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* 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 com.google.inject.Inject;
|
||||||
|
import com.velocitypowered.api.event.PostOrder;
|
||||||
|
import com.velocitypowered.api.event.Subscribe;
|
||||||
|
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||||
|
import com.velocitypowered.api.plugin.Dependency;
|
||||||
|
import com.velocitypowered.api.plugin.Plugin;
|
||||||
|
import lombok.Getter;
|
||||||
|
import nl.matsv.viabackwards.api.ViaBackwardsPlatform;
|
||||||
|
import nl.matsv.viabackwards.velocity.VersionInfo;
|
||||||
|
import us.myles.ViaVersion.sponge.util.LoggerWrapper;
|
||||||
|
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
@Plugin(id = "viabackwards",
|
||||||
|
name = "ViaBackwards",
|
||||||
|
version = VersionInfo.VERSION,
|
||||||
|
authors = {"Matsv"},
|
||||||
|
description = "Allow older Minecraft versions to connect to an newer server version.",
|
||||||
|
dependencies = {@Dependency(id = "viaversion")}
|
||||||
|
)
|
||||||
|
public class VelocityPlugin implements ViaBackwardsPlatform {
|
||||||
|
@Getter
|
||||||
|
private Logger logger;
|
||||||
|
@Inject
|
||||||
|
private org.slf4j.Logger loggerSlf4j;
|
||||||
|
|
||||||
|
@Subscribe(order = PostOrder.LATE)
|
||||||
|
public void onProxyStart(ProxyInitializeEvent e) {
|
||||||
|
// Setup Logger
|
||||||
|
this.logger = new LoggerWrapper(loggerSlf4j);
|
||||||
|
// Init!
|
||||||
|
this.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disable() {
|
||||||
|
// Not possible
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user