예제 #1
0
  /** @see fr.ribesg.bukkit.ncore.AbstractConfig#getConfigString() */
  @Override
  protected String getConfigString() {
    final StringBuilder content = new StringBuilder();
    FrameBuilder frame;

    // Header
    frame = new FrameBuilder();
    frame.addLine("Config file for NPlayer plugin", FrameBuilder.Option.CENTER);
    frame.addLine("If you don't understand something, please ask on dev.bukkit.org");
    frame.addLine("Ribesg", FrameBuilder.Option.RIGHT);
    for (final String line : frame.build()) {
      content.append(line + '\n');
    }

    // Maximum Login attempts
    content.append(
        "# Maximum login attempts before punishment. Possible values: Positive integers\n");
    content.append("# Default : 3\n");
    content.append("maximumLoginAttempts: " + getMaximumLoginAttempts() + "\n\n");

    // Too Many Attempts Punishment
    content.append("# How do we punish people after too many attempts? Possible values: 0, 1, 2\n");
    content.append("# Default : 1\n");
    content.append("#\n");
    content.append("#   Value | Action\n");
    content.append("#       0 : Kick\n");
    content.append("#       1 : Tempban\n");
    content.append("#       2 : Ban\n");
    content.append("#\n");
    content.append("tooManyAttemptsPunishment: " + getTooManyAttemptsPunishment() + "\n\n");

    // Too Many Attempts Punishment Duration
    content.append(
        "# The duration of the punishment, if applicable. Possible values: Positive integers\n");
    content.append("# Default : 300\n");
    content.append("#\n");
    content.append("# Here are some example values:\n");
    content.append("#      Value | Description\n");
    content.append("#         30 : 30 seconds\n");
    content.append("#         60 : 1 minute\n");
    content.append("#        300 : 5 minutes\n");
    content.append("#        600 : 10 minutes\n");
    content.append("#       1800 : 30 minutes\n");
    content.append("#       1800 : 30 minutes\n");
    content.append("#       1800 : 30 minutes\n");
    content.append("#       3600 : 1 hour\n");
    content.append("#       7200 : 2 hours\n");
    content.append("#      10800 : 3 hours\n");
    content.append("#      14400 : 4 hours\n");
    content.append("#      21600 : 6 hours\n");
    content.append("#      28800 : 8 hours\n");
    content.append("#      43200 : 12 hours\n");
    content.append("#      86400 : 24 hours - 1 day\n");
    content.append("#     172800 : 48 hours - 2 days\n");
    content.append("#     604800 : 7 days\n");
    content.append("#\n");
    content.append(
        "# You can use *any* strictly positive value you want, just be sure to convert it to seconds.\n");
    content.append("# Note: only applies to TempBan punishment for now.\n");
    content.append("#\n");
    content.append(
        "tooManyAttemptsPunishmentDuration: " + getTooManyAttemptsPunishmentDuration() + "\n\n");

    return content.toString();
  }
