close db then plugin is disabled
This commit is contained in:
parent
78e65372d9
commit
752da189c2
|
@ -35,4 +35,9 @@ public class DB
|
||||||
{
|
{
|
||||||
return m_DBClass.getPlayerTime(_playerUUID);
|
return m_DBClass.getPlayerTime(_playerUUID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void close()
|
||||||
|
{
|
||||||
|
m_DBClass.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,4 +32,5 @@ public interface IDB
|
||||||
public void update(UUID _playerUUID, int _newTime);
|
public void update(UUID _playerUUID, int _newTime);
|
||||||
public List<String[]> getTopPlayers(int _count);
|
public List<String[]> getTopPlayers(int _count);
|
||||||
public int getPlayerTime(UUID _playerUUID);
|
public int getPlayerTime(UUID _playerUUID);
|
||||||
|
public void close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,4 +111,13 @@ public class MySQL implements IDB
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void close()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
m_MySqlTools.getConnection().close();
|
||||||
|
} catch (SQLException throwables) {
|
||||||
|
throwables.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,4 +133,13 @@ public class SQLLite implements IDB
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void close()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
m_connection.close();
|
||||||
|
} catch (SQLException throwables) {
|
||||||
|
throwables.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class Playtime extends JavaPlugin implements Listener
|
||||||
|
|
||||||
//Load the text from the lang config.
|
//Load the text from the lang config.
|
||||||
if(m_db == null)
|
if(m_db == null)
|
||||||
m_db = new DB(this, m_config);
|
m_db = new DB(this, m_config);
|
||||||
|
|
||||||
getServer().getPluginManager().registerEvents(this, this);
|
getServer().getPluginManager().registerEvents(this, this);
|
||||||
|
|
||||||
|
@ -62,6 +62,17 @@ public class Playtime extends JavaPlugin implements Listener
|
||||||
}}, 0, 1200);
|
}}, 0, 1200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable()
|
||||||
|
{
|
||||||
|
//Load the text from the lang config.
|
||||||
|
if(m_db != null)
|
||||||
|
{
|
||||||
|
m_db.close();
|
||||||
|
m_db = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isInteger(String s) {
|
public static boolean isInteger(String s) {
|
||||||
try {
|
try {
|
||||||
Integer.parseInt(s);
|
Integer.parseInt(s);
|
||||||
|
|
Loading…
Reference in New Issue