Пример #1
0
  @EventHandler(priority = EventPriority.HIGH)
  public void onEDamageByE(EntityDamageByEntityEvent event) {
    // if (event.getEntity() instanceof Player) {
    /*	Player Damagee = (Player) event.getEntity();
    String damager = event.getDamager().toString();
    Damagee.
    Bukkit.broadcastMessage("entity "+ Damagee);
    Bukkit.broadcastMessage("damager "+ damager);*/

    if (event.getDamager() instanceof Player) {
      Player p = (Player) event.getDamager();
      // int dmg = event.getDamage();
      double cRate = plugin.critRate.get(p.getName().toLowerCase());
      double random = ((double) Math.random() * 100);

      if (cRate > 0) {
        if (random <= cRate) {
          int oldmg = event.getDamage();
          int newdmg = oldmg * 2;
          event.setDamage(newdmg);
          p.sendMessage(ChatColor.AQUA + "Critical!");
          Location loc = p.getLocation();
          p.playEffect(loc, Effect.BLAZE_SHOOT, 0);
        }
      }
    }

    /*
    Player p = (Player) event.getDamager();
    String player = p.getName();
    Bukkit.broadcastMessage("name "+ player);*/

    // }

  }
Пример #2
0
  @EventHandler(priority = EventPriority.LOWEST)
  public void entityDamageByEntity(EntityDamageByEntityEvent e) {
    if (e.isCancelled()) return;
    if (!Minegusta.getServer().containsWorld(e.getEntity().getWorld())) return;

    ElfPower arrow = ElfPower.arrowDamage(e);
    DwarfPower axe = DwarfPower.axeBoost(e);
    EnderbornPower bleed = EnderbornPower.bleedBoost(e);
    EnderbornPower pearl = EnderbornPower.enderPearlDamage(e);

    if (arrow.isBowDamage()
        && arrow.isPlayer()
        && arrow.arrowIsFiredByElf()
        && arrow.victimIsLiving()
        && arrow.canPVP()) {
      arrow.applyBowDamage();
    }

    if (axe.isPlayer() && axe.isDwarf() && axe.hasAxe() && axe.canPVP()) {
      axe.applyAxeBoost();
    }

    if (bleed.isPlayer() && bleed.damagerIsEndeborn() && bleed.victimIsLiving() && bleed.canPVP()) {
      bleed.applyBleedBoost();
    }

    if (pearl.isPearl() && pearl.isPlayer() && pearl.entityIsEnderBorn()) {
      pearl.cancelPearlDamage();
    }
  }
Пример #3
0
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onPlayerDamageByPlayer(final EntityDamageByEntityEvent e) {
    if (e.getEntity() instanceof Player == false || e.getDamager() instanceof Player == false)
      return;

    Player player = (Player) e.getEntity();
    Player target = (Player) e.getDamager();
    SCPlayer scp = getSCPlayer(player.getUniqueId());
    SCPlayer sct = getSCPlayer(target.getUniqueId());
    Faction faction = BoardColl.get().getFactionAt(PS.valueOf(target.getLocation().getChunk()));

    if (faction.getName().equalsIgnoreCase("Safezone")) {
      return;
    }

    final Faction pFaction = MPlayerColl.get().get(player).getFaction();
    final Faction tFaction = MPlayerColl.get().get(target).getFaction();

    if (pFaction.getRelationTo(tFaction) == Rel.MEMBER && !pFaction.isNone()) {
      return;
    }

    if (pFaction.getRelationTo(tFaction) == Rel.ALLY) {
      return;
    }

    scp.combatTag();
    sct.combatTag();
  }
