Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.murion.engine.network.protocol.connection.decoder.login;
- import java.util.List;
- import com.murion.engine.network.protocol.connection.event.login.WorldPullEvent;
- import com.murion.engine.network.utilities.Base37Utils;
- import com.murion.engine.network.utilities.ByteBufUtils;
- import com.murion.engine.network.utilities.LoginUtils;
- import com.murion.game.world.node.actor.player.manager.InterfaceManager.Screen;
- import com.murion.util.security.IsaacGroup;
- import io.netty.buffer.ByteBuf;
- import io.netty.channel.ChannelHandlerContext;
- import io.netty.handler.codec.ByteToMessageDecoder;
- /**
- * @author _Jordan <jordan.abraham1997@gmail.com>
- */
- public class WorldDecoder extends ByteToMessageDecoder {
- /*
- * (non-Javadoc)
- *
- * @see io.netty.handler.codec.ByteToMessageDecoder#decode(io.netty.channel.ChannelHandlerContext,
- * io.netty.buffer.ByteBuf, java.util.List)
- */
- @Override
- protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
- if (!in.isReadable()) {
- ctx.pipeline().remove(this);
- return;
- }
- in.readUnsignedByte();
- ByteBuf block = LoginUtils.getRSABlock(in);
- int blockId = block.readUnsignedByte();
- if (blockId != 10) {
- ctx.channel().disconnect().sync();
- return;
- }
- int[] isaacSeed = LoginUtils.setIsaacSeeds(block, new int[4]);
- block.readLong();
- String password = ByteBufUtils.readString(block);
- block.readLong();
- block.readLong();
- block = LoginUtils.getXTEABlock(in, isaacSeed);
- String username = block.readByte() == 1 ? ByteBufUtils.readString(block) : Base37Utils.decodeBase37(block.readLong());
- int screenSizeId = block.readUnsignedByte();
- block.readUnsignedShort();// width
- block.readUnsignedShort();// height
- block.readUnsignedByte();
- for (int i = 0; i < 24; i++) {
- block.readByte();
- }
- ByteBufUtils.readString(block);
- IsaacGroup group = LoginUtils.getIsaacGroup(isaacSeed);
- out.add(new WorldPullEvent(username, password, group, Screen.get(screenSizeId)));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement