mirror of
https://github.com/Anime-Game-Servers/Grasscutter-Quests.git
synced 2024-11-30 07:50:54 +00:00
Merge pull request #40 from Grasscutters/auto-account
Create the account if it doesn't exist on the login screen
This commit is contained in:
commit
88e608adba
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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(!permissionNode.isEmpty() && !account.hasPermission(permissionNode)) {
|
||||
CommandHandler.sendMessage(player, "You do not have permission to run this command."); return;
|
||||
}
|
||||
}
|
||||
|
@ -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":
|
||||
|
@ -225,8 +225,16 @@ public final class DispatchServer {
|
||||
// Login
|
||||
Account account = DatabaseHelper.getAccountByName(requestData.account);
|
||||
|
||||
// Test
|
||||
if (account == null) {
|
||||
// Check if account exists, else create a new one.
|
||||
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 {
|
||||
|
Loading…
Reference in New Issue
Block a user