Package com.comphenix.protocol.events

Examples of com.comphenix.protocol.events.PacketAdapter$AdapterParameteters


  }
 
  public void addListener(ProtocolManager protocolManager, JavaPlugin plugin) {

    // Hide all enchantments
    protocolManager.addPacketListener(new PacketAdapter(plugin, ConnectionSide.SERVER_SIDE, 0x67, 0x68, 0x3E) {
      @Override
      public void onPacketSending(PacketEvent event) {
        PacketContainer packet = event.getPacket();
       
        try {
          // Item packets
          switch (event.getPacketID()) {
          case 0x67: // Set slot
            removeEnchantments(packet.getItemModifier().read(0));
            break;
           
          case 0x68: // Set Window Items
            ItemStack[] elements = packet.getItemArrayModifier().read(0);
 
            for (int i = 0; i < elements.length; i++) {
              if (elements[i] != null) {
                removeEnchantments(elements[i]);
              }
            }
            break;
           
          case 0x3E: // Sound effect
            event.setCancelled(true);
            break;
          }
       
        } catch (FieldAccessException e) {
          logger.log(Level.SEVERE, "Couldn't access field.", e);
        }
      }
    });
   
    // Censor
    protocolManager.addPacketListener(new PacketAdapter(plugin, ConnectionSide.CLIENT_SIDE, 0x3) {
      @Override
      public void onPacketReceiving(PacketEvent event) {
        if (event.getPacketID() == 0x3) {
          try {
            String message = event.getPacket().
View Full Code Here


  }
 
  private void register(Class<? extends PacketAdapter> clazz, Plugin plugin) {
    try {
      // Construct a new instance using reflection.
      PacketAdapter adapter = clazz.getDeclaredConstructor(Plugin.class).newInstance(plugin);
      ProtocolLibrary.getProtocolManager().addPacketListener(adapter);
      registeredPacketAdapters.add(adapter);
    } catch (Throwable t) {
      LogUtil.logWarning("[NoCheatPlus] Could not register packet level hook: " + clazz.getSimpleName());
      LogUtil.logWarning(t);
View Full Code Here

 
  private Future<String> testInterception(Plugin test) {
    PacketType customPacket = PacketType.fromCurrent(Protocol.STATUS, Sender.CLIENT, 3, -1);
   
    ProtocolLibrary.getProtocolManager().addPacketListener(
      new PacketAdapter(test, PacketType.Status.Server.OUT_SERVER_INFO) {
      @Override
      public void onPacketSending(PacketEvent event) {
        source = event.getPacket().getServerPings().read(0).toJson();
      }
    });
View Full Code Here

    @Override
    public void onEnable() {
        final Plugin grab = this.plugin.getServer().getPluginManager().getPlugin("ProtocolLib");
        if (grab != null) {
            ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(this.plugin, ConnectionSide.SERVER_SIDE, ListenerPriority.HIGHEST, GamePhase.LOGIN, Packets.Server.KICK_DISCONNECT) {
                @Override
                public void onPacketSending(PacketEvent event) {
                    try {
                        final StructureModifier<String> stringModifier = event.getPacket().getSpecificModifier(String.class);
                        final String replyString = stringModifier.read(0);
View Full Code Here

public class VariablePacketModifier {

    public VariablePacketModifier() {

        ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(CraftBookPlugin.inst(), PacketType.Play.Server.CHAT) {
            @Override
            public void onPacketSending(PacketEvent event) {
                WrappedChatComponent chat = event.getPacket().getChatComponents().read(0);
                chat.setJson(ParsingUtil.parseVariables(chat.getJson(), event.getPlayer()));
View Full Code Here

        Bukkit.getScheduler().runTaskTimer(CraftBookPlugin.inst(), new ChairChecker(), 20L, 20L);

        try {
            Class.forName("com.comphenix.protocol.events.PacketListener");
            ProtocolLibrary.getProtocolManager().getAsynchronousManager().registerAsyncHandler(new PacketAdapter(PacketAdapter.params(CraftBookPlugin.inst(), PacketType.Play.Client.STEER_VEHICLE).clientSide().listenerPriority(ListenerPriority.HIGHEST).options(ListenerOptions.INTERCEPT_INPUT_BUFFER)) {
                @Override
                public void onPacketReceiving(PacketEvent e) {
                    if (!e.isCancelled()) {
                        Player player = e.getPlayer();
                        if (e.getPacket().getBooleans().getValues().get(1))
                            if(hasChair(player))
                                removeChair(player);
                    }
                }
            }).syncStart();

            ProtocolLibrary.getProtocolManager().getAsynchronousManager().registerAsyncHandler(new PacketAdapter(PacketAdapter.params(CraftBookPlugin.inst(), PacketType.Play.Client.ENTITY_ACTION).clientSide().listenerPriority(ListenerPriority.HIGHEST).options(ListenerOptions.INTERCEPT_INPUT_BUFFER)) {
                @Override
                public void onPacketReceiving(PacketEvent e) {
                    if (!e.isCancelled()) {
                        Player player = e.getPlayer();
                        if(hasChair(player))
                            removeChair(player);
                    }
                }
            }).syncStart();

            ProtocolLibrary.getProtocolManager().getAsynchronousManager().registerAsyncHandler(new PacketAdapter(PacketAdapter.params(CraftBookPlugin.inst(), PacketType.Play.Client.POSITION, PacketType.Play.Client.POSITION_LOOK).clientSide().listenerPriority(ListenerPriority.HIGHEST).options(ListenerOptions.INTERCEPT_INPUT_BUFFER)) {
                @Override
                public void onPacketReceiving(PacketEvent e) {
                    if (!e.isCancelled()) {
                        for(double d : e.getPacket().getDoubles().getValues())
                            if(Double.isNaN(d)) {
View Full Code Here

        ProtocolLibrary.getProtocolManager().removePacketListeners(this.handler.getPlugin());
    }

    @Override
    public void startup() {
        ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(this.handler.getPlugin(), ConnectionSide.SERVER_SIDE, ListenerPriority.HIGH, Packets.Server.NAMED_ENTITY_SPAWN) {
            @Override
            public void onPacketSending(PacketEvent event) {
                if (event.getPacketID() != Packets.Server.NAMED_ENTITY_SPAWN) {
                    return;
                }
View Full Code Here

TOP

Related Classes of com.comphenix.protocol.events.PacketAdapter$AdapterParameteters

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.