actual freya branch

This commit is contained in:
2026-09-12 15:41:31 +00:00
parent 8049e0a882
commit 68c1cd27d4
3510 changed files with 336689 additions and 302906 deletions
@@ -0,0 +1,92 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.handler;
import java.util.Map;
import javolution.util.FastMap;
import com.l2jserver.gameserver.model.L2Object.InstanceType;
public class ActionHandler
{
private final Map<InstanceType, IActionHandler> _actions;
private final Map<InstanceType, IActionHandler> _actionsShift;
public static ActionHandler getInstance()
{
return SingletonHolder._instance;
}
private ActionHandler()
{
_actions = new FastMap<>();
_actionsShift = new FastMap<>();
}
public void registerActionHandler(IActionHandler handler)
{
_actions.put(handler.getInstanceType(), handler);
}
public void registerActionShiftHandler(IActionHandler handler)
{
_actionsShift.put(handler.getInstanceType(), handler);
}
public IActionHandler getActionHandler(InstanceType iType)
{
IActionHandler result = null;
for (InstanceType t = iType; t != null; t = t.getParent())
{
result = _actions.get(t);
if (result != null)
{
break;
}
}
return result;
}
public IActionHandler getActionShiftHandler(InstanceType iType)
{
IActionHandler result = null;
for (InstanceType t = iType; t != null; t = t.getParent())
{
result = _actionsShift.get(t);
if (result != null)
{
break;
}
}
return result;
}
public int size()
{
return _actions.size();
}
public int sizeShift()
{
return _actionsShift.size();
}
@SuppressWarnings("synthetic-access")
private static class SingletonHolder
{
protected static final ActionHandler _instance = new ActionHandler();
}
}
@@ -0,0 +1,83 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.handler;
import gnu.trove.TIntObjectHashMap;
import java.util.logging.Logger;
import com.l2jserver.Config;
/**
* This class ...
* @version $Revision: 1.1.4.5 $ $Date: 2005/03/27 15:30:09 $
*/
public class AdminCommandHandler
{
private static Logger _log = Logger.getLogger(AdminCommandHandler.class.getName());
private final TIntObjectHashMap<IAdminCommandHandler> _datatable;
public static AdminCommandHandler getInstance()
{
return SingletonHolder._instance;
}
private AdminCommandHandler()
{
_datatable = new TIntObjectHashMap<>();
}
public void registerAdminCommandHandler(IAdminCommandHandler handler)
{
String[] ids = handler.getAdminCommandList();
for (String id : ids)
{
if (Config.DEBUG)
{
_log.fine("Adding handler for command " + id);
}
_datatable.put(id.hashCode(), handler);
}
}
public IAdminCommandHandler getAdminCommandHandler(String adminCommand)
{
String command = adminCommand;
if (adminCommand.indexOf(" ") != -1)
{
command = adminCommand.substring(0, adminCommand.indexOf(" "));
}
if (Config.DEBUG)
{
_log.fine("getting handler for command: " + command + " -> " + (_datatable.get(command.hashCode()) != null));
}
return _datatable.get(command.hashCode());
}
/**
* @return
*/
public int size()
{
return _datatable.size();
}
@SuppressWarnings("synthetic-access")
private static class SingletonHolder
{
protected static final AdminCommandHandler _instance = new AdminCommandHandler();
}
}
@@ -0,0 +1,83 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.handler;
import gnu.trove.TIntObjectHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jserver.Config;
/**
* @author nBd
*/
public class BypassHandler
{
private static Logger _log = Logger.getLogger(BypassHandler.class.getName());
private final TIntObjectHashMap<IBypassHandler> _datatable;
public static BypassHandler getInstance()
{
return SingletonHolder._instance;
}
private BypassHandler()
{
_datatable = new TIntObjectHashMap<>();
}
public void registerBypassHandler(IBypassHandler handler)
{
for (String element : handler.getBypassList())
{
if (Config.DEBUG)
{
_log.log(Level.FINE, "Adding handler for command " + element);
}
_datatable.put(element.toLowerCase().hashCode(), handler);
}
}
public IBypassHandler getBypassHandler(String BypassCommand)
{
String command = BypassCommand;
if (BypassCommand.indexOf(" ") != -1)
{
command = BypassCommand.substring(0, BypassCommand.indexOf(" "));
}
if (Config.DEBUG)
{
_log.log(Level.FINE, "getting handler for command: " + command + " -> " + (_datatable.get(command.hashCode()) != null));
}
return _datatable.get(command.toLowerCase().hashCode());
}
public int size()
{
return _datatable.size();
}
@SuppressWarnings("synthetic-access")
private static class SingletonHolder
{
protected static final BypassHandler _instance = new BypassHandler();
}
}
@@ -0,0 +1,87 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.handler;
import gnu.trove.TIntObjectHashMap;
import java.util.logging.Logger;
import com.l2jserver.Config;
/**
* This class handles all chat handlers
* @author durgus
*/
public class ChatHandler
{
private static Logger _log = Logger.getLogger(ChatHandler.class.getName());
private final TIntObjectHashMap<IChatHandler> _datatable;
public static ChatHandler getInstance()
{
return SingletonHolder._instance;
}
/**
* Singleton constructor
*/
private ChatHandler()
{
_datatable = new TIntObjectHashMap<>();
}
/**
* Register a new chat handler
* @param handler
*/
public void registerChatHandler(IChatHandler handler)
{
int[] ids = handler.getChatTypeList();
for (int id : ids)
{
if (Config.DEBUG)
{
_log.fine("Adding handler for chat type " + id);
}
_datatable.put(id, handler);
}
}
/**
* Get the chat handler for the given chat type
* @param chatType
* @return
*/
public IChatHandler getChatHandler(int chatType)
{
return _datatable.get(chatType);
}
/**
* Returns the size
* @return
*/
public int size()
{
return _datatable.size();
}
@SuppressWarnings("synthetic-access")
private static class SingletonHolder
{
protected static final ChatHandler _instance = new ChatHandler();
}
}
@@ -0,0 +1,30 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.handler;
import java.util.logging.Logger;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Object.InstanceType;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
public interface IActionHandler
{
public static Logger _log = Logger.getLogger(IActionHandler.class.getName());
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact);
public InstanceType getInstanceType();
}
@@ -0,0 +1,38 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.handler;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
/**
* This class ...
* @version $Revision: 1.1.4.2 $ $Date: 2005/03/27 15:30:09 $
*/
public interface IAdminCommandHandler
{
/**
* this is the worker method that is called when someone uses an admin command.
* @param activeChar
* @param command
* @return command success
*/
public boolean useAdminCommand(String command, L2PcInstance activeChar);
/**
* this method is called at initialization to register all the item ids automatically
* @return all known itemIds
*/
public String[] getAdminCommandList();
}
@@ -0,0 +1,43 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.handler;
import java.util.logging.Logger;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
/**
* @author nBd
*/
public interface IBypassHandler
{
public static Logger _log = Logger.getLogger(IBypassHandler.class.getName());
/**
* this is the worker method that is called when someone uses an bypass command
* @param command
* @param activeChar
* @param target
* @return success
*/
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target);
/**
* this method is called at initialization to register all bypasses automatically
* @return all known bypasses
*/
public String[] getBypassList();
}
@@ -0,0 +1,38 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.handler;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
/**
* Interface for chat handlers
* @author durgus
*/
public interface IChatHandler
{
/**
* Handles a specific type of chat messages
* @param type
* @param activeChar
* @param target
*/
public void handleChat(int type, L2PcInstance activeChar, String target, String text);
/**
* Returns a list of all chat types registered to this handler
* @return
*/
public int[] getChatTypeList();
}
@@ -0,0 +1,40 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.handler;
import java.util.logging.Logger;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.actor.L2Playable;
/**
* Mother class of all itemHandlers.<BR>
* <BR>
* an IItemHandler implementation has to be stateless
* @version $Revision: 1.1.4.3 $ $Date: 2005/03/27 15:30:09 $
*/
public interface IItemHandler
{
public static Logger _log = Logger.getLogger(IItemHandler.class.getName());
/**
* Launch task associated to the item.
* @param playable : L2PlayableInstance designating the player
* @param item : L2ItemInstance designating the item to use
* @param forceUse: ctrl hold on item use
*/
public void useItem(L2Playable playable, L2ItemInstance item, boolean forceUse);
}
@@ -0,0 +1,47 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.handler;
import java.util.logging.Logger;
import com.l2jserver.gameserver.model.L2Object;
import com.l2jserver.gameserver.model.L2Skill;
import com.l2jserver.gameserver.model.actor.L2Character;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
/**
* an IItemHandler implementation has to be stateless
* @version $Revision: 1.2.2.2.2.3 $ $Date: 2005/04/03 15:55:06 $
*/
public interface ISkillHandler
{
public static Logger _log = Logger.getLogger(ISkillHandler.class.getName());
/**
* this is the worker method that is called when using an item.
* @param activeChar
* @param item
* @param target
* @return count reduction after usage
*/
public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets);
/**
* this method is called at initialization to register all the item ids automatically
* @return all known itemIds
*/
public L2SkillType[] getSkillIds();
}
@@ -0,0 +1,42 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.handler;
import java.util.logging.Logger;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
/**
* This class ...
* @version $Revision: 1.1.2.1.2.2 $ $Date: 2005/03/27 15:30:10 $
*/
public interface IUserCommandHandler
{
public static Logger _log = Logger.getLogger(IUserCommandHandler.class.getName());
/**
* this is the worker method that is called when someone uses an admin command.
* @param activeChar
* @param command
* @return command success
*/
public boolean useUserCommand(int id, L2PcInstance activeChar);
/**
* this method is called at initialization to register all the item ids automatically
* @return all known itemIds
*/
public int[] getUserCommandList();
}
@@ -0,0 +1,42 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.handler;
import java.util.logging.Logger;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
/**
* This class ...
* @version $Revision: 1.1.4.2 $ $Date: 2005/03/27 15:30:09 $
*/
public interface IVoicedCommandHandler
{
public static Logger _log = Logger.getLogger(IVoicedCommandHandler.class.getName());
/**
* this is the worker method that is called when someone uses an admin command.
* @param activeChar
* @param command
* @return command success
*/
public boolean useVoicedCommand(String command, L2PcInstance activeChar, String params);
/**
* this method is called at initialization to register all the item ids automatically
* @return all known itemIds
*/
public String[] getVoicedCommandList();
}
@@ -0,0 +1,86 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.handler;
import gnu.trove.TIntObjectHashMap;
import com.l2jserver.gameserver.templates.item.L2EtcItem;
/**
* This class manages handlers of items
* @version $Revision: 1.1.4.3 $ $Date: 2005/03/27 15:30:09 $
*/
public class ItemHandler
{
private final TIntObjectHashMap<IItemHandler> _datatable;
/**
* Create ItemHandler if doesn't exist and returns ItemHandler
* @return ItemHandler
*/
public static ItemHandler getInstance()
{
return SingletonHolder._instance;
}
/**
* Returns the number of elements contained in datatable
* @return int : Size of the datatable
*/
public int size()
{
return _datatable.size();
}
/**
* Constructor of ItemHandler
*/
private ItemHandler()
{
_datatable = new TIntObjectHashMap<>();
}
/**
* Adds handler of item type in <I>datatable</I>.<BR>
* <BR>
* <B><I>Concept :</I></U><BR>
* This handler is put in <I>datatable</I> Map &lt;String ; IItemHandler &gt; for each ID corresponding to an item type (existing in classes of package itemhandlers) sets as key of the Map.
* @param handler (IItemHandler)
*/
public void registerItemHandler(IItemHandler handler)
{
_datatable.put(handler.getClass().getSimpleName().intern().hashCode(), handler);
}
/**
* Returns the handler of the item
* @param itemId : int designating the itemID
* @return IItemHandler
*/
public IItemHandler getItemHandler(L2EtcItem item)
{
if ((item == null) || (item.getHandlerName() == null))
{
return null;
}
return _datatable.get(item.getHandlerName().hashCode());
}
@SuppressWarnings("synthetic-access")
private static class SingletonHolder
{
protected static final ItemHandler _instance = new ItemHandler();
}
}
@@ -0,0 +1,66 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.handler;
import gnu.trove.TIntObjectHashMap;
import com.l2jserver.gameserver.templates.skills.L2SkillType;
/**
* This class ...
* @version $Revision: 1.1.4.4 $ $Date: 2005/04/03 15:55:06 $
*/
public class SkillHandler
{
private final TIntObjectHashMap<ISkillHandler> _datatable;
public static SkillHandler getInstance()
{
return SingletonHolder._instance;
}
private SkillHandler()
{
_datatable = new TIntObjectHashMap<>();
}
public void registerSkillHandler(ISkillHandler handler)
{
L2SkillType[] types = handler.getSkillIds();
for (L2SkillType t : types)
{
_datatable.put(t.ordinal(), handler);
}
}
public ISkillHandler getSkillHandler(L2SkillType skillType)
{
return _datatable.get(skillType.ordinal());
}
/**
* @return
*/
public int size()
{
return _datatable.size();
}
@SuppressWarnings("synthetic-access")
private static class SingletonHolder
{
protected static final SkillHandler _instance = new SkillHandler();
}
}
@@ -0,0 +1,78 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.handler;
import gnu.trove.TIntObjectHashMap;
import java.util.logging.Logger;
import com.l2jserver.Config;
/**
* This class ...
* @version $Revision: 1.1.2.1.2.5 $ $Date: 2005/03/27 15:30:09 $
*/
public class UserCommandHandler
{
private static Logger _log = Logger.getLogger(UserCommandHandler.class.getName());
private final TIntObjectHashMap<IUserCommandHandler> _datatable;
public static UserCommandHandler getInstance()
{
return SingletonHolder._instance;
}
private UserCommandHandler()
{
_datatable = new TIntObjectHashMap<>();
}
public void registerUserCommandHandler(IUserCommandHandler handler)
{
int[] ids = handler.getUserCommandList();
for (int id : ids)
{
if (Config.DEBUG)
{
_log.fine("Adding handler for user command " + id);
}
_datatable.put(id, handler);
}
}
public IUserCommandHandler getUserCommandHandler(int userCommand)
{
if (Config.DEBUG)
{
_log.fine("getting handler for user command: " + userCommand);
}
return _datatable.get(userCommand);
}
/**
* @return
*/
public int size()
{
return _datatable.size();
}
@SuppressWarnings("synthetic-access")
private static class SingletonHolder
{
protected static final UserCommandHandler _instance = new UserCommandHandler();
}
}
@@ -0,0 +1,83 @@
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.gameserver.handler;
import gnu.trove.TIntObjectHashMap;
import java.util.logging.Logger;
import com.l2jserver.Config;
/**
* This class ...
* @version $Revision: 1.1.4.5 $ $Date: 2005/03/27 15:30:09 $
*/
public class VoicedCommandHandler
{
private static Logger _log = Logger.getLogger(ItemHandler.class.getName());
private final TIntObjectHashMap<IVoicedCommandHandler> _datatable;
public static VoicedCommandHandler getInstance()
{
return SingletonHolder._instance;
}
private VoicedCommandHandler()
{
_datatable = new TIntObjectHashMap<>();
}
public void registerVoicedCommandHandler(IVoicedCommandHandler handler)
{
String[] ids = handler.getVoicedCommandList();
for (String id : ids)
{
if (Config.DEBUG)
{
_log.fine("Adding handler for command " + id);
}
_datatable.put(id.hashCode(), handler);
}
}
public IVoicedCommandHandler getVoicedCommandHandler(String voicedCommand)
{
String command = voicedCommand;
if (voicedCommand.indexOf(" ") != -1)
{
command = voicedCommand.substring(0, voicedCommand.indexOf(" "));
}
if (Config.DEBUG)
{
_log.fine("getting handler for command: " + command + " -> " + (_datatable.get(command.hashCode()) != null));
}
return _datatable.get(command.hashCode());
}
/**
* @return
*/
public int size()
{
return _datatable.size();
}
@SuppressWarnings("synthetic-access")
private static class SingletonHolder
{
protected static final VoicedCommandHandler _instance = new VoicedCommandHandler();
}
}