Database.java cleanup

This commit is contained in:
GJ 2012-03-07 01:42:43 -05:00
parent a8aed1bf02
commit 653e06dd03
7 changed files with 341 additions and 299 deletions

View File

@ -1,93 +1,95 @@
/* /*
This file is part of mcMMO. * Copyright (C) 2012 Matt 'The Yeti' Burnett & mcMMO Development
* Copyright (C) 2010-2011 'nossr50'
mcMMO is free software: you can redistribute it and/or modify *
it under the terms of the GNU General Public License as published by * This program is free software: you can redistribute it and/or modify
the Free Software Foundation, either version 3 of the License, or * it under the terms of the GNU General Public License as published by
(at your option) any later version. * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
mcMMO is distributed in the hope that it will be useful, *
but WITHOUT ANY WARRANTY; without even the implied warranty of * This program is distributed in the hope that it will be useful,
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
You should have received a copy of the GNU General Public License *
along with mcMMO. If not, see <http://www.gnu.org/licenses/>. * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package com.gmail.nossr50; package com.gmail.nossr50;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DriverManager; import java.sql.DriverManager;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.PreparedStatement;
import java.util.HashMap; import java.util.HashMap;
import java.util.ArrayList; import java.util.ArrayList;
import java.sql.PreparedStatement; import java.util.Properties;
import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.config.LoadProperties;
import datatypes.DatabaseUpdate;
public class Database { public class Database {
private mcMMO plugin; private mcMMO plugin;
private String connectionString = "jdbc:mysql://" + LoadProperties.MySQLserverName + ":" + LoadProperties.MySQLport + "/" + LoadProperties.MySQLdbName + "?user=" + LoadProperties.MySQLuserName + "&password=" + LoadProperties.MySQLdbPass; private String connectionString = "jdbc:mysql://" + LoadProperties.MySQLserverName + ":" + LoadProperties.MySQLport + "/" + LoadProperties.MySQLdbName + "?user=" + LoadProperties.MySQLuserName + "&password=" + LoadProperties.MySQLdbPass;
private boolean isConnected = false; private boolean isConnected;
private Connection conn = null; private Connection conn = null;
public void connect() public Database(mcMMO instance) {
{ connect(); //Connect to MySQL
try this.plugin = instance;
{
// Load the driver instance
try {
Class.forName("com.mysql.jdbc.Driver");
DriverManager.getConnection(connectionString);
}
catch (ClassNotFoundException e) {
plugin.getServer().getLogger().warning(e.getLocalizedMessage());
}
catch (SQLException ex) {
plugin.getServer().getLogger().warning(ex.getLocalizedMessage());
printErrors(ex);
}
}
/**
* Attempt to connect to the mySQL database.
*/
public void connect() {
try {
System.out.println("[mcMMO] Attempting connection to MySQL..."); System.out.println("[mcMMO] Attempting connection to MySQL...");
java.util.Properties conProperties = new java.util.Properties(); Properties conProperties = new Properties();
conProperties.put("autoReconnect", "true"); conProperties.put("autoReconnect", "true");
conProperties.put("maxReconnects", "3"); conProperties.put("maxReconnects", "3");
conn = DriverManager.getConnection(connectionString, conProperties); conn = DriverManager.getConnection(connectionString, conProperties);
isConnected = true; isConnected = true;
System.out.println("[mcMMO] Connection to MySQL established!"); System.out.println("[mcMMO] Connection to MySQL established!");
} catch (SQLException ex) }
{ catch (SQLException ex) {
isConnected = false; isConnected = false;
ex.printStackTrace(); ex.printStackTrace();
System.out.println("SQLException: " + ex.getMessage()); printErrors(ex);
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
} }
} }
public boolean isConnected() /**
{ * Attempt to create the database structure.
return isConnected; */
}
public Database(mcMMO instance) {
connect(); //Connect to MySQL
this.plugin = instance;
// Load the driver instance
try {
Class.forName("com.mysql.jdbc.Driver");
DriverManager.getConnection(connectionString);
} catch (ClassNotFoundException e) {
plugin.getServer().getLogger().warning(e.getLocalizedMessage());
} catch (SQLException e) {
plugin.getServer().getLogger().warning(e.getLocalizedMessage());
System.out.println("SQLException: " + e.getMessage());
System.out.println("SQLState: " + e.getSQLState());
System.out.println("VendorError: " + e.getErrorCode());
}
}
//Create the DB structure
public void createStructure() { public void createStructure() {
Write("CREATE TABLE IF NOT EXISTS `" + LoadProperties.MySQLtablePrefix + "huds` (`user_id` int(10) unsigned NOT NULL," write("CREATE TABLE IF NOT EXISTS `" + LoadProperties.MySQLtablePrefix + "huds` (`user_id` int(10) unsigned NOT NULL,"
+ "`hudtype` varchar(50) NOT NULL DEFAULT ''," + "`hudtype` varchar(50) NOT NULL DEFAULT '',"
+ "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); + "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
Write("CREATE TABLE IF NOT EXISTS `" + LoadProperties.MySQLtablePrefix + "users` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT," write("CREATE TABLE IF NOT EXISTS `" + LoadProperties.MySQLtablePrefix + "users` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT,"
+ "`user` varchar(40) NOT NULL," + "`user` varchar(40) NOT NULL,"
+ "`lastlogin` int(32) unsigned NOT NULL," + "`lastlogin` int(32) unsigned NOT NULL,"
+ "`party` varchar(100) NOT NULL DEFAULT ''," + "`party` varchar(100) NOT NULL DEFAULT '',"
+ "PRIMARY KEY (`id`)," + "PRIMARY KEY (`id`),"
+ "UNIQUE KEY `user` (`user`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;"); + "UNIQUE KEY `user` (`user`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;");
Write("CREATE TABLE IF NOT EXISTS `" + LoadProperties.MySQLtablePrefix + "cooldowns` (`user_id` int(10) unsigned NOT NULL," write("CREATE TABLE IF NOT EXISTS `" + LoadProperties.MySQLtablePrefix + "cooldowns` (`user_id` int(10) unsigned NOT NULL,"
+ "`taming` int(32) unsigned NOT NULL DEFAULT '0'," + "`taming` int(32) unsigned NOT NULL DEFAULT '0',"
+ "`mining` int(32) unsigned NOT NULL DEFAULT '0'," + "`mining` int(32) unsigned NOT NULL DEFAULT '0',"
+ "`woodcutting` int(32) unsigned NOT NULL DEFAULT '0'," + "`woodcutting` int(32) unsigned NOT NULL DEFAULT '0',"
@ -101,7 +103,7 @@ public class Database {
+ "`acrobatics` int(32) unsigned NOT NULL DEFAULT '0'," + "`acrobatics` int(32) unsigned NOT NULL DEFAULT '0',"
+ "`blast_mining` int(32) unsigned NOT NULL DEFAULT '0'," + "`blast_mining` int(32) unsigned NOT NULL DEFAULT '0',"
+ "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); + "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
Write("CREATE TABLE IF NOT EXISTS `" + LoadProperties.MySQLtablePrefix + "skills` (`user_id` int(10) unsigned NOT NULL," write("CREATE TABLE IF NOT EXISTS `" + LoadProperties.MySQLtablePrefix + "skills` (`user_id` int(10) unsigned NOT NULL,"
+ "`taming` int(10) unsigned NOT NULL DEFAULT '0'," + "`taming` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`mining` int(10) unsigned NOT NULL DEFAULT '0'," + "`mining` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`woodcutting` int(10) unsigned NOT NULL DEFAULT '0'," + "`woodcutting` int(10) unsigned NOT NULL DEFAULT '0',"
@ -114,7 +116,7 @@ public class Database {
+ "`axes` int(10) unsigned NOT NULL DEFAULT '0'," + "`axes` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`acrobatics` int(10) unsigned NOT NULL DEFAULT '0'," + "`acrobatics` int(10) unsigned NOT NULL DEFAULT '0',"
+ "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); + "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
Write("CREATE TABLE IF NOT EXISTS `" + LoadProperties.MySQLtablePrefix + "experience` (`user_id` int(10) unsigned NOT NULL," write("CREATE TABLE IF NOT EXISTS `" + LoadProperties.MySQLtablePrefix + "experience` (`user_id` int(10) unsigned NOT NULL,"
+ "`taming` int(10) unsigned NOT NULL DEFAULT '0'," + "`taming` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`mining` int(10) unsigned NOT NULL DEFAULT '0'," + "`mining` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`woodcutting` int(10) unsigned NOT NULL DEFAULT '0'," + "`woodcutting` int(10) unsigned NOT NULL DEFAULT '0',"
@ -128,20 +130,35 @@ public class Database {
+ "`acrobatics` int(10) unsigned NOT NULL DEFAULT '0'," + "`acrobatics` int(10) unsigned NOT NULL DEFAULT '0',"
+ "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); + "PRIMARY KEY (`user_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
Write("DROP TABLE IF EXISTS `"+LoadProperties.MySQLtablePrefix+"skills2`"); write("DROP TABLE IF EXISTS `"+LoadProperties.MySQLtablePrefix+"skills2`");
Write("DROP TABLE IF EXISTS `"+LoadProperties.MySQLtablePrefix+"experience2`"); write("DROP TABLE IF EXISTS `"+LoadProperties.MySQLtablePrefix+"experience2`");
Write("DROP TABLE IF EXISTS `"+LoadProperties.MySQLtablePrefix+"spawn`"); write("DROP TABLE IF EXISTS `"+LoadProperties.MySQLtablePrefix+"spawn`");
checkDatabaseStructure(); checkDatabaseStructure(DatabaseUpdate.FISHING);
checkDatabaseStructureForBlastMining(); checkDatabaseStructure(DatabaseUpdate.BLAST_MINING);
} }
public void checkDatabaseStructure() /**
{ * Check database structure for missing values.
String sql = "SELECT * FROM `"+LoadProperties.MySQLtablePrefix+"experience` ORDER BY `"+LoadProperties.MySQLtablePrefix+"experience`.`fishing` ASC LIMIT 0 , 30"; *
* @param update Type of data to check updates for
*/
public void checkDatabaseStructure(DatabaseUpdate update) {
String sql = null;
ResultSet rs = null; ResultSet rs = null;
HashMap<Integer, ArrayList<String>> Rows = new HashMap<Integer, ArrayList<String>>(); HashMap<Integer, ArrayList<String>> Rows = new HashMap<Integer, ArrayList<String>>();
switch (update) {
case BLAST_MINING:
sql = "SELECT * FROM `"+LoadProperties.MySQLtablePrefix+"cooldowns` ORDER BY `"+LoadProperties.MySQLtablePrefix+"cooldowns`.`blast_mining` ASC LIMIT 0 , 30";
break;
case FISHING:
sql = "SELECT * FROM `"+LoadProperties.MySQLtablePrefix+"experience` ORDER BY `"+LoadProperties.MySQLtablePrefix+"experience`.`fishing` ASC LIMIT 0 , 30";
break;
default:
break;
}
try { try {
PreparedStatement stmt = conn.prepareStatement(sql); PreparedStatement stmt = conn.prepareStatement(sql);
if (stmt.executeQuery() != null) { if (stmt.executeQuery() != null) {
@ -155,73 +172,62 @@ public class Database {
Rows.put(rs.getRow(), Col); Rows.put(rs.getRow(), Col);
} }
} }
} catch (SQLException ex) {
System.out.println("Updating mcMMO MySQL tables for Fishing...");
Write("ALTER TABLE `"+LoadProperties.MySQLtablePrefix + "skills` ADD `fishing` int(10) NOT NULL DEFAULT '0' ;");
Write("ALTER TABLE `"+LoadProperties.MySQLtablePrefix + "experience` ADD `fishing` int(10) NOT NULL DEFAULT '0' ;");
} }
} catch (SQLException ex) {
if (update.equals(DatabaseUpdate.BLAST_MINING)) {
public void checkDatabaseStructureForBlastMining()
{
String sql = "SELECT * FROM `"+LoadProperties.MySQLtablePrefix+"cooldowns` ORDER BY `"+LoadProperties.MySQLtablePrefix+"cooldowns`.`blast_mining` ASC LIMIT 0 , 30";
ResultSet rs = null;
HashMap<Integer, ArrayList<String>> Rows = new HashMap<Integer, ArrayList<String>>();
try {
PreparedStatement stmt = conn.prepareStatement(sql);
if (stmt.executeQuery() != null) {
stmt.executeQuery();
rs = stmt.getResultSet();
while (rs.next()) {
ArrayList<String> Col = new ArrayList<String>();
for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
Col.add(rs.getString(i));
}
Rows.put(rs.getRow(), Col);
}
}
} catch (SQLException ex) {
System.out.println("Updating mcMMO MySQL tables for Blast Mining..."); System.out.println("Updating mcMMO MySQL tables for Blast Mining...");
Write("ALTER TABLE `"+LoadProperties.MySQLtablePrefix + "cooldowns` ADD `blast_mining` int(32) NOT NULL DEFAULT '0' ;"); write("ALTER TABLE `"+LoadProperties.MySQLtablePrefix + "cooldowns` ADD `blast_mining` int(32) NOT NULL DEFAULT '0' ;");
}
else if (update.equals(DatabaseUpdate.FISHING)) {
System.out.println("Updating mcMMO MySQL tables for Fishing...");
write("ALTER TABLE `"+LoadProperties.MySQLtablePrefix + "skills` ADD `fishing` int(10) NOT NULL DEFAULT '0' ;");
write("ALTER TABLE `"+LoadProperties.MySQLtablePrefix + "experience` ADD `fishing` int(10) NOT NULL DEFAULT '0' ;");
}
} }
} }
// write query /**
public boolean Write(String sql) { * Attempt to write the SQL query.
if(conn != null) *
{ * @param sql Query to write.
* @return true if the query was successfully written, false otherwise.
*/
public boolean write(String sql) {
if (conn != null) {
try { try {
PreparedStatement stmt = conn.prepareStatement(sql); PreparedStatement stmt = conn.prepareStatement(sql);
stmt.executeUpdate(); stmt.executeUpdate();
return true; return true;
} catch (SQLException ex) { }
System.out.println("SQLException: " + ex.getMessage()); catch (SQLException ex) {
System.out.println("SQLState: " + ex.getSQLState()); printErrors(ex);
System.out.println("VendorError: " + ex.getErrorCode());
return false; return false;
} }
} else }
{ else {
isConnected = false; isConnected = false;
connect(); //Attempt to reconnect connect(); //Attempt to reconnect
if(isConnected = true) if (isConnected) {
{ write(sql); //Try the same operation again now that we are connected
Write(sql); //Try the same operation again now that we are connected }
} else { else {
System.out.println("[mcMMO] Unable to connect to MySQL! Make sure the SQL server is online!"); System.out.println("[mcMMO] Unable to connect to MySQL! Make sure the SQL server is online!");
} }
} }
return false; return false;
} }
// Get Int /**
// only return first row / first field * Get the Integer. Only return first row / first field.
public Integer GetInt(String sql) { *
* @param sql SQL query to execute
* @return the value in the first row / first field
*/
public Integer getInt(String sql) {
ResultSet rs = null; ResultSet rs = null;
Integer result = 0; Integer result = 0;
if(conn != null)
{ if (conn != null) {
try { try {
PreparedStatement stmt = conn.prepareStatement(sql); PreparedStatement stmt = conn.prepareStatement(sql);
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
@ -230,34 +236,40 @@ public class Database {
rs = stmt.getResultSet(); rs = stmt.getResultSet();
if (rs.next()) { if (rs.next()) {
result = rs.getInt(1); result = rs.getInt(1);
} else { }
else {
result = 0; result = 0;
} }
} }
} catch (SQLException ex) {
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
} }
} else { catch (SQLException ex) {
printErrors(ex);
}
}
else {
isConnected = false; isConnected = false;
connect(); //Attempt to reconnect connect(); //Attempt to reconnect
if(isConnected = true) if (isConnected) {
{ getInt(sql); //Try the same operation again now that we are connected
GetInt(sql); //Try the same operation again now that we are connected }
} else { else {
System.out.println("[mcMMO] Unable to connect to MySQL! Make sure the SQL server is online!"); System.out.println("[mcMMO] Unable to connect to MySQL! Make sure the SQL server is online!");
} }
} }
return result; return result;
} }
// read query /**
public HashMap<Integer, ArrayList<String>> Read(String sql) { * Read SQL query.
*
* @param sql SQL query to read
* @return the rows in this SQL query
*/
public HashMap<Integer, ArrayList<String>> read(String sql) {
ResultSet rs = null; ResultSet rs = null;
HashMap<Integer, ArrayList<String>> Rows = new HashMap<Integer, ArrayList<String>>(); HashMap<Integer, ArrayList<String>> Rows = new HashMap<Integer, ArrayList<String>>();
if(conn != null)
{ if (conn != null) {
try { try {
PreparedStatement stmt = conn.prepareStatement(sql); PreparedStatement stmt = conn.prepareStatement(sql);
if (stmt.executeQuery() != null) { if (stmt.executeQuery() != null) {
@ -271,21 +283,27 @@ public class Database {
Rows.put(rs.getRow(), Col); Rows.put(rs.getRow(), Col);
} }
} }
} catch (SQLException ex) {
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
} }
} else { catch (SQLException ex) {
printErrors(ex);
}
}
else {
isConnected = false; isConnected = false;
connect(); //Attempt to reconnect connect(); //Attempt to reconnect
if(isConnected = true) if (isConnected) {
{ read(sql); //Attempt the same operation again now that we are connected
Read(sql); //Attempt the same operation again now that we are connected }
} else { else {
System.out.println("[mcMMO] Unable to connect to MySQL! Make sure the SQL server is online!"); System.out.println("[mcMMO] Unable to connect to MySQL! Make sure the SQL server is online!");
} }
} }
return Rows; return Rows;
} }
private static void printErrors(SQLException ex) {
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
}
} }

View File

@ -38,30 +38,30 @@ public class McremoveCommand implements CommandExecutor {
//If the server is using MySQL //If the server is using MySQL
if(LoadProperties.useMySQL) if(LoadProperties.useMySQL)
{ {
int userId = mcMMO.database.GetInt("SELECT id FROM "+LoadProperties.MySQLtablePrefix+"users WHERE user = '" + playerName + "'"); int userId = mcMMO.database.getInt("SELECT id FROM "+LoadProperties.MySQLtablePrefix+"users WHERE user = '" + playerName + "'");
//Remove user from tables //Remove user from tables
mcMMO.database.Write("DELETE FROM " mcMMO.database.write("DELETE FROM "
+LoadProperties.MySQLdbName+"." +LoadProperties.MySQLdbName+"."
+LoadProperties.MySQLtablePrefix+"users WHERE " +LoadProperties.MySQLtablePrefix+"users WHERE "
+LoadProperties.MySQLtablePrefix+"users.id="+userId); +LoadProperties.MySQLtablePrefix+"users.id="+userId);
mcMMO.database.Write("DELETE FROM " mcMMO.database.write("DELETE FROM "
+LoadProperties.MySQLdbName+"." +LoadProperties.MySQLdbName+"."
+LoadProperties.MySQLtablePrefix+"cooldowns WHERE " +LoadProperties.MySQLtablePrefix+"cooldowns WHERE "
+LoadProperties.MySQLtablePrefix+"cooldowns.user_id="+userId); +LoadProperties.MySQLtablePrefix+"cooldowns.user_id="+userId);
mcMMO.database.Write("DELETE FROM " mcMMO.database.write("DELETE FROM "
+LoadProperties.MySQLdbName+"." +LoadProperties.MySQLdbName+"."
+LoadProperties.MySQLtablePrefix+"huds WHERE " +LoadProperties.MySQLtablePrefix+"huds WHERE "
+LoadProperties.MySQLtablePrefix+"huds.user_id="+userId); +LoadProperties.MySQLtablePrefix+"huds.user_id="+userId);
mcMMO.database.Write("DELETE FROM " mcMMO.database.write("DELETE FROM "
+LoadProperties.MySQLdbName+"." +LoadProperties.MySQLdbName+"."
+LoadProperties.MySQLtablePrefix+"skills WHERE " +LoadProperties.MySQLtablePrefix+"skills WHERE "
+LoadProperties.MySQLtablePrefix+"skills.user_id="+userId); +LoadProperties.MySQLtablePrefix+"skills.user_id="+userId);
mcMMO.database.Write("DELETE FROM " mcMMO.database.write("DELETE FROM "
+LoadProperties.MySQLdbName+"." +LoadProperties.MySQLdbName+"."
+LoadProperties.MySQLtablePrefix+"experience WHERE " +LoadProperties.MySQLtablePrefix+"experience WHERE "
+LoadProperties.MySQLtablePrefix+"experience.user_id="+userId); +LoadProperties.MySQLtablePrefix+"experience.user_id="+userId);

View File

@ -138,22 +138,22 @@ public class MctopCommand implements CommandExecutor {
n = n * (n2 - 1); n = n * (n2 - 1);
} }
// If a page number is specified // If a page number is specified
HashMap<Integer, ArrayList<String>> userslist = mcMMO.database.Read("SELECT " + lowercase + ", user_id FROM " + LoadProperties.MySQLtablePrefix + "skills WHERE " + lowercase + " > 0 ORDER BY `" + LoadProperties.MySQLtablePrefix + "skills`.`" + lowercase + "` DESC "); HashMap<Integer, ArrayList<String>> userslist = mcMMO.database.read("SELECT " + lowercase + ", user_id FROM " + LoadProperties.MySQLtablePrefix + "skills WHERE " + lowercase + " > 0 ORDER BY `" + LoadProperties.MySQLtablePrefix + "skills`.`" + lowercase + "` DESC ");
for (int i = n; i <= n + 10; i++) { for (int i = n; i <= n + 10; i++) {
if (i > userslist.size() || mcMMO.database.Read("SELECT user FROM " + LoadProperties.MySQLtablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'") == null) if (i > userslist.size() || mcMMO.database.read("SELECT user FROM " + LoadProperties.MySQLtablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'") == null)
break; break;
HashMap<Integer, ArrayList<String>> username = mcMMO.database.Read("SELECT user FROM " + LoadProperties.MySQLtablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'"); HashMap<Integer, ArrayList<String>> username = mcMMO.database.read("SELECT user FROM " + LoadProperties.MySQLtablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'");
player.sendMessage(String.valueOf(i) + ". " + ChatColor.GREEN + userslist.get(i).get(0) + " - " + ChatColor.WHITE + username.get(1).get(0)); player.sendMessage(String.valueOf(i) + ". " + ChatColor.GREEN + userslist.get(i).get(0) + " - " + ChatColor.WHITE + username.get(1).get(0));
} }
return true; return true;
} }
// If no page number is specified // If no page number is specified
HashMap<Integer, ArrayList<String>> userslist = mcMMO.database.Read("SELECT " + lowercase + ", user_id FROM " + LoadProperties.MySQLtablePrefix + "skills WHERE " + lowercase + " > 0 ORDER BY `" + LoadProperties.MySQLtablePrefix + "skills`.`" + lowercase + "` DESC "); HashMap<Integer, ArrayList<String>> userslist = mcMMO.database.read("SELECT " + lowercase + ", user_id FROM " + LoadProperties.MySQLtablePrefix + "skills WHERE " + lowercase + " > 0 ORDER BY `" + LoadProperties.MySQLtablePrefix + "skills`.`" + lowercase + "` DESC ");
for (int i = 1; i <= 10; i++) { // i<=userslist.size() for (int i = 1; i <= 10; i++) { // i<=userslist.size()
if (i > userslist.size() || mcMMO.database.Read("SELECT user FROM " + LoadProperties.MySQLtablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'") == null) if (i > userslist.size() || mcMMO.database.read("SELECT user FROM " + LoadProperties.MySQLtablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'") == null)
break; break;
HashMap<Integer, ArrayList<String>> username = mcMMO.database.Read("SELECT user FROM " + LoadProperties.MySQLtablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'"); HashMap<Integer, ArrayList<String>> username = mcMMO.database.read("SELECT user FROM " + LoadProperties.MySQLtablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'");
player.sendMessage(String.valueOf(i) + ". " + ChatColor.GREEN + userslist.get(i).get(0) + " - " + ChatColor.WHITE + username.get(1).get(0)); player.sendMessage(String.valueOf(i) + ". " + ChatColor.GREEN + userslist.get(i).get(0) + " - " + ChatColor.WHITE + username.get(1).get(0));
} }
return true; return true;
@ -169,20 +169,20 @@ public class MctopCommand implements CommandExecutor {
n = n * (n2 - 1); n = n * (n2 - 1);
} }
// If a page number is specified // If a page number is specified
HashMap<Integer, ArrayList<String>> userslist = mcMMO.database.Read("SELECT " + powerlevel + ", user_id FROM " + LoadProperties.MySQLtablePrefix + "skills WHERE " + powerlevel + " > 0 ORDER BY " + powerlevel + " DESC "); HashMap<Integer, ArrayList<String>> userslist = mcMMO.database.read("SELECT " + powerlevel + ", user_id FROM " + LoadProperties.MySQLtablePrefix + "skills WHERE " + powerlevel + " > 0 ORDER BY " + powerlevel + " DESC ");
for (int i = n; i <= n + 10; i++) { for (int i = n; i <= n + 10; i++) {
if (i > userslist.size() || mcMMO.database.Read("SELECT user FROM " + LoadProperties.MySQLtablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'") == null) if (i > userslist.size() || mcMMO.database.read("SELECT user FROM " + LoadProperties.MySQLtablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'") == null)
break; break;
HashMap<Integer, ArrayList<String>> username = mcMMO.database.Read("SELECT user FROM " + LoadProperties.MySQLtablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'"); HashMap<Integer, ArrayList<String>> username = mcMMO.database.read("SELECT user FROM " + LoadProperties.MySQLtablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'");
player.sendMessage(String.valueOf(i) + ". " + ChatColor.GREEN + userslist.get(i).get(0) + " - " + ChatColor.WHITE + username.get(1).get(0)); player.sendMessage(String.valueOf(i) + ". " + ChatColor.GREEN + userslist.get(i).get(0) + " - " + ChatColor.WHITE + username.get(1).get(0));
} }
return true; return true;
} }
HashMap<Integer, ArrayList<String>> userslist = mcMMO.database.Read("SELECT " + powerlevel + ", user_id FROM " + LoadProperties.MySQLtablePrefix + "skills WHERE " + powerlevel + " > 0 ORDER BY " + powerlevel + " DESC "); HashMap<Integer, ArrayList<String>> userslist = mcMMO.database.read("SELECT " + powerlevel + ", user_id FROM " + LoadProperties.MySQLtablePrefix + "skills WHERE " + powerlevel + " > 0 ORDER BY " + powerlevel + " DESC ");
for (int i = 1; i <= 10; i++) { for (int i = 1; i <= 10; i++) {
if (i > userslist.size() || mcMMO.database.Read("SELECT user FROM " + LoadProperties.MySQLtablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'") == null) if (i > userslist.size() || mcMMO.database.read("SELECT user FROM " + LoadProperties.MySQLtablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'") == null)
break; break;
HashMap<Integer, ArrayList<String>> username = mcMMO.database.Read("SELECT user FROM " + LoadProperties.MySQLtablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'"); HashMap<Integer, ArrayList<String>> username = mcMMO.database.read("SELECT user FROM " + LoadProperties.MySQLtablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'");
player.sendMessage(String.valueOf(i) + ". " + ChatColor.GREEN + userslist.get(i).get(0) + " - " + ChatColor.WHITE + username.get(1).get(0)); player.sendMessage(String.valueOf(i) + ". " + ChatColor.GREEN + userslist.get(i).get(0) + " - " + ChatColor.WHITE + username.get(1).get(0));
// System.out.println(username.get(1).get(0)); // System.out.println(username.get(1).get(0));
// System.out.println("Mining : " + userslist.get(i).get(0) + ", User id : " + userslist.get(i).get(1)); // System.out.println("Mining : " + userslist.get(i).get(0) + ", User id : " + userslist.get(i).get(1));

View File

@ -15,7 +15,7 @@ public enum AbilityType
SKULL_SPLIITER(LoadProperties.skullSplitterCooldown, mcLocale.getString("Skills.SkullSplitterOn"), mcLocale.getString("Skills.SkullSplitterOff"), "Skills.SkullSplitterPlayer", mcLocale.getString("Skills.YourSkullSplitter"), "Skills.SkullSplitterPlayerOff"), SKULL_SPLIITER(LoadProperties.skullSplitterCooldown, mcLocale.getString("Skills.SkullSplitterOn"), mcLocale.getString("Skills.SkullSplitterOff"), "Skills.SkullSplitterPlayer", mcLocale.getString("Skills.YourSkullSplitter"), "Skills.SkullSplitterPlayerOff"),
TREE_FELLER(LoadProperties.treeFellerCooldown, mcLocale.getString("Skills.TreeFellerOn"), mcLocale.getString("Skills.TreeFellerOff"), "Skills.TreeFellerPlayer", mcLocale.getString("Skills.YourTreeFeller"), "Skills.TreeFellerPlayerOff"), TREE_FELLER(LoadProperties.treeFellerCooldown, mcLocale.getString("Skills.TreeFellerOn"), mcLocale.getString("Skills.TreeFellerOff"), "Skills.TreeFellerPlayer", mcLocale.getString("Skills.YourTreeFeller"), "Skills.TreeFellerPlayerOff"),
SERRATED_STRIKES(LoadProperties.skullSplitterCooldown, mcLocale.getString("Skills.SerratedStrikesOn"), mcLocale.getString("Skills.SerratedStrikesOff"), "Skills.SerratedStrikesPlayer", mcLocale.getString("Skills.YourSerratedStrikes"), "Skills.SerratedStrikesPlayerOff"), SERRATED_STRIKES(LoadProperties.skullSplitterCooldown, mcLocale.getString("Skills.SerratedStrikesOn"), mcLocale.getString("Skills.SerratedStrikesOff"), "Skills.SerratedStrikesPlayer", mcLocale.getString("Skills.YourSerratedStrikes"), "Skills.SerratedStrikesPlayerOff"),
BLAST_MINING(LoadProperties.blastMiningCooldown, "NOT NEEDED FOR BLAST MINING", "NOT NEEDED FOR BLAST MINING", "Skills.BlastMiningPlayer", mcLocale.getString("Skills.YourBlastMining"), "NOT NEEDED FOR BLAST MINING"); BLAST_MINING(LoadProperties.blastMiningCooldown, null, null, "Skills.BlastMiningPlayer", mcLocale.getString("Skills.YourBlastMining"), null);
private int cooldown; private int cooldown;
private String abilityOn; private String abilityOn;

View File

@ -145,15 +145,15 @@ public class PlayerProfile
public boolean loadMySQL() public boolean loadMySQL()
{ {
Integer id = 0; Integer id = 0;
id = mcMMO.database.GetInt("SELECT id FROM "+LoadProperties.MySQLtablePrefix+"users WHERE user = '" + playerName + "'"); id = mcMMO.database.getInt("SELECT id FROM "+LoadProperties.MySQLtablePrefix+"users WHERE user = '" + playerName + "'");
if(id == 0) if(id == 0)
return false; return false;
this.userid = id; this.userid = id;
if (id > 0) { if (id > 0) {
HashMap<Integer, ArrayList<String>> huds = mcMMO.database.Read("SELECT hudtype FROM "+LoadProperties.MySQLtablePrefix+"huds WHERE user_id = " + id); HashMap<Integer, ArrayList<String>> huds = mcMMO.database.read("SELECT hudtype FROM "+LoadProperties.MySQLtablePrefix+"huds WHERE user_id = " + id);
if(huds.get(1) == null) if(huds.get(1) == null)
{ {
mcMMO.database.Write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"huds (user_id) VALUES ("+id+")"); mcMMO.database.write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"huds (user_id) VALUES ("+id+")");
} else { } else {
if(huds.get(1).get(0) != null) if(huds.get(1).get(0) != null)
{ {
@ -168,17 +168,17 @@ public class PlayerProfile
hud = LoadProperties.defaulthud; hud = LoadProperties.defaulthud;
} }
} }
HashMap<Integer, ArrayList<String>> users = mcMMO.database.Read("SELECT lastlogin, party FROM "+LoadProperties.MySQLtablePrefix+"users WHERE id = " + id); HashMap<Integer, ArrayList<String>> users = mcMMO.database.read("SELECT lastlogin, party FROM "+LoadProperties.MySQLtablePrefix+"users WHERE id = " + id);
//lastlogin = Integer.parseInt(users.get(1).get(0)); //lastlogin = Integer.parseInt(users.get(1).get(0));
party = users.get(1).get(1); party = users.get(1).get(1);
HashMap<Integer, ArrayList<String>> cooldowns = mcMMO.database.Read("SELECT mining, woodcutting, unarmed, herbalism, excavation, swords, axes, blast_mining FROM "+LoadProperties.MySQLtablePrefix+"cooldowns WHERE user_id = " + id); HashMap<Integer, ArrayList<String>> cooldowns = mcMMO.database.read("SELECT mining, woodcutting, unarmed, herbalism, excavation, swords, axes, blast_mining FROM "+LoadProperties.MySQLtablePrefix+"cooldowns WHERE user_id = " + id);
/* /*
* I'm still learning MySQL, this is a fix for adding a new table * I'm still learning MySQL, this is a fix for adding a new table
* its not pretty but it works * its not pretty but it works
*/ */
if(cooldowns.get(1) == null) if(cooldowns.get(1) == null)
{ {
mcMMO.database.Write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"cooldowns (user_id) VALUES ("+id+")"); mcMMO.database.write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"cooldowns (user_id) VALUES ("+id+")");
} }
else else
{ {
@ -191,7 +191,7 @@ public class PlayerProfile
skillsDATS.put(AbilityType.SKULL_SPLIITER, Integer.valueOf(cooldowns.get(1).get(6))); skillsDATS.put(AbilityType.SKULL_SPLIITER, Integer.valueOf(cooldowns.get(1).get(6)));
skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(cooldowns.get(1).get(7))); skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(cooldowns.get(1).get(7)));
} }
HashMap<Integer, ArrayList<String>> stats = mcMMO.database.Read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM "+LoadProperties.MySQLtablePrefix+"skills WHERE user_id = " + id); HashMap<Integer, ArrayList<String>> stats = mcMMO.database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM "+LoadProperties.MySQLtablePrefix+"skills WHERE user_id = " + id);
skills.put(SkillType.TAMING, Integer.valueOf(stats.get(1).get(0))); skills.put(SkillType.TAMING, Integer.valueOf(stats.get(1).get(0)));
skills.put(SkillType.MINING, Integer.valueOf(stats.get(1).get(1))); skills.put(SkillType.MINING, Integer.valueOf(stats.get(1).get(1)));
skills.put(SkillType.REPAIR, Integer.valueOf(stats.get(1).get(2))); skills.put(SkillType.REPAIR, Integer.valueOf(stats.get(1).get(2)));
@ -204,7 +204,7 @@ public class PlayerProfile
skills.put(SkillType.AXES, Integer.valueOf(stats.get(1).get(9))); skills.put(SkillType.AXES, Integer.valueOf(stats.get(1).get(9)));
skills.put(SkillType.ACROBATICS, Integer.valueOf(stats.get(1).get(10))); skills.put(SkillType.ACROBATICS, Integer.valueOf(stats.get(1).get(10)));
skills.put(SkillType.FISHING, Integer.valueOf(stats.get(1).get(11))); skills.put(SkillType.FISHING, Integer.valueOf(stats.get(1).get(11)));
HashMap<Integer, ArrayList<String>> experience = mcMMO.database.Read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM "+LoadProperties.MySQLtablePrefix+"experience WHERE user_id = " + id); HashMap<Integer, ArrayList<String>> experience = mcMMO.database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM "+LoadProperties.MySQLtablePrefix+"experience WHERE user_id = " + id);
skillsXp.put(SkillType.TAMING, Integer.valueOf(experience.get(1).get(0))); skillsXp.put(SkillType.TAMING, Integer.valueOf(experience.get(1).get(0)));
skillsXp.put(SkillType.MINING, Integer.valueOf(experience.get(1).get(1))); skillsXp.put(SkillType.MINING, Integer.valueOf(experience.get(1).get(1)));
skillsXp.put(SkillType.REPAIR, Integer.valueOf(experience.get(1).get(2))); skillsXp.put(SkillType.REPAIR, Integer.valueOf(experience.get(1).get(2)));
@ -226,11 +226,11 @@ public class PlayerProfile
} }
public void addMySQLPlayer() { public void addMySQLPlayer() {
Integer id = 0; Integer id = 0;
mcMMO.database.Write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"users (user, lastlogin) VALUES ('" + playerName + "'," + System.currentTimeMillis() / 1000 +")"); mcMMO.database.write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"users (user, lastlogin) VALUES ('" + playerName + "'," + System.currentTimeMillis() / 1000 +")");
id = mcMMO.database.GetInt("SELECT id FROM "+LoadProperties.MySQLtablePrefix+"users WHERE user = '" + playerName + "'"); id = mcMMO.database.getInt("SELECT id FROM "+LoadProperties.MySQLtablePrefix+"users WHERE user = '" + playerName + "'");
mcMMO.database.Write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"cooldowns (user_id) VALUES ("+id+")"); mcMMO.database.write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"cooldowns (user_id) VALUES ("+id+")");
mcMMO.database.Write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"skills (user_id) VALUES ("+id+")"); mcMMO.database.write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"skills (user_id) VALUES ("+id+")");
mcMMO.database.Write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"experience (user_id) VALUES ("+id+")"); mcMMO.database.write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"experience (user_id) VALUES ("+id+")");
this.userid = id; this.userid = id;
} }
@ -345,11 +345,11 @@ public class PlayerProfile
// if we are using mysql save to database // if we are using mysql save to database
if (LoadProperties.useMySQL) if (LoadProperties.useMySQL)
{ {
mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"huds SET " mcMMO.database.write("UPDATE "+LoadProperties.MySQLtablePrefix+"huds SET "
+" hudtype = '"+hud.toString()+"' WHERE user_id = "+this.userid); +" hudtype = '"+hud.toString()+"' WHERE user_id = "+this.userid);
mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"users SET lastlogin = " + timestamp.intValue() + " WHERE id = " + this.userid); mcMMO.database.write("UPDATE "+LoadProperties.MySQLtablePrefix+"users SET lastlogin = " + timestamp.intValue() + " WHERE id = " + this.userid);
mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"users SET party = '"+this.party+"' WHERE id = " +this.userid); mcMMO.database.write("UPDATE "+LoadProperties.MySQLtablePrefix+"users SET party = '"+this.party+"' WHERE id = " +this.userid);
mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"cooldowns SET " mcMMO.database.write("UPDATE "+LoadProperties.MySQLtablePrefix+"cooldowns SET "
+" mining = " + skillsDATS.get(AbilityType.SUPER_BREAKER) +" mining = " + skillsDATS.get(AbilityType.SUPER_BREAKER)
+", woodcutting = " + skillsDATS.get(AbilityType.TREE_FELLER) +", woodcutting = " + skillsDATS.get(AbilityType.TREE_FELLER)
+", unarmed = " + skillsDATS.get(AbilityType.BERSERK) +", unarmed = " + skillsDATS.get(AbilityType.BERSERK)
@ -359,7 +359,7 @@ public class PlayerProfile
+", axes = " + skillsDATS.get(AbilityType.SKULL_SPLIITER) +", axes = " + skillsDATS.get(AbilityType.SKULL_SPLIITER)
+", blast_mining = " + skillsDATS.get(AbilityType.BLAST_MINING) +", blast_mining = " + skillsDATS.get(AbilityType.BLAST_MINING)
+" WHERE user_id = "+this.userid); +" WHERE user_id = "+this.userid);
mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"skills SET " mcMMO.database.write("UPDATE "+LoadProperties.MySQLtablePrefix+"skills SET "
+" taming = "+skills.get(SkillType.TAMING) +" taming = "+skills.get(SkillType.TAMING)
+", mining = "+skills.get(SkillType.MINING) +", mining = "+skills.get(SkillType.MINING)
+", repair = "+skills.get(SkillType.REPAIR) +", repair = "+skills.get(SkillType.REPAIR)
@ -373,7 +373,7 @@ public class PlayerProfile
+", acrobatics = "+skills.get(SkillType.ACROBATICS) +", acrobatics = "+skills.get(SkillType.ACROBATICS)
+", fishing = "+skills.get(SkillType.FISHING) +", fishing = "+skills.get(SkillType.FISHING)
+" WHERE user_id = "+this.userid); +" WHERE user_id = "+this.userid);
mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"experience SET " mcMMO.database.write("UPDATE "+LoadProperties.MySQLtablePrefix+"experience SET "
+" taming = "+skillsXp.get(SkillType.TAMING) +" taming = "+skillsXp.get(SkillType.TAMING)
+", mining = "+skillsXp.get(SkillType.MINING) +", mining = "+skillsXp.get(SkillType.MINING)
+", repair = "+skillsXp.get(SkillType.REPAIR) +", repair = "+skillsXp.get(SkillType.REPAIR)

View File

@ -493,18 +493,18 @@ public class m
fishingXP = character[35]; fishingXP = character[35];
//Check to see if the user is in the DB //Check to see if the user is in the DB
id = mcMMO.database.GetInt("SELECT id FROM " id = mcMMO.database.getInt("SELECT id FROM "
+ LoadProperties.MySQLtablePrefix + LoadProperties.MySQLtablePrefix
+ "users WHERE user = '" + playerName + "'"); + "users WHERE user = '" + playerName + "'");
if (id > 0) { if (id > 0) {
theCount++; theCount++;
//Update the skill values //Update the skill values
mcMMO.database.Write("UPDATE " mcMMO.database.write("UPDATE "
+ LoadProperties.MySQLtablePrefix + LoadProperties.MySQLtablePrefix
+ "users SET lastlogin = " + 0 + "users SET lastlogin = " + 0
+ " WHERE id = " + id); + " WHERE id = " + id);
mcMMO.database.Write("UPDATE " mcMMO.database.write("UPDATE "
+ LoadProperties.MySQLtablePrefix + LoadProperties.MySQLtablePrefix
+ "skills SET " + " taming = taming+" + "skills SET " + " taming = taming+"
+ getInt(taming) + ", mining = mining+" + getInt(taming) + ", mining = mining+"
@ -524,7 +524,7 @@ public class m
+ getInt(acrobatics) + getInt(acrobatics)
+ ", fishing = fishing+" + getInt(fishing) + ", fishing = fishing+" + getInt(fishing)
+ " WHERE user_id = " + id); + " WHERE user_id = " + id);
mcMMO.database.Write("UPDATE " mcMMO.database.write("UPDATE "
+ LoadProperties.MySQLtablePrefix + LoadProperties.MySQLtablePrefix
+ "experience SET " + " taming = " + "experience SET " + " taming = "
+ getInt(tamingXP) + ", mining = " + getInt(tamingXP) + ", mining = "
@ -543,33 +543,33 @@ public class m
} else { } else {
theCount++; theCount++;
//Create the user in the DB //Create the user in the DB
mcMMO.database.Write("INSERT INTO " mcMMO.database.write("INSERT INTO "
+ LoadProperties.MySQLtablePrefix + LoadProperties.MySQLtablePrefix
+ "users (user, lastlogin) VALUES ('" + "users (user, lastlogin) VALUES ('"
+ playerName + "'," + playerName + "',"
+ System.currentTimeMillis() / 1000 + ")"); + System.currentTimeMillis() / 1000 + ")");
id = mcMMO.database id = mcMMO.database
.GetInt("SELECT id FROM " .getInt("SELECT id FROM "
+ LoadProperties.MySQLtablePrefix + LoadProperties.MySQLtablePrefix
+ "users WHERE user = '" + "users WHERE user = '"
+ playerName + "'"); + playerName + "'");
mcMMO.database.Write("INSERT INTO " mcMMO.database.write("INSERT INTO "
+ LoadProperties.MySQLtablePrefix + LoadProperties.MySQLtablePrefix
+ "skills (user_id) VALUES (" + id + ")"); + "skills (user_id) VALUES (" + id + ")");
mcMMO.database.Write("INSERT INTO " mcMMO.database.write("INSERT INTO "
+ LoadProperties.MySQLtablePrefix + LoadProperties.MySQLtablePrefix
+ "experience (user_id) VALUES (" + id + "experience (user_id) VALUES (" + id
+ ")"); + ")");
//Update the skill values //Update the skill values
mcMMO.database.Write("UPDATE " mcMMO.database.write("UPDATE "
+ LoadProperties.MySQLtablePrefix + LoadProperties.MySQLtablePrefix
+ "users SET lastlogin = " + 0 + "users SET lastlogin = " + 0
+ " WHERE id = " + id); + " WHERE id = " + id);
mcMMO.database.Write("UPDATE " mcMMO.database.write("UPDATE "
+ LoadProperties.MySQLtablePrefix + LoadProperties.MySQLtablePrefix
+ "users SET party = '" + party + "users SET party = '" + party
+ "' WHERE id = " + id); + "' WHERE id = " + id);
mcMMO.database.Write("UPDATE " mcMMO.database.write("UPDATE "
+ LoadProperties.MySQLtablePrefix + LoadProperties.MySQLtablePrefix
+ "skills SET " + " taming = " + "skills SET " + " taming = "
+ getInt(taming) + ", mining = " + getInt(taming) + ", mining = "
@ -585,7 +585,7 @@ public class m
+ getInt(acrobatics) + ", fishing = " + getInt(acrobatics) + ", fishing = "
+ getInt(fishing) + " WHERE user_id = " + getInt(fishing) + " WHERE user_id = "
+ id); + id);
mcMMO.database.Write("UPDATE " mcMMO.database.write("UPDATE "
+ LoadProperties.MySQLtablePrefix + LoadProperties.MySQLtablePrefix
+ "experience SET " + " taming = " + "experience SET " + " taming = "
+ getInt(tamingXP) + ", mining = " + getInt(tamingXP) + ", mining = "

View File

@ -0,0 +1,24 @@
/*
* Copyright (C) 2012 Matt 'The Yeti' Burnett & mcMMO Development
* Copyright (C) 2010-2011 'nossr50'
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package datatypes;
public enum DatabaseUpdate {
FISHING,
BLAST_MINING;
}