Solved using world guard w/ breakNaturally

Discussion in 'Plugin Development' started by pingpong1999, Apr 26, 2016.

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

    pingpong1999

    Code:
        @EventHandler
        public void onBreak(BlockBreakEvent e){
            ItemStack item = e.getPlayer().getItemInHand();
            ItemMeta meta2 = item.getItemMeta();
            List<String> lore = meta2.getLore();
            if(lore.toString().contains("Drill")){
            Block surroundXp = e.getBlock().getLocation().subtract(0.0, 0.0, 1.0).getBlock();
            Block surroundXm = e.getBlock().getLocation().add(1.0, 0.0, 0.0).getBlock();
            Block surroundZp = e.getBlock().getLocation().add(0.0, 0.0, 1.0).getBlock();
            Block surroundZm = e.getBlock().getLocation().subtract(1.0, 0.0, 0.0).getBlock();
            surroundXm.breakNaturally(item);
            surroundXp.breakNaturally(item);
            surroundZp.breakNaturally(item);
            surroundZm.breakNaturally(item);
            }
          
        }
    
    So I am making a custom enchant that destroys a + shape or maybe even a 3x3 shape.
    The server is a prison server, so it is mostly restricted on what you can break and what you cant. But say the player was mining with the Drill Enchant. Say they were on the exact corner of the mine. they would destroy the block they broke and the mine walls in the + shape. this would also break spawn etc leaving the block they originally broke. how do I implement it so that I can hook into world guard and check if the block is in a region or not. I have never really hooked into plugins and I cant find an answer anywhere on google. because It is quite a specific question

    Also- please correct me on anything I could improve on to make my code more efficient
     
  2. Offline

    Lordloss

  3. Offline

    pingpong1999

    How would I beable to do this?
     
  4. Offline

    Lordloss

    Sorry but seriously, if you dont know how to use lists properly / iterate over a collection, you are here in the wrong place.
    You should only use bukkit if you have a basic knowledge in java, and stuff like that is very very basic.
     
  5. Offline

    DoggyCode™

    Yo must check if the block you break naturally is within the mine region, if it isn't, don't break it,
     
  6. Offline

    bennie3211

    *Reads JavaDocs*
    Couldn't find it for (craft)bukkit but it works the same
     
Thread Status:
Not open for further replies.

Share This Page