@Override public void handle(Player player, ItemOnObjectMessage message) { if (message.getInterfaceId() == Interface.INVENTORY) { if (player.getInventory().get(message.getSlotId()).getId() == message.getItemId()) { GameObject object = World.getWorld() .getRegionManager() .getRegion(player.getPosition()) .getObject(new Position(message.getObjectX(), message.getObjectY())); if (object.getId() == message.getObjectId()) { // TODO: logic return; } } } }
public void sendLoginSuccess(int status, Player player) { ByteBuf buf = channel.alloc().buffer(11); buf.writeByte(player.getRights()); buf.writeByte(0); buf.writeByte(0); buf.writeByte(0); buf.writeByte(0); buf.writeByte(0); buf.writeByte(0); buf.writeShort(player.getId()); buf.writeByte(1); buf.writeByte(1); ChannelPipeline pipeline = channel.pipeline(); GameSession session = new GameSession(server, channel, player); RsChannelHandler handler = pipeline.get(RsChannelHandler.class); handler.setSession(session); pipeline.remove(ReadTimeoutHandler.class); // TODO a different timeout mechanism is used in-game LoginResponse response = new LoginResponse(status, buf); channel.write(response); pipeline.addFirst( new GameFrameEncoder(outRandom), new GameMessageEncoder(server.getCodecRepository()), new GameFrameDecoder(inRandom), new GameMessageDecoder(server.getCodecRepository())); if (displayMode == 0 || displayMode == 1) player.getInterfaceSet().setDisplayMode(DisplayMode.FIXED); else player.getInterfaceSet().setDisplayMode(DisplayMode.RESIZABLE); session.init(); }