summaryrefslogtreewikicommitdiff
path: root/src/main/java/net/tylermurphy/hideAndSeek/database
diff options
context:
space:
mode:
authorTyler Murphy <tylermurphy534@gmail.com>2022-05-17 16:36:35 -0400
committerTyler Murphy <tylermurphy534@gmail.com>2022-05-17 16:36:35 -0400
commitb74b8136365ca2542242023fc91e370873d6eabf (patch)
tree75e1a9267d11fadad417cc91a225e70385983aae /src/main/java/net/tylermurphy/hideAndSeek/database
parentmapsave bug fixes for windows servers (diff)
downloadkenshinshideandseek-b74b8136365ca2542242023fc91e370873d6eabf.tar.gz
kenshinshideandseek-b74b8136365ca2542242023fc91e370873d6eabf.tar.bz2
kenshinshideandseek-b74b8136365ca2542242023fc91e370873d6eabf.zip
working on expanding database
Diffstat (limited to 'src/main/java/net/tylermurphy/hideAndSeek/database')
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/database/Database.java41
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/database/GameDataTable.java (renamed from src/main/java/net/tylermurphy/hideAndSeek/database/PlayerInfoTable.java)63
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/database/LegacyTable.java104
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/database/NameDataTable.java99
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/database/connections/DatabaseConnection.java29
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/database/connections/MySQLConnection.java61
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/database/connections/SQLiteConnection.java64
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/database/util/LegacyPlayerInfo.java56
-rw-r--r--src/main/java/net/tylermurphy/hideAndSeek/database/util/PlayerInfo.java (renamed from src/main/java/net/tylermurphy/hideAndSeek/database/PlayerInfo.java)4
9 files changed, 478 insertions, 43 deletions
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/database/Database.java b/src/main/java/net/tylermurphy/hideAndSeek/database/Database.java
index ce06244..0eceb98 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/database/Database.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/database/Database.java
@@ -21,48 +21,51 @@ package net.tylermurphy.hideAndSeek.database;
import com.google.common.io.ByteStreams;
import net.tylermurphy.hideAndSeek.Main;
-import org.sqlite.SQLiteConfig;
+import net.tylermurphy.hideAndSeek.database.connections.DatabaseConnection;
+import net.tylermurphy.hideAndSeek.database.connections.SQLiteConnection;
import java.io.ByteArrayInputStream;
-import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.sql.Connection;
-import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.UUID;
public class Database {
- private final File databaseFile = new File(Main.getInstance().getDataFolder(), "database.db");
- private final PlayerInfoTable playerInfo;
- private final SQLiteConfig config;
+ private final GameDataTable playerInfo;
+ private final NameDataTable nameInfo;
+ private final DatabaseConnection connection;
public Database(){
- try {
- Class.forName("org.sqlite.JDBC");
- } catch (ClassNotFoundException e) {
- Main.getInstance().getLogger().severe(e.getMessage());
- throw new RuntimeException(e.getMessage());
- }
- config = new SQLiteConfig();
- config.setSynchronous(SQLiteConfig.SynchronousMode.NORMAL);
- config.setTempStore(SQLiteConfig.TempStore.MEMORY);
+ connection = new SQLiteConnection();
+
+ playerInfo = new GameDataTable(this);
- playerInfo = new PlayerInfoTable(this);
+ nameInfo = new NameDataTable(this);
+
+ LegacyTable legacyTable = new LegacyTable(this);
+ if(legacyTable.exists()){
+ if(legacyTable.copyData()){
+ if(!legacyTable.drop()){
+ Main.getInstance().getLogger().severe("Failed to drop old legacy table: player_info. Some data may be duplicated!");
+ }
+ }
+ }
}
- public PlayerInfoTable getGameData(){
+ public GameDataTable getGameData(){
return playerInfo;
}
+ public NameDataTable getNameData() { return nameInfo; }
+
protected Connection connect() {
Connection conn = null;
try {
- String url = "jdbc:sqlite:"+databaseFile;
- conn = DriverManager.getConnection(url, config.toProperties());
+ conn = connection.connect();
} catch (SQLException e) {
Main.getInstance().getLogger().severe(e.getMessage());
e.printStackTrace();
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/database/PlayerInfoTable.java b/src/main/java/net/tylermurphy/hideAndSeek/database/GameDataTable.java
index 500cdc0..128614d 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/database/PlayerInfoTable.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/database/GameDataTable.java
@@ -1,7 +1,7 @@
/*
* This file is part of Kenshins Hide and Seek
*
- * Copyright (c) 2021 Tyler Murphy.
+ * Copyright (c) 2021-2022 Tyler Murphy.
*
* Kenshins Hide and Seek free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,6 +20,7 @@
package net.tylermurphy.hideAndSeek.database;
import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.database.util.PlayerInfo;
import net.tylermurphy.hideAndSeek.game.Board;
import net.tylermurphy.hideAndSeek.game.util.WinType;
import org.jetbrains.annotations.Nullable;
@@ -27,12 +28,12 @@ import org.jetbrains.annotations.Nullable;
import java.sql.*;
import java.util.*;
-public class PlayerInfoTable {
+public class GameDataTable {
private final Map<UUID, PlayerInfo> CACHE = new HashMap<>();
private final Database database;
- protected PlayerInfoTable(Database database) {
+ protected GameDataTable(Database database) {
String sql = "CREATE TABLE IF NOT EXISTS hs_data (\n"
+ " uuid BINARY(16) PRIMARY KEY,\n"
@@ -170,30 +171,48 @@ public class PlayerInfoTable {
public void addWins(Board board, List<UUID> uuids, List<UUID> winners, Map<String,Integer> hider_kills, Map<String,Integer> hider_deaths, Map<String,Integer> seeker_kills, Map<String,Integer> seeker_deaths, WinType type) {
for(UUID uuid : uuids) {
- String sql = "INSERT OR REPLACE INTO hs_data (uuid, hider_wins, seeker_wins, hider_games, seeker_games, hider_kills, seeker_kills, hider_deaths, seeker_deaths) VALUES (?,?,?,?,?,?,?,?,?)";
PlayerInfo info = getInfo(uuid);
if(info == null){
info = new PlayerInfo(uuid, 0, 0, 0, 0, 0, 0, 0, 0);
}
- try(Connection connection = database.connect(); PreparedStatement statement = connection.prepareStatement(sql)) {
- statement.setBytes(1, database.encodeUUID(uuid));
- statement.setInt(2, info.getHiderWins() + (winners.contains(uuid) && type == WinType.HIDER_WIN ? 1 : 0));
- statement.setInt(3, info.getSeekerWins() + (winners.contains(uuid) && type == WinType.SEEKER_WIN ? 1 : 0));
- statement.setInt(4, info.getHiderGames() + (board.isHider(uuid) || (board.isSeeker(uuid) && !board.getFirstSeeker().getUniqueId().equals(uuid)) ? 1 : 0));
- statement.setInt(5, info.getSeekerGames() + (board.getFirstSeeker().getUniqueId().equals(uuid) ? 1 : 0));
- statement.setInt(6, info.getHiderKills() + hider_kills.getOrDefault(uuid.toString(), 0));
- statement.setInt(7, info.getSeekerKills() + seeker_kills.getOrDefault(uuid.toString(), 0));
- statement.setInt(8, info.getHiderDeaths() + hider_deaths.getOrDefault(uuid.toString(), 0));
- statement.setInt(9, info.getSeekerDeaths() + seeker_deaths.getOrDefault(uuid.toString(), 0));
- statement.execute();
- } catch (SQLException e) {
- Main.getInstance().getLogger().severe("SQL Error: " + e.getMessage());
- e.printStackTrace();
- return;
- } finally {
- CACHE.remove(uuid);
- }
+ updateInfo(
+ database.encodeUUID(info.getUniqueId()),
+ info.getHiderWins() + (winners.contains(uuid) && type == WinType.HIDER_WIN ? 1 : 0),
+ info.getSeekerWins() + (winners.contains(uuid) && type == WinType.SEEKER_WIN ? 1 : 0),
+ info.getHiderGames() + (board.isHider(uuid) || (board.isSeeker(uuid) && !board.getFirstSeeker().getUniqueId().equals(uuid)) ? 1 : 0),
+ info.getSeekerGames() + (board.getFirstSeeker().getUniqueId().equals(uuid) ? 1 : 0),
+ info.getHiderKills() + hider_kills.getOrDefault(uuid.toString(), 0),
+ info.getSeekerKills() + seeker_kills.getOrDefault(uuid.toString(), 0),
+ info.getHiderDeaths() + hider_deaths.getOrDefault(uuid.toString(), 0),
+ info.getSeekerDeaths() + seeker_deaths.getOrDefault(uuid.toString(), 0)
+ );
+ }
+ }
+
+ protected boolean updateInfo(byte[] uuid, int hider_wins, int seeker_wins, int hider_games, int seeker_games, int hider_kills, int seeker_kills, int hider_deaths, int seeker_deaths){
+ boolean success;
+ String sql = "INSERT OR REPLACE INTO hs_data (uuid, hider_wins, seeker_wins, hider_games, seeker_games, hider_kills, seeker_kills, hider_deaths, seeker_deaths) VALUES (?,?,?,?,?,?,?,?,?)";
+ try(Connection connection = database.connect(); PreparedStatement statement = connection.prepareStatement(sql)) {
+ statement.setBytes(1, uuid);
+ statement.setInt(2, hider_wins);
+ statement.setInt(3, seeker_wins);
+ statement.setInt(4, hider_games);
+ statement.setInt(5, seeker_games);
+ statement.setInt(6, hider_kills);
+ statement.setInt(7, seeker_kills);
+ statement.setInt(8, hider_deaths);
+ statement.setInt(9, seeker_deaths);
+ statement.execute();
+ statement.close();
+ success = true;
+ } catch (SQLException e) {
+ Main.getInstance().getLogger().severe("SQL Error: " + e.getMessage());
+ e.printStackTrace();
+ success = false;
+ } finally {
+ CACHE.remove(uuid);
}
+ return success;
}
}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/database/LegacyTable.java b/src/main/java/net/tylermurphy/hideAndSeek/database/LegacyTable.java
new file mode 100644
index 0000000..580c2f5
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/database/LegacyTable.java
@@ -0,0 +1,104 @@
+/*
+ * This file is part of Kenshins Hide and Seek
+ *
+ * Copyright (c) 2022 Tyler Murphy.
+ *
+ * Kenshins Hide and Seek free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * he Free Software Foundation version 3.
+ *
+ * Kenshins Hide and Seek 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 net.tylermurphy.hideAndSeek.database;
+
+import net.tylermurphy.hideAndSeek.Main;
+import net.tylermurphy.hideAndSeek.database.Database;
+import net.tylermurphy.hideAndSeek.database.util.LegacyPlayerInfo;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.List;
+
+public class LegacyTable {
+
+ private final Database database;
+ private final boolean exists;
+
+ protected LegacyTable(Database database) {
+
+ String sql = "SELECT * FROM player_info LIMIT 1;";
+
+ boolean check;
+ try(Connection connection = database.connect(); Statement statement = connection.createStatement()) {
+ ResultSet resultSet = statement.executeQuery(sql);
+ check = resultSet.next();
+ } catch (SQLException e) {
+ check = false;
+ }
+
+ this.exists = check;
+ this.database = database;
+ }
+
+ public boolean exists(){
+ return exists;
+ }
+
+ public boolean copyData(){
+ String sql = "SELECT * FROM player_info;";
+ List<LegacyPlayerInfo> legacyPlayerInfoList = new ArrayList<>();
+ try(Connection connection = database.connect(); Statement statement = connection.createStatement()) {
+ ResultSet resultSet = statement.executeQuery(sql);
+ while(resultSet.next()){
+ legacyPlayerInfoList.add(new LegacyPlayerInfo(
+ resultSet.getBytes("uuid"),
+ resultSet.getInt("wins"),
+ resultSet.getInt("hider_wins"),
+ resultSet.getInt("seeker_wins"),
+ resultSet.getInt("games_played")
+ ));
+ }
+ resultSet.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ return false;
+ }
+ for(LegacyPlayerInfo legacyInfo : legacyPlayerInfoList){
+ database.getGameData().updateInfo(
+ legacyInfo.getUniqueId(),
+ legacyInfo.getHiderWins(),
+ legacyInfo.getSeekerWins(),
+ legacyInfo.getGamesPlayer() - legacyInfo.getSeekerWins(),
+ legacyInfo.getSeekerWins(),
+ 0,
+ 0,
+ 0,
+ 0
+ );
+ }
+ return true;
+ }
+
+ public boolean drop(){
+ String sql = "DROP table player_info";
+ try(Connection connection = database.connect(); Statement statement = connection.createStatement()) {
+ statement.execute(sql);
+ return true;
+ } catch (SQLException e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/database/NameDataTable.java b/src/main/java/net/tylermurphy/hideAndSeek/database/NameDataTable.java
new file mode 100644
index 0000000..cbf410a
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/database/NameDataTable.java
@@ -0,0 +1,99 @@
+/*
+ * This file is part of Kenshins Hide and Seek
+ *
+ * Copyright (c) 2022 Tyler Murphy.
+ *
+ * Kenshins Hide and Seek free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * he Free Software Foundation version 3.
+ *
+ * Kenshins Hide and Seek 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 net.tylermurphy.hideAndSeek.database;
+
+import net.tylermurphy.hideAndSeek.Main;
+import org.jetbrains.annotations.Nullable;
+
+import java.sql.*;
+import java.util.UUID;
+
+public class NameDataTable {
+
+ private final Database database;
+
+ protected NameDataTable(Database database) {
+
+ String sql = "CREATE TABLE IF NOT EXISTS hs_names (\n"
+ + " uuid BINARY(16) NOT NULL,\n"
+ + " name VARCHAR(48) NOT NULL,\n"
+ + " PRIMARY KEY (uuid,name)\n"
+ + ");";
+
+ try(Connection connection = database.connect(); Statement statement = connection.createStatement()) {
+ statement.executeUpdate(sql);
+ } catch (SQLException e) {
+ Main.getInstance().getLogger().severe("SQL Error: " + e.getMessage());
+ e.printStackTrace();
+ }
+
+ this.database = database;
+ }
+
+ @Nullable
+ public String getName(UUID uuid) {
+ String sql = "SELECT * FROM hs_names WHERE uuid = ?;";
+ try(Connection connection = database.connect(); PreparedStatement statement = connection.prepareStatement(sql)) {
+ statement.setBytes(1, database.encodeUUID(uuid));
+ ResultSet rs = statement.executeQuery();
+ if (rs.next()) {
+ return rs.getString("name");
+ }
+ rs.close();
+ } catch (SQLException e) {
+ Main.getInstance().getLogger().severe("SQL Error: " + e.getMessage());
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ @Nullable
+ public UUID getUUID(String name) {
+ String sql = "SELECT * FROM hs_names WHERE name = ?;";
+ try(Connection connection = database.connect(); PreparedStatement statement = connection.prepareStatement(sql)) {
+ statement.setString(1, name);
+ ResultSet rs = statement.executeQuery();
+ if (rs.next()) {
+ return database.decodeUUID(rs.getBytes("uuid"));
+ }
+ rs.close();
+ } catch (SQLException e) {
+ Main.getInstance().getLogger().severe("SQL Error: " + e.getMessage());
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ public boolean update(UUID uuid, String name){
+ String sql = "INSERT OR REPLACE INTO hs_names (uuid, name) VALUES (?,?)";
+ try(Connection connection = database.connect(); PreparedStatement statement = connection.prepareStatement(sql)) {
+ statement.setBytes(1, database.encodeUUID(uuid));
+ statement.setString(2, name);
+ statement.execute();
+ statement.close();
+ return true;
+ } catch (SQLException e) {
+ Main.getInstance().getLogger().severe("SQL Error: " + e.getMessage());
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/database/connections/DatabaseConnection.java b/src/main/java/net/tylermurphy/hideAndSeek/database/connections/DatabaseConnection.java
new file mode 100644
index 0000000..466bda5
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/database/connections/DatabaseConnection.java
@@ -0,0 +1,29 @@
+/*
+ * This file is part of Kenshins Hide and Seek
+ *
+ * Copyright (c) 2022 Tyler Murphy.
+ *
+ * Kenshins Hide and Seek free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * he Free Software Foundation version 3.
+ *
+ * Kenshins Hide and Seek 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 net.tylermurphy.hideAndSeek.database.connections;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+public interface DatabaseConnection {
+
+ Connection connect() throws SQLException;
+
+}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/database/connections/MySQLConnection.java b/src/main/java/net/tylermurphy/hideAndSeek/database/connections/MySQLConnection.java
new file mode 100644
index 0000000..c29d1b3
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/database/connections/MySQLConnection.java
@@ -0,0 +1,61 @@
+/*
+ * This file is part of Kenshins Hide and Seek
+ *
+ * Copyright (c) 2022 Tyler Murphy.
+ *
+ * Kenshins Hide and Seek free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * he Free Software Foundation version 3.
+ *
+ * Kenshins Hide and Seek 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 net.tylermurphy.hideAndSeek.database.connections;
+
+import com.zaxxer.hikari.HikariConfig;
+import com.zaxxer.hikari.HikariDataSource;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+public class MySQLConnection implements DatabaseConnection {
+
+ private final HikariConfig config;
+ private final HikariDataSource ds;
+
+ public MySQLConnection(){
+
+ String host = "to be implemented";
+ String port = "to be implemented";
+ String user = "to be implemented";
+ String pass = "to be implemented";
+
+ config = new HikariConfig();
+
+ config.setJdbcUrl("jdbc:mariadb://"+host+":"+port+"/kenbot");
+ config.addDataSourceProperty("cachePrepStmts", "true");
+ config.addDataSourceProperty("prepStmtCacheSize", "250");
+ config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
+ config.addDataSourceProperty("user", user);
+ config.addDataSourceProperty("password",pass);
+ config.addDataSourceProperty("autoCommit", "true");
+ config.setAutoCommit(true);
+ config.setMaximumPoolSize(20);
+
+ ds = new HikariDataSource(config);
+
+ }
+
+ @Override
+ public Connection connect() throws SQLException {
+ return ds.getConnection();
+ }
+
+}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/database/connections/SQLiteConnection.java b/src/main/java/net/tylermurphy/hideAndSeek/database/connections/SQLiteConnection.java
new file mode 100644
index 0000000..1a03106
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/database/connections/SQLiteConnection.java
@@ -0,0 +1,64 @@
+/*
+ * This file is part of Kenshins Hide and Seek
+ *
+ * Copyright (c) 2022 Tyler Murphy.
+ *
+ * Kenshins Hide and Seek free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * he Free Software Foundation version 3.
+ *
+ * Kenshins Hide and Seek 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 net.tylermurphy.hideAndSeek.database.connections;
+
+import net.tylermurphy.hideAndSeek.Main;
+import org.sqlite.SQLiteConfig;
+
+import java.io.File;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+
+public class SQLiteConnection implements DatabaseConnection {
+
+ private final File databaseFile;
+ private final SQLiteConfig config;
+
+ public SQLiteConnection(){
+
+ try {
+ Class.forName("org.sqlite.JDBC");
+ } catch (ClassNotFoundException e) {
+ Main.getInstance().getLogger().severe(e.getMessage());
+ throw new RuntimeException(e.getMessage());
+ }
+
+ databaseFile = new File(Main.getInstance().getDataFolder(), "database.db");
+
+ config = new SQLiteConfig();
+ config.setSynchronous(SQLiteConfig.SynchronousMode.NORMAL);
+ config.setTempStore(SQLiteConfig.TempStore.MEMORY);
+ }
+
+ @Override
+ public Connection connect() {
+ Connection conn = null;
+ try {
+ String url = "jdbc:sqlite:"+databaseFile;
+ conn = DriverManager.getConnection(url, config.toProperties());
+ } catch (SQLException e) {
+ Main.getInstance().getLogger().severe(e.getMessage());
+ e.printStackTrace();
+ }
+ return conn;
+ }
+
+}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/database/util/LegacyPlayerInfo.java b/src/main/java/net/tylermurphy/hideAndSeek/database/util/LegacyPlayerInfo.java
new file mode 100644
index 0000000..5b59779
--- /dev/null
+++ b/src/main/java/net/tylermurphy/hideAndSeek/database/util/LegacyPlayerInfo.java
@@ -0,0 +1,56 @@
+/*
+ * This file is part of Kenshins Hide and Seek
+ *
+ * Copyright (c) 2021-2022 Tyler Murphy.
+ *
+ * Kenshins Hide and Seek free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * he Free Software Foundation version 3.
+ *
+ * Kenshins Hide and Seek 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 net.tylermurphy.hideAndSeek.database.util;
+
+import java.util.UUID;
+
+public class LegacyPlayerInfo {
+
+ private final byte[] uniqueId;
+ private final int totalWins;
+ private final int hiderWins;
+ private final int seekerWins;
+ private final int gamesPlayed;
+
+ public LegacyPlayerInfo(byte[] uniqueId, int totalWins, int hiderWins, int seekerWins, int gamesPlayed) {
+ this.uniqueId = uniqueId;
+ this.totalWins = totalWins;
+ this.hiderWins = hiderWins;
+ this.seekerWins = seekerWins;
+ this.gamesPlayed = gamesPlayed;
+ }
+
+ public byte[] getUniqueId() {
+ return uniqueId;
+ }
+
+ public int getTotalWins() { return totalWins; }
+
+ public int getHiderWins() {
+ return hiderWins;
+ }
+
+ public int getSeekerWins() {
+ return seekerWins;
+ }
+
+ public int getGamesPlayer() { return gamesPlayed; }
+
+}
diff --git a/src/main/java/net/tylermurphy/hideAndSeek/database/PlayerInfo.java b/src/main/java/net/tylermurphy/hideAndSeek/database/util/PlayerInfo.java
index 5c74e76..96fe9d8 100644
--- a/src/main/java/net/tylermurphy/hideAndSeek/database/PlayerInfo.java
+++ b/src/main/java/net/tylermurphy/hideAndSeek/database/util/PlayerInfo.java
@@ -1,7 +1,7 @@
/*
* This file is part of Kenshins Hide and Seek
*
- * Copyright (c) 2021 Tyler Murphy.
+ * Copyright (c) 2021-2022 Tyler Murphy.
*
* Kenshins Hide and Seek free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -17,7 +17,7 @@
*
*/
-package net.tylermurphy.hideAndSeek.database;
+package net.tylermurphy.hideAndSeek.database.util;
import java.util.UUID;