コード例 #1
0
  @Override
  public void loadCraftCooldowns(final Player player) {
    Connection con = null;
    FastMap<Integer, Long> craftCoolDowns = new FastMap<Integer, Long>();
    try {
      con = DatabaseFactory.getConnection();
      PreparedStatement stmt = con.prepareStatement(SELECT_QUERY);

      stmt.setInt(1, player.getObjectId());
      ResultSet rset = stmt.executeQuery();

      while (rset.next()) {
        int delayId = rset.getInt("delay_id");
        long reuseTime = rset.getLong("reuse_time");
        int delay = (int) ((reuseTime - System.currentTimeMillis()) / 1000);

        if (delay > 0) {
          craftCoolDowns.put(delayId, reuseTime);
        }
      }
      player.getCraftCooldownList().setCraftCoolDowns(craftCoolDowns);
      rset.close();
      stmt.close();
    } catch (SQLException e) {
      log.error("LoadcraftCoolDowns", e);
    } finally {
      DatabaseFactory.close(con);
    }
  }
コード例 #2
0
  @Override
  public void storeCraftCooldowns(final Player player) {
    deleteCraftCoolDowns(player);
    Map<Integer, Long> craftCoolDowns = player.getCraftCooldownList().getCraftCoolDowns();

    if (craftCoolDowns == null) {
      return;
    }

    for (Map.Entry<Integer, Long> entry : craftCoolDowns.entrySet()) {
      final int delayId = entry.getKey();
      final long reuseTime = entry.getValue();

      if (reuseTime < System.currentTimeMillis()) {
        continue;
      }

      Connection con = null;

      try {
        con = DatabaseFactory.getConnection();
        PreparedStatement stmt = con.prepareStatement(INSERT_QUERY);

        stmt.setInt(1, player.getObjectId());
        stmt.setInt(2, delayId);
        stmt.setLong(3, reuseTime);
        stmt.execute();
      } catch (SQLException e) {
        log.error("storecraftCoolDowns", e);
      } finally {
        DatabaseFactory.close(con);
      }
    }
  }
コード例 #3
0
 @Override
 public List<ToyPet> getPlayerPets(int playerId) {
   List<ToyPet> pets = new ArrayList<ToyPet>();
   Connection con = null;
   try {
     con = DatabaseFactory.getConnection();
     PreparedStatement stmt =
         con.prepareStatement("SELECT * FROM player_pets WHERE player_id = ?");
     stmt.setInt(1, playerId);
     ResultSet rs = stmt.executeQuery();
     while (rs.next()) {
       ToyPet pet = new ToyPet();
       pet.setName(rs.getString("name"));
       pet.setDecoration(rs.getInt("decoration"));
       pet.setPetId(rs.getInt("pet_id"));
       pet.setDatabaseIndex(rs.getInt("idx"));
       pets.add(pet);
     }
     stmt.close();
   } catch (Exception e) {
     log.error("Error getting pets for " + playerId, e);
   } finally {
     DatabaseFactory.close(con);
   }
   return pets;
 }
コード例 #4
0
 @Override
 public ToyPet getPlayerPet(int playerId, int petId) {
   ToyPet pet;
   Connection con = null;
   try {
     con = DatabaseFactory.getConnection();
     PreparedStatement stmt =
         con.prepareStatement("SELECT * FROM player_pets WHERE player_id = ? AND pet_id = ?");
     stmt.setInt(1, playerId);
     stmt.setInt(2, petId);
     ResultSet rs = stmt.executeQuery();
     if (rs.first()) {
       pet = new ToyPet();
       pet.setName(rs.getString("name"));
       pet.setDecoration(rs.getInt("decoration"));
       pet.setPetId(rs.getInt("pet_id"));
       pet.setDatabaseIndex(rs.getInt("idx"));
     } else {
       pet = null;
     }
     stmt.close();
   } catch (Exception e) {
     log.error("Error getting pets for " + playerId, e);
     pet = null;
   } finally {
     DatabaseFactory.close(con);
   }
   return pet;
 }
コード例 #5
0
  private void deleteCraftCoolDowns(final Player player) {
    Connection con = null;

    try {
      con = DatabaseFactory.getConnection();
      PreparedStatement stmt = con.prepareStatement(DELETE_QUERY);

      stmt.setInt(1, player.getObjectId());
      stmt.execute();
    } catch (SQLException e) {
      log.error("deletecraftCoolDowns", e);
    } finally {
      DatabaseFactory.close(con);
    }
  }
コード例 #6
0
 @Override
 public void removePlayerPet(Player player, int petId) {
   Connection con = null;
   try {
     con = DatabaseFactory.getConnection();
     PreparedStatement stmt =
         con.prepareStatement("DELETE FROM player_pets WHERE player_id = ? AND pet_id = ?");
     stmt.setInt(1, player.getObjectId());
     stmt.setInt(2, petId);
     stmt.execute();
     stmt.close();
   } catch (Exception e) {
     log.error("Error removing pet #" + petId, e);
   } finally {
     DatabaseFactory.close(con);
   }
 }
