BreakEvent, WorldEdit, NotWork

Discussion in 'Plugin Development' started by nyanneko0113, Nov 17, 2020.

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

    nyanneko0113

    I break don't wall block.
    So not work...

    I use WorldEdit Plugin (API).

    Config:
    Code:
    game:
      arena1:
        x: 160
        y: 61
        z: 216
      arena2:
        x: 146
        y: 200
        z: 230
    

    Code:
    Code:
    public class onBreakEvent implements Listener {
    
        private Main instance;
        public onBreakEvent(Main instance) {
            this.instance = instance;
        }
    
        @EventHandler
        public void BreakEvent(BlockBreakEvent e) {
            FileConfiguration config = instance.getConfig();
            World world = e.getPlayer().getWorld();
            Location loc = e.getBlock().getLocation();
    
            Vector play_arena1 = new Vector(config.getInt("game.arena1.x"), config.getInt("game.arena1.y"), config.getInt("game.arena1.z"));
            Vector play_arena2 = new Vector(config.getInt("game.arena2.x"), config.getInt("game.arena2.y"), config.getInt("game.arena2.z"));
            CuboidRegion region_play = new CuboidRegion(play_arena1, play_arena2);
            for (BlockVector block : region_play) {
                Location playloc = new Location(world, block.getBlockX(), block.getBlockY(), block.getBlockZ());
                if (playloc.equals(loc)) {
                    e.setCancelled(false);
                }
                else {
                    e.setCancelled(true);
                }
            }
        }
    }
    
    ↓ picture (black): don't break area
     

    Attached Files:

    • don.PNG
      don.PNG
      File size:
      204.5 KB
      Views:
      6
  2. Offline

    Chr0mosom3

    You made it so if the block is in the arena you can break it, if not then you can't
     
Thread Status:
Not open for further replies.

Share This Page