예제 #2
0
파일: Config.java 프로젝트: Gust09/NPlugins
  /** @see AbstractConfig#getConfigString() */
  @Override
  protected String getConfigString() {
    final StringBuilder content = new StringBuilder();
    FrameBuilder frame;

    // Header
    frame = new FrameBuilder();
    frame.addLine("Config file for NWorld plugin", FrameBuilder.Option.CENTER);
    frame.addLine("If you don't understand something, please ask on dev.bukkit.org");
    frame.addLine("Ribesg", FrameBuilder.Option.RIGHT);
    for (final String line : frame.build()) {
      content.append(line + '\n');
    }
    content.append('\n');

    // #############
    // ## General ##
    // #############

    frame = new FrameBuilder();
    frame.addLine("General", FrameBuilder.Option.CENTER);
    content.append('\n');
    for (final String line : frame.build()) {
      content.append(line + '\n');
    }
    content.append('\n');

    // Spawn command behaviour
    content.append("# Configures the behaviour of the /spawn command. Two possibilities:\n");
    content.append("# - 0 = Teleports the player to the current world's spawn point\n");
    content.append("# - 1 = Teleports the player to a \"Global\" spawn point\n");
    content.append("# Default : 1\n");
    content.append("spawnCommandBehaviour: " + getSpawnCommandBehaviour() + "\n\n");

    // Default required permission
    content.append("# The default permission required to warp to a point, set if\n");
    content.append("# not provided in \"/nworld create\" or \"/setwarp\" commands\n");
    content.append("# Default : nworld.admin\n");
    content.append("defaultRequiredPermission: \"" + getDefaultRequiredPermission() + "\"\n\n");

    // Default hidden value
    content.append("# The default value for any new World or Warp created, set if\n");
    content.append("# not provided in \"/nworld create\" or \"/setwarp\" commands\n");
    content.append("# Default : true\n");
    content.append("defaultHidden: " + isDefaultHidden() + "\n\n");

    // Permission shortcuts
    content.append("# You can use those shortcuts when setting a required Permission\n");
    content.append("# to a world or a warp >>> VIA IN GAME COMMANDS <<< /!\\\n");
    content.append("# Note: every key should be lowercase.\n");
    content.append("permissionShortcuts:\n");
    if (!permissionShortcuts.containsKey("user")) {
      content.append("  user: \"nworld.user\"\n");
    }
    if (!permissionShortcuts.containsKey("admin")) {
      content.append("  admin: \"nworld.admin\"\n");
    }
    for (final Map.Entry<String, String> e : permissionShortcuts.entrySet()) {
      content.append("  " + e.getKey() + ": \"" + e.getValue() + "\"\n");
    }

    // ##############
    // ## Messages ##
    // ##############

    frame = new FrameBuilder();
    frame.addLine("Messages", FrameBuilder.Option.CENTER);
    content.append('\n');
    for (final String line : frame.build()) {
      content.append(line + '\n');
    }
    content.append('\n');

    // Broadcast on world creation
    content.append("# Do we broadcast a message on World creation. Possible values: 0,1\n");
    content.append("# Default : 0\n");
    content.append("broadcastOnWorldCreate: " + getBroadcastOnWorldCreate() + "\n\n");

    // Broadcast on world load
    content.append("# Do we broadcast a message on World load. Possible values: 0,1\n");
    content.append("# Default : 0\n");
    content.append("broadcastOnWorldLoad: " + getBroadcastOnWorldLoad() + "\n\n");

    // Broadcast on world unload
    content.append("# Do we broadcast a message on World unload. Possible values: 0,1\n");
    content.append("# Default : 0\n");
    content.append("broadcastOnWorldUnload: " + getBroadcastOnWorldUnload() + "\n\n");

    // ############
    // ## Worlds ##
    // ############

    frame = new FrameBuilder();
    frame.addLine("Worlds", FrameBuilder.Option.CENTER);
    content.append('\n');
    for (final String line : frame.build()) {
      content.append(line + '\n');
    }
    content.append('\n');

    content.append("# Values for stock worlds (Handled by Bukkit config files)\n");
    content.append("# - Spawn Location\n");
    content.append("# - Required Permission for direct warp to this world's spawn point\n");
    content.append(
        "# - If this world will be hidden to those that are not allowed to directly warp to it\n");
    content.append("stockWorlds:\n");
    for (final StockWorld w : worlds.getStock().values()) {
      content.append("  \"" + w.getWorldName() + "\":\n");
      content.append("    spawnLocation:\n");
      content.append("      x: " + w.getSpawnLocation().getX() + "\n");
      content.append("      y: " + w.getSpawnLocation().getY() + "\n");
      content.append("      z: " + w.getSpawnLocation().getZ() + "\n");
      content.append("      yaw: " + w.getSpawnLocation().getYaw() + "\n");
      content.append("      pitch: " + w.getSpawnLocation().getPitch() + "\n");
      content.append("    requiredPermission: \"" + w.getRequiredPermission() + "\"\n");
      content.append("    hidden: " + w.isHidden() + "\n");
    }
    content.append("\n");

    content.append("# Values for additional worlds\n");
    content.append("# - Spawn Location\n");
    content.append("# - Required Permission for direct warp to this world's spawn point\n");
    content.append("# - If this world:\n");
    content.append("#   * was loaded at last server stop\n");
    content.append("#   * will be loaded at next server start\n");
    content.append(
        "# - If this world will be hidden to those that are not allowed to directly warp to it\n");
    content.append(
        "# - If this world has an associated Nether world, and the associated parameters\n");
    content.append(
        "# - If this world has an associated End world, and the associated parameters\n");
    content.append("additionalWorlds:\n");
    for (final AdditionalWorld w : worlds.getAdditional().values()) {
      content.append("  \"" + w.getWorldName() + "\":\n");
      content.append("    spawnLocation:\n");
      content.append("      x: " + w.getSpawnLocation().getX() + "\n");
      content.append("      y: " + w.getSpawnLocation().getY() + "\n");
      content.append("      z: " + w.getSpawnLocation().getZ() + "\n");
      content.append("      yaw: " + w.getSpawnLocation().getYaw() + "\n");
      content.append("      pitch: " + w.getSpawnLocation().getPitch() + "\n");
      content.append("    seed: " + w.getSeed() + "\n");
      content.append("    requiredPermission: \"" + w.getRequiredPermission() + "\"\n");
      content.append("    enabled: " + w.isEnabled() + "\n");
      content.append("    hidden: " + w.isHidden() + "\n");
      content.append("    hasNether: " + w.hasNether() + "\n");
      content.append(
          "    netherWorld: # Ignore this category if this world has no Nether sub-world\n");
      content.append("      spawnLocation:\n");
      content.append("        x: " + w.getSpawnLocation().getX() + "\n");
      content.append("        y: " + w.getSpawnLocation().getY() + "\n");
      content.append("        z: " + w.getSpawnLocation().getZ() + "\n");
      content.append("        yaw: " + w.getSpawnLocation().getYaw() + "\n");
      content.append("        pitch: " + w.getSpawnLocation().getPitch() + "\n");
      content.append("      requiredPermission: \"" + w.getRequiredPermission() + "\"\n");
      content.append("      enabled: " + w.isEnabled() + "\n");
      content.append("      hidden: " + w.isHidden() + "\n");
      content.append("    hasEnd: " + w.hasEnd() + "\n");
      content.append("    endWorld: # Ignore this category if this world has no End sub-world\n");
      content.append("      spawnLocation:\n");
      content.append("        x: " + w.getSpawnLocation().getX() + "\n");
      content.append("        y: " + w.getSpawnLocation().getY() + "\n");
      content.append("        z: " + w.getSpawnLocation().getZ() + "\n");
      content.append("        yaw: " + w.getSpawnLocation().getYaw() + "\n");
      content.append("        pitch: " + w.getSpawnLocation().getPitch() + "\n");
      content.append("      requiredPermission: \"" + w.getRequiredPermission() + "\"\n");
      content.append("      enabled: " + w.isEnabled() + "\n");
      content.append("      hidden: " + w.isHidden() + "\n");
    }

    // ###########
    // ## Warps ##
    // ###########

    frame = new FrameBuilder();
    frame.addLine("Warps", FrameBuilder.Option.CENTER);
    content.append('\n');
    for (final String line : frame.build()) {
      content.append(line + '\n');
    }
    content.append('\n');

    content.append("# Everything warp related\n");
    content.append("# - Location\n");
    content.append("# - Required Permission to warp\n");
    content.append("# - If it is hidden to those who do not have the required permission\n");
    content.append("warps:\n");
    for (final Warp w : warps) {
      content.append("  \"" + w.getName() + "\":\n");
      content.append("    location:\n");
      content.append("      worldName: " + w.getLocation().getWorldName() + "\n");
      content.append("      x: " + w.getLocation().getX() + "\n");
      content.append("      y: " + w.getLocation().getY() + "\n");
      content.append("      z: " + w.getLocation().getZ() + "\n");
      content.append("      yaw: " + w.getLocation().getYaw() + "\n");
      content.append("      pitch: " + w.getLocation().getPitch() + "\n");
      content.append("    requiredPermission: \"" + w.getRequiredPermission() + "\"\n");
      content.append("    hidden: " + w.isHidden() + "\n");
    }

    return content.toString();
  }