Commit d20e9d1f authored by Melledy's avatar Melledy
Browse files

Refactor player managers

parent 3957616b
......@@ -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
......
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();
}
......
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;
......
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() {
......
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);
}
/**********
......
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
......
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;
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment