3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-12-25 07:40:08 +01:00

Basic support for multiplatform ViaBackwards (Bungee doesn't seem to work correctly yet)

Dieser Commit ist enthalten in:
Matsv 2016-10-03 15:20:38 +02:00
Ursprung 305cc5514a
Commit a21bd3acec
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 97CEC2A2EA31350F
34 geänderte Dateien mit 414 neuen und 87 gelöschten Zeilen

3
.gitignore vendored
Datei anzeigen

@ -1,6 +1,7 @@
# Created by .ignore support plugin (hsz.mobi)
### Maven template
target/
*/target
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
@ -78,6 +79,8 @@ local.properties
.idea/tasks.xml
.idea/dictionaries
.idea/vcs.xml
.idea/
*.iml
.idea/jsLibraryMappings.xml
# Sensitive or high-churn files:

75
all/pom.xml Normale Datei
Datei anzeigen

@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>1.0.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>viabackwards-all</artifactId>
<build>
<finalName>${project.name}-${project.version}</finalName>
<defaultGoal>clean install</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<showWarnings>false</showWarnings>
<showDeprecation>false</showDeprecation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<minimizeJar>false</minimizeJar>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>nl.matsv</groupId>
<artifactId>viabackwards-core</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>nl.matsv</groupId>
<artifactId>viabackwards-bukkit</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>nl.matsv</groupId>
<artifactId>viabackwards-bungee</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>nl.matsv</groupId>
<artifactId>viabackwards-sponge</artifactId>
<version>${project.parent.version}</version>
</dependency>
</dependencies>
</project>

47
bukkit/pom.xml Normale Datei
Datei anzeigen

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>1.0.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>viabackwards-bukkit</artifactId>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.10.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>nl.matsv</groupId>
<artifactId>viabackwards-core</artifactId>
<version>1.0.1</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<targetPath>.</targetPath>
<filtering>true</filtering>
<directory>src/main/resources/</directory>
<includes>
<include>*</include>
</includes>
</resource>
</resources>
</build>
</project>

Datei anzeigen

@ -0,0 +1,10 @@
package nl.matsv.viabackwards;
import org.bukkit.plugin.java.JavaPlugin;
public class BukkitPlugin extends JavaPlugin implements ViaBackwardsPlatform {
@Override
public void onEnable() {
this.init();
}
}

Datei anzeigen

@ -1,6 +1,6 @@
name: ViaBackwards
version: ${project.version}
main: nl.matsv.viabackwards.ViaBackwards
main: nl.matsv.viabackwards.BukkitPlugin
description: Allow
authors: [Matsv]

40
bungee/pom.xml Normale Datei
Datei anzeigen

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>1.0.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>viabackwards-bungee</artifactId>
<repositories>
<!-- Bungee repo -->
<repository>
<id>bungeecord-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
</repositories>
<dependencies>
<!-- BungeeCord API -->
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<version>1.10-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- Core Module -->
<dependency>
<groupId>nl.matsv</groupId>
<artifactId>viabackwards-core</artifactId>
<version>${project.parent.version}</version>
</dependency>
</dependencies>
</project>

Datei anzeigen

@ -0,0 +1,11 @@
package nl.matsv.viabackwards;
import net.md_5.bungee.api.plugin.Plugin;
public class BungeePlugin extends Plugin implements ViaBackwardsPlatform {
@Override
public void onEnable() {
this.init();
}
}

Datei anzeigen

@ -0,0 +1,5 @@
name: ViaBackwards
main: nl.matsv.viabackwards.BungeePlugin
author: Matsv
version: ${project.version}
depends: [ViaVersion]

33
core/pom.xml Normale Datei
Datei anzeigen

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>1.0.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>viabackwards-core</artifactId>
<repositories>
<repository>
<id>viaversion-repo</id>
<url>https://repo.viaversion.com/</url>
</repository>
</repositories>
<dependencies>
<!-- Netty (Network Library) -->
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.0.20.Final</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
</dependencies>
</project>

Datei anzeigen

@ -0,0 +1,15 @@
package nl.matsv.viabackwards;
import com.google.common.base.Preconditions;
import lombok.Getter;
public class ViaBackwards {
@Getter
private static ViaBackwardsPlatform platform;
public static void init(ViaBackwardsPlatform platform) {
Preconditions.checkArgument(platform != null, "ViaBackwards is already initialized");
ViaBackwards.platform = platform;
}
}

Datei anzeigen

@ -19,17 +19,25 @@
package nl.matsv.viabackwards;
import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9To1_10;
import org.bukkit.plugin.java.JavaPlugin;
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
import java.util.Collections;
import java.util.logging.Logger;
public class ViaBackwards extends JavaPlugin {
@Override
public void onEnable() {
// Register the protocol
public interface ViaBackwardsPlatform {
/**
* Initialize ViaBackwards
*/
default void init() {
ViaBackwards.init(this);
ProtocolRegistry.registerProtocol(new Protocol1_9To1_10(), Collections.singletonList(ProtocolVersion.v1_9_3.getId()), ProtocolVersion.v1_10.getId());
}
/**
* Logger provided by the platform
*
* @return logger instance
*/
Logger getLogger();
}

Datei anzeigen

@ -19,12 +19,12 @@
package nl.matsv.viabackwards.api.rewriters;
import lombok.RequiredArgsConstructor;
import nl.matsv.viabackwards.ViaBackwards;
import nl.matsv.viabackwards.api.BackwardsProtocol;
import nl.matsv.viabackwards.api.MetaRewriter;
import nl.matsv.viabackwards.api.exceptions.RemovedValueException;
import nl.matsv.viabackwards.api.storage.EntityTracker;
import nl.matsv.viabackwards.api.storage.EntityType;
import org.bukkit.Bukkit;
import us.myles.ViaVersion.api.ViaVersion;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
@ -112,7 +112,7 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Rewrit
} catch (RemovedValueException ignored) {
} catch (Exception e) {
if (ViaVersion.getInstance().isDebug()) {
Logger log = Bukkit.getPluginManager().getPlugin("ViaBackwards").getLogger();
Logger log = ViaBackwards.getPlatform().getLogger();
log.warning("Unable to handle metadata " + md);
log.warning("Full metadata list " + metaData);
e.printStackTrace();

Datei anzeigen

@ -20,8 +20,7 @@ package nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.chunks;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.apache.commons.lang.IllegalClassException;
import org.bukkit.World;
import us.myles.ViaVersion.api.minecraft.Environment;
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
import us.myles.ViaVersion.api.type.PartialType;
@ -65,7 +64,7 @@ public class Chunk1_10Type extends PartialType<Chunk, ClientWorld> {
sections[i] = section;
section.readBlocks(input);
section.readBlockLight(input);
if (world.getEnvironment() == World.Environment.NORMAL) {
if (world.getEnvironment() == Environment.NORMAL) {
section.readSkyLight(input);
}
}
@ -83,7 +82,7 @@ public class Chunk1_10Type extends PartialType<Chunk, ClientWorld> {
@Override
public void write(ByteBuf output, ClientWorld world, Chunk input) throws Exception {
if (!(input instanceof Chunk1_10))
throw new IllegalClassException("Tried to send the wrong chunk type from 1.9.3-4 chunk: " + input.getClass());
throw new Exception("Tried to send the wrong chunk type from 1.9.3-4 chunk: " + input.getClass());
Chunk1_10 chunk = (Chunk1_10) input;
output.writeInt(chunk.getX());

Datei anzeigen

@ -26,6 +26,7 @@ import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.chunks.ChunkSection1_1
import nl.matsv.viabackwards.utils.Block;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_9;
import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type;
@ -245,7 +246,7 @@ public class BlockItemPackets extends BlockItemRewriter<Protocol1_9To1_10> {
/* Register Metadata */
protocol.getEntityPackets().registerMetaRewriter((isObject, entityType, data) -> {
if (data.getTypeID() == 5) // Is Item
if (data.getMetaType().equals(MetaType1_9.Slot)) // Is Item
data.setValue(handleItemToClient((Item) data.getValue()));
return data;

Datei anzeigen

@ -23,13 +23,13 @@ import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
import nl.matsv.viabackwards.api.storage.EntityTracker;
import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9To1_10;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_9;
import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.api.type.types.version.Types1_9;
import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.metadata.NewType;
public class EntityPackets extends EntityRewriter<Protocol1_9To1_10> {
@ -331,8 +331,7 @@ public class EntityPackets extends EntityRewriter<Protocol1_9To1_10> {
boolean b = (boolean) data.getValue();
data.setId(13);
data.setType(Type.BYTE);
data.setTypeID(NewType.Byte.getTypeID());
data.setMetaType(MetaType1_9.Byte);
data.setValue(b ? (byte) (14 & 0x0F) : 0);
}
return data;
@ -343,7 +342,7 @@ public class EntityPackets extends EntityRewriter<Protocol1_9To1_10> {
if (isObject || entityType != 54)
return data;
if (data.getId() == 13 && data.getTypeID() == 1 && (int) data.getValue() == 6)
if (data.getId() == 13 && data.getMetaType().getTypeID() == 1 && (int) data.getValue() == 6)
data.setValue(0);
return data;
});
@ -353,7 +352,7 @@ public class EntityPackets extends EntityRewriter<Protocol1_9To1_10> {
if (isObject || entityType != 51)
return data;
if (data.getId() == 12 && data.getTypeID() == 1 && (int) data.getValue() == 2)
if (data.getId() == 12 && data.getMetaType().getTypeID() == 1 && (int) data.getValue() == 2)
data.setValue(0);
return data;
});

103
pom.xml
Datei anzeigen

@ -23,40 +23,32 @@
<modelVersion>4.0.0</modelVersion>
<groupId>nl.matsv</groupId>
<artifactId>viabackwards</artifactId>
<artifactId>viabackwards-parent</artifactId>
<packaging>pom</packaging>
<version>1.0.1</version>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>viaversion-repo</id>
<url>https://repo.viaversion.com/</url>
</repository>
</repositories>
<description>Allow newer clients to join older server versions.</description>
<inceptionYear>2016</inceptionYear>
<url>https://www.spigotmc.org/resources/viaversion.19254/</url>
<modules>
<module>core</module>
<module>bukkit</module>
<module>bungee</module>
<module>sponge</module>
<module>all</module>
</modules>
<properties>
<!-- Project Properties -->
<projectEncoding>UTF-8</projectEncoding>
<project.build.sourceEncoding>${projectEncoding}</project.build.sourceEncoding>
<project.build.outputEncoding>${projectEncoding}</project.build.outputEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.10.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>us.myles</groupId>
<artifactId>viaversion</artifactId>
<version>0.9.8-SNAPSHOT</version>
</dependency>
<!-- Netty (Network Library) -->
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.0.20.Final</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<!-- Lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
@ -64,43 +56,18 @@
<version>1.16.6</version>
<scope>provided</scope>
</dependency>
<!-- Guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>19.0</version>
</dependency>
<!--ViaVersion -->
<dependency>
<groupId>us.myles</groupId>
<artifactId>viaversion</artifactId>
<version>1.0.0-ALPHA-modules</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.name}-${project.version}</finalName>
<sourceDirectory>src/main/java</sourceDirectory>
<defaultGoal>clean install</defaultGoal>
<resources>
<resource>
<targetPath>.</targetPath>
<filtering>false</filtering>
<directory>.</directory>
<includes>
<include>LICENSE</include>
</includes>
</resource>
<resource>
<targetPath>.</targetPath>
<filtering>true</filtering>
<directory>src/main/resources/</directory>
<includes>
<include>*</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<showWarnings>false</showWarnings>
<showDeprecation>false</showDeprecation>
</configuration>
</plugin>
</plugins>
</build>
</project>

73
sponge/pom.xml Normale Datei
Datei anzeigen

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>1.0.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>viabackwards-sponge</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>sponge-maven-repo</id>
<name>Sponge maven repo</name>
<url>http://repo.spongepowered.org/maven</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>
<!-- Sponge API -->
<dependency>
<groupId>org.spongepowered</groupId>
<artifactId>spongeapi</artifactId>
<version>LATEST</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

Datei anzeigen

@ -0,0 +1,5 @@
package nl.matsv.viabackwards.sponge;
public class VersionInfo {
public static final String VERSION = "${project.version}";
}

Datei anzeigen

@ -0,0 +1,36 @@
package nl.matsv.viabackwards;
import com.google.inject.Inject;
import nl.matsv.viabackwards.sponge.VersionInfo;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.game.state.GameAboutToStartServerEvent;
import org.spongepowered.api.plugin.Dependency;
import org.spongepowered.api.plugin.Plugin;
import org.spongepowered.api.plugin.PluginContainer;
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 SpongePlugin implements ViaBackwardsPlatform {
private Logger logger;
@Inject
private PluginContainer container;
@Listener
public void onServerStart(GameAboutToStartServerEvent e) {
// Setup Logger
this.logger = new LoggerWrapper(container.getLogger());
}
@Override
public Logger getLogger() {
return logger;
}
}