コード例 #7
0
 /* (non-Javadoc)
  * @see com.aionengine.gameserver.dao.PlayerTitleListDAO#removeTitle(int, int)
  */
 @Override
 public boolean removeTitle(int playerId, int titleId) {
   Connection con = null;
   try {
     con = DatabaseFactory.getConnection();
     PreparedStatement stmt = con.prepareStatement(DELETE_QUERY);
     stmt.setInt(1, playerId);
     stmt.setInt(2, titleId);
     stmt.execute();
     stmt.close();
   } catch (Exception e) {
     log.error("Could not delete title for player " + playerId + " from DB: " + e.getMessage(), e);
     return false;
   } finally {
     DatabaseFactory.close(con);
   }
   return true;
 }
コード例 #8
0
 @Override
 public void deletePlayerGameStat(final int playerId) {
   Connection con = null;
   try {
     con = DatabaseFactory.getConnection();
     PreparedStatement stmt = con.prepareStatement(DELETE_QUERY);
     stmt.setInt(1, playerId);
     stmt.execute();
     stmt.close();
   } catch (Exception e) {
     log.error(
         "Could not delete PlayerGameStat data for player "
             + playerId
             + " from DB: "
             + e.getMessage(),
         e);
   } finally {
     DatabaseFactory.close(con);
   }
 }
コード例 #9
0
 @Override
 public void insertPlayerPet(Player player, int petId, int decoration, String name) {
   Connection con = null;
   try {
     con = DatabaseFactory.getConnection();
     PreparedStatement stmt =
         con.prepareStatement(
             "INSERT INTO player_pets(player_id, pet_id, decoration, name) VALUES(?, ?, ?, ?)");
     stmt.setInt(1, player.getObjectId());
     stmt.setInt(2, petId);
     stmt.setInt(3, decoration);
     stmt.setString(4, name);
     stmt.execute();
     stmt.close();
   } catch (Exception e) {
     log.error("Error inserting new pet #" + petId + "[" + name + "]", e);
   } finally {
     DatabaseFactory.close(con);
   }
 }
コード例 #10
0
 @Override
 public void insertPlayerGameStat(final Player player) {
   Connection con = null;
   try {
     con = DatabaseFactory.getConnection();
     PreparedStatement stmt = con.prepareStatement(INSERT_QUERY);
     stmt.setInt(1, player.getObjectId());
     stmt.setInt(2, player.getGameStats().getPDef().getCurrent());
     stmt.setInt(3, player.getGameStats().getBlock().getCurrent());
     stmt.setInt(4, player.getGameStats().getParry().getCurrent());
     stmt.setInt(5, player.getGameStats().getMCritical().getCurrent());
     stmt.setInt(6, player.getGameStats().getWill().getCurrent());
     stmt.setInt(7, player.getGameStats().getAccuracy().getCurrent());
     stmt.setInt(8, player.getGameStats().getPower().getCurrent());
     stmt.setInt(9, player.getGameStats().getMainHandMAccuracy().getCurrent());
     stmt.setInt(10, player.getGameStats().getAttackSpeed().getCurrent());
     stmt.setInt(11, player.getGameStats().getMResist().getCurrent());
     stmt.setInt(12, player.getGameStats().getMainHandMAttack().getCurrent());
     stmt.setInt(13, player.getGameStats().getMainHandPCritical().getCurrent());
     stmt.setInt(14, player.getGameStats().getAttackRange().getCurrent());
     stmt.setInt(15, player.getGameStats().getMDef().getCurrent());
     stmt.setInt(16, player.getGameStats().getAgility().getCurrent());
     stmt.setInt(17, player.getGameStats().getKnowledge().getCurrent());
     stmt.setInt(18, player.getGameStats().getWill().getCurrent());
     stmt.setInt(19, player.getGameStats().getMBoost().getCurrent());
     stmt.setInt(20, player.getGameStats().getMBResist().getCurrent());
     stmt.setInt(21, player.getGameStats().getPCR().getCurrent());
     stmt.setInt(22, player.getGameStats().getMCR().getCurrent());
     stmt.execute();
     stmt.close();
   } catch (Exception e) {
     log.error(
         "Could not store PlayerGameStat data for player "
             + player.getObjectId()
             + " from DB: "
             + e.getMessage(),
         e);
   } finally {
     DatabaseFactory.close(con);
   }
 }
コード例 #11
0
 @Override
 public boolean storeTitles(Player player, Title entry) {
   Connection con = null;
   try {
     con = DatabaseFactory.getConnection();
     PreparedStatement stmt = con.prepareStatement(INSERT_QUERY);
     stmt.setInt(1, player.getObjectId());
     stmt.setInt(2, entry.getId());
     stmt.setInt(3, entry.getExpireTime());
     stmt.execute();
     stmt.close();
   } catch (Exception e) {
     log.error(
         "Could not store emotionId for player "
             + player.getObjectId()
             + " from DB: "
             + e.getMessage(),
         e);
     return false;
   } finally {
     DatabaseFactory.close(con);
   }
   return true;
 }