Command to replace more Blocks with WorldGuard

Discussion in 'Plugin Development' started by Si1lve3r, Jul 12, 2014.

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

    Si1lve3r

    Hi!

    Can somebody help me with the following problem?

    In my world I have different blocks, which I would like to replace but only in a dedicated area.

    Example:

    Green wool 2x2, -> on command it changes to -> blue wool 2x2.


    In total there are over 1000 blocks that should be replaced but I don't want to make for every block a Location.

    I thought I can use the WorldGuard API, but I don't understand it ^^

    Can one of you give me some assistance?

    Thanks!
     
  2. Offline

    TheMcScavenger

    Replacing blocks has nothing to do with WorldGuard, it's WorldEdit. Probably your mistake..
     
  3. Offline

    ResultStatic

    Si1lve3r I just started on the api but i got it to work. there is 2 classes that you should be concerned with to start off. i would suggest looking at the source code.

    EditSession. this class has tons of useful methods for setting blocks calculating things and handle blocks
    Region/CuboidRegion/Poly2DRegion check to api to see the full list
    these are great for setting all the blocks in the group and handling if blocks are in them. basically what worldguard does.

    Code:
    static EditSession edit;
     
                        //constuctor          //bukkitworld
        public PolyRegion(World world){
            if (edit == null){                                       
                edit = new EditSession(BukkitUtil.getLocalWorld(world), 100000//max blocks);
            }
        }
    here is how you would create a cuboid region with 2 location parameters

    Code:
            this.loc1 = loc1;
            this.loc2 = loc2;
            BlockVector v1 = new BlockVector(loc1.getBlockX(),loc1.getBlockY(),loc1.getBlockZ());
            BlockVector v2 = new BlockVector(loc2.getBlockX(),loc2.getBlockY(),loc2.getBlockZ());
            this.region = new CuboidRegion(v1,v2);
    i looked at ur post again and ur having trouble because its not setting the wool to the right color. you have to add a semicolon after and then more data to get specific colors. like red stainedclay is 159:5.
     
Thread Status:
Not open for further replies.

Share This Page