コード例 #1
0
ファイル: AbstractAutoEvent.java プロジェクト: sabracx/tera
  @Override
  public boolean unregisterPlayer(Player player) {
    lock();
    try {

      if (!isStarted()) {
        player.sendMessage("Ивент не запущен.");
        return false;
      }

      if (getState() != EventState.REGISTER) {
        player.sendMessage("Время регистрации вышло.");
        return false;
      }

      Array<Player> prepare = getPrepare();

      if (!prepare.contains(player)) {
        player.sendMessage("Вы не зарегестрированы.");
        return false;
      }

      prepare.fastRemove(player);

      player.setEvent(false);
      player.sendMessage("Вы отрегестрированы.");
      return false;

    } finally {
      unlock();
    }
  }
コード例 #2
0
  @Override
  public Packet processing(Packet packet) {
    String nick = packet.nextString();
    String text = packet.nextString();

    Player player = World.getPlayer(nick);

    if (player == null) return null;

    player.sendMessage(text);

    return null;
  }
コード例 #3
0
ファイル: AbstractAutoEvent.java プロジェクト: sabracx/tera
  @Override
  public boolean registerPlayer(Player player) {
    lock();
    try {

      if (!isStarted()) {
        player.sendMessage("Ивент не запущен.");
        return false;
      }

      if (getState() != EventState.REGISTER) {
        player.sendMessage("Время регистрации вышло.");
        return false;
      }

      if (player.getLevel() > getMaxLevel() || player.getLevel() < getMinLevel()) {
        player.sendMessage("Вы не подходите по уровню.");
        return false;
      }

      Array<Player> prepare = getPrepare();

      if (prepare.contains(player)) {
        player.sendMessage("Вы уже зарегестрированы.");
        return false;
      }

      if (player.isDead()) {
        player.sendMessage("Вы мертвы.");
        return false;
      }

      if (player.hasDuel()) {
        player.sendMessage("Вы находитесь в дуэли.");
        return false;
      }

      prepare.add(player);

      player.setEvent(true);
      player.sendMessage("Вы зарегестрированы.");
      return true;

    } finally {
      unlock();
    }
  }
コード例 #4
0
ファイル: UserCommand.java プロジェクト: sabracx/tera
  @Override
  public void execution(String command, Player player, String values) {
    switch (command) {
      case "event_reg":
        {
          if (values == null) {
            return;
          }

          EventManager eventManager = EventManager.getInstance();
          eventManager.registerPlayer(values, player);
          break;
        }
      case "restore_characters":
        {
          PlayerManager playerManager = PlayerManager.getInstance();
          playerManager.restoreCharacters(player);

          break;
        }
      case "help":
        player.sendMessage(help);
        break;
      case "time":
        {
          synchronized (date) {
            date.setTime(System.currentTimeMillis());
            player.sendMessage(timeFormat.format(date));
          }

          break;
        }
      case "end_pay":
        {
          Account account = player.getAccount();

          long time = account.getEndPay();

          if (System.currentTimeMillis() > time)
            player.sendMessage("У вас не проплаченный аккаунт.");
          else {
            synchronized (date) {
              date.setTime(time);
              player.sendMessage("Дата завершения проплаты: " + timeFormat.format(date));
            }
          }

          break;
        }
      case "restore_skills":
        {
          Table<IntKey, Skill> current = player.getSkills();

          DataBaseManager dbManager = DataBaseManager.getInstance();

          for (Skill skill : current) {
            if (skill.getClassId() == -15) continue;

            player.removeSkill(skill, false);

            dbManager.deleteSkill(player, skill);

            skill.fold();
          }

          current.clear();

          player.getTemplate().giveSkills(player);
          player.sendPacket(SkillListInfo.getInstance(player), true);
          break;
        }
      case "kill_me":
        {
          if (player.isBattleStanced()) {
            player.sendMessage("Нельзя использовать в бою.");
            return;
          }

          synchronized (player) {
            player.setCurrentHp(0);
            player.doDie(player);
          }

          break;
        }
      case "version":
        player.sendMessage("Текущая версия сервера: " + Config.SERVER_VERSION);
        break;
      case "online":
        {
          OnlineManager onlineManager = OnlineManager.getInstance();

          player.sendMessage("Текущий онлаин: " + onlineManager.getCurrentOnline());

          break;
        }
      case "player_info":
        {
          if (player.getName().equals(values)) return;

          Player target = World.getAroundByName(Player.class, player, values);

          if (target == null) target = World.getPlayer(values);

          if (target == null) {
            player.sendMessage(MessageType.THAT_CHARACTER_ISNT_ONLINE);
            return;
          }

          StringBuilder builder =
              new StringBuilder("\n--------\nPlayer: \"").append(target.getName()).append("\":\n");

          builder.append("attack:").append(target.getAttack(null, null)).append(";\n");
          builder.append("defense:").append(target.getDefense(null, null)).append(";\n");
          builder.append("impact:").append(target.getImpact(null, null)).append(";\n");
          builder.append("balance:").append(target.getBalance(null, null)).append(";\n");
          builder.append("max hp:").append(target.getMaxHp()).append(".\n");
          builder.append("--------");

          player.sendMessage(builder.toString());

          break;
        }
    }
  }