OnTime API

The OnTime plugin comes with four API functions that can be used to access OnTime data. (OnTime V3.8.0 or later is required)

To use this API:
1. Place the OnTime.jar into the JAVA build path for your bukkit project.
2. Import the OnTimeAPI in the JAVA class files that are to be interfaced:

> import me.edge209.OnTime.OnTimeAPI;

3. Use one of the four function calls:

a. See if a player has an record in the OnTime Database

	/**
	 * hasOnTimeRecord
	 * 
	 * This function will return true if the player has a record within the OnTime database
	 * 
	 * @param PlayerName
	 * @return Boolean (True/False)
	 */
	public static boolean playerHasOnTimeRecord(String playerName) {
		return (PlayingTime.playerHasOnTimeRecord(playerName));
	}


b. Validate/complete/match a player's name in the OnTime database. This function will return an array of player names that match the sub-string provided. If there is no match, it will return null. If there is a single match it will return the full string match. If there are multiple matches it will return a string array of the full names containing the sub-string provided.

	/**
	 * matchPlayerNames
	 * v3.9.0
	 * 
	 * This function will return a list of player names contained in the OnTime database that match all or a portion
	 * of the specified name "root".
	 * 
	 * @param nameRoot - Name root to be matched against OnTime records
	 * *
	 * @return String[] : List of matching names found in the OnTime Database
	 * 					   Will be (null) if no matches are found
	 */
	public static String[] matchPlayerNames(String nameRoot){
		return(DataIO.matchPlayerNames(nameRoot));
	}
	

c. Get an piece of OnTime data. There is a single function used to get the different pieces of data, so your call must specify what data you want using the enum defined in the API class:

public enum data {TOTALPLAY, TODAYPLAY, WEEKPLAY, MONTHPLAY, LASTLOGIN,TOTALVOTE, TODAYVOTE, WEEKVOTE, MONTHVOTE, ,LASTVOTE, TOTALREFER, TODAYREFER, WEEKREFER, MONTHREFER};

Where:

  • LASTLOGIN = The time stamp (date and time) of the player's last login (join) event. The returned value is in milliseconds, and is the number of milliseconds that have passed since the JAVA epoch date of January 1, 1970.
  • TODAYPLAY = The time a player has spent on your server since midnight of the current day. The returned value is in milliseconds.
  • WEEKPLAY = The time a player has spent on your server since midnight of the first day of the current week. The first day of the week is set in the OnTime/config.yml. The returned value is in milliseconds.
  • MONTHPLAY = The time a player has spent on your server since midnight of the first day of the current month. The first day of the month is set in the OnTime/config.yml. The returned value is in milliseconds.
  • TOTALPLAY = Total play time (OnTime) a player has spent on your server. The returned value is in milliseconds.
  • TOTDAYVOTE = Number of votes cast by the player in the current day.
  • WEEKVOTE = Number of votes cast by the player in the current week.
  • MONTHVOTE = Number of votes cast by the player in the current month.
  • TOTALVOTE = Number of votes coast by the player for all time.
  • LASTVOTE = The time stamp (date and time) of the player's last received vote for the server. The returned value is in milliseconds, and is the number of milliseconds that have passed since the JAVA epoch date of January 1, 1970.
  • TOTDAYREFER = Number of referrals made by the player in the current day.
  • WEEKREFER = Number of referrals made by the player in the current week.
  • MONTHREFER = Number of referrals made by the player in the current month.
  • TOTALREFER = Number of referrals made by the player for all time.

	/**
	 * 
	 * @param playerName - Name of the player whose data is to be retrieved
	 * @param data - Data to retrieve: TOTALPLAY, TODAYPLAY, WEEKPLAY, MONTHPLAY, LASTLOGIN, TOTALVOTE, TODAYVOTE, WEEKVOTE, MONTHVOTE, LASTVOTE, TOTALREFER, TODAYREFER, WEEKREFER, MONTHREFER
	 * @return data (long) = all *PLAY data in milliseconds; lastlogin & lastvote = # of milliseconds since Jan 1, 1970; vote = count of votes
	 * 					   = -1 if data not found for the specified player
	 */
	public static long getPlayerTimeData(String playerName, OnTimeAPI.data data) {
		return(DataIO.getPlayerTimeData(playerName, data));
		
	}

d. Get an ordered "top" list set of player names and their data. This function will return a sorted list of player name and data pairs, sorted by the specified data from highest to lowest values. The number of data sets returned is as specified by the "topListMax" parameter defined in the OnTime/config.yml.

The data set supported is the same as listed above for "getPlayerTimeData" above with the exception of LASTLOGIN, which is not supported.

	/**
	 * getTopData
	 * v3.9.0
	 * 
	 * This function will return an array of player name and data pairs for the specified data type.  The order of
	 * the data is sorted from the highest value to the lowest value.
	 * 
	 * @param data - Data to retrieve: TOTALPLAY, TODAYPLAY, WEEKPLAY, MONTHPLAY, TOTALVOTE, TODAYVOTE, WEEKVOTE, MONTHVOTE, TOTALREFER, TODAYREFER, WEEKREFER, MONTHREFER
	 * @return topData[] - (String, long) Array of player name an data value pairs for the specified data, sorted highest to lowest data values.
	 */
	public static topData[] getTopData(OnTimeAPI.data data){
		return(DataIO.getTopData(data));
	}

Comments

  • To post a comment, please or register a new account.
Posts Quoted:
Reply
Clear All Quotes