diff --git a/src/main/java/emu/grasscutter/commands/CommandMap.java b/src/main/java/emu/grasscutter/commands/CommandMap.java index a802551ce..aee080912 100644 --- a/src/main/java/emu/grasscutter/commands/CommandMap.java +++ b/src/main/java/emu/grasscutter/commands/CommandMap.java @@ -91,7 +91,7 @@ public final class CommandMap { public void invoke(GenshinPlayer player, String rawMessage) { rawMessage = rawMessage.trim(); if(rawMessage.length() == 0) { - CommandHandler.sendMessage(player, "No command specified."); + CommandHandler.sendMessage(player, "No command specified."); return; } // Remove prefix if present. @@ -113,7 +113,7 @@ public final class CommandMap { if(player != null) { String permissionNode = this.annotations.get(label).permission(); Account account = player.getAccount(); - if(permissionNode != "" && !account.hasPermission(permissionNode)) { + if(!Objects.equals(permissionNode, "") && !account.hasPermission(permissionNode)) { CommandHandler.sendMessage(player, "You do not have permission to run this command."); return; } } diff --git a/src/main/java/emu/grasscutter/commands/ServerCommands.java b/src/main/java/emu/grasscutter/commands/ServerCommands.java index edeac6ca3..8f679581d 100644 --- a/src/main/java/emu/grasscutter/commands/ServerCommands.java +++ b/src/main/java/emu/grasscutter/commands/ServerCommands.java @@ -188,6 +188,7 @@ public final class ServerCommands { } else { CommandHandler.sendMessage(null, "Account created with UID " + account.getPlayerId() + "."); account.addPermission("*"); // Grant the player superuser permissions. + account.save(); // Save account to database. } return; case "delete": diff --git a/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java b/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java index 0ac4c4fc8..a3c73d465 100644 --- a/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java +++ b/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java @@ -225,16 +225,16 @@ public final class DispatchServer { // Login Account account = DatabaseHelper.getAccountByName(requestData.account); - // Test + // Check if account exists, else create a new one. if (account == null) { - responseData.retcode = -201; - responseData.message = "Username not found."; - } else { - responseData.message = "OK"; - responseData.data.account.uid = account.getId(); - responseData.data.account.token = account.generateSessionKey(); - responseData.data.account.email = account.getEmail(); + account = DatabaseHelper.createAccountWithId(requestData.account, 0); + // This account has been created AUTOMATICALLY. There will be no permissions added. } + + responseData.message = "OK"; + responseData.data.account.uid = account.getId(); + responseData.data.account.token = account.generateSessionKey(); + responseData.data.account.email = account.getEmail(); // Create a response String response = getGsonFactory().toJson(responseData);