Пример #4
0
  @Override
  public boolean onDamageOther(EntityDamageByEntityEvent e, Player p, int level) {
    if (e.getEntity() instanceof LivingEntity) {
      LivingEntity le = (LivingEntity) e.getEntity();

      try {
        fireworks.playFirework(
            le.getWorld(),
            le.getLocation(),
            FireworkEffect.builder().with(Type.BURST).withColor(Color.WHITE).build());
      } catch (Exception ex) {
        Logger.getLogger(Burst.class.getName()).log(Level.SEVERE, null, ex);
      }

      Vector unitVector =
          le.getLocation().toVector().subtract(e.getDamager().getLocation().toVector()).normalize();

      unitVector.setY(0.55 / level);

      le.setVelocity(unitVector.multiply(level * 2));

      e.setCancelled(true);

      return true;
    }
    return false;
  }
 @EventHandler
 private void entityDamageByEntityEvent(EntityDamageByEntityEvent event) {
   if (event.isCancelled()
       || !(event.getDamager() instanceof Player)
       || !(event.getEntity() instanceof Player)
       || !(RandomPackage.getEnabledEnchantsConfig()
           .getString("Unique.Curse")
           .equalsIgnoreCase("true"))) {
     return;
   } else {
     Player damager = (Player) event.getDamager();
     Player victim = (Player) event.getEntity();
     if (victim.getInventory().getChestplate() == null
         || !(victim.getInventory().getChestplate().hasItemMeta())
         || !(victim.getInventory().getChestplate().getItemMeta().hasLore())) {
       return;
     } else {
       Bukkit.getScheduler()
           .scheduleSyncDelayedTask(
               RandomPackage.getPlugin(),
               new Runnable() {
                 public void run() {
                   if (event.isCancelled()) {
                     return;
                   } else {
                     Random random = new Random();
                     int chance = 8;
                     int duration = 60;
                     for (int i = 1; i <= 3; i++) {
                       chance = chance + 2;
                       duration = duration + 40;
                       if (victim
                               .getInventory()
                               .getChestplate()
                               .getItemMeta()
                               .getLore()
                               .contains(
                                   ChatColor.translateAlternateColorCodes(
                                       '&',
                                       RandomPackage.getPlugin()
                                           .getConfig()
                                           .getString(
                                               "Enchantments.Unique.Curse.Curse"
                                                   + i
                                                   + ".ItemLore")))
                           && random.nextInt(100) <= chance) {
                         damager.addPotionEffect(
                             new PotionEffect(PotionEffectType.SLOW, duration, 4));
                         return;
                       }
                     }
                     return;
                   }
                 }
               },
               1);
       return;
     }
   }
 }
Пример #6
0
 public static void global_no_mana_damaged(
     Player pl, final Plugin plugin, final EntityDamageByEntityEvent event) {
   event.setDamage(event.getDamage() * 2D);
   if (pl.isSneaking()) {
     pl.sendMessage(THRPlugin.thrpre + ChatColor.RED + pl.getName() + "貴方は霊力再生モードの為非常に柔いです!");
   }
 }
Пример #7
0
  @EventHandler(priority = EventPriority.NORMAL)
  public void onPlayerDamage(EntityDamageByEntityEvent evt) {
    if (evt.getDamager() instanceof Player) {
      Player p = (Player) evt.getDamager();

      if (p.hasPotionEffect(PotionEffectType.INCREASE_DAMAGE)) {
        for (PotionEffect eff : p.getActivePotionEffects()) {
          if (eff.getType().equals(PotionEffectType.INCREASE_DAMAGE)) {
            double div = (eff.getAmplifier() + 1) * 1.3D + 1.0D;
            int dmg;

            if (evt.getDamage() / div <= 1.0D) {
              dmg = (eff.getAmplifier() + 1) * 3 + 1;
            } else {
              double flatdmg = 2.0;
              dmg = (int) (evt.getDamage() / div) + (int) ((eff.getAmplifier() + 1) * flatdmg);
            }

            evt.setDamage(dmg);
            break;
          }
        }
      }
    }
  }
