Overriding WorldGuard build event

Discussion in 'Plugin Development' started by RandomPanda30, May 20, 2016.

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

    RandomPanda30

    Essentially, I want to be able to let a player build when I allow so and not let WorldGuard interfere. I've tried -

    Cancelling the event
    Going as far as editing the actual source of WorldGuard
    Changing the event priority

    No matter what happens I cannot let my plugin make the decision first about building before WorldGuard. Anyone got any suggestions?
     
  2. Offline

    OhYes

    There's a permission for world guard that lets a player modify the region.
    A command rather. I think it's /region addmember (name)
     
  3. Offline

    I Al Istannen

    @RandomPanda30
    You want to cancel the event or allow it? There is no worldguard event though, so I presume you are listening to a blockBreak/place event.

    You can modify the @EventHandler annotation of your event listener to @EventHandler(ignoreCancelled = false) and un-cancel / cancel the event. This way your event listener will also be called if worldguard cancels the event.

    You need to make your decision AFTER worldguard, to change the outcome. "Normal" priority should be okay, you might even want to try one lower. If that doesn't work, work up your way till "Highest".
     
  4. Offline

    RandomPanda30

    Tried this, still getting completely run over by WorldGuard's "You don't have permission for this area" message.

    Code:
    @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = false)
    Tried changing almost everything! Is there anything special WorldGuard does that I'm not seeing?

    Edit: to answer your question, I'm trying to allow it
     
  5. Offline

    I Al Istannen

    @RandomPanda30
    Why do you need this? Is temporarily adding the player to a region an option?
     
  6. Offline

    RandomPanda30

    So there's basically a region called spawn which has a lot of houses in. I've made a plugin that selects all the inside of the house. However, instead of using complicated regions stuff (Cuboid and such won't work because it shapes the inside of the house) I've just stored the locations and then I'm hoping to allow building in the normally restricted area if you get my drift.
     
  7. Offline

    I Al Istannen

    @RandomPanda30
    I see. The houses are totally irregular shaped and the user can't change them? So a bounding box cuboid will really not work? I haven't tried uncancelling world guard events before, I will try a bit and edit this post.

    EDIT: Works for me:
    Code:
        @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = false)
        public void onBuild(BlockPlaceEvent e) {
            System.out.println(e.getPlayer().getDisplayName() + " " + e.isCancelled() + " " + e.canBuild());
            e.setCancelled(false);
        }
    
        @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = false)
        public void onBreak(BlockBreakEvent e) {
            System.out.println(e.getPlayer().getDisplayName() + " " + e.isCancelled());
            e.setCancelled(false);
        }
    You will see the worldguard message. You can place and break though. Ugly workaround though. Doing it with regions would be better!
     
    Last edited: May 20, 2016
  8. Offline

    RandomPanda30

    The user will only be able to edit the air inside the house basically. Yeah a box cuboid will not work or such which sucks really. I'll keep on trying and let you know as well, thank you
     
  9. Offline

    I Al Istannen

  10. Offline

    RandomPanda30

    Ugly...but absolutely beautiful though! The block breaking works, however one small problem. I still keep getting the "You don't have permission for this area" from WorldGuard. Any last solutions for this?
     
  11. Offline

    I Al Istannen

    @RandomPanda30
    I don't think you can easily do this.
    Worldguard still cancels the event, you just choose to uncancel it later.
    Worldguard thinks it is cancelled and therefore send the message and the smoke.

    This is also why I referred to it as an ugly solution :/
    Maybe there is a way to remove the message without packets, but I don't know any.
     
  12. Offline

    RandomPanda30

    Hmmm what about just creating a new region? Surely there must be more complicated methods in WorldGuard to create an obscure region?
     
  13. Offline

    I Al Istannen

    @RandomPanda30
    Polygon one is the most complex, I think. I might be wrong though, and i can't reach the world guard docs at the moment.
     
  14. Offline

    DoggyCode™

    CREATE A NEW WORLDGUARD PLUGIN! Just jokin'. You would almost have to edit the chat packets WorldGuard sends the player, which is something i wouldn't really recommend.
     
    RandomPanda30 likes this.
  15. Offline

    RandomPanda30

    *screams* Those words...I know I'm looking into alternatives to this now and making a complex region with WorldGuard
    Me neither hmm
     
    DoggyCode™ likes this.
  16. Offline

    RandomPanda30

  17. Offline

    RandomPanda30

  18. Offline

    I Al Istannen

    @RandomPanda30
    What is your question? Have you tried the Polygon Region?
     
Thread Status:
Not open for further replies.

Share This Page