# Server Config Syntax and Examples

## Example File
```
WITH config(server)
    //general settings
    set(creative_reach).value(50);
    set(salvage_block).value(minecraft:smithing_table);
    set(treasure_enabled).value(true);
    set(brewing_tracked).value(true);
    
    //levels settings
    set(max_level).value(1523);
    set(static_levels).value(-1);
    set(loss_on_death).value(0.05);
    set(lose_only_excess).value(false);
    set(global_modifier).value(1.0);
    set(skill_modifiers).value(example_skill,1.0);
    set(xp_min).value(200);
    set(xp_base).value(1.025);
    set(per_level).value(1.1);
    
    //Requirements settings
    //requirements are true by default.  the script explicitly disables them.  omission implies enabled.
    //see wiki table for all values
    set(disable_req).value(WORN);
    
    //XP Gain Settings
    set(reuse_penalty).value(0.0);
    set(perks_plus_config).set(false);
    set(player_actions).event(JUMP).value(agility,2.5);
    set(damage_dealt).type(minecraft:player_attack).value(combat,1);
    set(damage_received).type(minecraft:mob_attack).value(endurance,1);
    
    //Party Settings
    set(party_range).value(50);
    set(party_bonus).value(combat,1.05,endurance,1.1);
    
    //Mob Scaling Settings
    set(mob_scaling_enabled).value(false);
    set(scaling_aoe).value(150);
    set(base_level).value(0);
    set(boss_scaling).value(1.1);
    set(use_exponential_formula).value(true);
    set(per_level).value(1.0);
    set(power_base).value(1.104088404342588);
    set(ratios).mob(minecraft:generic.max_health).value(combat,0.001);
    
    //Vein Miner Settings
    set(vein_enabled).value(true);
    set(require_settings).value(false);
    set(default_consume).value(1);
    set(charge_modifier).value(1.0);
    set(blacklist).value(silentgear:saw);
END
```
## Example JSON File
```json
{
  "xp_gains": {
    "reuse_penalty": 0.0,
    "perks_plus_config": false,
    "player_actions": {
      "SWIM_SPRINTING": {
        "swimming": 1.0
      },
      "SURFACING": {
        "swimming": 1.0
      },
      "BREATH_CHANGE": {
        "endurance": 1.0
      },
      "SPRINT_JUMP": {
        "agility": 2.5
      },
      "DIVING": {
        "swimming": 1.0
      },
      "SPRINTING": {
        "agility": 2.0
      },
      "SUBMERGED": {
        "swimming": 1.0
      },
      "JUMP": {
        "agility": 2.5
      },
      "CROUCH_JUMP": {
        "agility": 2.5
      },
      "HEALTH_DECREASE": {
        "endurance": 1.0
      },
      "HEALTH_INCREASE": {
        "endurance": 1.0
      },
      "SWIMMING": {
        "swimming": 1.0
      }
    },
    "damage": {
      "RECEIVE_DAMAGE": {
        "minecraft:generic_kill": {
          "endurance": 1
        },
        "#pmmo:impact": {
          "endurance": 15
        },
        "#pmmo:magic": {
          "magic": 15
        },
        "#pmmo:environment": {
          "endurance": 10
        },
        "#minecraft:is_projectile": {
          "endurance": 15
        }
      },
      "DEAL_DAMAGE": {
        "minecraft:generic_kill": {
          "combat": 1
        },
        "#pmmo:gun": {
          "gunslinging": 1
        },
        "#pmmo:magic": {
          "magic": 15
        },
        "minecraft:player_attack": {
          "combat": 1
        },
        "#minecraft:is_projectile": {
          "archery": 1
        }
      }
    }
  },
  "party": {
    "party_range": 50,
    "party_bonus": {
      "combat": 1.05,
      "endurance": 1.1
    }
  },
  "mob_scaling": {
    "use_exponential_formula": true,
    "per_level": 1.0,
    "power_base": 1.104088404342588,
    "ratios": {
      "minecraft:generic.attack_damage": {
        "combat": 1.0E-4
      },
      "minecraft:generic.movement_speed": {
        "combat": 1.0E-6
      },
      "minecraft:generic.max_health": {
        "combat": 0.001
      }
    },
    "enabled": false,
    "scaling_aoe": 150,
    "base_level": 0,
    "boss_scaling": 1.1
  },
  "vein_miner": {
    "default_consume": 1,
    "charge_modifier": 1.0,
    "blacklist": [
      "silentgear:saw"
    ],
    "enabled": true,
    "require_settings": false
  },
  "general": {
    "creative_reach": 50.0,
    "salvage_block": "minecraft:smithing_table",
    "treasure_enabled": true,
    "brewing_tracked": true
  },
  "levels": {
    "xp_min": 200,
    "xp_base": 1.025,
    "per_level": 1.1,
    "global_modifier": 1.0,
    "skill_modifiers": {
      "example_skill": 1.0
    },
    "max_level": 1523,
    "static_levels": [
      -1
    ],
    "loss_on_death": 0.05,
    "lose_only_excess": true
  },
  "requirements": {
    "requirement_enabled": {
      "TAME": true,
      "TRAVEL": true,
      "USE": true,
      "ENTITY_INTERACT": true,
      "USE_ENCHANTMENT": true,
      "PLACE": true,
      "INTERACT": true,
      "WEAR": true,
      "BREAK": true,
      "WEAPON": true,
      "BREED": true,
      "KILL": true,
      "RIDE": true,
      "TOOL": true
    }
  },
  "type": "SERVER"
}
```

