Fall Damage Cancel?

Discussion in 'Plugin Development' started by Cooper PluginDev, Jan 2, 2014.

Thread Status:
Not open for further replies.
  1. Is it possible to cancel a fall damage event when wielding a special item meta sword type?
    If so, could you comment the line(s) of code? :D
  2. Offline


    Never ask people for code. It's lazy and you won't learn anything from just getting the code.
  3. Offline


    Cooper PluginDev on falldamage event, check if iteminhand is sword material. then check meta for specifics. cancel if all is true
    Garris0n likes this.
  4. How do I cancel it?
  5. Offline


    Cooper PluginDev

    As a PluginDev ;) you know, that most of event could be canceled by using method event.setCancel(true) in your event handler routine.
  6. Offline


    2. @EventHandler
    3. public void onEntityDamage(EntityDamageEvent e) {
    4. ItemStack i = e.getPlayer().getItemInHand();
    5. if (i.hasItemMeta() && i.getItemMeta().hasLore()) {
    6. e.setCancelled(i.getItemMeta().getLore().get(0).equalsIgnoreCase("Whatever your text is"));\
    7. // Unless you are sure that items aren't renameable, lore is the surefire way to make sure your
    8. // items won't be renamed.
    9. } else {
    10. // Have any logic that is done when there is no lore (if in a minigames type plugin, maybe a warning, or something...
    11. }
    12. }

    Just note, I wrote this freehand (pretty much), so, it may have bugs, but I bet you can fix them if there are any. :D
Thread Status:
Not open for further replies.

Share This Page