Only explode blocks within a specific region

Discussion in 'Plugin Development' started by Jncwhite01, Apr 11, 2018.

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

    Jncwhite01

    Hello! Im currently developing a plugin for the pickaxes which were on the TitanMC server a while back.

    Currently doing the Explosive pickaxe and cant seem to get it to only explode blocks which are within a specific region. (For anyone who doesnt know: When you mine a block with the explosive pickaxe, a explosion will be created at the location of the exploded block)

    I have tried using WolrdGuards API to no avail. This would be my first time using the WolrdGuard API and since there is not any clear documentation or videos on it, it is very hard to use.

    I was thinking about crating my own regions (getting a min and max, x, y. z value and just checking if the exploded blocks position is within them values, if so destroy it, if not then dont)

    Not sure the best way to go about it though, any help would greatly be appreciated.
     
  2. @Jncwhite01
    this is what i used to check if a player is in a region, same could be done for blocks


    Code:
    private WorldGuardPlugin getWorldGuard()
    {
       Plugin plugin = getServer().getPluginManager().getPlugin("WorldGuard");
        
       if (plugin == null || !(plugin instanceof WorldGuardPlugin))
       {
           return null;
       }
        
        return (WorldGuardPlugin) plugin;
    }
    
    WorldGuardPlugin wg = getWorldGuard();
    
    ProtectedRegion pr = wg.getRegionManager(p.getWorld()).getRegion("Region Name Here"); //code from an event
    if(pr != null)
    {
       if(pr.contains(p.getLocation().getBlockX(), p.getLocation().getBlockY(), p.getLocation().getBlockZ()))
       {
            p.sendMessage(ChatColor.RED + "You are not allowed to use this here!");
            e.setCancelled(true);
       }
    }
     
  3. Offline

    Jncwhite01

    Thank you, originally I was creating an ApplicableRegionSet, and then looping through each region in there, which didnt seem to work... Ill try that now and will get back to you!

    ---------

    Took what you said and implemented it and kinda played around with it for abit and managed to get it working thnaks:) now need to figure out how to add blocks that were exploded to the users inventory
     
    Last edited: Apr 12, 2018
Thread Status:
Not open for further replies.

Share This Page