本文整理汇总了Java中org.inventivetalent.packetlistener.handler.PacketHandler类的典型用法代码示例。如果您正苦于以下问题:Java PacketHandler类的具体用法?Java PacketHandler怎么用?Java PacketHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PacketHandler类属于org.inventivetalent.packetlistener.handler包,在下文中一共展示了PacketHandler类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: disable
import org.inventivetalent.packetlistener.handler.PacketHandler; //导入依赖的package包/类
public void disable() {
PacketHandler.removeHandler(packetHandler);
}
开发者ID:InventivetalentDev,项目名称:Murder,代码行数:4,代码来源:PacketListener.java
示例2: init
import org.inventivetalent.packetlistener.handler.PacketHandler; //导入依赖的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
示例3: disable
import org.inventivetalent.packetlistener.handler.PacketHandler; //导入依赖的package包/类
protected void disable() {
PacketHandler.removeHandler(this.packetHandler);
}
开发者ID:InventivetalentDev,项目名称:MapManager,代码行数:4,代码来源:PacketListener.java
注:本文中的org.inventivetalent.packetlistener.handler.PacketHandler类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论