当前位置: 首页>>代码示例>>Java>>正文


Java PacketAdapter类代码示例

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


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

示例1: listenPackets

import com.comphenix.protocol.events.PacketAdapter; //导入依赖的package包/类
public static void listenPackets() {
    ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(DynamicAC.instance, ListenerPriority.NORMAL, PacketType.Play.Client.POSITION, PacketType.Play.Client.POSITION_LOOK) {
        @Override
        public void onPacketReceiving(PacketEvent e) {
            Player p = e.getPlayer();
            Location cur = e.getPlayer().getLocation();
            if(!MOVE_COUNT.containsKey(p)) {
                MOVE_COUNT.put(p, 1);
            } else {
                MOVE_COUNT.put(p, MOVE_COUNT.get(p) + 1);
                if(MOVE_COUNT.get(p) > MagicNumbers.BLINK_PACKET)  {
                    for(Player player : DynamicAC.instance.onlinestaff) {
                        player.sendMessage(DynamicAC.prefix + p.getName() + " failed Blink test, sent too many " +
                                "packets in one place!");
                    }
                    MOVE_COUNT.remove(p);
                    e.setCancelled(true);
                    e.getPlayer().teleport(cur);
                }
            }
        }
    });
}
 
开发者ID:Notoh,项目名称:DynamicAC,代码行数:24,代码来源:MovementListener.java

示例2: constructProtocol

import com.comphenix.protocol.events.PacketAdapter; //导入依赖的package包/类
/**
 * Construct the packet listener that will be used to intercept every entity-related packet.
 *
 * @param plugin - the parent plugin.
 *
 * @return The packet listener.
 */
private PacketAdapter constructProtocol(Plugin plugin)
{
    return new PacketAdapter(plugin, ENTITY_PACKETS)
    {
        @Override
        public void onPacketSending(PacketEvent event)
        {
            int entityID = event.getPacket().getIntegers().read(0);

            // See if this packet should be cancelled
            if (!isVisible(event.getPlayer(), entityID))
            {
                event.setCancelled(true);
            }
        }
    };
}
 
开发者ID:WoutDev,项目名称:Mega-Walls,代码行数:25,代码来源:EntityHider.java

示例3: onEnable

import com.comphenix.protocol.events.PacketAdapter; //导入依赖的package包/类
/**
 * @see org.bukkit.plugin.java.JavaPlugin#onEnable()
 */
@Override
public void onEnable() {
    saveDefaultConfig();
    CONFIG = new Configuration(this);
    CONFIG.reload();

    _protocolManager = ProtocolLibrary.getProtocolManager();
    _protocolManager.addPacketListener(new PacketAdapter(this, ListenerPriority.NORMAL, PacketType.Play.Server.UPDATE_TIME) {
        @Override
        public void onPacketSending(PacketEvent event) {
            if (event.getPacketType() == PacketType.Play.Server.UPDATE_TIME &&
                _ignoringTime.contains(event.getPlayer()) &&
                event.getPacket().getLongs().read(1) >= 0) {
                event.setCancelled(true);
            }
        }
    });
}
 
开发者ID:NerdNu,项目名称:NerdMoods,代码行数:22,代码来源:NerdMoods.java

示例4: register

import com.comphenix.protocol.events.PacketAdapter; //导入依赖的package包/类
public void register() {
    ProtocolLibrary.getProtocolManager().addPacketListener(
            new PacketAdapter(this, WrapperPlayClientUseEntity.TYPE) {
                @Override
                public void onPacketReceiving(PacketEvent event) {
                    if (event.getPacketType() == WrapperPlayClientUseEntity.TYPE) {
                        WrapperPlayClientUseEntity packet = new WrapperPlayClientUseEntity(event.getPacket());
                        int entID = packet.getTarget();
                        if (running.containsKey(event.getPlayer().getUniqueId()) && packet.getType() == EntityUseAction.ATTACK) {
                            running.get(event.getPlayer().getUniqueId()).markAsKilled(entID);
                        }
                    }
                }

            });
    this.isRegistered = true;
}
 
开发者ID:TechzoneMC,项目名称:SimpleAntiAura,代码行数:18,代码来源:AntiAura.java

示例5: init

import com.comphenix.protocol.events.PacketAdapter; //导入依赖的package包/类
@Override
public void init(Plugin plugin) {
	ProtocolLibrary.getProtocolManager().addPacketListener(
			new PacketAdapter(PacketAdapter
					.params(plugin, PacketType.Play.Server.SET_SLOT,
							PacketType.Play.Server.WINDOW_ITEMS)
							.serverSide().listenerPriority(ListenerPriority.HIGH)) {

				@Override
				public void onPacketSending(PacketEvent event) {
					if (event.getPacketType().equals(PacketType.Play.Server.SET_SLOT)) {
						addGlow(new ItemStack[] { event.getPacket().getItemModifier().read(0) });
					} else {
						addGlow(event.getPacket().getItemArrayModifier().read(0));
					}
				}
			});
	
	_signManager = new ProtocolLibSignGUI(plugin);
	
	Bukkit.getServicesManager().register(SignGUI.class, _signManager, plugin, ServicePriority.Highest);
}
 
开发者ID:glen3b,项目名称:BukkitLib,代码行数:23,代码来源:ProtocolLibUtilImplementation.java

示例6: enable

import com.comphenix.protocol.events.PacketAdapter; //导入依赖的package包/类
public void enable() {
	ProtocolLibrary.getProtocolManager().addPacketListener(
			new PacketAdapter(plugin, ConnectionSide.SERVER_SIDE, ListenerPriority.NORMAL, new Integer[] {
					Integer.valueOf(130) 
			})
			{
				public void onPacketSending(PacketEvent event) {
					if (event.getPacketID() == 130)
						try {
							event.setPacket(modify(event.getPacket(), event.getPlayer().getName()));
						} catch (FieldAccessException e) {
							plugin.getLogger().log(Level.SEVERE, "Couldn't access field.", e);
						}
				}
			});
	log("Enabled");
}
 
开发者ID:Esaych,项目名称:DDCustomPlugin,代码行数:18,代码来源:JailSigns.java

示例7: constructProtocol

import com.comphenix.protocol.events.PacketAdapter; //导入依赖的package包/类
/**
 * Construct the packet listener that will be used to intercept every
 * entity-related packet.
 * 
 * @param plugin
 *            - the parent plugin.
 * @return The packet listener.
 */
private PacketAdapter constructProtocol(Plugin plugin) {
    return new PacketAdapter(plugin, ENTITY_PACKETS) {

        @Override
        public void onPacketSending(PacketEvent event) {
            int index = event.getPacketType() == COMBAT_EVENT ? 1 : 0;

            Integer entityID = event.getPacket().getIntegers().readSafely(index);
            if (entityID != null) {
                if (!isVisible(event.getPlayer(), entityID)) {
                    event.setCancelled(true);
                }
            }
        }
    };
}
 
开发者ID:Co0sh,项目名称:BetonQuest,代码行数:25,代码来源:EntityHider.java

示例8: register

import com.comphenix.protocol.events.PacketAdapter; //导入依赖的package包/类
public void register() {
    ProtocolLibrary.getProtocolManager().addPacketListener(
            new PacketAdapter(this, WrapperPlayClientUseEntity.TYPE) {
                @Override
                public void onPacketReceiving(PacketEvent event) {
                    if (event.getPacketType() == WrapperPlayClientUseEntity.TYPE) {
                        WrapperPlayClientUseEntity packet = new WrapperPlayClientUseEntity(event.getPacket());
                        int entID = packet.getTargetID();
                        if (running.containsKey(event.getPlayer().getUniqueId()) && packet.getType() == EntityUseAction.ATTACK) {
                            running.get(event.getPlayer().getUniqueId()).markAsKilled(entID);
                        }
                    }
                }

            });
    this.isRegistered = true;
}
 
开发者ID:maciekmm,项目名称:AntiAura,代码行数:18,代码来源:AntiAura.java

示例9: setupPacketModification

import com.comphenix.protocol.events.PacketAdapter; //导入依赖的package包/类
/**
 * Set up packet listening for ENTITY_METADATA packets so they can be modified to actually contain
 * the dead horses' equipped armor.
 */
private void setupPacketModification() {
  if (getServer().getPluginManager().getPlugin(PROTOCOL_LIB) instanceof ProtocolLibrary) {
    fancyLog("ProtocolLib detected, creating hook for entity metadata packets.");
    ProtocolManager manager = ProtocolLibrary.getProtocolManager();
    manager.addPacketListener(new PacketAdapter(new PacketAdapter.AdapterParameteters()
        .plugin(this).serverSide().types(PacketType.Play.Server.ENTITY_METADATA)) {
      @Override
      public void onPacketSending(PacketEvent event) {
        if (config.isPacketModificationEnabled()) {
          handleMetadataPacket(event);
        }
      }
    });
    hookedProtocolLib = true;
    fancyLog("Entity metadata packet hooked.");
  }
}
 
开发者ID:EasyMFnE,项目名称:DeadHorses,代码行数:22,代码来源:DeadHorses.java

示例10: registerPacketListeners

import com.comphenix.protocol.events.PacketAdapter; //导入依赖的package包/类
public void registerPacketListeners() {
	final ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
	for (PacketType packetType : new PacketType[] { PacketType.Play.Client.POSITION }) {
		protocolManager
				.addPacketListener(new PacketAdapter(Crescent.getInstance(), ListenerPriority.NORMAL, packetType) {
					@Override
					public void onPacketReceiving(PacketEvent event) {
						if (event.getPacketType() == packetType) {
							Bukkit.getPluginManager()
									.callEvent(new PlayerPacketEvent(event.getPlayer(), event.getPacket()));
						}
					}
				});
	}
}
 
开发者ID:davidm98,项目名称:Crescent,代码行数:16,代码来源:BehaviourListeners.java

示例11: RecipeDupePatch

