private void damageEvents(EntityDamageEvent e) {
   if (!(e.getEntity() instanceof Player)) return;
   Player p = (Player) e.getEntity();
   if (p.getGameMode() == GameMode.CREATIVE) return;
   PlayerDetails d = getPlayerDetails(p);
   if (d == null) // make way for hacky plugins!
   return;
   ClassDetails c = MQCoreRPG.classManager.getClassDetail(d.getClassID());
   int amount = c.getDamageFromCause(e.getCause()) + e.getDamage();
   long total = d.getHealth() - amount;
   if (total < 0) total = 0;
   int minecrafthealth = d.getMinecraftHealth(total);
   int minecraftcurrent = p.getHealth();
   e.setDamage(minecraftcurrent - minecrafthealth);
   switch (e.getCause()) {
     case FIRE:
     case CONTACT:
     case LAVA:
     case VOID:
       d.setHealth(total, false);
       break;
     default:
       d.setHealth(total);
       break;
   }
 }
示例#2
0
  @EventHandler(priority = EventPriority.HIGH)
  public void onEntityDamage(EntityDamageEvent event_) {
    // If the event is cancelled, then we want to return.
    if (event_.isCancelled() == true) return;

    // Block damage in creative world.
    WorldConfig wm = new WorldConfig();

    if (!wm.getIsRpg(event_.getEntity().getWorld().getName())) return;

    // Store event.
    event = event_;

    // Set defaults.
    setGlobalDefaults();

    // Always set event damage to 0.
    event.setDamage(0);

    boolean dealEnviromentalDamage = false;

    // For entity damage events we want to handle the attck normally.
    if (event instanceof EntityDamageByEntityEvent) {
      Entity damager = ((EntityDamageByEntityEvent) event).getDamager();

      if (damager.getType() == EntityType.WITHER) dealEnviromentalDamage = true;
      else if (damager.getType() == EntityType.WITHER_SKULL) dealEnviromentalDamage = true;
      else if (damager.getType() == EntityType.SPLASH_POTION) dealEnviromentalDamage = true;
      else if (damager.getType() == EntityType.PRIMED_TNT) dealEnviromentalDamage = true;
      else entityAttack((EntityDamageByEntityEvent) event, -1);
    } else dealEnviromentalDamage = true;

    // Else we want to deal the damage to the player/mob as though not from an entity.
    if (dealEnviromentalDamage == true) {
      // If the defender is a player, then we attacker player defender.
      if (event.getEntity() instanceof Player) {
        Player player = (Player) event.getEntity();

        // Prevent damage done to already dead players
        if (FC_Rpg.rpgEntityManager.getRpgPlayer(player).playerConfig.getIsActive() == true) {
          if (FC_Rpg.rpgEntityManager.getRpgPlayer(player).getIsAlive() == false) return;
        }

        // Prepare the defender.
        prepareDefender(player);

        double damage = getEnviromentalDamage(player);

        if (damage == 0) return;

        // Attack the player with enviromental damage.
        edm.attackPlayerDefender(
            rpgDefender, null, null, damage, damageType, event.getCause().toString());
      } else {
        // If the event entity is a livingentity and the damage isn't fall damage, then nuke.
        if (event.getCause() != DamageCause.FALL && event.getEntity() instanceof LivingEntity)
          edm.nukeMob((LivingEntity) event.getEntity());
      }
    }
  }
示例#3
0
  @EventHandler(priority = EventPriority.HIGHEST)
  private void onEntityDamage(EntityDamageEvent evt) {
    if (!(evt.getEntity() instanceof Player)) {
      return;
    }
    Player p = (Player) evt.getEntity();
    PlayerDataClass pData = plugin.getPlayerHandler().findPlayer(p.getDisplayName());
    if (pData != null) {
      if (evt.getCause() == DamageCause.FALL) {
        Player player = (Player) evt.getEntity();
        if (plugin.getPlayerHandler().findPlayer(player.getDisplayName()) != null) {

          PlayerDataClass playerData =
              plugin.getPlayerHandler().findPlayer(player.getDisplayName());

          if (playerData.getType().equalsIgnoreCase("soldier")) {
            if (evt.getDamage() > 4) {
              evt.setDamage(4);
            }
          }
        }
      }
    } else {
      evt.setCancelled(true);
    }
  }
示例#4
0
  @EventHandler(priority = EventPriority.MONITOR)
  public void onEntityDamage(EntityDamageEvent event) {

    if (event.isCancelled()) {
      return;
    }

    Entity p2 = event.getEntity();

    db.i(
        "onEntityDamage: cause: " + event.getCause().name() + " : " + event.getEntity().toString());

    if ((p2 == null) || (!(p2 instanceof Player))) {
      return;
    }

    Arena arena = Arenas.getArenaByPlayer((Player) p2);
    if (arena == null) {
      // defender no arena player => out
      return;
    }

    Player defender = (Player) p2;

    ArenaPlayer apDefender = ArenaPlayer.parsePlayer(defender);

    if (arena.REALEND_ID != -1
        || (!apDefender.getStatus().equals(Status.EMPTY)
            && !apDefender.getStatus().equals(Status.FIGHT))) {
      event.setCancelled(true);
      return;
    }
  }
示例#5
0
 @EventHandler
 public void onEntityDamage(EntityDamageEvent event) {
   if (event.getEntity() instanceof Player) {
     Player p = (Player) event.getEntity();
     if (um.isSpectator(p.getName())) event.setCancelled(true);
   }
 }
示例#6
0
 @EventHandler
 public void onEntityDamage(EntityDamageEvent event) {
   if (!(event.getEntity() instanceof Player)) return;
   Player player = (Player) event.getEntity();
   if (!player.hasPermission("breathe.use")) return;
   if (event.getCause() == EntityDamageEvent.DamageCause.DROWNING) event.setCancelled(true);
 }
 @EventHandler
 public void onEntityDamage(EntityDamageEvent event) {
   if (!(event.isCancelled())
       && ((event.getCause().equals(DamageCause.ENTITY_EXPLOSION))
           || (event.getCause().equals(DamageCause.BLOCK_EXPLOSION)))
       && (event.getEntity() instanceof Player)) {
     Player player = (Player) event.getEntity();
     Hero hero = plugin.getCharacterManager().getHero(player);
     if (hero.hasEffect("BlastResistance")) {
       int level = hero.getSkillLevel(this.skill);
       double amount =
           (SkillConfigManager.getUseSetting(
                   hero, this.skill, Setting.AMOUNT.node(), 0.25, false)
               + (SkillConfigManager.getUseSetting(
                       hero, this.skill, "amount-increase", 0.0, false)
                   * level));
       if (hst != null)
         amount +=
             (SkillConfigManager.getUseSetting(hero, skill, "hst-amount", 0.0, false)
                 * (hst.getSkillLevel(hero, skill) - 1));
       amount = amount > 0 ? amount : 0;
       event.setDamage((int) (event.getDamage() * (1 - amount)));
     }
   }
 }
 @EventHandler(priority = EventPriority.HIGHEST)
 public void onEntityDamageEvent(EntityDamageEvent event) {
   if (event.isCancelled()) {
     return;
   }
   if (!(event.getEntity() instanceof Player)) {
     return;
   }
   Player p = (Player) event.getEntity();
   ItemStack iimh = p.getEquipment().getItemInMainHand();
   Tier t = iimh != null ? TierUtil.getTierFromItemStack(iimh) : null;
   if (t != null && t.isInfiniteDurability()) {
     p.getEquipment().getItemInMainHand().setDurability((short) 0);
   }
   for (ItemStack is : p.getEquipment().getArmorContents()) {
     if (is == null || is.getType() == Material.AIR) {
       continue;
     }
     t = TierUtil.getTierFromItemStack(is);
     if (t == null) {
       continue;
     }
     if (t.isInfiniteDurability()) {
       is.setDurability((short) 0);
     }
   }
 }
  @EventHandler(priority = EventPriority.NORMAL)
  public void onEDamaged(EntityDamageEvent event) {

    if (event.getEntity() instanceof Player) {
      DamageCause cause = event.getCause();
      if (cause != DamageCause.LAVA && cause != DamageCause.FIRE) {
        Player p = (Player) event.getEntity();
        // p.sendMessage("Au!");
        // formula daño equivalente
        int evdmg = event.getDamage();
        double resHP = event.getDamage();
        double tempop = 0;
        event.setDamage(0);
        double CH = plugin.PCH.get(p.getName().toLowerCase());
        double MH = plugin.PMH.get(p.getName().toLowerCase());
        CH = CH - evdmg;
        tempop = MH / 20;
        resHP = CH / tempop;
        p.setHealth((int) resHP);
        plugin.PCH.put(p.getName().toLowerCase(), CH);
        p.sendMessage(
            "HP: " + ChatColor.AQUA + CH + ChatColor.GRAY + "/" + ChatColor.DARK_AQUA + MH);

      } else {
        Player p = (Player) event.getEntity();
        double HP = p.getHealth();
        double CH = plugin.PCH.get(p.getName().toLowerCase());
        double MH = plugin.PMH.get(p.getName().toLowerCase());
        double tempop = 0;
        tempop = MH / 20;
        CH = HP * tempop;
        plugin.PCH.put(p.getName().toLowerCase(), CH);
      }
    }
  }
示例#10
0
 @EventHandler(priority = EventPriority.LOWEST)
 public void onEntityDamage(EntityDamageEvent event) {
   if (event.getEntity() instanceof SpoutPlayer) {
     event.setCancelled(
         event.isCancelled() || !((SpoutPlayer) event.getEntity()).isPreCachingComplete());
   }
 }
 @Override
 public void onEntityDamage(EntityDamageEvent event) {
   if (Player.class.isInstance(event.getEntity())) {
     Player player = (Player) event.getEntity();
     master.onPlayerDamage(player, event);
   }
 }
  // @EventHandler(priority = EventPriority.MONITOR)
  public void onDamage(EntityDamageEvent event) {
    Player p;
    if (event.getEntity() instanceof Player) {
      p = (Player) event.getEntity();
    } else {
      return;
    }

    if (!ArenaPlayerManager.isPlayerInArena(p)) return;

    String arenaName = ArenaPlayerManager.getArenaNameFromPlayer(p);

    if (!ArenaManager.isArenaRunning(arenaName)) return;

    Arena arena = ArenaManager.getArena(arenaName);

    if (event.getDamage() > p.getHealth()) {
      ArenaPlayerManager.getArenaFromPlayer(p).onDeath(p, event.getEntity());
      if (ArenaManager.getArenaSettings(arena).isShowRespawnScreen()) {
        return;
      }

      p.setHealth(20D);
      p.teleport(arena.getSpawnLocation(p));
      event.setCancelled(true);
    }
  }
    // Damage Hook
    public void onEntityDamage(EntityDamageEvent event) {
      // No point in running if this has been stopped
      if (event.isCancelled()) {
        return;
      }

      // Is this a player?
      if (event.getEntity() instanceof Player) {
        Player player = (Player) event.getEntity();
        PotionEntry entry = getPlugin().BuffList.get(player);

        // Elixir of Obsidian Skin
        if (entry != null && entry.HasBuff.get(Name) != null && entry.HasBuff.get(Name)) {
          // Halve all damages that have sources.
          // (Note, this means that direct damage through plugins
          // and such are left alone)
          if (event.getCause() != null) {
            int damage = event.getDamage();
            damage = (int) (damage * 0.5);
            damage = Math.max(damage, 1);
            event.setDamage(damage);
          }
        }
      }
    }
