Skip to content
This repository was archived by the owner on Nov 8, 2021. It is now read-only.

How To Proxy

theminecoder edited this page Apr 10, 2018 · 6 revisions

Step 1 - Create proxy class

Creating NMS proxy classes is very simple, its just a matter of creating an interface with the right annotations and NMSPoxy will handle the rest. NMSProxy supports any class but is especially good at NMS & CraftBukkit/Spigot classes.

To start you will need an interface that extends NMSProxy and is annotated with @NMSClass. This is the marker to a valid proxy class and tells the api the class type we will be proxying. When proxying NMS (NMSClass.Type.NMS) and CraftBukkit/Spigot (NMSClass.Type.CRAFTBUKKIT) classes the api will automatically prefix the correct versioned package to the provided class name to save you time. If implimenting something outside these bounds, you can insert %version into the class name and it will be replaced with the nms version identifier used in many places in the bukkit ecosystem.

Next up is specifying methods and fields.

Example proxy class

CraftBukkit/Spigot

@NMSClass(type = NMSClass.Type.CRAFTBUKKIT, className = "entity.CraftPlayer")
public class NMSCraftPlayer implements NMSProxy {
    
    @NMSMethod
    NMSEntityPlayer getHandle();
    
}

NMS

@NMSClass(type = NMSClass.Type.NMS, className = "EntityPlayer")
public class NMSEntityPlayer implements NMSProxy {
    
    @NMSField(type = NMSField.Type.GETTER)
    NMSPlayerConnection playerConnection();
    
    @NMSMethod
    GameProfile getProfile();
    
}

Step 2 - Use it in your plugin

Clone this wiki locally