@EventHandler(priority = EventPriority.NORMAL)
  public void grapple(ProjectileHitEvent event) {
    Entity proj = event.getEntity();
    Location hit = proj.getLocation();

    if (contains(hit, x1, x2, y1, y2, z1, z2) == true) {

      if (proj instanceof Snowball) {
        Snowball fish = (Snowball) proj;
        Entity shooter = fish.getShooter();

        if (shooter instanceof Player) {
          Player p = (Player) shooter;
          Location loc = p.getLocation();
          ItemStack is = p.getItemInHand();
          Material mat = is.getType();

          if (mat == Material.FISHING_ROD) {

            p.setFallDistance(0);
            p.playSound(loc, Sound.ARROW_HIT, 1, 1);

            int hitx = hit.getBlockX();
            int hity = hit.getBlockY();
            int hitz = hit.getBlockZ();
            int locx = loc.getBlockX();
            int locy = loc.getBlockY();
            int locz = loc.getBlockZ();
            double co[] = new double[3];

            if (hitx > locx) {
              co[0] = 1.2;
            } else if (hitx < locx) {
              co[0] = -1.2;
            } else if (hitx == locx) {
              co[0] = 0;
            }

            if (hity > locy) {
              co[1] = 1.4;
            } else if (hity < locy) {
              co[1] = -0.8;
            } else if (hity == locy) {
              co[1] = 0;
            }

            if (hitz > locz) {
              co[2] = 1.2;
            } else if (hitz < locz) {
              co[2] = -1.2;
            } else if (hitz == locz) {
              co[2] = 0;
            }

            p.setVelocity(new Vector(co[0], co[1], co[2]));
          }
        }
      }
    }
  }
  public boolean isProtectedLocation(Location location) {
    // Destroyed walls do not protect anything.
    if (!this.isActive()) {
      return false;
    }

    // We already know this location is inside a protected chunk
    // A protected location then, is any location which has a x, z match
    // and its y is less than our structure blocks'

    for (BlockCoord coord : this.wallBlocks.keySet()) {
      Location blockLocation = coord.getLocation();

      if (location.getBlockX() == blockLocation.getBlockX()
          && location.getBlockZ() == blockLocation.getBlockZ()) {

        // x and z match, now check that block is 'below' us.
        if (location.getBlockY() < Wall.MAX_HEIGHT) {
          return true;
        }
      }
    }

    return false;
  }
  public void teleportAway(Player player) {
    // prepare teleport destination

    Location destination = player.getLocation();
    World world = destination.getWorld();

    Vec safe = findSafeLocation(destination);
    double x = safe.getX() + .5D;
    double y = safe.getY();
    double z = safe.getZ() + .5D;

    if (y == -1) {
      return;
    }

    if (!world.isChunkLoaded(destination.getBlockX() >> 4, destination.getBlockZ() >> 4)) {
      world.loadChunk(destination.getBlockX() >> 4, destination.getBlockZ() >> 4);
    }

    Location loc = new Location(world, x, y, z, destination.getYaw(), destination.getPitch());

    // teleport the player

    player.teleport(loc);
  }
  @EventHandler(priority = EventPriority.HIGH)
  public void enterSnitchProximity(PlayerMoveEvent event) {
    Location from = event.getFrom();
    Location to = event.getTo();

    if (from.getBlockX() == to.getBlockX()
        && from.getBlockY() == to.getBlockY()
        && from.getBlockZ() == to.getBlockZ()
        && from.getWorld().equals(to.getWorld())) {
      // Player didn't move by at least one block.
      return;
    }
    Player player = event.getPlayer();
    if (vanishNoPacket.isPlayerInvisible(player)) {
      return;
    }
    String playerName = player.getName();
    Location location = player.getLocation();
    World world = location.getWorld();
    Set<Snitch> inList = playersInSnitches.get(playerName);
    if (inList == null) {
      inList = new TreeSet<Snitch>();
      playersInSnitches.put(player.getName(), inList);
    }
    Set<Snitch> snitches = snitchManager.findSnitches(world, location);
    for (Snitch snitch : snitches) {
      if (!isOnSnitch(snitch, playerName) && doesSnitchExist(snitch, true) || isDebugging()) {
        if (!inList.contains(snitch)) {
          inList.add(snitch);
          for (Player remoteplayer : playerManager.getPlayers()) {
            String remoteName = remoteplayer.getName();
            if (isOnSnitch(snitch, remoteName)) {
              remoteplayer.sendMessage(
                  ChatColor.AQUA
                      + " * "
                      + playerName
                      + " entered snitch at "
                      + snitch.getName()
                      + " ["
                      + snitch.getX()
                      + " "
                      + snitch.getY()
                      + " "
                      + snitch.getZ()
                      + "]");
            }
          }
          plugin.getJaLogger().logSnitchEntry(snitch, location, player);
        }
      }
    }
    Set<Snitch> rmList = new TreeSet<Snitch>();
    for (Snitch snitch : inList) {
      if (snitches.contains(snitch)) {
        continue;
      }
      rmList.add(snitch);
    }
    inList.removeAll(rmList);
  }
