use of net.dzikoysk.funnyguilds.concurrency.requests.WarUseRequest in project FunnyGuilds by FunnyGuilds.
the class PacketExtension method registerPlayer.
public static void registerPlayer(Player player) {
try {
ConcurrencyManager concurrencyManager = FunnyGuilds.getInstance().getConcurrencyManager();
Channel channel = getChannel(player);
ChannelHandler handler = new ChannelDuplexHandler() {
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
if (msg == null) {
return;
}
super.write(ctx, msg, promise);
}
@Override
public void channelRead(ChannelHandlerContext ctx, Object packet) throws Exception {
try {
if (packet == null) {
return;
}
// IndependentThread.action(ActionType.PACKET_PLAY_IN_USE_ENTITY, p, msg);
concurrencyManager.postRequests(new WarUseRequest(player, packet));
super.channelRead(ctx, packet);
} catch (Exception e) {
super.channelRead(ctx, packet);
}
}
};
if (channel == null) {
return;
}
ChannelPipeline pipeline = channel.pipeline();
if (pipeline.names().contains("packet_handler")) {
if (pipeline.names().contains("FunnyGuilds")) {
pipeline.replace("FunnyGuilds", "FunnyGuilds", handler);
} else {
pipeline.addBefore("packet_handler", "FunnyGuilds", handler);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations