mirror of
https://github.com/GTNewHorizons/Opis.git
synced 2026-11-22 05:02:17 +00:00
Directory structure for ForgeGradle
This commit is contained in:
1 parent
3d8319dc6b
commit
04764c83c9
214 files changed
+104
-6
No files matched your search
@@ -0,0 +1,36 @@
|
||||
package mcp.mobius.opis.api;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
||||
import mcp.mobius.opis.modOpis;
|
||||
import mcp.mobius.opis.network.enums.Message;
|
||||
import mcp.mobius.opis.network.packets.server.NetDataRaw;
|
||||
|
||||
public enum MessageHandlerRegistrar {
|
||||
INSTANCE;
|
||||
|
||||
private HashMap<Message, HashSet<IMessageHandler>> msgHandlers = new HashMap<Message, HashSet<IMessageHandler>>();
|
||||
|
||||
public void registerHandler(Message msg, IMessageHandler handler){
|
||||
if (!msgHandlers.containsKey(msg))
|
||||
msgHandlers.put(msg, new HashSet<IMessageHandler>());
|
||||
|
||||
msgHandlers.get(msg).add(handler);
|
||||
}
|
||||
|
||||
public void routeMessage(Message msg, NetDataRaw rawdata){
|
||||
|
||||
if (msgHandlers.containsKey(msg)){
|
||||
for (IMessageHandler handler : msgHandlers.get(msg)){
|
||||
if (!handler.handleMessage(msg, rawdata)){
|
||||
modOpis.log.warning(String.format("Unhandled msg %s in handler %s", msg, handler));
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
modOpis.log.warning(String.format("Unhandled msg : %s", msg));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user