Package l2p.database

Examples of l2p.database.FiltredStatement


   */
  public static L2Player restore(final int objectId)
  {
    L2Player player = null;
    ThreadConnection con = null;
    FiltredStatement statement = null;
    FiltredStatement statement2 = null;
    ResultSet pl_rset = null;
    ResultSet ps_rset = null;
    try
    {
      // Retrieve the L2Player from the characters table of the database
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.createStatement();
      statement2 = con.createStatement();
      pl_rset = statement.executeQuery("SELECT * FROM `characters` WHERE `obj_Id`=" + objectId + " LIMIT 1");
      ps_rset = statement2.executeQuery("SELECT `class_id` FROM `character_subclasses` WHERE `char_obj_id`=" + objectId + " AND `isBase`=1 LIMIT 1");
      if(pl_rset.next() && ps_rset.next())
      {
        final int classId = ps_rset.getInt("class_id");
        final boolean female = pl_rset.getInt("sex") == 1;
        final L2PlayerTemplate template = CharTemplateTable.getInstance().getTemplate(classId, female);
        player = new L2Player(objectId, template);
        player.loadVariables();
        player.bookmarks.setCapacity(pl_rset.getInt("bookmarks"));
        player.setBaseClass(classId);
        player._accountName = pl_rset.getString("account_name");
        player.setName(pl_rset.getString("char_name"));
        player.setFace(pl_rset.getByte("face"));
        player.setHairStyle(pl_rset.getByte("hairStyle"));
        player.setHairColor(pl_rset.getByte("hairColor"));
        player.setHeading(pl_rset.getInt("heading"));
        player.setKarma(pl_rset.getInt("karma"));
        player.setPvpKills(pl_rset.getInt("pvpkills"));
        player.setPkKills(pl_rset.getInt("pkkills"));
        player.setLeaveClanTime(pl_rset.getLong("leaveclan") * 1000L);
        if(player.getLeaveClanTime() > 0 && player.canJoinClan())
        {
          player.setLeaveClanTime(0);
        }
        player.setDeleteClanTime(pl_rset.getLong("deleteclan") * 1000L);
        if(player.getDeleteClanTime() > 0 && player.canCreateClan())
        {
          player.setDeleteClanTime(0);
        }
        player.setNoChannel(pl_rset.getLong("nochannel") * 1000L);
        if(player.getNoChannel() > 0 && player.getNoChannelRemained() < 0)
        {
          player.updateNoChannel(0);
        }
        player.setOnlineTime(pl_rset.getLong("onlinetime") * 1000L);
        final int clanId = pl_rset.getInt("clanid");
        if(clanId > 0)
        {
          player.setClan(ClanTable.getInstance().getClan(clanId));
          player.setPledgeType(pl_rset.getInt("pledge_type"));
          player.setPowerGrade(pl_rset.getInt("pledge_rank"));
          player.setLvlJoinedAcademy(pl_rset.getInt("lvl_joined_academy"));
          player.setApprentice(pl_rset.getInt("apprentice"));
        }
        player.setCreateTime(pl_rset.getLong("createtime") * 1000L);
        player.setDeleteTimer(pl_rset.getInt("deletetime"));
        player.setTitle(pl_rset.getString("title"));
        if(player.getVar("namecolor") == null)
        {
          if(player.isGM())
          {
            player.setNameColor(Config.GM_NAME_COLOUR);
          }
          else if(player.getClan() != null && player.getClan().getLeaderId() == player.getObjectId())
          {
            player.setNameColor(Config.CLANLEADER_NAME_COLOUR);
          }
          else
          {
            player.setNameColor(Config.NORMAL_NAME_COLOUR);
          }
        }
        else
        {
          player.setNameColor(Integer.decode("0x" + player.getVar("namecolor")));
        }
        if(Config.AUTO_LOOT_INDIVIDUAL)
        {
          player.AutoLoot = player.getVarB("AutoLoot", Config.AUTO_LOOT);
          player.AutoLootHerbs = player.getVarB("AutoLootHerbs", Config.AUTO_LOOT_HERBS);
        }
        String recomList = player.getVar("recomChars");
        if(recomList != null && !recomList.isEmpty())
        {
          for(String recom : recomList.split(","))
          {
            if(!recom.isEmpty())
            {
              player._recomChars.add(Integer.decode("0x" + recom));
            }
          }
        }
        player.setFistsWeaponItem(player.findFistsWeaponItem(classId));
        player.setUptime(System.currentTimeMillis());
        player.setLastAccess(pl_rset.getLong("lastAccess"));
        player.setRecomHave(pl_rset.getInt("rec_have"));
        player.setRecomLeft(pl_rset.getInt("rec_left"));
        player.setKeyBindings(pl_rset.getBytes("key_bindings"));
        player.setPcBangPoints(pl_rset.getInt("pcBangPoints"));
        player.setFame(pl_rset.getInt("fame"), null);
        player.restoreRecipeBook();
        if(Config.ENABLE_OLYMPIAD)
        {
          player.setHero(Hero.getInstance().isHero(player.getObjectId()));
          player.setNoble(Olympiad.isNoble(player.getObjectId()));
        }
        player.updatePledgeClass();
        player.updateKetraVarka();
        player.updateRam();
        // для сервиса виверн - возврат денег если сервер упал во время полета
        String wm = player.getVar("wyvern_moneyback");
        if(wm != null && Integer.parseInt(wm) > 0)
        {
          player.addAdena(Integer.parseInt(wm));
        }
        player.unsetVar("wyvern_moneyback");
        long reflection = 0;
        // Set the x,y,z position of the L2Player and make it invisible
        if(player.getVar("jailed") != null && System.currentTimeMillis() / 1000 < Integer.parseInt(player.getVar("jailed")) + 60)
        {
          player.setXYZInvisible(-114648, -249384, -2984);
          String[] re = player.getVar("jailedFrom").split(";");
          Location loc = new Location(Integer.parseInt(re[0]), Integer.parseInt(re[1]), Integer.parseInt(re[2]));
          reflection = -3;
          player._unjailTask = ThreadPoolManager.getInstance().scheduleGeneral(new TeleportTask(player, loc, re.length > 3 ? Integer.parseInt(re[3]) : 0), Integer.parseInt(player.getVar("jailed")) * 1000L);
        }
        else
        {
          player.setXYZInvisible(pl_rset.getInt("x"), pl_rset.getInt("y"), pl_rset.getInt("z"));
          wm = player.getVar("reflection");
          if(wm != null)
          {
            reflection = Long.parseLong(wm);
            if(reflection > 0)
            {
              if(!Config.RepairPlayerToInstance || ReflectionTable.getInstance().get(reflection) == null)
              {
                String back = player.getVar("backCoords");
                if(back != null)
                {
                  player.setXYZInvisible(new Location(back));
                  player.unsetVar("backCoords");
                }
                reflection = 0;
              }
            }
          }
        }
        player.setReflection(reflection);
        player.restoreTradeList();
        if(player.getVar("storemode") != null)
        {
          if(player.getVar("offline") != null) // оффтрейдеры выбивают других, онтрейдеры нет
          {
            if(Config.SERVICES_TRADE_ONLY_FAR)
            {
              L2WorldRegion currentRegion = L2World.getRegion(player.getLoc(), player.getReflectionId());
              if(currentRegion != null)
              {
                GArray<L2WorldRegion> neighbors = currentRegion.getNeighbors();
                int size = 0;
                for(L2WorldRegion region : neighbors)
                {
                  size += region.getPlayersSize();
                }
                GArray<L2Player> result = new GArray<L2Player>(size);
                for(L2WorldRegion region : neighbors)
                {
                  region.getPlayersList(result, 0, player.getReflection(), player.getX(), player.getY(), player.getZ(), Config.SERVICES_TRADE_RADIUS * Config.SERVICES_TRADE_RADIUS, 200);
                }
                for(L2Player p : result)
                {
                  if(p.isInStoreMode())
                  {
                    if(p.isInOfflineMode())
                    {
                      L2TradeList.cancelStore(p);
                    }
                    else
                    {
                      p.setPrivateStoreType(L2Player.STORE_PRIVATE_NONE);
                      p.broadcastUserInfo(true);
                    }
                  }
                }
              }
            }
            player.setPrivateStoreType(Short.parseShort(player.getVar("storemode")));
            player.setSitting(true);
          }
          else
          {
            short type = Short.parseShort(player.getVar("storemode"));
            if(player.checksForShop(type == STORE_PRIVATE_MANUFACTURE))
            {
              player.setPrivateStoreType(type);
              player.setSitting(true);
            }
            else
            {
              player.unsetVar("storemode");
            }
          }
        }
        if(TerritorySiege.isInProgress())
        {
          player.setTerritorySiege(TerritorySiege.getTerritoryForPlayer(objectId));
        }
        Quest.playerEnter(player);
        player._hidden = true;
        restoreCharSubClasses(player);
        player._hidden = false;
        // 2 очка в минуту оффлайна, на оффе 4, но там очки вдвое легче
        player.setVitality(pl_rset.getInt("vitality") + (int) ((System.currentTimeMillis() / 1000 - pl_rset.getLong("lastAccess")) / 30.));
        // 15 секунд после входа в игру на персонажа не агрятся мобы
        player.setNonAggroTime(System.currentTimeMillis() + 15000);
        try
        {
          String var = player.getVar("ExpandInventory");
          if(var != null)
          {
            player.setExpandInventory(Integer.parseInt(var));
          }
        }
        catch(Exception e)
        {
          e.printStackTrace();
        }
        try
        {
          String var = player.getVar("ExpandWarehouse");
          if(var != null)
          {
            player.setExpandWarehouse(Integer.parseInt(var));
          }
        }
        catch(Exception e)
        {
          e.printStackTrace();
        }
        try
        {
          String var = player.getVar("notShowBuffAnim");
          if(var != null)
          {
            player.setNotShowBuffAnim(Boolean.parseBoolean(var));
          }
        }
        catch(Exception e)
        {
          e.printStackTrace();
        }
        FiltredPreparedStatement stmt = null;
        ResultSet chars = null;
        try
        {
          stmt = con.prepareStatement("SELECT obj_Id, char_name FROM characters WHERE account_name=? AND obj_Id!=?");
          stmt.setString(1, player._accountName);
          stmt.setInt(2, objectId);
          chars = stmt.executeQuery();
          while(chars.next())
          {
            final Integer charId = chars.getInt("obj_Id");
            final String charName = chars.getString("char_name");
            player._chars.put(charId, charName);
          }
        }
        catch(Exception e)
        {
          e.printStackTrace();
        }
        finally
        {
          DatabaseUtils.closeDatabaseSR(stmt, chars);
        }
        if(Config.KILL_COUNTER)
        {
          // Restore kills stat
          FiltredStatement stt = null;
          ResultSet rstkills = null;
          try
          {
            stt = con.createStatement();
            rstkills = stt.executeQuery("SELECT `npc_id`, `count` FROM `killcount` WHERE `char_id`=" + objectId);
            player._StatKills = new HashMap<Integer, Long>(128);
            while(rstkills.next())
            {
              player._StatKills.put(rstkills.getInt("npc_id"), rstkills.getLong("count"));
            }
          }
          catch(Exception e)
          {
            e.printStackTrace();
          }
          finally
          {
            DatabaseUtils.closeDatabaseSR(stt, rstkills);
          }
        }
        //Restore craft stat
        if(Config.CRAFT_COUNTER)
        {
          FiltredStatement stcraft = null;
          ResultSet rstcraft = null;
          try
          {
            stcraft = con.createStatement();
            rstcraft = stcraft.executeQuery("SELECT `item_id`, `count` FROM `craftcount` WHERE `char_id`=" + objectId);
            player._StatCraft = new HashMap<Integer, Long>(32);
            while(rstcraft.next())
            {
              player._StatCraft.put(rstcraft.getInt("item_id"), rstcraft.getLong("count"));
            }
          }
          catch(Exception e)
          {
            e.printStackTrace();
          }
          finally
          {
            DatabaseUtils.closeDatabaseSR(stcraft, rstcraft);
          }
        }
        if(Config.DROP_COUNTER)
        {
          //Restore drop stat
          FiltredStatement stdrop = null;
          ResultSet rstdrop = null;
          try
          {
            stdrop = con.createStatement();
            rstdrop = stdrop.executeQuery("SELECT `item_id`, `count` FROM `dropcount` WHERE `char_id`=" + objectId);
            player._StatDrop = new HashMap<Integer, Long>(128);
            while(rstdrop.next())
            {
              player._StatDrop.put(rstdrop.getInt("item_id"), rstdrop.getLong("count"));
            }
View Full Code Here


  {
    synchronized(_storeLock)
    {
      ThreadConnection con = null;
      FiltredPreparedStatement statement = null;
      FiltredStatement fs;
      try
      {
        con = L2DatabaseFactory.getInstance().getConnection();
        statement = con.prepareStatement(//
        "UPDATE characters SET face=?,hairStyle=?,hairColor=?,heading=?,x=?,y=?,z=?" + //
        ",karma=?,pvpkills=?,pkkills=?,rec_have=?,rec_left=?,clanid=?,deletetime=?," + //
        "title=?,accesslevel=?,online=?,leaveclan=?,deleteclan=?,nochannel=?," + //
        "onlinetime=?,pledge_type=?,pledge_rank=?,lvl_joined_academy=?,apprentice=?,key_bindings=?,pcBangPoints=?,char_name=?,vitality=?,fame=?,bookmarks=? WHERE obj_Id=? LIMIT 1");
        statement.setInt(1, getFace());
        statement.setInt(2, getHairStyle());
        statement.setInt(3, getHairColor());
        statement.setInt(4, getHeading() & 0xFFFF);
        if(_stablePoint == null) // если игрок находится в точке в которой его сохранять не стоит (например на виверне) то сохраняются последние координаты
        {
          statement.setInt(5, getX());
          statement.setInt(6, getY());
          statement.setInt(7, getZ());
        }
        else
        {
          statement.setInt(5, _stablePoint.x);
          statement.setInt(6, _stablePoint.y);
          statement.setInt(7, _stablePoint.z);
        }
        statement.setInt(8, getKarma());
        statement.setInt(9, getPvpKills());
        statement.setInt(10, getPkKills());
        statement.setInt(11, getRecomHave());
        statement.setInt(12, getRecomLeft());
        statement.setInt(13, getClanId());
        statement.setInt(14, getDeleteTimer());
        statement.setString(15, _title);
        statement.setInt(16, _accessLevel);
        statement.setInt(17, isOnline() ? 1 : 0);
        statement.setLong(18, getLeaveClanTime() / 1000);
        statement.setLong(19, getDeleteClanTime() / 1000);
        statement.setLong(20, _NoChannel > 0 ? getNoChannelRemained() / 1000 : _NoChannel);
        statement.setLong(21, _onlineBeginTime > 0 ? (_onlineTime + System.currentTimeMillis() - _onlineBeginTime) / 1000 : _onlineTime / 1000);
        statement.setInt(22, getPledgeType());
        statement.setInt(23, getPowerGrade());
        statement.setInt(24, getLvlJoinedAcademy());
        statement.setInt(25, getApprentice());
        statement.setBytes(26, getKeyBindings());
        statement.setInt(27, getPcBangPoints());
        statement.setString(28, getName());
        statement.setInt(29, (int) getVitality());
        statement.setInt(30, getFame());
        statement.setInt(31, bookmarks.getCapacity());
        statement.setInt(32, getObjectId());
        statement.executeUpdate();
        Stat.increaseUpdatePlayerBase();
        try
        {
          if(!fast && Config.KILL_COUNTER && _StatKills != null)
          {
            TextBuilder sb = TextBuilder.newInstance();
            fs = con.createStatement();
            for(Entry<Integer, Long> tmp : _StatKills.entrySet())
            {
              fs.addBatch(sb.append("REPLACE DELAYED INTO `killcount` SET `npc_id`=").append(tmp.getKey()).append(", `count`=").append(tmp.getValue()).append(", `char_id`=").append(_objectId).toString());
              sb.clear();
            }
            TextBuilder.recycle(sb);
            fs.executeBatch();
            DatabaseUtils.closeStatement(fs);
          }
          if(!fast && Config.CRAFT_COUNTER && _StatCraft != null)
          {
            TextBuilder sb = TextBuilder.newInstance();
            fs = con.createStatement();
            for(Entry<Integer, Long> tmp : _StatCraft.entrySet())
            {
              fs.addBatch(sb.append("REPLACE DELAYED INTO `craftcount` SET `item_id`=").append(tmp.getKey()).append(", `count`=").append(tmp.getValue()).append(", `char_id`=").append(_objectId).toString());
              sb.clear();
            }
            TextBuilder.recycle(sb);
            fs.executeBatch();
            DatabaseUtils.closeStatement(fs);
          }
          if(!fast && Config.DROP_COUNTER && _StatDrop != null)
          {
            TextBuilder sb = TextBuilder.newInstance();
            fs = con.createStatement();
            for(Entry<Integer, Long> tmp : _StatDrop.entrySet())
            {
              fs.addBatch(sb.append("REPLACE DELAYED INTO `craftcount` SET `item_id`=").append(tmp.getKey()).append(", `count`=").append(tmp.getValue()).append(", `char_id`=").append(_objectId).toString());
              sb.clear();
            }
            TextBuilder.recycle(sb);
            fs.executeBatch();
            DatabaseUtils.closeStatement(fs);
          }
        }
        catch(ConcurrentModificationException e)
        {
View Full Code Here

  }

  public void storeDisableSkills()
  {
    ThreadConnection con = null;
    FiltredStatement statement = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.createStatement();
      statement.executeUpdate("DELETE FROM character_skills_save WHERE char_obj_id = " + getObjectId() + " AND class_index=" + getActiveClassId() + " AND `end_time` < " + System.currentTimeMillis());
      if(skillReuseTimeStamps.isEmpty())
      {
        return;
      }
      SqlBatch b = new SqlBatch("REPLACE INTO `character_skills_save` (`char_obj_id`,`skill_id`,`class_index`,`end_time`,`reuse_delay_org`) VALUES");
      synchronized(skillReuseTimeStamps)
      {
        StringBuilder sb;
        for(Entry<Integer, SkillTimeStamp> tmp : getSkillReuseTimeStamps().entrySet())
        {
          if(tmp.getValue().hasNotPassed())
          {
            sb = new StringBuilder("(");
            sb.append(getObjectId()).append(",");
            sb.append(tmp.getKey()).append(",");
            sb.append(getActiveClassId()).append(",");
            sb.append(tmp.getValue().getEndTime()).append(",");
            sb.append(tmp.getValue().getReuseBasic()).append(")");
            b.write(sb.toString());
          }
        }
      }
      if(!b.isEmpty())
      {
        statement.executeUpdate(b.close());
      }
    }
    catch(final Exception e)
    {
      _log.warning("Could not store disable skills data: " + e);
View Full Code Here

  }

  public void storeEffects()
  {
    ThreadConnection con = null;
    FiltredStatement statement = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.createStatement();
      statement.executeUpdate("DELETE FROM character_effects_save WHERE char_obj_id = " + getObjectId() + " AND class_index=" + getActiveClassId());
      if(_effectList == null || _effectList.isEmpty())
      {
        return;
      }
      int order = 0;
      SqlBatch b = new SqlBatch("INSERT IGNORE INTO `character_effects_save` (`char_obj_id`,`skill_id`,`skill_level`,`effect_count`,`effect_cur_time`,`duration`,`order`,`class_index`) VALUES");
      synchronized(getEffectList())
      {
        StringBuilder sb;
        for(L2Effect effect : getEffectList().getAllEffects())
        {
          if(effect != null && effect.isInUse() && !effect.getSkill().isToggle() && effect.getEffectType() != EffectType.HealOverTime && effect.getEffectType() != EffectType.CombatPointHealOverTime)
          {
            if(effect.isSaveable())
            {
              sb = new StringBuilder("(");
              sb.append(getObjectId()).append(",");
              sb.append(effect.getSkill().getId()).append(",");
              sb.append(effect.getSkill().getLevel()).append(",");
              sb.append(effect.getCount()).append(",");
              sb.append(effect.getTime()).append(",");
              sb.append(effect.getPeriod()).append(",");
              sb.append(order).append(",");
              sb.append(getActiveClassId()).append(")");
              b.write(sb.toString());
            }
            while((effect = effect.getNext()) != null && effect.isSaveable())
            {
              sb = new StringBuilder("(");
              sb.append(getObjectId()).append(",");
              sb.append(effect.getSkill().getId()).append(",");
              sb.append(effect.getSkill().getLevel()).append(",");
              sb.append(effect.getCount()).append(",");
              sb.append(effect.getTime()).append(",");
              sb.append(effect.getPeriod()).append(",");
              sb.append(order).append(",");
              sb.append(getActiveClassId()).append(")");
              b.write(sb.toString());
            }
            order++;
          }
        }
        if(Config.ALT_SAVE_UNSAVEABLE && _cubics != null)
        {
          for(L2CubicInstance cubic : _cubics)
          {
            sb = new StringBuilder("(");
            sb.append(getObjectId()).append(",");
            sb.append(cubic.getId() + L2CubicInstance.CUBIC_STORE_OFFSET).append(",");
            sb.append(cubic.getLevel()).append(",1,");
            sb.append(cubic.lifeLeft()).append(",1,");
            sb.append(order++).append(",");
            sb.append(getActiveClassId()).append(")");
            b.write(sb.toString());
          }
        }
      }
      if(!b.isEmpty())
      {
        statement.executeUpdate(b.close());
      }
    }
    catch(final Exception e)
    {
      _log.warning("Could not store active effects data: " + e);
View Full Code Here

  }

  public void restoreDisableSkills()
  {
    ThreadConnection con = null;
    FiltredStatement statement = null;
    ResultSet rset = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.createStatement();
      rset = statement.executeQuery("SELECT skill_id,end_time,reuse_delay_org FROM character_skills_save WHERE char_obj_id=" + getObjectId() + " AND class_index=" + getActiveClassId());
      while(rset.next())
      {
        int skillId = rset.getInt("skill_id");
        int skillLevel = Math.max(getSkillLevel(skillId), 1);
        long endTime = rset.getLong("end_time");
        long rDelayOrg = rset.getLong("reuse_delay_org");
        long curTime = System.currentTimeMillis();
        L2Skill skill = SkillTable.getInstance().getInfo(skillId, skillLevel);
        if(skill != null && endTime - curTime > 500)
        {
          getSkillReuseTimeStamps().put(skillId, new SkillTimeStamp(skillId, endTime, rDelayOrg));
          disableItem(skill, rDelayOrg, endTime - curTime);
        }
      }
      DatabaseUtils.closeStatement(statement);
      statement = con.createStatement();
      statement.executeUpdate("DELETE FROM character_skills_save WHERE char_obj_id = " + getObjectId() + " AND class_index=" + getActiveClassId() + " AND `end_time` < " + System.currentTimeMillis());
    }
    catch(Exception e)
    {
      _log.warning("Could not restore active skills data for " + getObjectId() + "/" + getActiveClassId());
      e.printStackTrace();
View Full Code Here

  }

  private void storeBlockList()
  {
    ThreadConnection con = null;
    FiltredStatement statement = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.createStatement();
      statement.executeUpdate("DELETE FROM character_blocklist WHERE obj_Id=" + getObjectId());
      if(_blockList.isEmpty())
      {
        return;
      }
      SqlBatch b = new SqlBatch("INSERT IGNORE INTO `character_blocklist` (`obj_Id`,`target_Id`) VALUES");
      synchronized(_blockList)
      {
        StringBuilder sb;
        for(Entry<Integer, String> e : _blockList.entrySet())
        {
          sb = new StringBuilder("(");
          sb.append(getObjectId()).append(",");
          sb.append(e.getKey()).append(")");
          b.write(sb.toString());
        }
      }
      if(!b.isEmpty())
      {
        statement.executeUpdate(b.close());
      }
    }
    catch(Exception e)
    {
      _log.warning("Can't store player blocklist " + e);
View Full Code Here

    else
    {
      _log.warning("Could not store char sub data, main class " + getActiveClassId() + " not found for " + this);
    }
    ThreadConnection con = null;
    FiltredStatement statement = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.createStatement();
      StringBuilder sb;
      for(L2SubClass subClass : getSubClasses().values())
      {
        sb = new StringBuilder("UPDATE character_subclasses SET ");
        sb.append("exp=").append(subClass.getExp()).append(",");
        sb.append("sp=").append(subClass.getSp()).append(",");
        sb.append("curHp=").append(subClass.getHp()).append(",");
        sb.append("curMp=").append(subClass.getMp()).append(",");
        sb.append("curCp=").append(subClass.getCp()).append(",");
        sb.append("level=").append(subClass.getLevel()).append(",");
        sb.append("active=").append(subClass.isActive() ? 1 : 0).append(",");
        sb.append("isBase=").append(subClass.isBase() ? 1 : 0).append(",");
        sb.append("death_penalty=").append(subClass.getDeathPenalty().getLevelOnSaveDB()).append(",");
        sb.append("skills='").append(subClass.getSkills()).append("'");
        sb.append(" WHERE char_obj_id=").append(getObjectId()).append(" AND class_id=").append(subClass.getClassId()).append(" LIMIT 1");
        statement.executeUpdate(sb.toString());
      }
      sb = new StringBuilder("UPDATE LOW_PRIORITY character_subclasses SET ");
      sb.append("maxHp=").append(getMaxHp()).append(",");
      sb.append("maxMp=").append(getMaxMp()).append(",");
      sb.append("maxCp=").append(getMaxCp());
      sb.append(" WHERE char_obj_id=").append(getObjectId()).append(" AND active=1 LIMIT 1");
      statement.executeUpdate(sb.toString());
    }
    catch(final Exception e)
    {
      _log.warning("Could not store char sub data: " + e);
      e.printStackTrace();
View Full Code Here

  private void loadStatus()
  {
    _storedInfo = new FastMap<Integer, StatsSet>().setShared(true);
    ThreadConnection con = null;
    FiltredStatement statement = null;
    ResultSet rset = null;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      rset = con.createStatement().executeQuery("SELECT * FROM `raidboss_status`");
View Full Code Here

  private void restorePointsTable()
  {
    pointsLock.lock();
    _points = new FastMap<Integer, FastMap<Integer, Integer>>().setShared(true);
    ThreadConnection con = null;
    FiltredStatement statement = null;
    ResultSet rset = null;
    try
    {
      //read raidboss points
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.createStatement();
      rset = statement.executeQuery("SELECT owner_id, boss_id, points FROM `raidboss_points` ORDER BY owner_id ASC");
      int currentOwner = 0;
      FastMap<Integer, Integer> score = null;
      while(rset.next())
      {
        if(currentOwner != rset.getInt("owner_id"))
View Full Code Here

    {
      pointsLock.unlock();
      return;
    }
    ThreadConnection con = null;
    FiltredStatement statement = null;
    StringBuilder sb;
    try
    {
      con = L2DatabaseFactory.getInstance().getConnection();
      statement = con.createStatement();
      SqlBatch b = new SqlBatch("INSERT INTO `raidboss_points` (owner_id, boss_id, points) VALUES");
      for(Entry<Integer, FastMap<Integer, Integer>> pointEntry : _points.entrySet())
      {
        FastMap<Integer, Integer> tmpPoint = pointEntry.getValue();
        if(tmpPoint == null || tmpPoint.isEmpty())
        {
          continue;
        }
        for(Entry<Integer, Integer> pointListEntry : tmpPoint.entrySet())
        {
          if(KEY_RANK.equals(pointListEntry.getKey()) || KEY_TOTAL_POINTS.equals(pointListEntry.getKey()) || pointListEntry.getValue() == null || pointListEntry.getValue() == 0)
          {
            continue;
          }
          sb = new StringBuilder("(");
          sb.append(pointEntry.getKey()).append(","); // игрок
          sb.append(pointListEntry.getKey()).append(","); // босс
          sb.append(pointListEntry.getValue()).append(")"); // количество очков
          b.write(sb.toString());
        }
      }
      if(!b.isEmpty())
      {
        statement.executeUpdate(b.close());
      }
    }
    catch(SQLException e)
    {
      _log.warning("RaidBossSpawnManager: Couldnt update raidboss_points table");
View Full Code Here

TOP

Related Classes of l2p.database.FiltredStatement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.