示例#5
0
  public static void drop(Player p) {
    Location loc = new Location(Bukkit.getWorld("world"), 0, 0, 0);
    Random rand = new Random();
    loc.setX(rand.nextInt(8000));
    loc.setY(100);
    loc.setZ(rand.nextInt(8000));
    loc.setY(Bukkit.getWorld("world").getHighestBlockAt(loc.getBlockX(), loc.getBlockZ()).getY());
    loc.getBlock().setType(Material.CHEST);
    Block bb = loc.getBlock();
    bb.setType(Material.CHEST);
    Chest chest = (Chest) bb.getState();

    Inventory inv = chest.getInventory();

    for (ItemStack stack : items) {
      inv.addItem(stack);
    }

    Bukkit.broadcastMessage(
        ChatColor.RED + "A tornado has appeared in the world, and left valuble supplies!");
    Bukkit.broadcastMessage(
        ChatColor.translateAlternateColorCodes(
            '&',
            "&7Coords: X: &c"
                + loc.getBlockX()
                + "&7 Y:&c "
                + loc.getBlockY()
                + "&7 Z: &c"
                + loc.getBlockZ()));
  }
  public void createArenaFromSelection(Player pl, String name) {
    FileConfiguration c = SettingsManager.getInstance().getSystemConfig();
    // SettingsManager s = SettingsManager.getInstance();

    WorldEditPlugin we = p.getWorldEdit();
    Selection sel = we.getSelection(pl);
    if (sel == null) {
      Message.send(pl, ChatColor.RED + "You must make a WorldEdit Selection first!");
      return;
    }
    Location max = sel.getMaximumPoint();
    Location min = sel.getMinimumPoint();

    /* if(max.getWorld()!=SettingsManager.getGameWorld() || min.getWorld()!=SettingsManager.getGameWorld()){
    	Message.send(pl, ChatColor.RED+"Wrong World!");
    	return;
    }*/
    SettingsManager.getInstance().getSpawns().set(("spawns." + name), null);
    c.set("system.arenas." + name + ".world", max.getWorld().getName());
    c.set("system.arenas." + name + ".x1", max.getBlockX());
    c.set("system.arenas." + name + ".y1", max.getBlockY());
    c.set("system.arenas." + name + ".z1", max.getBlockZ());
    c.set("system.arenas." + name + ".x2", min.getBlockX());
    c.set("system.arenas." + name + ".y2", min.getBlockY());
    c.set("system.arenas." + name + ".z2", min.getBlockZ());
    c.set("system.arenas." + name + ".enabled", false);
    c.set("system.arenas." + name + ".min", 3);
    c.set("system.arenas." + name + ".max", 4);
    SettingsManager.getInstance().saveSystemConfig();
    hotAddArena(name);
    Message.send(pl, ChatColor.GREEN + "Arena " + name.toUpperCase() + " succesfully added");
  }
 @EventHandler(priority = EventPriority.MONITOR)
 public void onEntityExplode(EntityExplodeEvent event) {
   for (Block block : event.blockList()) {
     for (Player player : Bukkit.getOnlinePlayers()) {
       Location location = block.getLocation();
       location.setY(location.getY() + 1);
       Location playerLoc = player.getLocation();
       if (playerLoc.getBlockX() == location.getBlockX()
           && playerLoc.getBlockY() == location.getBlockY()
           && playerLoc.getBlockZ() == location.getBlockZ()) {
         OfflinePlayer damager =
             (TntTracker.getWhoPlaced(event.getEntity()) != null
                 ? Bukkit.getOfflinePlayer(TntTracker.getWhoPlaced(event.getEntity()))
                 : null);
         Bukkit.getServer()
             .getPluginManager()
             .callEvent(
                 new TrackerSpleefEvent(
                     player,
                     damager,
                     (damager != null && damager.isOnline()
                         ? ((Player) damager).getItemInHand()
                         : null),
                     Type.TNT));
       }
     }
   }
 }
