Class ReflectionUtils

java.lang.Object
com.cryptomorin.xseries.ReflectionUtils

public class ReflectionUtils
extends Object
ReflectionUtils - Reflection handler for NMS and CraftBukkit.
Caches the packet related methods and is asynchronous.

This class does not handle null checks as most of the requests are from the other utility classes that already handle null checks.

Clientbound Packets are considered fake updates to the client without changing the actual data. Since all the data is handled by the server.

Version:
1.0.2
Author:
Crypto Morin
  • Field Details

    • VERSION

      public static final String VERSION
      We use reflection mainly to avoid writing a new class for version barrier. The version barrier is for NMS that uses the Minecraft version as the main package name.

      E.g. EntityPlayer in 1.15 is in the class net.minecraft.server.v1_15_R1 but in 1.14 it's in net.minecraft.server.v1_14_R1 In order to maintain cross-version compatibility we cannot import these classes.

    • CRAFTBUKKIT

      public static final String CRAFTBUKKIT
    • NMS

      public static final String NMS
  • Constructor Details

  • Method Details

    • getNMSClass

      @Nullable public static Class<?> getNMSClass​(@Nullable String name)
      Get a NMS (net.minecraft.server) class.
      Parameters:
      name - the name of the class.
      Returns:
      the class.
      Since:
      1.0.0
    • sendPacket

      @Nonnull public static CompletableFuture<Void> sendPacket​(@Nonnull org.bukkit.entity.Player player, @Nonnull Object packet)
      Sends a packet to the player asynchronously. Packets are thread-safe.
      Parameters:
      player - the player to send the packet to.
      packet - the packet to send.
      Returns:
      the async thread handling the packet.
      Since:
      1.0.0
    • getCraftClass

      @Nullable public static Class<?> getCraftClass​(@Nullable String name)
      Get a CraftBukkit class.
      Parameters:
      name - the name of the class.
      Returns:
      a class.
      Since:
      1.0.0