예제 #1
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);
      }
    }
  }
예제 #2
0
파일: Swords.java 프로젝트: nidefawl/mcMMO
  public static void applySerratedStrikes(
      Player attacker, EntityDamageByEntityEvent event, mcMMO pluginx) {
    int targets = 0;

    if (event.getEntity() instanceof LivingEntity) {
      LivingEntity x = (LivingEntity) event.getEntity();
      targets = Utils.getTier(attacker);

      for (Entity derp : x.getWorld().getEntities()) {
        if (Utils.getDistance(x.getLocation(), derp.getLocation()) < 5) {

          // Make sure the Wolf is not friendly
          if (derp instanceof Wolf) {
            Wolf hurrDurr = (Wolf) derp;
            if (Taming.getOwner(hurrDurr, pluginx) == attacker) continue;
            //						if(Party.getInstance().inSameParty(attacker, Taming.getOwner(hurrDurr,
            // pluginx)))
            //							continue;
          }
          // Damage nearby LivingEntities
          if (derp instanceof LivingEntity && targets >= 1) {
            if (derp instanceof Player) {
              Player target = (Player) derp;

              if (target.getName().equals(attacker.getName())) continue;

              if (Users.getProfile(target).getGodMode()) continue;

              //		    				if(Party.getInstance().inSameParty(attacker, target))
              //		    					continue;
              if (targets >= 1 && derp.getWorld().getPVP()) {
                target.damage(event.getDamage() / 4);
                target.sendMessage(ChatColor.DARK_RED + "Struck by Serrated Strikes!");
                if (Combat.dealDamage(attacker, target, 0)) target.increaseBleedTicks(5);
                target.setLastCustomDamageCause(
                    new EntityDamageByEntityEvent(attacker, target, DamageCause.ENTITY_ATTACK, 0));
                targets--;
                continue;
              }
            } else {
              LivingEntity target = (LivingEntity) derp;
              target.increaseBleedTicks(5);
              target.damage(event.getDamage() / 4);
              target.setLastCustomDamageCause(
                  new EntityDamageByEntityEvent(attacker, target, DamageCause.ENTITY_ATTACK, 0));
              targets--;
            }
          }
        }
      }
    }
  }
예제 #3
0
파일: Swords.java 프로젝트: nidefawl/mcMMO
 public static void bleedCheck(Player attacker, LivingEntity damaged, mcMMO pluginx) {
   PlayerProfile PPa = Users.getProfile(attacker);
   if (damaged.getBleedTicks() > 0) return;
   if (damaged instanceof Wolf) {
     Wolf wolf = (Wolf) damaged;
     if (Taming.getOwner(wolf, pluginx) != null) {
       if (Taming.getOwner(wolf, pluginx) == attacker) return;
       //	    		if(Party.getInstance().inSameParty(attacker, Taming.getOwner(wolf, pluginx)))
       //	    			return;
     }
   }
   if (mcPermissions.skillPermission(SkillType.SWORDS, attacker)
       && Utils.isSword(attacker.getItemInHand())) {
     if (Math.random() * 1000 <= Math.min(PPa.getSkillLevel(SkillType.SWORDS), 750)) {
       if (!(damaged instanceof Player) || Combat.dealDamage(attacker, damaged, 0))
         damaged.increaseBleedTicks(5);
       attacker.sendMessage(ChatColor.GREEN + "**ENEMY BLEEDING**");
       damaged.setLastCustomDamageCause(
           new EntityDamageByEntityEvent(attacker, damaged, DamageCause.ENTITY_ATTACK, 0));
     }
   }
 }
예제 #4
0
파일: Swords.java 프로젝트: nidefawl/mcMMO
  public static void counterAttackChecks(EntityDamageByEntityEvent event) {
    // Don't want to counter attack arrows
    if (event.getDamager() instanceof Projectile) return;

    if (event instanceof EntityDamageByEntityEvent) {
      Entity damager = ((EntityDamageByEntityEvent) event).getDamager();
      if (event.getEntity() instanceof Player) {
        Player damaged = (Player) event.getEntity();
        PlayerProfile PPd = Users.getProfile(damaged);
        if (Utils.isSword(damaged.getItemInHand())
            && mcPermissions.skillPermission(SkillType.SWORDS, damaged)) {
          if (Math.random() * 2000 <= Math.min(PPd.getSkillLevel(SkillType.SWORDS), 600)) {
            Combat.dealDamage(damaged, damager, event.getDamage() / 2);
            damaged.sendMessage(ChatColor.GREEN + "**COUNTER-ATTACKED**");
            if (damager instanceof Player) {
              ((Player) damager).sendMessage(ChatColor.DARK_RED + "Hit with counterattack!");
            }
          }
        }
      }
    }
  }
