Spigot Plugin Development

Discussion in 'Wiki Discussion' started by jtaylor69, Mar 1, 2015.

  1. Why are code examples in PHP?

    Aren't there different ways to format code?

    Code (Java):
    //On forum posts you do [code='language'] [/cod e]
     
  2. keep getting this:
    Code (Text):

    [07:06:52] [Server thread/ERROR]: Could not load 'plugins\SpigotBlankPlugin.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: Cannot find main class `furr.obscenity.spigotblankplugin'
    at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:66) ~[spigot-1.8.8.jar:git-Spigot-db6de12-930a59c]
    at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:131) ~[spigot-1.8.8.jar:git-Spigot-db6de12-930a59c]
    at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:329) ~[spigot-1.8.8.jar:git-Spigot-db6de12-930a59c]
    at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:251) [spigot-1.8.8.jar:git-Spigot-db6de12-930a59c]
    at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugins(CraftServer.java:292) [spigot-1.8.8.jar:git-Spigot-db6de12-930a59c]
    at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:198) [spigot-1.8.8.jar:git-Spigot-db6de12-930a59c]
    at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:525) [spigot-1.8.8.jar:git-Spigot-db6de12-930a59c]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_66]
    Caused by: java.lang.ClassNotFoundException: furr.obscenity.spigotblankplugin
    at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.8.0_66]
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:101) ~[spigot-1.8.8.jar:git-Spigot-db6de12-930a59c]
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:86) ~[spigot-1.8.8.jar:git-Spigot-db6de12-930a59c]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_66]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_66]
    at java.lang.Class.forName0(Native Method) ~[?:1.8.0_66]
    at java.lang.Class.forName(Unknown Source) ~[?:1.8.0_66]
    at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:64) ~[spigot-1.8.8.jar:git-Spigot-db6de12-930a59c]
    ... 7 more
     
    [​IMG]
     
  3. Recompile your code. Maybe sure all classes will be exported.
     
  4. i did it again just now, it exported exactly how it says, but same error
     
  5. Change your main in your plugin.yml to your main class and not your package.
     
    • Informative Informative x 1
  6. Ah. Yes.
     
  7. THAT was it! completely missed that, thanks.

    Code (Text):

    17:04:04 [INFO] [SpigotBlankPlugin] Enabling SpigotBlankPlugin v1.0
    17:04:04 [INFO] Woo
    ...
    17:05:03 [INFO] [SpigotBlankPlugin] Disabling SpigotBlankPlugin v1.0
    17:05:03 [INFO] Aww
     
     
  8. SlimeDog

    Benefactor

    Hopefully this is a quick java-newbie plugin development issue, but I'm not seeing through it. The meat of the plugin is to retrieve a list of loaded plugins. (I don't think such a plugin exists, but that is not the point -- I'm using it to learn java and the Spigot/Bukkit Eclipse-on-a-Mac plugin development environment.) The plugin compiles, loads and is enabled on Spigot 1.9 (and 1.8.8) server, runs a reload subcommand to refresh from config.yml, and runs a list subcommand. What the latter does not do is populate the list. Here are the relevant snippets:

    ...
    import org.bukkit.command.SimpleCommandMap;
    ...
    import org.bukkit.plugin.SimplePluginManager;
    ...
    // TODO: MAKE THIS WORK.
    SimpleCommandMap scm = new SimpleCommandMap(this.getServer());
    SimplePluginManager spm = new SimplePluginManager(this.getServer(),scm);
    Plugin[] pluginList = spm.getPlugins();
    if (pluginList.length == 0) {
    sender.sendMessage("No plugins loaded");
    return true;​
    }
    ...​
    As you might guess, pluginList.length == 0, despite the fact that there are 39 loaded plugins on the server. Any insight appreciated.
     
    #28 SlimeDog, Mar 29, 2016
    Last edited: Mar 29, 2016
  9. You may not ceate new SimpleCommandMaps and SimplePluginManagers. you do not understand the system of object orientated programming (oop).
    You need to get these object either in your JavaPlugin extending class with getServer().getPluginManager() for example or with Bukkit.getPluginManager() for example. It does not help that you give this.getServer() as constructor parameter. You need to get the already instantiated objects through the getters. Please note that the SimpleCommandMap class is nothing a plugin for bukkit normally needs.
    @rambeau

    Edit: I suggest that you first learn some java and oop, then start with a bukkit plugin tutorial. Please note that some bukkit plugin tutorials however teach bad habits / bad code style. For this I suggest to start with basic java and oop first.
     
  10. SlimeDog

    Benefactor

    Thank you. Wilco.

    UPDATE 3 weeks later: I did as you suggested. I know a lot more now -- still a neophyte, but willing to learn. I built a rudimentary plugin that did what I intended it to do. Onward...
     
    #30 SlimeDog, Mar 29, 2016
    Last edited: Apr 20, 2016
  11. Thanks for this post.
     
  12. Where can I find the API changelog?
     
  13. Thanks babe
     
  14. Phoenix616

    Resource Staff

    Can we please get a tutorial for a better NoSQL-DB than Mongo? If we want to promote a NoSQL-DB it should be one that works reliably (e.g. Redis) and not something like MongoDB...
     
  15. I noticed that Idea and Eclipse have examples with regards to creating an empty test plugin, but a NetBeans example is missing. Being a NetBeans user myself (and being quite familiar with writing documentation) I'm tempted to jump in, but would like to verify that this would be appreciated. I checked the page overview and nothing exists as of yet.

    Reason I ask: for all I know there might be a reason why this isn't included.

    Thanks in advance for any comments.

    Update: In the mean time, after having ensured myself several times that Wiki contributions are appreciated, I went ahead and added a few pages and also made some minor updates to some existing pages (mainly making sure that an example could used with the proper results, and I removed an invalid link after double checking that the wiki page was no where to be found anymore).
     
    #36 ShelLuser, Nov 23, 2016
    Last edited: Nov 24, 2016

Share This Page