(ProtocolLib) How do I cancel Item drop?

Discussion in 'Plugin Development' started by rfsantos1996, Jul 17, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    rfsantos1996

    For damage effects, I'm using item drops, but with this code, I use dropItemNaturally because I couldn't use PacketWrapper to spawn Items (due needs of generating Entity ID and somethings like that).

    I'm trying to deny the drop from spawning for the player using:
    Code:java
    1. pl.getProtocolManager().addPacketListener(new PacketAdapter(pl, PacketType.Play.Server.SPAWN_ENTITY) {
    2. @Override
    3. public void onPacketSending(PacketEvent event) {
    4. Jogador jogador = CustomServer.getJogador(event.getPlayer());
    5. WrapperPlayServerSpawnEntity spawnEntity = new WrapperPlayServerSpawnEntity(event.getPacket());
    6. pl.getLogger().info("Effects: " + (jogador.getStats().isReceivingEffects()) + " Contains? " + (itemEffectQueue.containsItem(spawnEntity.getEntityID())));
    7. if(itemEffectQueue.containsItem(spawnEntity.getEntityID()) && !jogador.getStats().isReceivingEffects()) {
    8. event.setCancelled(true);
    9. pl.getLogger().info("Cancelled");
    10. }
    11. }
    12. });

    I know the entity ID is wrong, but the Item's ID isn't the entity ID?

    @EDIT: the packet is sent before I add it to the list. Any idea on how to workarround?
     
  2. Offline

    Aventium

    Ummm....why not just use Bukkit's event? Lot easier than dealing with packets....
     
  3. Offline

    rfsantos1996

    I want people who don't want effects to not see the items, I already use events so people won't get the item dropped.
     
Thread Status:
Not open for further replies.

Share This Page