Checking if certain blocks are in a selection with WorldEdit API

Discussion in 'Spigot Plugin Development' started by black_, Jun 1, 2017.

  1. Hey! I am in need of some assistance. I would like to find out the best way to find all of a certain block (say, green wool) within a world edit selection. I assume that you would run a loop through all the blocks, however I am not well versed with the worldedit api and hope that someone with more knowledge than me can help.
    Any help is appreciated
     
  2. Sorry if this spoonfeeding bothers anyone... I believe basic stuff like this should be given because it is "the basics"
    Code (Java):
    WorldEditPlugin we = ( WorldEditPlugin ) Bukkit.getPluginManager().getPlugin( "WorldEdit" );
    Selection sel = we.getSelection( p );
    if( sel == null ){
         p.sendMessage(ChatColor.RED + "You must make a WorldEdit Selection first" );
         return;
    }
    Location min = sel.getMinimumPoint();
    Location max = sel.getMaximumPoint();
    After that, you run three loops with the x, y, and z of min up to the x, y, z of max and test if each block is wool with the color green.
     
    • Useful Useful x 2