Package org.bukkit.block

Examples of org.bukkit.block.Block


    }
  }

  public void placeSoutheast() {
    Warzone warzone = War.war.findWarzone(this.zoneName);
    Block southeastBlock = this.player.getLocation().getWorld().getBlockAt(this.player.getLocation());
    StringBuilder msgString = new StringBuilder();
    try {
      if (warzone == null && War.war.getWarzones().size() >= War.war.getWarConfig().getInt(WarConfig.MAXZONES)) {
        // max warzones reached
        War.war.badMsg(player, "Too many warzones already! To change the maximum, use /warcfg maxzone:20.");
        return;
      } else if (warzone == null) {
        // create the warzone
        warzone = new Warzone(this.player.getLocation().getWorld(), this.zoneName);
        warzone.addAuthor(player.getName());
        War.war.getIncompleteZones().add(warzone);
        warzone.getVolume().setSoutheast(southeastBlock.getLocation());
        War.war.msg(this.player, "Warzone " + warzone.getName() + " created. Southeasternmost point set to x:" + warzone.getVolume().getSoutheastX() + " z:" + warzone.getVolume().getSoutheastZ() + ". ");
        War.war.log(player.getName() + " created warzone " + zoneName + " by setting its se corner", Level.INFO);
      } else if (!this.isPlayerAuthorOfZoneOrAdmin(warzone)) {
        return;
      } else {
        // change existing warzone
        this.resetWarzone(warzone, msgString);
        warzone.getVolume().setSoutheast(southeastBlock.getLocation());
        msgString.append("Warzone " + warzone.getName() + " modified. Southeasternmost point set to x:" + warzone.getVolume().getSoutheastX() + " z:" + warzone.getVolume().getSoutheastZ() + ". ");
        War.war.log(player.getName() + " updated warzone " + zoneName + " by setting its se corner", Level.INFO);
      }
      this.saveIfReady(warzone, msgString);
    } catch (NotSoutheastException e) {
View Full Code Here


      }
    }
  }

  public void placeCorner1() {
    Block corner1Block = this.player.getLocation().getWorld().getBlockAt(this.player.getLocation());
    this.placeCorner1(corner1Block);
  }
View Full Code Here

      }
    }
  }

  public void placeCorner2() {
    Block corner2Block = this.player.getLocation().getWorld().getBlockAt(this.player.getLocation());
    this.placeCorner2(corner2Block);
  }
