drop in callEvent(PlayerFishingEvent) and mcmmo treasure

Discussion in 'Plugin Development' started by BatemanBR, Jan 6, 2020.

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

    BatemanBR

    I am trying to call PlayerFishingEvent, but this one doesn't drop item

    I put to manually add the fish to the inventory, so everything was ok, but now the problem is that mcmmo does not reward with its treasures despite receiving the xp in mcmmo and minecraft xp

    I asked the mcmo developers and he said:
    This version of mcmmo no longer contains the kraken, so Wrong repo;
    But, the caller of the event gives the item to the player, mcmmo just manipulates the item inside the event

    look my code

    Code:
        @EventHandler
        public void chance(PlayerInteractEvent e) {
            final Player p = e.getPlayer();
    
            if (p.getItemInHand().getType() == Material.FISHING_ROD) {
         
                for(Entity et : p.getWorld().getEntities())  {
             
                    if(et.getType() == EntityType.FISHING_HOOK) {
                        CraftFish fish =   (CraftFish) et;
                     
                        EntityFishingHook eth = fish.getHandle();
                        EntityHuman ehuman = eth.owner;
                        if(ehuman.getName().equals(p.getName())) {
                            if(et.getLocation().getBlock().getType() == Material.STATIONARY_WATER) {
    
                        final int chance = 50;
                        p.sendMessage("PlayerInteractEvent com Fishing_ROD no Cursor");
                        if((Math.random() * 100) <= chance) {
                            p.sendMessage("VocĂȘ pescou");
                       
    net.minecraft.server.v1_9_R2.ItemStack it = new net.minecraft.server.v1_9_R2.ItemStack(Item.getById(349),1,0);
    
    EntityItem entityitem = new EntityItem(MinecraftServer.getServer().getWorld());
    entityitem.setItemStack(it);
    
    Entity caugthFishBEntity = entityitem.getBukkitEntity();
    
    eth.world.addEntity(entityitem);
    fish.setTicksLived(500);
    
    Entity caugthFishBEntity = entityitem.getBukkitEntity();
    PlayerFishEvent pfe1 = new PlayerFishEvent(p, caugthFishBEntity, fish, PlayerFishEvent.State.BITE);
    getServer().getPluginManager().callEvent(pfe1);
    
    
    pfe.setExpToDrop(6);
    p.getInventory().addItem(new ItemStack(Material.RAW_FISH,1,(short)1));
    
     
    Last edited: Jan 6, 2020
Thread Status:
Not open for further replies.

Share This Page