示例#1
0
 @Override
 public boolean isOldName(final String name) {
   PreparedStatement s =
       DB.prepareStatement(
           "SELECT count(player_id) as cnt FROM old_names WHERE ? = old_names.old_name");
   try {
     s.setString(1, name);
     ResultSet rs = s.executeQuery();
     rs.next();
     return rs.getInt("cnt") > 0;
   } catch (SQLException e) {
     log.error("Can't check if name " + name + ", is used, returning possitive result", e);
     return true;
   } finally {
     DB.close(s);
   }
 }
示例#2
0
  /*
   *  (non-Javadoc)
   * @see com.aionemu.gameserver.utils.chathandlers.admincommands.AdminCommand#executeCommand(com.aionemu.gameserver.gameobjects.Player, java.lang.String[])
   */
  @Override
  public void executeCommand(Player admin, String... params) {
    if (params == null) {
      PacketSendUtility.sendMessage(admin, "syntax //add itemID");
      return;
    }

    int parameter = 0;
    try {
      parameter = Integer.parseInt(params[0]);
    } catch (NumberFormatException e) {
      PacketSendUtility.sendMessage(admin, "Param needs to be a number.");

      return;
    }
    int activePlayer = admin.getObjectId();
    try {
      try {
        PreparedStatement ps =
            DB.prepareStatement("SELECT id FROM item_list WHERE `id`=" + parameter);
        ResultSet rs = ps.executeQuery();
        rs.last();
        parameter = rs.getInt("id");
      } catch (Exception e) {
        parameter = 0;
      }

      if (parameter != 0) {
        Inventory itemsDbOfPlayerCount = new Inventory(); // wrong
        itemsDbOfPlayerCount.getInventoryFromDb(activePlayer);
        int totalItemsCount = itemsDbOfPlayerCount.getItemsCount();

        Inventory equipedItems = new Inventory();
        equipedItems.getEquipedItemsFromDb(activePlayer);
        int totalEquipedItemsCount = equipedItems.getEquipedItemsCount();

        int cubes = 1;
        int cubesize = 27;
        int allowItemsCount = cubesize * cubes - 1;

        if (totalItemsCount <= allowItemsCount) {
          Inventory items = new Inventory();
          items.putItemToDb(activePlayer, parameter, 1);
          items.getLastUniqueIdFromDb();
          int newItemUniqueId = items.getnewItemUniqueIdValue();

          PacketSendUtility.sendPacket(
              admin, new SM_INVENTORY_INFO(newItemUniqueId, parameter, 1, 1, 8));
          PacketSendUtility.sendMessage(admin, "Added Item.");
        } else {
          PacketSendUtility.sendMessage(admin, "Inventory is Full.");
        }
      } else {
        PacketSendUtility.sendMessage(admin, "Invalid Item.");
      }

    } catch (Exception e) {
      PacketSendUtility.sendMessage(admin, "There was an error in the Code.");

      return;
    }
  }