Merge pull request #4 from MylesIsCool/master

Merge from master
This commit is contained in:
HugoDaBosss 2016-03-03 12:17:06 +01:00
commit 5e34fda7e4
5 changed files with 36 additions and 19 deletions

10
ISSUE_TEMPLATE.md Normal file
View File

@ -0,0 +1,10 @@
### What version of ViaVersion are you using? Type /ver viaversion
### What version of Spigot are you using? Type /ver
### What plugins are you using? /plugins
### How does this error happen? login? using an item?
### Is there an error in the console? Use pastebin.com. Is there a kick message?

View File

@ -34,6 +34,10 @@ Contributors:
**Paulomart**
**gigosaurus**
**Chat: ** https://gitter.im/MylesIsCool/ViaVersion
We use it to collaborate and solve errors, sign in with github.
License:
--------
@ -41,3 +45,5 @@ You may modify this work, all rights are still owned by myself excluding any fil
Thanks!

View File

@ -8,7 +8,6 @@ import us.myles.ViaVersion.ConnectionInfo;
import us.myles.ViaVersion.transformers.IncomingTransformer;
import us.myles.ViaVersion.util.PacketUtil;
import java.nio.channels.ClosedChannelException;
import java.util.List;
public class ViaDecodeHandler extends ByteToMessageDecoder {
@ -45,15 +44,10 @@ public class ViaDecodeHandler extends ByteToMessageDecoder {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
if (!(cause.getCause().getCause() instanceof CancelException)
&& !(cause.getCause().getCause() instanceof ClosedChannelException)) {
if (!(cause.getCause() instanceof CancelException)
&& !(cause.getCause() instanceof ClosedChannelException)) {
if (!(cause instanceof CancelException)
&& !(cause instanceof ClosedChannelException)) {
if (cause instanceof Exception){
cause.printStackTrace();
}
if (!(cause.getCause().getCause() instanceof CancelException)) {
if (!(cause.getCause() instanceof CancelException)) {
if (!(cause instanceof CancelException)) {
super.exceptionCaught(ctx, cause);
}
}
}

View File

@ -72,14 +72,10 @@ public class ViaEncodeHandler extends MessageToByteEncoder {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
if (!(cause.getCause().getCause() instanceof CancelException)
&& !(cause.getCause().getCause() instanceof ClosedChannelException)) {
if (!(cause.getCause() instanceof CancelException)
&& !(cause.getCause() instanceof ClosedChannelException)) {
if (!(cause instanceof CancelException)
&& !(cause instanceof ClosedChannelException)) {
if (cause instanceof Exception)
cause.printStackTrace();
if (!(cause.getCause().getCause() instanceof CancelException)) {
if (!(cause.getCause() instanceof CancelException)) {
if (!(cause instanceof CancelException)) {
super.exceptionCaught(ctx, cause);
}
}
}

View File

@ -2,10 +2,14 @@ package us.myles.ViaVersion.transformers;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import io.netty.buffer.ByteBuf;
import org.bukkit.entity.EntityType;
import org.json.simple.parser.JSONParser;
import org.spacehq.mc.protocol.data.game.chunk.Column;
import org.spacehq.mc.protocol.util.NetUtil;
import us.myles.ViaVersion.CancelException;
import us.myles.ViaVersion.ConnectionInfo;
import us.myles.ViaVersion.ViaVersionPlugin;
@ -492,6 +496,13 @@ public class OutgoingTransformer {
if (line.startsWith("\""))
line = "{\"text\":" + line + "}";
}
try {
new JSONParser().parse(line);
}
catch (org.json.simple.parser.ParseException e) {
System.out.println("Invalid JSON String: \"" + line + "\" Please report this issue to the ViaVersion Github!");
return "{\"text\":\"\"}";
}
return line;
}