Kaynağa Gözat

BETA: Implementation of UI Key mapping using XML.
* Implemented using !DocumentParser.

Zoey76 12 yıl önce
ebeveyn
işleme
bdd61d8ae2

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

@@ -75,7 +75,7 @@ import com.l2jserver.gameserver.datatables.SpawnTable;
 import com.l2jserver.gameserver.datatables.StaticObjects;
 import com.l2jserver.gameserver.datatables.SummonSkillsTable;
 import com.l2jserver.gameserver.datatables.TeleportLocationTable;
-import com.l2jserver.gameserver.datatables.UITable;
+import com.l2jserver.gameserver.datatables.UIData;
 import com.l2jserver.gameserver.geoeditorcon.GeoEditorListener;
 import com.l2jserver.gameserver.handler.EffectHandler;
 import com.l2jserver.gameserver.idfactory.IdFactory;
@@ -292,7 +292,7 @@ public class GameServer
 		HtmCache.getInstance();
 		CrestCache.getInstance();
 		TeleportLocationTable.getInstance();
-		UITable.getInstance();
+		UIData.getInstance();
 		PartyMatchWaitingList.getInstance();
 		PartyMatchRoomList.getInstance();
 		PetitionManager.getInstance();

+ 2 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/GameTimeController.java

@@ -32,11 +32,12 @@ import com.l2jserver.gameserver.model.actor.L2Character;
 import com.l2jserver.util.StackTrace;
 
 /**
+ * Game Time controller class.
  * @author Unknown, Forsaiken
  */
 public final class GameTimeController extends Thread
 {
-	static final Logger _log = Logger.getLogger(GameTimeController.class.getName());
+	private static final Logger _log = Logger.getLogger(GameTimeController.class.getName());
 	
 	public static final int TICKS_PER_SECOND = 10; // not able to change this without checking through code
 	public static final int MILLIS_IN_TICK = 1000 / TICKS_PER_SECOND;

+ 202 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/datatables/UIData.java

@@ -0,0 +1,202 @@
+/*
+ * Copyright (C) 2004-2013 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 java.util.logging.Logger;
+
+import org.w3c.dom.Node;
+
+import com.l2jserver.gameserver.engines.DocumentParser;
+import com.l2jserver.gameserver.model.ActionKey;
+
+/**
+ * UI Data parser.
+ * @author Zoey76
+ */
+public class UIData extends DocumentParser
+{
+	private static final Logger _log = Logger.getLogger(UIData.class.getName());
+	
+	private final Map<Integer, List<ActionKey>> _storedKeys = new HashMap<>();
+	private final Map<Integer, List<Integer>> _storedCategories = new HashMap<>();
+	
+	protected UIData()
+	{
+		load();
+	}
+	
+	@Override
+	public void load()
+	{
+		_storedKeys.clear();
+		_storedCategories.clear();
+		parseDatapackFile("data/ui/ui_en.xml");
+		_log.info(getClass().getSimpleName() + ": Loaded " + _storedKeys.size() + " keys " + _storedCategories.size() + " categories.");
+	}
+	
+	@Override
+	protected void parseDocument()
+	{
+		for (Node n = getCurrentDocument().getFirstChild(); n != null; n = n.getNextSibling())
+		{
+			if ("list".equalsIgnoreCase(n.getNodeName()))
+			{
+				for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
+				{
+					if ("category".equalsIgnoreCase(d.getNodeName()))
+					{
+						parseCategory(d);
+					}
+				}
+			}
+		}
+	}
+	
+	private void parseCategory(Node n)
+	{
+		final int cat = parseInt(n.getAttributes(), "id");
+		for (Node d = n.getFirstChild(); d != null; d = d.getNextSibling())
+		{
+			if ("commands".equalsIgnoreCase(d.getNodeName()))
+			{
+				parseCommands(cat, d);
+			}
+			else if ("keys".equalsIgnoreCase(d.getNodeName()))
+			{
+				parseKeys(cat, d);
+			}
+		}
+	}
+	
+	private void parseCommands(int cat, Node d)
+	{
+		for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling())
+		{
+			if ("cmd".equalsIgnoreCase(c.getNodeName()))
+			{
+				addCategory(_storedCategories, cat, Integer.parseInt(c.getTextContent()));
+			}
+		}
+	}
+	
+	private void parseKeys(int cat, Node d)
+	{
+		for (Node c = d.getFirstChild(); c != null; c = c.getNextSibling())
+		{
+			if ("key".equalsIgnoreCase(c.getNodeName()))
+			{
+				final ActionKey akey = new ActionKey(cat);
+				for (int i = 0; i < c.getAttributes().getLength(); i++)
+				{
+					final Node att = c.getAttributes().item(i);
+					final int val = Integer.parseInt(att.getNodeValue());
+					switch (att.getNodeName())
+					{
+						case "cmd":
+						{
+							akey.setCommandId(val);
+							break;
+						}
+						case "key":
+						{
+							akey.setKeyId(val);
+							break;
+						}
+						case "toggleKey1":
+						{
+							akey.setToogleKey1(val);
+							break;
+						}
+						case "toggleKey2":
+						{
+							akey.setToogleKey2(val);
+							break;
+						}
+						case "showType":
+						{
+							akey.setShowStatus(val);
+							break;
+						}
+					}
+				}
+				addKey(_storedKeys, cat, akey);
+			}
+		}
+	}
+	
+	/**
+	 * Add a category to the stored categories.
+	 * @param map the map to store the category
+	 * @param cat the category
+	 * @param cmd the command
+	 */
+	public static void addCategory(Map<Integer, List<Integer>> map, int cat, int cmd)
+	{
+		if (!map.containsKey(cat))
+		{
+			map.put(cat, new ArrayList<Integer>());
+		}
+		map.get(cat).add(cmd);
+	}
+	
+	/**
+	 * Create and insert an Action Key into the stored keys.
+	 * @param map the map to store the key
+	 * @param cat the category
+	 * @param akey the action key
+	 */
+	public static void addKey(Map<Integer, List<ActionKey>> map, int cat, ActionKey akey)
+	{
+		if (!map.containsKey(cat))
+		{
+			map.put(cat, new ArrayList<ActionKey>());
+		}
+		map.get(cat).add(akey);
+	}
+	
+	/**
+	 * @return the categories
+	 */
+	public Map<Integer, List<Integer>> getCategories()
+	{
+		return _storedCategories;
+	}
+	
+	/**
+	 * @return the keys
+	 */
+	public Map<Integer, List<ActionKey>> getKeys()
+	{
+		return _storedKeys;
+	}
+	
+	public static UIData getInstance()
+	{
+		return SingletonHolder._instance;
+	}
+	
+	private static class SingletonHolder
+	{
+		protected static final UIData _instance = new UIData();
+	}
+}

