Inject a method to the Main class file of your plugin.

Discussion in 'Programming' started by ItzSomebody, May 11, 2017.

  1. Title says it all, how do you do it?
  2. By pressing keys on your keyboard?
  3. More specific this time:

    How do you add a method to your compiled class file.
  4. I sense the XY problem. What is the end goal?
  5. I am attempting to setup my own anti-piracy so I don't have to add code to a plugin. Instead, I just run my program that has my anti-piracy code that adds a method and runs it through onEnable().
  6. You learn the absolute beginner basics of java, then keep learning until you feel like a fool for asking this question..
    Which, i am almost sure is a troll post anyway.. :rolleyes:

    Edit: Compiled class file? If you mean while java is running, just forget it. Otherwise, decompile it and edit it, or use ASM in your program to add code to it before it is loaded.

    ASM is a library that can modify java bytecode, but it cannot modify a loaded class. You would have to loa ASM before the class in question, read the bytecode from the file, modify it, and load it normally with a classloader.
  7. So you're trying to add anti piracy after it's compiled and not reveal in your source code what your anti piracy methods are? A quick run through a decompiler will reveal how you're doing it so it's a waste of time to try to patch it in to the compiled class file.

    Just write it in and deal with it getting bypassed because that's what will happen anyways.

    Sent from my iPhone using Tapatalk
    • Agree Agree x 1
  8. I noticed Spigot's Antipiracy doesn't show up under a decompile. How do they do that?

    EDIT: But of course the it shows up under ByteCode