Need help understanding some Bukkit stuff :P

Discussion in 'Bukkit Discussion' started by PhantomUnicorns, Feb 24, 2017.

Thread Status:
Not open for further replies.
  1. Offline

    PhantomUnicorns

    Ok so in general Bukkit/Spigot/Whatever modified Minecraft jar that accepts plugins runs through the plugins folder and looks for the extention .jar

    How does it read the .jar, and run the code? Do they recompile it to a program, run the program, do they just run a sub-program with the server has the main program? So what's up?
     
  2. Offline

    ipodtouch0218

  3. @PhantomUnicorns
    Bukkits process:
    Scan the plugin folder
    Once a jar is found
    See if it has a plugin.yml
    If not, error, if so continue
    Get the main class from that plugin using the plugin.yml
    Get other info like author, version etc and put it into a Plugin object
    Put that in a list
    Once all plugins are "loaded"
    Loop the list and call onEnable
     
    nlthijs48 likes this.
  4. Offline

    Tecno_Wizard

    @PhantomUnicorns, its a very complicated process involving Classloaders, the plugin.yml file, and a lot of reflection. The server jar searches for all jar files within the plugins folder, loads them using a Classloader (something you can google. I'm not going to attempt to explain it), finds the yml file, uses reflection to find the main class with the plugin yml, and uses reflection to call its onEnable and onDisable.
     
  5. Offline

    PhantomUnicorns

    I'm guessing the classloader can read .jar files and decrypt them to the files within? I've tried making something that would read .jar files and I found it to be impossible (With my current expertise) and right now I'm trying to do so again.
    Thank you @Tecno_Wizard and @bwfcwalshy and @ipodtouch0218

    EDIT: Yolo there is a class named JarFile and it pretty much does it for you :p, here I was trying to uncompress a jar file into a .txt XD
     
    Last edited: Feb 25, 2017
  6. Offline

    timtower Administrator Administrator Moderator

    @PhantomUnicorns Jar to zip is a simple rename, you can open it from there.
     
  7. Offline

    PhantomUnicorns

    I wanted to make a program that reads it and uses it, not open it :p
     
  8. Offline

    timtower Administrator Administrator Moderator

    @PhantomUnicorns In a way of a new server or just a standalone program that is able to read jars the way Bukkit does it?
     
  9. Offline

    Tecno_Wizard

  10. Offline

    PhantomUnicorns

Thread Status:
Not open for further replies.

Share This Page