示例#14
0
  public void onEntityDamage(EntityDamageEvent event) {
    if (event instanceof EntityDamageByEntityEvent
        || event instanceof EntityDamageByProjectileEvent) {
      handlerAttackDefend((EntityDamageByEntityEvent) event);
    } else if (event.getCause() == DamageCause.FIRE_TICK) {
      Entity entity = event.getEntity();
      if (entity instanceof Player) {
        Player player = (Player) entity;
        Team team = war.getPlayerTeam(player.getName());
        if (team != null && team.getSpawnVolume().contains(player.getLocation())) {
          // smother out the fire that didn't burn out when you respawned
          // Stop fire (upcast, watch out!)
          if (player instanceof CraftPlayer) {
            net.minecraft.server.Entity playerEntity = ((CraftPlayer) player).getHandle();
            playerEntity.fireTicks = 0;
          }
          event.setCancelled(true);
        }
      }

    } else if (event.getCause() == DamageCause.DROWNING) {
      Entity entity = event.getEntity();
      if (entity instanceof Player) {
        Player player = (Player) entity;
        Team team = war.getPlayerTeam(player.getName());
        if (team != null && player.getHealth() <= 0) {
          // don't keep killing drowing player: trying to stop "Player moved wrongly!" error at
          // respawn.
          event.setCancelled(true);
        }
      }
    }
  }
  public void onEntityDamage(EntityDamageEvent event) {
    if (event.isCancelled()) return;

    if (event.getEntity() instanceof Player) {
      String playerName = ((Player) event.getEntity()).getName();
      if (AdminHandler.isGod(playerName)) event.setCancelled(true);
    }
  }
示例#16
0
 public void onEntityDamage(EntityDamageEvent e) {
   if ((e.getEntity() instanceof Player)) {
     Player p = (Player) e.getEntity();
     if (MainCmd.plugin.getConfig().getBoolean("Players." + p.getName() + ".god")) {
       e.setCancelled(true);
     }
   }
 }
示例#17
0
  @EventHandler
  public void onEntityDamage(EntityDamageEvent event) {
    if (event.getCause() != DamageCause.STARVATION || !(event.getEntity() instanceof Player))
      return;

    Player p = (Player) event.getEntity();
    if (p.hasPermission("fastfood.nostarve")) event.setCancelled(true);
  }
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onPlayerDamage(EntityDamageEvent event) {
    if (event.getEntity() instanceof Player) {

      Player p = (Player) event.getEntity();
      Hero hero = plugin.getHeroManager().getHero(p);
      HeroClass primclass = hero.getHeroClass();
      HeroClass secclass = hero.getSecondClass();
      SpoutPlayer sp = SpoutManager.getPlayer(p);

      int xpprim = (int) Math.round(hero.currentXPToNextLevel(primclass));
      int xpsec = (int) Math.round(hero.currentXPToNextLevel(secclass));

      if (hero != null) {

        String text =
            primclass
                + ": "
                + ChatColor.RED
                + hero.getHealth()
                + " / "
                + hero.getMaxHealth()
                + "\n"
                + ChatColor.DARK_RED
                + "Lvl/Exp: "
                + ChatColor.RED
                + hero.getLevel(primclass)
                + " / "
                + xpprim;

        if (secclass != null) {

          text +=
              "\n"
                  + ChatColor.DARK_GREEN
                  + "Prof: "
                  + ChatColor.GREEN
                  + secclass
                  + "\n"
                  + ChatColor.DARK_GREEN
                  + "LvL/Exp: "
                  + ChatColor.GREEN
                  + hero.getLevel(secclass)
                  + " / "
                  + xpsec;
        } else {
          text +=
              "\n"
                  + ChatColor.DARK_GREEN
                  + "You Dont have a"
                  + "\n"
                  + ChatColor.DARK_GREEN
                  + "Secondary Class!";
        }
        plugin.getGUI().updateLabel(sp, text);
      }
    }
  }
示例#19
0
 @EventHandler
 public void fall(EntityDamageEvent e) {
   if (e.getEntity() instanceof Player) {
     Player p = (Player) e.getEntity();
     if (Util.getKit(p) instanceof Poseidon) {
       if (e.getCause() == DamageCause.FALL) e.setCancelled(true);
     }
   }
 }
