Exemplo n.º 1
0
  private static boolean CheckCondition(Player player) {
    if (player == null) {
      return false;
    }

    if (player.isInOlympiadMode()) {
      if (player.isLangRus()) {
        player.sendMessage("Во время Олимпиады нельзя использовать данную функцию.");
      } else {
        player.sendMessage("During the Olympics you can not use this feature.");
      }
      return false;
    }

    if (player.getReflection().getId() != 0 && !Config.COMMUNITYBOARD_INSTANCE_ENABLED) {
      if (player.isLangRus()) {
        player.sendMessage("Сервис доступен только в обычном мире.");
      } else {
        player.sendMessage("Service is only available in the real world.");
      }
      return false;
    }
    return true;
  }
Exemplo n.º 2
0
  @SuppressWarnings("rawtypes")
  @Override
  public boolean useAdminCommand(
      Enum comm, String[] wordList, String fullString, Player activeChar) {
    Commands command = (Commands) comm;

    if (!activeChar.getPlayerAccess().CanTeleport) return false;

    switch (command) {
      case admin_show_moves:
        activeChar.sendPacket(new NpcHtmlMessage(5).setFile("admin/teleports.htm"));
        break;
      case admin_show_moves_other:
        activeChar.sendPacket(new NpcHtmlMessage(5).setFile("admin/tele/other.htm"));
        break;
      case admin_show_teleport:
        showTeleportCharWindow(activeChar);
        break;
      case admin_teleport_to_character:
        teleportToCharacter(activeChar, activeChar.getTarget());
        break;
      case admin_teleport_to:
      case admin_teleportto:
        if (wordList.length < 2) {
          activeChar.sendMessage("USAGE: //teleportto charName");
          return false;
        }
        String chaName = Util.joinStrings(" ", wordList, 1);
        Player cha = GameObjectsStorage.getPlayer(chaName);
        if (cha == null) {
          activeChar.sendMessage("Player '" + chaName + "' not found in world");
          return false;
        }
        teleportToCharacter(activeChar, cha);
        break;
      case admin_move_to:
      case admin_moveto:
      case admin_teleport:
        if (wordList.length < 2) {
          activeChar.sendMessage("USAGE: //teleport x y z [ref]");
          return false;
        }
        teleportTo(
            activeChar,
            activeChar,
            Util.joinStrings(" ", wordList, 1, 3),
            ArrayUtils.valid(wordList, 4) != null && !ArrayUtils.valid(wordList, 4).isEmpty()
                ? Integer.parseInt(wordList[4])
                : 0);
        break;
      case admin_walk:
        if (wordList.length < 2) {
          activeChar.sendMessage("USAGE: //walk x y z");
          return false;
        }
        try {
          activeChar.moveToLocation(Location.parseLoc(Util.joinStrings(" ", wordList, 1)), 0, true);
        } catch (IllegalArgumentException e) {
          activeChar.sendMessage("USAGE: //walk x y z");
          return false;
        }
        break;
      case admin_gonorth:
      case admin_gosouth:
      case admin_goeast:
      case admin_gowest:
      case admin_goup:
      case admin_godown:
        int val = wordList.length < 2 ? 150 : Integer.parseInt(wordList[1]);
        int x = activeChar.getX();
        int y = activeChar.getY();
        int z = activeChar.getZ();
        if (command == Commands.admin_goup) z += val;
        else if (command == Commands.admin_godown) z -= val;
        else if (command == Commands.admin_goeast) x += val;
        else if (command == Commands.admin_gowest) x -= val;
        else if (command == Commands.admin_gosouth) y += val;
        else if (command == Commands.admin_gonorth) y -= val;

        activeChar.teleToLocation(x, y, z);
        showTeleportWindow(activeChar);
        break;
      case admin_tele:
        showTeleportWindow(activeChar);
        break;
      case admin_teleto:
      case admin_tele_to:
      case admin_instant_move:
        if (wordList.length > 1 && wordList[1].equalsIgnoreCase("r")) activeChar.setTeleMode(2);
        else if (wordList.length > 1 && wordList[1].equalsIgnoreCase("end"))
          activeChar.setTeleMode(0);
        else activeChar.setTeleMode(1);
        break;
      case admin_tonpc:
      case admin_to_npc:
        if (wordList.length < 2) {
          activeChar.sendMessage("USAGE: //tonpc npcId|npcName");
          return false;
        }
        String npcName = Util.joinStrings(" ", wordList, 1);
        NpcInstance npc;
        try {
          if ((npc = GameObjectsStorage.getByNpcId(Integer.parseInt(npcName))) != null) {
            teleportToCharacter(activeChar, npc);
            return true;
          }
        } catch (Exception e) {
        }
        if ((npc = GameObjectsStorage.getNpc(npcName)) != null) {
          teleportToCharacter(activeChar, npc);
          return true;
        }
        activeChar.sendMessage("Npc " + npcName + " not found");
        break;
      case admin_toobject:
        if (wordList.length < 2) {
          activeChar.sendMessage("USAGE: //toobject objectId");
          return false;
        }
        Integer target = Integer.parseInt(wordList[1]);
        GameObject obj;
        if ((obj = GameObjectsStorage.findObject(target)) != null) {
          teleportToCharacter(activeChar, obj);
          return true;
        }
        activeChar.sendMessage("Object " + target + " not found");
        break;
      default:
        break;
    }

    if (!activeChar.getPlayerAccess().CanEditChar) return false;

    switch (command) {
      case admin_teleport_character:
        if (wordList.length < 2) {
          activeChar.sendMessage("USAGE: //teleport_character x y z");
          return false;
        }
        teleportCharacter(activeChar, Util.joinStrings(" ", wordList, 1));
        showTeleportCharWindow(activeChar);
        break;
      case admin_recall:
        if (wordList.length < 2) {
          activeChar.sendMessage("USAGE: //recall charName");
          return false;
        }
        String targetName = Util.joinStrings(" ", wordList, 1);
        Player recall_player = GameObjectsStorage.getPlayer(targetName);
        if (recall_player != null) {
          teleportTo(activeChar, recall_player, activeChar.getLoc(), activeChar.getReflectionId());
          return true;
        }
        int obj_id = CharacterDAO.getInstance().getObjectIdByName(targetName);
        if (obj_id > 0) {
          teleportCharacter_offline(obj_id, activeChar.getLoc());
          activeChar.sendMessage(targetName + " is offline. Offline teleport used...");
        } else activeChar.sendMessage("->" + targetName + "<- is incorrect.");
        break;
      case admin_setref:
        {
          if (wordList.length < 2) {
            activeChar.sendMessage("Usage: //setref <reflection>");
            return false;
          }

          int ref_id = Integer.parseInt(wordList[1]);
          if (ref_id != 0 && ReflectionManager.getInstance().get(ref_id) == null) {
            activeChar.sendMessage("Reflection <" + ref_id + "> not found.");
            return false;
          }

          GameObject target = activeChar;
          GameObject obj = activeChar.getTarget();
          if (obj != null) target = obj;

          target.setReflection(ref_id);
          target.decayMe();
          target.spawnMe();
          break;
        }
      case admin_getref:
        if (wordList.length < 2) {
          activeChar.sendMessage("Usage: //getref <char_name>");
          return false;
        }
        Player cha = GameObjectsStorage.getPlayer(wordList[1]);
        if (cha == null) {
          activeChar.sendMessage("Player '" + wordList[1] + "' not found in world");
          return false;
        }
        activeChar.sendMessage(
            "Player '"
                + wordList[1]
                + "' in reflection: "
                + activeChar.getReflectionId()
                + ", name: "
                + activeChar.getReflection().getName());
        break;
      default:
        break;
    }

    if (!activeChar.getPlayerAccess().CanEditNPC) return false;

    switch (command) {
      case admin_recall_npc:
        recallNPC(activeChar);
        break;
      default:
        break;
    }

    return true;
  }