Fixed bug were coords were not save and changed how how the check if coords already exist works

This commit is contained in:
Doc
2024-03-01 14:15:18 +01:00
parent 2016add473
commit a0acee4950
3 changed files with 5 additions and 6 deletions

View File

@@ -4,7 +4,7 @@ plugins {
} }
group = "dev.protron" group = "dev.protron"
version = "0.0.5-dev" version = "0.0.5"
repositories { repositories {
mavenCentral() mavenCentral()

View File

@@ -27,7 +27,7 @@ public class Commands {
checkPstmt.setString(2, coordname); checkPstmt.setString(2, coordname);
ResultSet checkResult = checkPstmt.executeQuery(); ResultSet checkResult = checkPstmt.executeQuery();
if (Objects.equals(checkResult.getString("coordname"), coordname)) { if (checkResult.getString("coordname") != null) {
TextComponent alreadyExistMessage = text() TextComponent alreadyExistMessage = text()
.content("A entry with the name ") .content("A entry with the name ")
.append(text(coordname)).color(TextColor.color(RED)) .append(text(coordname)).color(TextColor.color(RED))
@@ -46,10 +46,10 @@ public class Commands {
// Executing the query // Executing the query
pstmt.executeUpdate(); pstmt.executeUpdate();
String validateQuery = "SELECT * FROM coords WHERE uuid = ? and coordname = ?"; String validateQuery = "SELECT * FROM coords WHERE uuid = ? AND coordname = ?";
PreparedStatement validatePstmt = connection.prepareStatement(validateQuery); PreparedStatement validatePstmt = connection.prepareStatement(validateQuery);
checkPstmt.setString(1, playerUUID); validatePstmt.setString(1, playerUUID);
checkPstmt.setString(2, coordname); validatePstmt.setString(2, coordname);
ResultSet validateResult = validatePstmt.executeQuery(); ResultSet validateResult = validatePstmt.executeQuery();
if (Objects.equals(validateResult.getString("coordname"), coordname)) { if (Objects.equals(validateResult.getString("coordname"), coordname)) {

View File

@@ -63,7 +63,6 @@ public class CoordSave extends JavaPlugin {
final TextComponent errorMessage = text() final TextComponent errorMessage = text()
.content("No name provided").color(color(RED)) .content("No name provided").color(color(RED))
.build(); .build();
player.sendMessage(errorMessage); player.sendMessage(errorMessage);
yield false; yield false;
} }