+ 0 - 173
L2J_Server_BETA/java/com/l2jserver/gameserver/datatables/UITable.java

@@ -1,173 +0,0 @@
-/*
- * Copyright (C) 2004-2013 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.io.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.LineNumberReader;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import com.l2jserver.Config;
-import com.l2jserver.gameserver.model.entity.ActionKey;
-
-/**
- * @author mrTJO
- */
-public class UITable
-{
-	private static final Logger _log = Logger.getLogger(UITable.class.getName());
-	
-	private final Map<Integer, List<ActionKey>> _storedKeys = new HashMap<>();
-	private final Map<Integer, List<Integer>> _storedCategories = new HashMap<>();
-	
-	protected UITable()
-	{
-		parseCatData();
-		parseKeyData();
-		_log.info(getClass().getSimpleName() + ": Loaded " + _storedCategories.size() + " Categories.");
-		_log.info(getClass().getSimpleName() + ": Loaded " + _storedKeys.size() + " Keys.");
-	}
-	
-	private void parseCatData()
-	{
-		final File uiData = new File(Config.DATAPACK_ROOT, "data/uicats_en.csv");
-		try (FileReader fr = new FileReader(uiData);
-			BufferedReader br = new BufferedReader(fr);
-			LineNumberReader lnr = new LineNumberReader(br))
-		{
-			String line = null;
-			while ((line = lnr.readLine()) != null)
-			{
-				if (line.trim().isEmpty() || (line.charAt(0) == '#'))
-				{
-					continue;
-				}
-				
-				StringTokenizer st = new StringTokenizer(line, ";");
-				
-				int cat = Integer.parseInt(st.nextToken());
-				int cmd = Integer.parseInt(st.nextToken());
-				
-				insertCategory(cat, cmd);
-			}
-		}
-		catch (FileNotFoundException e)
-		{
-			_log.warning(getClass().getSimpleName() + ": uicats_en.csv is missing in data folder");
-		}
-		catch (Exception e)
-		{
-			_log.log(Level.WARNING, getClass().getSimpleName() + ": Error while creating UI Default Categories table " + e.getMessage(), e);
-		}
-	}
-	
-	private void parseKeyData()
-	{
-		final File uiData = new File(Config.DATAPACK_ROOT, "data/uikeys_en.csv");
-		try (FileReader fr = new FileReader(uiData);
-			BufferedReader br = new BufferedReader(fr);
-			LineNumberReader lnr = new LineNumberReader(br))
-		{
-			String line = null;
-			while ((line = lnr.readLine()) != null)
-			{
-				if (line.trim().isEmpty() || (line.charAt(0) == '#'))
-				{
-					continue;
-				}
-				
-				StringTokenizer st = new StringTokenizer(line, ";");
-				
-				int cat = Integer.parseInt(st.nextToken());
-				int cmd = Integer.parseInt(st.nextToken());
-				int key = Integer.parseInt(st.nextToken());
-				int tk1 = Integer.parseInt(st.nextToken());
-				int tk2 = Integer.parseInt(st.nextToken());
-				int shw = Integer.parseInt(st.nextToken());
-				
-				insertKey(cat, cmd, key, tk1, tk2, shw);
-			}
-		}
-		catch (FileNotFoundException e)
-		{
-			_log.warning(getClass().getSimpleName() + ": uikeys_en.csv is missing in data folder");
-		}
-		catch (Exception e)
-		{
-			_log.log(Level.WARNING, getClass().getSimpleName() + ": Error while creating UI Default Keys table " + e.getMessage(), e);
-		}
-	}
-	
-	private void insertCategory(int cat, int cmd)
-	{
-		if (_storedCategories.containsKey(cat))
-		{
-			_storedCategories.get(cat).add(cmd);
-		}
-		else
-		{
-			List<Integer> tmp = new ArrayList<>();
-			tmp.add(cmd);
-			_storedCategories.put(cat, tmp);
-		}
-	}
-	
-	private void insertKey(int cat, int cmdId, int key, int tgKey1, int tgKey2, int show)
-	{
-		ActionKey tmk = new ActionKey(cat, cmdId, key, tgKey1, tgKey2, show);
-		if (_storedKeys.containsKey(cat))
-		{
-			_storedKeys.get(cat).add(tmk);
-		}
-		else
-		{
-			List<ActionKey> tmp = new ArrayList<>();
-			tmp.add(tmk);
-			_storedKeys.put(cat, tmp);
-		}
-	}
-	
-	public Map<Integer, List<Integer>> getCategories()
-	{
-		return _storedCategories;
-	}
-	
-	public Map<Integer, List<ActionKey>> getKeys()
-	{
-		return _storedKeys;
-	}
-	
-	public static UITable getInstance()
-	{
-		return SingletonHolder._instance;
-	}
-	
-	private static class SingletonHolder
-	{
-		protected static final UITable _instance = new UITable();
-	}
-}