## Syntax
Most configurations use a combination of `set(config_keyword).value(some_value);`.  However, some have additional elements which clarify what that value is set on.  The table below lists each configuration node's keyword, purpose, any special nodes, and the value node format. 

|       set node key        | setting function                                                                                                                                         | special nodes                                                                                                                                                                                                     | value node                                                                                                                                                                                                                     |
|:-------------------------:|:---------------------------------------------------------------------------------------------------------------------------------------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|     `creative_reach`      | specifies how much extra distance players can interact while in creative mode                                                                            |                                                                                                                                                                                                                   | a whole number `value(50)` by default                                                                                                                                                                                          |
|      `salvage_block`      | Which block should be used to salvage items                                                                                                              |                                                                                                                                                                                                                   | the ID of the block. default `value(minecraft:smithing_table)`                                                                                                                                                                 |
|    `treasure_enabled`     | Should treasure drop.                                                                                                                                    |                                                                                                                                                                                                                   | value true/false.  default `value(true)`                                                                                                                                                                                       |
|     `brewing_tracked`     | should brewed potions be marked as having awarded xp. makes them unstackable with non-xp-gained potions if using a stacking potion mod                   |                                                                                                                                                                                                                   | value true/false. default `value(true)`                                                                                                                                                                                        |
|        `max_level`        | the maximum level for all skills                                                                                                                         |                                                                                                                                                                                                                   | a whole number. default `value(1523)`                                                                                                                                                                                          |
|      `static_levels`      | a full override of the level system where you set the required XP for every level.                                                                       |                                                                                                                                                                                                                   | value is a list of values representing the XP required for the level at that position in the list.  eg `value(10, 30, 10)` would require 10 xp for level 1, 30 for 2, and 10 for 3.  default `value(-1)` disables this feature |
|      `loss_on_death`      | what percentage of xp should be lost on death.  0.0 = no loss 1.0 = lose all xp                                                                          |                                                                                                                                                                                                                   | a decimal number. default `value(0.05)`                                                                                                                                                                                        |
|    `lose_only_excess`     | should xp loss apply only to xp gained after the current level threshold.                                                                                |                                                                                                                                                                                                                   | value true/false. default `value(true)`                                                                                                                                                                                        |
|     `global_modifier`     | adjusts xp gains for all levels                                                                                                                          |                                                                                                                                                                                                                   | decimal value less than zero reduces XP gain, 0 means no xp gain, 1.0 is no change and 2.0 is double xp. default `value(1.0)`                                                                                                  |
|     `skill_modifiers`     | adjusts xp gains like global modifier but only for specific skills                                                                                       |                                                                                                                                                                                                                   | values are skills followed by decimal numbers separated by commas. for example `value(combat,1.5,endurance,0.5)` results in 50% increase to combat and 50% decrease to endurance.  default none                                |
|         `xp_min`          | sets the value of the same name in the formula `xp_min + xp_base^(level * per_level)`                                                                    |                                                                                                                                                                                                                   | whole number.  default `value(200)`                                                                                                                                                                                            |
|         `xp_base`         | sets the value of the same name in the formula `xp_min + xp_base^(level * per_level)`                                                                    |                                                                                                                                                                                                                   | decimal value.  default `value(1.025)`                                                                                                                                                                                         |
|        `per_level`        | sets the value of the same name in the formula `xp_min + xp_base^(level * per_level)`                                                                    |                                                                                                                                                                                                                   | decimal vale. default `value(1.1)`                                                                                                                                                                                             |
|       `disable_req`       | since all reqs are enabled by default, this operation disables specific reqs.                                                                            |                                                                                                                                                                                                                   | any of `WEAR`, `USE_ENCHANTMENT`, `TOOL`, `WEAPON`, `USE`, `PLACE`, `BREAK`, `KILL`, `TRAVEL`, `RIDE`, `TAME`, `BREED`, `INTERACT`, `ENTITY_INTERACT`.  no defaults                                                            |
|      `reuse_penalty`      | how much xp percentage should breaking blocks placed by the player award.                                                                                |                                                                                                                                                                                                                   | decimal value. default `value(0.0)`                                                                                                                                                                                            |
|    `perks_plus_config`    | for perks that award XP, if this is true, the perk XP will combine with the configured XP                                                                |                                                                                                                                                                                                                   | true/false.  default `value(false)`                                                                                                                                                                                            |
|     `player_actions`      | sets the XP ratio for player actions not tied to other objects in the game.                                                                              | `event()` accepts any of the following `JUMP`, `SPRINT_JUMP`, `CROUCH_JUMP`, `BREATH_CHANGE`, `HEALTH_INCREASE`, `HEALTH_DECREASE`, `SPRINTING`, `SUBMERGED`, `SWIMMING`, `DIVING`, `SURFACING`, `SWIM_SPRINTING` | decimal value. example `value(2.5)`                                                                                                                                                                                            |
|      `damage_dealt`       | what skill and XP ratio to award when the player deals specific damage types                                                                             | `type()` takes a damage type ID. eg `type(minecraft:player_attack)`                                                                                                                                               | skills and decimal values separated by commas.  example `value(combat,2.5,archery,1.3)`                                                                                                                                        |
|     `damage_received`     | same as damage dealt but for damage inflicted to the player                                                                                              | same as above                                                                                                                                                                                                     | same as above                                                                                                                                                                                                                  |
|       `party_range`       | How close players need to be for their XP to be shared                                                                                                   |                                                                                                                                                                                                                   | a whole number, default `value(50)`                                                                                                                                                                                            |
|       `party_bonus`       | how much extra xp is awarded to players in parties based on the skill                                                                                    |                                                                                                                                                                                                                   | a list of skills and decimal values.  default `value(combat,1.05,endurance,1.1)`                                                                                                                                               |
|   `mob_scaling_enabled`   | is mob scaling enabled.                                                                                                                                  |                                                                                                                                                                                                                   | true/false. default `value(false)`                                                                                                                                                                                             |
|       `scaling_aoe`       | all players within this range of a spawning mob will contribute to the scaling values                                                                    |                                                                                                                                                                                                                   | whole number. default `value(150)`                                                                                                                                                                                             |
|       `base_level`        | the minimum level in the skill a player must be to contribute to scaling                                                                                 |                                                                                                                                                                                                                   | whole number. defaule `value(0)`                                                                                                                                                                                               |
|      `boss_scaling`       | a modifier on top of regular scaling applied to bosses                                                                                                   |                                                                                                                                                                                                                   | decimal number, default `value(1.1)`                                                                                                                                                                                           |
| `use_exponential_formula` | if false, use a linear formula for scaling attributes                                                                                                    |                                                                                                                                                                                                                   | true/false, default `value(true)`                                                                                                                                                                                              |
|        `per_level`        | the value in the formulas for linear (`(playerLevels - base_level) * per_level`) or exponential (`power_base^(per_level * (playerLevels - base_level))`) |                                                                                                                                                                                                                   | decimal number. default `value(1.0)`                                                                                                                                                                                           |
|       `power_base`        | see above                                                                                                                                                |                                                                                                                                                                                                                   | decimal value. default `value(1.104088404342588)`                                                                                                                                                                              |
|         `ratios`          | which skills should be used to scale which attributes.                                                                                                   | `attribute()` accepts the attribute ID being scaled                                                                                                                                                               | a list of skills and ratios separated by commas. example `value(combat,0.001,archery,0.003)`                                                                                                                                   |
|      `vein_enabled`       | should vein miner features be enabled                                                                                                                    |                                                                                                                                                                                                                   | true/false. default `value(true)`                                                                                                                                                                                              |
|    `require_settings`     | if true, requires that automatic break values be ignored                                                                                                 |                                                                                                                                                                                                                   | true/false. default `value(false)`                                                                                                                                                                                             |
|     `default_consume`     | the default amount of vein charge consumed on unconfigured blocks                                                                                        |                                                                                                                                                                                                                   | whole number. default `value(1)`                                                                                                                                                                                               |
|     `charge_modifier`     | scales charge rates globally from all sources                                                                                                            |                                                                                                                                                                                                                   | decimal value. default `value(1.0)`                                                                                                                                                                                            |
|        `blacklist`        | items that should cannot be used to vein mine blocks                                                                                                     |                                                                                                                                                                                                                   | a list of item ids separated by a comma. default `value(silentgear:saw)`                                                                                                                                                       |