3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-09 17:50:23 +01:00

Add additional information when packets aren't sent correctly.

Dieser Commit ist enthalten in:
Myles 2016-03-30 15:58:31 +01:00
Ursprung 93755c6732
Commit 1872845d2b
7 geänderte Dateien mit 30 neuen und 10 gelöschten Zeilen

Datei anzeigen

@ -52,7 +52,7 @@ public class PacketWrapper {
} }
Exception e = new ArrayIndexOutOfBoundsException("Could not find type " + type.getTypeName() + " at " + index); Exception e = new ArrayIndexOutOfBoundsException("Could not find type " + type.getTypeName() + " at " + index);
throw new InformativeException(e).set("Type", type.getTypeName()).set("Index", index).set("Packet ID", getId()); throw new InformativeException(e).set("Type", type.getTypeName()).set("Index", index).set("Packet ID", getId()).set("Data", packetValues);
} }
/** /**
@ -92,7 +92,7 @@ public class PacketWrapper {
try { try {
return type.read(inputBuffer); return type.read(inputBuffer);
} catch (Exception e) { } catch (Exception e) {
throw new InformativeException(e).set("Type", type.getTypeName()).set("Packet ID", getId()); throw new InformativeException(e).set("Type", type.getTypeName()).set("Packet ID", getId()).set("Data", packetValues);
} }
} else { } else {
Pair<Type, Object> read = readableObjects.poll(); Pair<Type, Object> read = readableObjects.poll();
@ -103,7 +103,7 @@ public class PacketWrapper {
return read(type); // retry return read(type); // retry
} else { } else {
Exception e = new IOException("Unable to read type " + type.getTypeName() + ", found " + read.getKey().getTypeName()); Exception e = new IOException("Unable to read type " + type.getTypeName() + ", found " + read.getKey().getTypeName());
throw new InformativeException(e).set("Type", type.getTypeName()).set("Packet ID", getId()); throw new InformativeException(e).set("Type", type.getTypeName()).set("Packet ID", getId()).set("Data", packetValues);
} }
} }
} }
@ -172,7 +172,7 @@ public class PacketWrapper {
} }
packetValue.getKey().write(buffer, value); packetValue.getKey().write(buffer, value);
} catch (Exception e) { } catch (Exception e) {
throw new InformativeException(e).set("Index", index).set("Type", packetValue.getKey().getTypeName()).set("Packet ID", getId()); throw new InformativeException(e).set("Index", index).set("Type", packetValue.getKey().getTypeName()).set("Packet ID", getId()).set("Data", packetValues);
} }
index++; index++;
} }

Datei anzeigen

@ -3,12 +3,10 @@ package us.myles.ViaVersion.api;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.ToString;
@Getter @Getter
@Setter @Setter
@EqualsAndHashCode @EqualsAndHashCode
@ToString
public class Pair<X, Y> { public class Pair<X, Y> {
private X key; private X key;
private Y value; private Y value;
@ -17,4 +15,9 @@ public class Pair<X, Y> {
this.key = key; this.key = key;
this.value = value; this.value = value;
} }
@Override
public String toString() {
return "Pair{" + key + ", " + value + '}';
}
} }

Datei anzeigen

@ -2,9 +2,11 @@ package us.myles.ViaVersion.api.minecraft;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import lombok.ToString;
@AllArgsConstructor @AllArgsConstructor
@Getter @Getter
@ToString
public class Position { public class Position {
private Long x; private Long x;
private Long y; private Long y;

Datei anzeigen

@ -2,9 +2,11 @@ package us.myles.ViaVersion.api.minecraft.chunks;
import lombok.Getter; import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.ToString;
@RequiredArgsConstructor @RequiredArgsConstructor
@Getter @Getter
@ToString
public class Chunk { public class Chunk {
private final int x; private final int x;
private final int z; private final int z;

Datei anzeigen

@ -1,9 +1,6 @@
package us.myles.ViaVersion.api.minecraft.item; package us.myles.ViaVersion.api.minecraft.item;
import lombok.AllArgsConstructor; import lombok.*;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.spacehq.opennbt.tag.builtin.CompoundTag; import org.spacehq.opennbt.tag.builtin.CompoundTag;
@ -11,6 +8,7 @@ import org.spacehq.opennbt.tag.builtin.CompoundTag;
@Setter @Setter
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@ToString
public class Item { public class Item {
private short id; private short id;
private byte amount; private byte amount;

Datei anzeigen

@ -13,4 +13,14 @@ public class Metadata {
private int typeID; private int typeID;
private Type type; private Type type;
private Object value; private Object value;
@Override
public String toString() {
return "Metadata{" +
"id=" + id +
", typeID=" + typeID +
", type=" + type +
", value=" + value +
'}';
}
} }

Datei anzeigen

@ -77,4 +77,9 @@ public abstract class Type<T> implements ByteBufReader<T>, ByteBufWriter<T> {
this.outputClass = outputClass; this.outputClass = outputClass;
this.typeName = typeName; this.typeName = typeName;
} }
@Override
public String toString() {
return "Type|" + getTypeName();
}
} }