+ 44 - 10
L2J_Server_BETA/java/com/l2jserver/gameserver/model/entity/ActionKey.java → L2J_Server_BETA/java/com/l2jserver/gameserver/model/ActionKey.java

@@ -16,27 +16,36 @@
  * 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.entity;
+package com.l2jserver.gameserver.model;
 
 /**
- * @author mrTJO
+ * Action Key DTO.
+ * @author mrTJO, Zoey76
  */
 public class ActionKey
 {
-	int _cat;
-	int _cmd;
-	int _key;
-	int _tgKey1;
-	int _tgKey2;
-	int _show;
+	private final int _cat;
+	private int _cmd = 0;
+	private int _key = 0;
+	private int _tgKey1 = 0;
+	private int _tgKey2 = 0;
+	private int _show = 1;
+	
+	/**
+	 * @param cat category Id
+	 */
+	public ActionKey(int cat)
+	{
+		_cat = cat;
+	}
 	
 	/**
 	 * L2ActionKey Initialization
 	 * @param cat Category ID
 	 * @param cmd Command ID
 	 * @param key User Defined Primary Key
-	 * @param tgKey1 1st Toogled Key (eg. Alt, Ctrl or Shift)
-	 * @param tgKey2 2nd Toogled Key (eg. Alt, Ctrl or Shift)
+	 * @param tgKey1 1st Toggled Key (eg. Alt, Ctrl or Shift)
+	 * @param tgKey2 2nd Toggled Key (eg. Alt, Ctrl or Shift)
 	 * @param show Show Action in UI
 	 */
 	public ActionKey(int cat, int cmd, int key, int tgKey1, int tgKey2, int show)
@@ -59,26 +68,51 @@ public class ActionKey
 		return _cmd;
 	}
 	
