Tutorials/1. Getting Started

Getting Started with OnTime

In this first tutorial I will explain how to setup most of the Plugin's configuration, and how to use OnTime's most basic functions:

  • Tracking a player's total time on a server (a.k.a. playtime or 'Total OnTime')
  • Displaying a player's OnTime data on the console or in-game

Basic Configuration

The base plugin configuration is found in /plugin/ontime/config.yml. Almost everything you need to use these basic functions are already setup in the default values of the config.yml. There is only one configuration change you must make, and the rest explained here can be considered optional things to change. (There are other items in the configuration file not covered in this tutorial, these will be discussed in other tutorials that highlight some more advanced functions.)

Your Server Name Here

The only change you must make to the config.yml file is to replace "<Your Server Name Here>", including removing the "<>", with the name of your server. This string is used in some of the in game displays and in the generated reports.

from config.yml

# The name of your server
serverName: <Your Server Name Here>

Data Storage Method

OnTime provides three options for the storage of the player data. Which option you use is a somewhat a personal preference, but some methods do offer advantages over the others.

from config.yml

# Selection of Data Storage Method. Valid values= YML, MYSQL
dataStorage: YML

DAT

.dat files were the original method for player data storage on OnTime. These files were prone to errors so use of these has been discontinued, in favor of YML and MySQL formats.

YML

The playerdata.yml storage file holds all of the total, daily, weekly, and monthly data in one place. This file is stored in a readable and editable ASCII format, so addition/modification of player data can be done with 'notepad' or other simple editors. The playtime data is represented in milliseconds (1/1000 second). The 'last login' is expressed in the number of milliseconds since the Jan. 1, 1970. This field also holds the number of different days the player has been on the server, by replacing the milliseconds value with this count. (I suggest never trying to modify this field, and let OnTime deal with the last login info.)

The order of the data in this file is:

- player name, total playtime, last login timestamp, today playtime, week playtime, month playtime

MYSQL

When the MySQL option is selected a MySQL database, which is separate from the OnTime plugin, must be setup and configured. There a lot of other tutorials out there showing how to setup an MySQL database, many of which are specific to setting one up for use with MineCraft, so I will not cover this here.
Using the MySQL database opens up some new options for use of OnTime data in other plugins, scripts, and web pages. I am just mentioning this here, but will not provide any tutorials on how to go about using the data in this way.

Once a MySQL database is set up on your server, using it requires proper setup of the database access via the /plugin/ontime/config.yml file. From the items below those most likely to require a change are the 'enable' (to turn it on for OnTime), the user, and the password. (User and Password are set as part of your MySQL database creation process.)

from config.yml

# MySQL - This must be enabled and properly set up if MySQL is to be used for data storage and/or
# data import is to be done from another plugin MySQL table. (currently support for LogBlock is provided)
MySQL:

enable: false
host: localhost
port: 3306
user: root
password: password
database: minecraft

ontime-players table

Below are the attributes of the ontime-players MySQL Table

  • id: (integer) A running id number, unique to every player to have ever logged onto the server.
  • playerName: (string) The player's login name
  • playtime: (long) The total playtime a player has on the server in milliseconds. (1/1000 second)
  • logintime: (long) The timestamp of a players last login. This is a value expressed in milliseconds, since Jan. 1, 1970.
  • todaytime: (long) The amount of playtime (in milliseconds) of the player for the current day. (since 12:00 AM)
  • weektime: (long) The amount of playtime (in milliseconds) of the player for the current week.
  • monthtime: (long) The amount of playtime (in milliseconds) of the player for the current month.
  • votes: (int) The number of times that a player has voted for the server via some website that supports Votifier
  • lastVote: (long) The timestamp of a player's last vote. This is a value expressed in milliseconds, since Jan. 1, 1970.
  • referrals*: (int) The number of times this player has been used as a reference by aother player.
  • firstlogin: (long) The timestamp of a player's first login to the server. This is a value expressed in milliseconds, since Jan. 1, 1970.
  • referredby: (string) The login name of the player that referred this player to the server.