Пример #8
0
 public static void parryCheck(EntityDamageByEntityEvent event, Player defender) {
   Entity y = event.getDamager();
   PlayerProfile PPd = Users.getProfile(defender);
   if (defender != null
       && Utils.isSword(defender.getItemInHand())
       && mcPermissions.skillPermission(SkillType.SWORDS, defender)) {
     if (PPd.getSkillLevel(SkillType.SWORDS) >= 900) {
       if (Math.random() * 3000 <= 900) {
         event.setCancelled(true);
         defender.sendMessage(ChatColor.GREEN + "**PARRIED**");
         defender
             .getItemInHand()
             .setDurability((short) (defender.getItemInHand().getDurability() + 1));
         if (y instanceof Player) {
           Player attacker = (Player) y;
           attacker.sendMessage(ChatColor.GREEN + "**PARRIED**");
         }
       }
     } else {
       if (Math.random() * 3000 <= PPd.getSkillLevel(SkillType.SWORDS)) {
         event.setCancelled(true);
         defender.sendMessage(ChatColor.YELLOW + "*CLANG* SUCCESSFUL PARRY *CLANG*");
         defender
             .getItemInHand()
             .setDurability((short) (defender.getItemInHand().getDurability() + 1));
         if (y instanceof Player) {
           Player attacker = (Player) y;
           attacker.sendMessage(ChatColor.DARK_RED + "**TARGET HAS PARRIED THAT ATTACK**");
         }
       }
     }
   }
 }
Пример #9
0
  public static EventData getEventData(EntityDamageEvent event) {
    if (event == null) return null;

    DamageType damageElement = DamageType.get(event.getCause());

    Entity attacker = null;
    Projectile projectile = null;
    Entity target = event.getEntity();
    World world = target.getWorld();

    if (event instanceof EntityDamageByEntityEvent) {
      EntityDamageByEntityEvent event_EE = (EntityDamageByEntityEvent) event;
      Entity damager = event_EE.getDamager();

      if (damager instanceof Projectile) {
        projectile = (Projectile) damager;

        attacker = projectile.getShooter();
      } else {
        attacker = damager;
      }
    }

    return myInfo.makeData(
        attacker, projectile, target, world, damageElement, event.getDamage(), event.isCancelled());
  }
Пример #10
0
  /**
   * Monitor EntityDamageByEntity events.
   *
   * @param event The event to monitor
   */
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
    if (event instanceof FakeEntityDamageByEntityEvent) {
      return;
    }

    Entity defender = event.getEntity();
    Entity attacker = event.getDamager();

    if (attacker instanceof Player && defender instanceof Player) {
      if (!defender.getWorld().getPVP()) {
        return;
      }

      if (Party.getInstance().inSameParty((Player) defender, (Player) attacker)) {
        event.setCancelled(true);
        return;
      }
    }

    /* Check for invincibility */
    if (defender instanceof LivingEntity) {
      LivingEntity livingDefender = (LivingEntity) defender;

      if (!m.isInvincible(livingDefender, event)) {
        // Make sure event isn't cancelled before trying to proc?
        if (!event.isCancelled()) Combat.combatChecks(event, plugin);
      }
    }
  }
Пример #11
0
 @EventHandler
 public void onPlayerAttack(EntityDamageByEntityEvent e) {
   if (e.getDamager() instanceof Player) {
     Player p = (Player) e.getDamager();
     if (ArenaManager.getInstance().getArena(p) != null) e.setCancelled(true);
   }
 }
