Skip to content

Commit

Permalink
Better insertion for new players
Browse files Browse the repository at this point in the history
  • Loading branch information
Brianetta committed Sep 11, 2018
1 parent a0d8d2f commit 7b748b4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/net/simplycrafted/StickyLocks/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public void addPlayer(Player player) {
try {
// The sub-select is used to preserve the notification setting. If
// nothing is returned, the default is used.
psql = db_conn.prepareStatement("REPLACE INTO player (uuid,name,notify,automatic) SELECT ?,?,notify,automatic FROM player WHERE uuid=?))");
psql = db_conn.prepareStatement("INSERT INTO player (uuid,name) SELECT ?,? WHERE NOT EXISTS (SELECT 1 FROM player WHERE uuid=?)");
psql.setString(1, player.getUniqueId().toString());
psql.setString(2, player.getName());
psql.setString(3, player.getUniqueId().toString());
Expand All @@ -312,7 +312,7 @@ public void addPlayer(OfflinePlayer offlinePlayer) {
try {
// The sub-select is used to preserve the notification setting. If
// nothing is returned, the default is used.
psql = db_conn.prepareStatement("REPLACE INTO player (uuid,name,notify,automatic) SELECT ?,?,notify,automatic FROM player WHERE uuid=?))");
psql = db_conn.prepareStatement("INSERT INTO player (uuid,name) SELECT ?,? WHERE NOT EXISTS (SELECT 1 FROM player WHERE uuid=?)");
psql.setString(1, offlinePlayer.getUniqueId().toString());
psql.setString(2, offlinePlayer.getName());
psql.setString(3, offlinePlayer.getUniqueId().toString());
Expand Down

0 comments on commit 7b748b4

Please sign in to comment.