Purging

The OnTime purging function was added to help keep your OnTime data under control. There is no need to waste your system resources on players that only visit once for a minute and never come back, or on players that just no longer use your server. When this is enabled and configured, each time the player data is stored to disk the players which have not been on for the minimum number of minutes, or have been away for the maximum number of days will be removed before the data is saved. Players online at the time of the purge activity will not be removed, regardless of their amount of playtime.

from config.yml

# If purge is enabled users will be auto removed from stored file if they don't have enough play time / or have not been on for so long
purgeEnable: true

# minimum time in minutes someone has to be on for their data to be saved
purgeTimeMin: 10

# maximum time in days since last login before purge
purgeLoginDay: 60

AutoSave and AutoBackup

To provide as much protection as possible against accidental data loss, OnTime provides the functions of regular, scheduled save and backup events. The save event will update all of the current player data via the configured storage method.

The backup event will generate copies of the playerdata.yml files into the sub-directory /plugins/ontime/backup . The backups are created daily, near the beginning of each new day, and multiple days worth of backups can be retained, as configured in the config.yml.

NOTE: If you are using MySQL storage the OnTime auto backup function is inactive. Please consult your MySQL database manager for methods of backing up the MySQL data.

from config.yml

# Enable if data should be saved to disk on scheduled event. Otherwise it will happen on server shutdown only
autoSaveEnable: true

# If auto file save is enabled above, how frequently (server ticks) should this be done. (72000 = 1 hour)
autoSavePeriod: 72000

# Enable if backup versions of data files should be auto-created each day
autoBackupEnable: true

# If auto backup is enabled above, how many versions should be retained?
autoBackupVersions: 3

Tracking Playing Time

The tracking of total playing time is done automatically, so there really is nothing that is needed to make this happen.

AFK

By the default settings the plugin will suspend counting of a player's Total OnTime if the plugin determines that they are AFK (Away From Keyboard), or in other words are doing nothing. By default, a player will be considered AFK if they do not move, interact with a block, or interact with another entity for 10 minutes. This function can be enabled/disabled and the time of inactivity can be set via the config.yml.

from config.yml

# Enable if AFK status to be checked, and AFK time NOT counted
afkCheckEnable: true

# If AFK is enabled, max time (minutes) with no activity before player is considered AFK
afkTime: 10

Seeing Playing Time

/ontime (self)

ex: /ontime

There is really only one command needed to see playing time and that simply is "/ontime".
When used in this format (without additional parameters) this command cannot be executed on the console, but only in-game. This command will display to the player his current information. The default output includes:

  • Playtime for current login
  • Playtime for current day
  • Playtime for current week
  • Playtime for current month
  • Playtime for all time on the server (a.k.a Total OnTime)

To be able to use this command the player must have the following permission setting:

ontime.me

The output generated when this command is executed is configurable, but I will cover how to do this in another tutorial.

/ontime <playerName> (others & self)

ex: /ontime Edge209

When the /ontime command includes the specification of a player (<playerName>) a different set of data is output to the person executing the command. Since 'self' is not implied, this version of the command can be executed on the console as well as in-game. The default output includes:

  • Number of total days since the player first joined the server
  • Number of different days since that time the player has been on the server
  • Timestamp of the players last login
  • Playtime for current login (and AFK status)
  • The amount of AFK time for the current login
  • Playtime for current day
  • Playtime for current week
  • Playtime for current month
  • Playtime for all time on the server (a.k.a Total OnTime)
  • Number of votes for the server cast by the player
  • Date the player last voted
  • The name of the player that referred this player
  • Number of referrals this player has made
  • Rewards currently scheduled for the player


To be able to use this command the player must have the following permission setting:

ontime.other


A player can execute this command on any other player found in the OnTime database, or on himself.

The output generated when this command is executed is configurable, but I will cover how to do this in another tutorial.

END TUTORIAL


Comments

Posts Quoted:
Reply
Clear All Quotes