A minecraft bukkit (spigot) plugin that creates a fare system used in subway/metro.
MetroFare is a highly customizable fare system that tries to mimic the Octopus Card and ticket system used in Mass Transit Railway in Hong Kong. This plugin is most suitable for fare system in minecraft railways.
This system includes a Debit Card, which is a IC Card that could be topped up and used to pay for charges. Single Ride tickets are also included if players opt to not use a Debit Card.
This plugin allows "Company" (The body for collecting fare in this plugin) to collect fare based on the following methods:
1. Zone
- A intra-zone charge and inter-zone charge is defined.
- Fare is calulated by <inter-zone-charge> * (DEST_ZONE - DEPT_ZONE) + <intra-zone-charge>
2. Uniform
- A single uniform fare is defined.
- Fare is the same and independent on which station the passenger enter/exit.
3. Abs_Coordinate
- A station coordinate is defined for each station
- A multiplier and constant is defined for the system.
- Fare is calulcated by the absolute coordinate between station coordinates with the following formula:
- DIFF = sqrt((destX - deptX)^2 + (destZ - deptZ)^2)
- Fare = Multiplier * DIFF + Constant
- This fare mode is good for simulating shortest distance fare policy.
4. Dijkstra
- Each station is defined as a vertex.
- A edge should be created between the previous and next station on a railway line.
- A fare is assiciated with each edge.
- Final fare is calculated by Dijstra Algorithum between the departure station vertex and destination station vertex.
- This fare mode is good for simulating shortest driving (rail) distance fare policy.
5. FareTable
- A fare table is created for the railway system
- The fare will be charged based on the fare table.
A few points to note:
1. The minimum denomination of fare in the plugin is 0.001 (current-unit),
to avoid double (decimal) value prescion problems.
2. Vault integration is supported if vault is installed. If no vault supporting economy plugin is instlled, the DebitCard and Ticket systems would still work.
You can download the plugin from spigot-mc forum here.
To setup a fare system, one must first create a company. It could be created via the following command:
/company
Different company requires different information upon creation:
For Zone/Abs_Coordinate Company:
/company new Zone
/company new Abs_Coordinate
For Dijkstra Company:
/company new Dijkstra
For FareTable Company:
/company new FareTable
For Uniform Company:
/company new Uniform
For the fare system to function, entry and exit gates should be created in stations with the following syntax. Type the following lines into a WallSign.
Entry Gate:
[MetroFareIn] # Configurable in config.yml
<Company Name>,<Entry Data (if necessary)>Exit Gate:
[MetroFareOut] # Configurable in config.yml
<Company Name>,<Entry Data (if necessary)>Line 3 and 4 is automatically generated.
A WallSign could also be placed within 3 blocks below the gate signs to temporarily set up to 2 blocks at specific location during gate open. Such Offset is relative to the position of the gate sign.
Syntax of such sign is as follows:
U : Axis parallel to WallSign
W : Axis perpendicular to WallSign
<Offset U>,<OffsetY>,<OffsetW>
<Offset U>,<OffsetY>,<OffsetW>
<Material During Gate OPEN>
<Material When Gate CLOSE>A datatable is a file that represents the graph(the relationship) between different stations. Dijkstra graphs looks something like this:
In this plugin, A B C D E represent different stations, and the lines in between
represent paths to go between stations. The number in on the line represents the fare to travel on this line (weight).
A datatable could be created via in-game commands:
/data
This command creates a new datatable.
/data new
To add a vertex/edge, do the following:
/data add
Vertex will automatically be created if it is not yet defined in the datatable.
To create a FareTable, start with an Excel file in the following format. Rows and Columns in the table represent the Departure and Arrival Stations respectively.
Save the file as .csv file format.
Open the file with a text editor, copy everything, and upload to pastebin. You should get a link.

