Tabnine Logo
us.myles.ViaVersion.api.protocol
Code IndexAdd Tabnine to your IDE (free)

How to use us.myles.ViaVersion.api.protocol

Best Java code snippets using us.myles.ViaVersion.api.protocol (Showing top 20 results out of 315)

origin: MylesIsCool/ViaVersion

/**
 * Register an outgoing packet, with simple id transformation.
 *
 * @param state       The state which the packet is sent in.
 * @param oldPacketID The old packet ID
 * @param newPacketID The new packet ID
 */
public void registerOutgoing(State state, int oldPacketID, int newPacketID) {
  registerOutgoing(state, oldPacketID, newPacketID, null);
}
origin: MylesIsCool/ViaVersion

  @Override
  public int compare(ProtocolVersion o1, ProtocolVersion o2) {
    return ProtocolVersion.getIndex(o2) - ProtocolVersion.getIndex(o1);
  }
});
origin: MylesIsCool/ViaVersion

/**
 * Register an incoming packet, with simple id transformation.
 *
 * @param state       The state which the packet is sent in.
 * @param oldPacketID The old packet ID
 * @param newPacketID The new packet ID
 */
public void registerIncoming(State state, int oldPacketID, int newPacketID) {
  registerIncoming(state, oldPacketID, newPacketID, null);
}
origin: MylesIsCool/ViaVersion

public static void refreshVersions() {
  supportedVersions.clear();
  supportedVersions.add(ProtocolRegistry.SERVER_PROTOCOL);
  for (ProtocolVersion versions : ProtocolVersion.getProtocols()) {
    List<Pair<Integer, Protocol>> paths = getProtocolPath(versions.getId(), ProtocolRegistry.SERVER_PROTOCOL);
    if (paths == null) continue;
    supportedVersions.add(versions.getId());
    for (Pair<Integer, Protocol> path : paths)
      supportedVersions.add(path.getKey());
  }
}
origin: Gerrygames/ViaRewind

default void init(ViaRewindConfig config) {
  ViaRewind.init(this, config);
  ProtocolRegistry.registerProtocol(new Protocol1_8TO1_9(), Collections.singletonList(ProtocolVersion.v1_8.getId()), ProtocolVersion.v1_9.getId());
  ProtocolRegistry.registerProtocol(new Protocol1_7_6_10TO1_8(), Collections.singletonList(ProtocolVersion.v1_7_6.getId()), ProtocolVersion.v1_8.getId());
  ProtocolRegistry.registerProtocol(new Protocol1_7_0_5to1_7_6_10(), Collections.singletonList(ProtocolVersion.v1_7_1.getId()), ProtocolVersion.v1_7_6.getId());
}
origin: MylesIsCool/ViaVersion

  @Override
  public String toString() {
    return String.format("%s(%d)", this.getName(), this.getId());
  }
}
origin: MylesIsCool/ViaVersion

  private boolean isSupported() {
    int protocolId = ProtocolRegistry.SERVER_PROTOCOL;
    if (protocolId >= ProtocolVersion.v1_8.getId() && protocolId <= ProtocolVersion.v1_11_1.getId()) {
      return true; // 1.8-1.11.2
    }
    // this is not needed on 1.12+ servers
    return false;
  }
}
origin: MylesIsCool/ViaVersion

  /**
   * Cleans the pipe and adds {@link us.myles.ViaVersion.protocols.base.BaseProtocol}
   * /!\ WARNING - It doesn't add version-specific base Protocol
   */
  public void cleanPipes() {
    pipes().clear();
    registerPackets();
  }
}
origin: MylesIsCool/ViaVersion

/**
 * Add a protocol to the current pipeline
 * This will call the {@link Protocol#init(UserConnection)} method.
 *
 * @param protocol The protocol to add to the end
 */
public void add(Protocol protocol) {
  if (protocolList != null) {
    protocolList.add(protocol);
    protocol.init(userConnection);
    // Move base Protocols to the end, so the login packets can be modified by other protocols
    List<Protocol> toMove = new ArrayList<>();
    for (Protocol p : protocolList) {
      if (ProtocolRegistry.isBaseProtocol(p)) {
        toMove.add(p);
      }
    }
    protocolList.removeAll(toMove);
    protocolList.addAll(toMove);
  } else {
    throw new NullPointerException("Tried to add protocol to early");
  }
}
origin: MylesIsCool/ViaVersion

@Override
public void init(UserConnection userConnection) {
  this.userConnection = userConnection;
  ProtocolInfo protocolInfo = new ProtocolInfo(userConnection);
  protocolInfo.setPipeline(this);
  userConnection.put(protocolInfo);
  /* Init through all our pipes */
  for (Protocol protocol : protocolList) {
    protocol.init(userConnection);
  }
}
origin: MylesIsCool/ViaVersion

