Search in sources :

Example 1 with PacketPlayOutSetSlot

use of net.minecraft.network.protocol.game.PacketPlayOutSetSlot in project Panilla by ds58.

the class PacketInspector method checkPacketPlayOutSetSlot.

@Override
public void checkPacketPlayOutSetSlot(Object _packet) throws NbtNotPermittedException {
    if (_packet instanceof PacketPlayOutSetSlot) {
        PacketPlayOutSetSlot packet = (PacketPlayOutSetSlot) _packet;
        try {
            Field windowIdField = PacketPlayOutSetSlot.class.getDeclaredField("c");
            windowIdField.setAccessible(true);
            int windowId = (int) windowIdField.get(packet);
            // check if window is not player inventory and we are ignoring non-player inventories
            if (windowId != 0 && panilla.getPConfig().ignoreNonPlayerInventories) {
                return;
            }
            Field slotField = PacketPlayOutSetSlot.class.getDeclaredField("e");
            Field itemStackField = PacketPlayOutSetSlot.class.getDeclaredField("f");
            slotField.setAccessible(true);
            itemStackField.setAccessible(true);
            int slot = (int) slotField.get(packet);
            ItemStack itemStack = (ItemStack) itemStackField.get(packet);
            if (itemStack == null || !itemStack.s()) {
                return;
            }
            NbtTagCompound tag = new NbtTagCompound(itemStack.t());
            String itemClass = itemStack.getClass().getSimpleName();
            String packetClass = packet.getClass().getSimpleName();
            NbtChecks.checkPacketPlayOut(slot, tag, itemClass, packetClass, panilla);
        } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
            e.printStackTrace();
        }
    }
}
Also used : Field(java.lang.reflect.Field) NbtTagCompound(com.ruinscraft.panilla.craftbukkit.v1_18_R2.nbt.NbtTagCompound) INbtTagCompound(com.ruinscraft.panilla.api.nbt.INbtTagCompound) PacketPlayOutSetSlot(net.minecraft.network.protocol.game.PacketPlayOutSetSlot) ItemStack(net.minecraft.world.item.ItemStack)

Example 2 with PacketPlayOutSetSlot

use of net.minecraft.network.protocol.game.PacketPlayOutSetSlot in project Panilla by ds58.

the class PacketInspector method checkPacketPlayOutSetSlot.

@Override
public void checkPacketPlayOutSetSlot(Object _packet) throws NbtNotPermittedException {
    if (_packet instanceof PacketPlayOutSetSlot) {
        PacketPlayOutSetSlot packet = (PacketPlayOutSetSlot) _packet;
        try {
            Field windowIdField = PacketPlayOutSetSlot.class.getDeclaredField("c");
            windowIdField.setAccessible(true);
            int windowId = (int) windowIdField.get(packet);
            // check if window is not player inventory and we are ignoring non-player inventories
            if (windowId != 0 && panilla.getPConfig().ignoreNonPlayerInventories) {
                return;
            }
            Field slotField = PacketPlayOutSetSlot.class.getDeclaredField("e");
            Field itemStackField = PacketPlayOutSetSlot.class.getDeclaredField("f");
            slotField.setAccessible(true);
            itemStackField.setAccessible(true);
            int slot = (int) slotField.get(packet);
            ItemStack itemStack = (ItemStack) itemStackField.get(packet);
            if (itemStack == null || !itemStack.hasTag())
                return;
            NbtTagCompound tag = new NbtTagCompound(itemStack.getTag());
            String itemClass = itemStack.getClass().getSimpleName();
            String packetClass = packet.getClass().getSimpleName();
            NbtChecks.checkPacketPlayOut(slot, tag, itemClass, packetClass, panilla);
        } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
            e.printStackTrace();
        }
    }
}
Also used : Field(java.lang.reflect.Field) INbtTagCompound(com.ruinscraft.panilla.api.nbt.INbtTagCompound) NbtTagCompound(com.ruinscraft.panilla.craftbukkit.v1_17_R1.nbt.NbtTagCompound) PacketPlayOutSetSlot(net.minecraft.network.protocol.game.PacketPlayOutSetSlot) ItemStack(net.minecraft.world.item.ItemStack)

Example 3 with PacketPlayOutSetSlot

use of net.minecraft.network.protocol.game.PacketPlayOutSetSlot in project wordle by HypoxTeam.

the class PacketHandler1_18_1_R0_1 method setFakeItem.