+	public void setCommandId(int cmd)
+	{
+		_cmd = cmd;
+	}
+	
 	public int getKeyId()
 	{
 		return _key;
 	}
 	
+	public void setKeyId(int key)
+	{
+		_key = key;
+	}
+	
 	public int getToogleKey1()
 	{
 		return _tgKey1;
 	}
 	
+	public void setToogleKey1(int tKey1)
+	{
+		_tgKey1 = tKey1;
+	}
+	
 	public int getToogleKey2()
 	{
 		return _tgKey2;
 	}
 	
+	public void setToogleKey2(int tKey2)
+	{
+		_tgKey2 = tKey2;
+	}
+	
 	public int getShowStatus()
 	{
 		return _show;
 	}
 	
+	public void setShowStatus(int show)
+	{
+		_show = show;
+	}
+	
 	public String getSqlSaveString(int playerId, int order)
 	{
 		return "(" + playerId + ", " + _cat + ", " + order + ", " + _cmd + "," + _key + ", " + _tgKey1 + ", " + _tgKey2 + ", " + _show + ")";

+ 42 - 83
L2J_Server_BETA/java/com/l2jserver/gameserver/model/L2UIKeysSettings.java → L2J_Server_BETA/java/com/l2jserver/gameserver/model/UIKeysSettings.java

@@ -21,36 +21,31 @@ package com.l2jserver.gameserver.model;
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import javolution.util.FastList;
-import javolution.util.FastMap;
-
 import com.l2jserver.L2DatabaseFactory;
-import com.l2jserver.gameserver.datatables.UITable;
-import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
-import com.l2jserver.gameserver.model.entity.ActionKey;
+import com.l2jserver.gameserver.datatables.UIData;
 
 /**
- * @author mrTJO
+ * UI Keys Settings class.
+ * @author mrTJO, Zoey76
  */
-public class L2UIKeysSettings
+public class UIKeysSettings
 {
-	protected static final Logger _log = Logger.getLogger(L2UIKeysSettings.class.getName());
-	
-	private final L2PcInstance _player;
-	
-	Map<Integer, List<ActionKey>> _storedKeys;
-	Map<Integer, List<Integer>> _storedCategories;
+	private static final Logger _log = Logger.getLogger(UIKeysSettings.class.getName());
 	
-	boolean _saved = true;
+	private final int _playerObjId;
+	private Map<Integer, List<ActionKey>> _storedKeys;
+	private Map<Integer, List<Integer>> _storedCategories;
+	private boolean _saved = true;
 	
-	public L2UIKeysSettings(L2PcInstance player)
+	public UIKeysSettings(int playerObjId)
 	{
-		_player = player;
+		_playerObjId = playerObjId;
 		loadFromDB();
 	}
 	
@@ -95,8 +90,6 @@ public class L2UIKeysSettings
 	public void saveInDB()
 	{
 		String query;
-		int playerId = _player.getObjectId();
-		
 		if (_saved)
 		{
 			return;
@@ -108,7 +101,7 @@ public class L2UIKeysSettings
 			int order = 0;
 			for (int key : _storedCategories.get(category))
 			{
-				query += "(" + playerId + ", " + category + ", " + (order++) + ", " + key + "),";
+				query += "(" + _playerObjId + ", " + category + ", " + (order++) + ", " + key + "),";
 			}
 		}
 		query = query.substring(0, query.length() - 1) + "; ";
@@ -128,7 +121,7 @@ public class L2UIKeysSettings
 			int order = 0;
 			for (ActionKey key : keyLst)
 			{
-				query += key.getSqlSaveString(playerId, order++) + ",";
+				query += key.getSqlSaveString(_playerObjId, order++) + ",";
 			}
 		}
 		query = query.substring(0, query.length() - 1) + ";";
@@ -147,37 +140,33 @@ public class L2UIKeysSettings
 	
 	public void getCatsFromDB()
 	{
-		
 		if (_storedCategories != null)
 		{
 			return;
 		}
 		
-		_storedCategories = new FastMap<>();
+		_storedCategories = new HashMap<>();
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
+		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+			PreparedStatement stmt = con.prepareStatement("SELECT * FROM character_ui_categories WHERE `charId` = ? ORDER BY `catId`, `order`"))
 		{
-			PreparedStatement stmt = con.prepareStatement("SELECT * FROM character_ui_categories WHERE `charId` = ? ORDER BY `catId`, `order`");
-			stmt.setInt(1, _player.getObjectId());
-			ResultSet rs = stmt.executeQuery();
-			
-			while (rs.next())
+			stmt.setInt(1, _playerObjId);
+			try (ResultSet rs = stmt.executeQuery())
 			{
-				int cat = rs.getInt("catId");
-				int cmd = rs.getInt("cmdId");
-				insertCategory(cat, cmd);
+				while (rs.next())
+				{
+					UIData.addCategory(_storedCategories, rs.getInt("catId"), rs.getInt("cmdId"));
+				}
 			}
-			stmt.close();
-			rs.close();
 		}
 		catch (Exception e)
 		{
 			_log.log(Level.WARNING, "Exception: getCatsFromDB(): " + e.getMessage(), e);
 		}
 		
-		if (_storedCategories.size() < 1)
+		if (_storedCategories.isEmpty())
 		{
-			_storedCategories = UITable.getInstance().getCategories();
+			_storedCategories = UIData.getInstance().getCategories();
 		}
 	}
 	
@@ -188,64 +177,34 @@ public class L2UIKeysSettings
 			return;
 		}
 		
