Beispiel #1
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;
  }