[API] ReflectionHelper 1.14.1-SNAPSHOT

Library to easily access Classes, Fields & Methods using reflection

  1. inventivetalent
    Tested Minecraft Versions:
    • 1.7
    • 1.8
    • 1.9
    • 1.10
    • 1.11
    • 1.12
    • 1.13
    Source Code:
    https://github.com/InventivetalentDev/ReflectionHelper
    This API allows you to access Classes, Fields & Methods using reflection.

    But unlike the default reflection methods, you can specify multiple names and the API will resolve those to the class/field/method which actually exists.
    This is especially useful if your plugin uses net.minecraft.server classes and you want to make it compatible to multiple versions. (e.g. 1.8 & 1.9)

    It also provides useful minecraft-related methods, for example a DataWatcher class to modify DataWatcher both for 1.9 & 1.8(/1.7)


    Usage
    Code (Java):

    //Let's say we want to access the NMS ChatSerializer class
    //in versions prior to 1_8_R2 it's located at net.minecraft.server.ChatSerializer, in later versions it was moved to net.minecraft.server.IChatBaseComponent$ChatSerializer
    //but instead of checking the version, you can just specify every possible class name

    // (The NMSClassResolver automatically appends the net.minecraft.server prefix)
    // (resolveSilent ignores any thrown exceptions)
    Class<?> chatSerializer = new NMSClassResolver().resolveSilent("ChatSerializer", "IChatBaseComponent$ChatSerializer");



    //The Title-Packet & the Title action-enum would also require a lot of code to support multiple versions
    //from some of the spigot protocol-hack versions, to the latest 1.8 version they were located in 6 different classes,
    //now we can just specify the possibilities without checking for any versions

    //We need to use the default resolver, since we might access non NMS classes
    ClassResolver resolver = new ClassResolver();
    Class<?> packetTitle = resolver.resolveSilent(
            "net.minecraft.server." + Minecraft.getVersion()/*Returns the NMS version*/ + "PacketPlayOutTitle"/* > 1.8 */,
            "org.spigotmc.ProtocolInjector$PacketTitle"/*protocol-hack*/);
    Class<?> packetAction = resolver.resolveSilent(
            "net.minecraft.server." + Minecraft.getVersion() + "PacketPlayOutTitle$EnumTitleAction"/* > 1.8 R3 */,
            "net.minecraft.server." + Minecraft.getVersion() + "EnumTitleAction"/* < 1.8 R3 */,
            "org.spigotmc.ProtocolInjector$PacketTitle$Action"/* protocol-hack*/);
     
    Check out the Javadocs for more details about


    Maven
    [​IMG]




    Code (spiget-meta (Unknown Language)):
    SlZOd2EkUm9kI1J3YW1GeUooVWtXa2QzZFdGPk4rSmFWelV3WVZoYWJHUiNSbk5hVnpVdytHMDVlVnAzUCswa0okUk1NMEp6WkZka2NHSnBPRDBrSiRSalIzZypXakpzZFZ7VyRtKmFiPmhzVytOJGNHIXlOVWxhVjNoM1dsaEpiV1J0Vm5sak1tKjJZbW93YkdSdFZubGpNbSoyWW1sVlAkUiNaPlFs

    Links
    [​IMG]

Recent Updates

  1. 1.13.1 support
  2. 1.13 support
  3. Fix

Recent Reviews

  1. Alter-Ego
    Alter-Ego
    2/5,
    Version: 1.14.0-SNAPSHOT
    I'm sure this is handy but it, needs a tutorial on how to apply the API please I'm new to applying API's, usually I only apply plugins like 'packetlisternerapi' etc. So confused as to how to apply this. If a tutorial is made will give 5 star rating
  2. FakeSaint
    FakeSaint
    5/5,
    Version: 1.14.0-SNAPSHOT
    This is incredibly well done... not only that its fully documented! Cleans up code quite a bit. Awesome job, screw that guy who gave 2 stars because he doesn't even understand this is a Library not a plugin lol :)
  3. d2231
    d2231
    2/5,
    Version: 1.13.0-SNAPSHOT
    I need help looking for the plugins this plugin requires. I don't know what plugins are needed. Can someone plz help me?
  4. aWolfWizard
    aWolfWizard
    5/5,
    Version: 1.11.0-SNAPSHOT
    Absolutely amazing resource, makes things so much clearer to read and understand and has made my life so much easier. Thank you ever so much. You have my eternal gratitude.
  5. Acquized
    Acquized
    5/5,
    Version: 1.6.0
    I don't really rate much on Spigot, but this Library definitely deserves 5 Stars. It is easy to use and makes the complete NMS Code more clear to see. Also the fact that we are allowed to compile it directly into our project makes it even better! Thanks for this great Resource.
  6. SAIFXGAMER
    SAIFXGAMER
    5/5,
    Version: 1.2.3
    Nice Pluigns ^_^
    and Your plugins is Good realy! -