From e1688c866fd10894201b787315744ead0d18e7ad Mon Sep 17 00:00:00 2001 From: ImmuState Date: Wed, 1 Jun 2022 14:55:33 -0700 Subject: [PATCH] Make sure no player already has the reserved UID when creating and account. --- .../java/emu/grasscutter/database/DatabaseHelper.java | 8 ++++++++ src/main/resources/languages/en-US.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/emu/grasscutter/database/DatabaseHelper.java b/src/main/java/emu/grasscutter/database/DatabaseHelper.java index 466cedc6b..fdd9c289e 100644 --- a/src/main/java/emu/grasscutter/database/DatabaseHelper.java +++ b/src/main/java/emu/grasscutter/database/DatabaseHelper.java @@ -38,10 +38,18 @@ public final class DatabaseHelper { if (reservedId == GameConstants.SERVER_CONSOLE_UID) { return null; } + + // Make sure not other accounts has that id as its reservedPlayerId exists = DatabaseHelper.getAccountByPlayerId(reservedId); if (exists != null) { return null; } + + // Make sure no existing player already has this id. + Player existsPlayer = DatabaseHelper.getPlayerByUid(reservedId); + if (existsPlayer != null) { + return null; + } } // Account diff --git a/src/main/resources/languages/en-US.json b/src/main/resources/languages/en-US.json index c747742bd..f18729700 100644 --- a/src/main/resources/languages/en-US.json +++ b/src/main/resources/languages/en-US.json @@ -103,7 +103,7 @@ "account": { "modify": "Modify user accounts", "invalid": "Invalid UID.", - "exists": "Account already exists.", + "exists": "An account with this username and/or UID already exists.", "create": "Account created with UID %s.", "delete": "Account deleted.", "no_account": "Account not found.",