示例#8
0
  public void loopThrough(Location loc1, Location loc2, World w) {

    File file = new File("plugins/NerdLocker/blocks.lock");
    if (!(file.exists())) {
      try {
        FileInputStream fstream = new FileInputStream("plugins/NerdLocker/blocks.lock");
        fstream.close();
      } catch (IOException e) {
        e.printStackTrace();
      }
    }

    int minx = Math.min(loc1.getBlockX(), loc2.getBlockX()),
        miny = Math.min(loc1.getBlockY(), loc2.getBlockY()),
        minz = Math.min(loc1.getBlockZ(), loc2.getBlockZ()),
        maxx = Math.max(loc1.getBlockX(), loc2.getBlockX()),
        maxy = Math.max(loc1.getBlockY(), loc2.getBlockY()),
        maxz = Math.max(loc1.getBlockZ(), loc2.getBlockZ());
    for (int x = minx; x <= maxx; x++) {
      for (int y = miny; y <= maxy; y++) {
        for (int z = minz; z <= maxz; z++) {
          Block b = w.getBlockAt(x, y, z);
          if (b.getTypeId() != 0) {
            addBlock(b);
          }
        }
      }
    }
  }
示例#9
0
 private String coordLine(Location coord, Location from) {
   return (coord.getBlockX() - from.getBlockX())
       + " "
       + (coord.getBlockY() - from.getBlockY())
       + " "
       + (coord.getBlockZ() - from.getBlockZ());
 }
示例#10
0
 public void remShelf(Location loc) {
   Shelf shelf = null;
   for (int i = 0; i < shelves.size(); i++) {
     Location key = (Location) shelves.keySet().toArray()[i];
     if (key.getBlockX() == loc.getBlockX()
         && key.getBlockY() == loc.getBlockY()
         && key.getBlockZ() == loc.getBlockZ()
         && key.getWorld().getName().equals(loc.getWorld().getName())) {
       shelf = shelves.get(key);
       break;
     }
   }
   if (shelf != null) {
     shelves.remove(shelf.getLocation());
     getFile()
         .remove(
             loc.getWorld().getName()
                 + ","
                 + loc.getBlockX()
                 + ","
                 + loc.getBlockY()
                 + ","
                 + loc.getBlockZ());
     saveFile();
   }
 }
