What rules.yml is for
#rules.yml holds requirements a player has to meet before an action goes ahead: who may place, sell, level up, invite and so on. Nothing in it is switched on as shipped; every example is commented out, so a server that never opens the file runs exactly as without it.
After editing, run /harvest reload. A mistake is reported in the console the moment you reload, with a ^ under the place it went wrong. A rule that cannot be read is never met, so a typo closes a door instead of quietly opening one.
/harvest rulesshows what is in effect./harvest rules test <rule>tries a rule out on yourself./harvest rules wordslists every function and variable.
Admins (simpleharvest.admin) skip every requirement unless admins-bypass is false. Anybody with simpleharvest.rules.bypass always skips them. Only players are asked: a keeper's own automation (auto-sell, culling) and /harvest admin never are.
Writing a requirement
#Under requirements:, name the action and list what it takes. Each line is a rule that must come out true. There are three ways to write one:
requirements:
sell:
- "permission('farm.sell')" # plain rule; the language file's line if not met
withdraw:
- check: "player.world == 'farm'"
deny: "<negative>✖</negative> <text>Take produce out in the farm world."
level-up:
- check: "has_item('GOLD_INGOT', 8)"
deny: "<negative>✖</negative> <text>Bring <value>8 gold ingots</value> to level a crop."
bypass: "farm.vip" # holders of this skip just this one
A deny of "" refuses without saying anything.
Settings
#| Key | Default | Description |
|---|---|---|
admins-bypass | true | Whether simpleharvest.admin skips every requirement. simpleharvest.rules.bypass always does. |
conditions | {} | Rules you name once and reuse anywhere as is('name'). A condition may use others, but not itself. |
requirements | {} | What each action takes. Leave an action out, or its list empty, to ask nothing. |
conditions:
vip: "permission('group.vip') or permission('group.mvp')"
farmer-tool: "holding('#minecraft:hoes') and holding_enchant('efficiency') >= 3"
rich: "can_afford(10000)"
Actions
#| Action | When it is asked | Variables only it fills in |
|---|---|---|
place | placing a keeper | where.world, where.x, where.y, where.z, origin, price |
move | moving one | where.world, where.x, where.y, where.z |
remove | taking one away | |
open | opening its menu | |
sell | selling its store | |
withdraw | taking produce out | produce, amount |
level-up | buying a crop level | produce, level, next_level, cost |
keeper-level | buying a keeper level | level, next_level, cost |
experience-take | taking its experience | points |
experience-sell | selling its experience | points, money |
crew-add | inviting somebody | target, role |
crew-role | changing a member's role | target |
crew-remove | removing a member | target |
transfer | handing it to somebody | target |
settings | changing a setting | setting, value |
look | changing its look | part (type, profession, glow or reset), value |
Every action except place also has the keeper's variables (keeper.*).
The language
#| Kind | Syntax |
|---|---|
| Values | 12, 3.5, 'text', "text", true, false, ['a', 'b', 'c'] |
| Placeholders | %player_level%, %vault_eco_balance% (PlaceholderAPI, also inside 'text') |
| Compare | ==, !=, <, <=, >, >= (= works as ==, <> as !=) |
| Text | contains, starts_with, ends_with, matches 'regex', in ['a', 'b'] |
| Arithmetic | +, -, *, /, % ('a' + 'b' joins text) |
| Logic | and, or, not (also &&, ||, !) and brackets |
How values are read:
- Text that is a number is a number:
'10' > 9is true, and so is'1,250' == 1250. - True means:
true, a number other than 0, a non-empty list, or the textyes,on,trueoryin any case. Everything else is false, so a placeholder nothing filled in is never a yes. - Text compares exactly:
'World' == 'world'is false; uselower(x) == 'world'. <,<=,>and>=compare numbers only. A variable that means nothing where the rule is checked (for examplekeeper.storedwith no keeper) is neither more, less, equal nor unequal to anything.- A word where a number was expected makes the rule unworkable this time: it is not met and the console says why, at most once a minute per rule.
Variables
#| Group | Variables |
|---|---|
| Player | player.name, player.uuid, player.world, player.x, player.y, player.z, player.level, player.experience, player.health, player.max_health, player.food, player.gamemode, player.flying, player.sneaking, player.op, player.keepers |
| Keeper | keeper.owner, keeper.owner_uuid, keeper.is_owner, keeper.role, keeper.world, keeper.region, keeper.x, keeper.y, keeper.z, keeper.stored, keeper.capacity, keeper.free, keeper.fullness, keeper.experience, keeper.crew, keeper.kinds, keeper.worth |
| Keeper history | keeper.harvested, keeper.sold, keeper.earned, keeper.withdrawn, keeper.levels_bought, keeper.spent, keeper.culled, keeper.experience_gathered, keeper.age_days |
keeper.role is owner, a role's name or none. keeper.fullness is 0 to 100.
Functions
#| Function | Result |
|---|---|
permission('node') | the player has the permission |
holding('ITEM', ...) | the main hand holds one of them |
offhand('ITEM', ...) | the off hand does |
wearing('ITEM', ...) | a worn armour piece is one of them |
holding_amount() | how many are in the main hand |
holding_name() | the main hand item's shown name, '' if none |
holding_enchant('efficiency') | that enchantment's level on the main hand item, 0 without |
has_item('ITEM', 16) | the player carries at least that many (1 if left out) |
item_count('ITEM') | how many they carry |
in_world('world', ...) | they are in one of these worlds |
can_afford(500) | their balance covers it |
stored('WHEAT') | how much of a crop the keeper holds |
level('WHEAT') | the keeper's level for a crop |
setting('auto-sell') | the keeper has that setting on (collect-drops, collect-mob-drops, auto-sell, hidden, cull) |
is('name') | a named condition is met |
cooldown('sell', 120) | true once 120 seconds have passed since this player last did it; a third argument 'keeper' makes it per keeper |
lower, upper, trim, length, replace, text, number, default | text and conversion helpers |
min, max, abs, round, floor, ceil, between | number helpers |
chance(25) | true one time in four |
if(rule, then, otherwise) | pick a value by a rule |
An ITEM is a vanilla item (DIAMOND_HOE, minecraft:diamond_hoe), an item tag (#minecraft:hoes) or a custom item id (itemsadder:farming:ruby_hoe, nexo:ruby_hoe, oraxen:ruby_hoe, craftengine:farming:ruby_hoe). In a deny message, <cooldown> shows how long is left.
Examples
#requirements:
place:
- check: "in_world('world', 'farms')"
deny: "<negative>✖</negative> <text>Keepers go in the overworld or the farm world."
- check: "where.y > 40"
deny: "<negative>✖</negative> <text>Not that deep - place it above <value>y 40</value>."
sell:
- check: "keeper.worth >= 100"
deny: "<notice>⚠</notice> <text>Wait until the store is worth <value>100</value> or more."
move:
- check: "cooldown('move', 180, 'keeper')"
deny: "<notice>⚠</notice> <text>This keeper was moved a moment ago <muted>· wait <value><cooldown>"
crew-add:
- check: "keeper.crew < 5 or is('vip')"
deny: "<negative>✖</negative> <text>A keeper takes five crew members; VIPs take more."
Rules in menus
#Any item in a menu file can carry rules in the same language:
view-requirement: "permission('farm.vip')" # drawn only for players who meet it
click-requirement: "holding('#minecraft:hoes')" # clicking does nothing for the others...
deny-message: "<negative>✖</negative> <text>Hold a hoe." # ...and they are told this
Menu rules can use named conditions with is('name') and read keeper.* in a keeper's menus.
Found a mistake or something missing? Open a ticket on Discord.
Report an issue