Hooking CommandBook

Discussion in 'Plugin Development' started by Hedgehogs4Me, Aug 10, 2014.

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

    Hedgehogs4Me

    Has anyone had any success with this, or know how to do it? I tried asking on their IRC, and one guy was pretty helpful, but I'm still confused, and it seems like the sort of thing that I need a more detailed example for.

    I know that you need to cast a plugin to CommandBook to handle it as Commandbook, like (CommandBook)Bukkit.getServer().getPluginManager().getPlugin("CommandBook");
    I also know that what I want is in BansComponent (more specifically the CSVBanDatabase instance "bans"), and I can look at the CommandBook src to see what's going on most of the time.
    That's where my knowledge ends. I'm not the greatest programmer, but I know enough to figure out what's going on in the CommandBook src. I just don't know how get access to the CSVBanDatabase instance.

    Here's why I'm doing this, and what I want to do:
    When a player logs in (using PlayerLoginEvent) and the server is full, they can replace another player or be kicked based on whether they have a certain permission. However, right now, this seems to override our CommandBook banning system, so I'd like to check if they're banned before letting them in.
     
  2. Offline

    bangman

    If I have understood your problem correctly, you could try executing your player replace system's code after CommandBook has handled a player login.

    You could (probably?) achieve this by setting your PlayerLoginEvent handler priority to MONITOR meaning your plugin is the last to have the event registered to (or do this a couple of ticks after the event using Scheduler) and check whether that player is still on the server (if they've been kicked, ignore) and then decide whether to kick or make space for them.

    Hope this helps:)
     
Thread Status:
Not open for further replies.

Share This Page