コード例 #1
0
  /**
   * @param player
   * @param field
   */
  public void addFieldMark(Player player, Field field) {
    Visualization vis = visualizations.get(player.getName());

    if (vis == null) {
      vis = new Visualization();
    }

    vis.addField(field);

    World world = plugin.getServer().getWorld(field.getWorld());

    if (world != null) {
      for (int y = 0; y < 256; y++) {
        int typeId = world.getBlockTypeIdAt(field.getX(), y, field.getZ());

        if (plugin.getSettingsManager().isThroughType(typeId)) {
          vis.addBlock(
              new Location(world, field.getX(), y, field.getZ()),
              plugin.getSettingsManager().getVisualizeMarkBlock(),
              (byte) 0);
        }
      }
    }

    visualizations.put(player.getName(), vis);
  }
コード例 #2
0
  /**
   * Revert a single a visualized block to the player
   *
   * @param player
   * @param block
   */
  public void revertSingle(Player player, Block block) {
    Visualization vis = visualizations.get(player.getName());

    if (vis == null) {
      vis = new Visualization();
    }

    vis.addBlock(block);
    visualizations.put(player.getName(), vis);

    player.sendBlockChange(block.getLocation(), block.getType(), (byte) 0);
  }
コード例 #3
0
  /**
   * Adds and displays a visualized block to the player
   *
   * @param player
   * @param material
   * @param block
   */
  public void displaySingle(Player player, Material material, Block block) {
    Visualization vis = visualizations.get(player.getName());

    if (vis == null) {
      vis = new Visualization();
    }

    vis.addBlock(block);
    visualizations.put(player.getName(), vis);

    player.sendBlockChange(block.getLocation(), material, (byte) 0);
  }
コード例 #4
0
  /**
   * Adds a fields perimeter to a player's visualization buffer
   *
   * @param player
   * @param field
   */
  public void addVisualizationField(Player player, Field field) {
    Visualization vis = visualizations.get(player.getName());

    if (vis == null) {
      vis = new Visualization();
    }

    if (plugin.getCuboidManager().hasOpenCuboid(player)) {
      return;
    }

    PlayerEntry data = plugin.getPlayerManager().getPlayerEntry(player.getName());

    if (data.getDensity() == 0) {
      return;
    }

    vis.addField(field);

    int visualizationType =
        field.hasFlag(FieldFlag.CUBOID)
            ? plugin.getSettingsManager().getCuboidVisualizationType()
            : plugin.getSettingsManager().getVisualizeBlock();
    int frameType = plugin.getSettingsManager().getVisualizeFrameBlock();

    int minx = field.getX() - field.getRadius() - 1;
    int maxx = field.getX() + field.getRadius() + 1;
    int minz = field.getZ() - field.getRadius() - 1;
    int maxz = field.getZ() + field.getRadius() + 1;
    int miny = field.getY() - (Math.max(field.getHeight() - 1, 0) / 2) - 1;
    int maxy = field.getY() + (Math.max(field.getHeight() - 1, 0) / 2) + 1;

    if (field.hasFlag(FieldFlag.CUBOID)) {
      minx = field.getMinx() - 1;
      maxx = field.getMaxx() + 1;
      minz = field.getMinz() - 1;
      maxz = field.getMaxz() + 1;
      miny = field.getMiny() - 1;
      maxy = field.getMaxy() + 1;
    }

    Location loc = null;

    for (int x = minx; x <= maxx; x++) {
      int frame = (x == minx || x == maxx) ? 89 : frameType;

      loc = new Location(player.getWorld(), x, miny, maxz);
      if (Helper.isAirOrWater(loc)) {
        vis.addBlock(loc, frame, (byte) 0);
      }

      loc = new Location(player.getWorld(), x, maxy, minz);
      if (Helper.isAirOrWater(loc)) {
        vis.addBlock(loc, frame, (byte) 0);
      }

      loc = new Location(player.getWorld(), x, miny, minz);
      if (Helper.isAirOrWater(loc)) {
        vis.addBlock(loc, frame, (byte) 0);
      }

      loc = new Location(player.getWorld(), x, maxy, maxz);
      if (Helper.isAirOrWater(loc)) {
        vis.addBlock(loc, frame, (byte) 0);
      }
    }

    for (int y = miny; y <= maxy; y++) {
      loc = new Location(player.getWorld(), minx, y, maxz);
      if (Helper.isAirOrWater(loc)) {
        vis.addBlock(loc, 89, (byte) 0);
      }

      loc = new Location(player.getWorld(), maxx, y, minz);
      if (Helper.isAirOrWater(loc)) {
        vis.addBlock(loc, 89, (byte) 0);
      }

      loc = new Location(player.getWorld(), minx, y, minz);
      if (Helper.isAirOrWater(loc)) {
        vis.addBlock(loc, 89, (byte) 0);
      }

      loc = new Location(player.getWorld(), maxx, y, maxz);
      if (Helper.isAirOrWater(loc)) {
        vis.addBlock(loc, 89, (byte) 0);
      }
    }

    for (int z = minz; z <= maxz; z++) {
      int frame = (z == minz || z == maxz) ? 89 : frameType;

      loc = new Location(player.getWorld(), minx, maxy, z);
      if (Helper.isAirOrWater(loc)) {
        vis.addBlock(loc, frame, (byte) 0);
      }

      loc = new Location(player.getWorld(), maxx, miny, z);
      if (Helper.isAirOrWater(loc)) {
        vis.addBlock(loc, frame, (byte) 0);
      }

      loc = new Location(player.getWorld(), minx, miny, z);
      if (Helper.isAirOrWater(loc)) {
        vis.addBlock(loc, frame, (byte) 0);
      }

      loc = new Location(player.getWorld(), maxx, maxy, z);
      if (Helper.isAirOrWater(loc)) {
        vis.addBlock(loc, frame, (byte) 0);
      }
    }

    visualizations.put(player.getName(), vis);
  }