Copy the link, fill in the required arguments and execute the following command:
/faretable download
Last but not least, load the fare table with the following command:
/faretable load <name_of_file>
DebitCard Editor requires a vault-supporting economy plugin to be installed.
The plugin comes with a basic DebitCard Editor to do the following:
1. Issue new DebitCard
2. Top-Up a DebitCard from player balance
3. Bank-In to player balance from DebitCard
4. View transaction history
5. Configure auto Top-Up (enable/disable, Top-Up amount, daily limit})
Type the following lines into a WallSign:
[MetroFareDCE] # Configurable in config.ymlOther lines are automatically generated.
Note that the DCE is intended for lazy people to use. It is not very customizable.
Should you need a customized DCE, create your own with the Command/Java API
To create a One-Time Payment Machine, type the following lines into a WallSign:
[MetroFareOTP] # Configurable in config.yml
<Company Name>,<FareAmount>Other lines are automatically generated.
DebitCard could be issued / edited using the following command:
/debitcard
Tickets could be issued using the following command:
/ticket
Refer to tab completion instructions for detailed used of the commands.
This feature requires TrainCarts / MikuCore to be installed.
A DebitCard validator allows automatic exit and re-entry of a debit card, which may be useful for inter company railways.
To create a DebitCard validator, place a Sign/WallSign according to rules defined by MikuCore / TrainCarts for Vanilla and TrainCarts variant respectively.
Vanilla (Requires MikuCore to be installed):
[MetroFareValidator]
<Company From>, <Company Data From>
<Company To>, <Company Data To>TrainCarts (Requires TrainCarts to be installed):
[+train]
validator
<Company From>, <Company Data From>
<Company To>, <Company Data To>Placing a STRUCTURE_VOID above any fence gate would prevent it from being opened by player directly.

It can still be opened by redstone.
The following permission notes are provided to limit access to certain parts of the plugin.
gate: # Allows player to build Entry/Exit Gates, One-Time Payment Machine, and DebitCard Validator.
database: # Allows player to edit DataTable/FareTable
fence: # Allows player to use the fence gate locking feature.
ticketing: # Allows player to place DebitCardEditor, and use Ticket/DebitCard related commands.You can customize the implementation of the plugin in your sever in various ways.
The following commands could be useful to you.
/valueaddmachine <player_name> <...> # Command for DebitCard related process to player.
/vending <player_name> <...> # Command for issuing ticket to player.
To execute the command in Skript, do the following :
execute console command "PUT THE COMMAND HERE"
Use %{VAR_NAME}% if you need to use variables.
The following tags could be used in place of player name in command blocks.
@a : For all players in the server.
@p : For the neareast player to the command block.
There is currently no java api. However, you could call the functions within the plugin via adding it to source.
Add the following repository:
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>Add the following dependency (replace PLUGIN_VERSION):
<dependency>
<groupId>com.github.Hasunemiku2015</groupId>
<artifactId>MetroFare</artifactId>
<version>PLUGIN_VERSION</version>
<scope>provided</scope>
</dependency>Add the following repository:
maven(uri("https://jitpack.io"))Add the following dependency (replace PLUGIN_VERSION):
compileOnly("com.github.Hasunemiku2015:MetroFare:PLUGIN_VERSION")Follow the following instruction if you want to build this plugin from source :
- Download JDK 1.8 (NOT Java Runtime or JRE) and Maven.
- Clone this repository (
git clone https://github.com/Hasunemiku2015/MetroFare.git) - Download MikuCore and add to $projectDir/external-jar
- Do
mvn clean package
Follow the following instruction contribute to the development of this plugin:
- Fork it (https://github.com/Hasunemiku2015/MetroFare/fork)
- Create your feature branch (
git checkout -b feature/fooBar) - Commit your changes (
git commit -am 'Add some fooBar') - Push to the branch (
git push origin feature/fooBar) - Create a new Pull Request
hasunemiku2015 – @Discord hasunemiku2015#1395
Distributed under the MIT license. See LICENSE for more information.
https://github.com/Hasunemiku2015
- The dijkstra algorithm engine is created by vogella.
- This plugin is inspired by MineStileXDD, the creator of the Skript Addon MineStile.




