Пример #12
0
 public WeaponDamageEvent(int damage, EntityDamageByEntityEvent event) {
   super("HeroesWeaponDamageEvent", HeroEventType.WEAPON_DAMAGE);
   this.damage = damage;
   this.damager = event.getDamager();
   this.entity = event.getEntity();
   this.cause = event.getCause();
 }
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onEntityDamageByEntity(EntityDamageByEntityEvent ede) {
    List<EntityType> canDamageTypes = new ArrayList<EntityType>();
    canDamageTypes.add(EntityType.PLAYER);

    if (Main.getInstance().getServer().getPluginManager().isPluginEnabled("AntiAura")) {
      canDamageTypes.add(EntityType.SQUID);
    }

    if (canDamageTypes.contains(ede.getEntityType())) {
      return;
    }

    Game game =
        Main.getInstance().getGameManager().getGameByLocation(ede.getEntity().getLocation());
    if (game == null) {
      return;
    }

    if (game.getState() == GameState.STOPPED) {
      return;
    }

    ede.setCancelled(true);
  }
 @EventHandler
 public void onDamage(EntityDamageByEntityEvent event) {
   if (!(event.getEntity() instanceof Player && event.getDamager() instanceof Player))
     return; // We only want to check this if players hit each other
   final Player attacker = (Player) event.getDamager();
   if (attacker.getInventory().getHeldItemSlot() != 8) return;
   final Player victim = (Player) event.getEntity();
   if (AbilityManager.getInstance().getCurrentSpell(attacker) instanceof AbilityHealing) {
     event.setCancelled(true);
     victim.setHealth(victim.getMaxHealth());
     ParticleEffect.HEART.display(
         Vector.getRandom(), 1, victim.getEyeLocation().add(0, 0, .25), Bukkit.getOnlinePlayers());
   }
   if (!(AbilityManager.getInstance().getCurrentSpell(attacker) instanceof AbilityHeartripping))
     return; // Make sure the person punching has heartripping active
   if (!AbilityManager.getInstance().getCurrentSpell(attacker).canUse(attacker)) return;
   if (victim.hasPermission("heart.block")) {
     ChatManager.messageBad(attacker, "That player is too powerful!");
     ChatManager.messageGood(
         victim, attacker.getName() + " attempted to rip out your heart but was too weak!");
     return;
   }
   if (!spellSelection.containsKey(attacker) || !spellSelection.get(attacker).equals(victim)) {
     ChatManager.messageGood(
         attacker, "You ripped " + victim.getName() + "'s heart out of their body!");
     ChatManager.messageBad(
         victim, attacker.getName() + " has ripped your heart out of your body!");
     spellSelection.put(attacker, victim);
   }
   attacker.getInventory().setItemInMainHand(getValidBook(attacker));
 }
Пример #15
0
 @EventHandler
 public void onDammange(EntityDamageByEntityEvent event) {
   Entity dammage = event.getEntity();
   if (dammage.getType() == EntityType.ENDER_CRYSTAL) {
     event.setCancelled(true);
   }
 }
Пример #16
0
  /**
   * Tag creepers hurt by players.
   *
   * <p>Only those creepers hurt recently by players will have special drops.
   */
  @EventHandler(ignoreCancelled = true)
  public void onCreeperDamage(EntityDamageByEntityEvent event) {
    if (!CONFIG.isAffectedWorld(event)) {
      return;
    }

    if (event.getEntityType() == EntityType.CREEPER) {
      boolean isPlayerAttack = false;
      if (event.getDamager() instanceof Player) {
        isPlayerAttack = true;
      } else if (event.getDamager() instanceof Projectile) {
        Projectile projectile = (Projectile) event.getDamager();
        if (projectile.getShooter() instanceof Player) {
          isPlayerAttack = true;
        }
      }

      // Tag creepers hurt by players with the damage time stamp.
      if (isPlayerAttack) {
        Entity creeper = event.getEntity();
        creeper.setMetadata(
            PLAYER_DAMAGE_TIME_KEY,
            new FixedMetadataValue(this, new Long(creeper.getWorld().getFullTime())));
      }
    }
  }
Пример #17
0
 private boolean causePain(Player player, LivingEntity target, float power) {
   if (target.isDead()) return false;
   double dam = damage * power;
   if (target instanceof Player && checkPlugins && player != null) {
     // handle the event myself so I can detect cancellation properly
     EntityDamageByEntityEvent event =
         new EntityDamageByEntityEvent(player, target, damageType, dam);
     Bukkit.getServer().getPluginManager().callEvent(event);
     if (event.isCancelled()) {
       return false;
     }
     dam = event.getDamage();
     target.setLastDamageCause(event);
   }
   if (ignoreArmor) {
     double health = target.getHealth();
     if (health > target.getMaxHealth()) health = target.getMaxHealth();
     health = health - dam;
     if (health < 0) health = 0;
     if (health > target.getMaxHealth()) health = target.getMaxHealth();
     if (health == 0 && player != null) {
       MagicSpells.getVolatileCodeHandler().setKiller(target, player);
     }
     target.setHealth(health);
     target.playEffect(EntityEffect.HURT);
   } else {
     target.damage(dam, player);
   }
   if (player != null) {
     playSpellEffects(player, target);
   } else {
     playSpellEffects(EffectPosition.TARGET, target);
   }
   return true;
 }
