Check if in WorldGuard Region

Discussion in 'Plugin Development' started by anonym110, Mar 20, 2012.

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

    anonym110

    Hey,
    I'm pretty new to devoloping Plugins and now I've been trying for a about an hour to get WorldGuard integrated, but I just keep failing.

    Code:
        @EventHandler(priority = EventPriority.NORMAL)
        public void onSaplingBreak(BlockBreakEvent sap)
        {
            if (sap.getBlock().getType() == Material.SAPLING){
                sap.setCancelled(true);
                sap.getPlayer().sendMessage(ChatColor.GREEN + "[TreeFarm] " + ChatColor.RED + "Don't destroy the Saplings!");
            }
    This is my code and I would like to add right on the top that it checks "if (region == treefarm)". So the code only executes if a block is broken inside of a certain WorldGuard region.
     
  2. Offline

    Karl Marx

  3. Offline

    anonym110

    Yes but I don't understand it enough to get it to work with a if-clause. I'd really appreciate someone could give me an example how to read out what region the block was broken and if it maches for example the region 'treefarm'

    Well I couldnt get WorldGuard figured out so I used this...
    Code:
                int x1,y1,z1;
                x1 = sap.getBlock().getX();
                y1 = sap.getBlock().getY();
                z1 = sap.getBlock().getZ();
             
                    if (x1 > -60 && x1 < -29){
                    if (y1 > 0 && y1 < 255){
                    if (z1 > 334 && z1 < 356){
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 24, 2016
Thread Status:
Not open for further replies.

Share This Page