Plugin Help Can't export decompiled plugins

Discussion in 'Plugin Help/Development/Requests' started by Filipzetomic, Aug 3, 2015.

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

    Filipzetomic

    I am trying to edit a Survival Games plugin so that I can change the system output of
    "SG - STOPPED LOBBY CHUNK FROM UNLOADING!" which is really annoying because it displays that every 30 seconds. I found the java file and removed the line. But when I export it to SurvivalGamesFix.jar it says:
    Code:
    JAR creation failed. See details for additional information.
      SurvivalGames/META-INF/MANIFEST.MF was replaced by the generated MANIFEST.MF and is no longer in the JAR.
      com/skitscape/survivalgames [in SurvivalGames] is not on its project's build path
      Unable to get package fragment root: SurvivalGames/com/skitscape/survivalgames/CommandHandler.java
        com/skitscape/survivalgames [in SurvivalGames] is not on its project's build path
      com/skitscape/survivalgames/Events [in SurvivalGames] is not on its project's build path
      Unable to get package fragment root: SurvivalGames/com/skitscape/survivalgames/Events/KeepLobbyLoadedEvent.java
        com/skitscape/survivalgames/Events [in SurvivalGames] is not on its project's build path
      com/skitscape/survivalgames [in SurvivalGames] is not on its project's build path
      Unable to get package fragment root: SurvivalGames/com/skitscape/survivalgames/Game.java
        com/skitscape/survivalgames [in SurvivalGames] is not on its project's build path
      com/skitscape/survivalgames [in SurvivalGames] is not on its project's build path
      Unable to get package fragment root: SurvivalGames/com/skitscape/survivalgames/GameManager.java
        com/skitscape/survivalgames [in SurvivalGames] is not on its project's build path
      com/skitscape/survivalgames [in SurvivalGames] is not on its project's build path
      Unable to get package fragment root: SurvivalGames/com/skitscape/survivalgames/LobbyManager.java
        com/skitscape/survivalgames [in SurvivalGames] is not on its project's build path
      com/skitscape/survivalgames [in SurvivalGames] is not on its project's build path
      Unable to get package fragment root: SurvivalGames/com/skitscape/survivalgames/SettingsManager.java
        com/skitscape/survivalgames [in SurvivalGames] is not on its project's build path
      com/skitscape/survivalgames [in SurvivalGames] is not on its project's build path
      Unable to get package fragment root: SurvivalGames/com/skitscape/survivalgames/SurvivalGames.java
        com/skitscape/survivalgames [in SurvivalGames] is not on its project's build path
    
     
  2. Offline

    pie_flavor

    @Filipzetomic Have you worked with Bukkit plugins before? If not, you have to compile the whole jar in one go, and it's kinda difficult to do it without an ide.
     
  3. Offline

    Filipzetomic

    I am using eclipse and just now I added in WorldEdit and my craftbukkit_server jars to the libraries of Java Build Path and also added existing manifest. I get less errors. Then I closed the java file I edited and mysteriously all errors disappear. I run the server and get this error

    Code:
    [15:16:55 ERROR]: Could not load 'plugins\SurvivalGamesFix.jar' in folder 'plugi
    ns'
    org.bukkit.plugin.InvalidPluginException: Cannot find main class `com.skitscape.
    survivalgames.SurvivalGames'
            at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.jav
    a:42) ~[craftbukkit_server.jar:git-Bukkit-a3cb1bc]
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
    ava:129) ~[craftbukkit_server.jar:git-Bukkit-a3cb1bc]
            at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.
    java:328) ~[craftbukkit_server.jar:git-Bukkit-a3cb1bc]
            at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager
    .java:251) [craftbukkit_server.jar:git-Bukkit-a3cb1bc]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugins(CraftServer.ja
    va:288) [craftbukkit_server.jar:git-Bukkit-a3cb1bc]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.<init>(CraftServer.java:25
    0) [craftbukkit_server.jar:git-Bukkit-a3cb1bc]
            at net.minecraft.server.v1_8_R3.PlayerList.<init>(PlayerList.java:69) [c
    raftbukkit_server.jar:git-Bukkit-a3cb1bc]
            at net.minecraft.server.v1_8_R3.DedicatedPlayerList.<init>(SourceFile:14
    ) [craftbukkit_server.jar:git-Bukkit-a3cb1bc]
            at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.jav
    a:179) [craftbukkit_server.jar:git-Bukkit-a3cb1bc]
            at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java
    :503) [craftbukkit_server.jar:git-Bukkit-a3cb1bc]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_51]
    Caused by: java.lang.ClassNotFoundException: com.skitscape.survivalgames.Surviva
    lGames
            at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.8.0_51]
            at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.
    java:77) ~[craftbukkit_server.jar:git-Bukkit-a3cb1bc]
            at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.
    java:62) ~[craftbukkit_server.jar:git-Bukkit-a3cb1bc]
            at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_51]
            at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_51]
            at java.lang.Class.forName0(Native Method) ~[?:1.8.0_51]
            at java.lang.Class.forName(Unknown Source) ~[?:1.8.0_51]
            at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.jav
    a:40) ~[craftbukkit_server.jar:git-Bukkit-a3cb1bc]
            ... 10 more
    
     
  4. Offline

    Boomer

    [15:16:55 ERROR]: Could not load 'plugins\SurvivalGamesFix.jar' in folder 'plugi
    ns'
    org.bukkit.plugin.InvalidPluginException: Cannot find main class `com.skitscape.
    survivalgames.SurvivalGames'
    the fully qualified classname doesn't match between the plugin.yml file (the original entry) and your recompiled one (due to the decompiling resulting in a different package name)
     
  5. Offline

    Filipzetomic

    Do you mean this:
    name: SurvivalGames
    main: com.skitscape.survivalgames.SurvivalGames
    What do I need to rename?
     
  6. Offline

    timtower Administrator Administrator Moderator

  7. Offline

    Filipzetomic

    SurvivalGames.class
    It has the onEnable and onDisable methods
     
  8. Offline

    timtower Administrator Administrator Moderator

  9. Offline

    Filipzetomic

  10. Offline

    Boomer

    that is the correct name, the issue is that the way you have your project setup from the decompiled code is not in the right structure for that to be correct. Kinda surprising actually that you dont have a lot of IDE warnings and errors about the package names and classnames..
     
  11. Offline

    nverdier

    @Filipzetomic Keep in mind that you may have to fix decompilation errors. Just speaking about general decompilation, didn't read any of the thread. Yeah. Decompilation errors.
     
  12. Offline

    Filipzetomic

    All I did was import an 'Existing Project into Workspace' and selected the decompiled plugin.
     
  13. Offline

    Boomer

    If thats "all you did" then you should definitely be seeing errors and compiling garbage, since you need to add the bukkit api to the project buildpath as well, not doing so would have given errors for all the bukkit references... Assuming that you actually did do that, and did not have any errors visible then it must be using the folder structure for the package as-is, in which case the package name would be right, and the plugin.yml settings are right..

    Its also possible that when exporting the compiled file, you didn't actually select the contents to export - sometimes an IDE will go dumb and look like its selected a project for export, but really, its un-selected all the files and stuff that are needed within the export structure. Make sure you're exporting the actual class files as part of the checked-to-include

    (You can and should double check the jar file you are exporting, unpack it/explore it to see what it contains. Should be in your case the plugin.yml file and a folder with subfolder with subfolder... \com\skitscape\survivalgames\ which contains the .class file/files
     
  14. Offline

    Filipzetomic

    Here are the exact steps (if you can recreate my steps, it'll be great):
    1) Switched on my computer
    jk
    1) Opened up the SurvivalGames.jar in jd-gui
    2) Saved all sources as a zip
    3) Extracted the whole zip onto a new folder
    4) Right-clicked on Project Explorer and selected Import
    5) Clicked 'Existing Projects into Workspace'
    6) Set the root directory to the folder I extracted the decompiled zip
    7) Clicked finish
    8) Clicked Configured Build Path
    9) Edited 'craftbukkit-1.3.1...jar' to my version of craftbukkit (Spigot 1.8)
    10) Edited 'WorldEdit.jar' to my version of WorldEdit (latest I believe)
    11) Removed the system output line in KeepLobbyLoadedEvent.java
    12) Saved and closed the file (for some reason you wont get any error that says it can't find package)
    13) Exported as JAR file, selected all resources to be exported, selected destination to my server's plugin folder
    14) Clicked next and then next again
    15) Used existing manifest from workspace (/SurvivalGames/META-INF/MANIFEST.MF)
    16) Clicked finished, and got not even one warning
    17) This is the error I got:
    Code:
    [19:06:16 ERROR]: Could not load 'plugins\SurvivalGames.jar' in folder 'plugins'
    
    org.bukkit.plugin.InvalidPluginException: Cannot find main class `com.skitscape.
    survivalgames.SurvivalGames'
            at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.jav
    a:42) ~[craftbukkit_server.jar:git-Bukkit-a3cb1bc]
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
    ava:129) ~[craftbukkit_server.jar:git-Bukkit-a3cb1bc]
            at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.
    java:328) ~[craftbukkit_server.jar:git-Bukkit-a3cb1bc]
            at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager
    .java:251) [craftbukkit_server.jar:git-Bukkit-a3cb1bc]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugins(CraftServer.ja
    va:288) [craftbukkit_server.jar:git-Bukkit-a3cb1bc]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.<init>(CraftServer.java:25
    0) [craftbukkit_server.jar:git-Bukkit-a3cb1bc]
            at net.minecraft.server.v1_8_R3.PlayerList.<init>(PlayerList.java:69) [c
    raftbukkit_server.jar:git-Bukkit-a3cb1bc]
            at net.minecraft.server.v1_8_R3.DedicatedPlayerList.<init>(SourceFile:14
    ) [craftbukkit_server.jar:git-Bukkit-a3cb1bc]
            at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.jav
    a:179) [craftbukkit_server.jar:git-Bukkit-a3cb1bc]
            at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java
    :503) [craftbukkit_server.jar:git-Bukkit-a3cb1bc]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_51]
    Caused by: java.lang.ClassNotFoundException: com.skitscape.survivalgames.Surviva
    lGames
            at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.8.0_51]
            at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.
    java:77) ~[craftbukkit_server.jar:git-Bukkit-a3cb1bc]
            at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.
    java:62) ~[craftbukkit_server.jar:git-Bukkit-a3cb1bc]
            at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_51]
            at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_51]
            at java.lang.Class.forName0(Native Method) ~[?:1.8.0_51]
            at java.lang.Class.forName(Unknown Source) ~[?:1.8.0_51]
            at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.jav
    a:40) ~[craftbukkit_server.jar:git-Bukkit-a3cb1bc]
            ... 10 more
     
  15. Offline

    Boomer

    And the most important step of all: Unpacking the jar file and confirming that indeed the files are present.
     
  16. Offline

    Filipzetomic

    Yes everything is there, otherwise I would get an error when I try to edit KeepLobbyLoaded.java in eclipse.
     
  17. Offline

    Boomer

    No, you're missing the point. The files are in the project, but are the class files present in the JAR that isn't running - the jar that has the message that says "Can't find xxx class file" ...
    Are they there in the JAR that YOU EXPORT when done?
     
  18. Offline

    Filipzetomic

    They are all uncompiled jar files which is weird since no error pops up. I'll try to compile the single java file
     
  19. Offline

    Boomer

    Export a jar, make sure you have this:
    [​IMG]
     
Thread Status:
Not open for further replies.

Share This Page