Пример #18
0
  // ================================================================================================
  @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
  public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
    if (Arctica.debug) {
      if (event.getDamager() instanceof Player) {
        if (event.getEntityType() == EntityType.HORSE) {
          Horse horse = (Horse) event.getEntity();
          Player damager = (Player) event.getDamager();

          Arctica.log.info(
              Arctica.logPrefix
                  + "Health: "
                  + String.format("%1$.2f", horse.getHealth())
                  + " HP of "
                  + String.format("%1$.2f", horse.getMaxHealth())
                  + " HP");
          damager.sendMessage(
              "Health: "
                  + String.format("%1$.2f", horse.getHealth())
                  + " HP of "
                  + String.format("%1$.2f", horse.getMaxHealth())
                  + " HP");
        }
      }
    }
  }
Пример #19
0
 @EventHandler
 public void onDamageFisherman(EntityDamageByEntityEvent e) {
   if (this.pl.comecou)
     if (((e.getEntity() instanceof Player)) && ((e.getDamager() instanceof Player))) {
       Entity ent = e.getEntity();
       Player player = (Player) e.getEntity();
       Player damager = (Player) e.getDamager();
       Player p = (Player) ent;
       if ((this.pl.km.temKit(player))
           && (this.pl.km.getPlayerKit(player, this.pl.km.getKitByName("Fisherman")))
           && (damager.getItemInHand() != null)
           && (damager.getItemInHand().getType() != null)) {
         if (damager.hasPermission("planeta.vip") && (damager.hasPermission("hg.youtuber"))) {
           BossBar.setMessage(
               damager,
               p.getName()
                   + " - Fisherman (§bSopas "
                   + AmountAPI.getAmount(p, Material.MUSHROOM_SOUP)
                   + " §f)",
               1);
         } else {
           BossBar.setMessage(damager, p.getName() + " - Fisherman", 1);
         }
       }
     }
 }
Пример #20
0
 @EventHandler
 public void onHit(EntityDamageByEntityEvent e) {
   if (e.getEntity() instanceof Player) {
     Player p = (Player) e.getEntity();
     if (e.getDamager() instanceof Snowball) {
       Snowball s = (Snowball) e.getDamager();
       Player shooter = (Player) s.getShooter();
       if (teamManager.getTeam(p) != teamManager.getTeam((Player) s.getShooter())) {
         if (s.getCustomName() != null) {
           if (s.getCustomName().equalsIgnoreCase("stun")) {
             if (!stunned.contains(p.getName())) {
               stunned.add(p.getName());
               p.playSound(p.getLocation(), Sound.FIREWORK_TWINKLE2, 3F, 1F);
               shooter.playSound(shooter.getLocation(), Sound.SUCCESSFUL_HIT, 3F, 1F);
               p.sendMessage(Color.np("&cYou got hit by a stun! You cannot move for 2 seconds!"));
               new BukkitRunnable() {
                 @Override
                 public void run() {
                   stunned.remove(p.getName());
                 }
               }.runTaskLater(Main.getInstance(), 40);
             } else {
               shooter.sendMessage(Color.np("&cThat player is already stunned!"));
             }
           }
         }
       } else {
         shooter.sendMessage(Color.np("&cYou cannot stun team members!"));
       }
     }
   }
 }
Пример #21
0
    public static DamageCause fromDamageEvent(EntityDamageEvent e) {
      EntityDamageEvent.DamageCause c = e.getCause();
      Object p = null, x = null;

      EntityDamageByEntityEvent edEvent = null;
      if ((e instanceof EntityDamageByEntityEvent)) edEvent = (EntityDamageByEntityEvent) e;

      switch (c) {
        case ENTITY_ATTACK:
        case ENTITY_EXPLOSION:
          // get the entity that did the killing
          if (edEvent != null) {
            p = edEvent.getDamager();
            if (p instanceof Player) x = ((Player) p).getItemInHand().getType();
          }
          break;

        case PROJECTILE:
        case MAGIC:
          // get the shooter from the projectile
          if (edEvent != null && edEvent.getDamager() != null) {
            p = ((Projectile) edEvent.getDamager()).getShooter();
            x = edEvent.getDamager().getType();
          }

          // change damage cause to ENTITY_ATTACK
          // c = EntityDamageEvent.DamageCause.ENTITY_ATTACK;
          break;
      }

      if ((p instanceof Player))
        p = AutoReferee.getInstance().getMatch(e.getEntity().getWorld()).getPlayer((Player) p);
      else if ((p instanceof Entity)) p = ((Entity) p).getType();
      return new DamageCause(c, p, x);
    }