示例#11
0
 public boolean isOutsideBorder(int border) {
   Location l = player.getLocation();
   return l.getBlockX() > border
       || l.getBlockZ() > border
       || l.getBlockX() < -border
       || l.getBlockZ() < -border;
 }
 @SuppressWarnings("deprecation")
 public void UpdateBarrier(Barrier barrier) {
   CustomConfig conf = plugin.configManager.getConfig("ArenaConfig");
   if (game.mode == ArenaStatus.DISABLED || game.mode == ArenaStatus.WAITING) {
     boolean same = false;
     for (Barrier b : barriers) {
       if (b.getLocation().equals(b.getLocation())) {
         same = true;
       }
     }
     if (!same) {
       Location loc = barrier.getLocation();
       Location loc2 = barrier.getRepairLoc();
       SpawnPoint sp = barrier.getSpawnPoint();
       int name = barrier.getNum();
       conf.set(game.getName() + ".Barriers." + name + ".x", loc.getBlockX());
       conf.set(game.getName() + ".Barriers." + name + ".y", loc.getBlockY());
       conf.set(game.getName() + ".Barriers." + name + ".z", loc.getBlockZ());
       conf.set(game.getName() + ".Barriers." + name + ".rx", loc2.getBlockX());
       conf.set(game.getName() + ".Barriers." + name + ".ry", loc2.getBlockY());
       conf.set(game.getName() + ".Barriers." + name + ".rz", loc2.getBlockZ());
       conf.set(game.getName() + ".Barriers." + name + ".sp", sp.getNumber());
       conf.set(game.getName() + ".Barriers." + name + ".bb", barrier.getBlock().getTypeId());
       conf.set(game.getName() + ".Barriers." + name + ".reward", barrier.getReward());
       conf.saveConfig();
       barriers.add(barrier);
     }
   }
 }
示例#13
0
  public static void fillmiddleroad(final AthionPlot plot1, final AthionPlot plot2, final World w) {
    final Location bottomPlot1 = getPlotBottomLoc(w, plot1.id);
    final Location topPlot1 = getPlotTopLoc(w, plot1.id);
    final Location bottomPlot2 = getPlotBottomLoc(w, plot2.id);
    final Location topPlot2 = getPlotTopLoc(w, plot2.id);

    int minX;
    int maxX;
    int minZ;
    int maxZ;

    final AthionMaps pmi = getMap(w);
    final int h = pmi.RoadHeight;
    final int fillId = pmi.PlotFloorBlockId;

    minX = Math.min(topPlot1.getBlockX(), topPlot2.getBlockX());
    maxX = Math.max(bottomPlot1.getBlockX(), bottomPlot2.getBlockX());

    minZ = Math.min(topPlot1.getBlockZ(), topPlot2.getBlockZ());
    maxZ = Math.max(bottomPlot1.getBlockZ(), bottomPlot2.getBlockZ());

    for (int x = minX; x <= maxX; x++) {
      for (int z = minZ; z <= maxZ; z++) {
        for (int y = h; y < w.getMaxHeight(); y++) {
          if (y >= (h + 1)) {
            w.getBlockAt(x, y, z).setType(Material.AIR);
          } else {
            w.getBlockAt(x, y, z).setTypeId(fillId);
          }
        }
      }
    }
  }
示例#14
0
 public void createMap(String id, Player p) throws EmptyClipboardException {
   Selection sel = WorldEditUtilities.getWorldEdit().getSelection(p);
   if (sel != null) {
     MapConfiguration.getMaps().reloadMap(id);
     Location b1 =
         new Location(
             p.getWorld(),
             sel.getNativeMinimumPoint().getBlockX(),
             sel.getNativeMinimumPoint().getBlockY(),
             sel.getNativeMinimumPoint().getBlockZ());
     Location b2 =
         new Location(
             p.getWorld(),
             sel.getNativeMaximumPoint().getBlockX(),
             sel.getNativeMaximumPoint().getBlockY(),
             sel.getNativeMaximumPoint().getBlockZ());
     MapConfiguration.getMaps().getMap(id).set("region.p1.w", b1.getWorld().getName());
     MapConfiguration.getMaps().getMap(id).set("region.p1.x", b1.getBlockX());
     MapConfiguration.getMaps().getMap(id).set("region.p1.y", b1.getBlockY());
     MapConfiguration.getMaps().getMap(id).set("region.p1.z", b1.getBlockZ());
     MapConfiguration.getMaps().getMap(id).set("region.p2.w", b2.getWorld().getName());
     MapConfiguration.getMaps().getMap(id).set("region.p2.x", b2.getBlockX());
     MapConfiguration.getMaps().getMap(id).set("region.p2.y", b2.getBlockY());
     MapConfiguration.getMaps().getMap(id).set("region.p2.z", b2.getBlockZ());
     MapConfiguration.getMaps().saveMap(id);
     List<String> enabled =
         DataConfiguration.getData().getDataFile().getStringList("enabled-maps");
     enabled.add(id);
     DataConfiguration.getData().getDataFile().set("enabled-maps", enabled);
     DataConfiguration.getData().saveData();
   } else {
     throw new EmptyClipboardException();
   }
 }
