Commit 1c36f078 authored by Melledy's avatar Melledy
Browse files

Renamed all references to a certain game

parent 6b8902be
......@@ -3,12 +3,12 @@ package emu.grasscutter.game.avatar;
import java.util.Iterator;
import java.util.List;
import emu.grasscutter.data.GenshinData;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.def.AvatarData;
import emu.grasscutter.database.DatabaseHelper;
import emu.grasscutter.game.GenshinPlayer;
import emu.grasscutter.game.Player;
import emu.grasscutter.game.entity.EntityAvatar;
import emu.grasscutter.game.inventory.GenshinItem;
import emu.grasscutter.game.inventory.GameItem;
import emu.grasscutter.server.packet.send.PacketAvatarChangeCostumeNotify;
import emu.grasscutter.server.packet.send.PacketAvatarFlycloakChangeNotify;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
......@@ -16,22 +16,22 @@ 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<GenshinAvatar> {
private final GenshinPlayer player;
private final Int2ObjectMap<GenshinAvatar> avatars;
private final Long2ObjectMap<GenshinAvatar> avatarsGuid;
public class AvatarStorage implements Iterable<Avatar> {
private final Player player;
private final Int2ObjectMap<Avatar> avatars;
private final Long2ObjectMap<Avatar> avatarsGuid;
public AvatarStorage(GenshinPlayer player) {
public AvatarStorage(Player player) {
this.player = player;
this.avatars = new Int2ObjectOpenHashMap<>();
this.avatarsGuid = new Long2ObjectOpenHashMap<>();
}
public GenshinPlayer getPlayer() {
public Player getPlayer() {
return player;
}
public Int2ObjectMap<GenshinAvatar> getAvatars() {
public Int2ObjectMap<Avatar> getAvatars() {
return avatars;
}
......@@ -39,11 +39,11 @@ public class AvatarStorage implements Iterable<GenshinAvatar> {
return this.avatars.size();
}
public GenshinAvatar getAvatarById(int id) {
public Avatar getAvatarById(int id) {
return getAvatars().get(id);
}
public GenshinAvatar getAvatarByGuid(long id) {
public Avatar getAvatarByGuid(long id) {
return avatarsGuid.get(id);
}
......@@ -51,7 +51,7 @@ public class AvatarStorage implements Iterable<GenshinAvatar> {
return getAvatars().containsKey(id);
}
public boolean addAvatar(GenshinAvatar avatar) {
public boolean addAvatar(Avatar avatar) {
if (avatar.getAvatarData() == null || this.hasAvatar(avatar.getAvatarId())) {
return false;
}
......@@ -68,14 +68,14 @@ public class AvatarStorage implements Iterable<GenshinAvatar> {
return true;
}
public void addStartingWeapon(GenshinAvatar avatar) {
public void addStartingWeapon(Avatar avatar) {
// Make sure avatar owner is this player
if (avatar.getPlayer() != this.getPlayer()) {
return;
}
// Create weapon
GenshinItem weapon = new GenshinItem(avatar.getAvatarData().getInitialWeapon());
GameItem weapon = new GameItem(avatar.getAvatarData().getInitialWeapon());
if (weapon.getItemData() != null) {
this.getPlayer().getInventory().addItem(weapon);
......@@ -85,7 +85,7 @@ public class AvatarStorage implements Iterable<GenshinAvatar> {
}
public boolean wearFlycloak(long avatarGuid, int flycloakId) {
GenshinAvatar avatar = this.getAvatarByGuid(avatarGuid);
Avatar avatar = this.getAvatarByGuid(avatarGuid);
if (avatar == null || !getPlayer().getFlyCloakList().contains(flycloakId)) {
return false;
......@@ -101,7 +101,7 @@ public class AvatarStorage implements Iterable<GenshinAvatar> {
}
public boolean changeCostume(long avatarGuid, int costumeId) {
GenshinAvatar avatar = this.getAvatarByGuid(avatarGuid);
Avatar avatar = this.getAvatarByGuid(avatarGuid);
if (avatar == null) {
return false;
......@@ -130,15 +130,15 @@ public class AvatarStorage implements Iterable<GenshinAvatar> {
}
public void loadFromDatabase() {
List<GenshinAvatar> avatars = DatabaseHelper.getAvatars(getPlayer());
List<Avatar> avatars = DatabaseHelper.getAvatars(getPlayer());
for (GenshinAvatar avatar : avatars) {
for (Avatar avatar : avatars) {
// Should never happen
if (avatar.getObjectId() == null) {
continue;
}
AvatarData avatarData = GenshinData.getAvatarDataMap().get(avatar.getAvatarId());
AvatarData avatarData = GameData.getAvatarDataMap().get(avatar.getAvatarId());
if (avatarData == null) {
continue;
}
......@@ -157,7 +157,7 @@ public class AvatarStorage implements Iterable<GenshinAvatar> {
}
public void postLoad() {
for (GenshinAvatar avatar : this) {
for (Avatar avatar : this) {
// Weapon check
if (avatar.getWeapon() == null) {
this.addStartingWeapon(avatar);
......@@ -168,7 +168,7 @@ public class AvatarStorage implements Iterable<GenshinAvatar> {
}
@Override
public Iterator<GenshinAvatar> iterator() {
public Iterator<Avatar> iterator() {
return getAvatars().values().iterator();
}
}
package emu.grasscutter.game.entity;
import emu.grasscutter.GenshinConstants;
import emu.grasscutter.data.GenshinData;
import emu.grasscutter.GameConstants;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.def.AvatarData;
import emu.grasscutter.data.def.AvatarSkillDepotData;
import emu.grasscutter.game.GenshinPlayer;
import emu.grasscutter.game.GenshinScene;
import emu.grasscutter.game.Player;
import emu.grasscutter.game.Scene;
import emu.grasscutter.game.World;
import emu.grasscutter.game.avatar.GenshinAvatar;
import emu.grasscutter.game.avatar.Avatar;
import emu.grasscutter.game.inventory.EquipType;
import emu.grasscutter.game.inventory.GenshinItem;
import emu.grasscutter.game.inventory.GameItem;
import emu.grasscutter.game.props.EntityIdType;
import emu.grasscutter.game.props.FightProperty;
import emu.grasscutter.game.props.PlayerProperty;
......@@ -34,29 +34,29 @@ import emu.grasscutter.utils.Utils;
import it.unimi.dsi.fastutil.ints.Int2FloatMap;
import it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap;
public class EntityAvatar extends GenshinEntity {
private final GenshinAvatar avatar;
public class EntityAvatar extends GameEntity {
private final Avatar avatar;
private PlayerDieType killedType;
private int killedBy;
public EntityAvatar(GenshinScene scene, GenshinAvatar avatar) {
public EntityAvatar(Scene scene, Avatar avatar) {
super(scene);
this.avatar = avatar;
this.id = getScene().getWorld().getNextEntityId(EntityIdType.AVATAR);
GenshinItem weapon = this.getAvatar().getWeapon();
GameItem weapon = this.getAvatar().getWeapon();
if (weapon != null) {
weapon.setWeaponEntityId(getScene().getWorld().getNextEntityId(EntityIdType.WEAPON));
}
}
public EntityAvatar(GenshinAvatar avatar) {
public EntityAvatar(Avatar avatar) {
super(null);
this.avatar = avatar;
}
public GenshinPlayer getPlayer() {
public Player getPlayer() {
return avatar.getPlayer();
}
......@@ -70,7 +70,7 @@ public class EntityAvatar extends GenshinEntity {
return getPlayer().getRotation();
}
public GenshinAvatar getAvatar() {
public Avatar getAvatar() {
return avatar;
}
......@@ -122,7 +122,7 @@ public class EntityAvatar extends GenshinEntity {
.setCostumeId(this.getAvatar().getCostume())
.setBornTime(this.getAvatar().getBornTime());
for (GenshinItem item : avatar.getEquips().values()) {
for (GameItem item : avatar.getEquips().values()) {
if (item.getItemData().getEquipType() == EquipType.EQUIP_WEAPON) {
avatarInfo.setWeapon(item.createSceneWeaponInfo());
} else {
......@@ -187,17 +187,17 @@ public class EntityAvatar extends GenshinEntity {
AbilityEmbryo emb = AbilityEmbryo.newBuilder()
.setAbilityId(++embryoId)
.setAbilityNameHash(id)
.setAbilityOverrideNameHash(GenshinConstants.DEFAULT_ABILITY_NAME)
.setAbilityOverrideNameHash(GameConstants.DEFAULT_ABILITY_NAME)
.build();
abilityControlBlock.addAbilityEmbryoList(emb);
}
}
// Add default abilities
for (int id : GenshinConstants.DEFAULT_ABILITY_HASHES) {
for (int id : GameConstants.DEFAULT_ABILITY_HASHES) {
AbilityEmbryo emb = AbilityEmbryo.newBuilder()
.setAbilityId(++embryoId)
.setAbilityNameHash(id)
.setAbilityOverrideNameHash(GenshinConstants.DEFAULT_ABILITY_NAME)
.setAbilityOverrideNameHash(GameConstants.DEFAULT_ABILITY_NAME)
.build();
abilityControlBlock.addAbilityEmbryoList(emb);
}
......@@ -206,18 +206,18 @@ public class EntityAvatar extends GenshinEntity {
AbilityEmbryo emb = AbilityEmbryo.newBuilder()
.setAbilityId(++embryoId)
.setAbilityNameHash(id)
.setAbilityOverrideNameHash(GenshinConstants.DEFAULT_ABILITY_NAME)
.setAbilityOverrideNameHash(GameConstants.DEFAULT_ABILITY_NAME)
.build();
abilityControlBlock.addAbilityEmbryoList(emb);
}
// Add skill depot abilities
AvatarSkillDepotData skillDepot = GenshinData.getAvatarSkillDepotDataMap().get(this.getAvatar().getSkillDepotId());
AvatarSkillDepotData skillDepot = GameData.getAvatarSkillDepotDataMap().get(this.getAvatar().getSkillDepotId());
if (skillDepot != null && skillDepot.getAbilities() != null) {
for (int id : skillDepot.getAbilities()) {
AbilityEmbryo emb = AbilityEmbryo.newBuilder()
.setAbilityId(++embryoId)
.setAbilityNameHash(id)
.setAbilityOverrideNameHash(GenshinConstants.DEFAULT_ABILITY_NAME)
.setAbilityOverrideNameHash(GameConstants.DEFAULT_ABILITY_NAME)
.build();
abilityControlBlock.addAbilityEmbryoList(emb);
}
......@@ -228,7 +228,7 @@ public class EntityAvatar extends GenshinEntity {
AbilityEmbryo emb = AbilityEmbryo.newBuilder()
.setAbilityId(++embryoId)
.setAbilityNameHash(Utils.abilityHash(skill))
.setAbilityOverrideNameHash(GenshinConstants.DEFAULT_ABILITY_NAME)
.setAbilityOverrideNameHash(GameConstants.DEFAULT_ABILITY_NAME)
.build();
abilityControlBlock.addAbilityEmbryoList(emb);
}
......
package emu.grasscutter.game.entity;
import emu.grasscutter.game.GenshinPlayer;
import emu.grasscutter.game.GenshinScene;
import emu.grasscutter.game.Player;
import emu.grasscutter.game.Scene;
import emu.grasscutter.game.World;
import emu.grasscutter.game.props.PlayerProperty;
import emu.grasscutter.net.proto.AbilitySyncStateInfoOuterClass.AbilitySyncStateInfo;
......@@ -24,7 +24,7 @@ import emu.grasscutter.utils.ProtoHelper;
import it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap;
public class EntityClientGadget extends EntityGadget {
private final GenshinPlayer owner;
private final Player owner;
private final Position pos;
private final Position rot;
......@@ -36,7 +36,7 @@ public class EntityClientGadget extends EntityGadget {
private int targetEntityId;
private boolean asyncLoad;
public EntityClientGadget(GenshinScene scene, GenshinPlayer player, EvtCreateGadgetNotify notify) {
public EntityClientGadget(Scene scene, Player player, EvtCreateGadgetNotify notify) {
super(scene);
this.owner = player;
this.id = notify.getEntityId();
......@@ -55,7 +55,7 @@ public class EntityClientGadget extends EntityGadget {
return configId;
}
public GenshinPlayer getOwner() {
public Player getOwner() {
return owner;
}
......
package emu.grasscutter.game.entity;
import emu.grasscutter.game.GenshinScene;
import emu.grasscutter.game.Scene;
import emu.grasscutter.game.World;
public abstract class EntityGadget extends GenshinEntity {
public abstract class EntityGadget extends GameEntity {
public EntityGadget(GenshinScene scene) {
public EntityGadget(Scene scene) {
super(scene);
}
......
package emu.grasscutter.game.entity;
import emu.grasscutter.data.def.ItemData;
import emu.grasscutter.game.GenshinPlayer;
import emu.grasscutter.game.GenshinScene;
import emu.grasscutter.game.Player;
import emu.grasscutter.game.Scene;
import emu.grasscutter.game.World;
import emu.grasscutter.game.inventory.GenshinItem;
import emu.grasscutter.game.inventory.GameItem;
import emu.grasscutter.game.props.EntityIdType;
import emu.grasscutter.game.props.PlayerProperty;
import emu.grasscutter.net.proto.AbilitySyncStateInfoOuterClass.AbilitySyncStateInfo;
......@@ -28,16 +28,16 @@ public class EntityItem extends EntityGadget {
private final Position pos;
private final Position rot;
private final GenshinItem item;
private final GameItem item;
private final long guid;
public EntityItem(GenshinScene scene, GenshinPlayer player, ItemData itemData, Position pos, int count) {
public EntityItem(Scene scene, Player player, ItemData itemData, Position pos, int count) {
super(scene);
this.id = getScene().getWorld().getNextEntityId(EntityIdType.GADGET);
this.pos = new Position(pos);
this.rot = new Position();
this.guid = player.getNextGenshinGuid();
this.item = new GenshinItem(itemData, count);
this.guid = player.getNextGameGuid();
this.item = new GameItem(itemData, count);
}
@Override
......@@ -45,7 +45,7 @@ public class EntityItem extends EntityGadget {
return this.id;
}
private GenshinItem getItem() {
private GameItem getItem() {
return this.item;
}
......
package emu.grasscutter.game.entity;
import emu.grasscutter.data.GenshinData;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.common.PropGrowCurve;
import emu.grasscutter.data.def.MonsterCurveData;
import emu.grasscutter.data.def.MonsterData;
import emu.grasscutter.game.GenshinScene;
import emu.grasscutter.game.Scene;
import emu.grasscutter.game.World;
import emu.grasscutter.game.props.EntityIdType;
import emu.grasscutter.game.props.FightProperty;
......@@ -27,7 +27,7 @@ import emu.grasscutter.utils.ProtoHelper;
import it.unimi.dsi.fastutil.ints.Int2FloatMap;
import it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap;
public class EntityMonster extends GenshinEntity {
public class EntityMonster extends GameEntity {
private final MonsterData monsterData;
private final Int2FloatOpenHashMap fightProp;
......@@ -41,7 +41,7 @@ public class EntityMonster extends GenshinEntity {
private int configId;
private int poseId;
public EntityMonster(GenshinScene scene, MonsterData monsterData, Position pos, int level) {
public EntityMonster(Scene scene, MonsterData monsterData, Position pos, int level) {
super(scene);
this.id = getWorld().getNextEntityId(EntityIdType.MONSTER);
this.monsterData = monsterData;
......@@ -160,7 +160,7 @@ public class EntityMonster extends GenshinEntity {
this.setFightProperty(FightProperty.FIGHT_PROP_ICE_SUB_HURT, data.getIceSubHurt());
// Level curve
MonsterCurveData curve = GenshinData.getMonsterCurveDataMap().get(this.getLevel());
MonsterCurveData curve = GameData.getMonsterCurveDataMap().get(this.getLevel());
if (curve != null) {
for (PropGrowCurve growCurve : data.getPropGrowCurves()) {
FightProperty prop = FightProperty.getPropByName(growCurve.getType());
......
package emu.grasscutter.game.entity;
import emu.grasscutter.game.GenshinScene;
import emu.grasscutter.game.Scene;
import emu.grasscutter.game.World;
import emu.grasscutter.game.props.FightProperty;
import emu.grasscutter.game.props.LifeState;
......@@ -12,16 +12,16 @@ import emu.grasscutter.net.proto.VectorOuterClass.Vector;
import emu.grasscutter.utils.Position;
import it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap;
public abstract class GenshinEntity {
public abstract class GameEntity {
protected int id;
private final GenshinScene scene;
private final Scene scene;
private SpawnDataEntry spawnEntry;
private MotionState moveState;
private int lastMoveSceneTimeMs;
private int lastMoveReliableSeq;
public GenshinEntity(GenshinScene scene) {
public GameEntity(Scene scene) {
this.scene = scene;
this.moveState = MotionState.MOTION_NONE;
}
......@@ -34,7 +34,7 @@ public abstract class GenshinEntity {
return this.getScene().getWorld();
}
public GenshinScene getScene() {
public Scene getScene() {
return this.scene;
}
......
......@@ -3,7 +3,7 @@ package emu.grasscutter.game.friends;
import java.util.List;
import emu.grasscutter.database.DatabaseHelper;
import emu.grasscutter.game.GenshinPlayer;
import emu.grasscutter.game.Player;
import emu.grasscutter.net.proto.DealAddFriendResultTypeOuterClass.DealAddFriendResultType;
import emu.grasscutter.server.packet.send.PacketAskAddFriendNotify;
import emu.grasscutter.server.packet.send.PacketAskAddFriendRsp;
......@@ -14,20 +14,20 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
public class FriendsList {
private final GenshinPlayer player;
private final Player player;
private final Int2ObjectMap<Friendship> friends;
private final Int2ObjectMap<Friendship> pendingFriends;
private boolean loaded = false;
public FriendsList(GenshinPlayer player) {
public FriendsList(Player player) {
this.player = player;
this.friends = new Int2ObjectOpenHashMap<Friendship>();
this.pendingFriends = new Int2ObjectOpenHashMap<Friendship>();
}
public GenshinPlayer getPlayer() {
public Player getPlayer() {
return player;
}
......@@ -83,7 +83,7 @@ public class FriendsList {
return;
}
GenshinPlayer target = getPlayer().getSession().getServer().getPlayerByUid(targetUid, true);
Player target = getPlayer().getSession().getServer().getPlayerByUid(targetUid, true);
if (target == null) {
return; // Should never happen
}
......@@ -143,7 +143,7 @@ public class FriendsList {
myFriendship.delete();
Friendship theirFriendship = null;
GenshinPlayer friend = myFriendship.getFriendProfile().getPlayer();
Player friend = myFriendship.getFriendProfile().getPlayer();
if (friend != null) {
// Friend online
theirFriendship = friend.getFriendsList().getFriendById(this.getPlayer().getUid());
......@@ -165,7 +165,7 @@ public class FriendsList {
}
public synchronized void sendFriendRequest(int targetUid) {
GenshinPlayer target = getPlayer().getSession().getServer().getPlayerByUid(targetUid, true);
Player target = getPlayer().getSession().getServer().getPlayerByUid(targetUid, true);
if (target == null || target == this.getPlayer()) {
return;
......@@ -220,7 +220,7 @@ public class FriendsList {
friendship.setOwner(getPlayer());
// Check if friend is online
GenshinPlayer friend = getPlayer().getSession().getServer().getPlayerByUid(friendship.getFriendProfile().getUid());
Player friend = getPlayer().getSession().getServer().getPlayerByUid(friendship.getFriendProfile().getUid());
if (friend != null) {
// Set friend to online mode
friendship.setFriendProfile(friend);
......
......@@ -5,7 +5,7 @@ import org.bson.types.ObjectId;
import dev.morphia.annotations.*;
import emu.grasscutter.database.DatabaseHelper;
import emu.grasscutter.game.GenshinPlayer;
import emu.grasscutter.game.Player;
import emu.grasscutter.net.proto.FriendBriefOuterClass.FriendBrief;
import emu.grasscutter.net.proto.FriendOnlineStateOuterClass.FriendOnlineState;
import emu.grasscutter.net.proto.HeadImageOuterClass.HeadImage;
......@@ -14,7 +14,7 @@ import emu.grasscutter.net.proto.HeadImageOuterClass.HeadImage;
public class Friendship {
@Id private ObjectId id;
@Transient private GenshinPlayer owner;
@Transient private Player owner;
@Indexed private int ownerId;
@Indexed private int friendId;
......@@ -26,7 +26,7 @@ public class Friendship {
@Deprecated // Morphia use only
public Friendship() { }
public Friendship(GenshinPlayer owner, GenshinPlayer friend, GenshinPlayer asker) {
public Friendship(Player owner, Player friend, Player asker) {
this.setOwner(owner);
this.ownerId = owner.getUid();
this.friendId = friend.getUid();
......@@ -34,11 +34,11 @@ public class Friendship {
this.askerId = asker.getUid();
}
public GenshinPlayer getOwner() {
public Player getOwner() {
return owner;
}
public void setOwner(GenshinPlayer owner) {
public void setOwner(Player owner) {
this.owner = owner;
}
......@@ -70,7 +70,7 @@ public class Friendship {
return profile;
}
public void setFriendProfile(GenshinPlayer character) {
public void setFriendProfile(Player character) {
if (character == null || this.friendId != character.getUid()) return;
this.profile = character.getProfile();
}
......
package emu.grasscutter.game.friends;
import dev.morphia.annotations.*;
import emu.grasscutter.game.GenshinPlayer;
import emu.grasscutter.game.Player;
import emu.grasscutter.utils.Utils;
@Entity
public class PlayerProfile {
@Transient private GenshinPlayer player;
@Transient private Player player;
@AlsoLoad("id") private int uid;
private int nameCard;
......@@ -22,7 +22,7 @@ public class PlayerProfile {
@Deprecated // Morphia only
public PlayerProfile() { }
public PlayerProfile(GenshinPlayer player) {
public PlayerProfile(Player player) {
this.uid = player.getUid();
this.syncWithCharacter(player);
}
......@@ -31,11 +31,11 @@ public class PlayerProfile {
return uid;
}
public GenshinPlayer getPlayer() {
public Player getPlayer() {
return player;
}
public synchronized void setPlayer(GenshinPlayer player) {
public synchronized void setPlayer(Player player) {
this.player = player;
}
......@@ -83,7 +83,7 @@ public class PlayerProfile {
return this.getPlayer() != null;
}
public void syncWithCharacter(GenshinPlayer player) {
public void syncWithCharacter(Player player) {
if (player == null) {
return;
}
......
......@@ -12,11 +12,11 @@ import com.google.gson.reflect.TypeToken;
import com.sun.nio.file.SensitivityWatchEventModifier;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.data.GenshinData;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.def.ItemData;
import emu.grasscutter.game.GenshinPlayer;
import emu.grasscutter.game.avatar.GenshinAvatar;
import emu.grasscutter.game.inventory.GenshinItem;
import emu.grasscutter.game.Player;
import emu.grasscutter.game.avatar.Avatar;
import emu.grasscutter.game.inventory.GameItem;
import emu.grasscutter.game.inventory.ItemType;
import emu.grasscutter.game.inventory.MaterialType;
import emu.grasscutter.net.proto.GachaItemOuterClass.GachaItem;
......@@ -89,7 +89,7 @@ public class GachaManager {
}
}
public synchronized void doPulls(GenshinPlayer player, int gachaType, int times) {
public synchronized void doPulls(Player player, int gachaType, int times) {
// Sanity check
if (times != 10 && times != 1) {
return;
......@@ -108,7 +108,7 @@ public class GachaManager {
// Spend currency
if (banner.getCostItem() > 0) {
GenshinItem costItem = player.getInventory().getInventoryTab(ItemType.ITEM_MATERIAL).getItemById(banner.getCostItem());
GameItem costItem = player.getInventory().getInventoryTab(ItemType.ITEM_MATERIAL).getItemById(banner.getCostItem());
if (costItem == null || costItem.getCount() < times) {
return;
}
......@@ -191,7 +191,7 @@ public class GachaManager {
int stardust = 0, starglitter = 0;
for (int itemId : wonItems) {
ItemData itemData = GenshinData.getItemDataMap().get(itemId);
ItemData itemData = GameData.getItemDataMap().get(itemId);
if (itemData == null) {
continue;
}
......@@ -204,11 +204,11 @@ public class GachaManager {
// Const check
if (itemData.getMaterialType() == MaterialType.MATERIAL_AVATAR) {
int avatarId = (itemData.getId() % 1000) + 10000000;
GenshinAvatar avatar = player.getAvatars().getAvatarById(avatarId);
Avatar avatar = player.getAvatars().getAvatarById(avatarId);
if (avatar != null) {
int constLevel = avatar.getCoreProudSkillLevel();
int constItemId = itemData.getId() + 100;
GenshinItem constItem = player.getInventory().getInventoryTab(ItemType.ITEM_MATERIAL).getItemById(constItemId);
GameItem constItem = player.getInventory().getInventoryTab(ItemType.ITEM_MATERIAL).getItemById(constItemId);
if (constItem != null) {
constLevel += constItem.getCount();
}
......@@ -249,7 +249,7 @@ public class GachaManager {
}
// Create item
GenshinItem item = new GenshinItem(itemData);
GameItem item = new GameItem(itemData);
gachaItem.setGachaItem(item.toItemParam());
player.getInventory().addItem(item);
......
......@@ -4,26 +4,26 @@ import java.util.HashSet;
import java.util.Set;
public class EquipInventoryTab implements InventoryTab {
private final Set<GenshinItem> items;
private final Set<GameItem> items;
private final int maxCapacity;
public EquipInventoryTab(int maxCapacity) {
this.items = new HashSet<GenshinItem>();
this.items = new HashSet<GameItem>();
this.maxCapacity = maxCapacity;
}
@Override
public GenshinItem getItemById(int id) {
public GameItem getItemById(int id) {
return null;
}
@Override
public void onAddItem(GenshinItem item) {
public void onAddItem(GameItem item) {
this.items.add(item);
}
@Override
public void onRemoveItem(GenshinItem item) {
public void onRemoveItem(GameItem item) {
this.items.remove(item);
}
......
......@@ -13,13 +13,13 @@ import dev.morphia.annotations.Indexed;
import dev.morphia.annotations.PostLoad;
import dev.morphia.annotations.Transient;
import emu.grasscutter.data.GenshinData;
import emu.grasscutter.data.GenshinDepot;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.GameDepot;
import emu.grasscutter.data.def.ItemData;
import emu.grasscutter.data.def.ReliquaryAffixData;
import emu.grasscutter.data.def.ReliquaryMainPropData;
import emu.grasscutter.database.DatabaseHelper;
import emu.grasscutter.game.GenshinPlayer;
import emu.grasscutter.game.Player;
import emu.grasscutter.game.props.FightProperty;
import emu.grasscutter.net.proto.AbilitySyncStateInfoOuterClass.AbilitySyncStateInfo;
import emu.grasscutter.net.proto.EquipOuterClass.Equip;
......@@ -35,7 +35,7 @@ import emu.grasscutter.net.proto.WeaponOuterClass.Weapon;
import emu.grasscutter.utils.WeightedList;
@Entity(value = "items", useDiscriminator = false)
public class GenshinItem {
public class GameItem {
@Id private ObjectId id;
@Indexed private int ownerId;
private int itemId;
......@@ -62,23 +62,23 @@ public class GenshinItem {
private int equipCharacter;
@Transient private int weaponEntityId;
public GenshinItem() {
public GameItem() {
// Morphia only
}
public GenshinItem(int itemId) {
this(GenshinData.getItemDataMap().get(itemId));
public GameItem(int itemId) {
this(GameData.getItemDataMap().get(itemId));
}
public GenshinItem(int itemId, int count) {
this(GenshinData.getItemDataMap().get(itemId), count);
public GameItem(int itemId, int count) {
this(GameData.getItemDataMap().get(itemId), count);
}
public GenshinItem(ItemData data) {
public GameItem(ItemData data) {
this(data, 1);
}
public GenshinItem(ItemData data, int count) {
public GameItem(ItemData data, int count) {
this.itemId = data.getId();
this.itemData = data;
......@@ -103,7 +103,7 @@ public class GenshinItem {
this.level = 1;
this.appendPropIdList = new ArrayList<>();
// Create main property
ReliquaryMainPropData mainPropData = GenshinDepot.getRandomRelicMainProp(getItemData().getMainPropDepotId());
ReliquaryMainPropData mainPropData = GameDepot.getRandomRelicMainProp(getItemData().getMainPropDepotId());
if (mainPropData != null) {
this.mainPropId = mainPropData.getId();
}
......@@ -124,9 +124,9 @@ public class GenshinItem {
return ownerId;
}
public void setOwner(GenshinPlayer player) {
public void setOwner(Player player) {
this.ownerId = player.getUid();
this.guid = player.getNextGenshinGuid();
this.guid = player.getNextGameGuid();
}
public int getItemId() {
return itemId;
......@@ -261,7 +261,7 @@ public class GenshinItem {
}
private void addNewAppendProp() {
List<ReliquaryAffixData> affixList = GenshinDepot.getRandomRelicAffixList(getItemData().getAppendPropDepotId());
List<ReliquaryAffixData> affixList = GameDepot.getRandomRelicAffixList(getItemData().getAppendPropDepotId());
if (affixList == null) {
return;
......@@ -269,13 +269,13 @@ public class GenshinItem {
// Build blacklist - Dont add same stat as main/sub stat
Set<FightProperty> blacklist = new HashSet<>();
ReliquaryMainPropData mainPropData = GenshinData.getReliquaryMainPropDataMap().get(this.getMainPropId());
ReliquaryMainPropData mainPropData = GameData.getReliquaryMainPropDataMap().get(this.getMainPropId());
if (mainPropData != null) {
blacklist.add(mainPropData.getFightProp());
}
int len = Math.min(4, this.getAppendPropIdList().size());
for (int i = 0; i < len; i++) {
ReliquaryAffixData affixData = GenshinData.getReliquaryAffixDataMap().get((int) this.getAppendPropIdList().get(i));
ReliquaryAffixData affixData = GameData.getReliquaryAffixDataMap().get((int) this.getAppendPropIdList().get(i));
if (affixData != null) {
blacklist.add(affixData.getFightProp());
}
......@@ -299,7 +299,7 @@ public class GenshinItem {
}
private void upgradeRandomAppendProp() {
List<ReliquaryAffixData> affixList = GenshinDepot.getRandomRelicAffixList(getItemData().getAppendPropDepotId());
List<ReliquaryAffixData> affixList = GameDepot.getRandomRelicAffixList(getItemData().getAppendPropDepotId());
if (affixList == null) {
return;
......@@ -309,7 +309,7 @@ public class GenshinItem {
Set<FightProperty> whitelist = new HashSet<>();
int len = Math.min(4, this.getAppendPropIdList().size());
for (int i = 0; i < len; i++) {
ReliquaryAffixData affixData = GenshinData.getReliquaryAffixDataMap().get((int) this.getAppendPropIdList().get(i));
ReliquaryAffixData affixData = GameData.getReliquaryAffixDataMap().get((int) this.getAppendPropIdList().get(i));
if (affixData != null) {
whitelist.add(affixData.getFightProp());
}
......@@ -331,7 +331,7 @@ public class GenshinItem {
@PostLoad
public void onLoad() {
if (this.itemData == null) {
this.itemData = GenshinData.getItemDataMap().get(getItemId());
this.itemData = GameData.getItemDataMap().get(getItemId());
}
}
......
......@@ -5,17 +5,17 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import emu.grasscutter.GenshinConstants;
import emu.grasscutter.GameConstants;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.data.GenshinData;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.def.AvatarCostumeData;
import emu.grasscutter.data.def.AvatarData;
import emu.grasscutter.data.def.AvatarFlycloakData;
import emu.grasscutter.data.def.ItemData;
import emu.grasscutter.database.DatabaseHelper;
import emu.grasscutter.game.GenshinPlayer;
import emu.grasscutter.game.Player;
import emu.grasscutter.game.avatar.AvatarStorage;
import emu.grasscutter.game.avatar.GenshinAvatar;
import emu.grasscutter.game.avatar.Avatar;
import emu.grasscutter.game.entity.EntityAvatar;
import emu.grasscutter.game.props.ActionReason;
import emu.grasscutter.net.proto.ItemParamOuterClass.ItemParam;
......@@ -28,13 +28,13 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
public class Inventory implements Iterable<GenshinItem> {
private final GenshinPlayer player;
public class Inventory implements Iterable<GameItem> {
private final Player player;
private final Long2ObjectMap<GenshinItem> store;
private final Long2ObjectMap<GameItem> store;
private final Int2ObjectMap<InventoryTab> inventoryTypes;
public Inventory(GenshinPlayer player) {
public Inventory(Player player) {
this.player = player;
this.store = new Long2ObjectOpenHashMap<>();
this.inventoryTypes = new Int2ObjectOpenHashMap<>();
......@@ -45,7 +45,7 @@ public class Inventory implements Iterable<GenshinItem> {
this.createInventoryTab(ItemType.ITEM_FURNITURE, new MaterialInventoryTab(Grasscutter.getConfig().getGameServerOptions().InventoryLimitFurniture));
}
public GenshinPlayer getPlayer() {
public Player getPlayer() {
return player;
}
......@@ -53,7 +53,7 @@ public class Inventory implements Iterable<GenshinItem> {
return this.getPlayer().getAvatars();
}
public Long2ObjectMap<GenshinItem> getItems() {
public Long2ObjectMap<GameItem> getItems() {
return store;
}
......@@ -69,7 +69,7 @@ public class Inventory implements Iterable<GenshinItem> {
this.getInventoryTypes().put(type.getValue(), tab);
}
public GenshinItem getItemByGuid(long id) {
public GameItem getItemByGuid(long id) {
return this.getItems().get(id);
}
......@@ -78,19 +78,19 @@ public class Inventory implements Iterable<GenshinItem> {
}
public boolean addItem(int itemId, int count) {
ItemData itemData = GenshinData.getItemDataMap().get(itemId);
ItemData itemData = GameData.getItemDataMap().get(itemId);
if (itemData == null) {
return false;
}
GenshinItem item = new GenshinItem(itemData, count);
GameItem item = new GameItem(itemData, count);
return addItem(item);
}
public boolean addItem(GenshinItem item) {
GenshinItem result = putItem(item);
public boolean addItem(GameItem item) {
GameItem result = putItem(item);
if (result != null) {
getPlayer().sendPacket(new PacketStoreItemChangeNotify(result));
......@@ -100,7 +100,7 @@ public class Inventory implements Iterable<GenshinItem> {
return false;
}
public boolean addItem(GenshinItem item, ActionReason reason) {
public boolean addItem(GameItem item, ActionReason reason) {
boolean result = addItem(item);
if (result && reason != null) {
......@@ -110,15 +110,15 @@ public class Inventory implements Iterable<GenshinItem> {
return result;
}
public void addItems(Collection<GenshinItem> items) {
public void addItems(Collection<GameItem> items) {
this.addItems(items, null);
}
public void addItems(Collection<GenshinItem> items, ActionReason reason) {
List<GenshinItem> changedItems = new LinkedList<>();
public void addItems(Collection<GameItem> items, ActionReason reason) {
List<GameItem> changedItems = new LinkedList<>();
for (GenshinItem item : items) {
GenshinItem result = putItem(item);
for (GameItem item : items) {
GameItem result = putItem(item);
if (result != null) {
changedItems.add(result);
}
......@@ -136,10 +136,10 @@ public class Inventory implements Iterable<GenshinItem> {
}
public void addItemParams(Collection<ItemParam> items) {
addItems(items.stream().map(param -> new GenshinItem(param.getItemId(), param.getCount())).toList(), null);
addItems(items.stream().map(param -> new GameItem(param.getItemId(), param.getCount())).toList(), null);
}
private synchronized GenshinItem putItem(GenshinItem item) {
private synchronized GameItem putItem(GameItem item) {
// Dont add items that dont have a valid item definition.
if (item.getItemData() == null) {
return null;
......@@ -163,23 +163,23 @@ public class Inventory implements Iterable<GenshinItem> {
// Get avatar id
int avatarId = (item.getItemId() % 1000) + 10000000;
// Dont let people give themselves extra main characters
if (avatarId == GenshinConstants.MAIN_CHARACTER_MALE || avatarId == GenshinConstants.MAIN_CHARACTER_FEMALE) {
if (avatarId == GameConstants.MAIN_CHARACTER_MALE || avatarId == GameConstants.MAIN_CHARACTER_FEMALE) {
return null;
}
// Add avatar
AvatarData avatarData = GenshinData.getAvatarDataMap().get(avatarId);
AvatarData avatarData = GameData.getAvatarDataMap().get(avatarId);
if (avatarData != null && !player.getAvatars().hasAvatar(avatarId)) {
this.getPlayer().addAvatar(new GenshinAvatar(avatarData));
this.getPlayer().addAvatar(new Avatar(avatarData));
}
return null;
} else if (item.getItemData().getMaterialType() == MaterialType.MATERIAL_FLYCLOAK) {
AvatarFlycloakData flycloakData = GenshinData.getAvatarFlycloakDataMap().get(item.getItemId());
AvatarFlycloakData flycloakData = GameData.getAvatarFlycloakDataMap().get(item.getItemId());
if (flycloakData != null && !player.getFlyCloakList().contains(item.getItemId())) {
getPlayer().addFlycloak(item.getItemId());
}
return null;
} else if (item.getItemData().getMaterialType() == MaterialType.MATERIAL_COSTUME) {
AvatarCostumeData costumeData = GenshinData.getAvatarCostumeDataItemIdMap().get(item.getItemId());
AvatarCostumeData costumeData = GameData.getAvatarCostumeDataItemIdMap().get(item.getItemId());
if (costumeData != null && !player.getCostumeList().contains(costumeData.getId())) {
getPlayer().addCostume(costumeData.getId());
}
......@@ -190,7 +190,7 @@ public class Inventory implements Iterable<GenshinItem> {
}
return null;
} else if (tab != null) {
GenshinItem existingItem = tab.getItemById(item.getItemId());
GameItem existingItem = tab.getItemById(item.getItemId());
if (existingItem == null) {
// Item type didnt exist before, we will add it to main inventory map if there is enough space
if (tab.getSize() >= tab.getMaxCapacity()) {
......@@ -213,7 +213,7 @@ public class Inventory implements Iterable<GenshinItem> {
return item;
}
private synchronized void putItem(GenshinItem item, InventoryTab tab) {
private synchronized void putItem(GameItem item, InventoryTab tab) {
// Set owner and guid FIRST!
item.setOwner(getPlayer());
// Put in item store
......@@ -242,9 +242,9 @@ public class Inventory implements Iterable<GenshinItem> {
}
}
public void removeItems(List<GenshinItem> items) {
public void removeItems(List<GameItem> items) {
// TODO Bulk delete
for (GenshinItem item : items) {
for (GameItem item : items) {
this.removeItem(item, item.getCount());
}
}
......@@ -254,7 +254,7 @@ public class Inventory implements Iterable<GenshinItem> {
}
public synchronized boolean removeItem(long guid, int count) {
GenshinItem item = this.getItemByGuid(guid);
GameItem item = this.getItemByGuid(guid);
if (item == null) {
return false;
......@@ -263,11 +263,11 @@ public class Inventory implements Iterable<GenshinItem> {
return removeItem(item, count);
}
public synchronized boolean removeItem(GenshinItem item) {
public synchronized boolean removeItem(GameItem item) {
return removeItem(item, item.getCount());
}
public synchronized boolean removeItem(GenshinItem item, int count) {
public synchronized boolean removeItem(GameItem item, int count) {
// Sanity check
if (count <= 0 || item == null) {
return false;
......@@ -296,7 +296,7 @@ public class Inventory implements Iterable<GenshinItem> {
return true;
}
private void deleteItem(GenshinItem item, InventoryTab tab) {
private void deleteItem(GameItem item, InventoryTab tab) {
getItems().remove(item.getGuid());
if (tab != null) {
tab.onRemoveItem(item);
......@@ -304,8 +304,8 @@ public class Inventory implements Iterable<GenshinItem> {
}
public boolean equipItem(long avatarGuid, long equipGuid) {
GenshinAvatar avatar = getPlayer().getAvatars().getAvatarByGuid(avatarGuid);
GenshinItem item = this.getItemByGuid(equipGuid);
Avatar avatar = getPlayer().getAvatars().getAvatarByGuid(avatarGuid);
GameItem item = this.getItemByGuid(equipGuid);
if (avatar != null && item != null) {
return avatar.equipItem(item, true);
......@@ -315,7 +315,7 @@ public class Inventory implements Iterable<GenshinItem> {
}
public boolean unequipItem(long avatarGuid, int slot) {
GenshinAvatar avatar = getPlayer().getAvatars().getAvatarByGuid(avatarGuid);
Avatar avatar = getPlayer().getAvatars().getAvatarByGuid(avatarGuid);
EquipType equipType = EquipType.getTypeByValue(slot);
if (avatar != null && equipType != EquipType.EQUIP_WEAPON) {
......@@ -330,15 +330,15 @@ public class Inventory implements Iterable<GenshinItem> {
}
public void loadFromDatabase() {
List<GenshinItem> items = DatabaseHelper.getInventoryItems(getPlayer());
List<GameItem> items = DatabaseHelper.getInventoryItems(getPlayer());
for (GenshinItem item : items) {
for (GameItem item : items) {
// Should never happen
if (item.getObjectId() == null) {
continue;
}
ItemData itemData = GenshinData.getItemDataMap().get(item.getItemId());
ItemData itemData = GameData.getItemDataMap().get(item.getItemId());
if (itemData == null) {
continue;
}
......@@ -354,7 +354,7 @@ public class Inventory implements Iterable<GenshinItem> {
// Equip to a character if possible
if (item.isEquipped()) {
GenshinAvatar avatar = getPlayer().getAvatars().getAvatarById(item.getEquipCharacter());
Avatar avatar = getPlayer().getAvatars().getAvatarById(item.getEquipCharacter());
boolean hasEquipped = false;
if (avatar != null) {
......@@ -370,7 +370,7 @@ public class Inventory implements Iterable<GenshinItem> {
}
@Override
public Iterator<GenshinItem> iterator() {
public Iterator<GameItem> iterator() {
return this.getItems().values().iterator();
}
}
package emu.grasscutter.game.inventory;
public interface InventoryTab {
public GenshinItem getItemById(int id);
public GameItem getItemById(int id);
public void onAddItem(GenshinItem item);
public void onAddItem(GameItem item);
public void onRemoveItem(GenshinItem item);
public void onRemoveItem(GameItem item);
public int getSize();
......
......@@ -4,7 +4,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
public class MaterialInventoryTab implements InventoryTab {
private final Int2ObjectMap<GenshinItem> items;
private final Int2ObjectMap<GameItem> items;
private final int maxCapacity;
public MaterialInventoryTab(int maxCapacity) {
......@@ -13,17 +13,17 @@ public class MaterialInventoryTab implements InventoryTab {
}
@Override
public GenshinItem getItemById(int id) {
public GameItem getItemById(int id) {
return this.items.get(id);
}
@Override
public void onAddItem(GenshinItem item) {
public void onAddItem(GameItem item) {
this.items.put(item.getItemId(), item);
}
@Override
public void onRemoveItem(GenshinItem item) {
public void onRemoveItem(GameItem item) {
this.items.remove(item.getItemId());
}
......
package emu.grasscutter.game.managers;
import emu.grasscutter.command.CommandMap;
import emu.grasscutter.game.GenshinPlayer;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.game.Player;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.server.game.GameServer;
import emu.grasscutter.server.packet.send.PacketPlayerChatNotify;
import emu.grasscutter.server.packet.send.PacketPrivateChatNotify;
......@@ -23,7 +23,7 @@ public class ChatManager {
return server;
}
public void sendPrivateMessage(GenshinPlayer player, int targetUid, String message) {
public void sendPrivateMessage(Player player, int targetUid, String message) {
// Sanity checks
if (message == null || message.length() == 0) {
return;
......@@ -36,35 +36,35 @@ public class ChatManager {
}
// Get target
GenshinPlayer target = getServer().getPlayerByUid(targetUid);
Player target = getServer().getPlayerByUid(targetUid);
if (target == null) {
return;
}
// Create chat packet
GenshinPacket packet = new PacketPrivateChatNotify(player.getUid(), target.getUid(), message);
BasePacket packet = new PacketPrivateChatNotify(player.getUid(), target.getUid(), message);
player.sendPacket(packet);
target.sendPacket(packet);
}
public void sendPrivateMessage(GenshinPlayer player, int targetUid, int emote) {
public void sendPrivateMessage(Player player, int targetUid, int emote) {
// Get target
GenshinPlayer target = getServer().getPlayerByUid(targetUid);
Player target = getServer().getPlayerByUid(targetUid);
if (target == null) {
return;
}
// Create chat packet
GenshinPacket packet = new PacketPrivateChatNotify(player.getUid(), target.getUid(), emote);
BasePacket packet = new PacketPrivateChatNotify(player.getUid(), target.getUid(), emote);
player.sendPacket(packet);
target.sendPacket(packet);
}
public void sendTeamMessage(GenshinPlayer player, int channel, String message) {
public void sendTeamMessage(Player player, int channel, String message) {
// Sanity checks
if (message == null || message.length() == 0) {
return;
......@@ -80,7 +80,7 @@ public class ChatManager {
player.getWorld().broadcastPacket(new PacketPlayerChatNotify(player, channel, message));
}
public void sendTeamMessage(GenshinPlayer player, int channel, int icon) {
public void sendTeamMessage(Player player, int channel, int icon) {
// Create and send chat packet
player.getWorld().broadcastPacket(new PacketPlayerChatNotify(player, channel, icon));
}
......
package emu.grasscutter.game.managers;
import emu.grasscutter.game.CoopRequest;
import emu.grasscutter.game.GenshinPlayer;
import emu.grasscutter.game.GenshinPlayer.SceneLoadState;
import emu.grasscutter.game.Player;
import emu.grasscutter.game.Player.SceneLoadState;
import emu.grasscutter.game.props.EnterReason;
import emu.grasscutter.net.proto.EnterTypeOuterClass.EnterType;
import emu.grasscutter.net.proto.PlayerApplyEnterMpReasonOuterClass.PlayerApplyEnterMpReason;
......@@ -24,8 +24,8 @@ public class MultiplayerManager {
return server;
}
public void applyEnterMp(GenshinPlayer player, int targetUid) {
GenshinPlayer target = getServer().getPlayerByUid(targetUid);
public void applyEnterMp(Player player, int targetUid) {
Player target = getServer().getPlayerByUid(targetUid);
if (target == null) {
player.sendPacket(new PacketPlayerApplyEnterMpResultNotify(targetUid, "", false, PlayerApplyEnterMpResultNotifyOuterClass.PlayerApplyEnterMpResultNotify.Reason.PLAYER_CANNOT_ENTER_MP));
return;
......@@ -59,7 +59,7 @@ public class MultiplayerManager {
target.sendPacket(new PacketPlayerApplyEnterMpNotify(player));
}
public void applyEnterMpReply(GenshinPlayer hostPlayer, int applyUid, boolean isAgreed) {
public void applyEnterMpReply(Player hostPlayer, int applyUid, boolean isAgreed) {
// Checks
CoopRequest request = hostPlayer.getCoopRequests().get(applyUid);
if (request == null || request.isExpired()) {
......@@ -67,7 +67,7 @@ public class MultiplayerManager {
}
// Remove now that we are handling it
GenshinPlayer requester = request.getRequester();
Player requester = request.getRequester();
hostPlayer.getCoopRequests().remove(applyUid);
// Sanity checks - Dont let the requesting player join if they are already in multiplayer
......@@ -108,14 +108,14 @@ public class MultiplayerManager {
requester.sendPacket(new PacketPlayerEnterSceneNotify(requester, hostPlayer, EnterType.ENTER_OTHER, EnterReason.TeamJoin, hostPlayer.getScene().getId(), hostPlayer.getPos()));
}
public boolean leaveCoop(GenshinPlayer player) {
public boolean leaveCoop(Player player) {
// Make sure player's world is multiplayer
if (!player.getWorld().isMultiplayer()) {
return false;
}
// Make sure everyone's scene is loaded
for (GenshinPlayer p : player.getWorld().getPlayers()) {
for (Player p : player.getWorld().getPlayers()) {
if (p.getSceneLoadState() != SceneLoadState.LOADED) {
return false;
}
......@@ -131,14 +131,14 @@ public class MultiplayerManager {
return true;
}
public boolean kickPlayer(GenshinPlayer player, int targetUid) {
public boolean kickPlayer(Player player, int targetUid) {
// Make sure player's world is multiplayer and that player is owner
if (!player.getWorld().isMultiplayer() || player.getWorld().getHost() != player) {
return false;
}
// Get victim and sanity checks
GenshinPlayer victim = player.getServer().getPlayerByUid(targetUid);
Player victim = player.getServer().getPlayerByUid(targetUid);
if (victim == null || victim == player) {
return false;
......
......@@ -7,7 +7,7 @@ import com.google.protobuf.GeneratedMessageV3;
import emu.grasscutter.net.proto.PacketHeadOuterClass.PacketHead;
import emu.grasscutter.utils.Crypto;
public class GenshinPacket {
public class BasePacket {
private static final int const1 = 17767; // 0x4567
private static final int const2 = -30293; // 0x89ab
......@@ -21,16 +21,16 @@ public class GenshinPacket {
private boolean useDispatchKey;
public boolean shouldEncrypt = true;
public GenshinPacket(int opcode) {
public BasePacket(int opcode) {
this.opcode = opcode;
}
public GenshinPacket(int opcode, int clientSequence) {
public BasePacket(int opcode, int clientSequence) {
this.opcode = opcode;
this.buildHeader(clientSequence);
}
public GenshinPacket(int opcode, boolean buildHeader) {
public BasePacket(int opcode, boolean buildHeader) {
this.opcode = opcode;
this.shouldBuildHeader = buildHeader;
}
......@@ -80,7 +80,7 @@ public class GenshinPacket {
this.data = proto.build().toByteArray();
}
public GenshinPacket buildHeader(int clientSequence) {
public BasePacket buildHeader(int clientSequence) {
if (this.getHeader() != null && clientSequence == 0) {
return this;
}
......
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