Save a player’s minigame stats (from the stats folder) to your database. By default, we’ll use local sqlite database.

Settings

Edit Settings/Database.yml to add in your database information.

# Typically either MySQL (remote server) or SQLite (local file)
type: "sqlite"
# Host is the IP address of the server, usually localhost
host: "localhost"
# Port for the database (usually 3306 for MySQL)
port: "3306"
# Username for the database
username: ""
# Password for the database
password: ""
# Which database on the server to use
database: "mgm"
# Prefix for all database tables. Useful if multiple plugins are using the same database.
prefix: "games_"
# Use SSL for the connection
use_SSL: true

Keys in the shipped file are type, username, and prefix (not driver / user).

How To Use Database Stats

You can use this information in areas like the Sidebar by using the stat Variables.

# Replaces with the data of a database statistic
{stats:(name):(database table)}

One way to organize this is to use the same name of your Minigame as the Database Table. For example, if you have a game called “Jump4Joy” and you want to count “jumps”,

# Replaces with the number of Jumps in Jump4Joy
{stats:jumps:Jump4Joy}

Another way to use database stats is with the stats placeholder.

%mgm_stats_<stats>_<table>%

Example Jump4Joy Game

We’ll use the command /mgm save-stats <player> <stat-name> <number/letters/simple math> [table] to save the stats directly to the database. Tap here for a full list of Commands.

Events:
  Minigame_Join:
    Commands:
      # Announce the player has joined the game
      - 'send-public-message {player} &6{player}&7 joined the minigame.'
  Server_Leave:
    Commands:
      # Remove the player from the game if they leave the server
      - 'remove-from-minigame {player}'
  Jumping:
    Commands:
      # Add 1 to "jumps" every time a player jumps
      - 'save-stats {player} jumps +1 Jump4Joy'
      - 'send-public-message {player} &e&l| &e{stats:jumps:Jump4Joy} jumps!'

# Set the scoreboard with player stats
Scoreboard:
  title: 'Jumper'
  lines:
    '1': '&7Players: &6{minigame-size}'
    '2': '&7Jumps: &6{stats:jumps:Jump4Joy}'