-		_storedKeys = new FastMap<>();
+		_storedKeys = new HashMap<>();
 		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
+		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
+			PreparedStatement stmt = con.prepareStatement("SELECT * FROM character_ui_actions WHERE `charId` = ? ORDER BY `cat`, `order`"))
 		{
-			PreparedStatement stmt = con.prepareStatement("SELECT * FROM character_ui_actions WHERE `charId` = ? ORDER BY `cat`, `order`");
-			stmt.setInt(1, _player.getObjectId());
-			ResultSet rs = stmt.executeQuery();
-			
-			while (rs.next())
+			stmt.setInt(1, _playerObjId);
+			try (ResultSet rs = stmt.executeQuery())
 			{
-				int cat = rs.getInt("cat");
-				int cmd = rs.getInt("cmd");
-				int key = rs.getInt("key");
-				int tgKey1 = rs.getInt("tgKey1");
-				int tgKey2 = rs.getInt("tgKey2");
-				int show = rs.getInt("show");
-				insertKey(cat, cmd, key, tgKey1, tgKey2, show);
+				while (rs.next())
+				{
+					int cat = rs.getInt("cat");
+					int cmd = rs.getInt("cmd");
+					int key = rs.getInt("key");
+					int tgKey1 = rs.getInt("tgKey1");
+					int tgKey2 = rs.getInt("tgKey2");
+					int show = rs.getInt("show");
+					UIData.addKey(_storedKeys, cat, new ActionKey(cat, cmd, key, tgKey1, tgKey2, show));
+				}
 			}
-			stmt.close();
-			rs.close();
 		}
 		catch (Exception e)
 		{
 			_log.log(Level.WARNING, "Exception: getKeysFromDB(): " + e.getMessage(), e);
 		}
 		
-		if (_storedKeys.size() < 1)
-		{
-			_storedKeys = UITable.getInstance().getKeys();
-		}
-	}
-	
-	public void insertCategory(int cat, int cmd)
-	{
-		if (_storedCategories.containsKey(cat))
-		{
-			_storedCategories.get(cat).add(cmd);
-		}
-		else
-		{
-			List<Integer> tmp = new FastList<>();
-			tmp.add(cmd);
-			_storedCategories.put(cat, tmp);
-		}
-	}
-	
-	public void insertKey(int cat, int cmdId, int key, int tgKey1, int tgKey2, int show)
-	{
-		ActionKey tmk = new ActionKey(cat, cmdId, key, tgKey1, tgKey2, show);
-		if (_storedKeys.containsKey(cat))
-		{
-			_storedKeys.get(cat).add(tmk);
-		}
-		else
+		if (_storedKeys.isEmpty())
 		{
-			List<ActionKey> tmp = new FastList<>();
-			tmp.add(tmk);
-			_storedKeys.put(cat, tmp);
+			_storedKeys = UIData.getInstance().getKeys();
 		}
 	}
 	

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

