Sync with L2JServer Feb 7th 2015.

This commit is contained in:
mobius
2015-02-07 23:48:56 +00:00
parent 1e166ca657
commit ecd17fdefb
1949 changed files with 3120 additions and 33466 deletions

View File

@@ -18,23 +18,25 @@
*/
package com.l2jserver.gameserver.handler;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Map;
import com.l2jserver.gameserver.enums.ChatType;
/**
* This class handles all chat handlers
* @author durgus, UnAfraid
*/
public class ChatHandler implements IHandler<IChatHandler, Integer>
public class ChatHandler implements IHandler<IChatHandler, ChatType>
{
private final Map<Integer, IChatHandler> _datatable;
private final Map<ChatType, IChatHandler> _datatable = new EnumMap<>(ChatType.class);
/**
* Singleton constructor
*/
protected ChatHandler()
{
_datatable = new HashMap<>();
}
/**
@@ -44,20 +46,18 @@ public class ChatHandler implements IHandler<IChatHandler, Integer>
@Override
public void registerHandler(IChatHandler handler)
{
int[] ids = handler.getChatTypeList();
for (int id : ids)
for (ChatType type : handler.getChatTypeList())
{
_datatable.put(id, handler);
_datatable.put(type, handler);
}
}
@Override
public synchronized void removeHandler(IChatHandler handler)
{
int[] ids = handler.getChatTypeList();
for (int id : ids)
for (ChatType type : handler.getChatTypeList())
{
_datatable.remove(id);
_datatable.remove(type);
}
}
@@ -67,7 +67,7 @@ public class ChatHandler implements IHandler<IChatHandler, Integer>
* @return
*/
@Override
public IChatHandler getHandler(Integer chatType)
public IChatHandler getHandler(ChatType chatType)
{
return _datatable.get(chatType);
}

View File

@@ -18,6 +18,7 @@
*/
package com.l2jserver.gameserver.handler;
import com.l2jserver.gameserver.enums.ChatType;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
/**
@@ -33,11 +34,11 @@ public interface IChatHandler
* @param target
* @param text
*/
public void handleChat(int type, L2PcInstance activeChar, String target, String text);
public void handleChat(ChatType type, L2PcInstance activeChar, String target, String text);
/**
* Returns a list of all chat types registered to this handler
* @return
*/
public int[] getChatTypeList();
public ChatType[] getChatTypeList();
}