me.armar.plugins.autorank.mysql.wrapper
Class MySQLWrapper

java.lang.Object
  extended by me.armar.plugins.autorank.mysql.wrapper.MySQLWrapper

public class MySQLWrapper
extends java.lang.Object

This class keeps all incoming and outgoing under control. It sends MySQL queries and can locate the database. Previously, Playtimes kept all MySQL, but it wasn't neatly organised. MySQLWrapper class is (hopefully) fail-prove and organised. This also has a fail-safe when two queries are altering at the same time.

Author:
Staartvin

Field Summary
(package private)  java.lang.String database
           
(package private)  int databaseTime
           
(package private)  java.lang.String hostname
           
private  SQLDataStorage mysql
           
(package private)  java.lang.String password
           
private  Autorank plugin
           
(package private)  java.lang.String table
           
(package private)  java.lang.Thread timeThread
           
(package private)  java.lang.String username
           
 
Constructor Summary
MySQLWrapper(Autorank instance)
           
 
Method Summary
 java.lang.String getDatabaseName()
           
 int getDatabaseTime(java.lang.String name)
          Gets the database time of player Run this ASYNC!
 boolean isMySQLEnabled()
           
 void setGlobalTime(java.lang.String playerName, int time)
          Sets the time of a player
 void setupTable()
           
 void sqlSetup(SimpleYamlConfiguration config)
           
private  void waitForThread(java.lang.Thread thread)
          Because the MySQL queries are done async, we need to wait for the result.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

plugin

private Autorank plugin

mysql

private SQLDataStorage mysql

hostname

java.lang.String hostname

username

java.lang.String username

password

java.lang.String password

database

java.lang.String database

table

java.lang.String table

databaseTime

int databaseTime

timeThread

java.lang.Thread timeThread
Constructor Detail

MySQLWrapper

public MySQLWrapper(Autorank instance)
Method Detail

setupTable

public void setupTable()

waitForThread

private void waitForThread(java.lang.Thread thread)
Because the MySQL queries are done async, we need to wait for the result. Otherwise it would be cached and out of date. This waits for the thread to die and then it will continue Use this whenever you do an async MySQL thread.


sqlSetup

public void sqlSetup(SimpleYamlConfiguration config)

getDatabaseTime

public int getDatabaseTime(java.lang.String name)
Gets the database time of player Run this ASYNC!

Parameters:
name - Playername to get the time of
Returns:
time player has played across all servers

setGlobalTime

public void setGlobalTime(java.lang.String playerName,
                          int time)
Sets the time of a player

Parameters:
playerName - Player to set the time of
time - Time to change to

isMySQLEnabled

public boolean isMySQLEnabled()

getDatabaseName

public java.lang.String getDatabaseName()