Compare commits

..
9 Commits
Author SHA1 Message Date
Myles ad3317f8d8 Update version number 2016-02-29 22:51:46 +00:00
Myles 3b480a61bd Correct boots so they display correctly 2016-02-29 22:48:29 +00:00
Myles c0296f04a1 Allow sharing of protocol packet handler and be more verbose to do with metaindex data 2016-02-29 22:43:53 +00:00
Myles 6f605e8d6c Fix signs correcting any json issues. 2016-02-29 21:27:17 +00:00
Myles a6cfcac675 Merge pull request #6 from Zbob750/master
Add Spigot's maven repo, so this is actually useful.
2016-02-29 20:50:07 +00:00
Zach Brown 8e717bb023 Add Spigot's maven repo, so this is actually useful 2016-02-29 14:38:54 -06:00
Myles e885a1cec2 Update version to 0.3, also fix issue with teams haha 2016-02-29 20:35:50 +00:00
Myles e2de17e221 Merge pull request #4 from StamBoom/master
Fix map crash (I was being stupid)
2016-02-29 20:32:21 +00:00
Mats 5738a992e5 Fix map crash 2016-02-29 21:26:02 +01:00
7 changed files with 66 additions and 33 deletions

No files matched your search

+5 -3
View File
@@ -1,9 +1,9 @@
# ViaVersion 0.2
# ViaVersion 0.3.1
**Allows the connection of 1.8 clients to 1.9**
This plugin modifies netty to allow connection of 1.9 clients to 1.8,
**Don't use late bind**
**Don't use late bind nor ProtocolLib**
**As of this point it doesn't have everything, I need to fix:**
@@ -11,6 +11,8 @@ Attempt to make boats nicer when they don't work
Remap spawn eggs
Some EntityMetadata is incorrect, fix this.
This took hours of work, so if you enjoy this consider looking into contacting me and supporting my projects.
@@ -25,7 +27,7 @@ Credits:
**Myself** (harhar)
**Matsv** (Movement Fix)
**Matsv** (Movement Fix / Correcting my stupidity)
License:
+7 -2
View File
@@ -45,5 +45,10 @@
<scope>provided</scope>
</dependency>
</dependencies>
</project>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
</project>
+4 -1
View File
@@ -24,7 +24,10 @@ public class Core extends JavaPlugin {
try {
injectPacketHandler();
} catch (Exception e) {
System.out.println("Unable to inject handlers, are you on 1.8?");
if(Bukkit.getPluginManager().getPlugin("ProtocolLib") != null){
System.out.println("This plugin is not compatible with protocol lib.");
}
System.out.println("Unable to inject handlers, are you on 1.8? ");
e.printStackTrace();
}
}
@@ -1,15 +1,13 @@
package us.myles.ViaVersion.handlers;
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOutboundHandlerAdapter;
import io.netty.channel.ChannelPromise;
import io.netty.channel.*;
import us.myles.ViaVersion.ConnectionInfo;
import us.myles.ViaVersion.ReflectionUtil;
import java.lang.reflect.Constructor;
@ChannelHandler.Sharable
public class ViaOutboundPacketHandler extends ChannelOutboundHandlerAdapter {
private final ConnectionInfo info;
@@ -171,7 +171,10 @@ public enum MetaIndex {
public static MetaIndex getIndex(EntityType type, int index) {
Class<? extends org.bukkit.entity.Entity> entityClass = type.getEntityClass();
if(entityClass == null){
System.out.println("Could not get entity class for " + type);
return null;
}
for (MetaIndex mi : MetaIndex.values()) {
if (mi.getIndex() == index) {
if (mi.getApplicableClass().isAssignableFrom(entityClass) ||
@@ -19,6 +19,7 @@ import us.myles.ViaVersion.packets.State;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.nio.charset.Charset;
import java.util.*;
public class OutgoingTransformer {
@@ -45,7 +46,7 @@ public class OutgoingTransformer {
if (packet == null) {
throw new RuntimeException("Outgoing Packet not found? " + packetID + " State: " + info.getState() + " Version: " + info.getProtocol());
}
// if (packet != PacketType.PLAY_CHUNK_DATA && packet != PacketType.PLAY_KEEP_ALIVE && packet != PacketType.PLAY_TIME_UPDATE && !packet.name().toLowerCase().contains("entity"))
// if (packet != PacketType.PLAY_CHUNK_DATA && packet != PacketType.PLAY_KEEP_ALIVE && packet != PacketType.PLAY_TIME_UPDATE && (!packet.name().toLowerCase().contains("move") && !packet.name().contains("look")))
// System.out.println("Packet Type: " + packet + " Original ID: " + packetID + " State:" + info.getState());
if (packet.getPacketID() != -1) {
packetID = packet.getNewPacketID();
@@ -157,7 +158,7 @@ public class OutgoingTransformer {
PacketUtil.writeVarInt(id, output);
short slot = input.readShort();
if (slot > 1) {
if (slot > 0) {
slot += 1; // add 1 so it's now 2-5
}
PacketUtil.writeVarInt(slot, output);
@@ -270,13 +271,18 @@ public class OutgoingTransformer {
}
return;
}
if(packet == PacketType.PLAY_UPDATE_SIGN){
if (packet == PacketType.PLAY_UPDATE_SIGN) {
Long location = input.readLong();
output.writeLong(location);
for(int i = 0;i<4;i++){
for (int i = 0; i < 4; i++) {
String line = PacketUtil.readString(input);
if(line.startsWith("\"")){
line = "{\"text\":" + line + "}";
if (line == null || line.equalsIgnoreCase("null")) {
line = "{\"text\":\"\"}";
} else {
if (!line.startsWith("\"") && !line.startsWith("{"))
line = "\"" + line + "\"";
if (line.startsWith("\""))
line = "{\"text\":" + line + "}";
}
PacketUtil.writeString(line, output);
}
@@ -317,16 +323,16 @@ public class OutgoingTransformer {
PacketUtil.writeVarInt(damage, output);
byte scale = input.readByte();
output.writeByte(scale);
input.readBoolean();
output.writeBoolean(true);
output.writeBytes(input);
return;
}
if(packet == PacketType.PLAY_TEAM) {
if (packet == PacketType.PLAY_TEAM) {
String teamName = PacketUtil.readString(input);
PacketUtil.writeString(teamName, output);
byte mode = input.readByte();
output.writeByte(mode);
if(mode == 0 || mode == 2){
if (mode == 0 || mode == 2) {
PacketUtil.writeString(PacketUtil.readString(input), output);
PacketUtil.writeString(PacketUtil.readString(input), output);
PacketUtil.writeString(PacketUtil.readString(input), output);
@@ -334,7 +340,7 @@ public class OutgoingTransformer {
output.writeByte(input.readByte());
PacketUtil.writeString(PacketUtil.readString(input), output);
PacketUtil.readString(input); // collission rule :)
PacketUtil.writeString("", output); // collission rule :)
}
output.writeBytes(input);
return;
@@ -414,15 +420,24 @@ public class OutgoingTransformer {
}
private void transformMetadata(Entity entity, List dw, ByteBuf output) {
try {
if (dw != null) {
short id = -1;
int data = -1;
if (dw != null) {
short id = -1;
int data = -1;
Iterator iterator = dw.iterator();
while (iterator.hasNext()) {
Object watchableObj = iterator.next(); //
MetaIndex metaIndex = MetaIndex.getIndex(entity, (int) ReflectionUtil.invoke(watchableObj, "a"));
Iterator iterator = dw.iterator();
while (iterator.hasNext()) {
Object watchableObj = iterator.next(); //
MetaIndex metaIndex = null;
try {
metaIndex = MetaIndex.getIndex(entity, (int) ReflectionUtil.invoke(watchableObj, "a"));
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
try {
if (metaIndex.getNewType() != NewType.Discontinued) {
if (metaIndex.getNewType() != NewType.BlockID || id != -1 && data == -1 || id == -1 && data != -1) { // block ID is only written if we have both parts
output.writeByte(metaIndex.getNewIndex());
@@ -501,13 +516,20 @@ public class OutgoingTransformer {
output.writeFloat((float) ReflectionUtil.invoke(value, "getY"));
output.writeFloat((float) ReflectionUtil.invoke(value, "getZ"));
}
}
} catch (Exception e) {
if (entity != null) {
System.out.println("An error occurred with entity meta data for " + entity.getType());
System.out.println("Old ID: " + metaIndex.getIndex() + " New ID: " + metaIndex.getNewIndex());
System.out.println("Old Type: " + metaIndex.getOldType() + " New Type: " + metaIndex.getNewType());
}
e.printStackTrace();
}
}
output.writeByte(255);
}catch(Exception e){
e.printStackTrace();
}
output.writeByte(255);
}
+1 -1
View File
@@ -1,4 +1,4 @@
name: ViaVersion
main: us.myles.ViaVersion.Core
author: _MylesC
version: 0.2
version: 0.3.1