Substring being transferred to Arrow/Snowball?

Discussion in 'Plugin Development' started by Slash9211, Sep 7, 2014.

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

    Slash9211

    Current code
    Code:java
    1. @EventHandler
    2. public void onEntityDamageByEntityArrow(EntityDamageByEntityEvent e) {
    3. Entity damager = e.getDamager();
    4.  
    5. if (e.getDamager() instanceof Arrow)
    6.  
    7. {
    8. final Arrow arrow = (Arrow) damager;
    9. Player p = (Player) arrow.getShooter();
    10. ItemStack i = ((Player) damager).getPlayer().getItemInHand();
    11.  
    12. if (i != null && i.hasItemMeta()) {
    13. for (String s : i.getItemMeta().getLore()) {
    14.  
    15. if (s.contains("DMG:")) {
    16. String dmgStr = s.substring(5);
    17. String dmgAmnt[] = dmgStr.split("-");
    18. Random rand = new Random();
    19. int damageAmount = rand.nextInt(Integer.parseInt(dmgAmnt[1]) - Integer.parseInt(dmgAmnt[0]) + 1) + Integer.parseInt(dmgAmnt[0]);
    20. e.setDamage(damageAmount);
    21.  
    22. Bukkit.getServer().broadcastMessage(ChatColor.RED + "DMG" + ChatColor.GRAY + damageAmount);
    23. }
    24. }
    25. }
    26. }
    27. }


    Its not even broadcasting the dmg it's doing... (Trying to get a lore from a bow to go to an arrow that was shot then when it hits an entity then deal a custom amount of damage)
     
  2. Offline

    SmooshCakez

    Did you register your events? Does the bow even have a lore? Any stack-traces?
     
  3. Offline

    Slash9211

    Its in my Listener class and yes I registered the events. yes the bow has a lore cause I added the lore to the bow...
    I'll post the stack-traces in a moment SmooshCakez
     
  4. Offline

    firecombat4

    What lore is being passed into your methods?
     
Thread Status:
Not open for further replies.

Share This Page