Package com.cryptomorin.xseries
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.
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 Summary
-
Constructor Summary
Constructors Constructor Description ReflectionUtils()
-
Method Summary
Modifier and Type Method Description static Class<?>
getCraftClass(String name)
Get a CraftBukkit class.static Class<?>
getNMSClass(String name)
Get a NMS (net.minecraft.server) class.static CompletableFuture<Void>
sendPacket(org.bukkit.entity.Player player, Object packet)
Sends a packet to the player asynchronously.
-
Field Details
-
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 innet.minecraft.server.v1_14_R1
In order to maintain cross-version compatibility we cannot import these classes. -
CRAFTBUKKIT
-
NMS
-
-
Constructor Details
-
ReflectionUtils
public ReflectionUtils()
-
-
Method Details
-
getNMSClass
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
Get a CraftBukkit class.- Parameters:
name
- the name of the class.- Returns:
- a class.
- Since:
- 1.0.0
-