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

Java SentPacket类代码示例

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

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



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

示例1: handleClientSound

import org.inventivetalent.packetlistener.handler.SentPacket; //导入依赖的package包/类
private void handleClientSound(SentPacket packet)
{
	Player player = packet.getPlayer();
	
	if(player != null)
	{
		if(!isVanished(player))
		{
			return;
		}
	}else return;
	
	if(versionProtocol.shouldIgnorePacket(packet.getPacketValue(0)))
	{
		return;
	}
	
	packet.setCancelled(true);
}
 
开发者ID:Shortninja66,项目名称:StaffPlus,代码行数:20,代码来源:PacketModifier.java


示例2: handleClientAnimation

import org.inventivetalent.packetlistener.handler.SentPacket; //导入依赖的package包/类
private void handleClientAnimation(SentPacket packet)
{
	Player player = packet.getPlayer();
	
	if(player == null)
	{
		return;
	}
	
	if(userManager.get(packet.getPlayer().getUniqueId()).getVanishType() != VanishType.TOTAL)
	{
		return;
	}
	
	packet.setCancelled(true);
}
 
开发者ID:Shortninja66,项目名称:StaffPlus,代码行数:17,代码来源:PacketModifier.java


示例3: init

import org.inventivetalent.packetlistener.handler.SentPacket; //导入依赖的package包/类
@Override
public void init(final Plugin plugin) {
	PacketHandler.addHandler(new PacketHandler(plugin) {
		@PacketOptions(forcePlayer = true)
		@Override
		public void onSend(final SentPacket sentPacket) {
			if (sentPacket.hasPlayer()) {
				if ("PacketPlayOutNamedEntitySpawn".equals(sentPacket.getPacketName())) {
					final Player player = sentPacket.getPlayer();
					final UUID uuid = Minecraft.VERSION.newerThan(Minecraft.Version.v1_8_R1) ?
							((UUID) sentPacket.getPacketValue("b")) :
							(((GameProfile) sentPacket.getPacketValue("b")).getId());
					Player npcPlayer = null;
					//TODO: check if this doesn't cause any ConcurrentModExceptions / make this synchronous somehow
					for (Player worldPlayer : player.getWorld().getPlayers()) {// We can't use Bukkit#getOnlinePlayers, since the server doesn't know about the player NPCs
						if (worldPlayer.getUniqueId().equals(uuid)) {
							npcPlayer = worldPlayer;
							break;
						}
					}
					if (npcPlayer != null) {
						NPCAbstract<?, ?> npcAbstract = NPCLib.getNPC(npcPlayer);
						if (npcAbstract != null && npcAbstract instanceof NPCPlayer) {
							((NPCPlayer) npcAbstract).updateToPlayer(player);
						}
					}
				}
			}
		}

		@PacketOptions(forcePlayer = true)
		@Override
		public void onReceive(ReceivedPacket receivedPacket) {
			if (receivedPacket.hasPlayer()) {
				if ("PacketPlayInUseEntity".equals(receivedPacket.getPacketName())) {
					int a = (int) receivedPacket.getPacketValue(0);
					Entity entity = Reflection.getEntityById(receivedPacket.getPlayer().getWorld(), a);
					if (entity == null || !NPCLib.isNPC(entity)) {
						return;
					}
					Enum<?> action = (Enum<?>) receivedPacket.getPacketValue(1);

					NPCInteractEvent event = new NPCInteractEvent(NPCLib.getNPC(entity), a, action == null ? -1 : action.ordinal(), receivedPacket.getPlayer());
					Bukkit.getPluginManager().callEvent(event);
					if (event.isCancelled()) {
						receivedPacket.setCancelled(true);
					}
				}
			}
		}
	});

	String version = getVersion();
	logger.info("Version is " + version);
}
 
开发者ID:InventivetalentDev,项目名称:CompactNPCLib,代码行数:56,代码来源:NPCLib.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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