Help

Discussion in 'Plugin Development' started by Iervolino, Jun 24, 2013.

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

    Iervolino

    Code:
    public int cooldown4 = 3;
    public String ThorCooldownMessage = ChatColor.RED + "Aguarde a cooldown!";
    public int ThorItemId = Material.IRON_AXE.getId();
    HashMap<String, Long> Thor = new HashMap<String, Long>();
     
    @EventHandler
    public void PlayerInteract(PlayerInteractEvent event){
      if(event.getAction() == Action.RIGHT_CLICK_BLOCK){
        final Player player = event.getPlayer();
        ItemStack item = event.getPlayer().getItemInHand();
        if (item.getTypeId() == ThorItemId){
        long lastUsed = 0;
        if (Thor.containsKey(player.getName()))
          lastUsed = Thor.get(player.getName());
        if (lastUsed + (1000 * cooldown4) > System.currentTimeMillis()) {
          event.getPlayer().sendMessage(
                  String.format(ThorCooldownMessage,
                          (-((System.currentTimeMillis() - (lastUsed + (1000 * cooldown4))) / 1000))));
        } else { 
          Block block = player.getTargetBlock(null, 50);
          Location location = block.getLocation();
          World world = player.getWorld();
          world.strikeLightning(location);
          Thor.put(player.getName(), System.currentTimeMillis());
        }
        }
        }
    How I can make the player which is using the IRON_AXE immune to the lightingStrike?
     
  2. Offline

    Ivan


    IRON_WOOD does that even exist? xD
     
  3. Offline

    Iervolino


    Sowwi, I mean IRON_AXE
     
  4. Offline

    Iervolino

    bump...
     
  5. Offline

    dillyg10

    eventcode{
    if (player.getItemInHand().getType() == Material.IRON_AXE){
    event.setCancelled(true);
    }
    }
     
  6. Offline

    Iervolino


    Yes, but you will cancel the strikelightning and not the damage..
     
  7. Offline

    adam753

    Maybe you could listen to EntityDamageEvent, and cancel it if the item in hand is an iron axe && the damage was caused by lightning. Or make the lightning strike happen on a 1-tick delay, and cancel the damage if the player is in your Thor set.
     
Thread Status:
Not open for further replies.

Share This Page