Sync with L2JServer Feb 7th 2015.
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user