Răsfoiți Sursa

BETA: Implementing Initial Shortcuts:
* Allows customization of initial shortcuts and macros for new characters.

Reviewed by: Nos, St3eT, UnAfraid

Zoey76 11 ani în urmă
părinte
comite
b7f2a5dff0
19 a modificat fișierele cu 715 adăugiri și 279 ștergeri
  1. 2 0
      L2J_Server_BETA/java/com/l2jserver/gameserver/GameServer.java
  2. 1 2
      L2J_Server_BETA/java/com/l2jserver/gameserver/datatables/InitialEquipmentData.java
  3. 353 0
      L2J_Server_BETA/java/com/l2jserver/gameserver/datatables/InitialShortcutData.java
  4. 34 0
      L2J_Server_BETA/java/com/l2jserver/gameserver/enums/MacroType.java
  5. 34 0
      L2J_Server_BETA/java/com/l2jserver/gameserver/enums/ShortcutType.java
  6. 0 91
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/L2ShortCut.java
  7. 40 7
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/Macro.java
  8. 26 4
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/MacroCmd.java
  9. 7 5
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/MacroList.java
  10. 23 22
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/ShortCuts.java
  11. 125 0
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/Shortcut.java
  12. 15 14
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java
  13. 7 32
      L2J_Server_BETA/java/com/l2jserver/gameserver/network/clientpackets/CharacterCreate.java
  14. 3 2
      L2J_Server_BETA/java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java
  15. 2 8
      L2J_Server_BETA/java/com/l2jserver/gameserver/network/clientpackets/RequestMakeMacro.java
  16. 12 46
      L2J_Server_BETA/java/com/l2jserver/gameserver/network/clientpackets/RequestShortCutReg.java
  17. 1 1
      L2J_Server_BETA/java/com/l2jserver/gameserver/network/serverpackets/SendMacroList.java
  18. 16 20
      L2J_Server_BETA/java/com/l2jserver/gameserver/network/serverpackets/ShortCutInit.java
  19. 14 25
      L2J_Server_BETA/java/com/l2jserver/gameserver/network/serverpackets/ShortCutRegister.java

+ 2 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/GameServer.java

@@ -64,6 +64,7 @@ import com.l2jserver.gameserver.datatables.FishingRodsData;
 import com.l2jserver.gameserver.datatables.HennaData;
 import com.l2jserver.gameserver.datatables.HitConditionBonus;
 import com.l2jserver.gameserver.datatables.InitialEquipmentData;
+import com.l2jserver.gameserver.datatables.InitialShortcutData;
 import com.l2jserver.gameserver.datatables.ItemTable;
 import com.l2jserver.gameserver.datatables.KarmaData;
 import com.l2jserver.gameserver.datatables.ManorData;
@@ -248,6 +249,7 @@ public class GameServer
 		printSection("Characters");
 		ClassListData.getInstance();
 		InitialEquipmentData.getInstance();
+		InitialShortcutData.getInstance();
 		ExperienceTable.getInstance();
 		KarmaData.getInstance();
 		HitConditionBonus.getInstance();

+ 1 - 2
L2J_Server_BETA/java/com/l2jserver/gameserver/datatables/InitialEquipmentData.java

@@ -84,7 +84,6 @@ public final class InitialEquipmentData extends DocumentParser
 	private void parseEquipment(Node d)
 	{
 		NamedNodeMap attrs = d.getAttributes();
-		Node attr;
 		final ClassId classId = ClassId.getClassId(Integer.parseInt(attrs.getNamedItem("classId").getNodeValue()));
 		final List<PcItemTemplate> equipList = new ArrayList<>();
 		for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling())
@@ -95,7 +94,7 @@ public final class InitialEquipmentData extends DocumentParser
 				attrs = c.getAttributes();
 				for (int i = 0; i < attrs.getLength(); i++)
 				{
-					attr = attrs.item(i);
+					Node attr = attrs.item(i);
 					set.set(attr.getNodeName(), attr.getNodeValue());
 				}
 				equipList.add(new PcItemTemplate(set));

+ 353 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/datatables/InitialShortcutData.java

