Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-26 00:00:28 +01:00
Fix books, also makes ItemSlotRewriter.ItemStack fields public
Dieser Commit ist enthalten in:
Ursprung
cb4a8b24d4
Commit
963f021226
@ -122,6 +122,7 @@ public class ItemSlotRewriter {
|
|||||||
public static ItemStack readItemStack(ByteBuf input) throws IOException {
|
public static ItemStack readItemStack(ByteBuf input) throws IOException {
|
||||||
short id = input.readShort();
|
short id = input.readShort();
|
||||||
if (id < 0) {
|
if (id < 0) {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
ItemStack item = new ItemStack();
|
ItemStack item = new ItemStack();
|
||||||
@ -146,10 +147,10 @@ public class ItemSlotRewriter {
|
|||||||
|
|
||||||
public static class ItemStack {
|
public static class ItemStack {
|
||||||
|
|
||||||
private short id;
|
public short id;
|
||||||
private byte amount;
|
public byte amount;
|
||||||
private short data;
|
public short data;
|
||||||
private CompoundTag tag;
|
public CompoundTag tag;
|
||||||
|
|
||||||
public static ItemStack fromBukkit(org.bukkit.inventory.ItemStack stack) {
|
public static ItemStack fromBukkit(org.bukkit.inventory.ItemStack stack) {
|
||||||
ItemStack item = new ItemStack();
|
ItemStack item = new ItemStack();
|
||||||
|
@ -1,7 +1,13 @@
|
|||||||
package us.myles.ViaVersion.transformers;
|
package us.myles.ViaVersion.transformers;
|
||||||
|
|
||||||
|
import com.avaje.ebeaninternal.server.cluster.Packet;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import io.netty.buffer.Unpooled;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.spacehq.opennbt.tag.builtin.ListTag;
|
||||||
|
import org.spacehq.opennbt.tag.builtin.StringTag;
|
||||||
|
import org.spacehq.opennbt.tag.builtin.Tag;
|
||||||
import us.myles.ViaVersion.CancelException;
|
import us.myles.ViaVersion.CancelException;
|
||||||
import us.myles.ViaVersion.ConnectionInfo;
|
import us.myles.ViaVersion.ConnectionInfo;
|
||||||
import us.myles.ViaVersion.ViaVersionPlugin;
|
import us.myles.ViaVersion.ViaVersionPlugin;
|
||||||
@ -11,8 +17,10 @@ import us.myles.ViaVersion.packets.State;
|
|||||||
import us.myles.ViaVersion.util.PacketUtil;
|
import us.myles.ViaVersion.util.PacketUtil;
|
||||||
import us.myles.ViaVersion.util.ReflectionUtil;
|
import us.myles.ViaVersion.util.ReflectionUtil;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
public class IncomingTransformer {
|
public class IncomingTransformer {
|
||||||
private final ConnectionInfo info;
|
private final ConnectionInfo info;
|
||||||
@ -171,6 +179,26 @@ public class IncomingTransformer {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(packet == PacketType.PLAY_PLUGIN_MESSAGE_REQUEST) {
|
||||||
|
String name = PacketUtil.readString(input);
|
||||||
|
PacketUtil.writeString(name, output);
|
||||||
|
byte[] b = new byte[input.readableBytes()];
|
||||||
|
input.readBytes(b);
|
||||||
|
// patch books
|
||||||
|
if(name.equals("MC|BSign")){
|
||||||
|
ByteBuf in = Unpooled.wrappedBuffer(b);
|
||||||
|
try {
|
||||||
|
ItemSlotRewriter.ItemStack stack = ItemSlotRewriter.readItemStack(in);
|
||||||
|
stack.id = (short) Material.WRITTEN_BOOK.getId();
|
||||||
|
// write
|
||||||
|
ItemSlotRewriter.writeItemStack(stack, output);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
output.writeBytes(b);
|
||||||
|
}
|
||||||
if (packet == PacketType.PLAY_PLAYER_BLOCK_PLACEMENT) {
|
if (packet == PacketType.PLAY_PLAYER_BLOCK_PLACEMENT) {
|
||||||
Long position = input.readLong();
|
Long position = input.readLong();
|
||||||
output.writeLong(position);
|
output.writeLong(position);
|
||||||
|
@ -1,20 +1,25 @@
|
|||||||
package us.myles.ViaVersion.transformers;
|
package us.myles.ViaVersion.transformers;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import io.netty.buffer.Unpooled;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
import org.json.simple.parser.JSONParser;
|
import org.json.simple.parser.JSONParser;
|
||||||
import org.json.simple.parser.ParseException;
|
import org.json.simple.parser.ParseException;
|
||||||
import org.spacehq.mc.protocol.data.game.chunk.Column;
|
import org.spacehq.mc.protocol.data.game.chunk.Column;
|
||||||
import org.spacehq.mc.protocol.util.NetUtil;
|
import org.spacehq.mc.protocol.util.NetUtil;
|
||||||
|
import org.spacehq.opennbt.tag.builtin.ListTag;
|
||||||
|
import org.spacehq.opennbt.tag.builtin.StringTag;
|
||||||
|
import org.spacehq.opennbt.tag.builtin.Tag;
|
||||||
import us.myles.ViaVersion.CancelException;
|
import us.myles.ViaVersion.CancelException;
|
||||||
import us.myles.ViaVersion.ConnectionInfo;
|
import us.myles.ViaVersion.ConnectionInfo;
|
||||||
import us.myles.ViaVersion.ViaVersionPlugin;
|
import us.myles.ViaVersion.ViaVersionPlugin;
|
||||||
import us.myles.ViaVersion.api.ViaVersion;
|
import us.myles.ViaVersion.api.ViaVersion;
|
||||||
import us.myles.ViaVersion.slot.ItemSlotRewriter;
|
|
||||||
import us.myles.ViaVersion.metadata.MetadataRewriter;
|
import us.myles.ViaVersion.metadata.MetadataRewriter;
|
||||||
import us.myles.ViaVersion.packets.PacketType;
|
import us.myles.ViaVersion.packets.PacketType;
|
||||||
import us.myles.ViaVersion.packets.State;
|
import us.myles.ViaVersion.packets.State;
|
||||||
|
import us.myles.ViaVersion.slot.ItemSlotRewriter;
|
||||||
import us.myles.ViaVersion.sounds.SoundEffect;
|
import us.myles.ViaVersion.sounds.SoundEffect;
|
||||||
import us.myles.ViaVersion.util.EntityUtil;
|
import us.myles.ViaVersion.util.EntityUtil;
|
||||||
import us.myles.ViaVersion.util.PacketUtil;
|
import us.myles.ViaVersion.util.PacketUtil;
|
||||||
@ -96,6 +101,17 @@ public class OutgoingTransformer {
|
|||||||
output.writeInt(vehicle);
|
output.writeInt(vehicle);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (packet == PacketType.PLAY_PLUGIN_MESSAGE) {
|
||||||
|
String name = PacketUtil.readString(input);
|
||||||
|
PacketUtil.writeString(name, output);
|
||||||
|
byte[] b = new byte[input.readableBytes()];
|
||||||
|
input.readBytes(b);
|
||||||
|
// patch books
|
||||||
|
if(name.equals("MC|BOpen")){
|
||||||
|
PacketUtil.writeVarInt(0, output);
|
||||||
|
}
|
||||||
|
output.writeBytes(b);
|
||||||
|
}
|
||||||
if (packet == PacketType.PLAY_DISCONNECT) {
|
if (packet == PacketType.PLAY_DISCONNECT) {
|
||||||
String reason = readString(input);
|
String reason = readString(input);
|
||||||
writeString(fixJson(reason), output);
|
writeString(fixJson(reason), output);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren