• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java PacketReceivedEvent类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.github.steveice10.packetlib.event.session.PacketReceivedEvent的典型用法代码示例。如果您正苦于以下问题:Java PacketReceivedEvent类的具体用法?Java PacketReceivedEvent怎么用?Java PacketReceivedEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PacketReceivedEvent类属于com.github.steveice10.packetlib.event.session包,在下文中一共展示了PacketReceivedEvent类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: packetReceived

import com.github.steveice10.packetlib.event.session.PacketReceivedEvent; //导入依赖的package包/类
@Override
public void packetReceived(PacketReceivedEvent receiveEvent) {
    if (receiveEvent.getPacket() instanceof ServerChatPacket) {
        Message message = receiveEvent.<ServerChatPacket>getPacket().getMessage();
        owner.getLogger().log(Level.INFO, "Received Message: {0}", message.getFullText());
    } else if (receiveEvent.getPacket() instanceof ServerPlayerPositionRotationPacket) {
        ServerPlayerPositionRotationPacket posPacket = receiveEvent.<ServerPlayerPositionRotationPacket>getPacket();

        double posX = posPacket.getX();
        double posY = posPacket.getY();
        double posZ = posPacket.getZ();
        float pitch = posPacket.getPitch();
        float yaw = posPacket.getYaw();
        EntitiyLocation location = new EntitiyLocation(posX, posY, posZ, pitch, yaw);
        owner.setLocation(location);
    } else if (receiveEvent.getPacket() instanceof ServerPlayerHealthPacket) {
        ServerPlayerHealthPacket healthPacket = receiveEvent.<ServerPlayerHealthPacket>getPacket();
        owner.setHealth(healthPacket.getHealth());
        owner.setFood(healthPacket.getFood());
    } else if (receiveEvent.getPacket() instanceof ServerJoinGamePacket) {
        ServerJoinGamePacket loginSuccessPacket = receiveEvent.<ServerJoinGamePacket>getPacket();
        super.onJoin();
    }
}
 
开发者ID:games647,项目名称:LambdaAttack,代码行数:25,代码来源:SessionListener112.java


示例2: decode

import com.github.steveice10.packetlib.event.session.PacketReceivedEvent; //导入依赖的package包/类
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf buf, List<Object> out) throws Exception {
    int initial = buf.readerIndex();
    NetInput in = new ByteBufNetInput(buf);
    int id = this.session.getPacketProtocol().getPacketHeader().readPacketId(in);
    if(id == -1) {
        buf.readerIndex(initial);
        return;
    }

    Packet packet = this.session.getPacketProtocol().createIncomingPacket(id);
    packet.read(in);

    if(buf.readableBytes() > 0) {
        throw new IllegalStateException("Packet \"" + packet.getClass().getSimpleName() + "\" not fully read.");
    }

    if(packet.isPriority()) {
        this.session.callEvent(new PacketReceivedEvent(this.session, packet));
    }

    out.add(packet);
}
 
开发者ID:Steveice10,项目名称:PacketLib,代码行数:24,代码来源:TcpPacketCodec.java


示例3: packetReceived

import com.github.steveice10.packetlib.event.session.PacketReceivedEvent; //导入依赖的package包/类
@Override
public void packetReceived(PacketReceivedEvent event) {
    if(ClientChatPacket.class.isAssignableFrom(event.getPacket().getClass())) {
        ClientChatPacket chat = event.getPacket();
        onChat(chat.getMessage());
    }
}
 
开发者ID:DragonetMC,项目名称:AuthServer,代码行数:8,代码来源:AuthSession.java


示例4: packetReceived

import com.github.steveice10.packetlib.event.session.PacketReceivedEvent; //导入依赖的package包/类
@Override
public void packetReceived(PacketReceivedEvent receiveEvent) {
    Packet packet = receiveEvent.getPacket();
    if (guessProtocol && packet instanceof HandshakePacket) {
        HandshakePacket handshakePacket = (HandshakePacket) packet;
        if (handshakePacket.getIntent() == HandshakeIntent.STATUS) {
            Session session = receiveEvent.getSession();
            int protocolVersion = handshakePacket.getProtocolVersion();
            verificationServer.getProtocolVersions().put(session, protocolVersion);
        }
    }

    super.packetReceived(receiveEvent);
}
 
开发者ID:games647,项目名称:MinecraftVerificationServer,代码行数:15,代码来源:PacketListener.java


示例5: packetReceived

import com.github.steveice10.packetlib.event.session.PacketReceivedEvent; //导入依赖的package包/类
@Override
public void packetReceived(PacketReceivedEvent event) {
    if(event.getPacket() instanceof ClientIdentificationPacket) {
        ClientIdentificationPacket packet = event.getPacket();
        event.getSession().setFlag(ClassicConstants.USERNAME_KEY, packet.getUsername());
        if(event.getSession().hasFlag(ClassicConstants.SALT_KEY) && !packet.getVerificationKey().equals(md5(event.getSession().getFlag(ClassicConstants.SALT_KEY) + packet.getUsername()))) {
            event.getSession().disconnect("Failed to verify username.");
        }
    }
}
 
开发者ID:Steveice10,项目名称:ClassicProtocolLib,代码行数:11,代码来源:ServerListener.java


示例6: packetReceived

import com.github.steveice10.packetlib.event.session.PacketReceivedEvent; //导入依赖的package包/类
@Override
public void packetReceived(PacketReceivedEvent event) {
    if(event.getPacket() instanceof PingPacket) {
        System.out.println("SERVER Received: " + event.<PingPacket>getPacket().getPingId());
        event.getSession().send(event.getPacket());
    }
}
 
开发者ID:Steveice10,项目名称:PacketLib,代码行数:8,代码来源:ServerSessionListener.java


示例7: packetReceived

import com.github.steveice10.packetlib.event.session.PacketReceivedEvent; //导入依赖的package包/类
@Override
public void packetReceived(PacketReceivedEvent event) {
    if(event.getPacket() instanceof PingPacket) {
        PingPacket packet = event.getPacket();

        System.out.println("CLIENT Received: " + packet.getPingId());

        if(packet.getPingId().equals("hello")) {
            event.getSession().send(new PingPacket("exit"));
        } else if(packet.getPingId().equals("exit")) {
            event.getSession().disconnect("Finished");
        }
    }
}
 
开发者ID:Steveice10,项目名称:PacketLib,代码行数:15,代码来源:ClientSessionListener.java


示例8: channelActive

import com.github.steveice10.packetlib.event.session.PacketReceivedEvent; //导入依赖的package包/类
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
    if(this.disconnected || this.channel != null) {
        ctx.channel().close();
        return;
    }

    this.channel = ctx.channel();

    this.packetHandleThread = new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                Packet packet;
                while((packet = packets.take()) != null) {
                    callEvent(new PacketReceivedEvent(TcpSession.this, packet));
                }
            } catch(InterruptedException e) {
            } catch(Throwable t) {
                exceptionCaught(null, t);
            }
        }
    });

    this.packetHandleThread.start();

    this.callEvent(new ConnectedEvent(this));
}
 
开发者ID:Steveice10,项目名称:PacketLib,代码行数:29,代码来源:TcpSession.java


示例9: packetReceived

import com.github.steveice10.packetlib.event.session.PacketReceivedEvent; //导入依赖的package包/类
@Override
    public void packetReceived(final PacketReceivedEvent event) {
        Packet packet = event.getPacket();
        if (packet instanceof ServerJoinGamePacket) {
            logger.log(Level.INFO, "Joined game!");
        } else if (packet instanceof ServerChatPacket) {
            Message message = event.<ServerChatPacket>getPacket().getMessage();
            try {
                logger.log(Level.INFO, "[Chat] {0}", parseJsonOpt(message.toJsonString()));
            } catch (JSONException ex) {
                logger.log(Level.SEVERE, "Failed to get chat text", ex);
            }
        } else if (packet instanceof LoginDisconnectPacket) {
            logger.log(Level.INFO, "Disconnected: " + ((LoginDisconnectPacket) packet).getReason());
        }
//        else if (!(packet instanceof ServerEntityHeadLookPacket || packet instanceof ServerEntityEquipmentPacket
//                || packet instanceof ServerEntityPropertiesPacket || packet instanceof ServerSpawnMobPacket
//                || packet instanceof ServerEntityVelocityPacket || packet instanceof ServerEntityRotationPacket
//                || packet instanceof ServerEntityPositionRotationPacket || packet instanceof ServerEntityTeleportPacket
//                || packet instanceof ServerEntityPositionPacket || packet instanceof ServerMultiChunkDataPacket
//                || packet instanceof ServerDestroyEntitiesPacket || packet instanceof ServerBlockChangePacket
//                || packet instanceof ServerEntityMetadataPacket || packet instanceof ServerSpawnObjectPacket
//                || packet instanceof ServerUpdateTimePacket || packet instanceof ServerPlaySoundPacket
//                || packet instanceof ServerMultiBlockChangePacket || packet instanceof ServerKeepAlivePacket
//                || packet instanceof ServerUpdateTileEntityPacket)) {
//            logger.log(Level.INFO, "Received {0}", event.getPacket());
//        }
    }
 
开发者ID:daboross,项目名称:minecraft-commandline-interface,代码行数:29,代码来源:LoggingClientListener.java


示例10: packetReceived

import com.github.steveice10.packetlib.event.session.PacketReceivedEvent; //导入依赖的package包/类
@Override
public void packetReceived(PacketReceivedEvent event) {
    if(event.getPacket() instanceof ServerDisconnectPacket) {
        event.getSession().disconnect(event.<ServerDisconnectPacket>getPacket().getReason());
    }
}
 
开发者ID:Steveice10,项目名称:ClassicProtocolLib,代码行数:7,代码来源:ClientListener.java


示例11: packetReceived

import com.github.steveice10.packetlib.event.session.PacketReceivedEvent; //导入依赖的package包/类
@Override
public void packetReceived(PacketReceivedEvent event) {
    if(event.getPacket() instanceof ServerChatPacket) {
        this.parseChat(event.<ServerChatPacket>getPacket().getMessage());
    }
}
 
开发者ID:Steveice10,项目名称:LibBot,代码行数:7,代码来源:MinecraftClassicModule.java



注:本文中的com.github.steveice10.packetlib.event.session.PacketReceivedEvent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java WSDLParseException类代码示例发布时间:2022-05-22
下一篇:
Java GMLWriter类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap