This commit is contained in:
parent
4859c95b12
commit
b6fa012ed0
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>cn.lunadeer</groupId>
|
<groupId>cn.lunadeer</groupId>
|
||||||
<artifactId>MiniPlayerTitle</artifactId>
|
<artifactId>MiniPlayerTitle</artifactId>
|
||||||
<version>2.10.0</version>
|
<version>2.10.2</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>MiniPlayerTitle</name>
|
<name>MiniPlayerTitle</name>
|
||||||
|
@ -41,6 +41,9 @@ public class Database {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Statement stmt = conn.createStatement();
|
Statement stmt = conn.createStatement();
|
||||||
|
if (sql.contains("SERIAL PRIMARY KEY") && MiniPlayerTitle.config.getDbType().equals("sqlite")) {
|
||||||
|
sql = sql.replace("SERIAL PRIMARY KEY", "INTEGER PRIMARY KEY AUTOINCREMENT");
|
||||||
|
}
|
||||||
// if query with no result return null
|
// if query with no result return null
|
||||||
if (stmt.execute(sql)) {
|
if (stmt.execute(sql)) {
|
||||||
return stmt.getResultSet();
|
return stmt.getResultSet();
|
||||||
@ -87,7 +90,7 @@ public class Database {
|
|||||||
String sql = "";
|
String sql = "";
|
||||||
|
|
||||||
// title table
|
// title table
|
||||||
sql += "CREATE TABLE IF NOT EXISTS mplt_title (" +
|
sql = "CREATE TABLE IF NOT EXISTS mplt_title (" +
|
||||||
" id SERIAL PRIMARY KEY," +
|
" id SERIAL PRIMARY KEY," +
|
||||||
" title TEXT NOT NULL UNIQUE," +
|
" title TEXT NOT NULL UNIQUE," +
|
||||||
" description TEXT NOT NULL," +
|
" description TEXT NOT NULL," +
|
||||||
@ -95,9 +98,10 @@ public class Database {
|
|||||||
" created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP," +
|
" created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP," +
|
||||||
" updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP" +
|
" updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP" +
|
||||||
");";
|
");";
|
||||||
|
query(sql);
|
||||||
|
|
||||||
// title shop table
|
// title shop table
|
||||||
sql += "CREATE TABLE IF NOT EXISTS mplt_title_shop (" +
|
sql = "CREATE TABLE IF NOT EXISTS mplt_title_shop (" +
|
||||||
" id SERIAL PRIMARY KEY," +
|
" id SERIAL PRIMARY KEY," +
|
||||||
" title_id INTEGER NOT NULL," +
|
" title_id INTEGER NOT NULL," +
|
||||||
" price INTEGER NOT NULL DEFAULT 0," +
|
" price INTEGER NOT NULL DEFAULT 0," +
|
||||||
@ -108,9 +112,10 @@ public class Database {
|
|||||||
" updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP," +
|
" updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP," +
|
||||||
" FOREIGN KEY (title_id) REFERENCES mplt_title(id) ON DELETE CASCADE" +
|
" FOREIGN KEY (title_id) REFERENCES mplt_title(id) ON DELETE CASCADE" +
|
||||||
");";
|
");";
|
||||||
|
query(sql);
|
||||||
|
|
||||||
// player title info table
|
// player title info table
|
||||||
sql += "CREATE TABLE IF NOT EXISTS mplt_player_info (" +
|
sql = "CREATE TABLE IF NOT EXISTS mplt_player_info (" +
|
||||||
" uuid UUID PRIMARY KEY," +
|
" uuid UUID PRIMARY KEY," +
|
||||||
" coin INTEGER NOT NULL DEFAULT 0," +
|
" coin INTEGER NOT NULL DEFAULT 0," +
|
||||||
" using_title_id INTEGER NOT NULL DEFAULT -1," +
|
" using_title_id INTEGER NOT NULL DEFAULT -1," +
|
||||||
@ -118,9 +123,10 @@ public class Database {
|
|||||||
" updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP," +
|
" updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP," +
|
||||||
" FOREIGN KEY (using_title_id) REFERENCES mplt_title(id) ON DELETE CASCADE" +
|
" FOREIGN KEY (using_title_id) REFERENCES mplt_title(id) ON DELETE CASCADE" +
|
||||||
");";
|
");";
|
||||||
|
query(sql);
|
||||||
|
|
||||||
// player title table
|
// player title table
|
||||||
sql += "CREATE TABLE IF NOT EXISTS mplt_player_title (" +
|
sql = "CREATE TABLE IF NOT EXISTS mplt_player_title (" +
|
||||||
" id SERIAL PRIMARY KEY," +
|
" id SERIAL PRIMARY KEY," +
|
||||||
" player_uuid UUID NOT NULL," +
|
" player_uuid UUID NOT NULL," +
|
||||||
" title_id INTEGER NOT NULL," +
|
" title_id INTEGER NOT NULL," +
|
||||||
@ -130,8 +136,9 @@ public class Database {
|
|||||||
" FOREIGN KEY (title_id) REFERENCES mplt_title(id) ON DELETE CASCADE," +
|
" FOREIGN KEY (title_id) REFERENCES mplt_title(id) ON DELETE CASCADE," +
|
||||||
" FOREIGN KEY (player_uuid) REFERENCES mplt_player_info(uuid) ON DELETE CASCADE" +
|
" FOREIGN KEY (player_uuid) REFERENCES mplt_player_info(uuid) ON DELETE CASCADE" +
|
||||||
");";
|
");";
|
||||||
|
query(sql);
|
||||||
|
|
||||||
sql += "INSERT INTO mplt_title (" +
|
sql = "INSERT INTO mplt_title (" +
|
||||||
"id, " +
|
"id, " +
|
||||||
"title, " +
|
"title, " +
|
||||||
"description," +
|
"description," +
|
||||||
@ -146,8 +153,6 @@ public class Database {
|
|||||||
"CURRENT_TIMESTAMP, " +
|
"CURRENT_TIMESTAMP, " +
|
||||||
"CURRENT_TIMESTAMP " +
|
"CURRENT_TIMESTAMP " +
|
||||||
") ON CONFLICT (id) DO NOTHING;";
|
") ON CONFLICT (id) DO NOTHING;";
|
||||||
|
|
||||||
|
|
||||||
query(sql);
|
query(sql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user