@@ -0,0 +1,353 @@
+/*
+ * Copyright (C) 2004-2014 L2J Server
+ * 
+ * This file is part of L2J Server.
+ * 
+ * L2J Server 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.
+ * 
+ * L2J Server 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 <http://www.gnu.org/licenses/>.
+ */
+package com.l2jserver.gameserver.datatables;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+import com.l2jserver.gameserver.engines.DocumentParser;
+import com.l2jserver.gameserver.enums.MacroType;
+import com.l2jserver.gameserver.enums.ShortcutType;
+import com.l2jserver.gameserver.model.Macro;
+import com.l2jserver.gameserver.model.MacroCmd;
+import com.l2jserver.gameserver.model.Shortcut;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.model.base.ClassId;
+import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
+import com.l2jserver.gameserver.network.serverpackets.ShortCutRegister;
+
+/**
+ * This class holds the Initial Shortcuts information.<br>
+ * What shortcuts get each newly created character.
+ * @author Zoey76
+ */
+public final class InitialShortcutData extends DocumentParser
+{
+	private final Map<ClassId, List<Shortcut>> _initialShortcutData = new HashMap<>();
+	private final List<Shortcut> _initialGlobalShortcutList = new ArrayList<>();
+	private final Map<Integer, Macro> _macroPresets = new HashMap<>();
+	
+	/**
+	 * Instantiates a new initial shortcuts data.
+	 */
+	protected InitialShortcutData()
+	{
+		load();
+	}
+	
+	@Override
+	public void load()
+	{
+		_initialShortcutData.clear();
+		_initialGlobalShortcutList.clear();
+		
+		parseDatapackFile("data/stats/initialShortcuts.xml");
+		
+		_log.info(getClass().getSimpleName() + ": Loaded " + _initialGlobalShortcutList.size() + " Initial Global Shortcuts data.");
+		_log.info(getClass().getSimpleName() + ": Loaded " + _initialShortcutData.size() + " Initial Shortcuts data.");
+		_log.info(getClass().getSimpleName() + ": Loaded " + _macroPresets.size() + " Macros presets.");
+	}
+	
+	@Override
+	protected void parseDocument()
+	{
+		for (Node n = getCurrentDocument().getFirstChild(); n != null; n = n.getNextSibling())
+		{
+			if ("list".equals(n.getNodeName()))
+			{
+				for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
+				{
+					switch (d.getNodeName())
+					{
+						case "shortcuts":
+						{
+							parseShortcuts(d);
+							break;
+						}
+						case "macros":
+						{
+							parseMacros(d);
+							break;
+						}
+					}
+				}
+			}
+		}
+	}
+	
+	/**
+	 * Parses a shortcut.
+	 * @param d the node
+	 */
+	private void parseShortcuts(Node d)
+	{
+		NamedNodeMap attrs = d.getAttributes();
+		final Node classIdNode = attrs.getNamedItem("classId");
+		final List<Shortcut> list = new ArrayList<>();
+		for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling())
+		{
+			if ("page".equals(c.getNodeName()))
+			{
+				attrs = c.getAttributes();
+				final int pageId = parseInteger(attrs, "pageId");
+				for (Node b = c.getFirstChild(); b != null; b = b.getNextSibling())
+				{
+					if ("slot".equals(b.getNodeName()))
+					{
+						list.add(createShortcut(pageId, b));
+					}
+				}
+			}
+		}
+		
+		if (classIdNode != null)
+		{
+			_initialShortcutData.put(ClassId.getClassId(Integer.parseInt(classIdNode.getNodeValue())), list);
+		}
+		else
+		{
+			_initialGlobalShortcutList.addAll(list);
+		}
+	}
+	
+	/**
+	 * Parses a macro.
+	 * @param d the node
+	 */
+	private void parseMacros(Node d)
+	{
+		for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling())
+		{
+			if ("macro".equals(c.getNodeName()))
+			{
+				NamedNodeMap attrs = c.getAttributes();
+				final int macroId = parseInteger(attrs, "macroId");
+				final int icon = parseInteger(attrs, "icon");
+				final String name = parseString(attrs, "name");
+				final String description = parseString(attrs, "description");
+				final String acronym = parseString(attrs, "acronym");
+				final List<MacroCmd> commands = new ArrayList<>(1);
+				int entry = 0;
+				for (Node b = c.getFirstChild(); b != null; b = b.getNextSibling())
+				{
+					if ("command".equals(b.getNodeName()))
+					{
+						attrs = b.getAttributes();
+						final MacroType type = parseEnum(attrs, MacroType.class, "type");
+						int d1 = 0;
+						int d2 = 0;
+						final String cmd = b.getTextContent();
+						switch (type)
+						{
+							case SKILL:
+							{
+								d1 = parseInteger(attrs, "skillId"); // Skill ID
+								d2 = parseInteger(attrs, "skillLvl", 0); // Skill level
+								break;
+							}
+							case ACTION:
+							{
+								// Not handled by client.
+								d1 = parseInteger(attrs, "actionId");
+								break;
+							}
+							case TEXT:
+							{
+								// Doesn't have numeric parameters.
+								break;
+							}
+							case SHORTCUT:
+							{
+								d1 = parseInteger(attrs, "page"); // Page
+								d2 = parseInteger(attrs, "slot", 0); // Slot
+								break;
+							}
+							case ITEM:
+							{
+								// Not handled by client.
+								d1 = parseInteger(attrs, "itemId");
+								break;
+							}
+							case DELAY:
+							{
+								d1 = parseInteger(attrs, "delay"); // Delay in seconds
+								break;
+							}
+						}
+						commands.add(new MacroCmd(entry++, type, d1, d2, cmd));
+					}
+				}
+				_macroPresets.put(macroId, new Macro(macroId, icon, name, description, acronym, commands));
+			}
+		}
+	}
+	
+	/**
+	 * Parses a node an create a shortcut from it.
+	 * @param pageId the page ID
+	 * @param b the node to parse
+	 * @return the new shortcut
+	 */
+	private Shortcut createShortcut(int pageId, Node b)
+	{
+		final NamedNodeMap attrs = b.getAttributes();
+		final int slotId = parseInteger(attrs, "slotId");
+		final ShortcutType shortcutType = parseEnum(attrs, ShortcutType.class, "shortcutType");
+		final int shortcutId = parseInteger(attrs, "shortcutId");
+		final int shortcutLevel = parseInteger(attrs, "shortcutLevel", 0);
+		final int characterType = parseInteger(attrs, "characterType", 0);
+		return new Shortcut(slotId, pageId, shortcutType, shortcutId, shortcutLevel, characterType);
+	}
+	
+	/**
+	 * Gets the shortcut list.
+	 * @param cId the class ID for the shortcut list
+	 * @return the shortcut list for the give class ID
+	 */
+	public List<Shortcut> getShortcutList(ClassId cId)
+	{
+		return _initialShortcutData.get(cId);
+	}
+	
+	/**
+	 * Gets the shortcut list.
+	 * @param cId the class ID for the shortcut list
+	 * @return the shortcut list for the give class ID
+	 */
+	public List<Shortcut> getShortcutList(int cId)
+	{
+		return _initialShortcutData.get(ClassId.getClassId(cId));
+	}
+	
+	/**
+	 * Gets the global shortcut list.
+	 * @return the global shortcut list
+	 */
+	public List<Shortcut> getGlobalMacroList()
+	{
+		return _initialGlobalShortcutList;
+	}
+	
+	/**
+	 * Register all the available shortcuts for the given player.
+	 * @param player the player
+	 */
+	public void registerAllShortcuts(L2PcInstance player)
+	{
+		if (player == null)
+		{
+			return;
+		}
+		
+		// Register global shortcuts.
+		for (Shortcut shortcut : _initialGlobalShortcutList)
+		{
+			int shortcutId = shortcut.getId();
+			switch (shortcut.getType())
+			{
+				case ITEM:
+				{
+					final L2ItemInstance item = player.getInventory().getItemByItemId(shortcutId);
+					if (item == null)
+					{
+						continue;
+					}
+					shortcutId = item.getObjectId();
+					break;
+				}
+				case SKILL:
+				{
+					if (!player.getSkills().containsKey(shortcutId))
+					{
+						continue;
+					}
+					break;
+				}
+				case MACRO:
+				{
+					player.registerMacro(_macroPresets.get(shortcutId));
+					break;
+				}
+			}
+			
+			// Register shortcut
+			final Shortcut newShortcut = new Shortcut(shortcut.getSlot(), shortcut.getPage(), shortcut.getType(), shortcutId, shortcut.getLevel(), shortcut.getCharacterType());
+			player.sendPacket(new ShortCutRegister(newShortcut));
+			player.registerShortCut(newShortcut);
+		}
+		
+		// Register class specific shortcuts.
+		if (_initialShortcutData.containsKey(player.getClassId()))
+		{
+			for (Shortcut shortcut : _initialShortcutData.get(player.getClassId()))
+			{
+				int shortcutId = shortcut.getId();
+				switch (shortcut.getType())
+				{
+					case ITEM:
+					{
+						final L2ItemInstance item = player.getInventory().getItemByItemId(shortcutId);
+						if (item == null)
+						{
+							continue;
+						}
+						shortcutId = item.getObjectId();
+						break;
+					}
+					case SKILL:
+					{
+						if (!player.getSkills().containsKey(shortcut.getId()))
+						{
+							continue;
+						}
+						break;
+					}
+					case MACRO:
+					{
+						player.registerMacro(_macroPresets.get(shortcut.getId()));
+						break;
+					}
+				}
+				// Register shortcut
+				final Shortcut newShortcut = new Shortcut(shortcut.getSlot(), shortcut.getPage(), shortcut.getType(), shortcutId, shortcut.getLevel(), shortcut.getCharacterType());
+				player.sendPacket(new ShortCutRegister(newShortcut));
+				player.registerShortCut(newShortcut);
+			}
+		}
+	}
+	
+	/**
+	 * Gets the single instance of InitialEquipmentData.
+	 * @return single instance of InitialEquipmentData
+	 */
+	public static InitialShortcutData getInstance()
+	{
+		return SingletonHolder._instance;
+	}
+	
+	private static class SingletonHolder
+	{
+		protected static final InitialShortcutData _instance = new InitialShortcutData();
+	}
+}