@@ -122,7 +122,7 @@ import com.l2jserver.gameserver.model.L2Request;
 import com.l2jserver.gameserver.model.L2ShortCut;
 import com.l2jserver.gameserver.model.L2SkillLearn;
 import com.l2jserver.gameserver.model.L2Transformation;
-import com.l2jserver.gameserver.model.L2UIKeysSettings;
+import com.l2jserver.gameserver.model.UIKeysSettings;
 import com.l2jserver.gameserver.model.L2World;
 import com.l2jserver.gameserver.model.L2WorldRegion;
 import com.l2jserver.gameserver.model.Location;
@@ -936,7 +936,7 @@ public final class L2PcInstance extends L2Playable
 	}
 	
 	// Character UI
-	private L2UIKeysSettings _uiKeySettings;
+	private UIKeysSettings _uiKeySettings;
 	
 	/** Herbs Task Time **/
 	private int _herbstask = 0;
@@ -15651,7 +15651,7 @@ public final class L2PcInstance extends L2Playable
 	
 	private void restoreUISettings()
 	{
-		_uiKeySettings = new L2UIKeysSettings(this);
+		_uiKeySettings = new UIKeysSettings(getObjectId());
 	}
 	
 	private void storeUISettings()
@@ -15667,7 +15667,7 @@ public final class L2PcInstance extends L2Playable
 		}
 	}
 	
-	public L2UIKeysSettings getUISettings()
+	public UIKeysSettings getUISettings()
 	{
 		return _uiKeySettings;
 	}

+ 14 - 54
L2J_Server_BETA/java/com/l2jserver/gameserver/network/clientpackets/RequestSaveKeyMapping.java

@@ -18,28 +18,27 @@
  */
 package com.l2jserver.gameserver.network.clientpackets;
 
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import javolution.util.FastList;
-import javolution.util.FastMap;
-
 import com.l2jserver.Config;
+import com.l2jserver.gameserver.datatables.UIData;
+import com.l2jserver.gameserver.model.ActionKey;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
-import com.l2jserver.gameserver.model.entity.ActionKey;
 import com.l2jserver.gameserver.network.L2GameClient.GameClientState;
 
 /**
- * @author mrTJO
+ * Request Save Key Mapping client packet.
+ * @author mrTJO, Zoey76
  */
 public class RequestSaveKeyMapping extends L2GameClientPacket
 {
 	private static String _C__D0_22_REQUESTSAVEKEYMAPPING = "[C] D0:22 RequestSaveKeyMapping";
 	
-	int _tabNum;
-	
-	Map<Integer, List<ActionKey>> _keyMap = new FastMap<>();
-	Map<Integer, List<Integer>> _catMap = new FastMap<>();
+	private int _tabNum;
+	private final Map<Integer, List<ActionKey>> _keyMap = new HashMap<>();
+	private final Map<Integer, List<Integer>> _catMap = new HashMap<>();
 	
 	@Override
 	protected void readImpl()
@@ -54,16 +53,14 @@ public class RequestSaveKeyMapping extends L2GameClientPacket
 			int cmd1Size = readC();
 			for (int j = 0; j < cmd1Size; j++)
 			{
-				int cmdId = readC();
-				insertCategory(category, cmdId);
+				UIData.addCategory(_catMap, category, readC());
 			}
 			category++;
 			
 			int cmd2Size = readC();
 			for (int j = 0; j < cmd2Size; j++)
 			{
-				int cmdId = readC();
-				insertCategory(category, cmdId);
+				UIData.addCategory(_catMap, category, readC());
 			}
 			category++;
 			
@@ -75,59 +72,22 @@ public class RequestSaveKeyMapping extends L2GameClientPacket
 				int tgKey1 = readD();
 				int tgKey2 = readD();
 				int show = readD();
-				insertKey(i, cmd, key, tgKey1, tgKey2, show);
+				UIData.addKey(_keyMap, i, new ActionKey(i, cmd, key, tgKey1, tgKey2, show));
 			}
 		}
 		readD();
 		readD();
 	}
 	