示例#15
0
 /**
  * Get the Chesspresso square index of the given location
  *
  * @param loc desired location
  * @return the square index, or Chess.NO_SQUARE if not on the board
  */
 int getSquareAt(Location loc) {
   if (!areaBoard.contains(loc)) {
     return Chess.NO_SQUARE;
   }
   int row = 0, col = 0;
   switch (rotation) {
     case NORTH:
       row = 7 - ((loc.getBlockX() - areaBoard.getLowerX()) / boardStyle.getSquareSize());
       col = 7 - ((loc.getBlockZ() - areaBoard.getLowerZ()) / boardStyle.getSquareSize());
       break;
     case EAST:
       row = 7 - ((loc.getBlockZ() - areaBoard.getLowerZ()) / boardStyle.getSquareSize());
       col = -((areaBoard.getLowerX() - loc.getBlockX()) / boardStyle.getSquareSize());
       break;
     case SOUTH:
       row = -((areaBoard.getLowerX() - loc.getBlockX()) / boardStyle.getSquareSize());
       col = -((areaBoard.getLowerZ() - loc.getBlockZ()) / boardStyle.getSquareSize());
       break;
     case WEST:
       row = -((areaBoard.getLowerZ() - loc.getBlockZ()) / boardStyle.getSquareSize());
       col = 7 - ((loc.getBlockX() - areaBoard.getLowerX()) / boardStyle.getSquareSize());
       break;
   }
   return Chess.coorToSqi(col, row);
 }
示例#16
0
  @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
  public void BlockBreakEvent(BlockBreakEvent e) {

    if (e.getBlock().hasMetadata("ce.Ice")) e.setCancelled(true);

    CEventHandler.handleEvent(e.getPlayer(), e, blockBroken);
    if (e.getBlock().hasMetadata("ce.mine")) {
      Block b = e.getBlock();
      b.removeMetadata("ce.mine", Main.plugin);
      Block[] blocks = {
        b.getRelative(0, 1, 0),
        b.getRelative(1, 0, 0),
        b.getRelative(-1, 0, 0),
        b.getRelative(0, 0, 1),
        b.getRelative(0, 0, -1)
      };

      for (Block block : blocks) {
        if (block.hasMetadata("ce.mine.secondary")) {
          String[] s = block.getMetadata("ce.mine.secondary").get(0).asString().split(" ");
          Location loc =
              new Location(
                  e.getPlayer().getWorld(),
                  Integer.parseInt(s[0]),
                  Integer.parseInt(s[1]),
                  Integer.parseInt(s[2]));
          Location blockLoc = b.getLocation();
          if (loc.getBlockX() == blockLoc.getBlockX()
              && loc.getBlockY() == blockLoc.getBlockY()
              && loc.getBlockZ() == blockLoc.getBlockZ())
            block.removeMetadata("ce.mine.secondary", Main.plugin);
        }
      }
    }
  }
