本文整理汇总了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;未经允许,请勿转载。 |
请发表评论