/**
 * Use the pipeline to filter a NMS packet
 *
 * @param o    The NMS packet object
 * @param list The output list to write to
 * @return If it should not write the input object to te list.
 * @throws Exception If it failed to convert / packet cancelld.
 */
public boolean filter(Object o, List list) throws Exception {
  for (Protocol protocol : protocolList) {
    if (protocol.isFiltered(o.getClass())) {
      protocol.filterPacket(userConnection, o, list);
      return true;
    }
  }
  return false;
}
origin: MylesIsCool/ViaVersion

/**
 * Called when the server is enabled, to register any non registered listeners.
 */
public static void onServerLoaded() {
  for (Protocol protocol : registerList) {
    protocol.registerListeners();
    protocol.register(Via.getManager().getProviders());
  }
  registerList.clear();
}
origin: MylesIsCool/ViaVersion

  @Override
  public void transform(Direction direction, State state, PacketWrapper packetWrapper) throws Exception {
    super.transform(direction, state, packetWrapper);
    if (direction == Direction.INCOMING && state == State.HANDSHAKE) {
      // Disable if it isn't a handshake packet.
      if (packetWrapper.getId() != 0) {
        packetWrapper.user().setActive(false);
      }
    }
  }
}
origin: MylesIsCool/ViaVersion

/**
 * Register an incoming packet, with id transformation and remapper.
 *
 * @param state          The state which the packet is sent in.
 * @param oldPacketID    The old packet ID
 * @param newPacketID    The new packet ID
 * @param packetRemapper The remapper to use for the packet
 */
public void registerIncoming(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper) {
  ProtocolPacket protocolPacket = new ProtocolPacket(state, oldPacketID, newPacketID, packetRemapper);
  incoming.put(new Pair<>(state, newPacketID), protocolPacket);
}
origin: MylesIsCool/ViaVersion

public ProtocolPipeline(UserConnection userConnection) {
  super();
  init(userConnection);
}
origin: MylesIsCool/ViaVersion

public Protocol() {
  registerPackets();
}
origin: MylesIsCool/ViaVersion

public static ProtocolVersion getProtocol(int id) {
  ProtocolVersion protocolVersion = versions.get(id);
  if (protocolVersion != null) {
    return protocolVersion;
  } else {
    return new ProtocolVersion(id, "Unknown (" + id + ")");
  }
}
origin: MylesIsCool/ViaVersion

public static void register(Protocol protocol) {
  //spawn particle
  protocol.registerOutgoing(State.PLAY, 0x24, 0x24, new PacketRemapper() {
    @Override
    public void registerMap() {
      map(Type.INT); // 0 - Particle ID
      map(Type.BOOLEAN); // 1 - Long Distance
      map(Type.FLOAT); // 2 - X
      map(Type.FLOAT); // 3 - Y
      map(Type.FLOAT); // 4 - Z
      map(Type.FLOAT); // 5 - Offset X
      map(Type.FLOAT); // 6 - Offset Y
      map(Type.FLOAT); // 7 - Offset Z
      map(Type.FLOAT); // 8 - Particle Data
      map(Type.INT); // 9 - Particle Count
      handler(new PacketHandler() {
        @Override
        public void handle(PacketWrapper wrapper) throws Exception {
          int id = wrapper.get(Type.INT, 0);
          if (id == 27) {
            wrapper.write(Type.FLAT_VAR_INT_ITEM, wrapper.read(Type.FLAT_ITEM));
          }
        }
      });
    }
  });
}
origin: MylesIsCool/ViaVersion

/**
 * Register an outgoing packet, with id transformation and remapper.
 *
 * @param state          The state which the packet is sent in.
 * @param oldPacketID    The old packet ID
 * @param newPacketID    The new packet ID
 * @param packetRemapper The remapper to use for the packet
 */
public void registerOutgoing(State state, int oldPacketID, int newPacketID, PacketRemapper packetRemapper) {
  ProtocolPacket protocolPacket = new ProtocolPacket(state, oldPacketID, newPacketID, packetRemapper);
  outgoing.put(new Pair<>(state, oldPacketID), protocolPacket);
}
origin: Gerrygames/ViaRewind

protocol.registerOutgoing(State.PLAY, 0x38, 0x3D);
protocol.registerOutgoing(State.PLAY, 0x3F, 0x3B);
protocol.registerOutgoing(State.PLAY, 0x41, 0x3E, new PacketRemapper() {
  @Override
  public void registerMap() {
protocol.registerOutgoing(State.PLAY, 0x42, 0x3C);
us.myles.ViaVersion.api.protocol

Most used classes

    Tabnine Logo
    • Products

      Search for Java codeSearch for JavaScript code
    • IDE Plugins

      IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
    • Company

      About UsContact UsCareers
    • Resources

      FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
    Get Tabnine for your IDE now