-	public void insertCategory(int cat, int cmd)
-	{
-		if (_catMap.containsKey(cat))
-		{
-			_catMap.get(cat).add(cmd);
-		}
-		else
-		{
-			List<Integer> tmp = new FastList<>();
-			tmp.add(cmd);
-			_catMap.put(cat, tmp);
-		}
-	}
-	
-	public void insertKey(int cat, int cmdId, int key, int tgKey1, int tgKey2, int show)
-	{
-		ActionKey tmk = new ActionKey(cat, cmdId, key, tgKey1, tgKey2, show);
-		if (_keyMap.containsKey(cat))
-		{
-			_keyMap.get(cat).add(tmk);
-		}
-		else
-		{
-			List<ActionKey> tmp = new FastList<>();
-			tmp.add(tmk);
-			_keyMap.put(cat, tmp);
-		}
-	}
-	
 	@Override
 	protected void runImpl()
 	{
-		L2PcInstance player = getClient().getActiveChar();
-		
-		if (player == null)
+		final L2PcInstance player = getActiveChar();
+		if (!Config.STORE_UI_SETTINGS || (player == null) || (getClient().getState() != GameClientState.IN_GAME))
 		{
 			return;
 		}
-		if (getClient().getState() != GameClientState.IN_GAME)
-		{
-			return;
-		}
-		if (Config.STORE_UI_SETTINGS)
-		{
-			player.getUISettings().storeAll(_catMap, _keyMap);
-		}
+		player.getUISettings().storeAll(_catMap, _keyMap);
 	}
 	
 	@Override

+ 3 - 3
L2J_Server_BETA/java/com/l2jserver/gameserver/network/serverpackets/ExUISetting.java

@@ -20,16 +20,16 @@ package com.l2jserver.gameserver.network.serverpackets;
 
 import java.util.List;
 
-import com.l2jserver.gameserver.model.L2UIKeysSettings;
+import com.l2jserver.gameserver.model.ActionKey;
+import com.l2jserver.gameserver.model.UIKeysSettings;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
-import com.l2jserver.gameserver.model.entity.ActionKey;
 
 /**
  * @author mrTJO
  */
 public class ExUISetting extends L2GameServerPacket
 {
-	private final L2UIKeysSettings _uiSettings;
+	private final UIKeysSettings _uiSettings;
 	private int buffsize, categories;
 	
 	public ExUISetting(L2PcInstance player)

+ 6 - 14
L2J_Server_BETA/java/com/l2jserver/util/StackTrace.java

@@ -23,7 +23,7 @@ import java.util.logging.Logger;
 
 public class StackTrace
 {
-	private static Logger _log = Logger.getLogger(StackTrace.class.getName());
+	private static final Logger _log = Logger.getLogger(StackTrace.class.getName());
 	
 	public static boolean displayStackTraceInformation(Throwable ex)
 	{
@@ -76,62 +76,54 @@ public class StackTrace
 	
 	private static String extractPackageName(String fullClassName)
 	{
-		if ((null == fullClassName) || ("".equals(fullClassName)))
+		if ((null == fullClassName) || fullClassName.isEmpty())
 		{
 			return "";
 		}
-		
-		int lastDot = fullClassName.lastIndexOf('.');
-		
+		final int lastDot = fullClassName.lastIndexOf('.');
 		if (0 >= lastDot)
 		{
 			return "";
 		}
-		
 		return fullClassName.substring(0, lastDot);
 	}
 	
 	private static String extractSimpleClassName(String fullClassName)
 	{
-		if ((null == fullClassName) || ("".equals(fullClassName)))
+		if ((null == fullClassName) || fullClassName.isEmpty())
 		{
 			return "";
 		}
 		
 		int lastDot = fullClassName.lastIndexOf('.');
-		
 		if (0 > lastDot)
 		{
 			return fullClassName;
 		}
-		
 		return fullClassName.substring(++lastDot);
 	}
 	
 	private static String extractDirectClassName(String simpleClassName)
 	{
-		if ((null == simpleClassName) || ("".equals(simpleClassName)))
+		if ((null == simpleClassName) || simpleClassName.isEmpty())
 		{
 			return "";
 		}
 		
 		int lastSign = simpleClassName.lastIndexOf('$');
-		
 		if (0 > lastSign)
 		{
 			return simpleClassName;
 		}
-		
 		return simpleClassName.substring(++lastSign);
 	}
 	
 	private static String unmungeSimpleClassName(String simpleClassName)
 	{
-		if ((null == simpleClassName) || ("".equals(simpleClassName)))
+		if ((null == simpleClassName) || simpleClassName.isEmpty())
 		{
 			return "";
 		}
-		
 		return simpleClassName.replace('$', '.');
 	}
 }