示例#17
0
 public boolean isInLocation(Location loc) {
   for (Location locs : location) {
     if (locs.getBlockX() == loc.getBlockX() && locs.getBlockZ() == loc.getBlockZ()) {
       return true;
     }
   }
   return false;
 }
  public static CompassDirection getDirection(final Location loc1, final Location loc2) {
    if ((loc1.getBlockX() - loc2.getBlockX()) > 0) return CompassDirection.WEST;
    if ((loc1.getBlockX() - loc2.getBlockX()) < 0) return CompassDirection.EAST;
    if ((loc1.getBlockZ() - loc2.getBlockZ()) > 0) return CompassDirection.NORTH;
    if ((loc1.getBlockZ() - loc2.getBlockZ()) < 0) return CompassDirection.SOUTH;

    return CompassDirection.NO_DIRECTION;
  }
示例#19
0
 public boolean isInBorder(Location center, Location notCenter, int range) {
   int x = center.getBlockX(), z = center.getBlockZ();
   int x1 = notCenter.getBlockX(), z1 = notCenter.getBlockZ();
   if (x1 >= (x + range) || z1 >= (z + range) || x1 <= (x - range) || z1 <= (z - range)) {
     return false;
   }
   return true;
 }
示例#20
0
  @EventHandler(priority = EventPriority.NORMAL)
  public void grapple(ProjectileHitEvent event) {
    Entity proj = event.getEntity();
    Location hit = proj.getLocation();

    if (!event.getEntity().getWorld().getName().equals(getName())) return;

    if (proj instanceof Snowball) {
      Snowball fish = (Snowball) proj;
      ProjectileSource shooter = (ProjectileSource) fish.getShooter();
      if (shooter instanceof Player) {
        Player player = (Player) shooter;
        Location location = player.getLocation();
        ItemStack itemStack = player.getItemInHand();
        Material material = itemStack.getType();

        if (material == Material.FISHING_ROD) {

          player.setFallDistance(0);
          player.playSound(location, Sound.ARROW_HIT, 1, 1);

          int hitx = hit.getBlockX();
          int hity = hit.getBlockY();
          int hitz = hit.getBlockZ();
          int locx = location.getBlockX();
          int locy = location.getBlockY();
          int locz = location.getBlockZ();
          double co[] = new double[3];

          if (hitx > locx) {
            co[0] = 1.2;
          } else if (hitx < locx) {
            co[0] = -1.2;
          } else if (hitx == locx) {
            co[0] = 0;
          }

          if (hity > locy) {
            co[1] = 1.4;
          } else if (hity < locy) {
            co[1] = -0.8;
          } else if (hity == locy) {
            co[1] = 0;
          }

          if (hitz > locz) {
            co[2] = 1.2;
          } else if (hitz < locz) {
            co[2] = -1.2;
          } else if (hitz == locz) {
            co[2] = 0;
          }

          player.setVelocity(new Vector(co[0], co[1] / 1.25, co[2]));
        }
      }
    }
  }
示例#21
0
 public boolean inIslandSpace(int x, int z) {
   if (x >= center.getBlockX() - islandDistance / 2
       && x < center.getBlockX() + islandDistance / 2
       && z >= center.getBlockZ() - islandDistance / 2
       && z < center.getBlockZ() + islandDistance / 2) {
     return true;
   }
   return false;
 }
示例#22
0
 private static int[] area(Location firstPoint, Location secndPoint) {
   return new int[] {
     Math.min(firstPoint.getBlockX(), secndPoint.getBlockX()),
     Math.max(firstPoint.getBlockX(), secndPoint.getBlockX()),
     Math.min(firstPoint.getBlockY(), secndPoint.getBlockY()),
     Math.max(firstPoint.getBlockY(), secndPoint.getBlockY()),
     Math.min(firstPoint.getBlockZ(), secndPoint.getBlockZ()),
     Math.max(firstPoint.getBlockZ(), secndPoint.getBlockZ()),
   };
 }
