Skip to content

Commit

Permalink
Using varchar(128) for world name in database
Browse files Browse the repository at this point in the history
  • Loading branch information
sandtechnology committed Oct 3, 2023
1 parent 235f56f commit 42366bc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ private void init() throws SQLException {
*/

private void createShopsTable() {
String sqlString = "CREATE TABLE " + manager.getDatabase().getTablePrefix() + "shops (owner VARCHAR(255) NOT NULL, price double(32, 2) NOT NULL, itemConfig TEXT CHARSET utf8 NOT NULL, x INTEGER(32) NOT NULL, y INTEGER(32) NOT NULL, z INTEGER(32) NOT NULL, world VARCHAR(32) NOT NULL, unlimited boolean, type boolean, PRIMARY KEY (x, y, z, world) );";
String sqlString = "CREATE TABLE " + manager.getDatabase().getTablePrefix() + "shops (owner VARCHAR(255) NOT NULL, price double(32, 2) NOT NULL, itemConfig TEXT CHARSET utf8 NOT NULL, x INTEGER(32) NOT NULL, y INTEGER(32) NOT NULL, z INTEGER(32) NOT NULL, world VARCHAR(128) NOT NULL, unlimited boolean, type boolean, PRIMARY KEY (x, y, z, world) );";
if (manager.getDatabase() instanceof MySQLCore) {
sqlString = "CREATE TABLE " + manager.getDatabase().getTablePrefix() + "shops (owner VARCHAR(255) NOT NULL, price double(32, 2) NOT NULL, itemConfig TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci, x INTEGER(32) NOT NULL, y INTEGER(32) NOT NULL, z INTEGER(32) NOT NULL, world VARCHAR(32) NOT NULL, unlimited boolean, type boolean, PRIMARY KEY (x, y, z, world) );";
sqlString = "CREATE TABLE " + manager.getDatabase().getTablePrefix() + "shops (owner VARCHAR(255) NOT NULL, price double(32, 2) NOT NULL, itemConfig TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci, x INTEGER(32) NOT NULL, y INTEGER(32) NOT NULL, z INTEGER(32) NOT NULL, world VARCHAR(128) NOT NULL, unlimited boolean, type boolean, PRIMARY KEY (x, y, z, world) );";
}
manager.runInstantTask(new DatabaseTask(sqlString));
}
Expand Down Expand Up @@ -111,7 +111,7 @@ private void createLogsTable() {

private void createExternalCacheTable() {
String createTable = "CREATE TABLE " + manager.getDatabase().getTablePrefix()
+ "external_cache (x INTEGER(32) NOT NULL, y INTEGER(32) NOT NULL, z INTEGER(32) NOT NULL, world VARCHAR(32) NOT NULL, PRIMARY KEY (x, y, z, world));";
+ "external_cache (x INTEGER(32) NOT NULL, y INTEGER(32) NOT NULL, z INTEGER(32) NOT NULL, world VARCHAR(128) NOT NULL, PRIMARY KEY (x, y, z, world));";
manager.runInstantTask(new DatabaseTask(createTable));
createColumn("external_cache", "space", new DataType(DataTypeMapping.INT, null));
createColumn("external_cache", "stock", new DataType(DataTypeMapping.INT, null));
Expand Down Expand Up @@ -151,6 +151,9 @@ public void onFailed(SQLException e) {
manager.runInstantTask(new DatabaseTask("ALTER TABLE " + manager.getDatabase().getTablePrefix() + "shops TO CHARACTER SET uft8mb4 COLLATE utf8mb4_general_ci", checkTask));
manager.runInstantTask(new DatabaseTask("ALTER TABLE " + manager.getDatabase().getTablePrefix() + "messages TO CHARACTER SET uft8mb4 COLLATE utf8mb4_general_ci", checkTask));
manager.runInstantTask(new DatabaseTask("ALTER TABLE " + manager.getDatabase().getTablePrefix() + "history TO CHARACTER SET uft8mb4 COLLATE utf8mb4_general_ci", checkTask));
//Using varchar 128 for world name
manager.runInstantTask(new DatabaseTask("ALTER TABLE " + manager.getDatabase().getTablePrefix() + "shops MODIFY COLUMN world VARCHAR(128)", checkTask));
manager.runInstantTask(new DatabaseTask("ALTER TABLE " + manager.getDatabase().getTablePrefix() + "external_cache MODIFY COLUMN world VARCHAR(128)", checkTask));
}
plugin.getLogger().info("Finished!");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ static class IndexMetaHandler extends DefaultHandler {
@Override
public void endElement(String uri, String localName, String qName) {
switch (qName) {
case "latest":
case "release":
latestRelease = tempStr;
break;
case "lastUpdated":
Expand Down

0 comments on commit 42366bc

Please # to comment.