Index: java/com/l2jserver/extensions/VisualArmorModel.java
===================================================================
--- java/com/l2jserver/extensions/VisualArmorModel.java (revision 0)
java/com/l2jserver/extensions/VisualArmorModel.java (revision 0)
@@ -0,0 1,171 @@
/*
* 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 3 of the License, 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, see .
*/
package com.l2jserver.extensions;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
/**
* @author Issle
*
*/
public class VisualArmorModel
{
private static final String RESTORE_VISUAL_ARMOR = "SELECT
GlovesId,ChestId,BootsId,PantsId,LeftHandId,RightHandId,DoubleHandId
FROM visual_armor WHERE CharId=?";
private static final String UPDATE_VISUAL_ARMOR = "UPDATE
visual_armor SET
GlovesId=?,ChestId=?,BootsId=?,PantsId=?,LeftHandId=?,RightHandId=?,DoubleHandId=?
WHERE CharId=?";
private static final String CREATE_VISUAL_ARMOR = "INSERT INTO
visual_armor
(CharId,GlovesId,ChestId,BootsId,PantsId,LeftHandId,RightHandId,DoubleHandId)
values (?,?,?,?,?,?,?,?)";
public static final String CREATE =
"CREATE TABLE IF NOT EXISTS `visual_armor` ("
"`CharId` int(11) NOT NULL,"
"`GlovesId` int(11) NOT NULL DEFAULT '0',"
"`BootsId` int(11) NOT NULL DEFAULT '0',"
"`ChestId` int(11) NOT NULL DEFAULT '0',"
"`PantsId` int(11) NOT NULL DEFAULT '0',"
"`LeftHandId` int(11) NOT NULL DEFAULT '0',"
"`RightHandId` int(11) NOT NULL DEFAULT '0',"
"`DoubleHandId` int(11) NOT NULL DEFAULT '0',PRIMARY KEY (`CharId`))";
public static final String DROP =
"DROP TABLE 'visual_armor'";
public int glovesTextureId=0;
public int armorTextureId=0;
public int pantsTextureId=0;
public int bootsTextureId=0;
public int weaponLHANDId=0;
public int weaponRHANDId=0;
public int weaponLRHANDId=0;
public int ownerId;
public void updateVisualArmor()
{
Connection con = null;
try
{
con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(UPDATE_VISUAL_ARMOR);
statement.setInt(1, glovesTextureId);
statement.setInt(2, armorTextureId);
statement.setInt(3, bootsTextureId);
statement.setInt(4, pantsTextureId);
statement.setInt(5, weaponLHANDId);
statement.setInt(6, weaponRHANDId);
statement.setInt(7, weaponLRHANDId);
statement.setInt(8, ownerId);
statement.execute();
statement.close();
}
catch (SQLException e)
{
e.printStackTrace();
}
finally
{
try { con.close(); } catch (Exception e) {}
}
}
public VisualArmorModel(L2PcInstance activeChar)
{
ownerId = activeChar.getObjectId();
Connection con = null;
try
{
con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(RESTORE_VISUAL_ARMOR);
statement.setInt(1, ownerId);
ResultSet rset = statement.executeQuery();
boolean got = false;
while(rset.next())
{
glovesTextureId = rset.getInt("GlovesId");
armorTextureId = rset.getInt("ChestId");
pantsTextureId = rset.getInt("PantsId");
bootsTextureId = rset.getInt("BootsId");
weaponLHANDId = rset.getInt("LeftHandId");
weaponRHANDId = rset.getInt("RightHandId");
weaponLRHANDId = rset.getInt("DoubleHandId");
got = true;
}
rset.close();
statement.close();
if(got == false)
{
createVisualArmor();
}
InventoryUpdate iu = new InventoryUpdate();
activeChar.sendPacket(iu);
activeChar.broadcastUserInfo();
InventoryUpdate iu2 = new InventoryUpdate();
activeChar.sendPacket(iu2);
activeChar.broadcastUserInfo();
activeChar.sendMessage("You changed clothes.");
}
catch (SQLException e)
{
e.printStackTrace();
}
finally
{
try { con.close(); } catch (Exception e) {}
}
}
public void createVisualArmor() throws SQLException
{
Connection con = null;
try
{
con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(CREATE_VISUAL_ARMOR);
statement.setInt(1, ownerId);
statement.setInt(2, 0);
statement.setInt(3, 0);
statement.setInt(4, 0);
statement.setInt(5, 0);
statement.setInt(6, 0);
statement.setInt(7, 0);
statement.setInt(8, 0);
statement.executeUpdate();
statement.close();
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
try { con.close(); } catch (Exception e) {}
}
}
}
Index: java/com/l2jserver/gameserver/GameServer.java
===================================================================
--- java/com/l2jserver/gameserver/GameServer.java (revision 4469)
java/com/l2jserver/gameserver/GameServer.java (working copy)
@@ -32,6 32,7 @@
import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.Server;
import com.l2jserver.extensions.VisualArmorController;
import com.l2jserver.gameserver.cache.CrestCache;
import com.l2jserver.gameserver.cache.HtmCache;
import com.l2jserver.gameserver.datatables.AccessLevels;
@@ -315,6 316,7 @@
BoatManager.getInstance();
AirShipManager.getInstance();
GraciaSeedsManager.getInstance();
VisualArmorController.load();
try
{
Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (revision 4469)
java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java (working copy)
@@ -38,6 38,7 @@
import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.extensions.VisualArmorModel;
import com.l2jserver.gameserver.Announcements;
import com.l2jserver.gameserver.GameTimeController;
import com.l2jserver.gameserver.GeoData;
@@ -274,6 275,7 @@
*/
public final class L2PcInstance extends L2Playable
{
public VisualArmorModel visualArmor;
// Character Skill SQL String Definitions:
private static final String RESTORE_SKILLS_FOR_CHAR = "SELECT
skill_id,skill_level FROM character_skills WHERE charId=? AND
class_index=?";
private static final String ADD_NEW_SKILL = "INSERT INTO
character_skills (charId,skill_id,skill_level,class_index) VALUES
(?,?,?,?)";
@@ -324,6 326,8 @@
public static final int STORE_PRIVATE_MANUFACTURE = 5;
public static final int STORE_PRIVATE_PACKAGE_SELL = 8;
/** The table containing all minimum level needed for each Expertise (None, D, C, B, A, S, S80, S84)*/
private static final int[] EXPERTISE_LEVELS =
{
@@ -1254,6 1258,7 @@
if (!Config.WAREHOUSE_CACHE)
getWarehouse();
startVitalityTask();
visualArmor = new VisualArmorModel(this);
}
private L2PcInstance(int objectId)
Index: java/com/l2jserver/gameserver/network/serverpackets/CharInfo.java
===================================================================
--- java/com/l2jserver/gameserver/network/serverpackets/CharInfo.java (revision 4469)
java/com/l2jserver/gameserver/network/serverpackets/CharInfo.java (working copy)
@@ -17,6 17,7 @@
import java.util.logging.Logger;
import com.l2jserver.Config;
import com.l2jserver.extensions.VisualArmorController;
import com.l2jserver.gameserver.datatables.NpcTable;
import com.l2jserver.gameserver.instancemanager.CursedWeaponsManager;
import com.l2jserver.gameserver.model.actor.L2Decoy;
@@ -249,20 250,20 @@
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_HEAD));
if (_airShipHelm == 0)
{
- writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_RHAND));
- writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_LHAND));
writeD(VisualArmorController.getRHAND(_activeChar));
writeD(VisualArmorController.getLHAND(_activeChar));
}
else
{
writeD(_airShipHelm);
writeD(0);
}
- writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_GLOVES));
- writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_CHEST));
- writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_LEGS));
- writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_FEET));
- writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_CLOAK));
- writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_RHAND));
writeD(VisualArmorController.getVirtualGloves(_activeChar));
writeD(VisualArmorController.getVirtualBody(_activeChar));
writeD(VisualArmorController.getVirtualPants(_activeChar));
writeD(VisualArmorController.getVirtualBoots(_activeChar));
writeD(VisualArmorController.getCloak(_activeChar));
writeD(VisualArmorController.getRHAND(_activeChar));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_HAIR));
writeD(_inv.getPaperdollItemId(Inventory.PAPERDOLL_HAIR2));
// T1 new d's
Index: java/com/l2jserver/gameserver/network/serverpackets/UserInfo.java
===================================================================
--- java/com/l2jserver/gameserver/network/serverpackets/UserInfo.java (revision 4469)
java/com/l2jserver/gameserver/network/serverpackets/UserInfo.java (working copy)
@@ -15,6 15,7 @@
package com.l2jserver.gameserver.network.serverpackets;
import com.l2jserver.Config;
import com.l2jserver.extensions.VisualArmorController;
import com.l2jserver.gameserver.datatables.NpcTable;
import com.l2jserver.gameserver.instancemanager.CursedWeaponsManager;
import com.l2jserver.gameserver.instancemanager.TerritoryWarManager;
@@ -192,20 193,20 @@
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_HEAD));
if (_airShipHelm == 0)
{
- writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_RHAND));
- writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_LHAND));
writeD(VisualArmorController.getRHAND(_activeChar));
writeD(VisualArmorController.getLHAND(_activeChar));
}
else
{
writeD(_airShipHelm);
writeD(0);
}
- writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_GLOVES));
- writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_CHEST));
- writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_LEGS));
- writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_FEET));
- writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_CLOAK));
- writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_RHAND));
writeD(VisualArmorController.getVirtualGloves(_activeChar));
writeD(VisualArmorController.getVirtualBody(_activeChar));
writeD(VisualArmorController.getVirtualPants(_activeChar));
writeD(VisualArmorController.getVirtualBoots(_activeChar));
writeD(VisualArmorController.getCloak(_activeChar));
writeD(VisualArmorController.getRHAND(_activeChar));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_HAIR));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_HAIR2));
writeD(_activeChar.getInventory().getPaperdollItemId(Inventory.PAPERDOLL_RBRACELET));