コード例 #1
0
  /**
   * This method is called when player leaves the game, which includes just two cases: either player
   * goes back to char selection screen or it's leaving the game [closing client].<br>
   * <br>
   * <b><font color='red'>NOTICE: </font> This method is called only from {@link AionConnection} and
   * {@link CM_QUIT} and must not be called from anywhere else</b>
   *
   * @param player
   */
  public static void playerLoggedOut(final Player player) {
    log.info(
        "Player logged out: "
            + player.getName()
            + " Account: "
            + player.getClientConnection().getAccount().getName());
    player.onLoggedOut();

    // Update prison timer
    if (player.isInPrison()) {
      long prisonTimer = System.currentTimeMillis() - player.getStartPrison();
      prisonTimer = player.getPrisonTimer() - prisonTimer;

      player.setPrisonTimer(prisonTimer);

      log.debug("Update prison timer to " + prisonTimer / 1000 + " seconds !");
    }

    // store current effects
    DAOManager.getDAO(PlayerEffectsDAO.class).storePlayerEffects(player);
    DAOManager.getDAO(ItemCooldownsDAO.class).storeItemCooldowns(player);
    DAOManager.getDAO(PlayerLifeStatsDAO.class).updatePlayerLifeStat(player);
    player.getEffectController().removeAllEffects();

    player.getLifeStats().cancelAllTasks();

    if (player.getLifeStats().isAlreadyDead()) TeleportService.moveToBindLocation(player, false);

    if (DuelService.getInstance().isDueling(player.getObjectId()))
      DuelService.getInstance().loseDuel(player);

    if (player.getSummon() != null) player.getSummon().getController().release(UnsummonType.LOGOUT);

    PunishmentService.stopPrisonTask(player, true);

    player.getCommonData().setOnline(false);
    player.getCommonData().setLastOnline(new Timestamp(System.currentTimeMillis()));

    player.setClientConnection(null);

    if (player.isLegionMember()) LegionService.getInstance().onLogout(player);

    if (player.isInGroup()) GroupService.getInstance().scheduleRemove(player);

    if (player.isInAlliance()) AllianceService.getInstance().onLogout(player);

    player.getController().delete();
    DAOManager.getDAO(PlayerDAO.class).onlinePlayer(player, false);

    if (!GSConfig.DISABLE_CHAT_SERVER) ChatService.onPlayerLogout(player);

    storePlayer(player);
    player.getEquipment().setOwner(null);
  }
コード例 #2
0
 @Override
 protected void handleUseItemFinish(Player player) {
   switch (getNpcId()) {
     case 730770:
       player.getLifeStats().increaseHp(SM_ATTACK_STATUS.TYPE.HP, 5000);
       AI2Actions.deleteOwner(this);
       break;
   }
 }
コード例 #3
0
  /**
   * Calculates the fall damage
   *
   * @param player
   * @param distance
   * @return True if the player is forced to his bind location.
   */
  public static boolean calculateFallDamage(Player player, float distance, boolean stoped) {
    if (player.isInvul()) {
      return false;
    }

    if (distance >= FallDamageConfig.MAXIMUM_DISTANCE_DAMAGE || !stoped) {
      player.getController().onStopMove();
      player.getFlyController().onStopGliding(false);
      player.getLifeStats().reduceHp(player.getLifeStats().getMaxHp() + 1, player);
      return true;
    } else if (distance >= FallDamageConfig.MINIMUM_DISTANCE_DAMAGE) {
      float dmgPerMeter =
          player.getLifeStats().getMaxHp() * FallDamageConfig.FALL_DAMAGE_PERCENTAGE / 100f;
      int damage = (int) (distance * dmgPerMeter);
      player.getLifeStats().reduceHp(damage, player);
      PacketSendUtility.sendPacket(
          player, new SM_ATTACK_STATUS(player, SM_ATTACK_STATUS.TYPE.FALL_DAMAGE, 0, -damage));
    }

    return false;
  }
