diff --git a/src/main/java/emu/grasscutter/Config.java b/src/main/java/emu/grasscutter/Config.java index 983524223..8573c83ba 100644 --- a/src/main/java/emu/grasscutter/Config.java +++ b/src/main/java/emu/grasscutter/Config.java @@ -53,5 +53,6 @@ public final class Config { public int MaxEntityLimit = 1000; // Max entity limit per world. // TODO: Enforce later. public int[] WelcomeEmotes = {2007, 1002, 4010}; public String WelcomeMotd = "Welcome to Grasscutter emu"; + public boolean AutomaticallyCreateAccounts = false; } } diff --git a/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java b/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java index a3c73d465..dab6ba0a4 100644 --- a/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java +++ b/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java @@ -226,15 +226,23 @@ public final class DispatchServer { Account account = DatabaseHelper.getAccountByName(requestData.account); // Check if account exists, else create a new one. - if (account == null) { - account = DatabaseHelper.createAccountWithId(requestData.account, 0); + if (account == null && Grasscutter.getConfig().ServerOptions.AutomaticallyCreateAccounts) { // This account has been created AUTOMATICALLY. There will be no permissions added. + account = DatabaseHelper.createAccountWithId(requestData.account, 0); + + responseData.message = "OK"; + responseData.data.account.uid = account.getId(); + responseData.data.account.token = account.generateSessionKey(); + responseData.data.account.email = account.getEmail(); + } else if (!Grasscutter.getConfig().ServerOptions.AutomaticallyCreateAccounts) { + 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(); } - - 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);