Package com.comphenix.protocol

Examples of com.comphenix.protocol.PacketType$Play$Server


{

  public static Server s1;
  public void callserver()
  {
    s1=new Server();
  }
View Full Code Here


     
      try {
        byte[] buffer = bufferStream != null ? bufferStream.toByteArray() : null;
       
        // Let the people know
        PacketType type = PacketType.findLegacy(packetID, Sender.CLIENT);
        PacketContainer container = new PacketContainer(type, thisObj);
        PacketEvent event = packetInjector.packetRecieved(container, input, buffer);
       
        // Handle override
        if (event != null) {
View Full Code Here

      // Make sure we're listening
      if (id != null && hasListener(id)) {
        NetworkMarker marker = queuedMarkers.remove(packet);
       
        // A packet has been sent guys!
        PacketType type = PacketType.findLegacy(id, Sender.SERVER);
        PacketContainer container = new PacketContainer(type, packet);
        PacketEvent event = PacketEvent.fromServer(invoker, container, marker, currentPlayer);
        invoker.invokePacketSending(event);
       
        // Cancelling is pretty simple. Just ignore the packet.
View Full Code Here

   */
  @SuppressWarnings("deprecation")
  Object createNegativePacket(Object source) {
    ListenerInvoker invoker = injector.getInvoker();
   
    PacketType type = invoker.getPacketType(source);

    // We want to subtract the byte amount that were added to the running
    // total of outstanding packets. Otherwise, cancelling too many packets
    // might cause a "disconnect.overflow" error.
    //
    // We do that by constructing a special packet of the same type that returns
    // a negative integer for all zero-parameter integer methods. This includes the
    // size() method, which is used by the queue method to count the number of
    // bytes to add.
    //
    // Essentially, we have:
    //
    //   public class NegativePacket extends [a packet] {
    //      @Override
    //      public int size() {
    //         return -super.size();
    //      }
    //   ect.
    //   }
    Enhancer ex = EnhancerFactory.getInstance().createEnhancer();
    ex.setSuperclass(MinecraftReflection.getPacketClass());
    ex.setInterfaces(new Class[] { FakePacket.class } );
    ex.setUseCache(true);
    ex.setCallbackType(InvertedIntegerCallback.class);

    Class<?> proxyClass = ex.createClass();
    Enhancer.registerCallbacks(proxyClass, new Callback[] { callback });
   
    try {
      // Temporarily associate the fake packet class
      invoker.registerPacketClass(proxyClass, type.getLegacyId());
      Object proxy = proxyClass.newInstance();
     
      InjectedArrayList.registerDelegate(proxy, source);
      return proxy;
     
View Full Code Here

    if (packet == null)
      throw new IllegalArgumentException("Packet cannot be NULL.");
    if (!MinecraftReflection.isPacketClass(packet))
      throw new IllegalArgumentException("The given object " + packet + " is not a packet.");
   
    PacketType type = PacketRegistry.getPacketType(packet.getClass());
   
    if (type != null) {
      return type;
    } else {
      throw new IllegalArgumentException(
View Full Code Here

      if (ignoredPackets.remove(packet)) {
        return packet;
      }
     
      Player sender = getInjector(networkManager, connection).getUpdatedPlayer();
      PacketType type = PacketType.findLegacy(id, Sender.CLIENT);
      PacketContainer container = new PacketContainer(type, packet);
      PacketEvent event = packetReceived(container, sender, readBufferedPackets.get(packet));
     
      if (!event.isCancelled())
        return event.getPacket().getHandle();
View Full Code Here

      if (ignoredPackets.remove(packet)) {
        return packet;
      }
     
      Player reciever = getInjector(networkManager, connection).getUpdatedPlayer();
      PacketType type = PacketType.findLegacy(id, Sender.SERVER);
      PacketContainer container = new PacketContainer(type, packet);
      PacketEvent event = packetQueued(container, reciever);

      if (!event.isCancelled())
        return event.getPacket().getHandle();
View Full Code Here

   * Construct a new packet container from a given handle.
   * @param packet - the NMS packet.
   * @return The packet container.
   */
  public static PacketContainer fromPacket(Object packet) {
    PacketType type = PacketType.fromClass(packet.getClass());
    return new PacketContainer(type, packet);
  }
View Full Code Here

      throw new IllegalStateException("The packet event is read-only.");
    if (packet == null)
      throw new IllegalArgumentException("Cannot set packet to NULL. Use setCancelled() instead.");
   
    // Change warnings
    final PacketType oldType = this.packet.getType();
    final PacketType newType = packet.getType();
    if (this.packet != null && !Objects.equal(oldType, newType)) {
      // Only report this once
      if (CHANGE_WARNINGS.put(oldType, newType)) {
        ProtocolLibrary.getErrorReporter().reportWarning(this,
            Report.newBuilder(REPORT_CHANGING_PACKET_TYPE_IS_CONFUSING).
View Full Code Here

    this.register = result;
  }
 
  private void associatePackets(Register register, Map<Integer, Class<?>> lookup, Protocol protocol, Sender sender) {
    for (Entry<Integer, Class<?>> entry : lookup.entrySet()) {
      PacketType type = PacketType.fromCurrent(protocol, sender, entry.getKey(), PacketType.UNKNOWN_PACKET);
      register.typeToClass.put(type, entry.getValue());
     
      if (sender == Sender.SERVER)
        register.serverPackets.add(type);
      if (sender == Sender.CLIENT)
View Full Code Here

TOP

Related Classes of com.comphenix.protocol.PacketType$Play$Server

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.