コード例 #4
0
  @Override
  public void executeCommand(Player admin, String[] params) {
    if (admin.getAccessLevel() < AdminConfig.COMMAND_POWERUP) {
      PacketSendUtility.sendMessage(admin, "You dont have enough rights to execute this command");
      return;
    }
    int index = 2;
    int i = 0;
    Player player = null;
    if (params.length != 0) {
      if ("help".startsWith(params[i])) {
        PacketSendUtility.sendMessage(admin, "0 to return to normal state");
        PacketSendUtility.sendMessage(admin, "//powerup <Multiplier = 2>");
        PacketSendUtility.sendMessage(
            admin,
            "Syntax:  //powerup [playerName] [Multiplier = 2]\n"
                + "  This command multiplies your actual power to the number given.\n"
                + "  Using 0 as the Multiplier resets the power to normal.\n"
                + "  Notice: You can ommit parameters between [], especially playerName.\n"
                + "  Target: Named player, then targeted player, only then self.\n"
                + "  Default Value: Multiplier is 2.");
        return;
      }
      player = World.getInstance().findPlayer(Util.convertName(params[i]));
      if (player == null) {
        VisibleObject target = admin.getTarget();
        if (target instanceof Player) player = (Player) target;
        else player = admin;
      } else i++;
      try {
        index = Integer.parseInt(params[i]);
      } catch (NumberFormatException ex) {
        PacketSendUtility.sendMessage(admin, "Wrong input use //powerup help");
        return;
      } catch (Exception ex2) {
        PacketSendUtility.sendMessage(admin, "Occurs an error.");
        return;
      }
    }
    if (index == 0) {
      player.getGameStats().recomputeStats();
      player.getLifeStats().increaseHp(TYPE.HP, admin.getLifeStats().getMaxHp() + 1);
      player.getLifeStats().increaseMp(TYPE.MP, admin.getLifeStats().getMaxMp() + 1);
      PacketSendUtility.sendPacket(player, new SM_STATS_INFO(admin));
      if (player == admin) PacketSendUtility.sendMessage(player, "You are now normal again.");
      else {
        PacketSendUtility.sendMessage(
            admin, "Player " + player.getName() + " is now normal again.");
        PacketSendUtility.sendMessage(
            player, "Admin " + admin.getName() + " made you normal again.");
      }
      return;
    }
    player.getGameStats().setStat(StatEnum.MAXMP, admin.getLifeStats().getMaxHp() * index);
    player.getGameStats().setStat(StatEnum.MAXHP, admin.getLifeStats().getMaxMp() * index);

    player
        .getGameStats()
        .setStat(StatEnum.BLOCK, admin.getGameStats().getStatBonus(StatEnum.BLOCK) * index);
    player
        .getGameStats()
        .setStat(StatEnum.EVASION, admin.getGameStats().getStatBonus(StatEnum.EVASION) * index);
    player
        .getGameStats()
        .setStat(StatEnum.HEALTH, admin.getGameStats().getStatBonus(StatEnum.HEALTH) * index);
    player
        .getGameStats()
        .setStat(StatEnum.ACCURACY, admin.getGameStats().getStatBonus(StatEnum.ACCURACY) * index);
    player
        .getGameStats()
        .setStat(StatEnum.PARRY, admin.getGameStats().getStatBonus(StatEnum.PARRY) * index);

    player
        .getGameStats()
        .setStat(
            StatEnum.MAIN_HAND_ACCURACY,
            admin.getGameStats().getStatBonus(StatEnum.MAIN_HAND_ACCURACY) * index);
    player
        .getGameStats()
        .setStat(
            StatEnum.MAIN_HAND_CRITICAL,
            admin.getGameStats().getStatBonus(StatEnum.MAIN_HAND_CRITICAL) * index);
    player
        .getGameStats()
        .setStat(
            StatEnum.MAIN_HAND_POWER,
            admin.getGameStats().getStatBonus(StatEnum.MAIN_HAND_POWER) * index);
    player
        .getGameStats()
        .setStat(
            StatEnum.MAIN_HAND_ATTACK_SPEED,
            admin.getGameStats().getStatBonus(StatEnum.MAIN_HAND_POWER) * index);
    player
        .getGameStats()
        .setStat(
            StatEnum.OFF_HAND_ACCURACY,
            admin.getGameStats().getStatBonus(StatEnum.OFF_HAND_ACCURACY) * index);
    player
        .getGameStats()
        .setStat(
            StatEnum.OFF_HAND_CRITICAL,
            admin.getGameStats().getStatBonus(StatEnum.OFF_HAND_CRITICAL) * index);
    player
        .getGameStats()
        .setStat(
            StatEnum.OFF_HAND_POWER,
            admin.getGameStats().getStatBonus(StatEnum.OFF_HAND_POWER) * index);
    player
        .getGameStats()
        .setStat(
            StatEnum.OFF_HAND_ATTACK_SPEED,
            admin.getGameStats().getStatBonus(StatEnum.OFF_HAND_ATTACK_SPEED) * index);

    player
        .getGameStats()
        .setStat(
            StatEnum.MAGICAL_ATTACK,
            admin.getGameStats().getStatBonus(StatEnum.MAGICAL_ATTACK) * index);
    player
        .getGameStats()
        .setStat(
            StatEnum.MAGICAL_ACCURACY,
            admin.getGameStats().getStatBonus(StatEnum.MAGICAL_ACCURACY) * index);
    player
        .getGameStats()
        .setStat(
            StatEnum.MAGICAL_CRITICAL,
            admin.getGameStats().getStatBonus(StatEnum.MAGICAL_CRITICAL) * index);
    player
        .getGameStats()
        .setStat(
            StatEnum.MAGICAL_RESIST,
            admin.getGameStats().getStatBonus(StatEnum.MAGICAL_RESIST) * index);
    player
        .getGameStats()
        .setStat(
            StatEnum.BOOST_MAGICAL_SKILL,
            admin.getGameStats().getStatBonus(StatEnum.BOOST_MAGICAL_SKILL) * index * 15);

    player
        .getGameStats()
        .setStat(StatEnum.REGEN_MP, admin.getGameStats().getStatBonus(StatEnum.REGEN_MP) * index);
    player
        .getGameStats()
        .setStat(StatEnum.REGEN_HP, admin.getGameStats().getStatBonus(StatEnum.REGEN_HP) * index);

    player.getLifeStats().increaseHp(TYPE.HP, admin.getLifeStats().getMaxHp() + 1);
    player.getLifeStats().increaseMp(TYPE.MP, admin.getLifeStats().getMaxMp() + 1);
    PacketSendUtility.sendPacket(player, new SM_STATS_INFO(admin));
    if (player == admin)
      PacketSendUtility.sendMessage(
          player, "You are now " + index + " times more powerfull than before.");
    else {
      PacketSendUtility.sendMessage(
          admin,
          "Player " + player.getName() + " is now " + index + " times more powerfull than before.");
      PacketSendUtility.sendMessage(
          player,
          "Admin " + admin.getName() + " made you " + index + " times more powerfull than before.");
    }
  }