public static boolean checkIfBlockBreaksSigns(final Block block) {
   final Block sign = block.getRelative(BlockFace.UP);
   if (sign.getType() == Material.SIGN_POST && isValidSign(new BlockSign(sign))) {
     return true;
   }
   final BlockFace[] directions =
       new BlockFace[] {BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST};
   for (BlockFace blockFace : directions) {
     final Block signblock = block.getRelative(blockFace);
     if (signblock.getType() == Material.WALL_SIGN) {
       final org.bukkit.material.Sign signMat =
           (org.bukkit.material.Sign) signblock.getState().getData();
       if (signMat.getFacing() == blockFace && isValidSign(new BlockSign(signblock))) {
         return true;
       }
     }
   }
   return false;
 }
Example #2
0
  /**
   * @param action_type
   * @param block
   * @param player
   */
  public void setBlock(Block block, String[] lines) {

    // Build an object for the specific details of this action
    actionData = new SignChangeActionData();

    if (block != null) {
      actionData.sign_type = block.getType().name();
      org.bukkit.material.Sign sign = (org.bukkit.material.Sign) block.getState().getData();
      actionData.facing = sign.getFacing();
      this.block = block;
      this.world_name = block.getWorld().getName();
      this.x = block.getX();
      this.y = block.getY();
      this.z = block.getZ();
    }
    if (lines != null) {
      actionData.lines = lines;
    }
  }
Example #3
0
  // RŽcupŽration du Relative et ajout du SignManager dans le Set
  public static boolean registerSign(Location locsign) {
    try {
      locsign.getBlock();
    } catch (Exception e) {
      return false;
    } // VŽrifie sur la locsign est un block

    if (!(locsign.getBlock().getState() instanceof org.bukkit.block.Sign)) return false;

    Block bs = locsign.getBlock();
    org.bukkit.material.Sign signmat = (org.bukkit.material.Sign) bs.getState().getData();
    Location relative = null;

    if (!signmat.isWallSign()) relative = bs.getRelative(BlockFace.DOWN).getLocation();
    else if (signmat.getAttachedFace() == BlockFace.EAST)
      relative = bs.getRelative(BlockFace.EAST).getLocation();
    else if (signmat.getAttachedFace() == BlockFace.WEST)
      relative = bs.getRelative(BlockFace.WEST).getLocation();
    else if (signmat.getAttachedFace() == BlockFace.NORTH)
      relative = bs.getRelative(BlockFace.NORTH).getLocation();
    else if (signmat.getAttachedFace() == BlockFace.SOUTH)
      relative = bs.getRelative(BlockFace.SOUTH).getLocation();

    SignManager sm = new SignManager(locsign, relative);
    sm.RefreshSign();
    return true;
  }
Example #4
0
  @Override
  public ChangeResult applyRestore(Player player, QueryParameters parameters, boolean is_preview) {

    Block block = getWorld().getBlockAt(getLoc());

    // Ensure a sign exists there (and no other block)
    if (block.getType().equals(Material.AIR)
        || block.getType().equals(Material.SIGN_POST)
        || block.getType().equals(Material.SIGN)
        || block.getType().equals(Material.WALL_SIGN)) {

      if (block.getType().equals(Material.AIR)) {
        block.setType(getSignType());
      }

      // Set the facing direction
      if (block.getState().getData() instanceof org.bukkit.material.Sign) {
        org.bukkit.material.Sign s = (org.bukkit.material.Sign) block.getState().getData();
        s.setFacingDirection(getFacing());
      }
      // Set the content
      if (block.getState() instanceof org.bukkit.block.Sign) {

        // Set sign data
        String[] lines = getLines();
        org.bukkit.block.Sign sign = (org.bukkit.block.Sign) block.getState();
        int i = 0;
        if (lines != null && lines.length > 0) {
          for (String line : lines) {
            sign.setLine(i, line);
            i++;
          }
        }
        sign.update();
        return new ChangeResult(ChangeResultType.APPLIED, null);
      }
    }
    return new ChangeResult(ChangeResultType.SKIPPED, null);
  }
  @Override
  protected World generateWorld() {
    if (!TFM_ConfigEntry.FLATLANDS_GENERATE.getBoolean()) {
      return null;
    }

    wipeFlatlandsIfFlagged();

    WorldCreator worldCreator = new WorldCreator(WORLD_NAME);
    worldCreator.generateStructures(false);
    worldCreator.type(WorldType.NORMAL);
    worldCreator.environment(World.Environment.NORMAL);
    worldCreator.generator(new CleanroomChunkGenerator(GENERATION_PARAMETERS));

    World world = Bukkit.getServer().createWorld(worldCreator);

    world.setSpawnFlags(false, false);
    world.setSpawnLocation(0, 50, 0);

    Block welcomeSignBlock = world.getBlockAt(0, 50, 0);
    welcomeSignBlock.setType(Material.SIGN_POST);
    org.bukkit.block.Sign welcomeSign = (org.bukkit.block.Sign) welcomeSignBlock.getState();

    org.bukkit.material.Sign signData = (org.bukkit.material.Sign) welcomeSign.getData();
    signData.setFacingDirection(BlockFace.NORTH);

    welcomeSign.setLine(0, ChatColor.GREEN + "DonatorWorld");
    welcomeSign.setLine(1, ChatColor.DARK_GRAY + "---");
    welcomeSign.setLine(2, ChatColor.YELLOW + "Spawn Point");
    welcomeSign.setLine(3, ChatColor.DARK_GRAY + "---");
    welcomeSign.update();

    TFM_GameRuleHandler.commitGameRules();

    return world;
  }