mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-10 04:52:52 +08:00
Refactor player managers
This commit is contained in:
parent
3957616b6c
commit
d20e9d1f72
@ -21,6 +21,7 @@ import emu.grasscutter.game.entity.EntityItem;
|
||||
import emu.grasscutter.game.entity.GameEntity;
|
||||
import emu.grasscutter.game.entity.gadget.GadgetGatherObject;
|
||||
import emu.grasscutter.game.entity.gadget.GadgetGatherPoint;
|
||||
import emu.grasscutter.game.player.BasePlayerManager;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.game.props.ElementType;
|
||||
import emu.grasscutter.net.proto.AbilityActionGenerateElemBallOuterClass.AbilityActionGenerateElemBall;
|
||||
@ -35,18 +36,14 @@ import emu.grasscutter.utils.Position;
|
||||
import emu.grasscutter.utils.Utils;
|
||||
import emu.grasscutter.game.props.FightProperty;
|
||||
|
||||
public class AbilityManager {
|
||||
public class AbilityManager extends BasePlayerManager {
|
||||
private Player player;
|
||||
HealAbilityManager healAbilityManager;
|
||||
|
||||
public AbilityManager(Player player) {
|
||||
this.player = player;
|
||||
super(player);
|
||||
this.healAbilityManager = new HealAbilityManager(player);
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public void onAbilityInvoke(AbilityInvokeEntry invoke) throws Exception {
|
||||
healAbilityManager.healHandler(invoke);
|
||||
|
@ -5,6 +5,7 @@ import com.google.gson.reflect.TypeToken;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.data.DataLoader;
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.game.player.BasePlayerManager;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.game.props.ActivityType;
|
||||
import emu.grasscutter.game.props.WatcherTriggerType;
|
||||
@ -19,9 +20,8 @@ import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@Getter
|
||||
public class ActivityManager {
|
||||
public class ActivityManager extends BasePlayerManager {
|
||||
private static final Map<Integer, ActivityConfigItem> activityConfigItemMap;
|
||||
private final Player player;
|
||||
private final Map<Integer, PlayerActivityData> playerActivityDataMap;
|
||||
|
||||
static {
|
||||
@ -79,7 +79,7 @@ public class ActivityManager {
|
||||
}
|
||||
|
||||
public ActivityManager(Player player){
|
||||
this.player = player;
|
||||
super(player);
|
||||
|
||||
playerActivityDataMap = new ConcurrentHashMap<>();
|
||||
// load data for player
|
||||
|
@ -1,26 +0,0 @@
|
||||
package emu.grasscutter.game.avatar;
|
||||
|
||||
import dev.morphia.annotations.Entity;
|
||||
|
||||
@Entity
|
||||
public class AvatarProfileData {
|
||||
private int avatarId;
|
||||
private int level;
|
||||
|
||||
public AvatarProfileData(Avatar avatar) {
|
||||
this.update(avatar);
|
||||
}
|
||||
|
||||
public int getAvatarId() {
|
||||
return avatarId;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void update(Avatar avatar) {
|
||||
this.avatarId = avatar.getAvatarId();
|
||||
this.level = avatar.getLevel();
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ import emu.grasscutter.data.excels.AvatarSkillDepotData;
|
||||
import emu.grasscutter.database.DatabaseHelper;
|
||||
import emu.grasscutter.game.entity.EntityAvatar;
|
||||
import emu.grasscutter.game.inventory.GameItem;
|
||||
import emu.grasscutter.game.player.BasePlayerManager;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.server.packet.send.PacketAvatarChangeCostumeNotify;
|
||||
import emu.grasscutter.server.packet.send.PacketAvatarFlycloakChangeNotify;
|
||||
@ -17,20 +18,15 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
||||
|
||||
public class AvatarStorage implements Iterable<Avatar> {
|
||||
private final Player player;
|
||||
public class AvatarStorage extends BasePlayerManager implements Iterable<Avatar> {
|
||||
private final Int2ObjectMap<Avatar> avatars;
|
||||
private final Long2ObjectMap<Avatar> avatarsGuid;
|
||||
|
||||
public AvatarStorage(Player player) {
|
||||
this.player = player;
|
||||
super(player);
|
||||
this.avatars = new Int2ObjectOpenHashMap<>();
|
||||
this.avatarsGuid = new Long2ObjectOpenHashMap<>();
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public Int2ObjectMap<Avatar> getAvatars() {
|
||||
return avatars;
|
||||
|
@ -15,7 +15,6 @@ import org.bson.types.ObjectId;
|
||||
import dev.morphia.annotations.Entity;
|
||||
import dev.morphia.annotations.Id;
|
||||
import dev.morphia.annotations.Indexed;
|
||||
import dev.morphia.annotations.Transient;
|
||||
import emu.grasscutter.GameConstants;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.data.GameData;
|
||||
@ -26,6 +25,7 @@ import emu.grasscutter.data.excels.RewardData;
|
||||
import emu.grasscutter.database.DatabaseHelper;
|
||||
import emu.grasscutter.game.inventory.GameItem;
|
||||
import emu.grasscutter.game.inventory.MaterialType;
|
||||
import emu.grasscutter.game.player.BasePlayerDataManager;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.game.props.BattlePassMissionRefreshType;
|
||||
import emu.grasscutter.game.props.BattlePassMissionStatus;
|
||||
@ -41,9 +41,8 @@ import emu.grasscutter.server.packet.send.PacketTakeBattlePassRewardRsp;
|
||||
import lombok.Getter;
|
||||
|
||||
@Entity(value = "battlepass", useDiscriminator = false)
|
||||
public class BattlePassManager {
|
||||
public class BattlePassManager extends BasePlayerDataManager {
|
||||
@Id @Getter private ObjectId id;
|
||||
@Transient @Getter private Player player;
|
||||
|
||||
@Indexed private int ownerUid;
|
||||
@Getter private int point;
|
||||
@ -60,7 +59,7 @@ public class BattlePassManager {
|
||||
public BattlePassManager() {}
|
||||
|
||||
public BattlePassManager(Player player) {
|
||||
this.setPlayer(player);
|
||||
super(player);
|
||||
}
|
||||
|
||||
public void setPlayer(Player player) {
|
||||
|
@ -3,6 +3,7 @@ package emu.grasscutter.game.friends;
|
||||
import java.util.List;
|
||||
|
||||
import emu.grasscutter.database.DatabaseHelper;
|
||||
import emu.grasscutter.game.player.BasePlayerManager;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.net.proto.DealAddFriendResultTypeOuterClass.DealAddFriendResultType;
|
||||
import emu.grasscutter.server.packet.send.PacketAskAddFriendNotify;
|
||||
@ -13,24 +14,18 @@ import emu.grasscutter.server.packet.send.PacketDeleteFriendRsp;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
public class FriendsList {
|
||||
private final Player player;
|
||||
|
||||
public class FriendsList extends BasePlayerManager {
|
||||
private final Int2ObjectMap<Friendship> friends;
|
||||
private final Int2ObjectMap<Friendship> pendingFriends;
|
||||
|
||||
private boolean loaded = false;
|
||||
|
||||
public FriendsList(Player player) {
|
||||
this.player = player;
|
||||
super(player);
|
||||
this.friends = new Int2ObjectOpenHashMap<Friendship>();
|
||||
this.pendingFriends = new Int2ObjectOpenHashMap<Friendship>();
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public boolean hasLoaded() {
|
||||
return loaded;
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import emu.grasscutter.data.excels.ItemData;
|
||||
import emu.grasscutter.database.DatabaseHelper;
|
||||
import emu.grasscutter.game.avatar.AvatarStorage;
|
||||
import emu.grasscutter.game.avatar.Avatar;
|
||||
import emu.grasscutter.game.player.BasePlayerManager;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.game.props.ActionReason;
|
||||
import emu.grasscutter.game.props.PlayerProperty;
|
||||
@ -31,14 +32,13 @@ import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
||||
|
||||
import static emu.grasscutter.Configuration.*;
|
||||
|
||||
public class Inventory implements Iterable<GameItem> {
|
||||
private final Player player;
|
||||
|
||||
public class Inventory extends BasePlayerManager implements Iterable<GameItem> {
|
||||
private final Long2ObjectMap<GameItem> store;
|
||||
private final Int2ObjectMap<InventoryTab> inventoryTypes;
|
||||
|
||||
public Inventory(Player player) {
|
||||
this.player = player;
|
||||
super(player);
|
||||
|
||||
this.store = new Long2ObjectOpenHashMap<>();
|
||||
this.inventoryTypes = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
@ -48,10 +48,6 @@ public class Inventory implements Iterable<GameItem> {
|
||||
this.createInventoryTab(ItemType.ITEM_FURNITURE, new MaterialInventoryTab(INVENTORY_LIMITS.furniture));
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public AvatarStorage getAvatarStorage() {
|
||||
return this.getPlayer().getAvatars();
|
||||
}
|
||||
|
@ -1,30 +1,26 @@
|
||||
package emu.grasscutter.game.mail;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.database.DatabaseHelper;
|
||||
import emu.grasscutter.game.player.BasePlayerManager;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.server.event.player.PlayerReceiveMailEvent;
|
||||
import emu.grasscutter.server.packet.send.PacketDelMailRsp;
|
||||
import emu.grasscutter.server.packet.send.PacketMailChangeNotify;
|
||||
|
||||
public class MailHandler {
|
||||
private final Player player;
|
||||
public class MailHandler extends BasePlayerManager {
|
||||
private final List<Mail> mail;
|
||||
|
||||
public MailHandler(Player player) {
|
||||
this.player = player;
|
||||
super(player);
|
||||
|
||||
this.mail = new ArrayList<>();
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public List<Mail> getMail() {
|
||||
return mail;
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.common.ItemParamData;
|
||||
import emu.grasscutter.data.excels.ItemData;
|
||||
import emu.grasscutter.game.inventory.GameItem;
|
||||
import emu.grasscutter.game.player.BasePlayerManager;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.game.props.ActionReason;
|
||||
import emu.grasscutter.net.proto.CookRecipeDataOuterClass;
|
||||
@ -22,14 +23,12 @@ import emu.grasscutter.server.packet.send.PacketPlayerCookArgsRsp;
|
||||
import emu.grasscutter.server.packet.send.PacketPlayerCookRsp;
|
||||
import io.netty.util.internal.ThreadLocalRandom;
|
||||
|
||||
public class CookingManager {
|
||||
public class CookingManager extends BasePlayerManager {
|
||||
private static final int MANUAL_PERFECT_COOK_QUALITY = 3;
|
||||
|
||||
private static Set<Integer> defaultUnlockedRecipies;
|
||||
private final Player player;
|
||||
|
||||
public CookingManager(Player player) {
|
||||
this.player = player;
|
||||
super(player);
|
||||
}
|
||||
|
||||
public static void initialize() {
|
||||
|
@ -4,6 +4,7 @@ import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.common.ItemParamData;
|
||||
import emu.grasscutter.game.home.FurnitureMakeSlotItem;
|
||||
import emu.grasscutter.game.inventory.GameItem;
|
||||
import emu.grasscutter.game.player.BasePlayerManager;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.net.proto.ItemParamOuterClass;
|
||||
import emu.grasscutter.net.proto.RetcodeOuterClass.Retcode;
|
||||
@ -13,11 +14,10 @@ import emu.grasscutter.utils.Utils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FurnitureManager {
|
||||
private final Player player;
|
||||
|
||||
public class FurnitureManager extends BasePlayerManager {
|
||||
|
||||
public FurnitureManager(Player player) {
|
||||
this.player = player;
|
||||
super(player);
|
||||
}
|
||||
|
||||
public void onLogin(){
|
||||
|
@ -8,11 +8,17 @@ import emu.grasscutter.game.entity.EntityMonster;
|
||||
import emu.grasscutter.game.entity.EntityVehicle;
|
||||
import emu.grasscutter.game.entity.GameEntity;
|
||||
import emu.grasscutter.game.inventory.GameItem;
|
||||
import emu.grasscutter.game.player.BasePlayerManager;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.game.props.ActionReason;
|
||||
import emu.grasscutter.net.proto.VisionTypeOuterClass;
|
||||
|
||||
public record InsectCaptureManager(Player player) {
|
||||
public class InsectCaptureManager extends BasePlayerManager {
|
||||
|
||||
public InsectCaptureManager(Player player) {
|
||||
super(player);
|
||||
}
|
||||
|
||||
public void arrestSmallCreature(GameEntity entity) {
|
||||
//System.out.println("arrestSmallCreature!");
|
||||
EnvAnimalGatherConfigData gather;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package emu.grasscutter.game.managers;
|
||||
|
||||
import emu.grasscutter.game.player.BasePlayerManager;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.game.props.PlayerProperty;
|
||||
import emu.grasscutter.game.props.WatcherTriggerType;
|
||||
@ -9,11 +10,10 @@ import emu.grasscutter.utils.Utils;
|
||||
|
||||
import static emu.grasscutter.Configuration.GAME_OPTIONS;
|
||||
|
||||
public class ResinManager {
|
||||
private final Player player;
|
||||
public class ResinManager extends BasePlayerManager {
|
||||
|
||||
public ResinManager(Player player) {
|
||||
this.player = player;
|
||||
super(player);
|
||||
}
|
||||
|
||||
/********************
|
||||
|
@ -3,6 +3,7 @@ package emu.grasscutter.game.managers;
|
||||
import ch.qos.logback.classic.Logger;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.game.entity.EntityAvatar;
|
||||
import emu.grasscutter.game.player.BasePlayerManager;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.game.props.FightProperty;
|
||||
import emu.grasscutter.game.props.PlayerProperty;
|
||||
@ -16,11 +17,10 @@ import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
// Statue of the Seven Manager
|
||||
public class SotSManager {
|
||||
public class SotSManager extends BasePlayerManager {
|
||||
|
||||
// NOTE: Spring volume balance *1 = fight prop HP *100
|
||||
|
||||
private final Player player;
|
||||
private final Logger logger = Grasscutter.getLogger();
|
||||
private Timer autoRecoverTimer;
|
||||
private final boolean enablePriorityHealing = false;
|
||||
@ -28,7 +28,7 @@ public class SotSManager {
|
||||
public final static int GlobalMaximumSpringVolume = PlayerProperty.PROP_MAX_SPRING_VOLUME.getMax();
|
||||
|
||||
public SotSManager(Player player) {
|
||||
this.player = player;
|
||||
super(player);
|
||||
}
|
||||
|
||||
public boolean getIsAutoRecoveryEnabled() {
|
||||
|
@ -1,74 +0,0 @@
|
||||
package emu.grasscutter.game.managers.collection;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import emu.grasscutter.game.entity.EntityGadget;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
|
||||
public class CollectionManager {
|
||||
private static final long SECOND = 1000; //1 Second
|
||||
private static final long MINUTE = SECOND*60; //1 Minute
|
||||
private static final long HOUR = MINUTE*60; //1 Hour
|
||||
private static final long DAY = HOUR*24; //1 Day
|
||||
private static final HashMap<Integer,Long> DEFINE_REFRESH_TIME = new HashMap<>();// <GadgetId,Waiting Millisecond>
|
||||
private static final long DEFAULT_REFRESH_TIME = HOUR*6; // default 6 Hours
|
||||
|
||||
static {
|
||||
DEFINE_REFRESH_TIME.put(70590027,3*DAY);//星银矿石 3 Days
|
||||
DEFINE_REFRESH_TIME.put(70590036,3*DAY);//紫晶块 3 Days
|
||||
DEFINE_REFRESH_TIME.put(70520003,3*DAY);//水晶 3 Days
|
||||
|
||||
DEFINE_REFRESH_TIME.put(70590013,2*DAY);//嘟嘟莲 2 Days
|
||||
DEFINE_REFRESH_TIME.put(70540029,2*DAY);//清心 2 Days
|
||||
DEFINE_REFRESH_TIME.put(70540028,2*DAY);//星螺 2 Days
|
||||
DEFINE_REFRESH_TIME.put(70540027,2*DAY);//马尾 2 Days
|
||||
DEFINE_REFRESH_TIME.put(70540026,2*DAY);//琉璃袋 2 Days
|
||||
DEFINE_REFRESH_TIME.put(70540022,2*DAY);//落落莓 2 Days
|
||||
DEFINE_REFRESH_TIME.put(70540020,2*DAY);//慕风蘑菇 2 Days
|
||||
DEFINE_REFRESH_TIME.put(70540019,2*DAY);//风车菊 2 Days
|
||||
DEFINE_REFRESH_TIME.put(70540018,2*DAY);//塞西莉亚花 2 Days
|
||||
DEFINE_REFRESH_TIME.put(70540015,2*DAY);//霓裳花 2 Days
|
||||
DEFINE_REFRESH_TIME.put(70540014,2*DAY);//莲蓬 2 Days
|
||||
DEFINE_REFRESH_TIME.put(70540013,2*DAY);//钩钩果 2 Days
|
||||
DEFINE_REFRESH_TIME.put(70540012,2*DAY);//琉璃百合 2 Days
|
||||
DEFINE_REFRESH_TIME.put(70540008,2*DAY);//绝云椒椒 2 Days
|
||||
DEFINE_REFRESH_TIME.put(70520018,2*DAY);//夜泊石 2 Days
|
||||
DEFINE_REFRESH_TIME.put(70520002,2*DAY);//白铁矿 2 Days
|
||||
DEFINE_REFRESH_TIME.put(70510012,2*DAY);//石珀 2 Days
|
||||
DEFINE_REFRESH_TIME.put(70510009,2*DAY);//蒲公英 2 Days
|
||||
DEFINE_REFRESH_TIME.put(70510007,2*DAY);//冰雾花 2 Days
|
||||
DEFINE_REFRESH_TIME.put(70510006,2*DAY);//烈焰花 2 Days
|
||||
DEFINE_REFRESH_TIME.put(70510005,2*DAY);//电气水晶 2 Days
|
||||
DEFINE_REFRESH_TIME.put(70510004,2*DAY);//小灯草 2 Days
|
||||
|
||||
|
||||
DEFINE_REFRESH_TIME.put(70540021,DAY);//日落果 1 Day
|
||||
DEFINE_REFRESH_TIME.put(70540005,DAY);//松果 1 Day
|
||||
DEFINE_REFRESH_TIME.put(70540003,DAY);//苹果 1 Day
|
||||
DEFINE_REFRESH_TIME.put(70540001,DAY);//树莓 1 Day
|
||||
DEFINE_REFRESH_TIME.put(70520019,DAY);//魔晶块 1 Days
|
||||
DEFINE_REFRESH_TIME.put(70520008,DAY);//金鱼草 1 Days
|
||||
DEFINE_REFRESH_TIME.put(70520007,DAY);//白萝卜 1 Days
|
||||
DEFINE_REFRESH_TIME.put(70520006,DAY);//胡萝卜 1 Days
|
||||
DEFINE_REFRESH_TIME.put(70520004,DAY);//蘑菇 1 Day
|
||||
DEFINE_REFRESH_TIME.put(70520001,DAY);//铁矿 1 Day
|
||||
|
||||
DEFINE_REFRESH_TIME.put(70520009,12*HOUR);//薄荷 12 Hours
|
||||
DEFINE_REFRESH_TIME.put(70520005,12*HOUR);//甜甜花 12 Hours
|
||||
}
|
||||
|
||||
private final static HashMap<Integer, List<CollectionData>> CollectionResourcesData = new HashMap<>();
|
||||
private final HashMap<CollectionData,EntityGadget> spawnedEntities = new HashMap<>();
|
||||
private CollectionRecordStore collectionRecordStore;
|
||||
Player player;
|
||||
|
||||
private static long getGadgetRefreshTime(int gadgetId){
|
||||
return DEFINE_REFRESH_TIME.getOrDefault(gadgetId,DEFAULT_REFRESH_TIME);
|
||||
}
|
||||
|
||||
public synchronized void setPlayer(Player player) {
|
||||
this.player = player;
|
||||
this.collectionRecordStore = player.getCollectionRecordStore();
|
||||
}
|
||||
}
|
@ -7,20 +7,21 @@ import dev.morphia.annotations.Transient;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.game.entity.EntityItem;
|
||||
import emu.grasscutter.game.player.BasePlayerManager;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.game.world.Scene;
|
||||
import emu.grasscutter.net.proto.HitTreeNotifyOuterClass;
|
||||
import emu.grasscutter.net.proto.VectorOuterClass;
|
||||
import emu.grasscutter.utils.Position;
|
||||
|
||||
public class DeforestationManager {
|
||||
public class DeforestationManager extends BasePlayerManager {
|
||||
final static int RECORD_EXPIRED_SECONDS = 60*5; // 5 min
|
||||
final static int RECORD_MAX_TIMES = 3; // max number of wood
|
||||
final static int RECORD_MAX_TIMES_OTHER_HIT_TREE = 10; // if hit 10 times other trees, reset wood
|
||||
|
||||
@Transient private final Player player;
|
||||
@Transient private final ArrayList<HitTreeRecord> currentRecord;
|
||||
@Transient private final static HashMap<Integer, Integer> ColliderTypeToWoodItemID = new HashMap<>();
|
||||
private final ArrayList<HitTreeRecord> currentRecord;
|
||||
private final static HashMap<Integer, Integer> ColliderTypeToWoodItemID = new HashMap<>();
|
||||
|
||||
static {
|
||||
/* define wood types which reflected to item id*/
|
||||
ColliderTypeToWoodItemID.put(1,101301);
|
||||
@ -36,8 +37,9 @@ public class DeforestationManager {
|
||||
ColliderTypeToWoodItemID.put(11,101311);
|
||||
ColliderTypeToWoodItemID.put(12,101312);
|
||||
}
|
||||
|
||||
public DeforestationManager(Player player){
|
||||
this.player = player;
|
||||
super(player);
|
||||
this.currentRecord = new ArrayList<>();
|
||||
}
|
||||
public void resetWood(){
|
||||
|
@ -13,6 +13,7 @@ import emu.grasscutter.game.entity.EntityItem;
|
||||
import emu.grasscutter.game.entity.EntityMonster;
|
||||
import emu.grasscutter.game.entity.GameEntity;
|
||||
import emu.grasscutter.game.inventory.GameItem;
|
||||
import emu.grasscutter.game.player.BasePlayerManager;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.game.props.ElementType;
|
||||
import emu.grasscutter.game.props.FightProperty;
|
||||
@ -46,8 +47,7 @@ import static java.util.Map.entry;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
|
||||
public class EnergyManager {
|
||||
private final Player player;
|
||||
public class EnergyManager extends BasePlayerManager {
|
||||
private final Map<EntityAvatar, Integer> avatarNormalProbabilities;
|
||||
// energyUsage for each player
|
||||
private Boolean energyUsage;
|
||||
@ -55,15 +55,11 @@ public class EnergyManager {
|
||||
private final static Int2ObjectMap<List<SkillParticleGenerationInfo>> skillParticleGenerationData = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
public EnergyManager(Player player) {
|
||||
this.player = player;
|
||||
super(player);
|
||||
this.avatarNormalProbabilities = new HashMap<>();
|
||||
this.energyUsage=GAME_OPTIONS.energyUsage;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public static void initialize() {
|
||||
// Read the data we need for monster energy drops.
|
||||
try (Reader fileReader = new InputStreamReader(DataLoader.load("EnergyDrop.json"))) {
|
||||
|
@ -11,6 +11,7 @@ import emu.grasscutter.data.common.ItemParamData;
|
||||
import emu.grasscutter.data.excels.ForgeData;
|
||||
import emu.grasscutter.data.excels.ItemData;
|
||||
import emu.grasscutter.game.inventory.GameItem;
|
||||
import emu.grasscutter.game.player.BasePlayerManager;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.game.props.ActionReason;
|
||||
import emu.grasscutter.game.props.WatcherTriggerType;
|
||||
@ -27,11 +28,10 @@ import emu.grasscutter.server.packet.send.PacketForgeQueueManipulateRsp;
|
||||
import emu.grasscutter.server.packet.send.PacketForgeStartRsp;
|
||||
import emu.grasscutter.utils.Utils;
|
||||
|
||||
public class ForgingManager {
|
||||
private final Player player;
|
||||
public class ForgingManager extends BasePlayerManager {
|
||||
|
||||
public ForgingManager(Player player) {
|
||||
this.player = player;
|
||||
super(player);
|
||||
}
|
||||
|
||||
/**********
|
||||
|
@ -1,5 +1,6 @@
|
||||
package emu.grasscutter.game.managers.mapmark;
|
||||
|
||||
import emu.grasscutter.game.player.BasePlayerManager;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.net.proto.MapMarkPointTypeOuterClass.MapMarkPointType;
|
||||
import emu.grasscutter.net.proto.MarkMapReqOuterClass.MarkMapReq;
|
||||
@ -9,16 +10,17 @@ import emu.grasscutter.server.packet.send.PacketSceneEntityAppearNotify;
|
||||
import emu.grasscutter.utils.Position;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class MapMarksManager {
|
||||
public class MapMarksManager extends BasePlayerManager {
|
||||
public static final int mapMarkMaxCount = 150;
|
||||
private HashMap<String, MapMark> mapMarks;
|
||||
private final Player player;
|
||||
|
||||
public MapMarksManager(Player player) {
|
||||
this.player = player;
|
||||
this.mapMarks = player.getMapMarks();
|
||||
if (this.mapMarks == null) { this.mapMarks = new HashMap<>(); }
|
||||
super(player);
|
||||
}
|
||||
|
||||
public Map<String, MapMark> getMapMarks() {
|
||||
return getPlayer().getMapMarks();
|
||||
}
|
||||
|
||||
public void handleMapMarkReq(MarkMapReq req) {
|
||||
@ -45,31 +47,26 @@ public class MapMarksManager {
|
||||
}
|
||||
}
|
||||
if (op != Operation.OPERATION_GET) {
|
||||
saveMapMarks();
|
||||
save();
|
||||
}
|
||||
player.getSession().send(new PacketMarkMapRsp(getMapMarks()));
|
||||
}
|
||||
|
||||
public HashMap<String, MapMark> getMapMarks() {
|
||||
return mapMarks;
|
||||
}
|
||||
|
||||
|
||||
public String getMapMarkKey(Position position) {
|
||||
return "x" + (int)position.getX()+ "z" + (int)position.getZ();
|
||||
}
|
||||
|
||||
public void removeMapMark(Position position) {
|
||||
mapMarks.remove(getMapMarkKey(position));
|
||||
getMapMarks().remove(getMapMarkKey(position));
|
||||
}
|
||||
|
||||
public void addMapMark(MapMark mapMark) {
|
||||
if (mapMarks.size() < mapMarkMaxCount) {
|
||||
mapMarks.put(getMapMarkKey(mapMark.getPosition()), mapMark);
|
||||
if (getMapMarks().size() < mapMarkMaxCount) {
|
||||
getMapMarks().put(getMapMarkKey(mapMark.getPosition()), mapMark);
|
||||
}
|
||||
}
|
||||
|
||||
private void saveMapMarks() {
|
||||
player.setMapMarks(mapMarks);
|
||||
private void save() {
|
||||
player.save();
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.game.avatar.Avatar;
|
||||
import emu.grasscutter.game.entity.EntityAvatar;
|
||||
import emu.grasscutter.game.entity.GameEntity;
|
||||
import emu.grasscutter.game.player.BasePlayerManager;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.game.props.FightProperty;
|
||||
import emu.grasscutter.game.props.LifeState;
|
||||
@ -25,10 +26,9 @@ import java.util.*;
|
||||
|
||||
import static emu.grasscutter.Configuration.GAME_OPTIONS;
|
||||
|
||||
public class StaminaManager {
|
||||
public class StaminaManager extends BasePlayerManager {
|
||||
|
||||
// TODO: Skiff state detection?
|
||||
private final Player player;
|
||||
private static final HashMap<String, HashSet<MotionState>> MotionStatesCategorized = new HashMap<>() {{
|
||||
put("CLIMB", new HashSet<>(List.of(
|
||||
MotionState.MOTION_STATE_CLIMB, // sustained, when not moving no cost no recover
|
||||
@ -163,7 +163,7 @@ public class StaminaManager {
|
||||
}
|
||||
|
||||
public StaminaManager(Player player) {
|
||||
this.player = player;
|
||||
super(player);
|
||||
}
|
||||
|
||||
// Accessors
|
||||
|
@ -0,0 +1,23 @@
|
||||
package emu.grasscutter.game.player;
|
||||
|
||||
import lombok.NonNull;
|
||||
|
||||
public abstract class BasePlayerDataManager {
|
||||
protected transient Player player;
|
||||
|
||||
public BasePlayerDataManager() {}
|
||||
|
||||
public BasePlayerDataManager(@NonNull Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public void setPlayer(Player player) {
|
||||
if (this.player == null) {
|
||||
this.player = player;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package emu.grasscutter.game.player;
|
||||
|
||||
import lombok.NonNull;
|
||||
|
||||
public abstract class BasePlayerManager {
|
||||
protected transient final Player player;
|
||||
|
||||
public BasePlayerManager(@NonNull Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
}
|
@ -4,7 +4,6 @@ import dev.morphia.annotations.*;
|
||||
import emu.grasscutter.GameConstants;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.excels.PersonalLineData;
|
||||
import emu.grasscutter.data.excels.PlayerLevelData;
|
||||
import emu.grasscutter.data.excels.WeatherData;
|
||||
import emu.grasscutter.database.DatabaseHelper;
|
||||
@ -13,7 +12,6 @@ import emu.grasscutter.game.CoopRequest;
|
||||
import emu.grasscutter.game.ability.AbilityManager;
|
||||
import emu.grasscutter.game.activity.ActivityManager;
|
||||
import emu.grasscutter.game.avatar.Avatar;
|
||||
import emu.grasscutter.game.avatar.AvatarProfileData;
|
||||
import emu.grasscutter.game.avatar.AvatarStorage;
|
||||
import emu.grasscutter.game.battlepass.BattlePassManager;
|
||||
import emu.grasscutter.game.entity.EntityMonster;
|
||||
@ -34,7 +32,6 @@ import emu.grasscutter.game.managers.CookingManager;
|
||||
import emu.grasscutter.game.managers.FurnitureManager;
|
||||
import emu.grasscutter.game.managers.InsectCaptureManager;
|
||||
import emu.grasscutter.game.managers.ResinManager;
|
||||
import emu.grasscutter.game.managers.collection.CollectionManager;
|
||||
import emu.grasscutter.game.managers.collection.CollectionRecordStore;
|
||||
import emu.grasscutter.game.managers.deforestation.DeforestationManager;
|
||||
import emu.grasscutter.game.managers.energy.EnergyManager;
|
||||
@ -91,11 +88,11 @@ import static emu.grasscutter.Configuration.*;
|
||||
|
||||
@Entity(value = "players", useDiscriminator = false)
|
||||
public class Player {
|
||||
|
||||
@Id private int id;
|
||||
@Indexed(options = @IndexOptions(unique = true)) private String accountId;
|
||||
|
||||
@Transient private Account account;
|
||||
private transient Account account;
|
||||
private transient GameSession session;
|
||||
|
||||
private String nickname;
|
||||
private String signature;
|
||||
private int headImage;
|
||||
@ -104,22 +101,29 @@ public class Player {
|
||||
private Position rotation;
|
||||
private PlayerBirthday birthday;
|
||||
private PlayerCodex codex;
|
||||
@Getter private PlayerOpenStateManager openStateManager;
|
||||
private boolean showAvatars;
|
||||
private List<Integer> showAvatarList;
|
||||
private Map<Integer, Integer> properties;
|
||||
private Set<Integer> nameCardList;
|
||||
private Set<Integer> flyCloakList;
|
||||
private Set<Integer> costumeList;
|
||||
private Set<Integer> unlockedForgingBlueprints;
|
||||
private Set<Integer> unlockedCombines;
|
||||
private Set<Integer> unlockedFurniture;
|
||||
private Set<Integer> unlockedFurnitureSuite;
|
||||
private List<ActiveForgeData> activeForges;
|
||||
private Map<Integer, Integer> unlockedRecipies;
|
||||
|
||||
private Integer widgetId;
|
||||
|
||||
private Set<Integer> realmList;
|
||||
private Integer currentRealmId;
|
||||
private int currentRealmId;
|
||||
private int widgetId;
|
||||
private int sceneId;
|
||||
private int regionId;
|
||||
private int mainCharacterId;
|
||||
private boolean godmode;
|
||||
private boolean stamina;
|
||||
|
||||
@Getter private Set<Integer> nameCardList;
|
||||
@Getter private Set<Integer> flyCloakList;
|
||||
@Getter private Set<Integer> costumeList;
|
||||
@Getter private Set<Integer> rewardedLevels;
|
||||
@Getter private Set<Integer> realmList;
|
||||
@Getter private Set<Integer> unlockedForgingBlueprints;
|
||||
@Getter private Set<Integer> unlockedCombines;
|
||||
@Getter private Set<Integer> unlockedFurniture;
|
||||
@Getter private Set<Integer> unlockedFurnitureSuite;
|
||||
@Getter private Map<Long, ExpeditionInfo> expeditionInfo;
|
||||
@Getter private Map<Integer, Integer> unlockedRecipies;
|
||||
@Getter private List<ActiveForgeData> activeForges;
|
||||
|
||||
@Transient private long nextGuid = 0;
|
||||
@Transient private int peerId;
|
||||
@ -127,71 +131,56 @@ public class Player {
|
||||
@Transient private Scene scene;
|
||||
@Transient @Getter private int weatherId = 0;
|
||||
@Transient @Getter private ClimateType climate = ClimateType.CLIMATE_SUNNY;
|
||||
@Transient private GameSession session;
|
||||
@Transient private AvatarStorage avatars;
|
||||
@Transient private Inventory inventory;
|
||||
@Transient private FriendsList friendsList;
|
||||
@Transient private MailHandler mailHandler;
|
||||
@Transient private MessageHandler messageHandler;
|
||||
@Transient private AbilityManager abilityManager;
|
||||
@Transient private QuestManager questManager;
|
||||
|
||||
// Player managers go here
|
||||
@Getter private transient AvatarStorage avatars;
|
||||
@Getter private transient Inventory inventory;
|
||||
@Getter private transient FriendsList friendsList;
|
||||
@Getter private transient MailHandler mailHandler;
|
||||
@Getter private transient MessageHandler messageHandler;
|
||||
@Getter private transient AbilityManager abilityManager;
|
||||
@Getter private transient QuestManager questManager;
|
||||
@Getter private transient TowerManager towerManager;
|
||||
@Getter private transient SotSManager sotsManager;
|
||||
@Getter private transient InsectCaptureManager insectCaptureManager;
|
||||
@Getter private transient MapMarksManager mapMarksManager;
|
||||
@Getter private transient StaminaManager staminaManager;
|
||||
@Getter private transient EnergyManager energyManager;
|
||||
@Getter private transient ResinManager resinManager;
|
||||
@Getter private transient ForgingManager forgingManager;
|
||||
@Getter private transient DeforestationManager deforestationManager;
|
||||
@Getter private transient FurnitureManager furnitureManager;
|
||||
@Getter private transient BattlePassManager battlePassManager;
|
||||
@Getter private transient CookingManager cookingManager;
|
||||
@Getter private transient ActivityManager activityManager;
|
||||
|
||||
@Transient private SotSManager sotsManager;
|
||||
@Transient private InsectCaptureManager insectCaptureManager;
|
||||
|
||||
private TeamManager teamManager;
|
||||
|
||||
@Transient private TowerManager towerManager;
|
||||
// Manager data (Save-able to the database)
|
||||
private PlayerProfile playerProfile;
|
||||
private TeamManager teamManager;
|
||||
private TowerData towerData;
|
||||
private PlayerGachaInfo gachaInfo;
|
||||
private PlayerProfile playerProfile;
|
||||
private boolean showAvatar;
|
||||
private ArrayList<AvatarProfileData> shownAvatars;
|
||||
private Set<Integer> rewardedLevels;
|
||||
private PlayerOpenStateManager openStateManager;
|
||||
private CollectionRecordStore collectionRecordStore;
|
||||
private ArrayList<ShopLimit> shopLimit;
|
||||
private Map<Long, ExpeditionInfo> expeditionInfo;
|
||||
|
||||
private int sceneId;
|
||||
private int regionId;
|
||||
private int mainCharacterId;
|
||||
private boolean godmode;
|
||||
private boolean stamina;
|
||||
|
||||
@Getter private transient GameHome home;
|
||||
|
||||
private boolean moonCard;
|
||||
private Date moonCardStartTime;
|
||||
private int moonCardDuration;
|
||||
private Set<Date> moonCardGetTimes;
|
||||
|
||||
private List<Integer> showAvatarList;
|
||||
private boolean showAvatars;
|
||||
|
||||
@Transient private boolean paused;
|
||||
@Transient private int enterSceneToken;
|
||||
@Transient private SceneLoadState sceneState;
|
||||
@Transient private boolean hasSentAvatarDataNotify;
|
||||
@Transient private long nextSendPlayerLocTime = 0;
|
||||
|
||||
@Transient private final Int2ObjectMap<CoopRequest> coopRequests;
|
||||
@Transient private final Queue<AttackResult> attackResults;
|
||||
@Transient private final InvokeHandler<CombatInvokeEntry> combatInvokeHandler;
|
||||
@Transient private final InvokeHandler<AbilityInvokeEntry> abilityInvokeHandler;
|
||||
@Transient private final InvokeHandler<AbilityInvokeEntry> clientAbilityInitFinishHandler;
|
||||
|
||||
@Transient private MapMarksManager mapMarksManager;
|
||||
@Transient private StaminaManager staminaManager;
|
||||
@Transient private EnergyManager energyManager;
|
||||
@Transient private ResinManager resinManager;
|
||||
@Transient private ForgingManager forgingManager;
|
||||
@Transient private DeforestationManager deforestationManager;
|
||||
@Transient private GameHome home;
|
||||
@Transient private FurnitureManager furnitureManager;
|
||||
@Transient private BattlePassManager battlePassManager;
|
||||
@Transient private CookingManager cookingManager;
|
||||
// @Transient private
|
||||
@Getter @Transient private ActivityManager activityManager;
|
||||
|
||||
@Transient private CollectionManager collectionManager;
|
||||
private CollectionRecordStore collectionRecordStore;
|
||||
private transient final Int2ObjectMap<CoopRequest> coopRequests;
|
||||
private transient final Queue<AttackResult> attackResults;
|
||||
@Getter private transient final InvokeHandler<CombatInvokeEntry> combatInvokeHandler;
|
||||
@Getter private transient final InvokeHandler<AbilityInvokeEntry> abilityInvokeHandler;
|
||||
@Getter private transient final InvokeHandler<AbilityInvokeEntry> clientAbilityInitFinishHandler;
|
||||
|
||||
private long springLastUsed;
|
||||
private HashMap<String, MapMark> mapMarks;
|
||||
@ -209,8 +198,8 @@ public class Player {
|
||||
this.abilityManager = new AbilityManager(this);
|
||||
this.deforestationManager = new DeforestationManager(this);
|
||||
this.insectCaptureManager = new InsectCaptureManager(this);
|
||||
|
||||
this.setQuestManager(new QuestManager(this));
|
||||
this.questManager = new QuestManager(this);
|
||||
|
||||
this.pos = new Position();
|
||||
this.rotation = new Position();
|
||||
this.properties = new HashMap<>();
|
||||
@ -374,10 +363,6 @@ public class Player {
|
||||
this.session.send(new PacketSceneAreaWeatherNotify(this));
|
||||
}
|
||||
|
||||
public int getGmLevel() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public String getNickname() {
|
||||
return nickname;
|
||||
}
|
||||
@ -413,10 +398,6 @@ public class Player {
|
||||
this.widgetId = widgetId;
|
||||
}
|
||||
|
||||
public Set<Integer> getRealmList() {
|
||||
return realmList;
|
||||
}
|
||||
|
||||
public void setRealmList(Set<Integer> realmList) {
|
||||
this.realmList = realmList;
|
||||
}
|
||||
@ -430,16 +411,14 @@ public class Player {
|
||||
this.realmList.add(realmId);
|
||||
}
|
||||
|
||||
public Integer getCurrentRealmId() {
|
||||
public int getCurrentRealmId() {
|
||||
return currentRealmId;
|
||||
}
|
||||
|
||||
public void setCurrentRealmId(Integer currentRealmId) {
|
||||
public void setCurrentRealmId(int currentRealmId) {
|
||||
this.currentRealmId = currentRealmId;
|
||||
}
|
||||
public GameHome getHome(){
|
||||
return home;
|
||||
}
|
||||
|
||||
public Position getPos() {
|
||||
return pos;
|
||||
}
|
||||
@ -598,10 +577,6 @@ public class Player {
|
||||
return this.teamManager;
|
||||
}
|
||||
|
||||
public TowerManager getTowerManager() {
|
||||
return towerManager;
|
||||
}
|
||||
|
||||
public TowerData getTowerData() {
|
||||
if (towerData == null) {
|
||||
// because of mistake, null may be saved as storage at some machine, this if can be removed in future
|
||||
@ -610,14 +585,6 @@ public class Player {
|
||||
return towerData;
|
||||
}
|
||||
|
||||
public QuestManager getQuestManager() {
|
||||
return questManager;
|
||||
}
|
||||
|
||||
public void setQuestManager(QuestManager questManager) {
|
||||
this.questManager = questManager;
|
||||
}
|
||||
|
||||
public PlayerGachaInfo getGachaInfo() {
|
||||
return gachaInfo;
|
||||
}
|
||||
@ -647,42 +614,6 @@ public class Player {
|
||||
return getProperties().get(prop.getId());
|
||||
}
|
||||
|
||||
public Set<Integer> getFlyCloakList() {
|
||||
return flyCloakList;
|
||||
}
|
||||
|
||||
public Set<Integer> getCostumeList() {
|
||||
return costumeList;
|
||||
}
|
||||
|
||||
public Set<Integer> getNameCardList() {
|
||||
return this.nameCardList;
|
||||
}
|
||||
|
||||
public Set<Integer> getUnlockedForgingBlueprints() {
|
||||
return this.unlockedForgingBlueprints;
|
||||
}
|
||||
|
||||
public Set<Integer> getUnlockedCombines() {
|
||||
return this.unlockedCombines;
|
||||
}
|
||||
|
||||
public Set<Integer> getUnlockedFurniture() {
|
||||
return unlockedFurniture;
|
||||
}
|
||||
|
||||
public Set<Integer> getUnlockedFurnitureSuite() {
|
||||
return unlockedFurnitureSuite;
|
||||
}
|
||||
|
||||
public List<ActiveForgeData> getActiveForges() {
|
||||
return this.activeForges;
|
||||
}
|
||||
|
||||
public Map<Integer, Integer> getUnlockedRecipies() {
|
||||
return this.unlockedRecipies;
|
||||
}
|
||||
|
||||
public MpSettingType getMpSetting() {
|
||||
return MpSettingType.MP_SETTING_TYPE_ENTER_AFTER_APPLY; // TEMP
|
||||
}
|
||||
@ -695,34 +626,6 @@ public class Player {
|
||||
return coopRequests;
|
||||
}
|
||||
|
||||
public InvokeHandler<CombatInvokeEntry> getCombatInvokeHandler() {
|
||||
return this.combatInvokeHandler;
|
||||
}
|
||||
|
||||
public InvokeHandler<AbilityInvokeEntry> getAbilityInvokeHandler() {
|
||||
return this.abilityInvokeHandler;
|
||||
}
|
||||
|
||||
public InvokeHandler<AbilityInvokeEntry> getClientAbilityInitFinishHandler() {
|
||||
return clientAbilityInitFinishHandler;
|
||||
}
|
||||
|
||||
public AvatarStorage getAvatars() {
|
||||
return avatars;
|
||||
}
|
||||
|
||||
public Inventory getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
public FriendsList getFriendsList() {
|
||||
return this.friendsList;
|
||||
}
|
||||
|
||||
public MailHandler getMailHandler() {
|
||||
return mailHandler;
|
||||
}
|
||||
|
||||
public int getEnterSceneToken() {
|
||||
return enterSceneToken;
|
||||
}
|
||||
@ -931,10 +834,6 @@ public class Player {
|
||||
session.send(new PacketCardProductRewardNotify(getMoonCardRemainDays()));
|
||||
}
|
||||
|
||||
public Map<Long, ExpeditionInfo> getExpeditionInfo() {
|
||||
return expeditionInfo;
|
||||
}
|
||||
|
||||
public void addExpeditionInfo(long avaterGuid, int expId, int hourTime, int startTime){
|
||||
ExpeditionInfo exp = new ExpeditionInfo();
|
||||
exp.setExpId(expId);
|
||||
@ -1188,10 +1087,8 @@ public class Player {
|
||||
return this.birthday.getDay() > 0;
|
||||
}
|
||||
|
||||
public PlayerCodex getCodex(){ return this.codex; }
|
||||
|
||||
public Set<Integer> getRewardedLevels() {
|
||||
return rewardedLevels;
|
||||
public PlayerCodex getCodex() {
|
||||
return this.codex;
|
||||
}
|
||||
|
||||
public void setRewardedLevels(Set<Integer> rewardedLevels) {
|
||||
@ -1290,59 +1187,12 @@ public class Player {
|
||||
.build();
|
||||
}
|
||||
|
||||
public MapMarksManager getMapMarksManager() {
|
||||
return mapMarksManager;
|
||||
}
|
||||
|
||||
public StaminaManager getStaminaManager() { return staminaManager; }
|
||||
|
||||
public SotSManager getSotSManager() { return sotsManager; }
|
||||
|
||||
public EnergyManager getEnergyManager() {
|
||||
return this.energyManager;
|
||||
}
|
||||
|
||||
public ResinManager getResinManager() {
|
||||
return this.resinManager;
|
||||
}
|
||||
|
||||
public ForgingManager getForgingManager() {
|
||||
return this.forgingManager;
|
||||
}
|
||||
|
||||
public FurnitureManager getFurnitureManager() {
|
||||
return furnitureManager;
|
||||
}
|
||||
|
||||
public BattlePassManager getBattlePassManager(){
|
||||
return battlePassManager;
|
||||
}
|
||||
|
||||
public CookingManager getCookingManager() {
|
||||
return cookingManager;
|
||||
}
|
||||
|
||||
public void loadBattlePassManager() {
|
||||
if (this.battlePassManager != null) return;
|
||||
this.battlePassManager = DatabaseHelper.loadBattlePass(this);
|
||||
this.battlePassManager.getMissions().values().removeIf(mission -> mission.getData() == null);
|
||||
}
|
||||
|
||||
public AbilityManager getAbilityManager() {
|
||||
return abilityManager;
|
||||
}
|
||||
|
||||
public DeforestationManager getDeforestationManager() {
|
||||
return deforestationManager;
|
||||
}
|
||||
|
||||
public CollectionManager getCollectionManager() {
|
||||
if(this.collectionManager==null){
|
||||
this.collectionManager = new CollectionManager();
|
||||
}
|
||||
return this.collectionManager;
|
||||
}
|
||||
|
||||
public CollectionRecordStore getCollectionRecordStore() {
|
||||
if(this.collectionRecordStore==null){
|
||||
this.collectionRecordStore = new CollectionRecordStore();
|
||||
@ -1350,11 +1200,21 @@ public class Player {
|
||||
return collectionRecordStore;
|
||||
}
|
||||
|
||||
public HashMap<String, MapMark> getMapMarks() { return mapMarks; }
|
||||
public Map<String, MapMark> getMapMarks() {
|
||||
if (this.mapMarks == null) {
|
||||
this.mapMarks = new HashMap<String, MapMark>();
|
||||
}
|
||||
return mapMarks;
|
||||
}
|
||||
|
||||
public void setMapMarks(HashMap<String, MapMark> newMarks) { mapMarks = newMarks; }
|
||||
public PlayerOpenStateManager getOpenStateManager() {
|
||||
if (this.openStateManager == null) {
|
||||
this.openStateManager = new PlayerOpenStateManager(this);
|
||||
}
|
||||
return openStateManager;
|
||||
}
|
||||
|
||||
public synchronized void onTick() {
|
||||
public synchronized void onTick() {
|
||||
// Check ping
|
||||
if (this.getLastPingTime() > System.currentTimeMillis() + 60000) {
|
||||
this.getSession().close();
|
||||
@ -1453,7 +1313,6 @@ public class Player {
|
||||
this.getCodex().setPlayer(this);
|
||||
this.getOpenStateManager().setPlayer(this);
|
||||
this.getTeamManager().setPlayer(this);
|
||||
this.getTowerManager().setPlayer(this);
|
||||
}
|
||||
|
||||
public void save() {
|
||||
@ -1463,24 +1322,15 @@ public class Player {
|
||||
// Called from tokenrsp
|
||||
public void loadFromDatabase() {
|
||||
// Make sure these exist
|
||||
if (this.getTowerManager() == null) {
|
||||
this.towerManager = new TowerManager(this);
|
||||
}
|
||||
if (this.getTeamManager() == null) {
|
||||
this.teamManager = new TeamManager(this);
|
||||
}
|
||||
if (this.getCodex() == null) {
|
||||
this.codex = new PlayerCodex(this);
|
||||
}
|
||||
if (this.getOpenStateManager() == null) {
|
||||
this.openStateManager = new PlayerOpenStateManager(this);
|
||||
}
|
||||
if (this.getProfile().getUid() == 0) {
|
||||
this.getProfile().syncWithCharacter(this);
|
||||
}
|
||||
//Make sure towerManager's player is online player
|
||||
this.getTowerManager().setPlayer(this);
|
||||
this.getCollectionManager().setPlayer(this);
|
||||
|
||||
// Load from db
|
||||
this.getAvatars().loadFromDatabase();
|
||||
@ -1537,8 +1387,8 @@ public class Player {
|
||||
this.cookingManager.sendCookDataNofity();
|
||||
|
||||
// Unlock in case this is an existing user that reached a level before we implemented unlocking.
|
||||
this.openStateManager.unlockLevelDependentStates();
|
||||
this.openStateManager.onPlayerLogin();
|
||||
this.getOpenStateManager().unlockLevelDependentStates();
|
||||
this.getOpenStateManager().onPlayerLogin();
|
||||
|
||||
getTodayMoonCard(); // The timer works at 0:0, some users log in after that, use this method to check if they have received a reward today or not. If not, send the reward.
|
||||
|
||||
|
@ -16,9 +16,7 @@ import java.util.stream.Stream;
|
||||
import static emu.grasscutter.game.props.OpenState.*;
|
||||
|
||||
@Entity
|
||||
public class PlayerOpenStateManager {
|
||||
@Transient private Player player;
|
||||
|
||||
public class PlayerOpenStateManager extends BasePlayerDataManager {
|
||||
// Map of all open states that this player has. Do not put default values here.
|
||||
private Map<Integer, Integer> map;
|
||||
|
||||
@ -37,11 +35,7 @@ public class PlayerOpenStateManager {
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
public PlayerOpenStateManager(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public void setPlayer(Player player) {
|
||||
this.player = player;
|
||||
super(player);
|
||||
}
|
||||
|
||||
public Map<Integer, Integer> getOpenStateMap() {
|
||||
|
@ -41,7 +41,7 @@ import it.unimi.dsi.fastutil.ints.IntSet;
|
||||
import static emu.grasscutter.Configuration.*;
|
||||
|
||||
@Entity
|
||||
public class TeamManager {
|
||||
public class TeamManager extends BasePlayerDataManager {
|
||||
@Transient private Player player;
|
||||
|
||||
private Map<Integer, TeamInfo> teams;
|
||||
@ -56,10 +56,7 @@ public class TeamManager {
|
||||
@Transient private final IntSet teamResonancesConfig;
|
||||
|
||||
@Transient private int useTemporarilyTeamIndex = -1;
|
||||
/**
|
||||
* Temporary Team for tower
|
||||
*/
|
||||
@Transient private List<TeamInfo> temporaryTeam;
|
||||
@Transient private List<TeamInfo> temporaryTeam; // Temporary Team for tower
|
||||
|
||||
public TeamManager() {
|
||||
this.mpTeam = new TeamInfo();
|
||||
@ -71,7 +68,7 @@ public class TeamManager {
|
||||
|
||||
public TeamManager(Player player) {
|
||||
this();
|
||||
this.player = player;
|
||||
this.setPlayer(player);
|
||||
|
||||
this.teams = new HashMap<>();
|
||||
this.currentTeamIndex = 1;
|
||||
@ -80,17 +77,9 @@ public class TeamManager {
|
||||
}
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return player.getWorld();
|
||||
}
|
||||
|
||||
public void setPlayer(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public Map<Integer, TeamInfo> getTeams() {
|
||||
return this.teams;
|
||||
|
@ -10,6 +10,7 @@ import emu.grasscutter.data.binout.MainQuestData;
|
||||
import emu.grasscutter.data.excels.QuestData;
|
||||
import emu.grasscutter.data.excels.QuestData.QuestCondition;
|
||||
import emu.grasscutter.database.DatabaseHelper;
|
||||
import emu.grasscutter.game.player.BasePlayerManager;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.game.quest.enums.ParentQuestState;
|
||||
import emu.grasscutter.game.quest.enums.QuestTrigger;
|
||||
@ -19,19 +20,14 @@ import emu.grasscutter.server.packet.send.*;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
public class QuestManager {
|
||||
private final Player player;
|
||||
public class QuestManager extends BasePlayerManager {
|
||||
private final Int2ObjectMap<GameMainQuest> quests;
|
||||
|
||||
public QuestManager(Player player) {
|
||||
this.player = player;
|
||||
super(player);
|
||||
this.quests = new Int2ObjectOpenHashMap<>();
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public Int2ObjectMap<GameMainQuest> getQuests() {
|
||||
return quests;
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.excels.TowerLevelData;
|
||||
import emu.grasscutter.game.dungeons.DungeonSettleListener;
|
||||
import emu.grasscutter.game.dungeons.TowerDungeonSettleListener;
|
||||
import emu.grasscutter.game.player.BasePlayerManager;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.server.packet.send.*;
|
||||
|
||||
@ -11,55 +12,54 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class TowerManager {
|
||||
private Player player;
|
||||
private TowerData towerData;
|
||||
public class TowerManager extends BasePlayerManager {
|
||||
|
||||
public TowerManager(Player player) {
|
||||
setPlayer(player);
|
||||
super(player);
|
||||
}
|
||||
public void setPlayer(Player player) {
|
||||
this.player = player;
|
||||
this.towerData = player.getTowerData();
|
||||
|
||||
public TowerData getTowerData() {
|
||||
return getPlayer().getTowerData();
|
||||
}
|
||||
|
||||
public int getCurrentFloorId() {
|
||||
return towerData.currentFloorId;
|
||||
return getTowerData().currentFloorId;
|
||||
}
|
||||
|
||||
public int getCurrentLevelId(){
|
||||
return towerData.currentLevelId + towerData.currentLevel;
|
||||
return getTowerData().currentLevelId + getTowerData().currentLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* form 1-3
|
||||
*/
|
||||
public int getCurrentLevel(){
|
||||
return towerData.currentLevel + 1;
|
||||
return getTowerData().currentLevel + 1;
|
||||
}
|
||||
private static final List<DungeonSettleListener> towerDungeonSettleListener = List.of(new TowerDungeonSettleListener());
|
||||
|
||||
public Map<Integer, TowerLevelRecord> getRecordMap() {
|
||||
Map<Integer, TowerLevelRecord> recordMap = towerData.recordMap;
|
||||
Map<Integer, TowerLevelRecord> recordMap = getTowerData().recordMap;
|
||||
if(recordMap == null || recordMap.size()==0){
|
||||
recordMap = new HashMap<>();
|
||||
recordMap.put(1001, new TowerLevelRecord(1001));
|
||||
towerData.recordMap = recordMap;
|
||||
getTowerData().recordMap = recordMap;
|
||||
}
|
||||
return recordMap;
|
||||
}
|
||||
|
||||
public void teamSelect(int floor, List<List<Long>> towerTeams) {
|
||||
var floorData = GameData.getTowerFloorDataMap().get(floor);
|
||||
towerData.currentFloorId = floorData.getFloorId();
|
||||
towerData.currentLevel = 0;
|
||||
towerData.currentLevelId = GameData.getTowerLevelDataMap().values().stream()
|
||||
getTowerData().currentFloorId = floorData.getFloorId();
|
||||
getTowerData().currentLevel = 0;
|
||||
getTowerData().currentLevelId = GameData.getTowerLevelDataMap().values().stream()
|
||||
.filter(x -> x.getLevelGroupId() == floorData.getLevelGroupId() && x.getLevelIndex() == 1)
|
||||
.findFirst()
|
||||
.map(TowerLevelData::getId)
|
||||
.orElse(0);
|
||||
|
||||
if (towerData.entryScene == 0){
|
||||
towerData.entryScene = player.getSceneId();
|
||||
if (getTowerData().entryScene == 0){
|
||||
getTowerData().entryScene = player.getSceneId();
|
||||
}
|
||||
|
||||
player.getTeamManager().setupTemporaryTeam(towerTeams);
|
||||
@ -78,22 +78,22 @@ public class TowerManager {
|
||||
towerDungeonSettleListener);
|
||||
|
||||
// make sure user can exit dungeon correctly
|
||||
player.getScene().setPrevScene(towerData.entryScene);
|
||||
player.getScene().setPrevScene(getTowerData().entryScene);
|
||||
player.getScene().setPrevScenePoint(enterPointId);
|
||||
|
||||
player.getSession().send(new PacketTowerEnterLevelRsp(towerData.currentFloorId, getCurrentLevel()));
|
||||
player.getSession().send(new PacketTowerEnterLevelRsp(getTowerData().currentFloorId, getCurrentLevel()));
|
||||
// stop using skill
|
||||
player.getSession().send(new PacketCanUseSkillNotify(false));
|
||||
// notify the cond of stars
|
||||
player.getSession().send(new PacketTowerLevelStarCondNotify(towerData.currentFloorId, getCurrentLevel()));
|
||||
player.getSession().send(new PacketTowerLevelStarCondNotify(getTowerData().currentFloorId, getCurrentLevel()));
|
||||
}
|
||||
|
||||
public void notifyCurLevelRecordChange(){
|
||||
player.getSession().send(new PacketTowerCurLevelRecordChangeNotify(towerData.currentFloorId, getCurrentLevel()));
|
||||
player.getSession().send(new PacketTowerCurLevelRecordChangeNotify(getTowerData().currentFloorId, getCurrentLevel()));
|
||||
}
|
||||
public void notifyCurLevelRecordChangeWhenDone(int stars){
|
||||
Map<Integer, TowerLevelRecord> recordMap = getRecordMap();
|
||||
int currentFloorId = towerData.currentFloorId;
|
||||
int currentFloorId = getTowerData().currentFloorId;
|
||||
if(!recordMap.containsKey(currentFloorId)){
|
||||
recordMap.put(currentFloorId,
|
||||
new TowerLevelRecord(currentFloorId).setLevelStars(getCurrentLevelId(),stars));
|
||||
@ -102,7 +102,7 @@ public class TowerManager {
|
||||
recordMap.get(currentFloorId).setLevelStars(getCurrentLevelId(),stars));
|
||||
}
|
||||
|
||||
towerData.currentLevel++;
|
||||
getTowerData().currentLevel++;
|
||||
|
||||
if(!hasNextLevel()){
|
||||
// set up the next floor
|
||||
@ -113,17 +113,17 @@ public class TowerManager {
|
||||
}
|
||||
}
|
||||
public boolean hasNextLevel(){
|
||||
return towerData.currentLevel < 3;
|
||||
return getTowerData().currentLevel < 3;
|
||||
}
|
||||
public int getNextFloorId() {
|
||||
return player.getServer().getTowerScheduleManager().getNextFloorId(towerData.currentFloorId);
|
||||
return player.getServer().getTowerScheduleManager().getNextFloorId(getTowerData().currentFloorId);
|
||||
}
|
||||
public boolean hasNextFloor(){
|
||||
return player.getServer().getTowerScheduleManager().getNextFloorId(towerData.currentFloorId) > 0;
|
||||
return player.getServer().getTowerScheduleManager().getNextFloorId(getTowerData().currentFloorId) > 0;
|
||||
}
|
||||
|
||||
public void clearEntry() {
|
||||
towerData.entryScene = 0;
|
||||
getTowerData().entryScene = 0;
|
||||
}
|
||||
|
||||
public boolean canEnterScheduleFloor(){
|
||||
|
@ -11,6 +11,6 @@ import emu.grasscutter.server.game.GameSession;
|
||||
public class HandlerEnterTransPointRegionNotify extends PacketHandler {
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception{
|
||||
session.getPlayer().getSotSManager().handleEnterTransPointRegionNotify();
|
||||
session.getPlayer().getSotsManager().handleEnterTransPointRegionNotify();
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,6 @@ import emu.grasscutter.server.game.GameSession;
|
||||
public class HandlerExitTransPointRegionNotify extends PacketHandler {
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception{
|
||||
session.getPlayer().getSotSManager().handleExitTransPointRegionNotify();
|
||||
session.getPlayer().getSotsManager().handleExitTransPointRegionNotify();
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ public class PacketHomeBasicInfoNotify extends BasePacket {
|
||||
public PacketHomeBasicInfoNotify(Player player, boolean editMode) {
|
||||
super(PacketOpcodes.HomeBasicInfoNotify);
|
||||
|
||||
if(player.getCurrentRealmId() == null){
|
||||
if (player.getCurrentRealmId() <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ import java.util.*;
|
||||
|
||||
public class PacketMarkMapRsp extends BasePacket {
|
||||
|
||||
public PacketMarkMapRsp(HashMap<String, MapMark> mapMarks) {
|
||||
public PacketMarkMapRsp(Map<String, MapMark> mapMarks) {
|
||||
super(PacketOpcodes.MarkMapRsp);
|
||||
|
||||
MarkMapRspOuterClass.MarkMapRsp.Builder proto = MarkMapRspOuterClass.MarkMapRsp.newBuilder();
|
||||
|
Loading…
Reference in New Issue
Block a user