congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
PacketWrapper.user
Code IndexAdd Tabnine to your IDE (free)

How to use
user
method
in
us.myles.ViaVersion.api.PacketWrapper

Best Java code snippets using us.myles.ViaVersion.api.PacketWrapper.user (Showing top 14 results out of 315)

origin: MylesIsCool/ViaVersion

/**
 * Create a new packet for the target of this packet.
 *
 * @param packetID The ID of the new packet
 * @return The newly created packet wrapper
 */
public PacketWrapper create(int packetID) {
  return new PacketWrapper(packetID, null, user());
}
origin: MylesIsCool/ViaVersion

/**
 * Send the current packet to the server.
 * (Ensure the ID is suitable for viaversion)
 *
 * @throws Exception If it failed to write
 */
@Deprecated
public void sendToServer() throws Exception {
  if (!isCancelled()) {
    ByteBuf output = inputBuffer == null ? user().getChannel().alloc().buffer() : inputBuffer.alloc().buffer();
    writeToBuffer(output);
    user().sendRawPacketToServer(output, true);
  }
}
origin: MylesIsCool/ViaVersion

/**
 * Send this packet to the associated user.
 * Be careful not to send packets twice.
 * (Sends it after current)
 * <b>This method is no longer used, it's favoured to use {@link #send(Class)} as it will handle the pipeline properly.</b>
 *
 * @throws Exception if it fails to write
 */
@Deprecated
public void send() throws Exception {
  if (!isCancelled()) {
    // Send
    ByteBuf output = inputBuffer == null ? user().getChannel().alloc().buffer() : inputBuffer.alloc().buffer();
    writeToBuffer(output);
    user().sendRawPacket(output);
  }
}
origin: MylesIsCool/ViaVersion

/**
 * Send this packet to the associated user.
 * Be careful not to send packets twice.
 * (Sends it after current)
 * Also returns the packets ChannelFuture
 *
 * @param packetProtocol - The protocol version of the packet.
 * @return The packets ChannelFuture
 * @throws Exception if it fails to write
 */
public ChannelFuture sendFuture(Class<? extends Protocol> packetProtocol) throws Exception {
  if (!isCancelled()) {
    ByteBuf output = constructPacket(packetProtocol, true, Direction.OUTGOING);
    return user().sendRawPacketFuture(output);
  }
  return user().getChannel().newFailedFuture(new Exception("Cancelled packet"));
}
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: Gerrygames/ViaRewind

@Override
public void transform(Direction direction, State state, PacketWrapper packetWrapper) throws Exception {
  CompressionSendStorage compressionSendStorage = packetWrapper.user().get(CompressionSendStorage.class);
  if (compressionSendStorage.isCompressionSend()) {
    Channel channel = packetWrapper.user().getChannel();
    channel.pipeline().replace("decompress", "decompress", new EmptyChannelHandler());
    channel.pipeline().replace("compress", "compress", new ForwardMessageToByteEncoder());
    compressionSendStorage.setCompressionSend(false);
  }
  super.transform(direction, state, packetWrapper);
}
origin: MylesIsCool/ViaVersion

/**
 * Send this packet to the associated user.
 * Be careful not to send packets twice.
 * (Sends it after current)
 *
 * @param packetProtocol      - The protocol version of the packet.
 * @param skipCurrentPipeline - Skip the current pipeline
 * @param currentThread       - Run in the same thread
 * @throws Exception if it fails to write
 */
public void send(Class<? extends Protocol> packetProtocol, boolean skipCurrentPipeline, boolean currentThread) throws Exception {
  if (!isCancelled()) {
    ByteBuf output = constructPacket(packetProtocol, skipCurrentPipeline, Direction.OUTGOING);
    user().sendRawPacket(output, currentThread);
  }
}
origin: MylesIsCool/ViaVersion