@Override
public void setFakeItem(Player player, byte windowID, int slot, ItemStack item) {
    CraftPlayer craftPlayer = (CraftPlayer) player;
    EntityPlayer entityHuman = craftPlayer.getHandle();
    PacketPlayOutSetSlot packet = new PacketPlayOutSetSlot(windowID, entityHuman.bW.j(), slot, CraftItemStack.asNMSCopy(item));
    entityHuman.b.a(packet);
}
Also used : EntityPlayer(net.minecraft.server.level.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer) PacketPlayOutSetSlot(net.minecraft.network.protocol.game.PacketPlayOutSetSlot)

Example 4 with PacketPlayOutSetSlot

use of net.minecraft.network.protocol.game.PacketPlayOutSetSlot in project wordle by HypoxTeam.

the class PacketHandler1_18_2_R0_1 method setFakeItem.

@Override
public void setFakeItem(Player player, byte windowID, int slot, ItemStack item) {
    CraftPlayer craftPlayer = (CraftPlayer) player;
    EntityPlayer entityHuman = craftPlayer.getHandle();
    PacketPlayOutSetSlot packet = new PacketPlayOutSetSlot(windowID, entityHuman.bV.j(), slot, CraftItemStack.asNMSCopy(item));
    entityHuman.b.a(packet);
}
Also used : EntityPlayer(net.minecraft.server.level.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer) PacketPlayOutSetSlot(net.minecraft.network.protocol.game.PacketPlayOutSetSlot)

Example 5 with PacketPlayOutSetSlot

use of net.minecraft.network.protocol.game.PacketPlayOutSetSlot in project Panilla by ds58.

the class PacketInspector method checkPacketPlayOutSetSlot.

@Override
public void checkPacketPlayOutSetSlot(Object _packet) throws NbtNotPermittedException {
    if (_packet instanceof PacketPlayOutSetSlot) {
        PacketPlayOutSetSlot packet = (PacketPlayOutSetSlot) _packet;
        try {
            Field windowIdField = PacketPlayOutSetSlot.class.getDeclaredField("c");
            windowIdField.setAccessible(true);
            int windowId = (int) windowIdField.get(packet);
            // check if window is not player inventory and we are ignoring non-player inventories
            if (windowId != 0 && panilla.getPConfig().ignoreNonPlayerInventories) {
                return;
            }
            Field slotField = PacketPlayOutSetSlot.class.getDeclaredField("e");
            Field itemStackField = PacketPlayOutSetSlot.class.getDeclaredField("f");
            slotField.setAccessible(true);
            itemStackField.setAccessible(true);
            int slot = (int) slotField.get(packet);
            ItemStack itemStack = (ItemStack) itemStackField.get(packet);
            if (itemStack == null || !itemStack.r())
                return;
            NbtTagCompound tag = new NbtTagCompound(itemStack.s());
            String itemClass = itemStack.getClass().getSimpleName();
            String packetClass = packet.getClass().getSimpleName();
            NbtChecks.checkPacketPlayOut(slot, tag, itemClass, packetClass, panilla);
        } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
            e.printStackTrace();
        }
    }
}
Also used : Field(java.lang.reflect.Field) NbtTagCompound(com.ruinscraft.panilla.craftbukkit.v1_18_R1.nbt.NbtTagCompound) INbtTagCompound(com.ruinscraft.panilla.api.nbt.INbtTagCompound) PacketPlayOutSetSlot(net.minecraft.network.protocol.game.PacketPlayOutSetSlot) ItemStack(net.minecraft.world.item.ItemStack)

Aggregations

PacketPlayOutSetSlot (net.minecraft.network.protocol.game.PacketPlayOutSetSlot)6 INbtTagCompound (com.ruinscraft.panilla.api.nbt.INbtTagCompound)3 Field (java.lang.reflect.Field)3 EntityPlayer (net.minecraft.server.level.EntityPlayer)3 ItemStack (net.minecraft.world.item.ItemStack)3 NbtTagCompound (com.ruinscraft.panilla.craftbukkit.v1_17_R1.nbt.NbtTagCompound)1 NbtTagCompound (com.ruinscraft.panilla.craftbukkit.v1_18_R1.nbt.NbtTagCompound)1 NbtTagCompound (com.ruinscraft.panilla.craftbukkit.v1_18_R2.nbt.NbtTagCompound)1 CraftPlayer (org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer)1 CraftPlayer (org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer)1 CraftPlayer (org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer)1