Пример #22
0
 @EventHandler(ignoreCancelled = true)
 public void CreatureExplosion(final EntityDamageByEntityEvent event) {
   if (plugin.isMonsterExplosionDamageEnabled()
       || event.getCause() != DamageCause.ENTITY_EXPLOSION) return;
   if (!(event.getEntity() instanceof Monster)) return;
   if (event.getDamager() instanceof TNTPrimed) return;
   event.setCancelled(true);
 }
Пример #23
0
 @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
 public void damageHandler(EntityDamageByEntityEvent event) {
   if (event.getDamager().getType() == EntityType.PLAYER) {
     Player player = (Player) event.getDamager();
     AnniPlayer p = AnniPlayer.getPlayer(player.getUniqueId());
     if (p != null && p.getKit().equals(this) && p.getData("Cur") != null) endLeap(player, p);
   }
 }
  @Test
  public void testWhenCreaturesIsAttackedByNonPlayerEventIsPassed() {
    EntityDamageByEntityEvent event =
        new EntityDamageByEntityEvent(mock(Creeper.class), mockCreature, null, 10.0);

    systemUnderTest.onEntityDamage(event);
    Assert.assertFalse(event.isCancelled());
  }
Пример #25
0
 @Override
 public void onEntityDamage(EntityDamageEvent ev) {
   if (ev instanceof EntityDamageByEntityEvent) {
     EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) ev;
     if (event.getDamager() instanceof Player) {
       QuestManager.incrementQuest((Player) event.getDamager(), event);
     }
   }
 }
Пример #26
0
 @EventHandler
 public void onDamage(EntityDamageByEntityEvent event) {
   if (event.getDamager() instanceof Player && hasAbility((Player) event.getDamager())) {
     Player p = (Player) event.getDamager();
     if (p.isSneaking() && (!needToBlock || p.isBlocking())) {
       event.setCancelled(true);
     }
   }
 }
Пример #27
0
  @EventHandler
  public void onPlayerAttack(EntityDamageByEntityEvent event) {
    Entity att = event.getDamager();
    Entity ent = event.getEntity();

    if (ent instanceof Player && att instanceof Player)
      if (plugin.spectators.contains(((Player) att).getName()) || Main.lobbyBoolean)
        event.setCancelled(true);
  }
Пример #28
0
 @EventHandler
 public void onDamageByEntity(EntityDamageByEntityEvent event) {
   if (dmgBuff.containsKey(event.getDamager())) {
     DmgBoost boost = dmgBuff.get(event.getDamager());
     if (boost.expires < HungergamesApi.getHungergames().currentTime)
       dmgBuff.remove(event.getDamager());
     else event.setDamage(event.getDamage() + boost.extraDamage);
   }
 }
Пример #29
0
 @EventHandler
 public void slendernoattack(EntityDamageByEntityEvent e) {
   if (e.getDamager() == slender.slenderman && e.getEntity() instanceof Player) {
     e.setCancelled(true);
   }
   if (e.getEntity() == slender.slenderman) {
     e.setCancelled(true);
   }
 }
Пример #30
0
  /**
   * Check EntityDamageByEntityEvent events.
   *
   * @param event The event to check
   */
  @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
  public void onEntityDeath(EntityDamageByEntityEvent event) {
    if (event.getDamage() == 0 || event.getEntity().isDead()) {
      return;
    }

    if (event.getEntity() instanceof LivingEntity) {
      combatChecks(event);
    }
  }