+ 34 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/enums/MacroType.java

@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2004-2014 L2J Server
+ * 
+ * This file is part of L2J Server.
+ * 
+ * L2J Server 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.
+ * 
+ * L2J Server 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 <http://www.gnu.org/licenses/>.
+ */
+package com.l2jserver.gameserver.enums;
+
+/**
+ * Macro type enumerated.
+ * @author Zoey76
+ */
+public enum MacroType
+{
+	NONE,
+	SKILL,
+	ACTION,
+	TEXT,
+	SHORTCUT,
+	ITEM,
+	DELAY
+}

+ 34 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/enums/ShortcutType.java

@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2004-2014 L2J Server
+ * 
+ * This file is part of L2J Server.
+ * 
+ * L2J Server 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.
+ * 
+ * L2J Server 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 <http://www.gnu.org/licenses/>.
+ */
+package com.l2jserver.gameserver.enums;
+
+/**
+ * Shortcut type enumerated.
+ * @author Zoey76
+ */
+public enum ShortcutType
+{
+	NONE,
+	ITEM,
+	SKILL,
+	ACTION,
+	MACRO,
+	RECIPE,
+	BOOKMARK,
+}

+ 0 - 91
L2J_Server_BETA/java/com/l2jserver/gameserver/model/L2ShortCut.java

@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2004-2014 L2J Server
- * 
- * This file is part of L2J Server.
- * 
- * L2J Server 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.
- * 
- * L2J Server 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 <http://www.gnu.org/licenses/>.
- */
-package com.l2jserver.gameserver.model;
-
-/**
- * This class ...
- * @version $Revision: 1.3.4.1 $ $Date: 2005/03/27 15:29:32 $
- */
-public class L2ShortCut
-{
-	public static final int TYPE_ITEM = 1;
-	public static final int TYPE_SKILL = 2;
-	public static final int TYPE_ACTION = 3;
-	public static final int TYPE_MACRO = 4;
-	public static final int TYPE_RECIPE = 5;
-	public static final int TYPE_TPBOOKMARK = 6;
-	
-	private final int _slot;
-	private final int _page;
-	private final int _type;
-	private final int _id;
-	private final int _level;
-	private final int _characterType;
-	private int _sharedReuseGroup = -1;
-	
-	public L2ShortCut(int slotId, int pageId, int shortcutType, int shortcutId, int shortcutLevel, int characterType)
-	{
-		_slot = slotId;
-		_page = pageId;
-		_type = shortcutType;
-		_id = shortcutId;
-		_level = shortcutLevel;
-		_characterType = characterType;
-	}
-	
-	public int getId()
-	{
-		return _id;
-	}
-	
-	public int getLevel()
-	{
-		return _level;
-	}
-	
-	public int getPage()
-	{
-		return _page;
-	}
-	
-	public int getSlot()
-	{
-		return _slot;
-	}
-	
-	public int getType()
-	{
-		return _type;
-	}
-	
-	public int getCharacterType()
-	{
-		return _characterType;
-	}
-	
-	public int getSharedReuseGroup()
-	{
-		return _sharedReuseGroup;
-	}
-	
-	public void setSharedReuseGroup(int g)
-	{
-		_sharedReuseGroup = g;
-	}
-}

+ 40 - 7
L2J_Server_BETA/java/com/l2jserver/gameserver/model/Macro.java

