Guest User

Untitled

a guest
Aug 29th, 2012
2,702
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ### Eclipse Workspace Patch 1.0
  2. #P L2J_Server
  3. Index: java/com/l2jserver/gameserver/network/clientpackets/RequestBypassToServer.java
  4. ===================================================================
  5. --- java/com/l2jserver/gameserver/network/clientpackets/RequestBypassToServer.java  (revision 5563)
  6. +++ java/com/l2jserver/gameserver/network/clientpackets/RequestBypassToServer.java  (working copy)
  7. @@ -25,6 +25,8 @@
  8.  import com.l2jserver.gameserver.handler.BypassHandler;
  9.  import com.l2jserver.gameserver.handler.IAdminCommandHandler;
  10.  import com.l2jserver.gameserver.handler.IBypassHandler;
  11. +import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
  12. +import com.l2jserver.gameserver.handler.VoicedCommandHandler;
  13.  import com.l2jserver.gameserver.model.L2CharPosition;
  14.  import com.l2jserver.gameserver.model.L2Object;
  15.  import com.l2jserver.gameserver.model.L2World;
  16. @@ -117,6 +119,17 @@
  17.                     ach.useAdminCommand(_command, activeChar);
  18.                 }
  19.             }
  20. +           else if (_command.startsWith(".")) {
  21. +               String command = _command.substring(1).split(" ")[0];
  22. +               String params = _command.substring(1).split(" ").length > 1 ? _command.substring(1).split(" ")[1] : "";
  23. +               IVoicedCommandHandler vch = VoicedCommandHandler.getInstance().getHandler(command);
  24. +               if (vch == null)
  25. +               {
  26. +                   _log.warning(activeChar + " requested not registered admin command '" + command + "'");
  27. +                   return;
  28. +               }
  29. +               vch.useVoicedCommand(command, activeChar, params);
  30. +           }
  31.             else if (_command.equals("come_here") && activeChar.isGM())
  32.             {
  33.                 comeHere(activeChar);
  34. Index: java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
  35. ===================================================================
  36. --- java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java    (revision 5563)
  37. +++ java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java    (working copy)
  38. @@ -7466,6 +7466,7 @@
  39.                 player.restoreUISettings();
  40.            
  41.             player.restoreZoneRestartLimitTime();
  42. +           player.restoreVisualArmors();
  43.         }
  44.         catch (Exception e)
  45.         {
  46. @@ -7728,6 +7729,7 @@
  47.         storeCharSub();
  48.         storeEffect(storeActiveEffects);
  49.         storeItemReuseDelay();
  50. +       storeVisualArmors();
  51.         transformInsertInfo();
  52.         if(Config.STORE_RECIPE_SHOPLIST)
  53.             storeRecipeShopList();
  54. @@ -15471,4 +15473,300 @@
  55.     {
  56.         globalProfessionChangeListeners.remove(listener);
  57.     }
  58. +
  59. +   private void restoreVisualArmors()
  60. +   {
  61. +       try
  62. +       {
  63. +           Connection con = L2DatabaseFactory.getInstance().getConnection();
  64. +           PreparedStatement statement = con.prepareStatement("SELECT * FROM character_visual_armors WHERE charId=?");
  65. +           statement.setInt(1, getObjectId());
  66. +           ResultSet rset = statement.executeQuery();
  67. +           if (rset.next())
  68. +           {
  69. +               isUsingVisualArmors(rset.getBoolean("isUsingVisual"));
  70. +               setVisualArmor(VisualArmors.Armor, rset.getInt("armor"));
  71. +               setVisualArmor(VisualArmors.Legs, rset.getInt("leggings"));
  72. +               setVisualArmor(VisualArmors.Feet, rset.getInt("feet"));
  73. +               setVisualArmor(VisualArmors.Gloves, rset.getInt("gloves"));
  74. +               setVisualArmor(VisualArmors.LHand, rset.getInt("lHand"));
  75. +               setVisualArmor(VisualArmors.Sword, rset.getInt("sword"));
  76. +               setVisualArmor(VisualArmors.Bow, rset.getInt("bow"));
  77. +               setVisualArmor(VisualArmors.Pole, rset.getInt("pole"));
  78. +               setVisualArmor(VisualArmors.Dual, rset.getInt("dualWeapons"));
  79. +               setVisualArmor(VisualArmors.BigSword, rset.getInt("bigSword"));
  80. +           }
  81. +       }
  82. +       catch (Exception e)
  83. +       {
  84. +           _log.log(Level.WARNING, "Could not restore " + getObjectId() + " visual armors data " + e.getMessage(), e);
  85. +       }
  86. +   }
  87. +  
  88. +   private boolean checkIfExist()
  89. +   {
  90. +       try
  91. +       {
  92. +           Connection con = L2DatabaseFactory.getInstance().getConnection();
  93. +           PreparedStatement statement = con.prepareStatement("SELECT charId FROM character_visual_armors WHERE charId=?");
  94. +           statement.setInt(1, getObjectId());
  95. +           try (ResultSet rset = statement.executeQuery()) {
  96. +               if (rset.next())
  97. +                   return true;
  98. +           }
  99. +       }
  100. +       catch (Exception e)
  101. +       {
  102. +           _log.log(Level.WARNING, "Could not restore " + getObjectId() + " visual armors data " + e.getMessage(), e);
  103. +       }
  104. +       return false;
  105. +   }
  106. +  
  107. +   private void storeVisualArmors()
  108. +   {
  109. +       if (!checkIfExist())
  110. +           insertVisualArmors();
  111. +       //UPDATE characters SET vitality_points=?,language=? WHERE charId=?";
  112. +       try
  113. +       {
  114. +           Connection con = L2DatabaseFactory.getInstance().getConnection();
  115. +           PreparedStatement statement = con.prepareStatement("UPDATE character_visual_armors SET isUsingVisual=?,armor=?,leggings=?,feet=?,gloves=?,sword=?,bow=?,pole=?,dualWeapons=?,bigSword=?,lHand=? WHERE charId=?");
  116. +           statement.setInt(1, isUsingVisualArmors() ? 1 : 0);
  117. +           statement.setInt(2, getVisualArmor(VisualArmors.Armor, true) == null ? 0 : getVisualArmor(VisualArmors.Armor, true).getItemId());
  118. +           statement.setInt(3, getVisualArmor(VisualArmors.Legs, true) == null ? 0 : getVisualArmor(VisualArmors.Legs, true).getItemId());
  119. +           statement.setInt(4, getVisualArmor(VisualArmors.Feet, true) == null ? 0 : getVisualArmor(VisualArmors.Feet, true).getItemId());
  120. +           statement.setInt(5, getVisualArmor(VisualArmors.Gloves, true) == null ? 0 : getVisualArmor(VisualArmors.Gloves, true).getItemId());
  121. +           statement.setInt(6, getVisualArmor(VisualArmors.Sword, true) == null ? 0 : getVisualArmor(VisualArmors.Sword, true).getItemId());
  122. +           statement.setInt(7, getVisualArmor(VisualArmors.Bow, true) == null ? 0 : getVisualArmor(VisualArmors.Bow, true).getItemId());
  123. +           statement.setInt(8, getVisualArmor(VisualArmors.Pole, true) == null ? 0 : getVisualArmor(VisualArmors.Pole, true).getItemId());
  124. +           statement.setInt(9, getVisualArmor(VisualArmors.Dual, true) == null ? 0 : getVisualArmor(VisualArmors.Dual, true).getItemId());
  125. +           statement.setInt(10, getVisualArmor(VisualArmors.BigSword, true) == null ? 0 : getVisualArmor(VisualArmors.BigSword, true).getItemId());
  126. +           statement.setInt(11, getVisualArmor(VisualArmors.LHand, true) == null ? 0 : getVisualArmor(VisualArmors.LHand, true).getItemId());
  127. +           statement.setInt(12, getObjectId());
  128. +           statement.execute();
  129. +       }
  130. +       catch (Exception e)
  131. +       {
  132. +           _log.log(Level.WARNING, "Could not store character " + getObjectId() + " visual armors data: ", e);
  133. +       }
  134. +   }
  135. +
  136. +   private boolean insertVisualArmors()
  137. +   {
  138. +       try
  139. +       {
  140. +           Connection con = L2DatabaseFactory.getInstance().getConnection();
  141. +           PreparedStatement statement = con.prepareStatement("INSERT INTO character_visual_armors (charId) values (?)");
  142. +           statement.setInt(1, getObjectId());
  143. +           statement.executeUpdate();
  144. +       }
  145. +       catch (Exception e)
  146. +       {
  147. +           _log.log(Level.SEVERE, "Could not insert character " + getObjectId() + " visual armors data: " + e.getMessage(), e);
  148. +           return false;
  149. +       }
  150. +       return true;
  151. +   }
  152. +  
  153. +   boolean isUsingVisualArmors = false;
  154. +
  155. +   public boolean isUsingVisualArmors() {
  156. +       return isUsingVisualArmors;
  157. +   }
  158. +
  159. +   public void isUsingVisualArmors(boolean _isUsingVisualArmors) {
  160. +       isUsingVisualArmors = _isUsingVisualArmors;
  161. +   }
  162. +
  163. +   public enum VisualArmors {
  164. +       Sword,
  165. +       Bow,
  166. +       Pole,
  167. +       Dual,
  168. +       BigSword,
  169. +       RHand,
  170. +       LHand,
  171. +       Armor,
  172. +       Legs,
  173. +       Feet,
  174. +       Gloves,
  175. +       Cloak
  176. +   }
  177. +
  178. +   int visualArmors[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  179. +
  180. +   public void setVisualArmor(VisualArmors position, int itemId) {
  181. +       visualArmors[position.ordinal()] = itemId;
  182. +   }
  183. +
  184. +   public L2Item getVisualArmor(VisualArmors position, boolean forceShow) {
  185. +       switch (position) {
  186. +           case Sword:
  187. +               if (visualArmors[VisualArmors.Sword.ordinal()] > 0)
  188. +                   return ItemTable.getInstance().getTemplate(visualArmors[VisualArmors.Sword.ordinal()]);
  189. +               if (getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND) != null)
  190. +                   switch (getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND).getWeaponItem().getItemType()) {
  191. +                       case SWORD:
  192. +                       case BLUNT:
  193. +                       case DAGGER:
  194. +                       case ETC:
  195. +                       case FIST:
  196. +                       case RAPIER:
  197. +                           return getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND).getItem();
  198. +                   }
  199. +               return null;
  200. +           case Bow:
  201. +               if (visualArmors[VisualArmors.Bow.ordinal()] > 0)
  202. +                   return ItemTable.getInstance().getTemplate(visualArmors[VisualArmors.Bow.ordinal()]);
  203. +               if (getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND) != null)
  204. +                   switch (getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND).getWeaponItem().getItemType()) {
  205. +                       case BOW:
  206. +                       case CROSSBOW:
  207. +                           return getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND).getItem();
  208. +                   }
  209. +               return null;
  210. +           case Pole:
  211. +               if (visualArmors[VisualArmors.Pole.ordinal()] > 0)
  212. +                   return ItemTable.getInstance().getTemplate(visualArmors[VisualArmors.Pole.ordinal()]);
  213. +               if (getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND) != null)
  214. +                   switch (getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND).getWeaponItem().getItemType()) {
  215. +                       case POLE:
  216. +                           return getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND).getItem();
  217. +                   }
  218. +               return null;
  219. +           case BigSword:
  220. +               if (visualArmors[VisualArmors.BigSword.ordinal()] > 0)
  221. +                   return ItemTable.getInstance().getTemplate(visualArmors[VisualArmors.BigSword.ordinal()]);
  222. +               if (getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND) != null)
  223. +                   switch (getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND).getWeaponItem().getItemType()) {
  224. +                       case ANCIENTSWORD:
  225. +                       case BIGBLUNT:
  226. +                       case BIGSWORD:
  227. +                           return getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND).getItem();
  228. +                   }
  229. +               return null;
  230. +           case Dual:
  231. +               if (visualArmors[VisualArmors.Dual.ordinal()] > 0)
  232. +                   return ItemTable.getInstance().getTemplate(visualArmors[VisualArmors.Dual.ordinal()]);
  233. +               if (getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND) != null)
  234. +                   switch (getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND).getWeaponItem().getItemType()) {
  235. +                       case DUAL:
  236. +                       case DUALFIST:
  237. +                       case DUALDAGGER:
  238. +                           return getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND).getItem();
  239. +                   }
  240. +               return null;
  241. +           case RHand:
  242. +               if (getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND) == null && !forceShow)
  243. +                   return null;
  244. +               else if (isUsingVisualArmors() || forceShow) {
  245. +                   switch (getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND).getWeaponItem().getItemType()) {
  246. +                       case SWORD:
  247. +                       case BLUNT:
  248. +                       case DAGGER:
  249. +                       case ETC:
  250. +                       case FIST:
  251. +                       case RAPIER:
  252. +                           if (visualArmors[VisualArmors.Sword.ordinal()] > 0)
  253. +                               return ItemTable.getInstance().getTemplate(visualArmors[VisualArmors.Sword.ordinal()]);
  254. +                           break;
  255. +                       case BOW:
  256. +                       case CROSSBOW:
  257. +                           if (visualArmors[VisualArmors.Bow.ordinal()] > 0)
  258. +                               return ItemTable.getInstance().getTemplate(visualArmors[VisualArmors.Bow.ordinal()]);
  259. +                           break;
  260. +                       case POLE:
  261. +                           if (visualArmors[VisualArmors.Pole.ordinal()] > 0)
  262. +                               return ItemTable.getInstance().getTemplate(visualArmors[VisualArmors.Pole.ordinal()]);
  263. +                           break;
  264. +                       case DUAL:
  265. +                       case DUALFIST:
  266. +                       case DUALDAGGER:
  267. +                           if (visualArmors[VisualArmors.Dual.ordinal()] > 0)
  268. +                               return ItemTable.getInstance().getTemplate(visualArmors[VisualArmors.Dual.ordinal()]);
  269. +                           break;
  270. +                       case ANCIENTSWORD:
  271. +                       case BIGBLUNT:
  272. +                       case BIGSWORD:
  273. +                           if (visualArmors[VisualArmors.BigSword.ordinal()] > 0)
  274. +                               return ItemTable.getInstance().getTemplate(visualArmors[VisualArmors.BigSword.ordinal()]);
  275. +                           break;
  276. +                       default:
  277. +                           return getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND).getItem();
  278. +                   }
  279. +               }
  280. +               return getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND).getItem();
  281. +           case LHand:
  282. +               if (getInventory().getPaperdollItem(Inventory.PAPERDOLL_LHAND) == null) {
  283. +                   if (visualArmors[position.ordinal()] > 0 && forceShow)
  284. +                       return ItemTable.getInstance().getTemplate(visualArmors[position.ordinal()]);
  285. +                   return null;
  286. +               }
  287. +               else if ((isUsingVisualArmors() || forceShow) && visualArmors[position.ordinal()] > 0) {
  288. +                   L2Item item = ItemTable.getInstance().getTemplate(visualArmors[position.ordinal()]);
  289. +                   if (getInventory().getPaperdollItem(Inventory.PAPERDOLL_LHAND).isArmor() && item instanceof L2Armor)
  290. +                       return item;
  291. +                   return null;
  292. +               }
  293. +               else
  294. +                   return getInventory().getPaperdollItem(Inventory.PAPERDOLL_LHAND).getItem();
  295. +           case Armor:
  296. +               if (getInventory().getPaperdollItem(Inventory.PAPERDOLL_CHEST) == null) {
  297. +                   if (visualArmors[position.ordinal()] > 0 && forceShow)
  298. +                       return ItemTable.getInstance().getTemplate(visualArmors[position.ordinal()]);
  299. +                   return null;
  300. +               }
  301. +               else if ((isUsingVisualArmors() || forceShow) && visualArmors[position.ordinal()] > 0)
  302. +                   return ItemTable.getInstance().getTemplate(visualArmors[position.ordinal()]);
  303. +               else
  304. +                   return getInventory().getPaperdollItem(Inventory.PAPERDOLL_CHEST).getItem();
  305. +           case Legs:
  306. +               if (getInventory().getPaperdollItem(Inventory.PAPERDOLL_LEGS) == null) {
  307. +                   if (visualArmors[position.ordinal()] > 0 && forceShow)
  308. +                       return ItemTable.getInstance().getTemplate(visualArmors[position.ordinal()]);
  309. +                   return null;
  310. +               }
  311. +               else if (isUsingVisualArmors() || forceShow) {
  312. +                   L2Item armor = getVisualArmor(VisualArmors.Armor, true);
  313. +                   if (armor.getBodyPart() == L2Item.SLOT_FULL_ARMOR)
  314. +                       return null;
  315. +                   if (visualArmors[position.ordinal()] > 0)
  316. +                       return ItemTable.getInstance().getTemplate(visualArmors[position.ordinal()]);
  317. +                   return getInventory().getPaperdollItem(Inventory.PAPERDOLL_LEGS).getItem();
  318. +               }
  319. +               else
  320. +                   return getInventory().getPaperdollItem(Inventory.PAPERDOLL_LEGS).getItem();
  321. +           case Feet:
  322. +               if (getInventory().getPaperdollItem(Inventory.PAPERDOLL_FEET) == null) {
  323. +                   if (visualArmors[position.ordinal()] > 0 && forceShow)
  324. +                       return ItemTable.getInstance().getTemplate(visualArmors[position.ordinal()]);
  325. +                   return null;
  326. +               }
  327. +               else if ((isUsingVisualArmors() || forceShow) && visualArmors[position.ordinal()] > 0)
  328. +                   return ItemTable.getInstance().getTemplate(visualArmors[position.ordinal()]);
  329. +               else
  330. +                   return getInventory().getPaperdollItem(Inventory.PAPERDOLL_FEET).getItem();
  331. +           case Gloves:
  332. +               if (getInventory().getPaperdollItem(Inventory.PAPERDOLL_GLOVES) == null) {
  333. +                   if (visualArmors[position.ordinal()] > 0 && forceShow)
  334. +                       return ItemTable.getInstance().getTemplate(visualArmors[position.ordinal()]);
  335. +                   return null;
  336. +               }
  337. +               else if ((isUsingVisualArmors() || forceShow) && visualArmors[position.ordinal()] > 0)
  338. +                   return ItemTable.getInstance().getTemplate(visualArmors[position.ordinal()]);
  339. +               else
  340. +                   return getInventory().getPaperdollItem(Inventory.PAPERDOLL_GLOVES).getItem();
  341. +           case Cloak:
  342. +               if (getInventory().getPaperdollItem(Inventory.PAPERDOLL_CLOAK) == null) {
  343. +                   if (visualArmors[position.ordinal()] > 0 && forceShow)
  344. +                       return ItemTable.getInstance().getTemplate(visualArmors[position.ordinal()]);
  345. +                   return null;
  346. +               }
  347. +               else if ((isUsingVisualArmors() || forceShow) && visualArmors[position.ordinal()] > 0)
  348. +                   return ItemTable.getInstance().getTemplate(visualArmors[position.ordinal()]);
  349. +               else
  350. +                   return getInventory().getPaperdollItem(Inventory.PAPERDOLL_CLOAK).getItem();
  351. +       }
  352. +       return null;
  353. +   }
  354.  }
  355. \ No newline at end of file
  356. Index: java/com/l2jserver/gameserver/network/serverpackets/CharInfo.java
  357. ===================================================================
  358. --- java/com/l2jserver/gameserver/network/serverpackets/CharInfo.java   (revision 5563)
  359. +++ java/com/l2jserver/gameserver/network/serverpackets/CharInfo.java   (working copy)
  360. @@ -19,6 +19,7 @@
  361.  import com.l2jserver.gameserver.instancemanager.CursedWeaponsManager;
  362.  import com.l2jserver.gameserver.model.actor.L2Decoy;
  363.  import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  364. +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance.VisualArmors;
  365.  import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
  366.  import com.l2jserver.gameserver.model.effects.AbnormalEffect;
  367.  import com.l2jserver.gameserver.model.itemcontainer.Inventory;
  368. @@ -196,15 +197,15 @@
  369.            
  370.             writeD(_inv.getPaperdollItemDisplayId(Inventory.PAPERDOLL_UNDER));
  371.             writeD(_inv.getPaperdollItemDisplayId(Inventory.PAPERDOLL_HEAD));
  372. +
  373. +           writeD(_activeChar.getVisualArmor(VisualArmors.RHand, false) != null ? _activeChar.getVisualArmor(VisualArmors.RHand, false).getItemId() : 0x00);
  374. +           writeD(_activeChar.getVisualArmor(VisualArmors.LHand, false) != null ? _activeChar.getVisualArmor(VisualArmors.LHand, false).getItemId() : 0x00);
  375.            
  376. -           writeD(_airShipHelm == 0 ? _inv.getPaperdollItemDisplayId(Inventory.PAPERDOLL_RHAND) : _airShipHelm);
  377. -           writeD(_airShipHelm == 0 ? _inv.getPaperdollItemDisplayId(Inventory.PAPERDOLL_LHAND) : 0);
  378. -          
  379. -           writeD(_inv.getPaperdollItemDisplayId(Inventory.PAPERDOLL_GLOVES));
  380. -           writeD(_inv.getPaperdollItemDisplayId(Inventory.PAPERDOLL_CHEST));
  381. -           writeD(_inv.getPaperdollItemDisplayId(Inventory.PAPERDOLL_LEGS));
  382. -           writeD(_inv.getPaperdollItemDisplayId(Inventory.PAPERDOLL_FEET));
  383. -           writeD(_inv.getPaperdollItemDisplayId(Inventory.PAPERDOLL_CLOAK));
  384. +           writeD(_activeChar.getVisualArmor(VisualArmors.Gloves, false) != null ? _activeChar.getVisualArmor(VisualArmors.Gloves, false).getItemId() : 0x00);
  385. +           writeD(_activeChar.getVisualArmor(VisualArmors.Armor, false) != null ? _activeChar.getVisualArmor(VisualArmors.Armor, false).getItemId() : 0x00);
  386. +           writeD(_activeChar.getVisualArmor(VisualArmors.Legs, false) != null ? _activeChar.getVisualArmor(VisualArmors.Legs, false).getItemId() : 0x00);
  387. +           writeD(_activeChar.getVisualArmor(VisualArmors.Feet, false) != null ? _activeChar.getVisualArmor(VisualArmors.Feet, false).getItemId() : 0x00);
  388. +           writeD(_activeChar.getVisualArmor(VisualArmors.Cloak, false) != null ? _activeChar.getVisualArmor(VisualArmors.Cloak, false).getItemId() : 0x00);
  389.             writeD(_inv.getPaperdollItemDisplayId(Inventory.PAPERDOLL_RHAND));
  390.             writeD(_inv.getPaperdollItemDisplayId(Inventory.PAPERDOLL_HAIR));
  391.             writeD(_inv.getPaperdollItemDisplayId(Inventory.PAPERDOLL_HAIR2));
  392. Index: java/com/l2jserver/gameserver/network/serverpackets/UserInfo.java
  393. ===================================================================
  394. --- java/com/l2jserver/gameserver/network/serverpackets/UserInfo.java   (revision 5563)
  395. +++ java/com/l2jserver/gameserver/network/serverpackets/UserInfo.java   (working copy)
  396. @@ -21,6 +21,7 @@
  397.  import com.l2jserver.gameserver.instancemanager.TerritoryWarManager;
  398.  import com.l2jserver.gameserver.model.Elementals;
  399.  import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  400. +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance.VisualArmors;
  401.  import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
  402.  import com.l2jserver.gameserver.model.effects.AbnormalEffect;
  403.  import com.l2jserver.gameserver.model.itemcontainer.Inventory;
  404. @@ -143,15 +144,15 @@
  405.         writeD(_activeChar.getInventory().getPaperdollItemDisplayId(Inventory.PAPERDOLL_LFINGER));
  406.         writeD(_activeChar.getInventory().getPaperdollItemDisplayId(Inventory.PAPERDOLL_HEAD));
  407.        
  408. -       writeD(_airShipHelm == 0 ? _activeChar.getInventory().getPaperdollItemDisplayId(Inventory.PAPERDOLL_RHAND) : 0);
  409. -       writeD(_airShipHelm == 0 ? _activeChar.getInventory().getPaperdollItemDisplayId(Inventory.PAPERDOLL_LHAND) : 0);
  410. +       writeD(_activeChar.getVisualArmor(VisualArmors.RHand, false) != null ? _activeChar.getVisualArmor(VisualArmors.RHand, false).getItemId() : 0x00);
  411. +       writeD(_activeChar.getVisualArmor(VisualArmors.LHand, false) != null ? _activeChar.getVisualArmor(VisualArmors.LHand, false).getItemId() : 0x00);
  412.        
  413. -       writeD(_activeChar.getInventory().getPaperdollItemDisplayId(Inventory.PAPERDOLL_GLOVES));
  414. -       writeD(_activeChar.getInventory().getPaperdollItemDisplayId(Inventory.PAPERDOLL_CHEST));
  415. -       writeD(_activeChar.getInventory().getPaperdollItemDisplayId(Inventory.PAPERDOLL_LEGS));
  416. -       writeD(_activeChar.getInventory().getPaperdollItemDisplayId(Inventory.PAPERDOLL_FEET));
  417. -       writeD(_activeChar.getInventory().getPaperdollItemDisplayId(Inventory.PAPERDOLL_CLOAK));
  418. -       writeD(_activeChar.getInventory().getPaperdollItemDisplayId(Inventory.PAPERDOLL_RHAND));
  419. +       writeD(_activeChar.getVisualArmor(VisualArmors.Gloves, false) != null ? _activeChar.getVisualArmor(VisualArmors.Gloves, false).getItemId() : 0x00);
  420. +       writeD(_activeChar.getVisualArmor(VisualArmors.Armor, false) != null ? _activeChar.getVisualArmor(VisualArmors.Armor, false).getItemId() : 0x00);
  421. +       writeD(_activeChar.getVisualArmor(VisualArmors.Legs, false) != null ? _activeChar.getVisualArmor(VisualArmors.Legs, false).getItemId() : 0x00);
  422. +       writeD(_activeChar.getVisualArmor(VisualArmors.Feet, false) != null ? _activeChar.getVisualArmor(VisualArmors.Feet, false).getItemId() : 0x00);
  423. +       writeD(_activeChar.getVisualArmor(VisualArmors.Cloak, false) != null ? _activeChar.getVisualArmor(VisualArmors.Cloak, false).getItemId() : 0x00);
  424. +       writeD(_activeChar.getVisualArmor(VisualArmors.RHand, false) != null ? _activeChar.getVisualArmor(VisualArmors.RHand, false).getItemId() : 0x00);
  425.         writeD(_activeChar.getInventory().getPaperdollItemDisplayId(Inventory.PAPERDOLL_HAIR));
  426.         writeD(_activeChar.getInventory().getPaperdollItemDisplayId(Inventory.PAPERDOLL_HAIR2));
  427.         writeD(_activeChar.getInventory().getPaperdollItemDisplayId(Inventory.PAPERDOLL_RBRACELET));
  428. #P L2J_DataPack
  429. Index: dist/game/data/scripts/handlers/MasterHandler.java
  430. ===================================================================
  431. --- dist/game/data/scripts/handlers/MasterHandler.java  (revision 9067)
  432. +++ dist/game/data/scripts/handlers/MasterHandler.java  (working copy)
  433. @@ -288,6 +288,7 @@
  434.  import handlers.voicedcommandhandlers.ChangePassword;
  435.  import handlers.voicedcommandhandlers.ChatAdmin;
  436.  import handlers.voicedcommandhandlers.Debug;
  437. +import handlers.voicedcommandhandlers.DressMe;
  438.  import handlers.voicedcommandhandlers.Hellbound;
  439.  import handlers.voicedcommandhandlers.Lang;
  440.  import handlers.voicedcommandhandlers.StatsVCmd;
  441. @@ -603,6 +604,7 @@
  442.             (Config.L2JMOD_DEBUG_VOICE_COMMAND ? Debug.class : null),
  443.             (Config.L2JMOD_ALLOW_CHANGE_PASSWORD ? ChangePassword.class : null),
  444.             (Config.L2JMOD_HELLBOUND_STATUS ? Hellbound.class : null),
  445. +           DressMe.class
  446.         },
  447.         {
  448.             // Target Handlers
  449. Index: dist/sql/game/character_visual_armors.sql
  450. ===================================================================
  451. --- dist/sql/game/character_visual_armors.sql   (revision 0)
  452. +++ dist/sql/game/character_visual_armors.sql   (working copy)
  453. @@ -0,0 +1,15 @@
  454. +CREATE TABLE IF NOT EXISTS `character_visual_armors` (
  455. +  `charId` int(10) unsigned NOT NULL DEFAULT '0',
  456. +  `isUsingVisual` tinyint(3) NOT NULL DEFAULT '0',
  457. +  `armor` int(10) NOT NULL DEFAULT '0',
  458. +  `leggings` int(10) NOT NULL DEFAULT '0',
  459. +  `feet` int(10) NOT NULL DEFAULT '0',
  460. +  `gloves` int(10) NOT NULL DEFAULT '0',
  461. +  `lHand` int(10) NOT NULL DEFAULT '0',
  462. +  `sword` int(10) NOT NULL DEFAULT '0',
  463. +  `bow` int(10) NOT NULL DEFAULT '0',
  464. +  `pole` int(10) NOT NULL DEFAULT '0',
  465. +  `dualWeapons` int(10) NOT NULL DEFAULT '0',
  466. +  `bigSword` int(10) NOT NULL DEFAULT '0',
  467. +  PRIMARY KEY (`charId`)
  468. +) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  469. \ No newline at end of file
  470. Index: dist/game/data/html/DressMe/Menu.htm
  471. ===================================================================
  472. --- dist/game/data/html/DressMe/Menu.htm    (revision 0)
  473. +++ dist/game/data/html/DressMe/Menu.htm    (working copy)
  474. @@ -0,0 +1,11 @@
  475. +<html>
  476. +<body>
  477. +<center>
  478. +<button value="Copy Target" action="bypass -h .dressmetarget" width=80 height=27 back="L2UI_CT1.Button_DF_Down" fore="L2UI_ct1.button_df">
  479. +<br1>
  480. +%items%
  481. +<br>
  482. +%visualArmorState%
  483. +</center>
  484. +</body>
  485. +</html>
  486. \ No newline at end of file
  487. Index: dist/game/data/scripts/handlers/voicedcommandhandlers/DressMe.java
  488. ===================================================================
  489. --- dist/game/data/scripts/handlers/voicedcommandhandlers/DressMe.java  (revision 0)
  490. +++ dist/game/data/scripts/handlers/voicedcommandhandlers/DressMe.java  (working copy)
  491. @@ -0,0 +1,179 @@
  492. +/*
  493. + * This program is free software: you can redistribute it and/or modify it under
  494. + * the terms of the GNU General Public License as published by the Free Software
  495. + * Foundation, either version 3 of the License, or (at your option) any later
  496. + * version.
  497. + *
  498. + * This program is distributed in the hope that it will be useful, but WITHOUT
  499. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  500. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  501. + * details.
  502. + *
  503. + * You should have received a copy of the GNU General Public License along with
  504. + * this program. If not, see <http://www.gnu.org/licenses/>.
  505. + */
  506. +package handlers.voicedcommandhandlers;
  507. +
  508. +import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
  509. +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  510. +import com.l2jserver.gameserver.model.actor.instance.L2PcInstance.VisualArmors;
  511. +import com.l2jserver.gameserver.model.itemcontainer.Inventory;
  512. +import com.l2jserver.gameserver.network.SystemMessageId;
  513. +import com.l2jserver.gameserver.network.serverpackets.CharInfo;
  514. +import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
  515. +import com.l2jserver.gameserver.network.serverpackets.UserInfo;
  516. +
  517. +/**
  518. + * @author Erlandys
  519. + *
  520. + */
  521. +public class DressMe implements IVoicedCommandHandler
  522. +{
  523. +   private static final String[] VOICED_COMMANDS =
  524. +   {
  525. +       "dressme", "dressmetarget", "dressmestate"
  526. +   };
  527. +  
  528. +   @Override
  529. +   public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params)
  530. +   {
  531. +       if (command.equalsIgnoreCase("dressme")) {
  532. +           NpcHtmlMessage html = new NpcHtmlMessage(0);
  533. +           html.setFile(activeChar.getHtmlPrefix(), "data/html/DressMe/Menu.htm");
  534. +           html.replace("%items%", showItems(activeChar));
  535. +           html.replace("%visualArmorState%", "You are currently " + (activeChar.isUsingVisualArmors() ? "enabled" : "disabled") + " your Visual Armors! <a action=\"bypass -h .dressmestate\">Turn " + (activeChar.isUsingVisualArmors() ? "off" : "on") + " Visual Armors!</a>");
  536. +           activeChar.sendPacket(html);
  537. +       }
  538. +       else if (command.equalsIgnoreCase("dressmetarget")) {
  539. +           if (!(activeChar.getTarget() instanceof L2PcInstance) || activeChar.getTarget() == activeChar) {
  540. +               activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
  541. +               useVoicedCommand("dressme", activeChar, "");
  542. +               return false;
  543. +           }
  544. +           L2PcInstance target = ((L2PcInstance) activeChar.getTarget());
  545. +           if (target.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND) != null) {
  546. +               switch (target.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND).getWeaponItem().getItemType()) {
  547. +                   case SWORD:
  548. +                   case BLUNT:
  549. +                   case DAGGER:
  550. +                   case ETC:
  551. +                   case FIST:
  552. +                   case RAPIER:
  553. +                       activeChar.setVisualArmor(VisualArmors.Sword, target.getVisualArmor(VisualArmors.RHand, false).getItemId());
  554. +                       break;
  555. +                   case BOW:
  556. +                   case CROSSBOW:
  557. +                       activeChar.setVisualArmor(VisualArmors.Bow, target.getVisualArmor(VisualArmors.RHand, false).getItemId());
  558. +                       break;
  559. +                   case POLE:
  560. +                       activeChar.setVisualArmor(VisualArmors.Pole, target.getVisualArmor(VisualArmors.RHand, false).getItemId());
  561. +                       break;
  562. +                   case DUAL:
  563. +                   case DUALFIST:
  564. +                   case DUALDAGGER:
  565. +                       activeChar.setVisualArmor(VisualArmors.Dual, target.getVisualArmor(VisualArmors.RHand, false).getItemId());
  566. +                       break;
  567. +                   case ANCIENTSWORD:
  568. +                   case BIGBLUNT:
  569. +                   case BIGSWORD:
  570. +                       activeChar.setVisualArmor(VisualArmors.BigSword, target.getVisualArmor(VisualArmors.RHand, false).getItemId());
  571. +                       break;
  572. +               }
  573. +           }
  574. +           if (target.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LHAND) != null && target.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LHAND).isArmor())
  575. +               activeChar.setVisualArmor(VisualArmors.LHand, target.getVisualArmor(VisualArmors.LHand, false).getItemId());
  576. +           if (target.getInventory().getPaperdollItem(Inventory.PAPERDOLL_CHEST) != null)
  577. +               activeChar.setVisualArmor(VisualArmors.Armor, target.getVisualArmor(VisualArmors.Armor, false).getItemId());
  578. +           if (target.getInventory().getPaperdollItem(Inventory.PAPERDOLL_LEGS) != null && target.getVisualArmor(VisualArmors.Legs, false) != null)
  579. +               activeChar.setVisualArmor(VisualArmors.Legs, target.getVisualArmor(VisualArmors.Legs, false).getItemId());
  580. +           if (target.getInventory().getPaperdollItem(Inventory.PAPERDOLL_FEET) != null)
  581. +               activeChar.setVisualArmor(VisualArmors.Feet, target.getVisualArmor(VisualArmors.Feet, false).getItemId());
  582. +           if (target.getInventory().getPaperdollItem(Inventory.PAPERDOLL_GLOVES) != null)
  583. +               activeChar.setVisualArmor(VisualArmors.Gloves, target.getVisualArmor(VisualArmors.Gloves, false).getItemId());
  584. +           if (target.getInventory().getPaperdollItem(Inventory.PAPERDOLL_CLOAK) != null)
  585. +               activeChar.setVisualArmor(VisualArmors.Cloak, target.getVisualArmor(VisualArmors.Cloak, false).getItemId());
  586. +           activeChar.sendMessage("You have successfully copied " + target.getName() + "'s template!");
  587. +           activeChar.sendPacket(new UserInfo(activeChar));
  588. +           activeChar.sendPacket(new UserInfo(activeChar));
  589. +           activeChar.broadcastPacket(new CharInfo(activeChar));
  590. +           useVoicedCommand("dressme", activeChar, "");
  591. +       }
  592. +       else if (command.toLowerCase().startsWith("dressmestate")) {
  593. +           boolean turnOn = !activeChar.isUsingVisualArmors();
  594. +           activeChar.isUsingVisualArmors(turnOn);
  595. +           activeChar.sendMessage("You have successfully " + (turnOn ? "enabled" : "disabled") + " Visual Armors!");
  596. +           activeChar.sendPacket(new UserInfo(activeChar));
  597. +           activeChar.sendPacket(new UserInfo(activeChar));
  598. +           activeChar.broadcastPacket(new CharInfo(activeChar));
  599. +           useVoicedCommand("dressme", activeChar, "");
  600. +       }
  601. +       return true;
  602. +   }
  603. +  
  604. +   public String showItems(L2PcInstance activeChar) {
  605. +       String items = "";
  606. +       String sword = "icon.NOIMAGE";
  607. +       if (activeChar.getVisualArmor(VisualArmors.Sword, true) != null)
  608. +           sword = activeChar.getVisualArmor(VisualArmors.Sword, true).getIcon();
  609. +       String bow = "icon.NOIMAGE";
  610. +       if (activeChar.getVisualArmor(VisualArmors.Bow, true) != null)
  611. +           bow = activeChar.getVisualArmor(VisualArmors.Bow, true).getIcon();
  612. +       String pole = "icon.NOIMAGE";
  613. +       if (activeChar.getVisualArmor(VisualArmors.Pole, true) != null)
  614. +           pole = activeChar.getVisualArmor(VisualArmors.Pole, true).getIcon();
  615. +       String dual = "icon.NOIMAGE";
  616. +       if (activeChar.getVisualArmor(VisualArmors.Dual, true) != null)
  617. +           dual = activeChar.getVisualArmor(VisualArmors.Dual, true).getIcon();
  618. +       String bigSword = "icon.NOIMAGE";
  619. +       if (activeChar.getVisualArmor(VisualArmors.BigSword, true) != null)
  620. +           bigSword = activeChar.getVisualArmor(VisualArmors.BigSword, true).getIcon();
  621. +       String cloak = "icon.NOIMAGE";
  622. +       if (activeChar.getVisualArmor(VisualArmors.Cloak, true) != null)
  623. +           cloak = activeChar.getVisualArmor(VisualArmors.Cloak, true).getIcon();
  624. +       String armor = "icon.NOIMAGE";
  625. +       if (activeChar.getVisualArmor(VisualArmors.Armor, true) != null)
  626. +           armor = activeChar.getVisualArmor(VisualArmors.Armor, true).getIcon();
  627. +       String lHand = "icon.NOIMAGE";
  628. +       if (activeChar.getVisualArmor(VisualArmors.LHand, true) != null)
  629. +           lHand = activeChar.getVisualArmor(VisualArmors.LHand, true).getIcon();
  630. +       String legs = "icon.NOIMAGE";
  631. +       if (activeChar.getVisualArmor(VisualArmors.Legs, true) != null)
  632. +           legs = activeChar.getVisualArmor(VisualArmors.Legs, true).getIcon();
  633. +       String feet = "icon.NOIMAGE";
  634. +       if (activeChar.getVisualArmor(VisualArmors.Feet, true) != null)
  635. +           feet = activeChar.getVisualArmor(VisualArmors.Feet, true).getIcon();
  636. +       String gloves = "icon.NOIMAGE";
  637. +       if (activeChar.getVisualArmor(VisualArmors.Gloves, true) != null)
  638. +           gloves = activeChar.getVisualArmor(VisualArmors.Gloves, true).getIcon();
  639. +       items += "<table width=200>" +
  640. +           "<tr>" +
  641. +           "<td><img src=\"" + cloak + "\" width=32 height=32/></td>" +
  642. +           "<td><img src=\"" + armor + "\" width=32 height=32/></td>" +
  643. +           "<td><img src=\"" + lHand + "\" width=32 height=32/></td>" +
  644. +           "</tr>" +
  645. +           "<tr></tr><tr></tr>" +
  646. +           "<tr>" +
  647. +           "<td><img src=\"" + gloves + "\" width=32 height=32/></td>" +
  648. +           "<td><img src=\"" + legs + "\" width=32 height=32/></td>" +
  649. +           "<td><img src=\"" + feet + "\" width=32 height=32/></td>" +
  650. +           "</tr>" +
  651. +           "</table>";
  652. +       items += "<br><table width=250>" +
  653. +           "<tr>" +
  654. +           "<td><img src=\"" + sword + "\" width=32 height=32/></td>" +
  655. +           "<td><img src=\"" + bow + "\" width=32 height=32/></td>" +
  656. +           "<td><img src=\"" + pole + "\" width=32 height=32/></td>" +
  657. +           "<td><img src=\"" + dual + "\" width=32 height=32/></td>" +
  658. +           "<td><img src=\"" + bigSword + "\" width=32 height=32/></td>" +
  659. +           "</tr>" +
  660. +           "</table>" +
  661. +           "<br>";
  662. +       return items;
  663. +   }
  664. +  
  665. +   @Override
  666. +   public String[] getVoicedCommandList()
  667. +   {
  668. +       return VOICED_COMMANDS;
  669. +   }
  670. +}
Advertisement
Add Comment
Please, Sign In to add comment