Solved Another way to do this?

Discussion in 'Plugin Development' started by lewysryan, Feb 3, 2014.

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

    lewysryan

    Ok so i'm having some fun with a bow and stuff. I waned to make a bow that if it hits someone throws them up in the air, BUT my problem is it is going in the hub is world guarded flag is to be invisible. So players dont get damaged, you will see what I mean:

    Code:java
    1.  
    2. @EventHandler
    3. public void playershot(EntityDamageByEntityEvent e){
    4. if(e.getDamager() instanceof Arrow){
    5. final Arrow arrow = (Arrow) e.getDamager();
    6. if(arrow.getShooter() instanceof Player){
    7. Player p = (Player) e.getEntity();
    8. Player damager = (Player) arrow.getShooter();
    9. e.setCancelled(true);
    10. p.sendMessage(ChatColor.BLUE + "Donator Gadget " + ChatColor.WHITE + "> " + ChatColor.GOLD + damager.getName() + ChatColor.GREEN + " Hit you with there player launcher!");
    11. damager.sendMessage(ChatColor.BLUE + "Donator Gadget " + ChatColor.WHITE + "> " + ChatColor.GREEN + "You hit " + ChatColor.GOLD + p.getName() + ChatColor.GREEN + " With player launcher!");
    12. Location ploc = (Location) p.getLocation();
    13. Location dloc = (Location) damager.getLocation();
    14. World w = p.getWorld();
    15. w.playSound(ploc, Sound.FALL_BIG, 2.0F, 2.0F);
    16. w.playSound(dloc, Sound.LEVEL_UP, 2.0F, 2.0F);
    17. p.setVelocity(new Vector(0,3,0));
    18.  
    19. }
    20. }
    21. }


    I use the EntityDamageByEntityEvent and was wondering if I could use another event as with the world guard flag, players don't take damage so dont get "EntityDamageByEntity"

    anyway around this?

    thanks!
     
  2. Offline

    EcMiner

    So you are trying to do that they can't use the 'Donator gadget' when the invincible flag is set to allow, or the pvp is set to deny?
     
    lewysryan likes this.
  3. I'd do @EventHandler(ignoreCancelled=true) to solve that... I think. Otherwise, implement WorldGuard (add it to your external class folders) and then loops through all regions in the world, check if the player is in that region, then check if the flag "PvP" is set to allow/deny.
     
    lewysryan likes this.
  4. Offline

    lewysryan

    No they can't use it due to the world guard flag invincible. so there is no damage, so the event dont fire

    KingFaris11
    I will try later. Thanks :D
     
  5. Offline

    Codex Arcanum

    Not true. The event fires, but is cancelled. If you want your code to run regardless if the event is cancelled by worldgaurd, ignoreCancelled = true will solve your problem.
     
    lewysryan likes this.
  6. Offline

    lewysryan

    KingFaris11 likes this.
  7. Offline

    MunchMallow

    Hello lewys my lovely cat
     
    lewysryan likes this.
Thread Status:
Not open for further replies.

Share This Page