mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-24 07:02:54 +08:00
Automatically create account on login screen
This commit is contained in:
parent
866941589b
commit
dd826abb55
@ -91,7 +91,7 @@ public final class CommandMap {
|
|||||||
public void invoke(GenshinPlayer player, String rawMessage) {
|
public void invoke(GenshinPlayer player, String rawMessage) {
|
||||||
rawMessage = rawMessage.trim();
|
rawMessage = rawMessage.trim();
|
||||||
if(rawMessage.length() == 0) {
|
if(rawMessage.length() == 0) {
|
||||||
CommandHandler.sendMessage(player, "No command specified.");
|
CommandHandler.sendMessage(player, "No command specified."); return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove prefix if present.
|
// Remove prefix if present.
|
||||||
@ -113,7 +113,7 @@ public final class CommandMap {
|
|||||||
if(player != null) {
|
if(player != null) {
|
||||||
String permissionNode = this.annotations.get(label).permission();
|
String permissionNode = this.annotations.get(label).permission();
|
||||||
Account account = player.getAccount();
|
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;
|
CommandHandler.sendMessage(player, "You do not have permission to run this command."); return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -188,6 +188,7 @@ public final class ServerCommands {
|
|||||||
} else {
|
} else {
|
||||||
CommandHandler.sendMessage(null, "Account created with UID " + account.getPlayerId() + ".");
|
CommandHandler.sendMessage(null, "Account created with UID " + account.getPlayerId() + ".");
|
||||||
account.addPermission("*"); // Grant the player superuser permissions.
|
account.addPermission("*"); // Grant the player superuser permissions.
|
||||||
|
account.save(); // Save account to database.
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case "delete":
|
case "delete":
|
||||||
|
@ -225,17 +225,17 @@ public final class DispatchServer {
|
|||||||
// Login
|
// Login
|
||||||
Account account = DatabaseHelper.getAccountByName(requestData.account);
|
Account account = DatabaseHelper.getAccountByName(requestData.account);
|
||||||
|
|
||||||
// Test
|
// Check if account exists, else create a new one.
|
||||||
if (account == null) {
|
if (account == null) {
|
||||||
responseData.retcode = -201;
|
account = DatabaseHelper.createAccountWithId(requestData.account, 0);
|
||||||
responseData.message = "Username not found.";
|
// This account has been created AUTOMATICALLY. There will be no permissions added.
|
||||||
} 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
|
// Create a response
|
||||||
String response = getGsonFactory().toJson(responseData);
|
String response = getGsonFactory().toJson(responseData);
|
||||||
// Set the response header status and length
|
// Set the response header status and length
|
||||||
|
Loading…
Reference in New Issue
Block a user