@@ -25,10 +25,6 @@ import com.l2jserver.gameserver.model.interfaces.INamable;
 
 public class Macro implements IIdentifiable, INamable
 {
-	public static final int CMD_TYPE_SKILL = 1;
-	public static final int CMD_TYPE_ACTION = 3;
-	public static final int CMD_TYPE_SHORTCUT = 4;
-	
 	private int _id;
 	private final int _icon;
 	private final String _name;
@@ -36,9 +32,18 @@ public class Macro implements IIdentifiable, INamable
 	private final String _acronym;
 	private final List<MacroCmd> _commands;
 	
+	/**
+	 * Constructor for macros.
+	 * @param id the macro ID
+	 * @param icon the icon ID
+	 * @param name the macro name
+	 * @param descr the macro description
+	 * @param acronym the macro acronym
+	 * @param list the macro command list
+	 */
 	public Macro(int id, int icon, String name, String descr, String acronym, List<MacroCmd> list)
 	{
-		setId(id);
+		_id = id;
 		_icon = icon;
 		_name = name;
 		_descr = descr;
@@ -46,38 +51,66 @@ public class Macro implements IIdentifiable, INamable
 		_commands = list;
 	}
 	
+	/**
+	 * Gets the marco ID.
+	 * @returns the marco ID
+	 */
 	@Override
 	public int getId()
 	{
 		return _id;
 	}
 	
-	public void setId(int _id)
+	/**
+	 * Sets the marco ID.
+	 * @param id the marco ID
+	 */
+	public void setId(int id)
 	{
-		this._id = _id;
+		_id = id;
 	}
 	
+	/**
+	 * Gets the macro icon ID.
+	 * @return the icon
+	 */
 	public int getIcon()
 	{
 		return _icon;
 	}
 	
+	/**
+	 * Gets the macro name.
+	 * @return the name
+	 */
 	@Override
 	public String getName()
 	{
 		return _name;
 	}
 	
+	/**
+	 * Gets the macro description.
+	 * @return the description
+	 */
 	public String getDescr()
 	{
 		return _descr;
 	}
 	
+	/**
+	 * Gets the macro acronym.
+	 * @return the acronym
+	 */
 	public String getAcronym()
 	{
 		return _acronym;
 	}
 	
+	/**
+	 * Gets the macro command list.
+	 * @return the macro command list
+	 */
 	public List<MacroCmd> getCommands()
 	{
 		return _commands;

+ 26 - 4
L2J_Server_BETA/java/com/l2jserver/gameserver/model/MacroCmd.java

@@ -18,19 +18,21 @@
  */
 package com.l2jserver.gameserver.model;
 
+import com.l2jserver.gameserver.enums.MacroType;
+
 /**
- * Macro Cmd data transfer object.
+ * Macro Cmd DTO.
  * @author Zoey76
  */
 public class MacroCmd
 {
 	private final int _entry;
-	private final int _type;
+	private final MacroType _type;
 	private final int _d1; // skill_id or page for shortcuts
 	private final int _d2; // shortcut
 	private final String _cmd;
 	
-	public MacroCmd(int entry, int type, int d1, int d2, String cmd)
+	public MacroCmd(int entry, MacroType type, int d1, int d2, String cmd)
 	{
 		_entry = entry;
 		_type = type;
@@ -39,26 +41,46 @@ public class MacroCmd
 		_cmd = cmd;
 	}
 	
+	/**
+	 * Gets the entry index.
+	 * @return the entry index
+	 */
 	public int getEntry()
 	{
 		return _entry;
 	}
 	
-	public int getType()
+	/**
+	 * Gets the macro type.
+	 * @return the macro type
+	 */
+	public MacroType getType()
 	{
 		return _type;
 	}
 	
+	/**
+	 * Gets the skill ID, item ID, page ID, depending on the marco use.
+	 * @return the first value
+	 */
 	public int getD1()
 	{
 		return _d1;
 	}
 	
+	/**
+	 * Gets the skill level, shortcut ID, depending on the marco use.
+	 * @return the second value
+	 */
 	public int getD2()
 	{
 		return _d2;
 	}
 	
+	/**
+	 * Gets the command.
+	 * @return the command
+	 */
 	public String getCmd()
 	{
 		return _cmd;

+ 7 - 5
L2J_Server_BETA/java/com/l2jserver/gameserver/model/MacroList.java

@@ -32,6 +32,8 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.gameserver.enums.MacroType;
+import com.l2jserver.gameserver.enums.ShortcutType;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.interfaces.IRestorable;
 import com.l2jserver.gameserver.network.serverpackets.SendMacroList;
@@ -95,10 +97,10 @@ public class MacroList implements IRestorable
 			deleteMacroFromDb(removed);
 		}
 		
-		final L2ShortCut[] allShortCuts = _owner.getAllShortCuts();
-		for (L2ShortCut sc : allShortCuts)
+		final Shortcut[] allShortCuts = _owner.getAllShortCuts();
+		for (Shortcut sc : allShortCuts)
 		{
-			if ((sc.getId() == id) && (sc.getType() == L2ShortCut.TYPE_MACRO))
+			if ((sc.getId() == id) && (sc.getType() == ShortcutType.MACRO))
 			{
 				_owner.deleteShortCut(sc.getSlot(), sc.getPage());
 			}
@@ -141,7 +143,7 @@ public class MacroList implements IRestorable
 			final StringBuilder sb = new StringBuilder(300);
 			for (MacroCmd cmd : macro.getCommands())
 			{
-				StringUtil.append(sb, String.valueOf(cmd.getType()), ",", String.valueOf(cmd.getD1()), ",", String.valueOf(cmd.getD2()));
+				StringUtil.append(sb, String.valueOf(cmd.getType().ordinal()), ",", String.valueOf(cmd.getD1()), ",", String.valueOf(cmd.getD2()));
 				if ((cmd.getCmd() != null) && (cmd.getCmd().length() > 0))
 				{
 					StringUtil.append(sb, ",", cmd.getCmd());
@@ -204,7 +206,7 @@ public class MacroList implements IRestorable
 						{
 							continue;
 						}
-						int type = Integer.parseInt(st.nextToken());
+						MacroType type = MacroType.values()[Integer.parseInt(st.nextToken())];
 						int d1 = Integer.parseInt(st.nextToken());
 						int d2 = Integer.parseInt(st.nextToken());
 						String cmd = "";

+ 23 - 22
L2J_Server_BETA/java/com/l2jserver/gameserver/model/ShortCuts.java

@@ -27,6 +27,7 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.gameserver.enums.ShortcutType;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.interfaces.IRestorable;
 import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
@@ -40,23 +41,23 @@ public class ShortCuts implements IRestorable
 	private static Logger _log = Logger.getLogger(ShortCuts.class.getName());
 	private static final int MAX_SHORTCUTS_PER_BAR = 12;
 	private final L2PcInstance _owner;
-	private final Map<Integer, L2ShortCut> _shortCuts = new TreeMap<>();
+	private final Map<Integer, Shortcut> _shortCuts = new TreeMap<>();
 	
 	public ShortCuts(L2PcInstance owner)
 	{
 		_owner = owner;
 	}
 	
-	public L2ShortCut[] getAllShortCuts()
+	public Shortcut[] getAllShortCuts()
 	{
-		return _shortCuts.values().toArray(new L2ShortCut[_shortCuts.values().size()]);
+		return _shortCuts.values().toArray(new Shortcut[_shortCuts.values().size()]);
 	}
 	
-	public L2ShortCut getShortCut(int slot, int page)
+	public Shortcut getShortCut(int slot, int page)
 	{
-		L2ShortCut sc = _shortCuts.get(slot + (page * MAX_SHORTCUTS_PER_BAR));
+		Shortcut sc = _shortCuts.get(slot + (page * MAX_SHORTCUTS_PER_BAR));
 		// Verify shortcut
-		if ((sc != null) && (sc.getType() == L2ShortCut.TYPE_ITEM))
+		if ((sc != null) && (sc.getType() == ShortcutType.ITEM))
 		{
 			if (_owner.getInventory().getItemByObjectId(sc.getId()) == null)
 			{
@@ -67,10 +68,10 @@ public class ShortCuts implements IRestorable
 		return sc;
 	}
 	
-	public synchronized void registerShortCut(L2ShortCut shortcut)
+	public synchronized void registerShortCut(Shortcut shortcut)
 	{
 		// Verify shortcut
-		if (shortcut.getType() == L2ShortCut.TYPE_ITEM)
+		if (shortcut.getType() == ShortcutType.ITEM)
 		{
 			final L2ItemInstance item = _owner.getInventory().getItemByObjectId(shortcut.getId());
 			if (item == null)
@@ -79,11 +80,11 @@ public class ShortCuts implements IRestorable
 			}
 			shortcut.setSharedReuseGroup(item.getSharedReuseGroup());
 		}
-		final L2ShortCut oldShortCut = _shortCuts.put(shortcut.getSlot() + (shortcut.getPage() * MAX_SHORTCUTS_PER_BAR), shortcut);
+		final Shortcut oldShortCut = _shortCuts.put(shortcut.getSlot() + (shortcut.getPage() * MAX_SHORTCUTS_PER_BAR), shortcut);
 		registerShortCutInDb(shortcut, oldShortCut);
 	}
 	
-	private void registerShortCutInDb(L2ShortCut shortcut, L2ShortCut oldShortCut)
+	private void registerShortCutInDb(Shortcut shortcut, Shortcut oldShortCut)
 	{
 		if (oldShortCut != null)
 		{
@@ -96,7 +97,7 @@ public class ShortCuts implements IRestorable
 			statement.setInt(1, _owner.getObjectId());
 			statement.setInt(2, shortcut.getSlot());
 			statement.setInt(3, shortcut.getPage());
-			statement.setInt(4, shortcut.getType());
+			statement.setInt(4, shortcut.getType().ordinal());
 			statement.setInt(5, shortcut.getId());
 			statement.setInt(6, shortcut.getLevel());
 			statement.setInt(7, _owner.getClassIndex());
@@ -114,13 +115,13 @@ public class ShortCuts implements IRestorable
 	 */
 	public synchronized void deleteShortCut(int slot, int page)
 	{
-		final L2ShortCut old = _shortCuts.remove(slot + (page * MAX_SHORTCUTS_PER_BAR));
+		final Shortcut old = _shortCuts.remove(slot + (page * MAX_SHORTCUTS_PER_BAR));
 		if ((old == null) || (_owner == null))
 		{
 			return;
 		}
 		deleteShortCutFromDb(old);
-		if (old.getType() == L2ShortCut.TYPE_ITEM)
+		if (old.getType() == ShortcutType.ITEM)
 		{
 			L2ItemInstance item = _owner.getInventory().getItemByObjectId(old.getId());
 			
@@ -143,9 +144,9 @@ public class ShortCuts implements IRestorable
 	
 	public synchronized void deleteShortCutByObjectId(int objectId)
 	{
-		for (L2ShortCut shortcut : _shortCuts.values())
+		for (Shortcut shortcut : _shortCuts.values())
 		{
-			if ((shortcut.getType() == L2ShortCut.TYPE_ITEM) && (shortcut.getId() == objectId))
+			if ((shortcut.getType() == ShortcutType.ITEM) && (shortcut.getId() == objectId))
 			{
 				deleteShortCut(shortcut.getSlot(), shortcut.getPage());
 				break;
@@ -156,7 +157,7 @@ public class ShortCuts implements IRestorable
 	/**
 	 * @param shortcut
 	 */
-	private void deleteShortCutFromDb(L2ShortCut shortcut)
+	private void deleteShortCutFromDb(Shortcut shortcut)
 	{
 		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
 			PreparedStatement statement = con.prepareStatement("DELETE FROM character_shortcuts WHERE charId=? AND slot=? AND page=? AND class_index=?"))
@@ -193,7 +194,7 @@ public class ShortCuts implements IRestorable
 					int id = rset.getInt("shortcut_id");
 					int level = rset.getInt("level");
 					
-					_shortCuts.put(slot + (page * MAX_SHORTCUTS_PER_BAR), new L2ShortCut(slot, page, type, id, level, 1));
+					_shortCuts.put(slot + (page * MAX_SHORTCUTS_PER_BAR), new Shortcut(slot, page, ShortcutType.values()[type], id, level, 1));
 				}
 			}
 		}
@@ -204,9 +205,9 @@ public class ShortCuts implements IRestorable
 		}
 		
 		// Verify shortcuts
-		for (L2ShortCut sc : getAllShortCuts())
+		for (Shortcut sc : getAllShortCuts())
 		{
-			if (sc.getType() == L2ShortCut.TYPE_ITEM)
+			if (sc.getType() == ShortcutType.ITEM)
 			{
 				L2ItemInstance item = _owner.getInventory().getItemByObjectId(sc.getId());
 				if (item == null)
@@ -231,11 +232,11 @@ public class ShortCuts implements IRestorable
 	public synchronized void updateShortCuts(int skillId, int skillLevel)
 	{
 		// Update all the shortcuts for this skill
-		for (L2ShortCut sc : _shortCuts.values())
+		for (Shortcut sc : _shortCuts.values())
 		{
-			if ((sc.getId() == skillId) && (sc.getType() == L2ShortCut.TYPE_SKILL))
+			if ((sc.getId() == skillId) && (sc.getType() == ShortcutType.SKILL))
 			{
-				L2ShortCut newsc = new L2ShortCut(sc.getSlot(), sc.getPage(), sc.getType(), sc.getId(), skillLevel, 1);
+				Shortcut newsc = new Shortcut(sc.getSlot(), sc.getPage(), sc.getType(), sc.getId(), skillLevel, 1);
 				_owner.sendPacket(new ShortCutRegister(newsc));
 				_owner.registerShortCut(newsc);
 			}

+ 125 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/model/Shortcut.java

@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2004-2014 L2J Server
+ * 
+ * This file is part of L2J Server.
+ * 
+ * L2J Server 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.
+ * 
+ * L2J Server 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 <http://www.gnu.org/licenses/>.
+ */
+package com.l2jserver.gameserver.model;
+
+import com.l2jserver.gameserver.enums.ShortcutType;
+
+/**
+ * Shortcut DTO.
+ * @author Zoey76
+ */
+public class Shortcut
+{
+	/** Slot from 0 to 11. */
+	private final int _slot;
+	/** Page from 0 to 9. */
+	private final int _page;
+	/** Type: item, skill, action, macro, recipe, bookmark. */
+	private final ShortcutType _type;
+	/** Shortcut ID. */
+	private final int _id;
+	/** Shortcut level (skills). */
+	private final int _level;
+	/** Character type: 1 player, 2 summon. */
+	private final int _characterType;
+	/** Shared reuse group. */
+	private int _sharedReuseGroup = -1;
+	
+	public Shortcut(int slot, int page, ShortcutType type, int id, int level, int characterType)
+	{
+		_slot = slot;
+		_page = page;
+		_type = type;
+		_id = id;
+		_level = level;
+		_characterType = characterType;
+	}
+	
+	/**
+	 * Gets the shortcut ID.
+	 * @return the ID
+	 */
+	public int getId()
+	{
+		return _id;
+	}
+	
+	/**
+	 * Gets the shortcut level.
+	 * @return the level
+	 */
+	public int getLevel()
+	{
+		return _level;
+	}
+	
+	/**
+	 * Gets the shortcut page.
+	 * @return the page
+	 */
+	public int getPage()
+	{
+		return _page;
+	}
+	
+	/**
+	 * Gets the shortcut slot.
+	 * @return the slot
+	 */
+	public int getSlot()
+	{
+		return _slot;
+	}
+	
+	/**
+	 * Gets the shortcut type.
+	 * @return the type
+	 */
+	public ShortcutType getType()
+	{
+		return _type;
+	}
+	
+	/**
+	 * Gets the shortcut character type.
+	 * @return the character type
+	 */
+	public int getCharacterType()
+	{
+		return _characterType;
+	}
+	
+	/**
+	 * Gets the shared reuse group.
+	 * @return the shared reuse group
+	 */
+	public int getSharedReuseGroup()
+	{
+		return _sharedReuseGroup;
+	}
+	
+	/**
+	 * Sets the shared reuse group.
+	 * @param sharedReuseGroup the shared reuse group to set
+	 */
+	public void setSharedReuseGroup(int sharedReuseGroup)
+	{
+		_sharedReuseGroup = sharedReuseGroup;
+	}
+}

+ 15 - 14
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java

@@ -96,6 +96,7 @@ import com.l2jserver.gameserver.enums.PlayerAction;
 import com.l2jserver.gameserver.enums.PrivateStoreType;
 import com.l2jserver.gameserver.enums.QuestEventType;
 import com.l2jserver.gameserver.enums.Sex;
+import com.l2jserver.gameserver.enums.ShortcutType;
 import com.l2jserver.gameserver.enums.ShotType;
 import com.l2jserver.gameserver.enums.Team;
 import com.l2jserver.gameserver.handler.IItemHandler;
@@ -137,7 +138,6 @@ import com.l2jserver.gameserver.model.L2PremiumItem;
 import com.l2jserver.gameserver.model.L2Radar;
 import com.l2jserver.gameserver.model.L2RecipeList;
 import com.l2jserver.gameserver.model.L2Request;
-import com.l2jserver.gameserver.model.L2ShortCut;
 import com.l2jserver.gameserver.model.L2SkillLearn;
 import com.l2jserver.gameserver.model.L2World;
 import com.l2jserver.gameserver.model.L2WorldRegion;
@@ -149,6 +149,7 @@ import com.l2jserver.gameserver.model.PartyMatchRoomList;
 import com.l2jserver.gameserver.model.PartyMatchWaitingList;
 import com.l2jserver.gameserver.model.PcCondOverride;
 import com.l2jserver.gameserver.model.ShortCuts;
+import com.l2jserver.gameserver.model.Shortcut;
 import com.l2jserver.gameserver.model.TeleportBookmark;
 import com.l2jserver.gameserver.model.TeleportWhereType;
 import com.l2jserver.gameserver.model.TerritoryWard;
@@ -607,12 +608,10 @@ public final class L2PcInstance extends L2Playable
 	/** The table containing all Quests began by the L2PcInstance */
 	private final Map<String, QuestState> _quests = new FastMap<>();
 	
-	/** The list containing all shortCuts of this L2PcInstance */
+	/** The list containing all shortCuts of this player. */
 	private final ShortCuts _shortCuts = new ShortCuts(this);
 	
-	/**
-	 * The list containing all macros of this L2PcInstance.
-	 */
+	/** The list containing all macros of this player. */
 	private final MacroList _macros = new MacroList(this);
 	
 	private final List<L2PcInstance> _snoopListener = new FastList<>();
@@ -1396,9 +1395,9 @@ public final class L2PcInstance extends L2Playable
 			_log.warning("Attempted to remove unknown RecipeList: " + recipeId);
 		}
 		
-		for (L2ShortCut sc : getAllShortCuts())
+		for (Shortcut sc : getAllShortCuts())
 		{
-			if ((sc != null) && (sc.getId() == recipeId) && (sc.getType() == L2ShortCut.TYPE_RECIPE))
+			if ((sc != null) && (sc.getId() == recipeId) && (sc.getType() == ShortcutType.RECIPE))
 			{
 				deleteShortCut(sc.getSlot(), sc.getPage());
 			}
@@ -1766,7 +1765,7 @@ public final class L2PcInstance extends L2Playable
 	/**
 	 * @return a table containing all L2ShortCut of the L2PcInstance.
 	 */
-	public L2ShortCut[] getAllShortCuts()
+	public Shortcut[] getAllShortCuts()
 	{
 		return _shortCuts.getAllShortCuts();
 	}
@@ -1776,7 +1775,7 @@ public final class L2PcInstance extends L2Playable
 	 * @param page The page of shortCuts containing the slot
 	 * @return the L2ShortCut of the L2PcInstance corresponding to the position (page-slot).
 	 */
-	public L2ShortCut getShortCut(int slot, int page)
+	public Shortcut getShortCut(int slot, int page)
 	{
 		return _shortCuts.getShortCut(slot, page);
 	}
@@ -1785,7 +1784,7 @@ public final class L2PcInstance extends L2Playable
 	 * Add a L2shortCut to the L2PcInstance _shortCuts
 	 * @param shortcut
 	 */
-	public void registerShortCut(L2ShortCut shortcut)
+	public void registerShortCut(Shortcut shortcut)
 	{
 		_shortCuts.registerShortCut(shortcut);
 	}
@@ -7944,12 +7943,14 @@ public final class L2PcInstance extends L2Playable
 			return oldSkill;
 		}
 		
-		final L2ShortCut[] allShortCuts = getAllShortCuts();
-		for (L2ShortCut sc : allShortCuts)
+		if (skill != null)
 		{
-			if ((sc != null) && (skill != null) && (sc.getId() == skill.getId()) && (sc.getType() == L2ShortCut.TYPE_SKILL) && !((skill.getId() >= 3080) && (skill.getId() <= 3259)))
+			for (Shortcut sc : getAllShortCuts())
 			{
-				deleteShortCut(sc.getSlot(), sc.getPage());
+				if ((sc != null) && (sc.getId() == skill.getId()) && (sc.getType() == ShortcutType.SKILL) && !((skill.getId() >= 3080) && (skill.getId() <= 3259)))
+				{
+					deleteShortCut(sc.getSlot(), sc.getPage());
+				}
 			}
 		}
 		return oldSkill;

+ 7 - 32
L2J_Server_BETA/java/com/l2jserver/gameserver/network/clientpackets/CharacterCreate.java

@@ -31,10 +31,10 @@ import javolution.util.FastList;
 import com.l2jserver.Config;
 import com.l2jserver.gameserver.datatables.CharNameTable;
 import com.l2jserver.gameserver.datatables.CharTemplateTable;
+import com.l2jserver.gameserver.datatables.InitialShortcutData;
 import com.l2jserver.gameserver.datatables.SkillData;
 import com.l2jserver.gameserver.datatables.SkillTreesData;
 import com.l2jserver.gameserver.instancemanager.QuestManager;
-import com.l2jserver.gameserver.model.L2ShortCut;
 import com.l2jserver.gameserver.model.L2SkillLearn;
 import com.l2jserver.gameserver.model.L2World;
 import com.l2jserver.gameserver.model.Location;
@@ -276,36 +276,17 @@ public final class CharacterCreate extends L2GameClientPacket
 			newChar.getStat().addSp(Config.STARTING_SP);
 		}
 		
-		L2ShortCut shortcut;
-		// add attack shortcut
-		shortcut = new L2ShortCut(0, 0, 3, 2, 0, 1);
-		newChar.registerShortCut(shortcut);
-		// add take shortcut
-		shortcut = new L2ShortCut(3, 0, 3, 5, 0, 1);
-		newChar.registerShortCut(shortcut);
-		// add sit shortcut
-		shortcut = new L2ShortCut(10, 0, 3, 0, 0, 1);
-		newChar.registerShortCut(shortcut);
-		
 		if (template.hasInitialEquipment())
 		{
-			L2ItemInstance item;
 			for (PcItemTemplate ie : template.getInitialEquipment())
 			{
-				item = newChar.getInventory().addItem("Init", ie.getId(), ie.getCount(), newChar, null);
+				final L2ItemInstance item = newChar.getInventory().addItem("Init", ie.getId(), ie.getCount(), newChar, null);
 				if (item == null)
 				{
 					_log.warning("Could not create item during char creation: itemId " + ie.getId() + ", amount " + ie.getCount() + ".");
 					continue;
 				}
 				
-				// Place Tutorial Guide shortcut.
-				if (item.getId() == 5588)
-				{
-					shortcut = new L2ShortCut(11, 0, 1, item.getObjectId(), 0, 1);
-					newChar.registerShortCut(shortcut);
-				}
-				
 				if (item.isEquipable() && ie.isEquipped())
 				{
 					newChar.getInventory().equipItem(item);
@@ -315,23 +296,17 @@ public final class CharacterCreate extends L2GameClientPacket
 		
 		for (L2SkillLearn skill : SkillTreesData.getInstance().getAvailableSkills(newChar, newChar.getClassId(), false, true))
 		{
-			newChar.addSkill(SkillData.getInstance().getSkill(skill.getSkillId(), skill.getSkillLevel()), true);
-			if ((skill.getSkillId() == 1001) || (skill.getSkillId() == 1177))
-			{
-				shortcut = new L2ShortCut(1, 0, 2, skill.getSkillId(), skill.getSkillLevel(), 1);
-				newChar.registerShortCut(shortcut);
-			}
-			if (skill.getSkillId() == 1216)
-			{
-				shortcut = new L2ShortCut(10, 0, 2, skill.getSkillId(), skill.getSkillLevel(), 1);
-				newChar.registerShortCut(shortcut);
-			}
 			if (Config.DEBUG)
 			{
 				_log.fine("Adding starter skill:" + skill.getSkillId() + " / " + skill.getSkillLevel());
 			}
+			
+			newChar.addSkill(SkillData.getInstance().getSkill(skill.getSkillId(), skill.getSkillLevel()), true);
 		}
 		
+		// Register all shortcuts for actions, skills and items for this new character.
+		InitialShortcutData.getInstance().registerAllShortcuts(newChar);
+		
 		if (!Config.DISABLE_TUTORIAL)
 		{
 			startTutorialQuest(newChar);

+ 3 - 2
L2J_Server_BETA/java/com/l2jserver/gameserver/network/clientpackets/EnterWorld.java

@@ -448,7 +448,7 @@ public class EnterWorld extends L2GameClientPacket
 		activeChar.sendPacket(SystemMessageId.WELCOME_TO_LINEAGE);
 		
 		activeChar.sendMessage(getText("VGhpcyBTZXJ2ZXIgdXNlcyBMMkosIGEgUHJvamVjdCBmb3VuZGVkIGJ5IEwyQ2hlZg==" + Config.EOL));
-		activeChar.sendMessage(getText("YW5kIGRldmVsb3BlZCBieSB0aGUgTDJKIERldiBUZWFtIGF0IHd3dy5sMmpzZXJ2ZXIuY29t" + Config.EOL));
+		activeChar.sendMessage(getText("YW5kIGRldmVsb3BlZCBieSBMMkogVGVhbSBhdCB3d3cubDJqc2VydmVyLmNvbQ==" + Config.EOL));
 		
 		if (Config.DISPLAY_SERVER_VERSION)
 		{
@@ -462,7 +462,8 @@ public class EnterWorld extends L2GameClientPacket
 				activeChar.sendMessage(getText("TDJKIERhdGFQYWNrIFZlcnNpb246") + " " + Config.DATAPACK_VERSION);
 			}
 		}
-		activeChar.sendMessage(getText("Q29weXJpZ2h0IDIwMDQtMjAxMg==" + Config.EOL));
+		activeChar.sendMessage(getText("Q29weXJpZ2h0IDIwMDQtMjAxNA==" + Config.EOL));
+		activeChar.sendMessage(getText("VGhhbmsgeW91IGZvciAxMCB5ZWFycyE=" + Config.EOL));
 		
 		SevenSigns.getInstance().sendCurrentPeriodMsg(activeChar);
 		Announcements.getInstance().showAnnouncements(activeChar);

+ 2 - 8
L2J_Server_BETA/java/com/l2jserver/gameserver/network/clientpackets/RequestMakeMacro.java

@@ -22,14 +22,12 @@ import java.util.ArrayList;
 import java.util.List;
 
 import com.l2jserver.Config;
+import com.l2jserver.gameserver.enums.MacroType;
 import com.l2jserver.gameserver.model.Macro;
 import com.l2jserver.gameserver.model.MacroCmd;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.network.SystemMessageId;
 
-/**
- * packet type id 0xc1 sample c1 d // id S // macro name S // unknown desc S // unknown acronym c // icon c // count c // entry c // type d // skill id c // shortcut id S // command name format: cdSSScc (ccdcS)
- */
 public final class RequestMakeMacro extends L2GameClientPacket
 {
 	private static final String _C__CD_REQUESTMAKEMACRO = "[C] CD RequestMakeMacro";
@@ -67,11 +65,7 @@ public final class RequestMakeMacro extends L2GameClientPacket
 			int d2 = readC();
 			String command = readS();
 			_commandsLenght += command.length();
-			commands.add(new MacroCmd(entry, type, d1, d2, command));
-			if (Config.DEBUG)
-			{
-				_log.info("entry:" + entry + "\ttype:" + type + "\td1:" + d1 + "\td2:" + d2 + "\tcommand:" + command);
-			}
+			commands.add(new MacroCmd(entry, MacroType.values()[(type < 1) || (type > 6) ? 0 : type], d1, d2, command));
 		}
 		_macro = new Macro(_id, _icon, _name, _desc, _acronym, commands);
 	}

+ 12 - 46
L2J_Server_BETA/java/com/l2jserver/gameserver/network/clientpackets/RequestShortCutReg.java

@@ -18,19 +18,15 @@
  */
 package com.l2jserver.gameserver.network.clientpackets;
 
-import com.l2jserver.gameserver.model.L2ShortCut;
-import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.enums.ShortcutType;
+import com.l2jserver.gameserver.model.Shortcut;
 import com.l2jserver.gameserver.network.serverpackets.ShortCutRegister;
 
-/**
- * This class ...
- * @version $Revision: 1.3.4.3 $ $Date: 2005/03/27 15:29:30 $
- */
 public final class RequestShortCutReg extends L2GameClientPacket
 {
 	private static final String _C__3D_REQUESTSHORTCUTREG = "[C] 3D RequestShortCutReg";
 	
-	private int _type;
+	private ShortcutType _type;
 	private int _id;
 	private int _slot;
 	private int _page;
@@ -40,57 +36,27 @@ public final class RequestShortCutReg extends L2GameClientPacket
 	@Override
 	protected void readImpl()
 	{
-		_type = readD();
-		int slot = readD();
+		final int typeId = readD();
+		_type = ShortcutType.values()[(typeId < 1) || (typeId > 6) ? 0 : typeId];
+		final int slot = readD();
+		_slot = slot % 12;
+		_page = slot / 12;
 		_id = readD();
 		_lvl = readD();
 		_characterType = readD();
-		
-		_slot = slot % 12;
-		_page = slot / 12;
 	}
 	
 	@Override
 	protected void runImpl()
 	{
-		L2PcInstance activeChar = getClient().getActiveChar();
-		if (activeChar == null)
+		if ((getActiveChar() == null) || (_page > 10) || (_page < 0))
 		{
 			return;
 		}
 		
-		if ((_page > 10) || (_page < 0))
-		{
-			return;
-		}
-		
-		switch (_type)
-		{
-			case 0x01: // item
-			case 0x02: // skill
-			{
-				L2ShortCut sc = new L2ShortCut(_slot, _page, _type, _id, _lvl, _characterType);
-				activeChar.registerShortCut(sc);
-				sendPacket(new ShortCutRegister(sc));
-				break;
-			}
-			case 0x03: // action
-			case 0x04: // macro
-			case 0x05: // recipe
-			{
-				L2ShortCut sc = new L2ShortCut(_slot, _page, _type, _id, _lvl, _characterType);
-				activeChar.registerShortCut(sc);
-				sendPacket(new ShortCutRegister(sc));
-				break;
-			}
-			case 0x06: // Teleport Bookmark
-			{
-				L2ShortCut sc = new L2ShortCut(_slot, _page, _type, _id, _lvl, _characterType);
-				activeChar.registerShortCut(sc);
-				sendPacket(new ShortCutRegister(sc));
-				break;
-			}
-		}
+		final Shortcut sc = new Shortcut(_slot, _page, _type, _id, _lvl, _characterType);
+		getActiveChar().registerShortCut(sc);
+		sendPacket(new ShortCutRegister(sc));
 	}
 	
 	@Override

+ 1 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/network/serverpackets/SendMacroList.java

@@ -58,7 +58,7 @@ public class SendMacroList extends L2GameServerPacket
 			for (MacroCmd cmd : _macro.getCommands())
 			{
 				writeC(i++); // command count
-				writeC(cmd.getType()); // type 1 = skill, 3 = action, 4 = shortcut
+				writeC(cmd.getType().ordinal()); // type 1 = skill, 3 = action, 4 = shortcut
 				writeD(cmd.getD1()); // skill id
 				writeC(cmd.getD2()); // shortcut id
 				writeS(cmd.getCmd()); // command name

+ 16 - 20
L2J_Server_BETA/java/com/l2jserver/gameserver/network/serverpackets/ShortCutInit.java

@@ -18,12 +18,12 @@
  */
 package com.l2jserver.gameserver.network.serverpackets;
 
-import com.l2jserver.gameserver.model.L2ShortCut;
+import com.l2jserver.gameserver.model.Shortcut;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 
 public final class ShortCutInit extends L2GameServerPacket
 {
-	private L2ShortCut[] _shortCuts;
+	private Shortcut[] _shortCuts;
 	private L2PcInstance _activeChar;
 	
 	public ShortCutInit(L2PcInstance activeChar)
@@ -43,15 +43,15 @@ public final class ShortCutInit extends L2GameServerPacket
 	{
 		writeC(0x45);
 		writeD(_shortCuts.length);
-		
-		for (L2ShortCut sc : _shortCuts)
+		for (Shortcut sc : _shortCuts)
 		{
-			writeD(sc.getType());
+			writeD(sc.getType().ordinal());
 			writeD(sc.getSlot() + (sc.getPage() * 12));
 			
 			switch (sc.getType())
 			{
-				case L2ShortCut.TYPE_ITEM: // 1
+				case ITEM:
+				{
 					writeD(sc.getId());
 					writeD(0x01);
 					writeD(sc.getSharedReuseGroup());
@@ -60,27 +60,23 @@ public final class ShortCutInit extends L2GameServerPacket
 					writeH(0x00);
 					writeH(0x00);
 					break;
-				case L2ShortCut.TYPE_SKILL: // 2
+				}
+				case SKILL:
+				{
 					writeD(sc.getId());
 					writeD(sc.getLevel());
 					writeC(0x00); // C5
 					writeD(0x01); // C6
 					break;
-				case L2ShortCut.TYPE_ACTION: // 3
-					writeD(sc.getId());
-					writeD(0x01); // C6
-					break;
-				case L2ShortCut.TYPE_MACRO: // 4
-					writeD(sc.getId());
-					writeD(0x01); // C6
-					break;
-				case L2ShortCut.TYPE_RECIPE: // 5
-					writeD(sc.getId());
-					writeD(0x01); // C6
-					break;
-				default:
+				}
+				case ACTION:
+				case MACRO:
+				case RECIPE:
+				case BOOKMARK:
+				{
 					writeD(sc.getId());
 					writeD(0x01); // C6
+				}
 			}
 		}
 	}

+ 14 - 25
L2J_Server_BETA/java/com/l2jserver/gameserver/network/serverpackets/ShortCutRegister.java

@@ -18,17 +18,17 @@
  */
 package com.l2jserver.gameserver.network.serverpackets;
 
-import com.l2jserver.gameserver.model.L2ShortCut;
+import com.l2jserver.gameserver.model.Shortcut;
 
 public final class ShortCutRegister extends L2GameServerPacket
 {
-	private final L2ShortCut _shortcut;
+	private final Shortcut _shortcut;
 	
 	/**
 	 * Register new skill shortcut
 	 * @param shortcut
 	 */
-	public ShortCutRegister(L2ShortCut shortcut)
+	public ShortCutRegister(Shortcut shortcut)
 	{
 		_shortcut = shortcut;
 	}
@@ -37,12 +37,12 @@ public final class ShortCutRegister extends L2GameServerPacket
 	protected final void writeImpl()
 	{
 		writeC(0x44);
-		
-		writeD(_shortcut.getType());
+		writeD(_shortcut.getType().ordinal());
 		writeD(_shortcut.getSlot() + (_shortcut.getPage() * 12)); // C4 Client
 		switch (_shortcut.getType())
 		{
-			case L2ShortCut.TYPE_ITEM: // 1
+			case ITEM:
+			{
 				writeD(_shortcut.getId());
 				writeD(_shortcut.getCharacterType());
 				writeD(_shortcut.getSharedReuseGroup());
@@ -50,30 +50,19 @@ public final class ShortCutRegister extends L2GameServerPacket
 				writeD(0x00); // unknown
 				writeD(0x00); // item augment id
 				break;
-			case L2ShortCut.TYPE_SKILL: // 2
+			}
+			case SKILL:
+			{
 				writeD(_shortcut.getId());
 				writeD(_shortcut.getLevel());
 				writeC(0x00); // C5
 				writeD(_shortcut.getCharacterType());
 				break;
-			//@formatter:off
-				/** these are same as default case, no need to duplicate, enable if packet get changed
-				 */
-				/*	case L2ShortCut.TYPE_ACTION: //3
-				 *		writeD(_shortcut.getId());
-				 *		writeD(_shortcut.getUserCommand());
-				 *		break;
-				 *	case L2ShortCut.TYPE_MACRO: //4
-				 *		writeD(_shortcut.getId());
-				 *		writeD(_shortcut.getUserCommand());
-				 *		break;
-				 *	case L2ShortCut.TYPE_RECIPE: //5
-				 *		writeD(_shortcut.getId());
-				 *		writeD(_shortcut.getUserCommand());
-				 *		break;
-				 */
-				//@formatter:on
-			default:
+			}
+			case ACTION:
+			case MACRO:
+			case RECIPE:
+			case BOOKMARK:
 			{
 				writeD(_shortcut.getId());
 				writeD(_shortcut.getCharacterType());