View Full Code Here

  public static int load(Connection databaseConnection, ZoneVolume volume, World world, boolean onlyLoadCorners, int start, int total, boolean[][][] changes) throws SQLException {
    Validate.isTrue(!databaseConnection.isClosed());
    Statement stmt = databaseConnection.createStatement();
    ResultSet cornerQuery = stmt.executeQuery("SELECT * FROM corners");
    cornerQuery.next();
    final Block corner1 = world.getBlockAt(cornerQuery.getInt("x"), cornerQuery.getInt("y"), cornerQuery.getInt("z"));
    cornerQuery.next();
    final Block corner2 = world.getBlockAt(cornerQuery.getInt("x"), cornerQuery.getInt("y"), cornerQuery.getInt("z"));
    cornerQuery.close();
    volume.setCornerOne(corner1);
    volume.setCornerTwo(corner2);
    if (onlyLoadCorners) {
      stmt.close();
      return 0;
    }
    int minX = volume.getMinX(), minY = volume.getMinY(), minZ = volume.getMinZ();
    int changed = 0;
    ResultSet query = stmt.executeQuery("SELECT * FROM blocks ORDER BY rowid LIMIT " + start + ", " + total);
    while (query.next()) {
      int x = query.getInt("x"), y = query.getInt("y"), z = query.getInt("z");
      changed++;
      Block relative = corner1.getRelative(x, y, z);
      int xi = relative.getX() - minX, yi = relative.getY() - minY, zi = relative.getZ() - minZ;
      if (changes != null) {
        changes[xi][yi][zi] = true;
      }
      BlockState modify = relative.getState();
      ItemStack data = new ItemStack(Material.valueOf(query.getString("type")), 0, query.getShort("data"));
      if (modify.getType() != data.getType() || !modify.getData().equals(data.getData())) {
        // Update the type & data if it has changed
        modify.setType(data.getType());
        modify.setData(data.getData());
View Full Code Here

    World world = volume.getWorld();
    Validate.notNull(world, String.format("Cannot find the warzone for %s", prefix));
    Statement stmt = databaseConnection.createStatement();
    ResultSet cornerQuery = stmt.executeQuery("SELECT * FROM " + prefix + "_corners");
    cornerQuery.next();
    final Block corner1 = world.getBlockAt(cornerQuery.getInt("x"), cornerQuery.getInt("y"), cornerQuery.getInt("z"));
    cornerQuery.next();
    final Block corner2 = world.getBlockAt(cornerQuery.getInt("x"), cornerQuery.getInt("y"), cornerQuery.getInt("z"));
    cornerQuery.close();
    volume.setCornerOne(corner1);
    volume.setCornerTwo(corner2);
    volume.getBlocks().clear();
    ResultSet query = stmt.executeQuery("SELECT * FROM " + prefix + "_blocks");
View Full Code Here

    final int batchSize = 10000;
    for (int i = 0, x = volume.getMinX(); i < volume.getSizeX(); i++, x++) {
      for (int j = 0, y = volume.getMinY(); j < volume.getSizeY(); j++, y++) {
        for (int k = 0, z = volume.getMinZ(); k < volume.getSizeZ(); k++, z++) {
          // Make sure we are using zone volume-relative coords
          final Block block = volume.getWorld().getBlockAt(x, y, z);
          if (block.getType() == Material.AIR) {
            continue; // Do not save air blocks to the file anymore.
          }
          final BlockState state = block.getState();
          dataStmt.setInt(1, block.getX() - volume.getCornerOne().getBlockX());
          dataStmt.setInt(2, block.getY() - volume.getCornerOne().getBlockY());
          dataStmt.setInt(3, block.getZ() - volume.getCornerOne().getBlockZ());
          dataStmt.setString(4, block.getType().name());
          dataStmt.setShort(5, state.getData().toItemStack().getDurability());
          if (state instanceof Sign) {
            final String signText = StringUtils.join(((Sign) block.getState()).getLines(), "\n");
            dataStmt.setString(6, signText);
          } else if (state instanceof InventoryHolder) {
            List<ItemStack> items = Arrays.asList(((InventoryHolder) block.getState()).getInventory().getContents());
            YamlConfiguration config = new YamlConfiguration();
            // Serialize to config, then store config in database
            config.set("items", items);
            dataStmt.setString(6, config.saveToString());
          } else if (state instanceof NoteBlock) {
            Note note = ((NoteBlock) block.getState()).getNote();
            dataStmt.setString(6, note.getTone().toString() + '\n' + note.getOctave() + '\n' + note.isSharped());
          } else if (state instanceof Jukebox) {
            dataStmt.setString(6, ((Jukebox) block.getState()).getPlaying().toString());
          } else if (state instanceof Skull) {
            dataStmt.setString(6, String.format("%s\n%s\n%s",
                ((Skull) block.getState()).hasOwner() ? ((Skull) block.getState()).getOwner() : "",
                ((Skull) block.getState()).getSkullType().toString(),
                ((Skull) block.getState()).getRotation().toString()));
          } else if (state instanceof CommandBlock) {
            dataStmt.setString(6, ((CommandBlock) block.getState()).getName()
                + "\n" + ((CommandBlock) block.getState()).getCommand());
          } else if (state instanceof CreatureSpawner) {
            dataStmt.setString(6, ((CreatureSpawner) block.getState()).getSpawnedType().toString());
          }
         
          dataStmt.addBatch();
         
          if (++changed % batchSize == 0) {
View Full Code Here

  public String getName() {
    return this.name;
  }

  public void setLocation(Location location) {
    Block locationBlock = this.warzone.getWorld().getBlockAt(location.getBlockX(), location.getBlockY(), location.getBlockZ());
    this.volume.setCornerOne(locationBlock.getRelative(BlockFace.DOWN).getRelative(Direction.EAST(), 1).getRelative(Direction.SOUTH(), 1));
    this.volume.setCornerTwo(locationBlock.getRelative(BlockFace.UP, 2).getRelative(Direction.WEST(), 1).getRelative(Direction.NORTH(), 1));
    this.volume.saveBlocks();
    this.location = location;
    this.addBombBlocks();
  }
View Full Code Here

    if (teamSpawn.getYaw() >= 0) {
      yaw = (int) (teamSpawn.getYaw() % 360);
    } else {
      yaw = (int) (360 + (teamSpawn.getYaw() % 360));
    }
    Block signBlock = null;
    BlockFace signDirection = null;

    if (style.equals(TeamSpawnStyle.SMALL)) {
      // SMALL style
      if (yaw >= 0 && yaw < 90) {
        signDirection = BlockFace.SOUTH_WEST.getOppositeFace();
        signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getRelative(Direction.NORTH()).getRelative(Direction.WEST());
      } else if (yaw >= 90 && yaw <= 180) {
        signDirection = BlockFace.NORTH_WEST.getOppositeFace();
        signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getRelative(Direction.NORTH()).getRelative(Direction.EAST());
      } else if (yaw >= 180 && yaw < 270) {
        signDirection = BlockFace.NORTH_EAST.getOppositeFace();
        signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getRelative(Direction.SOUTH()).getRelative(Direction.EAST());
      } else if (yaw >= 270 && yaw <= 360) {
        signDirection = BlockFace.SOUTH_EAST.getOppositeFace();
        signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getRelative(Direction.SOUTH()).getRelative(Direction.WEST());
      }
    } else if (!style.equals(TeamSpawnStyle.INVISIBLE)) {
      // outer ring (FLAT or BIG)
      this.setBlock(x + 2, y - 1, z + 2, this.kind);
      this.setBlock(x + 2, y - 1, z + 1, this.kind);
      this.setBlock(x + 2, y - 1, z, this.kind);
      this.setBlock(x + 2, y - 1, z - 1, this.kind);
      this.setBlock(x + 2, y - 1, z - 2, this.kind);

      this.setBlock(x - 1, y - 1, z + 2, this.kind);
      this.setBlock(x - 1, y - 1, z - 2, this.kind);

      this.setBlock(x, y - 1, z + 2, this.kind);
      this.setBlock(x, y - 1, z - 2, this.kind);

      this.setBlock(x + 1, y - 1, z + 2, this.kind);
      this.setBlock(x + 1, y - 1, z - 2, this.kind);

      this.setBlock(x - 2, y - 1, z + 2, this.kind);
      this.setBlock(x - 2, y - 1, z + 1, this.kind);
      this.setBlock(x - 2, y - 1, z, this.kind);
      this.setBlock(x - 2, y - 1, z - 1, this.kind);
      this.setBlock(x - 2, y - 1, z - 2, this.kind);

      if (yaw >= 0 && yaw < 90) {
        signDirection = BlockFace.SOUTH_WEST.getOppositeFace();
        signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getRelative(Direction.NORTH(), 2).getRelative(Direction.WEST(), 2);

        if (style.equals(TeamSpawnStyle.BIG)) {
          // rim
          this.setBlock(x - 2, y, z - 1, this.kind);
          this.setBlock(x - 2, y, z - 2, this.kind);
          this.setBlock(x - 1, y, z - 2, this.kind);
          this.setBlock(x, y, z - 2, this.kind);
          this.setBlock(x + 1, y, z - 2, this.kind);
          this.setBlock(x + 2, y, z - 2, this.kind);
          this.setBlock(x + 2, y, z - 1, this.kind);
          this.setBlock(x + 2, y, z, this.kind);
          this.setBlock(x + 2, y, z + 1, this.kind);
          this.setBlock(x + 2, y, z + 2, this.kind);
          this.setBlock(x + 1, y, z + 2, this.kind);

          // tower
          this.setBlock(x, y + 1, z - 2, this.kind);
          this.setBlock(x + 1, y + 1, z - 2, this.kind);
          this.setBlock(x + 2, y + 1, z - 2, this.kind);
          this.setBlock(x + 2, y + 1, z - 1, this.kind);
          this.setBlock(x + 2, y + 1, z, this.kind);

          this.setBlock(x + 1, y + 2, z - 2, this.kind);
          this.setBlock(x + 2, y + 2, z - 2, this.kind);
          this.setBlock(x + 2, y + 2, z - 1, this.kind);

          this.setBlock(x + 2, y + 3, z - 2, this.kind);
        }
      } else if (yaw >= 90 && yaw <= 180) {
        signDirection = BlockFace.NORTH_WEST.getOppositeFace();
        signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getRelative(Direction.NORTH(), 2).getRelative(Direction.EAST(), 2);
        if (style.equals(TeamSpawnStyle.BIG)) {
          // rim
          this.setBlock(x + 1, y, z - 2, this.kind);
          this.setBlock(x + 2, y, z - 2, this.kind);
          this.setBlock(x + 2, y, z - 1, this.kind);
          this.setBlock(x + 2, y, z, this.kind);
          this.setBlock(x + 2, y, z + 1, this.kind);
          this.setBlock(x + 2, y, z + 2, this.kind);
          this.setBlock(x + 1, y, z + 2, this.kind);
          this.setBlock(x, y, z + 2, this.kind);
          this.setBlock(x - 1, y, z + 2, this.kind);
          this.setBlock(x - 2, y, z + 2, this.kind);
          this.setBlock(x - 2, y, z + 1, this.kind);

          // tower
          this.setBlock(x + 2, y + 1, z, this.kind);
          this.setBlock(x + 2, y + 1, z + 1, this.kind);
          this.setBlock(x + 2, y + 1, z + 2, this.kind);
          this.setBlock(x + 1, y + 1, z + 2, this.kind);
          this.setBlock(x, y + 1, z + 2, this.kind);

          this.setBlock(x + 2, y + 2, z + 1, this.kind);
          this.setBlock(x + 2, y + 2, z + 2, this.kind);
          this.setBlock(x + 1, y + 2, z + 2, this.kind);

          this.setBlock(x + 2, y + 3, z + 2, this.kind);
        }
      } else if (yaw >= 180 && yaw < 270) {
        signDirection = BlockFace.NORTH_EAST.getOppositeFace();
        signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getRelative(Direction.SOUTH(), 2).getRelative(Direction.EAST(), 2);
        if (style.equals(TeamSpawnStyle.BIG)) {
          // rim
          this.setBlock(x + 2, y, z + 1, this.kind);
          this.setBlock(x + 2, y, z + 2, this.kind);
          this.setBlock(x + 1, y, z + 2, this.kind);
          this.setBlock(x, y, z + 2, this.kind);
          this.setBlock(x - 1, y, z + 2, this.kind);
          this.setBlock(x - 2, y, z + 2, this.kind);
          this.setBlock(x - 2, y, z + 1, this.kind);
          this.setBlock(x - 2, y, z, this.kind);
          this.setBlock(x - 2, y, z - 1, this.kind);
          this.setBlock(x - 2, y, z - 2, this.kind);
          this.setBlock(x - 1, y, z - 2, this.kind);

          // tower
          this.setBlock(x, y + 1, z + 2, this.kind);
          this.setBlock(x - 1, y + 1, z + 2, this.kind);
          this.setBlock(x - 2, y + 1, z + 2, this.kind);
          this.setBlock(x - 2, y + 1, z + 1, this.kind);
          this.setBlock(x - 2, y + 1, z, this.kind);

          this.setBlock(x - 1, y + 2, z + 2, this.kind);
          this.setBlock(x - 2, y + 2, z + 2, this.kind);
          this.setBlock(x - 2, y + 2, z + 1, this.kind);

          this.setBlock(x - 2, y + 3, z + 2, this.kind);
        }
      } else if (yaw >= 270 && yaw <= 360) {
        signDirection = BlockFace.SOUTH_EAST.getOppositeFace();
        signBlock = this.warzone.getWorld().getBlockAt(x, y, z).getRelative(Direction.SOUTH(), 2).getRelative(Direction.WEST(), 2);
        if (style.equals(TeamSpawnStyle.BIG)) {
          // rim
          this.setBlock(x - 1, y, z + 2, this.kind);
          this.setBlock(x - 2, y, z + 2, this.kind);
          this.setBlock(x - 2, y, z + 1, this.kind);
          this.setBlock(x - 2, y, z, this.kind);
          this.setBlock(x - 2, y, z - 1, this.kind);
          this.setBlock(x - 2, y, z - 2, this.kind);
          this.setBlock(x - 1, y, z - 2, this.kind);
          this.setBlock(x, y, z - 2, this.kind);
          this.setBlock(x + 1, y, z - 2, this.kind);
          this.setBlock(x + 2, y, z - 2, this.kind);
          this.setBlock(x + 2, y, z - 1, this.kind);

          // tower
          this.setBlock(x - 2, y + 1, z, this.kind);
          this.setBlock(x - 2, y + 1, z - 1, this.kind);
          this.setBlock(x - 2, y + 1, z - 2, this.kind);
          this.setBlock(x - 1, y + 1, z - 2, this.kind);
          this.setBlock(x, y + 1, z - 2, this.kind);

          this.setBlock(x - 2, y + 2, z - 1, this.kind);
          this.setBlock(x - 2, y + 2, z - 2, this.kind);
          this.setBlock(x - 1, y + 2, z - 2, this.kind);

          this.setBlock(x - 2, y + 3, z - 2, this.kind);
        }
      }
    }

    if (signBlock != null) {
      String[] lines;
      if (this.getTeamConfig().resolveInt(TeamConfig.LIFEPOOL) == -1) {
        lines = MessageFormat
            .format(War.war.getString("sign.team.unlimited"),
                this.name,
                this.players.size(),
                this.getTeamConfig().resolveInt(
                    TeamConfig.TEAMSIZE),
                this.points,
                this.getTeamConfig().resolveInt(
                    TeamConfig.MAXSCORE)).split("\n");
      } else {
        lines = MessageFormat
            .format(War.war.getString("sign.team.limited"),
                this.name,
                this.players.size(),
                this.getTeamConfig().resolveInt(
                    TeamConfig.TEAMSIZE),
                this.points,
                this.getTeamConfig().resolveInt(
                    TeamConfig.MAXSCORE),
                this.remainingLives,
                this.getTeamConfig().resolveInt(
                    TeamConfig.LIFEPOOL)).split("\n");
      }
      signBlock.setType(Material.SIGN_POST);
      org.bukkit.block.Sign block = (org.bukkit.block.Sign) signBlock
          .getState();
      org.bukkit.material.Sign data = (Sign) block.getData();
      data.setFacingDirection(signDirection);
      block.setData(data);
      for (int i = 0; i < 4; i++) {
View Full Code Here

        // Run some update SQL for each old version
      }
    }
    ResultSet cornerQuery = stmt.executeQuery("SELECT * FROM corners");
    cornerQuery.next();
    final Block corner1 = world.getBlockAt(cornerQuery.getInt("x"), cornerQuery.getInt("y"), cornerQuery.getInt("z"));
    cornerQuery.next();
    final Block corner2 = world.getBlockAt(cornerQuery.getInt("x"), cornerQuery.getInt("y"), cornerQuery.getInt("z"));
    cornerQuery.close();
    volume.setCornerOne(corner1);
    volume.setCornerTwo(corner2);
    ResultSet query = stmt.executeQuery("SELECT * FROM blocks");
    while (query.next()) {
View Full Code Here

            return true;
       
        if (!arena.isRunning())
            return false;

        Block b = event.getBlock();
        if (arena.removeBlock(b) || b.getType() == Material.TNT)
            return true;
       
        if (softRestore) {
            if (arena.isProtected())
                return false;
           
            BlockState state = b.getState();
            Repairable r = null;
           
            if (state instanceof InventoryHolder)
                r = new RepairableContainer(state);
            else if (state instanceof Sign)
                r = new RepairableSign(state);
            else if (state.getData() instanceof Attachable)
                r = new RepairableAttachable(state);
            else
                r = new RepairableBlock(state);

            arena.addRepairable(r);
           
            if (!softRestoreDrops)
                b.setTypeId(0);
            return true;
        }

        return false;
    }
View Full Code Here

TOP

Related Classes of org.bukkit.block.Block

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.