@EventHandler
  public void onEntityTameEvent(EntityTameEvent event) {

    /*
    Get the entity being tamed.
     */
    LivingEntity entity = event.getEntity();

    if (StackUtils.hasRequiredData(entity)) {

      /*
      Get the new quantity. Current size, less one (One being tamed)
       */
      int newQuantity = StackUtils.getStackSize(entity) - 1;

      /*
      Clear the name of the entity that was just tamed.
       */
      entity.setCustomName("");

      /*
      If there are any mobs remaining in the stack, then peel em off to form a new stack.
       */
      if (newQuantity > 0) {

        LivingEntity newEntity = getPlugin().getStackUtils().peelOffStack(entity, false);

        /*
        If there was an age in question, then assign it.
         */
        if (newEntity instanceof Ageable) {
          ((Ageable) newEntity).setAge(((Ageable) event.getEntity()).getAge());
        }

        /*
         * Yes I know the following aren't possible, but if someone uses a plugin that allows for taming of other mobs through NMS,
         * then this will account for that.
         */

        /*
        If the stack had a colour, assign it.
         */
        if (newEntity instanceof Colorable) {
          ((Colorable) newEntity).setColor(((Colorable) event.getEntity()).getColor());
        }

        /*
        If it was a sheep, keep it's sheared status.
         */
        if (newEntity instanceof Sheep) {
          ((Sheep) newEntity).setSheared(((Sheep) event.getEntity()).isSheared());
        }
      }
    }
  }
Exemplo n.º 2
0
 @EventHandler(priority = EventPriority.MONITOR)
 public void onEntityTame(EntityTameEvent event) {
   if (event.isCancelled() == false
       && event.getOwner() instanceof Player
       && !worlds.contains(event.getEntity().getWorld().getName())) {
     playerStatManager
         .getPlayerBlob(((Player) event.getOwner()).getName())
         .getStat("stats", "tame" + event.getEntity().getType().toString().replace("_", ""))
         .incrementStat(1);
   }
 }
Exemplo n.º 3
0
  /**
   * Monitor EntityTame events.
   *
   * @param event The event to watch
   */
  @EventHandler(priority = EventPriority.MONITOR)
  public void onEntityTame(EntityTameEvent event) {
    Player player = (Player) event.getOwner();

    if (mcPermissions.getInstance().taming(player)
        && !event.getEntity().hasMetadata("mcmmoSummoned")) {
      PlayerProfile PP = Users.getProfile(player);
      EntityType type = event.getEntityType();
      int xp = 0;

      switch (type) {
        case WOLF:
          xp = LoadProperties.mtameWolf;
          break;

        case OCELOT:
          xp = LoadProperties.mtameOcelot;
          break;

        default:
          break;
      }

      PP.addXP(SkillType.TAMING, xp);
      Skills.XpCheckSkill(SkillType.TAMING, player);
    }
  }
Exemplo n.º 4
0
 @EventHandler
 public void onTaming(EntityTameEvent event) {
   if (event.getOwner() instanceof Player) {
     String playerID = PlayerConverter.getID((Player) event.getOwner());
     if (!dataMap.containsKey(playerID)) {
       return;
     }
     LivingEntity entity = event.getEntity();
     TameData playerData = (TameData) dataMap.get(playerID);
     switch (type) {
       case WOLF:
         if (entity.getType().equals(EntityType.WOLF) && checkConditions(playerID)) {
           playerData.subtract();
         }
         break;
       case OCELOT:
         if (entity.getType().equals(EntityType.OCELOT) && checkConditions(playerID)) {
           playerData.subtract();
         }
         break;
       case HORSE:
         if (entity.getType().equals(EntityType.HORSE) && checkConditions(playerID)) {
           playerData.subtract();
         }
         break;
       default:
         break;
     }
     if (playerData.isZero()) {
       completeObjective(playerID);
     }
   }
 }
Exemplo n.º 5
0
  /**
   * Monitor EntityTame events.
   *
   * @param event The event to watch
   */
  @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
  public void onEntityTame(EntityTameEvent event) {
    Player player = (Player) event.getOwner();
    LivingEntity entity = event.getEntity();

    if (Misc.isNPCEntity(player)
        || Misc.isNPCEntity(entity)
        || entity.hasMetadata(mcMMO.entityMetadataKey)) {
      return;
    }

    UserManager.getPlayer(player).getTamingManager().awardTamingXP(entity);
  }