Solved Getting my plugin .JAR file, even when renamed

Discussion in 'Spigot Plugin Development' started by kangarko, May 17, 2016.

  1. Hello Spigotters!

    I need a method to get the plugin jar File. Obviously following only works if the jar name is unattended, and can easily lead to errors if the user has renamed the file.

    Code (Text):
    new File("plugins/MyPlugin.jar")
    Is there any universal way to always point to the actual plugin jar?

    EDIT: Solved by @blablubbabc. Thanks kindly! (using JavaPlugin#getFile())

    Thanks beforehand!
    #1 kangarko, May 17, 2016
    Last edited: May 17, 2016
  2. You can just add a file to the jar and check for all plugins is the file is in.
    • Funny Funny x 1
  3. Interesting, but it seems a bit too robust and resource expensive.
    • Funny Funny x 1
  4. I'd just go about it by loading it's plugin.yml.
    If there's multiple with the same main, SHA-128/-256/-512
  5. When I say add file, just check the md5 or sha of the plugin.yml!
    • Like Like x 1
  6. I am trying to get my plugin's file, but to be name-independand. I was using this so far: new File("plugins/MyPlugin.jar")
    but in public plugins, one can easily rename the jar (e.g. MyPlugin to MySuperPlugin) and then it would fail.
    • Agree Agree x 2
  7. Thanks awfully! That was what I was looking for :)
  8. Ow, you don't said this. :c
  9. Yeah I am not fluent, sometimes it's hard to express myself in a way that most of you will understand, haha :) Sorry for that!
  10. Can't you just rename it without any problem? works for me..
    • Agree Agree x 1