Server#broadcastMessage() not compatible with softdepend

Discussion in 'Spigot Plugin Development' started by Rixterz, Jun 16, 2016.

  1. Hi

    I'm using NPC factory jar file in my project which depends on Citizens.jar, so I put softdepend: [Citizens] in the project plugin.yml to ensure Citizens is enabled first. However, that stops all broadcastMessage()s in my project from working. How can I get around it? When the NPC factory jar is enabled, it refuses to run and gives an error because Citizens isn't enabled, although it would be very soon afterwards due to the jar enabling order.
  2. If you put 'softdepend' your plugin will still run even if the plugin doesn't start. You should be using just 'depend' so your plugin won't try to start if the dependency isn't found. (If it's 100% required)
  3. Done that, but broadcastMessage still does nothing. Not even on the console
  4. I don't know why dependencies would affect broadcastMessage. What do you mean? Like in the onEnable? Maybe your plugin isn't enabling, then. How is broadcastMessage relevant? Show the code you're having trouble with
  5. Code (Text):
    public void onEnable()
        getServer().getPluginManager().registerEvents(this, this);
    If I remove depend: [Citizens] from my plugin.yml, it works as expected, except I can't use most of my plugin without that dependency because of sloppy coding by the creator of that jar
  6. Are you sure you have Citizens installed? Your problem is confusing.
  7. So what exactly happens when the depend is in the yml? The broadcast doesn't show? That would indicate that your plugin isn't enabling. Have you tried System.out.println() instead of broadcastMessage? When the depend is there, do the features of the plugin work?
  8. As @andrew28 said make sure you have Citizens installed and can we see your console when you start up your server or reload your server? Thanks!
  9. This.

    The broadcastMessage method doesn't do anything when the server is still starting up.
    Valid alternatives that do work are:

    #9 iPyronic, Jun 16, 2016
    Last edited: Jun 17, 2016
  10. Every feature works except broadcasting messages
  11. Actually broadcastMessage does work when the server is starting up, as long as there is no depend in the yml. It's almost as if the plugin being depended on has somehow disabled broadcastMessage
  12. I can't seem to reproduce that. Both with and without depending in the plugin.yml, broadcastMessage() doesn't work on my end (however, all of the other ways do work). The reason being that Bukkit.getPluginManager().getPermissionSubscriptions("bukkit.broadcast.user") returns an empty set while the plugin is enabling. broadcastMessage() iterates over that set and calls sendMessage() on the elements, so you might as well just do the sendMessage() manually yourself.

    It's possible to give the console the permission yourself (which does allow broadcastMessage() to work), but that's just overkill, you're better off using the other methods.
    #12 iPyronic, Jun 18, 2016
    Last edited: Jun 18, 2016