mirror of
https://github.com/Zrips/Jobs.git
synced 2025-01-04 23:37:49 +01:00
Slightly faster new player recording
This commit is contained in:
parent
cec32c32a0
commit
35867ddcf2
@ -36,6 +36,7 @@ import com.gamingmesh.jobs.container.PlayerPoints;
|
|||||||
import com.gamingmesh.jobs.container.TopList;
|
import com.gamingmesh.jobs.container.TopList;
|
||||||
import com.gamingmesh.jobs.dao.JobsManager.DataBaseType;
|
import com.gamingmesh.jobs.dao.JobsManager.DataBaseType;
|
||||||
import com.gamingmesh.jobs.economy.PaymentData;
|
import com.gamingmesh.jobs.economy.PaymentData;
|
||||||
|
import com.gamingmesh.jobs.stuff.Debug;
|
||||||
import com.gamingmesh.jobs.stuff.TimeManage;
|
import com.gamingmesh.jobs.stuff.TimeManage;
|
||||||
|
|
||||||
public abstract class JobsDAO {
|
public abstract class JobsDAO {
|
||||||
@ -765,34 +766,6 @@ public abstract class JobsDAO {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// private void loadAllSavedJobs() {
|
|
||||||
// JobsConnection conn = getConnection();
|
|
||||||
// if (conn == null)
|
|
||||||
// return;
|
|
||||||
// PreparedStatement prest = null;
|
|
||||||
// ResultSet res = null;
|
|
||||||
// try {
|
|
||||||
// prest = conn.prepareStatement("SELECT * FROM `" + prefix + "jobs`;");
|
|
||||||
// res = prest.executeQuery();
|
|
||||||
// while (res.next()) {
|
|
||||||
// int id = res.getInt("userid");
|
|
||||||
// ArrayList<JobsDAOData> list = map.get(id);
|
|
||||||
// if (list == null) {
|
|
||||||
// list = new ArrayList<JobsDAOData>();
|
|
||||||
// list.add(new JobsDAOData(res.getString("job"), res.getInt("level"), res.getInt("experience")));
|
|
||||||
// map.put(id, list);
|
|
||||||
// } else {
|
|
||||||
// list.add(new JobsDAOData(res.getString("job"), res.getInt("level"), res.getInt("experience")));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } catch (SQLException e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// } finally {
|
|
||||||
// close(res);
|
|
||||||
// close(prest);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
public void recordNewPlayer(Player player) {
|
public void recordNewPlayer(Player player) {
|
||||||
recordNewPlayer((OfflinePlayer) player);
|
recordNewPlayer((OfflinePlayer) player);
|
||||||
}
|
}
|
||||||
@ -806,31 +779,27 @@ public abstract class JobsDAO {
|
|||||||
if (conn == null)
|
if (conn == null)
|
||||||
return;
|
return;
|
||||||
PreparedStatement prestt = null;
|
PreparedStatement prestt = null;
|
||||||
|
ResultSet res2 = null;
|
||||||
try {
|
try {
|
||||||
prestt = conn.prepareStatement("INSERT INTO `" + prefix + "users` (`player_uuid`, `username`, `seen`) VALUES (?, ?, ?);");
|
prestt = conn.prepareStatement("INSERT INTO `" + prefix + "users` (`player_uuid`, `username`, `seen`) VALUES (?, ?, ?);", Statement.RETURN_GENERATED_KEYS);
|
||||||
prestt.setString(1, uuid.toString());
|
prestt.setString(1, uuid.toString());
|
||||||
prestt.setString(2, playerName);
|
prestt.setString(2, playerName);
|
||||||
prestt.setLong(3, System.currentTimeMillis());
|
prestt.setLong(3, System.currentTimeMillis());
|
||||||
prestt.executeUpdate();
|
prestt.executeUpdate();
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
res2 = prestt.getGeneratedKeys();
|
||||||
} finally {
|
int id = 0;
|
||||||
close(prestt);
|
if (res2.next())
|
||||||
}
|
id = res2.getInt(1);
|
||||||
PreparedStatement prest = null;
|
|
||||||
ResultSet res = null;
|
Debug.D("got id " + id);
|
||||||
try {
|
|
||||||
prest = conn.prepareStatement("SELECT `id` FROM `" + prefix + "users` WHERE `player_uuid` = ?;");
|
|
||||||
prest.setString(1, uuid.toString());
|
|
||||||
res = prest.executeQuery();
|
|
||||||
res.next();
|
|
||||||
int id = res.getInt("id");
|
|
||||||
Jobs.getPlayerManager().addPlayerToMap(new PlayerInfo(playerName, id, uuid, System.currentTimeMillis()));
|
Jobs.getPlayerManager().addPlayerToMap(new PlayerInfo(playerName, id, uuid, System.currentTimeMillis()));
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
close(res);
|
close(prestt);
|
||||||
close(prest);
|
close(res2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user