/**
 * Send this packet to the server.
 *
 * @param packetProtocol - The protocol version of the packet.
 * @param skipCurrentPipeline - Skip the current pipeline
 * @param currentThread - Run in the same thread
 * @throws Exception if it fails to write
 */
public void sendToServer(Class<? extends Protocol> packetProtocol, boolean skipCurrentPipeline, boolean currentThread) throws Exception {
  if (!isCancelled()) {
    ByteBuf output = constructPacket(packetProtocol, skipCurrentPipeline, Direction.INCOMING);
    user().sendRawPacketToServer(output, currentThread);
  }
}
origin: MylesIsCool/ViaVersion

List<Protocol> protocols = new ArrayList<>(user().get(ProtocolInfo.class).getPipeline().pipes());
if (direction == Direction.OUTGOING) {
apply(direction, user().get(ProtocolInfo.class).getState(), index, protocols);
ByteBuf output = inputBuffer == null ? user().getChannel().alloc().buffer() : inputBuffer.alloc().buffer();
writeToBuffer(output);
origin: MylesIsCool/ViaVersion

  @Override
  public void handle(PacketWrapper wrapper) throws Exception {
    MovementTracker tracker = wrapper.user().get(MovementTracker.class);
    tracker.incrementIdlePacket();
    // If packet has the ground data
    if (wrapper.is(Type.BOOLEAN, 0)) {
      tracker.setGround(wrapper.get(Type.BOOLEAN, 0));
    }
  }
}
origin: MylesIsCool/ViaVersion

PacketWrapper chunkPacket = new PacketWrapper(0x21, null, wrapper.user());
chunkPacket.write(Type.INT, meta.getX());
chunkPacket.write(Type.INT, meta.getZ());
origin: Gerrygames/ViaRewind

public static void transformChunk(PacketWrapper packetWrapper) throws Exception {
  ClientWorld world = packetWrapper.user().get(ClientWorld.class);
  Chunk chunk = packetWrapper.read(new Chunk1_8Type(world));
  packetWrapper.write(new Chunk1_7_10WriteOnlyType(world), chunk);
  for (ChunkSection section : chunk.getSections()){
    if (section == null) continue;
    for (int x = 0; x < 16; x++) {
      for (int y = 0; y < 16; y++) {
        for (int z = 0; z < 16; z++) {
          int block = section.getBlock(x, y, z);
          BlockState state = BlockState.rawToState(block);
          state = ReplacementRegistry1_7_6_10to1_8.replace(state);
          section.setBlock(x, y, z, state.getId(), state.getData());
        }
      }
    }
  }
}
origin: MylesIsCool/ViaVersion

ViaPlatform platform = Via.getPlatform();
String actualUsername = packetWrapper.user().get(ProtocolInfo.class).getUsername();
String username = actualUsername != null ? actualUsername + " " : "";
origin: Gerrygames/ViaRewind

public static void transformChunk(PacketWrapper packetWrapper) throws Exception {
  ClientWorld world = packetWrapper.user().get(ClientWorld.class);
  final UserConnection user = packetWrapper.user();
  chunk.getBlockEntities().forEach(nbt -> {
    if (!nbt.contains("x") || !nbt.contains("y") || !nbt.contains("z") || !nbt.contains("id")) return;
us.myles.ViaVersion.apiPacketWrapperuser

Popular methods of PacketWrapper

    Popular in Java

    • Updating database using SQL prepared statement
    • getExternalFilesDir (Context)
    • requestLocationUpdates (LocationManager)
    • runOnUiThread (Activity)
    • Container (java.awt)
      A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
    • Thread (java.lang)
      A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
    • ServerSocket (java.net)
      This class represents a server-side socket that waits for incoming client connections. A ServerSocke
    • ExecutorService (java.util.concurrent)
      An Executor that provides methods to manage termination and methods that can produce a Future for tr
    • Collectors (java.util.stream)
    • JOptionPane (javax.swing)
    • Top plugins for Android Studio
    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