rendered paste bodyIndex: C:/workspace/c4/java/net/sf/l2j/status/LoginStatusThread.java
===================================================================
--- C:/workspace/c4/java/net/sf/l2j/status/LoginStatusThread.java (revision 1605)
+++ C:/workspace/c4/java/net/sf/l2j/status/LoginStatusThread.java (working copy)
@@ -13,15 +13,12 @@
import java.net.Socket;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
import java.util.Properties;
import java.util.logging.Logger;
import net.sf.l2j.Base64;
import net.sf.l2j.Config;
-import net.sf.l2j.L2DatabaseFactory;
+import net.sf.l2j.sql.SQLHandler;
import net.sf.l2j.loginserver.GameServerTable;
import net.sf.l2j.loginserver.LoginController;
import net.sf.l2j.loginserver.LoginServer;
@@ -202,31 +199,8 @@
{
if(!LoginController.getInstance().isGM(login))
return false;
- java.sql.Connection con = null;
- try
- {
- con = L2DatabaseFactory.getInstance().getConnection();
- PreparedStatement statement = con.prepareStatement("SELECT password FROM accounts WHERE login=?");
- statement.setString(1, login);
- ResultSet rset = statement.executeQuery();
- if (rset.next())
- {
- _pass = rset.getString("password");
- statement.close();
- con.close();
- return true;
- }
- statement.close();
- }
- catch(SQLException sqle)
- {
- sqle.printStackTrace();
- }
- finally
- {
- try { con.close(); } catch (Exception e) {}
- }
- return false;
+ _pass=SQLHandler.getInstance().getStringValue("password","accounts","login",login);
+ return _pass=="" ? false : true;
}
public void run()
Index: C:/workspace/c4/java/net/sf/l2j/Config.java
===================================================================
--- C:/workspace/c4/java/net/sf/l2j/Config.java (revision 1605)
+++ C:/workspace/c4/java/net/sf/l2j/Config.java (working copy)
@@ -62,6 +62,7 @@
public static String DATABASE_LOGIN;
public static String DATABASE_PASSWORD;
public static int DATABASE_MAX_CONNECTIONS;
+ public static int SQL_LOG_EXEC_TIME_MAX;
public static int MAXIMUM_ONLINE_USERS;
@@ -652,6 +653,7 @@
DATABASE_LOGIN = serverSettings.getProperty("Login", "root");
DATABASE_PASSWORD = serverSettings.getProperty("Password", "");
DATABASE_MAX_CONNECTIONS = Integer.parseInt(serverSettings.getProperty("MaximumDbConnections", "10"));
+ SQL_LOG_EXEC_TIME_MAX = Integer.parseInt(serverSettings.getProperty("SqlLogExecTimeMax", "1000"));
COUNT_PACKETS = Boolean.valueOf(serverSettings.getProperty("CountPacket", "false"));
DUMP_PACKET_COUNTS = Boolean.valueOf(serverSettings.getProperty("DumpPacketCounts", "false"));
@@ -826,6 +828,7 @@
GM_NAME_COLOUR = Integer.decode("0x" + otherSettings.getProperty("GMNameColour", "00FF00"));
GM_STARTUP_INVISIBLE = Boolean.parseBoolean(otherSettings.getProperty("GMStartupInvisible", "True"));
GM_STARTUP_SILENCE = Boolean.parseBoolean(otherSettings.getProperty("GMStartupSilence", "True"));
+
}
catch (Exception e)
{
@@ -1048,6 +1051,7 @@
DATABASE_LOGIN = serverSettings.getProperty("Login", "root");
DATABASE_PASSWORD = serverSettings.getProperty("Password", "");
DATABASE_MAX_CONNECTIONS = Integer.parseInt(serverSettings.getProperty("MaximumDbConnections", "10"));
+ SQL_LOG_EXEC_TIME_MAX = Integer.parseInt(serverSettings.getProperty("SqlLogExecTimeMax","1000"));
SHOW_LICENCE = Boolean.parseBoolean(serverSettings.getProperty("ShowLicence", "true"));
}
Index: C:/workspace/c4/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- C:/workspace/c4/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 1605)
+++ C:/workspace/c4/java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (working copy)
@@ -42,6 +42,7 @@
import javolution.util.FastSet;
import net.sf.l2j.Config;
import net.sf.l2j.L2DatabaseFactory;
+import net.sf.l2j.sql.SQLHandler;
import net.sf.l2j.gameserver.CharTemplateTable;
import net.sf.l2j.gameserver.ClanTable;
import net.sf.l2j.gameserver.ClientScheduler;
@@ -3870,117 +3871,17 @@
*/
public void updateOnlineStatus()
{
- java.sql.Connection con = null;
-
- try {
- con = L2DatabaseFactory.getInstance().getConnection();
- PreparedStatement statement = con.prepareStatement("UPDATE characters SET online=?, lastAccess=? WHERE obj_id=?");
- statement.setInt(1, isOnline());
- statement.setLong(2, System.currentTimeMillis());
- statement.setInt(3, getObjectId());
- statement.execute();
- statement.close();
- }
- catch (Exception e)
- {
- _log.warning("could not set char online status:"+e);
- }
- finally
- {
- try { con.close(); } catch (Exception e) {}
- }
+ if (!SQLHandler.getInstance().UpdateOnlineStatus(this)) _log.warning("could not update character online status");
}
/**
* Create a new player in the characters table of the database.<BR><BR>
*/
- private boolean createDb()
- {
- java.sql.Connection con = null;
- try
- {
- con = L2DatabaseFactory.getInstance().getConnection();
- PreparedStatement statement;
- statement = con.prepareStatement(
- "INSERT INTO characters " +
- "(account_name,obj_Id,char_name,level,maxHp,curHp,maxCp,curCp,maxMp,curMp," +
- "acc,crit,evasion,mAtk,mDef,mSpd,pAtk,pDef,pSpd,runSpd,walkSpd," +
- "str,con,dex,_int,men,wit,face,hairStyle,hairColor,sex," +
- "movement_multiplier,attack_speed_multiplier,colRad,colHeight," +
- "exp,sp,karma,pvpkills,pkkills,clanid,maxload,race,classid,deletetime," +
- "cancraft,title,allyId,accesslevel,online,clan_privs,wantspeace,deleteclan," +
- "base_class) " +
- "values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
- statement.setString(1, _accountName);
- statement.setInt(2, getObjectId());
- statement.setString(3, getName());
- statement.setInt(4, getLevel());
- statement.setInt(5, getMaxHp());
- statement.setDouble(6, getCurrentHp());
- statement.setInt(7, getMaxCp());
- statement.setDouble(8, getCurrentCp());
- statement.setInt(9, getMaxMp());
- statement.setDouble(10, getCurrentMp());
- statement.setInt(11, getAccuracy());
- statement.setInt(12, getCriticalHit(null, null));
- statement.setInt(13, getEvasionRate(null));
- statement.setInt(14, getMAtk(null, null));
- statement.setInt(15, getMDef(null, null));
- statement.setInt(16, getMAtkSpd());
- statement.setInt(17, getPAtk(null));
- statement.setInt(18, getPDef(null));
- statement.setInt(19, getPAtkSpd());
- statement.setInt(20, getRunSpeed());
- statement.setInt(21, getWalkSpeed());
- statement.setInt(22, getSTR());
- statement.setInt(23, getCON());
- statement.setInt(24, getDEX());
- statement.setInt(25, getINT());
- statement.setInt(26, getMEN());
- statement.setInt(27, getWIT());
- statement.setInt(28, getFace());
- statement.setInt(29, getHairStyle());
- statement.setInt(30, getHairColor());
- statement.setInt(31, getSex());
- statement.setDouble(32, 1/*getMovementMultiplier()*/);
- statement.setDouble(33, 1/*getAttackSpeedMultiplier()*/);
- statement.setDouble(34, getTemplate().collisionRadius/*getCollisionRadius()*/);
- statement.setDouble(35, getTemplate().collisionHeight/*getCollisionHeight()*/);
- statement.setInt(36, getExp());
- statement.setInt(37, getSp());
- statement.setInt(38, getKarma());
- statement.setInt(39, getPvpKills());
- statement.setInt(40, getPkKills());
- statement.setInt(41, getClanId());
- statement.setInt(42, getMaxLoad());
- statement.setInt(43, getRace().ordinal());
- statement.setInt(44, getClassId().getId());
- statement.setInt(45, getDeleteTimer());
- statement.setInt(46, hasDwarvenCraft() ? 1 : 0);
- statement.setString(47, getTitle());
- statement.setInt(48, getAllyId());
- statement.setInt(49, getAccessLevel());
- statement.setInt(50, isOnline());
- statement.setInt(51, getClanPrivileges());
- statement.setInt(52, getWantsPeace());
- statement.setLong(53, getDeleteClanTime());
- statement.setInt(54, getBaseClass());
- statement.executeUpdate();
- statement.close();
- }
- catch (Exception e)
- {
- _log.warning("Could not insert char data: " + e);
- return false;
- }
- finally
- {
- try { con.close(); } catch (Exception e) {}
- }
- return true;
- }
+ private boolean createDb()
+ {
+ return SQLHandler.getInstance().createDb(this);
+ }
-
/**
* Retrieve a L2PcInstance from the characters table of the database and add it in _allObjects of the L2world.<BR><BR>
*
@@ -5200,11 +5101,10 @@
}
// Check if the caster isn't sitting
- if (isSitting() && !skill.isPotion())
+ if (isSitting() && !skill.isPotion() && !skill.isCraftingSkillType())
{
// Send a System Message to the caster
sendPacket(new SystemMessage(SystemMessage.CANT_MOVE_SITTING));
-
// Send a Server->Client packet ActionFailed to the L2PcInstance
sendPacket(new ActionFailed());
return;
Index: C:/workspace/c4/java/net/sf/l2j/gameserver/model/L2Skill.java
===================================================================
--- C:/workspace/c4/java/net/sf/l2j/gameserver/model/L2Skill.java (revision 1605)
+++ C:/workspace/c4/java/net/sf/l2j/gameserver/model/L2Skill.java (working copy)
@@ -461,6 +460,12 @@
return _ispotion;
}
+ public final boolean isCraftingSkillType()
+ {
+ if (getSkillType() == SkillType.DWARVEN_CRAFT || getSkillType() == SkillType.COMMON_CRAFT) return true;
+ return false;
+ }
+
public final int getArmorsAllowed()
{
return _armorsAllowed;
Index: C:/workspace/c4/java/net/sf/l2j/gameserver/cache/CrestCache.java
===================================================================
--- C:/workspace/c4/java/net/sf/l2j/gameserver/cache/CrestCache.java (revision 1605)
+++ C:/workspace/c4/java/net/sf/l2j/gameserver/cache/CrestCache.java (working copy)
@@ -16,7 +16,8 @@
import javolution.util.FastMap;
import net.sf.l2j.Config;
-import net.sf.l2j.L2DatabaseFactory;
+import net.sf.l2j.sql.SQLHandler;
import net.sf.l2j.gameserver.ClanTable;
import net.sf.l2j.gameserver.idfactory.BitSetIDFactory;
import net.sf.l2j.gameserver.model.L2Clan;
@@ -135,26 +136,7 @@
file.renameTo(new File(Config.DATAPACK_ROOT, "data/crests/Crest_"+newId+".bmp"));
_log.info("Renamed Clan crest to new format: Crest_"+newId+".bmp");
- java.sql.Connection con = null;
-
- try
- {
- con = L2DatabaseFactory.getInstance().getConnection();
- PreparedStatement statement = con.prepareStatement("UPDATE clan_data SET crest_id = ? WHERE clan_id = ?");
- statement.setInt(1, newId);
- statement.setInt(2, clan.getClanId());
- statement.executeUpdate();
- statement.close();
- }
- catch (SQLException e)
- {
- _log.warning("could not update the crest id:"+e.getMessage());
- }
- finally
- {
- try { con.close(); } catch (Exception e) {}
- }
-
+ SQLHandler.getInstance().setIntValue("clan_data","crest_id",newId,"clan_id",clan.getClanId());
clan.setCrestId(newId);
clan.setHasCrest(true);
}