예제 #5
0
파일: Fishing.java 프로젝트: bigggan/mcMMO
  /**
   * Shake a mob, have them drop an item.
   *
   * @param event The event to modify
   */
  public static void shakeMob(PlayerFishEvent event) {
    final int DROP_NUMBER = random.nextInt(100);

    LivingEntity le = (LivingEntity) event.getCaught();
    EntityType type = le.getType();
    Location loc = le.getLocation();

    switch (type) {
      case BLAZE:
        m.mcDropItem(loc, new ItemStack(Material.BLAZE_ROD));
        break;

      case CAVE_SPIDER:
        if (DROP_NUMBER > 50) {
          m.mcDropItem(loc, new ItemStack(Material.SPIDER_EYE));
        } else {
          m.mcDropItem(loc, new ItemStack(Material.STRING));
        }
        break;

      case CHICKEN:
        if (DROP_NUMBER > 66) {
          m.mcDropItem(loc, new ItemStack(Material.FEATHER));
        } else if (DROP_NUMBER > 33) {
          m.mcDropItem(loc, new ItemStack(Material.RAW_CHICKEN));
        } else {
          m.mcDropItem(loc, new ItemStack(Material.EGG));
        }
        break;

      case COW:
        if (DROP_NUMBER > 99) {
          m.mcDropItem(loc, new ItemStack(Material.MILK_BUCKET));
        } else if (DROP_NUMBER > 50) {
          m.mcDropItem(loc, new ItemStack(Material.LEATHER));
        } else {
          m.mcDropItem(loc, new ItemStack(Material.RAW_BEEF));
        }
        break;

      case CREEPER:
        m.mcDropItem(loc, new ItemStack(Material.SULPHUR));
        break;

      case ENDERMAN:
        m.mcDropItem(loc, new ItemStack(Material.ENDER_PEARL));
        break;

      case GHAST:
        if (DROP_NUMBER > 50) {
          m.mcDropItem(loc, new ItemStack(Material.SULPHUR));
        } else {
          m.mcDropItem(loc, new ItemStack(Material.GHAST_TEAR));
        }
        break;

      case MAGMA_CUBE:
        m.mcDropItem(loc, new ItemStack(Material.MAGMA_CREAM));
        break;

      case MUSHROOM_COW:
        if (DROP_NUMBER > 99) {
          m.mcDropItem(loc, new ItemStack(Material.MILK_BUCKET));
        } else if (DROP_NUMBER > 98) {
          m.mcDropItem(loc, new ItemStack(Material.MUSHROOM_SOUP));
        } else if (DROP_NUMBER > 66) {
          m.mcDropItem(loc, new ItemStack(Material.LEATHER));
        } else if (DROP_NUMBER > 33) {
          m.mcDropItem(loc, new ItemStack(Material.RAW_BEEF));
        } else {
          m.mcDropItems(loc, new ItemStack(Material.RED_MUSHROOM), 3);
        }
        break;

      case PIG:
        m.mcDropItem(loc, new ItemStack(Material.PORK));
        break;

      case PIG_ZOMBIE:
        if (DROP_NUMBER > 50) {
          m.mcDropItem(loc, new ItemStack(Material.ROTTEN_FLESH));
        } else {
          m.mcDropItem(loc, new ItemStack(Material.GOLD_NUGGET));
        }
        break;

      case SHEEP:
        Sheep sheep = (Sheep) le;

        if (!sheep.isSheared()) {
          Wool wool = new Wool();
          wool.setColor(sheep.getColor());

          ItemStack theWool = wool.toItemStack();
          theWool.setAmount(1 + random.nextInt(6));

          m.mcDropItem(loc, theWool);
          sheep.setSheared(true);
        }
        break;

      case SKELETON:
        if (DROP_NUMBER > 50) {
          m.mcDropItem(loc, new ItemStack(Material.BONE));
        } else {
          m.mcDropItems(loc, new ItemStack(Material.ARROW), 3);
        }
        break;

      case SLIME:
        m.mcDropItem(loc, new ItemStack(Material.SLIME_BALL));
        break;

      case SNOWMAN:
        if (DROP_NUMBER > 99) {
          m.mcDropItem(loc, new ItemStack(Material.PUMPKIN));
        } else {
          m.mcDropItems(loc, new ItemStack(Material.SNOW_BALL), 5);
        }
        break;

      case SPIDER:
        if (DROP_NUMBER > 50) {
          m.mcDropItem(loc, new ItemStack(Material.SPIDER_EYE));
        } else {
          m.mcDropItem(loc, new ItemStack(Material.STRING));
        }
        break;

      case SQUID:
        m.mcDropItem(loc, new ItemStack(Material.INK_SACK, 1, (short) 0, (byte) 0x0));
        break;

      case ZOMBIE:
        m.mcDropItem(loc, new ItemStack(Material.ROTTEN_FLESH));
        break;

      default:
        break;
    }

    Combat.dealDamage(le, 1);
  }