We've learned about the Paths system on the previous pages and now it is time to build our own path! To do that, you'll need to go to the Paths.yml file in the Autorank plugin folder.
The basic setup of a path looks like this:
Name of the path: # Name of the pathprerequisites: # The prerequisite section.some prerequisite:value: value specific to the prerequisitesome prerequisite 2:value: value specific to the prerequisiterequirements: # The requirements section.some requirement name:value: values specific to the requirementsome requirement name 2:value: values specific to the requirementresults: # The results section.some result:value: value specific to the resultsome result 2:value: value specific to the result
You can see that there are basically three important subsections of a path. You start off with the name of the path at the top, and then get to the three subsections:
Conditions that a player needs to meet to be eligible for the path.
Conditions that the player needs to fulfill to complete the path.
Actions that are performed after the player completes a path.
Note that these subsections are all located at the same level of indentation! It is very important that this is always the case because it's a specification of the YAML standard.
Now that we know the structure of a path, can you decipher the path below?
Running a marathon:prerequisites:in group:value: 'Participants'requirements:blocks moved:value: 1000;0results:money:value: 10000
Try to figure out what this path means, it should be familiar (if you've read the previous pages).
This path is called Running a marathon and requires players to move at least a thousand blocks to complete it (by walking). The player will need to walk as opposed to flying, swimming, or riding in a minecart. This is indicated by the zero behind the '1000', but don't worry about that for now.
To be able to activate this path, players need to be in the group Participants. Once the player has completed the (only) requirement of this path, the path is completed. Upon completion of the path, the player will receive ten thousand money (in whatever currency unit you use).
Hopefully, you've got the hang of it now. One of the most frequent use-cases of Autorank is allowing players to gain ranks by playing on the server for a while. Due to popular request, we can work out an example here.
Let's say we have the following ranks on our server:
Default (new players start in this rank)
Now let's say we want players to be able to rank up to a new rank after the following times:
Default (new players start in this rank)
Newbie (after playing for 2 hours)
Member (after playing for one day)
Trusted Member (after playing for a week)
Elite (after playing for a year)
With your knowledge of paths, try to set it up using the path system! The answer is given below.
Newbie Path:prerequisites:in group:value: 'Default' # Player is in the Default path to activate this pathrequirements:time:value: '2h'results:command:value: 'lp user &p parent set Newbie' # Set the player to Newbie rank
Member Path:prerequisites:in group:value: 'Newbie'requirements:time:value: '1d'results:command:value: 'lp user &p parent set Member' # Set the player to Member rank
Trusted Member Path:prerequisites:in group:value: 'Member'requirements:time:value: '7d' # 7 days is a week!results:command:value: 'lp user &p parent set Trusted Member'
Elite Path:prerequisites:in group:value: 'Trusted Member'requirements:time:value: '365d' # 365 days is a year!results:command:value: 'lp user &p parent set Elite'
When you're finished, the Paths file should look like this:
Newbie Path:prerequisites:in group:value: 'Default' # Player is in the Default path to activate this pathrequirements:time:value: '2h'results:command:value: 'lp user &p parent set Newbie' # Set the player to Newbie rankMember Path:prerequisites:in group:value: 'Newbie'requirements:time:value: '1d'results:command:value: 'lp user &p parent set Member' # Set the player to Member rankTrusted Member Path:prerequisites:in group:value: 'Member'requirements:time:value: '7d' # 7 days is a week!results:command:value: 'lp user &p parent set Trusted Member'Elite Path:prerequisites:in group:value: 'Trusted Member'requirements:time:value: '365d' # 365 days is a year!results:command:value: 'lp user &p parent set Elite'
Now that we've built our first path, we might want to improve it a bit. Let's look into a few improvements!
Often you want players to fulfill more than one requirement to be able to complete a path. Let's take the example given above. You want a player to go from the Default rank to the Newbie rank when he's played for 2 hours and he's obtained at least 100 money. It's very easy to add additional requirements, see the example below.
Newbie Path:prerequisites:in group:value: 'Default'requirements: # There are two requirements in this sectiontime:value: '2h'money:value: 100results:command:value: 'lp user &p parent set Newbie'
Just like requirements, you can also use multiple prerequisites. Let's say we want a player to be in two groups at the same time before he is eligible for a path.
Path with two prerequisites:prerequisites: # Player should be in the Default and Newbie group!in group:value: 'Default'in group2:value: 'Newbie'# Requirements and results are left out for brevity
Let's say you want to give the player something when they start a path; perhaps the path requires the player to walk a thousand blocks, so you surely want to give them some food before they embark on their long journey. To run results whenever a player activates a path, you'll need to add a new subsection to your path. See the example below.
Travel across the world:prerequisites:in group: # Only travellers can undertake such a long journey.value: Travellersupon choosing: # New section that performs results when the path is activatedcommand:value: "give &p bread 5" # Give the player some breadmessage:value: "Good luck on your journey."requirements:blocks moved:value: 1000;0results:message: # Tell the player they've done well.value: "You've become a true traveller!"
The path will perform the results that are specified in the upon choosing section. Note that the indentation matches that of the other sections!
Whenever a player activates a path or checks the progress on their path, they will have to use the name of the path as specified in your Paths.yml file. If you want to show a different name, you should not adjust the name at the top of your paths declaration! If you do, Autorank will think that it is a completely new path (and will kick players out of their current path). Instead, you should add a display name to the path, like so:
Very long and ugly path name: # DO NOT change this nameprerequisites:# Some prerequisites hererequirements:# Some requirements hereresults:# Some results hereoptions:display name: "New path name" # Instead, add this to your path
The options section is used to configure additional options for a path. Note that it has the same indentation as the other subsections!
Normally, results of a path are only performed when all of the requirements of a path are fulfilled. If you want to perform a result whenever a specific requirement is fulfilled, that is also possible. Let's say we want a player to get a new rank after he has completed multiple tasks (requirements), but also give him a small incentive every time a single task has been completed successfully. We can do that using the following example:
Get a new rank:prerequisites:# Some prerequisitesrequirements:mobs killed: # Kill a few spidersvalue: 50;Spiderresults: # Get a small intermediate rewardmoney:value: 125mobs killed 2:value: 20;Zombieresults:money: # Get a small intermediate rewardvalue: 40message: # Encourage the player a bit morevalue: "Good job on killing those zombies!"results:money: # Also get a large reward when all monsters have been killedvalue: 1000
As you can see, the example above gives the player a monetary reward whenever he completes a requirement. You can have multiple results for a single requirement (see the second requirement for example). When the player has fulfilled both requirements and hence has completed the path, the results of the path are performed (see the results subsection of the path) and he'll get 1000 money.
What if you want a player to fulfill some requirements of a path, but not necessarily all of them to be able to complete the path. Autorank has a feature where you can mark a requirement as 'optional'. An optional requirement (or prerequisite) indicates that a player does not necessarily have to fulfill it to count it as complete.
Let's say you want players to walk a thousand blocks, but on the way, they may also gather some coal to get an extra reward. See the example below.
Walk a way:prerequisites:# Some prerequisitesrequirements:blocks moved:value: 1000;0has item: # An optional requirementvalue: COAL;10options:optional: trueresults: # Give the player a bit of money for finding some coalmoney:value: 300results:# Some results
This path will require players to walk at least 1000 blocks. In addition, they may also gather some coal (and be rewarded 300 money for it), but that is optional. They do not have to gather the coal to complete the path.
You've read a lot about the Paths system and the way you can configure it. We believe most Paths can be made with these options. However, if you feel like you need an even deeper dive into the Paths system, feel free to continue to the next page.