import com.comphenix.protocol.events.PacketAdapter; //导入依赖的package包/类
public RecipeDupePatch() {
    keepers = Sets.newHashSet();
    
    ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(EscapeLag.MainThis, Play.Client.AUTO_RECIPE) {
        @Override
        public void onPacketReceiving(PacketEvent evt) {
            if (!ConfigPatch.autoRecipePatch) return;
            keepers.add(evt.getPlayer());
        }
    });
}
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:12,代码来源:RecipeDupePatch.java

示例12: SignLoginWindow

import com.comphenix.protocol.events.PacketAdapter; //导入依赖的package包/类
public SignLoginWindow(ProtocolManager protocolManager, Plugin plugin) {
	super(protocolManager, plugin);
	protocolManager.addPacketListener(
			new PacketAdapter(plugin, ListenerPriority.NORMAL, PacketType.Play.Client.UPDATE_SIGN) {
				@Override
				public void onPacketReceiving(PacketEvent event) {
					if (event.getPacketType() != PacketType.Play.Client.UPDATE_SIGN) {
						return;
					}
					if (AuthMeApi.getInstance().isAuthenticated(event.getPlayer())) {
						return;
					}
					PacketContainer packet = event.getPacket();
					String[] strings = packet.getStringArrays().read(0);
					if (strings[Variables.signLoginLine - 1].isEmpty()) {
						return;
					}
					boolean registered = AuthMeApi.getInstance().isRegistered(event.getPlayer().getName());
					String password = strings[Variables.signLoginLine - 1].substring(SignLoginWindow.this
							.getInfoFor(event.getPlayer(), Variables.signInfo.get(Variables.signLoginLine - 1))
							.length());
					if (!registered & !password.isEmpty()) {
						AuthMeApi.getInstance().registerPlayer(event.getPlayer().getName(), password);
					}
					Bukkit.getPluginCommand("login").execute(event.getPlayer(), "login", new String[] { password });
				}
			});
}
 
开发者ID:lj2000lj,项目名称:AuthMeGUI,代码行数:29,代码来源:SignLoginWindow.java

示例13: register

import com.comphenix.protocol.events.PacketAdapter; //导入依赖的package包/类
public static void register() {
	ProtocolUtils.get().addPacketListener(
		new PacketAdapter(NeverLag.getInstance(), PacketType.Play.Client.SET_CREATIVE_SLOT) {
			@Override
			public void onPacketReceiving(PacketEvent e) {
				onSetCreativeSlotPacket(e);
			}
		});
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:10,代码来源:AntiAUWMod.java

示例14: hook

import com.comphenix.protocol.events.PacketAdapter; //导入依赖的package包/类
/**
 * Hooks ProtocolLibrary into a {@link JavaPlugin}.
 *
 * @param kairos
 *            the plugin to hook into
 */
public static void hook(HCF kairos) {
    ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
    protocolManager.addPacketListener(new PacketAdapter(kairos, ListenerPriority.NORMAL, PacketType.Play.Client.BLOCK_DIG) {
        @Override
        public void onPacketReceiving(PacketEvent event) {
            PacketContainer packet = event.getPacket();
            StructureModifier<Integer> modifier = packet.getIntegers();
            Player player = event.getPlayer();

            try {
                int status = modifier.read(4);
                // int face = modifier.read(3);
                if (status == STARTED_DIGGING || status == FINISHED_DIGGING) {
                    int x, y, z;
                    Location location = new Location(player.getWorld(), x = modifier.read(0), y = modifier.read(1), z = modifier.read(2));

                    // Validation
                    VisualBlock visualBlock = kairos.getVisualiseHandler().getVisualBlockAt(player, location);
                    if (visualBlock == null)
                        return;

                    event.setCancelled(true);
                    VisualBlockData data = visualBlock.getBlockData();
                    if (status == FINISHED_DIGGING) {
                        player.sendBlockChange(location, data.getBlockType(), data.getData());
                    } else if (status == STARTED_DIGGING) { // we check this because Blocks that broke pretty much straight away do not send a FINISHED for some weird reason.
                        EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
                        if (player.getGameMode() == GameMode.CREATIVE
                                || net.minecraft.server.v1_7_R4.Block.getById(data.getItemTypeId()).getDamage(entityPlayer, entityPlayer.world, x, y, z) > 1.0F) {

                            player.sendBlockChange(location, data.getBlockType(), data.getData());
                        }
                    }
                }
            } catch (FieldAccessException ignored) {
            }
        }
    });
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:46,代码来源:ProtocolLibHook.java

示例15: constructProtocol

import com.comphenix.protocol.events.PacketAdapter; //导入依赖的package包/类
/**
 * Construct the packet listener that will be used to intercept every entity-related packet.
 * @param plugin - the parent plugin.
 * @return The packet listener.
 */
private PacketAdapter constructProtocol(Plugin plugin) {
	return new PacketAdapter(plugin, ENTITY_PACKETS) {
		@Override
		public void onPacketSending(PacketEvent event) {
			int entityID = event.getPacket().getIntegers().read(0);

			// See if this packet should be cancelled
			if (!isVisible(event.getPlayer(), entityID)) {
				event.setCancelled(true);
			}
		}
	};
}
 
开发者ID:ijoeleoli,项目名称:ZorahPractice,代码行数:19,代码来源:EntityHider.java


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