Nothing happening?

Discussion in 'Spigot Plugin Development' started by TheSupreme, Apr 16, 2017.

  1. Code (Text):
        @EventHandler
        public void onPlace(BlockPlaceEvent event) {
            Player player = event.getPlayer();
            event.setCancelled(true);
           
            Location loc = player.getLocation();
           
            Location l1 = player.getLocation();
            l1.setX(100);
            l1.setY(100);
            l1.setZ(100);
           
            Location l2 = player.getLocation();
            l2.setX(-100);
            l2.setY(-100);
            l2.setZ(-100);
            if (!isInside(loc, l1, l2)) {
                    event.setCancelled(true);
                  player.sendMessage("You cannot build here.");
                }
        }
       
        public boolean isInside(Location loc, Location l1, Location l2)
        {
            int x1 = Math.min(l1.getBlockX(), l2.getBlockX());
            int y1 = Math.min(l1.getBlockY(), l2.getBlockY());
            int z1 = Math.min(l1.getBlockZ(), l2.getBlockZ());
            int x2 = Math.max(l1.getBlockX(), l2.getBlockX());
            int y2 = Math.max(l1.getBlockY(), l2.getBlockY());
            int z2 = Math.max(l1.getBlockZ(), l2.getBlockZ());
            int x = 0;
            int y = 0;
            int z = 0;
            return x >= x1 && x <= x2 && y >= y1 && y <= y2 && z >= z1 && z <= z2;
        }
    Why isn't this working correctly?
    Trying to see if a player is inside a custom region.
     
    • Funny Funny x 1
  2. mathhulk

    mathhulk Retired Moderator
    Retired

    Moved to Spigot Plugin Development.
     
    • Agree Agree x 1