示例#23
0
  public static void highlightRegion(Player player, NovaRegion region) {
    Location loc1 = region.getCorner(0).clone();
    Location loc2 = region.getCorner(1).clone();

    loc1.setY(player.getWorld().getHighestBlockAt(loc1.getBlockX(), loc1.getBlockZ()).getY() - 1);
    loc2.setY(player.getWorld().getHighestBlockAt(loc2.getBlockX(), loc2.getBlockZ()).getY() - 1);

    setCorner(player, loc1, Material.DIAMOND_BLOCK);
    setCorner(player, loc2, Material.DIAMOND_BLOCK);
  }
示例#24
0
  public void playNote(Location loc, byte instrument, byte note) {
    if (getHandle().playerNetServerHandler == null) return;

    int id = getHandle().worldObj.getBlockId(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
    getHandle()
        .playerNetServerHandler
        .sendPacketToPlayer(
            new Packet54PlayNoteBlock(
                loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), id, instrument, note));
  }
示例#25
0
  public static void resetHighlightRegion(Player player, NovaRegion region) {
    Location loc1 = region.getCorner(0).clone();
    Location loc2 = region.getCorner(1).clone();

    loc1.setY(player.getWorld().getHighestBlockAt(loc1.getBlockX(), loc1.getBlockZ()).getY() - 1);
    loc2.setY(player.getWorld().getHighestBlockAt(loc2.getBlockX(), loc2.getBlockZ()).getY() - 1);

    setCorner(player, loc1, loc1.getBlock().getType());
    setCorner(player, loc2, loc2.getBlock().getType());
  }
示例#26
0
  public void playNote(Location loc, byte instrument, byte note) {
    if (getHandle().field_71135_a == null) return;

    int id =
        getHandle().field_70170_p.func_72798_a(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
    getHandle()
        .field_71135_a
        .func_72567_b(
            new net.minecraft.network.packet.Packet54PlayNoteBlock(
                loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), id, instrument, note));
  }
示例#27
0
  public MonumentBlock getBlock(Location location) {
    for (MonumentBlock block : getBlocks()) {
      Location loc = block.getLocation();
      boolean x = loc.getBlockX() == location.getBlockX();
      boolean y = loc.getBlockY() == location.getBlockY();
      boolean z = loc.getBlockZ() == location.getBlockZ();
      if (x && y && z) return block;
    }

    return null;
  }
示例#28
0
 public List<Block> getBlocks() {
   List<Block> blocks = new ArrayList<Block>();
   for (int x = minLoc.getBlockX(); x < maxLoc.getBlockX() + 1; x++) {
     for (int y = minLoc.getBlockY(); y < maxLoc.getBlockY() + 1; y++) {
       for (int z = minLoc.getBlockZ(); z < maxLoc.getBlockZ() + 1; z++) {
         blocks.add(minLoc.getWorld().getBlockAt(new Location(minLoc.getWorld(), x, y, z)));
       }
     }
   }
   return blocks;
 }
示例#29
0
 /**
  * Organizes locations and gets least x,z and most x,z locations: Does not organize by sum of
  * coords but by whether or not the coord checked is greater in both the x and the z
  *
  * @param locs All locations to compare
  * @return Organized locations as {least, greatest}
  */
 public static Location[] organizeXZ(Location... locs) {
   Location greatest = locs[0];
   Location least = locs[0];
   for (Location loc : locs) {
     if (loc.getBlockX() > greatest.getBlockX() && loc.getBlockZ() > greatest.getBlockZ())
       greatest = loc;
     else if (loc.getBlockX() < greatest.getBlockX() && loc.getBlockZ() < greatest.getBlockZ())
       least = loc;
   }
   Location[] returnLoc = {least, greatest};
   return returnLoc;
 }
示例#30
0
 public Shelf getShelf(Location loc) {
   for (int i = 0; i < shelves.size(); i++) {
     Location key = (Location) shelves.keySet().toArray()[i];
     if (key.getBlockX() == loc.getBlockX()
         && key.getBlockY() == loc.getBlockY()
         && key.getBlockZ() == loc.getBlockZ()
         && key.getWorld().getName().equals(loc.getWorld().getName())) {
       return shelves.get(key);
     }
   }
   return null;
 }