ClientThread.java

Index Score
net.sf.l2j.gameserver
L2J

View: Reasons, Metrics, Source Code

These are the metrics that contribute to the Enerjy Score for this file, ranked by impact. So the metrics listed at the top influence the score to a greater extent that the metrics listed at the bottom.

MetricDescription
EXITSProcedure exits
JAVA0076JAVA0076 Use of magic number
LOGICAL_LINESNumber of statements
OPERANDSNumber of operands
JAVA0020JAVA0020 Field name does not have required form
JAVA0166JAVA0166 Generic exception caught
PROGRAM_LENGTHHalstead program length
UNIQUE_OPERANDSNumber of unique operands
OPERATORSNumber of operators
PROGRAM_VOCABHalstead program vocabulary
LOCLines of code
ELOCEffective lines of code
LINESNumber of lines in the source file
SIZESize of the file in bytes
LOOPSNumber of loops
JAVA0130JAVA0130 Non-static method does not use instance fields
JAVA0144JAVA0144 Line exceeds maximum M characters
JAVA0265JAVA0265 Use of Throwable.printStackTrace()
JAVA0034JAVA0034 Missing braces in if statement
JAVA0109JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA0177JAVA0177 Variable declaration missing initializer
JAVA0145JAVA0145 Tab character used in source file
RETURNSNumber of return points from functions
JAVA0270JAVA0270 Use Java 5.0 enhanced for loop construct to iterate over all elements in an array
BLOCKSNumber of blocks
JAVA0108JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
BLOCK_COMMENTNumber of block comment lines
JAVA0171JAVA0171 Unused local variable
JAVA0030JAVA0030 Private field not used
JAVA0117JAVA0117 Missing javadoc: method 'method'
INTERFACE_COMPLEXITYInterface complexity
JAVA0006JAVA0006 Empty finally block
EXEC_COMMENTSComments in executable code
PROGRAM_VOLUMEHalstead program volume
JAVA0136JAVA0136 N methods defined in class (maximum: M)
UNIQUE_OPERATORSNumber of unique operators
JAVA0126JAVA0126 Method declares unchecked exception in throws
JAVA0273JAVA0273 Non-final derivative of Thread calls start() in constructor
JAVA0110JAVA0110 Incorrect javadoc: no @return tag
JAVA0264JAVA0264 Integer math in long context - check for overflow
JAVA0173JAVA0173 Unused method parameter
COMMENTSComment lines
JAVA0100JAVA0100 Class contains N non-final fields (maximum: M)
NEST_DEPTHMaximum nesting depth
/* * $Header: /cvsroot/l2j/L2_Gameserver/java/net/sf/l2j/gameserver/ClientThread.java,v 1.21 2004/11/19 08:54:43 l2chef Exp $ * * $Author: l2chef $ * $Date: 2004/11/19 08:54:43 $ * $Revision: 1.21 $ * $Log: ClientThread.java,v $ * Revision 1.21 2004/11/19 08:54:43 l2chef * database is now used * * Revision 1.20 2004/11/14 20:31:01 dethx * minor mp bonus fixes (DETH) * * Revision 1.19 2004/11/07 13:00:38 l2chef * basemp and effectivemp are now used * * Revision 1.18 2004/10/17 06:46:23 l2chef * no more direct access to Item collection to avoid wrong usage * * Revision 1.17 2004/09/16 00:03:04 l2chef * fistweapon is set on restore (Deth) * * Revision 1.16 2004/08/14 22:30:19 l2chef * unknown methods renamed * * Revision 1.15 2004/08/10 00:47:00 l2chef * clan reference is set on load, automatic expel from clan added * * Revision 1.14 2004/08/08 22:57:00 l2chef * resetting active char is now possible * * Revision 1.13 2004/08/08 16:33:34 l2chef * deleteme method of L2pcinstance is used to cleanup * * Revision 1.12 2004/07/25 23:00:38 l2chef * pet system started (whatev) * * Revision 1.11 2004/07/25 00:36:49 l2chef * warehouse file is now also deleted when a char is deleted (Deth) * * Revision 1.10 2004/07/23 01:42:35 l2chef * all object spawn and delete is now handeld in L2PcInstance * * Revision 1.9 2004/07/19 02:02:56 l2chef * party code completed (whatev) * some exception cases fixed * * Revision 1.8 2004/07/17 12:15:43 l2chef * logging removed (NuocNam) * * Revision 1.7 2004/07/13 23:17:05 l2chef * log message added and empty blocks commented * * Revision 1.6 2004/07/12 20:53:03 l2chef * warehouses added (nuocnam) * char data is now stored in subfolder data/accounts * * Revision 1.5 2004/07/11 23:41:22 l2chef * chars are always reloaded from disk and stored every 15mins (whatev) * * Revision 1.4 2004/07/05 23:03:31 l2chef * access levels are stored for logins * * Revision 1.3 2004/06/30 21:51:33 l2chef * using jdk logger instead of println * * Revision 1.2 2004/06/27 08:51:43 jeichhorn * Added copyright notice * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA * 02111-1307, USA. * * http://www.gnu.org/copyleft/gpl.html */ package net.sf.l2j.gameserver; import java.io.File; import java.io.IOException; import java.net.Socket; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.ArrayList; import java.util.logging.Logger; import net.sf.l2j.L2DatabaseFactory; import net.sf.l2j.gameserver.model.L2Clan; import net.sf.l2j.gameserver.model.L2ItemInstance; import net.sf.l2j.gameserver.model.L2PcInstance; import net.sf.l2j.gameserver.model.L2ShortCut; import net.sf.l2j.gameserver.model.L2Skill; import net.sf.l2j.gameserver.model.L2World; import net.sf.l2j.gameserver.templates.L2Item; import net.sf.l2j.loginserver.LoginController; /** * This class ... * * @version $Revision: 1.21 $ $Date: 2004/11/19 08:54:43 $ */ public class ClientThread extends Thread { private static Logger _log = Logger.getLogger(ClientThread.class.getName()); private String _loginName; private L2PcInstance _activeChar; private int _sessionId; private byte[] _filter; private byte[] _cryptkey = { (byte)0x94, (byte)0x35, (byte)0x00, (byte)0x00, (byte)0xa1, (byte)0x6c, (byte)0x54, (byte)0x87 // these 4 bytes are fixed }; private File _userFolder; private File _charFolder; private long _autoSaveTime; private Connection _connection; private PacketHandler _handler; private L2World _world; public ClientThread(Socket client) throws IOException { _connection = new Connection(client, _cryptkey); _sessionId = 0x12345678; _handler = new PacketHandler(this); _world = L2World.getInstance(); _autoSaveTime = 60000 * 15;//15 min start(); } public void run() { _log.fine("thread[C] started"); long starttime = System.currentTimeMillis(); boolean checksumOk = false; try { while (true) { if ((_activeChar != null) && (_autoSaveTime < (System.currentTimeMillis() - starttime))) { saveCharToDisk(_activeChar); starttime = System.currentTimeMillis(); } byte[] decrypt = _connection.getPacket(); _handler.handlePacket(decrypt); } } catch (IOException io) { // this happens when the client disconnects } catch (Exception e) { e.printStackTrace(); } finally { try { if (_activeChar != null) // this should only happen on connection loss { // notify the world about our disconnect _activeChar.deleteMe(); try { saveCharToDisk(_activeChar); } catch (Exception e2) { // ignore any problems here } } _connection.close(); } catch (Exception e1) { _log.warning(e1.toString()); } finally { // remove the account LoginController.getInstance().removeGameServerLogin(getLoginName()); } } _log.fine("gameserver thread[C] stopped"); } /** * */ public void saveCharToDisk(L2PcInstance cha) { storeChar(cha); storeInventory(cha); storeSkills(cha); storeShortcuts(cha); storeWarehouse(cha); IdFactory.getInstance().saveCurrentState(); } /** * @param cha * @param saveFile */ private void storeShortcuts(L2PcInstance cha) { try { L2ShortCut[] scs = cha.getAllShortCuts(); java.sql.Connection con = null; con = L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement = con.prepareStatement("DELETE FROM character_shortcuts WHERE char_obj_id=?"); statement.setInt(1, cha.getObjectId()); statement.execute(); statement.close(); con.close(); for (int x =0 ; x < scs.length;x++) { statement = con.prepareStatement("INSERT INTO character_shortcuts SET char_obj_id=?,slot=?,type=?,shortcut_id=?,level=?,unknown=?"); statement.setInt(1, cha.getObjectId()); statement.setInt(2, scs[x].getSlot()); statement.setInt(3, scs[x].getType()); statement.setInt(4, scs[x].getId()); statement.setInt(5, scs[x].getLevel()); statement.setInt(6, scs[x].getUnk()); statement.execute(); statement.close(); } } catch (Exception e) { _log.warning("could not store shortcuts:" + e.toString()); e.printStackTrace(); } } public void deleteChar(int charslot) throws Exception { //have to make sure active character must be nulled if (getActiveChar() != null) { saveCharToDisk (getActiveChar()); _log.fine("active Char saved"); _activeChar = null; } int objid = 0; String charname=""; java.sql.Connection con = null; con = L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement = con.prepareStatement("SELECT obj_id FROM characters WHERE account_name=? ORDER BY char_name"); statement.setString(1, _loginName); ResultSet result = statement.executeQuery(); while (result.next()) { if (result.getRow() == charslot+1) { objid = result.getInt("obj_id"); break; } } result.close(); statement.close(); statement = con.prepareStatement("DELETE FROM characters WHERE obj_Id=?"); statement.setInt(1, objid); statement.execute(); statement.close(); statement = con.prepareStatement("DELETE FROM character_shortcuts WHERE char_obj_id=?"); statement.setInt(1, objid); statement.execute(); statement.close(); statement = con.prepareStatement("DELETE FROM character_inventory WHERE obj_Id=?"); statement.setInt(1, objid); statement.execute(); statement.close(); statement = con.prepareStatement("DELETE FROM character_warehouse WHERE obj_Id=?"); statement.setInt(1, objid); statement.execute(); statement.close(); statement = con.prepareStatement("DELETE FROM character_skills WHERE obj_Id=?"); statement.setInt(1, objid); statement.execute(); statement.close(); con.close(); } public L2PcInstance loadCharFromDisk(int charslot) { L2PcInstance character = new L2PcInstance(); character = restoreChar(charslot); if (character != null) { restoreInventory(character); restoreSkills(character); restoreShortCuts(character); restoreWarehouse(character); if (character.getClanId() != 0) { L2Clan clan = ClanTable.getInstance().getClan(character.getClanId()); if (!clan.isMember(character.getName())) { // char has been kicked from clan character.setClanId(0); character.setTitle(""); } else { character.setClan(clan); character.setIsClanLeader(clan.getLeaderId() == character.getObjectId()); } } } else { _log.warning("could not restore in slot:"+ charslot); } //setCharacter(character); return character; } /** * @param file * @param restored */ private void restoreShortCuts(L2PcInstance restored) { try { java.sql.Connection con = null; con = L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement = con.prepareStatement("SELECT * FROM character_shortcuts WHERE char_obj_id=?"); statement.setInt(1, restored.getObjectId()); ResultSet rset = statement.executeQuery(); while (rset.next()) { int slot = rset.getInt("slot"); int type = rset.getInt("type"); int id = rset.getInt("shortcut_id"); int level = rset.getInt("level"); int unk = rset.getInt("unknown"); L2ShortCut sc = new L2ShortCut(slot, type, id, level, unk); restored.registerShortCut(sc); } rset.close(); statement.close(); } catch (Exception e) { _log.warning("could not restore shortcuts:"+e); } } /** * @param cha * @param saveFile */ private void storeInventory(L2PcInstance cha) { try { java.sql.Connection con = null; con = L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement = con.prepareStatement("DELETE FROM character_inventory WHERE char_obj_id=?"); statement.setInt(1, cha.getObjectId()); statement.execute(); statement.close(); L2ItemInstance[] inv = cha.getInventory().getItems(); L2ItemInstance temp; for (int x =0 ; x < inv.length;x++) { temp = inv[x]; statement = con.prepareStatement("INSERT INTO character_inventory SET char_obj_id=?,object_id=?,item_id=?,name=?,count=?,price=?,equipSlot=?"); statement.setInt(1, cha.getObjectId()); statement.setInt(2, temp.getObjectId()); statement.setInt(3, temp.getItemId()); statement.setString(4, temp.getItem().getName()); statement.setInt(5, temp.getCount()); statement.setInt(6, temp.getPrice()); statement.setInt(7, temp.getEquipSlot()); statement.execute(); statement.close(); } con.close(); } catch (Exception e) { _log.warning("could not store characters inventory:"+e); } } /** * @param cha * @param saveFile */ private void storeSkills(L2PcInstance cha) { try { java.sql.Connection con = null; con = L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement = con.prepareStatement("DELETE FROM character_skills WHERE char_obj_id=?"); statement.setInt(1, cha.getObjectId()); statement.execute(); statement.close(); L2Skill[] skills = cha.getAllSkills(); for (int count=0; count < skills.length; count++) { statement = con.prepareStatement("INSERT INTO character_skills SET char_obj_id=?,skill_id=?,skill_level=?,skill_name=?"); statement.setInt(1, cha.getObjectId()); statement.setInt(2, skills[count].getId()); statement.setInt(3, skills[count].getLevel()); statement.setString(4, skills[count].getName()); statement.execute(); statement.close(); } con.close(); } catch (Exception e) { _log.warning("could not store skills:"+e); e.printStackTrace(); } } private void storeChar(L2PcInstance cha) { try { java.sql.Connection con = null; con = L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement = con.prepareStatement("DELETE FROM characters WHERE obj_id=?"); statement.setInt(1, cha.getObjectId()); statement.execute(); statement.close(); statement = con.prepareStatement("INSERT INTO characters SET account_name=?,obj_Id=?,char_name=?,level=?,maxHp=?,curHp=?,maxMp=?,curMp=?,acc=?,crit=?,evasion=?,mAtk=?,mDef=?,mSpd=?,pAtk=?,pDef=?,pSpd=?,runSpd=?,walkSpd=?,str=?,con=?,dex=?,_int=?,men=?,wit=?,face=?,hairStyle=?,hairColor=?,sex=?,heading=?,x=?,y=?,z=?,movement_multiplier=?,attack_speed_multiplier=?,colRad=?,colHeight=?,exp=?,sp=?,karma=?,pvpkills=?,pkkills=?,clanid=?,maxload=?,race=?,classid=?,deletetime=?,cancraft=?,title=?,allyId=?,accesslevel=?"); statement.setString(1, _loginName); statement.setInt(2, cha.getObjectId()); statement.setString(3, cha.getName()); statement.setInt(4, cha.getLevel()); statement.setInt(5, cha.getMaxHp()); statement.setDouble(6, cha.getCurrentHp()); statement.setInt(7, cha.getMaxBaseMp()); statement.setDouble(8, cha.getCurrentMp()); statement.setInt(9, cha.getAccuracy()); statement.setInt(10, cha.getCriticalHit()); statement.setInt(11, cha.getEvasionRate()); statement.setInt(12, cha.getMagicalAttack()); statement.setInt(13, cha.getMagicalDefense()); statement.setInt(14, cha.getMagicalSpeed()); statement.setInt(15, cha.getPhysicalAttack()); statement.setInt(16, cha.getPhysicalDefense()); statement.setInt(17, cha.getPhysicalSpeed()); statement.setInt(18, cha.getRunSpeed()); statement.setInt(19, cha.getWalkSpeed()); statement.setInt(20, cha.getStr()); statement.setInt(21, cha.getCon()); statement.setInt(22, cha.getDex()); statement.setInt(23, cha.getInt()); statement.setInt(24, cha.getMen()); statement.setInt(25, cha.getWit()); statement.setInt(26, cha.getFace()); statement.setInt(27, cha.getHairStyle()); statement.setInt(28, cha.getHairColor()); statement.setInt(29, cha.getSex()); statement.setInt(30, cha.getHeading()); statement.setInt(31, cha.getX()); statement.setInt(32, cha.getY()); statement.setInt(33, cha.getZ()); statement.setDouble(34, cha.getMovementMultiplier()); statement.setDouble(35, cha.getAttackSpeedMultiplier()); statement.setDouble(36, cha.getCollisionRadius()); statement.setDouble(37, cha.getCollisionHeight()); statement.setInt(38, cha.getExp()); statement.setInt(39, cha.getSp()); statement.setInt(40, cha.getKarma()); statement.setInt(41, cha.getPvpKills()); statement.setInt(42, cha.getPkKills()); statement.setInt(43, cha.getClanId()); statement.setInt(44, cha.getMaxLoad()); statement.setInt(45, cha.getRace()); statement.setInt(46, cha.getClassId()); statement.setInt(47, cha.getDeleteTimer()); statement.setInt(48, cha.getCanCraft()); statement.setString(49, cha.getTitle()); statement.setInt(50, cha.getAllyId()); statement.setInt(51, cha.getAccessLevel()); statement.execute(); statement.close(); con.close(); } catch (Exception e) { _log.warning("could not store char data:"+e); } } private void restoreWarehouse(L2PcInstance cha) { try { java.sql.Connection con = null; con = L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement = con.prepareStatement("SELECT * FROM character_warehouse WHERE char_obj_id=?"); statement.setInt(1, cha.getObjectId()); ResultSet rset = statement.executeQuery(); L2ItemInstance item; while (rset.next()) { item = new L2ItemInstance(); item.setObjectId(rset.getInt(2)); int itemId = rset.getInt(3); L2Item itemTemp = ItemTable.getInstance().getTemplate(itemId); item.setItem(itemTemp); item.setCount(rset.getInt(5)); cha.getWarehouse().addItem(item); // add this item to the world _world.storeObject(item); } rset.close(); statement.close(); con.close(); } catch (Exception e) { _log.warning("could not restore warehouse:"+e); } } private void storeWarehouse(L2PcInstance cha) { try { java.sql.Connection con = null; con = L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement = con.prepareStatement("DELETE FROM character_warehouse WHERE char_obj_id=?"); statement.setInt(1, cha.getObjectId()); statement.execute(); statement.close(); ArrayList wh = cha.getWarehouse().getItems(); L2ItemInstance temp; for (int x =0 ; x < wh.size();x++) { temp = (L2ItemInstance) wh.get(x); statement = con.prepareStatement("INSERT INTO character_warehouse SET char_obj_id=?,object_id=?,item_id=?,name=?,count=?"); statement.setInt(1, cha.getObjectId()); statement.setInt(2, temp.getObjectId()); statement.setInt(3, temp.getItemId()); statement.setString(4, temp.getItem().getName()); statement.setInt(5, temp.getCount()); statement.execute(); statement.close(); _log.fine("warehouse saved item:" + temp.getItem().getName()); } con.close(); } catch (Exception e) { _log.warning("could not store characters warehouse:"+e); } } /** * @param string */ private void restoreInventory(L2PcInstance cha) { try { java.sql.Connection con = null; con = L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement = con.prepareStatement("SELECT * FROM character_inventory WHERE char_obj_id=? ORDER BY object_id DESC"); statement.setInt(1, cha.getObjectId()); ResultSet inv = statement.executeQuery(); L2ItemInstance item; while (inv.next()) { item = new L2ItemInstance(); item.setObjectId(inv.getInt(2)); int itemId = inv.getInt(3); L2Item itemTemp = ItemTable.getInstance().getTemplate(itemId); item.setItem(itemTemp); item.setCount(inv.getInt(5)); item.setPrice(inv.getInt(6)); item.setEquipSlot(inv.getInt(7)); cha.getInventory().addItem(item); if (item.isEquipped()) { cha.getInventory().equipItem(item); } // add this item to the world _world.storeObject(item); } inv.close(); statement.close(); con.close(); cha.updateMpBonus(); } catch (Exception e) { _log.warning("could not restore inventory:"+e); } finally { } } /** * @param string */ private void restoreSkills(L2PcInstance cha) { try { java.sql.Connection con = null; con = L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement = con.prepareStatement("SELECT * FROM character_skills WHERE char_obj_id=?"); statement.setInt(1, cha.getObjectId()); ResultSet rset = statement.executeQuery(); while (rset.next()) { int id = rset.getInt(2); int level = rset.getInt(3); L2Skill skill = SkillTable.getInstance().getInfo(id, level); cha.addSkill(skill); } rset.close(); statement.close(); con.close(); } catch (Exception e) { _log.warning("count not restore skills:"+e); } } /** * @param line * @return */ private L2PcInstance restoreChar(int charslot) { L2PcInstance oldChar = new L2PcInstance(); try { java.sql.Connection con = null; con = L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement = con.prepareStatement("SELECT * FROM characters WHERE account_name=? ORDER BY char_name"); statement.setString(1, _loginName); ResultSet rset = statement.executeQuery(); while (rset.next()) { if (rset.getRow() != charslot+1) { continue; } oldChar.setObjectId(rset.getInt(2)); oldChar.setName(rset.getString(3)); oldChar.setLevel(rset.getInt(4)); oldChar.setMaxHp(rset.getInt(5)); oldChar.setCurrentHp(rset.getDouble(6)); oldChar.setMaxBaseMp(rset.getInt(7)); oldChar.setCurrentMp(rset.getDouble(8)); oldChar.setAccuracy(rset.getInt(9)); oldChar.setCriticalHit(rset.getInt(10)); oldChar.setEvasionRate(rset.getInt(11)); oldChar.setMagicalAttack(rset.getInt(12)); oldChar.setMagicalDefense(rset.getInt(13)); oldChar.setMagicalSpeed(rset.getInt(14)); oldChar.setPhysicalAttack(rset.getInt(15)); oldChar.setPhysicalDefense(rset.getInt(16)); oldChar.setPhysicalSpeed(rset.getInt(17)); oldChar.setRunSpeed(rset.getInt(18)); oldChar.setWalkSpeed(rset.getInt(19)); oldChar.setStr(rset.getInt(20)); oldChar.setCon(rset.getInt(21)); oldChar.setDex(rset.getInt(22)); oldChar.setInt(rset.getInt(23)); oldChar.setMen(rset.getInt(24)); oldChar.setWit(rset.getInt(25)); oldChar.setFace(rset.getInt(26)); oldChar.setHairStyle(rset.getInt(27)); oldChar.setHairColor(rset.getInt(28)); oldChar.setSex(rset.getInt(29)); oldChar.setHeading(rset.getInt(30)); oldChar.setX(rset.getInt(31)); oldChar.setY(rset.getInt(32)); oldChar.setZ(rset.getInt(33)); oldChar.setMovementMultiplier(rset.getDouble(34)); oldChar.setAttackSpeedMultiplier(rset.getDouble(35)); oldChar.setCollisionRadius(rset.getDouble(36)); oldChar.setCollisionHeight(rset.getDouble(37)); oldChar.setExp(rset.getInt(38)); oldChar.setSp(rset.getInt(39)); oldChar.setKarma(rset.getInt(40)); oldChar.setPvpKills(rset.getInt(41)); oldChar.setPkKills(rset.getInt(42)); oldChar.setClanId(rset.getInt(43)); oldChar.setMaxLoad(rset.getInt(44)); oldChar.setRace(rset.getInt(45)); oldChar.setClassId(rset.getInt(46)); oldChar.setDeleteTimer(rset.getInt(47)); oldChar.setCanCraft(rset.getInt(48)); oldChar.setTitle(rset.getString(49)); //oldChar.setCrestId(rset.getInt()); oldChar.setAllyId(rset.getInt(50)); oldChar.setAccessLevel(rset.getInt(51)); L2World.getInstance().storeObject(oldChar); } rset.close(); statement.close(); con.close(); } catch (Exception e) { _log.warning("could not restore char data:"+e); e.printStackTrace(); } return oldChar; } /** * @return */ public Connection getConnection() { return _connection; } /** * @return */ public L2PcInstance getActiveChar() { return _activeChar; } /** * @return Returns the sessionId. */ public int getSessionId() { return _sessionId; } public String getLoginName() { return _loginName; } public void setLoginFolder(String folder) { _charFolder = new File("data/accounts",_loginName); _charFolder.mkdirs(); } public void setLoginName(String loginName) { _loginName = loginName; } /** * @param cha */ public void setActiveChar(L2PcInstance cha) { _activeChar = cha; if (cha != null) { // we store the connection in the player object so that external // events can directly send events to the players client // might be changed later to use a central event management and distribution system _activeChar.setNetConnection(_connection); // update world data _world.storeObject(_activeChar); } } }

The table below shows all metrics for ClientThread.java.

MetricValueDescription
BLOCKS75.00Number of blocks
BLOCK_COMMENT87.00Number of block comment lines
COMMENTS147.00Comment lines
COMMENT_DENSITY 0.32Comment density
COMPARISONS25.00Number of comparison operators
CYCLOMATIC58.00Cyclomatic complexity
DECL_COMMENTS14.00Comments in declarations
DOC_COMMENT46.00Number of javadoc comment lines
ELOC463.00Effective lines of code
EXEC_COMMENTS12.00Comments in executable code
EXITS193.00Procedure exits
FUNCTIONS22.00Number of function declarations
HALSTEAD_DIFFICULTY84.77Halstead difficulty
HALSTEAD_EFFORT 0.00Halstead effort
INTERFACE_COMPLEXITY70.00Interface complexity
JAVA0001 1.00JAVA0001 Package name does not contain only lower case letters
JAVA0002 0.00JAVA0002 Package name does not begin with a top level domain name or country code
JAVA0003 0.00JAVA0003 Minimize use of on-demand (.*) imports
JAVA0004 0.00JAVA0004 Unnecessary import from java.lang
JAVA0005 0.00JAVA0005 Imports not in specified order
JAVA0006 1.00JAVA0006 Empty finally block
JAVA0007 0.00JAVA0007 Should not declare public field
JAVA0008 0.00JAVA0008 Empty catch block
JAVA0009 0.00JAVA0009 Protected member in final class
JAVA0010 0.00JAVA0010 Non-instantiable class does not contain a non-private static member
JAVA0011 0.00JAVA0011 Abstract class does not contain an abstract method
JAVA0012 0.00JAVA0012 Non-constructor method with same name as declaring class
JAVA0013 0.00JAVA0013 Non-blank final field is not static
JAVA0014 0.00JAVA0014 Class with only static members has non-private constructor
JAVA0015 0.00JAVA0015 Package class contains public nested type
JAVA0016 0.00JAVA0016 Abstract class contains public constructor
JAVA0017 0.00JAVA0017 Class name does not have required form
JAVA0018 0.00JAVA0018 Method name does not have required form
JAVA0019 0.00JAVA0019 Interface name does not have required form
JAVA002011.00JAVA0020 Field name does not have required form
JAVA0021 0.00JAVA0021 Interface method name does not have required form
JAVA0022 0.00JAVA0022 Static final field name does not have required form
JAVA0023 0.00JAVA0023 Empty finalize method
JAVA0024 0.00JAVA0024 Empty class
JAVA0025 0.00JAVA0025 Method override is empty
JAVA0026 0.00JAVA0026 Finalize method with parameters
JAVA0029 0.00JAVA0029 Private method not used
JAVA0030 2.00JAVA0030 Private field not used
JAVA0031 0.00JAVA0031 Case statement not properly closed
JAVA0032 0.00JAVA0032 Switch statement missing default
JAVA0033 0.00JAVA0033 default: not last case in switch statement
JAVA0034 0.00JAVA0034 Missing braces in if statement
JAVA0035 0.00JAVA0035 Missing braces in for statement
JAVA0036 0.00JAVA0036 Missing braces in while statement
JAVA0038 0.00JAVA0038 Non-case label in switch statement
JAVA0039 0.00JAVA0039 Break statement with label
JAVA0040 0.00JAVA0040 Switch statement contains N cases (maximum: M)
JAVA0041 0.00JAVA0041 Nested synchronized block
JAVA0042 0.00JAVA0042 Empty synchronized statement
JAVA0043 0.00JAVA0043 Inner class does not use outer class
JAVA0044 0.00JAVA0044 Serializable class with no instance variables
JAVA0045 0.00JAVA0045 Serializable class with only transient fields
JAVA0046 0.00JAVA0046 Name of class not derived from Exception ends with 'Exception'
JAVA0047 0.00JAVA0047 Serializable class derives from invalid base class
JAVA0048 0.00JAVA0048 Name of class derived from Exception does not end with 'Exception'
JAVA0049 0.00JAVA0049 Nested block at depth N (maximum: M)
JAVA0050 0.00JAVA0050 Class derives from java.lang.Error
JAVA0051 0.00JAVA0051 Class derives from java.lang.RuntimeException
JAVA0052 0.00JAVA0052 Class derives from java.lang.Throwable
JAVA0053 0.00JAVA0053 Unused label
JAVA0054 0.00JAVA0054 Inheritance depth N exceeds maximum M
JAVA0055 0.00JAVA0055 Class should be interface
JAVA0056 0.00JAVA0056 Unnecessary abstract modifier for interface or annotation
JAVA0057 0.00JAVA0057 Unnecessary default constructor
JAVA0058 0.00JAVA0058 Constructor calls super()
JAVA0059 0.00JAVA0059 Method override only calls super()
JAVA0061 0.00JAVA0061 Inaccessible member in anonymous class
JAVA0062 0.00JAVA0062 Public class missing public member or protected constructor
JAVA0063 0.00JAVA0063 Identifier name should not contain '$'
JAVA0064 0.00JAVA0064 N variations of identifier name (maximum: M)
JAVA0065 0.00JAVA0065 Unnecessary final modifier for method in final class
JAVA0066 0.00JAVA0066 Unnecessary modifier for interface nested type
JAVA0067 0.00JAVA0067 Array descriptor on identifier name
JAVA0068 0.00JAVA0068 Modifiers not declared in recommended order
JAVA0071 0.00JAVA0071 Strings compared with ==
JAVA0073 0.00JAVA0073 Integer division in floating-point context
JAVA0074 0.00JAVA0074 Use of Object.notify()
JAVA0075 0.00JAVA0075 Method parameter hides field
JAVA0076100.00JAVA0076 Use of magic number
JAVA0077 0.00JAVA0077 Private field not used in declaring class
JAVA0078 0.00JAVA0078 Floating point values compared with ==
JAVA0079 0.00JAVA0079 Use of instance to reference static member
JAVA0080 0.00JAVA0080 Import declaration not used
JAVA0081 0.00JAVA0081 Boolean literal in comparison
JAVA0082 0.00JAVA0082 Unnecessary widening cast
JAVA0083 0.00JAVA0083 Unnecessary instanceof test
JAVA0084 0.00JAVA0084 Should use compound assignment operator
JAVA0085 0.00JAVA0085 Use of sun.* class
JAVA0087 0.00JAVA0087 Use of Thread.sleep()
JAVA0089 0.00JAVA0089 Use of restricted package
JAVA0092 0.00JAVA0092 Use of restricted type
JAVA0093 0.00JAVA0093 Redundant assignment
JAVA0094 0.00JAVA0094 Field hides a superclass field
JAVA0095 0.00JAVA0095 Uninitialized private field
JAVA0096 0.00JAVA0096 Field in nested class hides outer field
JAVA0098 0.00JAVA0098 Minimize use of implicit field initializers
JAVA0100 1.00JAVA0100 Class contains N non-final fields (maximum: M)
JAVA0101 0.00JAVA0101 Unnecessary modifier for field in interface
JAVA0102 0.00JAVA0102 Last statement in finalize() not super.finalize()
JAVA0103 0.00JAVA0103 Explicit call to finalize()
JAVA0104 0.00JAVA0104 finalize() only calls super.finalize()
JAVA0105 0.00JAVA0105 Duplicate import declaration
JAVA0106 0.00JAVA0106 Unnecessary import from current package
JAVA0108 4.00JAVA0108 Incorrect javadoc: no @param tag for 'parameter'
JAVA0109 7.00JAVA0109 Incorrect javadoc: no parameter 'parameter'
JAVA0110 0.00JAVA0110 Incorrect javadoc: no @return tag
JAVA0111 0.00JAVA0111 Incorrect javadoc: @return tag for void method
JAVA0112 0.00JAVA0112 Incorrect javadoc: no exception 'exception' in throws
JAVA0113 1.00JAVA0113 Incorrect javadoc: no @author tag
JAVA0114 0.00JAVA0114 Incorrect javadoc: no @version tag
JAVA0115 0.00JAVA0115 Incorrect javadoc: no @throws or @exception tag for 'exception'
JAVA0116 0.00JAVA0116 Missing javadoc: field 'field'
JAVA0117 6.00JAVA0117 Missing javadoc: method 'method'
JAVA0118 0.00JAVA0118 Missing javadoc: type 'type'
JAVA0119 0.00JAVA0119 Control variable changed within body of for loop
JAVA0123 0.00JAVA0123 Use all three components of for loop
JAVA0125 0.00JAVA0125 Continue statement with label
JAVA0126 0.00JAVA0126 Method declares unchecked exception in throws
JAVA0128 0.00JAVA0128 Public constructor in non-public class
JAVA0130 6.00JAVA0130 Non-static method does not use instance fields
JAVA0131 0.00JAVA0131 Compatible method does not override base
JAVA0132 0.00JAVA0132 Method overload with compatible signature
JAVA0133 0.00JAVA0133 Non-synchronized method overrides synchronized method
JAVA0135 0.00JAVA0135 Only one of Object.equals and Object.hashCode defined: missing 'method'
JAVA0136 1.00JAVA0136 N methods defined in class (maximum: M)
JAVA0137 0.00JAVA0137 Non-abstract class missing constructor
JAVA0138 0.00JAVA0138 N parameters defined for method (maximum: M)
JAVA0139 0.00JAVA0139 Definition of main other than public static void main(java.lang.String[])
JAVA0141 0.00JAVA0141 Unnecessary modifier for method in interface
JAVA0143 0.00JAVA0143 Synchronized method
JAVA0144 6.00JAVA0144 Line exceeds maximum M characters
JAVA01451934.00JAVA0145 Tab character used in source file
JAVA0150 0.00JAVA0150 java.lang.Error (or subclass) thrown
JAVA0153 0.00JAVA0153 Inefficient conversion of integer to string
JAVA0159 0.00JAVA0159 Inefficient conversion of string to integer
JAVA0160 0.00JAVA0160 Method does not throw specified exception
JAVA0161 0.00JAVA0161 Conditional wait() not in loop
JAVA0163 0.00JAVA0163 Empty statement
JAVA0165 0.00JAVA0165 Conflicting return statement in finally block
JAVA016613.00JAVA0166 Generic exception caught
JAVA0167 0.00JAVA0167 ThreadDeath not rethrown
JAVA0169 0.00JAVA0169 Unnecessary catch block: exception 'exception'
JAVA0170 0.00JAVA0170 Caught exception not derived from java.lang.Exception
JAVA0171 2.00JAVA0171 Unused local variable
JAVA0173 1.00JAVA0173 Unused method parameter
JAVA0174 0.00JAVA0174 Assigned local variable never used
JAVA0175 0.00JAVA0175 Successive assignment to variable
JAVA0176 0.00JAVA0176 Local variable name does not have required form
JAVA0177 4.00JAVA0177 Variable declaration missing initializer
JAVA0179 0.00JAVA0179 Local variable hides visible field
JAVA0233 0.00JAVA0233 Definition of serialVersionUID other than 'private static final long serialVersionUID'
JAVA0234 0.00JAVA0234 Class is Serializable but does not define serialVersionUID
JAVA0235 0.00JAVA0235 Class defines serialVersionUID but does not implement Serializable
JAVA0236 0.00JAVA0236 Attempt to clone an object which does not implement Cloneable
JAVA0237 0.00JAVA0237 Class implements Cloneable but does not have public clone method
JAVA0238 0.00JAVA0238 Clone method does not call super.clone()
JAVA0239 0.00JAVA0239 Class declares 'readObject' or 'writeObject' but does not implement Serializable
JAVA0240 0.00JAVA0240 Serializable class which declares readObject or writeObject but not both
JAVA0241 0.00JAVA0241 'readObject' or 'writeObject' should be declared private in Serializable class
JAVA0242 0.00JAVA0242 Transient field in non-Serializable class
JAVA0243 0.00JAVA0243 'readResolve' or 'writeReplace' should be declared private or protected
JAVA0244 0.00JAVA0244 Field or method name in subclass differs only by case from inherited field or method
JAVA0245 0.00JAVA0245 JUnit TestCase with non-trivial constructor
JAVA0246 0.00JAVA0246 JUnit assertXXX statement missing message parameter
JAVA0247 0.00JAVA0247 JUnit 'setUp()' and 'tearDown()' should call super method
JAVA0248 0.00JAVA0248 JUnit method 'setUp' or 'tearDown' with incorrect signature
JAVA0249 0.00JAVA0249 JUnit TestCase 'suite()' should be declared static
JAVA0250 0.00JAVA0250 JUnit TestCase declares testXXX method with incorrect signature
JAVA0251 0.00JAVA0251 Use '%n' for line breaks in printf/format for platform independence
JAVA0252 0.00JAVA0252 'enum' is a Java 1.5 reserved word
JAVA0253 0.00JAVA0253 Not all enum constants consumed in switch statement
JAVA0254 0.00JAVA0254 Use enhanced for loop construct instead of Iterator
JAVA0255 0.00JAVA0255 Result of method invocation not used
JAVA0256 0.00JAVA0256 Assignment of external collection/array to field
JAVA0257 0.00JAVA0257 Use of 'Constant Interface' anti-pattern
JAVA0258 0.00JAVA0258 Implement Iterable for foreach compatibility
JAVA0259 0.00JAVA0259 Return of collection/array field
JAVA0260 0.00JAVA0260 Use 'enum' instead of Enumerated Type pattern
JAVA0261 0.00JAVA0261 Use specialized Enum collection types
JAVA0262 0.00JAVA0262 Use of char in integer context
JAVA0263 0.00JAVA0263 Long literal ends with 'l' instead of 'L'
JAVA0264 1.00JAVA0264 Integer math in long context - check for overflow
JAVA0265 4.00JAVA0265 Use of Throwable.printStackTrace()
JAVA0266 0.00JAVA0266 Use of System.out
JAVA0267 0.00JAVA0267 Use of System.err
JAVA0269 0.00JAVA0269 Contents of StringBuffer never used
JAVA0270 3.00JAVA0270 Use Java 5.0 enhanced for loop construct to iterate over all elements in an array
JAVA0271 0.00JAVA0271 Minimize use of on-demand (.*) static imports
JAVA0272 0.00JAVA0272 Thread.run() called
JAVA0273 1.00JAVA0273 Non-final derivative of Thread calls start() in constructor
JAVA0274 0.00JAVA0274 Serializable class has a synchronized readObject()
JAVA0275 0.00JAVA0275 Serializable class has a synchronized writeObject() and no other synchronized methods
JAVA0276 0.00JAVA0276 Unnecessary use of String constructor
JAVA0277 0.00JAVA0277 Iterator.next() implementation does not throw NoSuchElementException
JAVA0278 0.00JAVA0278 Unnecessary use of Boolean constructor
JAVA0279 0.00JAVA0279 Serialization method readObject or readObjectNoData calls an overridable method
JAVA0280 0.00JAVA0280 IllegalMonitorStateException caught
JAVA0281 0.00JAVA0281 Iterator.next() not called in loop
JAVA0282 0.00JAVA0282 Call to Iterator.next() in loop which does not test Iterator.hasNext()
JAVA0283 0.00JAVA0283 Control variable not updated in loop body
JAVA0284 0.00JAVA0284 Explicit garbage collection
JAVA0285 0.00JAVA0285 Dereference of potentially null variable
JAVA0286 0.00JAVA0286 Dereference of null variable
JAVA0287 0.00JAVA0287 Unnecessary null check
JAVA0288 0.00JAVA0288 Inconsistent null check
LINES863.00Number of lines in the source file
LINE_COMMENT14.00Number of line comments
LOC615.00Lines of code
LOGICAL_LINES392.00Number of statements
LOOPS11.00Number of loops
NEST_DEPTH 5.00Maximum nesting depth
OPERANDS1634.00Number of operands
OPERATORS2738.00Number of operators
PARAMS17.00Number of formal parameter declarations
PROGRAM_LENGTH4372.00Halstead program length
PROGRAM_VOCAB500.00Halstead program vocabulary
PROGRAM_VOLUME 0.00Halstead program volume
RETURNS53.00Number of return points from functions
SIZE23597.00Size of the file in bytes
UNIQUE_OPERANDS453.00Number of unique operands
UNIQUE_OPERATORS47.00Number of unique operators
WHITESPACE101.00Number of whitespace lines