mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-15 08:25:21 +01:00
Merge branch 'Grasscutters:development' into development
This commit is contained in:
@@ -1,22 +1,18 @@
|
||||
package emu.grasscutter.game;
|
||||
|
||||
import dev.morphia.annotations.AlsoLoad;
|
||||
import dev.morphia.annotations.Collation;
|
||||
import dev.morphia.annotations.Entity;
|
||||
import dev.morphia.annotations.Id;
|
||||
import dev.morphia.annotations.Indexed;
|
||||
import dev.morphia.annotations.PreLoad;
|
||||
import dev.morphia.annotations.*;
|
||||
import emu.grasscutter.database.DatabaseHelper;
|
||||
import emu.grasscutter.utils.Crypto;
|
||||
import emu.grasscutter.utils.Utils;
|
||||
import dev.morphia.annotations.IndexOptions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bson.Document;
|
||||
|
||||
import com.mongodb.DBObject;
|
||||
|
||||
@Entity(value = "accounts", noClassnameStored = true)
|
||||
@Entity(value = "accounts", useDiscriminator = false)
|
||||
public class Account {
|
||||
@Id private String id;
|
||||
|
||||
@@ -31,7 +27,7 @@ public class Account {
|
||||
private String token;
|
||||
private String sessionKey; // Session token for dispatch server
|
||||
private List<String> permissions;
|
||||
|
||||
|
||||
@Deprecated
|
||||
public Account() {
|
||||
this.permissions = new ArrayList<>();
|
||||
@@ -122,15 +118,15 @@ public class Account {
|
||||
return this.token;
|
||||
}
|
||||
|
||||
@PreLoad
|
||||
public void onLoad(DBObject dbObj) {
|
||||
// Grant the superuser permissions to accounts created before the permissions update
|
||||
if (!dbObj.containsField("permissions")) {
|
||||
this.addPermission("*");
|
||||
}
|
||||
}
|
||||
|
||||
public void save() {
|
||||
DatabaseHelper.saveAccount(this);
|
||||
}
|
||||
|
||||
@PreLoad
|
||||
public void onLoad(Document document) {
|
||||
// Grant the superuser permissions to accounts created before the permissions update
|
||||
if (!document.containsKey("permissions")) {
|
||||
this.addPermission("*");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import emu.grasscutter.game.friends.PlayerProfile;
|
||||
import emu.grasscutter.game.gacha.PlayerGachaInfo;
|
||||
import emu.grasscutter.game.inventory.GenshinItem;
|
||||
import emu.grasscutter.game.inventory.Inventory;
|
||||
import emu.grasscutter.game.player.PlayerBirthday;
|
||||
import emu.grasscutter.game.props.ActionReason;
|
||||
import emu.grasscutter.game.props.PlayerProperty;
|
||||
import emu.grasscutter.net.packet.GenshinPacket;
|
||||
@@ -61,7 +62,7 @@ import emu.grasscutter.utils.Position;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
@Entity(value = "players", noClassnameStored = true)
|
||||
@Entity(value = "players", useDiscriminator = false)
|
||||
public class GenshinPlayer {
|
||||
@Id private int id;
|
||||
@Indexed(options = @IndexOptions(unique = true)) private String accountId;
|
||||
@@ -73,6 +74,7 @@ public class GenshinPlayer {
|
||||
private int nameCardId = 210001;
|
||||
private Position pos;
|
||||
private Position rotation;
|
||||
private PlayerBirthday birthday;
|
||||
|
||||
private Map<Integer, Integer> properties;
|
||||
private Set<Integer> nameCardList;
|
||||
@@ -139,6 +141,8 @@ public class GenshinPlayer {
|
||||
this.combatInvokeHandler = new InvokeHandler(PacketCombatInvocationsNotify.class);
|
||||
this.abilityInvokeHandler = new InvokeHandler(PacketAbilityInvocationsNotify.class);
|
||||
this.clientAbilityInitFinishHandler = new InvokeHandler(PacketClientAbilityInitFinishNotify.class);
|
||||
|
||||
this.birthday = new PlayerBirthday();
|
||||
}
|
||||
|
||||
// On player creation
|
||||
@@ -150,6 +154,7 @@ public class GenshinPlayer {
|
||||
this.nickname = "Traveler";
|
||||
this.signature = "";
|
||||
this.teamManager = new TeamManager(this);
|
||||
this.birthday = new PlayerBirthday();
|
||||
this.setProperty(PlayerProperty.PROP_PLAYER_LEVEL, 1);
|
||||
this.setProperty(PlayerProperty.PROP_IS_SPRING_AUTO_USE, 1);
|
||||
this.setProperty(PlayerProperty.PROP_SPRING_AUTO_USE_PERCENT, 50);
|
||||
@@ -642,6 +647,15 @@ public class GenshinPlayer {
|
||||
return onlineInfo.build();
|
||||
}
|
||||
|
||||
public PlayerBirthday getBirthday(){
|
||||
return this.birthday;
|
||||
}
|
||||
|
||||
public void setBirthday(int d, int m) {
|
||||
this.birthday = new PlayerBirthday(d, m);
|
||||
this.updateProfile();
|
||||
}
|
||||
|
||||
public SocialDetail.Builder getSocialDetail() {
|
||||
SocialDetail.Builder social = SocialDetail.newBuilder()
|
||||
.setUid(this.getUid())
|
||||
@@ -649,7 +663,7 @@ public class GenshinPlayer {
|
||||
.setNickname(this.getNickname())
|
||||
.setSignature(this.getSignature())
|
||||
.setLevel(this.getLevel())
|
||||
.setBirthday(Birthday.newBuilder())
|
||||
.setBirthday(this.getBirthday().getFilledProtoWhenNotEmpty())
|
||||
.setWorldLevel(this.getWorldLevel())
|
||||
.setUnk1(1)
|
||||
.setUnk3(1)
|
||||
|
||||
@@ -3,10 +3,12 @@ package emu.grasscutter.game;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import dev.morphia.annotations.Entity;
|
||||
import emu.grasscutter.GenshinConstants;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.game.avatar.GenshinAvatar;
|
||||
|
||||
@Entity
|
||||
public class TeamInfo {
|
||||
private String name;
|
||||
private List<Integer> avatars;
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import dev.morphia.annotations.Entity;
|
||||
import dev.morphia.annotations.Transient;
|
||||
import emu.grasscutter.GenshinConstants;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
@@ -41,6 +42,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||
|
||||
@Entity
|
||||
public class TeamManager {
|
||||
@Transient private GenshinPlayer player;
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package emu.grasscutter.game.avatar;
|
||||
|
||||
import dev.morphia.annotations.Entity;
|
||||
|
||||
@Entity
|
||||
public class AvatarProfileData {
|
||||
private int avatarId;
|
||||
private int level;
|
||||
|
||||
@@ -56,7 +56,7 @@ import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
@Entity(value = "avatars", noClassnameStored = true)
|
||||
@Entity(value = "avatars", useDiscriminator = false)
|
||||
public class GenshinAvatar {
|
||||
@Id private ObjectId id;
|
||||
@Indexed private int ownerId; // Id of player that this avatar belongs to
|
||||
|
||||
@@ -9,7 +9,7 @@ import emu.grasscutter.net.proto.FriendBriefOuterClass.FriendBrief;
|
||||
import emu.grasscutter.net.proto.FriendOnlineStateOuterClass.FriendOnlineState;
|
||||
import emu.grasscutter.net.proto.HeadImageOuterClass.HeadImage;
|
||||
|
||||
@Entity(value = "friendships", noClassnameStored = true)
|
||||
@Entity(value = "friendships", useDiscriminator = false)
|
||||
public class Friendship {
|
||||
@Id private ObjectId id;
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import dev.morphia.annotations.*;
|
||||
import emu.grasscutter.game.GenshinPlayer;
|
||||
import emu.grasscutter.utils.Utils;
|
||||
|
||||
@Entity
|
||||
public class PlayerProfile {
|
||||
@Transient private GenshinPlayer player;
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package emu.grasscutter.game.gacha;
|
||||
|
||||
import dev.morphia.annotations.Entity;
|
||||
|
||||
@Entity
|
||||
public class PlayerGachaBannerInfo {
|
||||
private int pity5 = 0;
|
||||
private int pity4 = 0;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package emu.grasscutter.game.gacha;
|
||||
|
||||
import dev.morphia.annotations.Entity;
|
||||
|
||||
@Entity
|
||||
public class PlayerGachaInfo {
|
||||
private PlayerGachaBannerInfo standardBanner;
|
||||
private PlayerGachaBannerInfo eventCharacterBanner;
|
||||
|
||||
@@ -34,7 +34,7 @@ import emu.grasscutter.net.proto.SceneWeaponInfoOuterClass.SceneWeaponInfo;
|
||||
import emu.grasscutter.net.proto.WeaponOuterClass.Weapon;
|
||||
import emu.grasscutter.utils.WeightedList;
|
||||
|
||||
@Entity(value = "items", noClassnameStored = true)
|
||||
@Entity(value = "items", useDiscriminator = false)
|
||||
public class GenshinItem {
|
||||
@Id private ObjectId id;
|
||||
@Indexed private int ownerId;
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
package emu.grasscutter.game.player;
|
||||
|
||||
import dev.morphia.annotations.Entity;
|
||||
import emu.grasscutter.net.proto.BirthdayOuterClass.Birthday;
|
||||
|
||||
@Entity
|
||||
public class PlayerBirthday {
|
||||
private int day;
|
||||
private int month;
|
||||
|
||||
public PlayerBirthday(){
|
||||
this.day = 0;
|
||||
this.month = 0;
|
||||
}
|
||||
|
||||
public PlayerBirthday(int day, int month){
|
||||
this.day = day;
|
||||
this.month = month;
|
||||
}
|
||||
|
||||
public PlayerBirthday set(PlayerBirthday birth){
|
||||
this.day = birth.day;
|
||||
this.month = birth.month;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public PlayerBirthday set(int d, int m){
|
||||
this.day = d;
|
||||
this.month = m;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public PlayerBirthday setDay(int value){
|
||||
this.day = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PlayerBirthday setMonth(int value){
|
||||
this.month = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getDay(){
|
||||
return this.day;
|
||||
}
|
||||
|
||||
public int getMonth(){
|
||||
return this.month;
|
||||
}
|
||||
|
||||
public Birthday toProto(){
|
||||
return Birthday.newBuilder()
|
||||
.setDay(this.getDay())
|
||||
.setMonth(this.getMonth())
|
||||
.build();
|
||||
}
|
||||
|
||||
public Birthday.Builder getFilledProtoWhenNotEmpty(){
|
||||
if(this.getDay() > 0)
|
||||
{
|
||||
return Birthday.newBuilder()
|
||||
.setDay(this.getDay())
|
||||
.setMonth(this.getMonth());
|
||||
}
|
||||
|
||||
return Birthday.newBuilder();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user