mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-29 13:42:56 +08:00
More refactoring (player id -> player uid)
This commit is contained in:
parent
35925903a1
commit
75cea5bc48
@ -46,7 +46,7 @@ public final class AccountCommand implements CommandHandler {
|
|||||||
CommandHandler.sendMessage(null, "Account already exists.");
|
CommandHandler.sendMessage(null, "Account already exists.");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
CommandHandler.sendMessage(null, "Account created with UID " + account.getPlayerId() + ".");
|
CommandHandler.sendMessage(null, "Account created with UID " + account.getPlayerUid() + ".");
|
||||||
account.addPermission("*"); // Grant the player superuser permissions.
|
account.addPermission("*"); // Grant the player superuser permissions.
|
||||||
account.save(); // Save account to database.
|
account.save(); // Save account to database.
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ public final class KickCommand implements CommandHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sender != null) {
|
if (sender != null) {
|
||||||
CommandHandler.sendMessage(sender, String.format("Player [%s:%s] has kicked player [%s:%s]", sender.getAccount().getPlayerId(), sender.getAccount().getUsername(), target, targetPlayer.getAccount().getUsername()));
|
CommandHandler.sendMessage(sender, String.format("Player [%s:%s] has kicked player [%s:%s]", sender.getAccount().getPlayerUid(), sender.getAccount().getUsername(), target, targetPlayer.getAccount().getUsername()));
|
||||||
}
|
}
|
||||||
CommandHandler.sendMessage(sender, String.format("Kicking player [%s:%s]", target, targetPlayer.getAccount().getUsername()));
|
CommandHandler.sendMessage(sender, String.format("Kicking player [%s:%s]", target, targetPlayer.getAccount().getUsername()));
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package emu.grasscutter.game;
|
package emu.grasscutter.game;
|
||||||
|
|
||||||
|
import dev.morphia.annotations.AlsoLoad;
|
||||||
import dev.morphia.annotations.Collation;
|
import dev.morphia.annotations.Collation;
|
||||||
import dev.morphia.annotations.Entity;
|
import dev.morphia.annotations.Entity;
|
||||||
import dev.morphia.annotations.Id;
|
import dev.morphia.annotations.Id;
|
||||||
@ -24,7 +25,7 @@ public class Account {
|
|||||||
private String username;
|
private String username;
|
||||||
private String password; // Unused for now
|
private String password; // Unused for now
|
||||||
|
|
||||||
private int playerId;
|
@AlsoLoad("playerUid") private int playerId;
|
||||||
private String email;
|
private String email;
|
||||||
|
|
||||||
private String token;
|
private String token;
|
||||||
@ -68,7 +69,7 @@ public class Account {
|
|||||||
this.token = token;
|
this.token = token;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPlayerId() {
|
public int getPlayerUid() {
|
||||||
return this.playerId;
|
return this.playerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -722,7 +722,7 @@ public class GenshinPlayer {
|
|||||||
// Make sure these exist
|
// Make sure these exist
|
||||||
if (this.getTeamManager() == null) {
|
if (this.getTeamManager() == null) {
|
||||||
this.teamManager = new TeamManager(this);
|
this.teamManager = new TeamManager(this);
|
||||||
} if (this.getProfile().getId() == 0) {
|
} if (this.getProfile().getUid() == 0) {
|
||||||
this.getProfile().syncWithCharacter(this);
|
this.getProfile().syncWithCharacter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,7 +220,7 @@ public class FriendsList {
|
|||||||
friendship.setOwner(getPlayer());
|
friendship.setOwner(getPlayer());
|
||||||
|
|
||||||
// Check if friend is online
|
// Check if friend is online
|
||||||
GenshinPlayer friend = getPlayer().getSession().getServer().getPlayerByUid(friendship.getFriendProfile().getId());
|
GenshinPlayer friend = getPlayer().getSession().getServer().getPlayerByUid(friendship.getFriendProfile().getUid());
|
||||||
if (friend != null) {
|
if (friend != null) {
|
||||||
// Set friend to online mode
|
// Set friend to online mode
|
||||||
friendship.setFriendProfile(friend);
|
friendship.setFriendProfile(friend);
|
||||||
|
@ -88,7 +88,7 @@ public class Friendship {
|
|||||||
|
|
||||||
public FriendBrief toProto() {
|
public FriendBrief toProto() {
|
||||||
FriendBrief proto = FriendBrief.newBuilder()
|
FriendBrief proto = FriendBrief.newBuilder()
|
||||||
.setUid(getFriendProfile().getId())
|
.setUid(getFriendProfile().getUid())
|
||||||
.setNickname(getFriendProfile().getName())
|
.setNickname(getFriendProfile().getName())
|
||||||
.setLevel(getFriendProfile().getPlayerLevel())
|
.setLevel(getFriendProfile().getPlayerLevel())
|
||||||
.setAvatar(HeadImage.newBuilder().setAvatarId(getFriendProfile().getAvatarId()))
|
.setAvatar(HeadImage.newBuilder().setAvatarId(getFriendProfile().getAvatarId()))
|
||||||
|
@ -7,7 +7,7 @@ import emu.grasscutter.utils.Utils;
|
|||||||
public class PlayerProfile {
|
public class PlayerProfile {
|
||||||
@Transient private GenshinPlayer player;
|
@Transient private GenshinPlayer player;
|
||||||
|
|
||||||
private int id;
|
@AlsoLoad("id") private int uid;
|
||||||
private int nameCard;
|
private int nameCard;
|
||||||
private int avatarId;
|
private int avatarId;
|
||||||
private String name;
|
private String name;
|
||||||
@ -22,12 +22,12 @@ public class PlayerProfile {
|
|||||||
public PlayerProfile() { }
|
public PlayerProfile() { }
|
||||||
|
|
||||||
public PlayerProfile(GenshinPlayer player) {
|
public PlayerProfile(GenshinPlayer player) {
|
||||||
this.id = player.getUid();
|
this.uid = player.getUid();
|
||||||
this.syncWithCharacter(player);
|
this.syncWithCharacter(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getUid() {
|
||||||
return id;
|
return uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GenshinPlayer getPlayer() {
|
public GenshinPlayer getPlayer() {
|
||||||
@ -87,7 +87,7 @@ public class PlayerProfile {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.id = player.getUid();
|
this.uid = player.getUid();
|
||||||
this.name = player.getNickname();
|
this.name = player.getNickname();
|
||||||
this.avatarId = player.getHeadImage();
|
this.avatarId = player.getHeadImage();
|
||||||
this.signature = player.getSignature();
|
this.signature = player.getSignature();
|
||||||
|
@ -35,15 +35,15 @@ public class HandlerGetPlayerTokenReq extends PacketHandler {
|
|||||||
|
|
||||||
// Has character
|
// Has character
|
||||||
boolean doesPlayerExist = false;
|
boolean doesPlayerExist = false;
|
||||||
if (account.getPlayerId() > 0) {
|
if (account.getPlayerUid() > 0) {
|
||||||
// Set flag for player existing
|
// Set flag for player existing
|
||||||
doesPlayerExist = DatabaseHelper.checkPlayerExists(account.getPlayerId());
|
doesPlayerExist = DatabaseHelper.checkPlayerExists(account.getPlayerUid());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set reserve player id if account doesnt exist
|
// Set reserve player id if account doesnt exist
|
||||||
if (!doesPlayerExist) {
|
if (!doesPlayerExist) {
|
||||||
int id = DatabaseHelper.getNextPlayerId(session.getAccount().getPlayerId());
|
int id = DatabaseHelper.getNextPlayerId(session.getAccount().getPlayerUid());
|
||||||
if (id != session.getAccount().getPlayerId()) {
|
if (id != session.getAccount().getPlayerUid()) {
|
||||||
session.getAccount().setPlayerId(id);
|
session.getAccount().setPlayerId(id);
|
||||||
session.getAccount().save();
|
session.getAccount().save();
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ public class HandlerPlayerLoginReq extends PacketHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load character from db
|
// Load character from db
|
||||||
GenshinPlayer player = DatabaseHelper.getPlayerById(session.getAccount().getPlayerId());
|
GenshinPlayer player = DatabaseHelper.getPlayerById(session.getAccount().getPlayerUid());
|
||||||
|
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
// Send packets
|
// Send packets
|
||||||
|
@ -43,7 +43,7 @@ public class HandlerSetPlayerBornDataReq extends PacketHandler {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// Save to db
|
// Save to db
|
||||||
DatabaseHelper.createPlayer(player, session.getAccount().getPlayerId());
|
DatabaseHelper.createPlayer(player, session.getAccount().getPlayerUid());
|
||||||
|
|
||||||
// Create avatar
|
// Create avatar
|
||||||
if (player.getAvatars().getAvatarCount() == 0) {
|
if (player.getAvatars().getAvatarCount() == 0) {
|
||||||
|
@ -16,7 +16,7 @@ public class PacketGetPlayerTokenRsp extends GenshinPacket {
|
|||||||
this.setUseDispatchKey(true);
|
this.setUseDispatchKey(true);
|
||||||
|
|
||||||
GetPlayerTokenRsp p = GetPlayerTokenRsp.newBuilder()
|
GetPlayerTokenRsp p = GetPlayerTokenRsp.newBuilder()
|
||||||
.setPlayerUid(session.getAccount().getPlayerId())
|
.setPlayerUid(session.getAccount().getPlayerUid())
|
||||||
.setAccountToken(session.getAccount().getToken())
|
.setAccountToken(session.getAccount().getToken())
|
||||||
.setAccountType(1)
|
.setAccountType(1)
|
||||||
.setIsProficientPlayer(doesPlayerExist) // Not sure where this goes
|
.setIsProficientPlayer(doesPlayerExist) // Not sure where this goes
|
||||||
|
Loading…
Reference in New Issue
Block a user