Check if player can edit block

Discussion in 'Plugin Development' started by Robnoo, Dec 23, 2018.

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

    Robnoo

    Hi all,

    How can I check whether a player can edit a block or not, depended on plot/region/claim/...? (Break/place)

    Thanks in advance,
    Robnoo
     
  2. Offline

    Robnoo

    Thanks for the help, WorldGuard is indeed one of the plugins it should work with. But what I actually want is a way to check if a player is able to break/place a block on a specific location, independent from other plugins, although I don't know if this is possible or not. Otherwise, I'd have to check every single protect plugin. (And there are a lot of them) Some plugins use e.setCancelled(true) on PlayerInteractEvent, so using if(!e.isCancelled()) solves the problem for plugins which are using that event. Now I'm stuck with the other plugins which don't use that event.
    I wasn't really clear, my bad.

    Robnoo
     
  3. Checking if a player is able to break/place a block on a specific location without the use of other plugin would (I think) require you to create your own system for building permissions, and I doubt that that is easier than just including the most-used plugins that do this.

    I suggest creating a special handler class for each plugin (for example "WorldGuardHandler", "GriefPreventionHandler" etc.) you want to your plugin to support, and checking which plugin the server uses. Then, according to that, 'activate' the handler for that plugin in onEnable(). There might be better solutions to this, but this is the only thing I can currently come up with.
     
  4. Offline

    Robnoo

    Oke, thanks for your help! I'll try to do something with that :).

    Robnoo
     
Thread Status:
Not open for further replies.

Share This Page