示例#20
0
 @EventHandler
 public void onEntityDamage(EntityDamageEvent e) {
   if (e.getEntity() instanceof Player
       && e.getCause().equals(DamageCause.VOID)
       && Config.getConfig().getBoolean("teleport-to-spawn-on.void-fall")) {
     Utils.teleportToSpawn((Player) e.getEntity());
     e.setCancelled(true);
   }
 }
示例#21
0
 @EventHandler
 public void onPlayerDamage(EntityDamageEvent e) {
   if (e.getEntity() instanceof Player) {
     Player p = (Player) e.getEntity();
     if (ArenaManager.getInstance().getArena(p) != null) {
       if (e.getCause() != DamageCause.ENTITY_ATTACK) e.setCancelled(true);
     }
   }
 }
 @EventHandler
 public void onPlayerHurt(EntityDamageEvent event) {
   if (event.getEntity() instanceof Player) {
     Player player = (Player) event.getEntity();
     if (FOPM_TFM_Util.inGod(player)) {
       event.setCancelled(true);
     }
   }
 }
示例#23
0
 // Invincibility
 @EventHandler
 public void onPlayerDamage(EntityDamageEvent event) {
   if (event.getEntity() instanceof Player) {
     Player player = (Player) event.getEntity();
     if (Utilities.getUtilities().invincible.contains(player.getName())) {
       event.setCancelled(true);
     }
   }
 }
示例#24
0
 @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
 public void damageHandler(EntityDamageEvent event) {
   if (event.getEntityType() == EntityType.PLAYER) {
     AnniPlayer p = AnniPlayer.getPlayer(event.getEntity().getUniqueId());
     if (p != null && p.getKit().equals(this) && p.getData("Cur") != null) {
       if (event.getCause() == DamageCause.FALL) event.setCancelled(true);
       else endLeap((Player) event.getEntity(), p);
     }
   }
 }
示例#25
0
 @EventHandler
 public void onEntityDamage(EntityDamageEvent event) {
   if (event.getEntity() instanceof Player) {
     Player player = (Player) event.getEntity();
     if (helpDeskInstance.doesHaveTicketAssigned(player)) {
       if (player.getFireTicks() > 0) player.setFireTicks(0);
       event.setCancelled(true);
     }
   }
 }
 @EventHandler
 public void onPlayerDamage(EntityDamageEvent e) {
   if (e.getEntity() instanceof Player && e.getCause() == DamageCause.FALL) {
     Player p = (Player) e.getEntity();
     if (spongify.contains(p.getName())) {
       e.setDamage(0);
       spongify.remove(p.getName());
     }
   }
 }
示例#27
0
	@EventHandler
	public void onEntityDamage(EntityDamageEvent e) {
		if (!(e.getEntity() instanceof Player))
			return;

		SpleefPlayer player = HeavySpleef.getInstance().getSpleefPlayer(e.getEntity());

		if (player.isActive()) {
			e.setCancelled(true);
		}
	}
示例#28
0
 @EventHandler
 public void onDamage(EntityDamageEvent e) {
   if (e.getEntity() instanceof Player) {
     Player player = (Player) e.getEntity();
     if (UtilsIceTag.players.contains(player)) {
       if (UtilsIceTag.started == false && UtilsIceTag.countdown == true) {
         e.setCancelled(true);
       }
     }
   }
 }
	@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
	public void onEntityDamage(final EntityDamageEvent event)
	{
		if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
		{
			final Player player = (Player)event.getEntity();
			player.setFireTicks(0);
			player.setRemainingAir(player.getMaximumAir());
			event.setCancelled(true);
		}
	}
  @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
  public void onEntityDamage(EntityDamageEvent event) {
    if (event.getEntity() instanceof ItemFrame) {
      ItemFrame frame = (ItemFrame) event.getEntity();

      // is the block below a shop block?
      if (scs.getShopHandler().isKnownItemFrame(frame)) {
        frame.setItem(null);
      }
    }
  }