Various SQL Fixes for Syntax + Functionality Improv.

This commit is contained in:
Laika 2022-05-04 11:29:28 -07:00
parent 59e1866c59
commit 22a30c07f9
3 changed files with 13 additions and 7 deletions

View file

@ -78,6 +78,11 @@
<version>5.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.28</version>
</dependency>
<dependency>
<groupId>webukkit</groupId>
<artifactId>dynmap</artifactId>

View file

@ -19,23 +19,23 @@ public class NAWDatabase {
private final String INITIALIZE_NATION_PLAYERS = "CREATE TABLE IF NOT EXISTS `nation_players`" +
"(`nation_name` VARCHAR(50) NOT NULL COMMENT 'The name of the nation for the player to join'," +
"`player_uuid` VARCHAR(50) NOT NULL COMMENT 'The UUID of the player who is in that nation', PRIMARY KEY (`player_uuid`)";
"`player_uuid` VARCHAR(50) NOT NULL COMMENT 'The UUID of the player who is in that nation', PRIMARY KEY (`player_uuid`));";
private final String INITIALIZE_NATIONS = "CREATE TABLE IF NOT EXISTS `nations` (" +
"`nation_name` VARCHAR(50) NOT NULL COMMENT 'Nation name'," +
"`nation_name` VARCHAR(50) NOT NULL COMMENT 'Nation name', PRIMARY KEY (`nation_name`)," +
"`groupName` VARCHAR(50) NOT NULL COMMENT 'Name for the luckperms group.', " +
"`dynmapIcon` VARCHAR(50) NOT NULL COMMENT 'National Icon for Dynmap'," +
"`spawnworld` VARCHAR(50) NOT NULL," +
"`spawnx` INT NOT NULL DEFAULT 0," +
"`spawny` INT NOT NULL DEFAULT 0," +
"`spawnz` INT NOT NULL DEFAULT 0), PRIMARY KEY (`nation_name`)";
private final String INITIALIZE_CITIES = "CREATE TABLE `cities` (" +
"`city_name` VARCHAR(50) NOT NULL DEFAULT '' COMMENT 'City Name'," +
"`spawnz` INT NOT NULL DEFAULT 0);";
private final String INITIALIZE_CITIES = "CREATE TABLE IF NOT EXISTS `cities` (" +
"`city_name` VARCHAR(50) NOT NULL DEFAULT '' COMMENT 'City Name', PRIMARY KEY (`city_name`)," +
"`resource` VARCHAR(50) NOT NULL DEFAULT '' COMMENT 'Resource the city provides'," +
"`owner` VARCHAR(50) NOT NULL DEFAULT '' COMMENT 'The name of the nation that owns it'," +
"`pointworld` VARCHAR(50) NOT NULL DEFAULT ''," +
"`pointx` INT NOT NULL DEFAULT 0," +
"`pointy` INT NOT NULL DEFAULT 0," +
"`pointz` INT NOT NULL DEFAULT 0) COMMENT='Cities on the NAW map', PRIMARY KEY (`city_name`);";
"`pointz` INT NOT NULL DEFAULT 0) COMMENT='Cities on the NAW map';";
private final String SELECT_CITIES = "SELECT * FROM `cities`;";
private final String SELECT_NATION = "SELECT * FROM `nations`;";
private final String SELECT_PLAYERS = "SELECT * FROM `nation_players`;";
@ -55,7 +55,7 @@ public class NAWDatabase {
public NAWDatabase(String username, String password, String host, int port, String database) {
//all relevant
try {
connection = DriverManager.getConnection("jdbc:mysql//" + host + ":" + port + "/" + database, username, password);
connection = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, username, password);
} catch (Exception ex) {
ex.printStackTrace();
OpenNAW.getInstance().getLogger().severe("FAILED TO INITIALIZE PERSISTENT MYSQL DATABASE.");

View file

@ -44,6 +44,7 @@ public class NationHandler {
}
public Nation fetchNationViaName(String name) {
if(name.equals(Nation.UNCLAIMED.getName())) { return Nation.UNCLAIMED; }
for(Nation cty : nations.values()) {
if(cty.getName().equalsIgnoreCase(name)) {
return cty;