Commit 9fc8cc1c authored by Kengxxiao's avatar Kengxxiao Committed by GitHub
Browse files

Merge pull request #1 from Grasscutters/development

merge
parents 627a2f1e d1fc8c1f
package emu.grasscutter.data.def;
import emu.grasscutter.data.GenshinResource;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import emu.grasscutter.game.props.FightProperty;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import it.unimi.dsi.fastutil.ints.IntSet;
@ResourceType(name = {"MaterialExcelConfigData.json", "WeaponExcelConfigData.json", "ReliquaryExcelConfigData.json"})
public class ItemData extends GenshinResource {
public class ItemData extends GameResource {
private int Id;
private int StackLimit = 1;
......
......@@ -4,12 +4,12 @@ import java.util.HashMap;
import java.util.Map;
import java.util.stream.Stream;
import emu.grasscutter.data.GenshinResource;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import emu.grasscutter.data.common.CurveInfo;
@ResourceType(name = "MonsterCurveExcelConfigData.json")
public class MonsterCurveData extends GenshinResource {
public class MonsterCurveData extends GameResource {
private int Level;
private CurveInfo[] CurveInfos;
......
......@@ -2,14 +2,14 @@ package emu.grasscutter.data.def;
import java.util.List;
import emu.grasscutter.data.GenshinData;
import emu.grasscutter.data.GenshinResource;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import emu.grasscutter.data.ResourceType.LoadPriority;
import emu.grasscutter.data.common.PropGrowCurve;
@ResourceType(name = "MonsterExcelConfigData.json", loadPriority = LoadPriority.LOW)
public class MonsterData extends GenshinResource {
public class MonsterData extends GameResource {
private int Id;
private String MonsterName;
......@@ -168,13 +168,13 @@ public class MonsterData extends GenshinResource {
@Override
public void onLoad() {
this.describeData = GenshinData.getMonsterDescribeDataMap().get(this.getDescribeId());
this.describeData = GameData.getMonsterDescribeDataMap().get(this.getDescribeId());
for (int id : this.Equips) {
if (id == 0) {
continue;
}
GadgetData gadget = GenshinData.getGadgetDataMap().get(id);
GadgetData gadget = GameData.getGadgetDataMap().get(id);
if (gadget == null) {
continue;
}
......
package emu.grasscutter.data.def;
import emu.grasscutter.data.GenshinResource;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import emu.grasscutter.data.ResourceType.LoadPriority;
@ResourceType(name = "MonsterDescribeExcelConfigData.json", loadPriority = LoadPriority.HIGH)
public class MonsterDescribeData extends GenshinResource {
public class MonsterDescribeData extends GameResource {
private int Id;
private long NameTextMapHash;
private int TitleID;
......
package emu.grasscutter.data.def;
import emu.grasscutter.data.GenshinResource;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
@ResourceType(name = "NpcExcelConfigData.json")
public class NpcData extends GenshinResource {
public class NpcData extends GameResource {
private int Id;
private String JsonName;
......
package emu.grasscutter.data.def;
import emu.grasscutter.data.GenshinResource;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
@ResourceType(name = "PlayerLevelExcelConfigData.json")
public class PlayerLevelData extends GenshinResource {
public class PlayerLevelData extends GameResource {
private int Level;
private int Exp;
private int RewardId;
......
......@@ -3,13 +3,13 @@ package emu.grasscutter.data.def;
import java.util.ArrayList;
import java.util.List;
import emu.grasscutter.data.GenshinResource;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import emu.grasscutter.data.common.FightPropData;
import emu.grasscutter.data.common.ItemParamData;
@ResourceType(name = "ProudSkillExcelConfigData.json")
public class ProudSkillData extends GenshinResource {
public class ProudSkillData extends GameResource {
private int ProudSkillId;
private int ProudSkillGroupId;
......
package emu.grasscutter.data.def;
import emu.grasscutter.data.GenshinResource;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import emu.grasscutter.game.props.FightProperty;
@ResourceType(name = "ReliquaryAffixExcelConfigData.json")
public class ReliquaryAffixData extends GenshinResource {
public class ReliquaryAffixData extends GameResource {
private int Id;
private int DepotId;
......
......@@ -2,14 +2,14 @@ package emu.grasscutter.data.def;
import java.util.List;
import emu.grasscutter.data.GenshinResource;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import emu.grasscutter.game.props.FightProperty;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
@ResourceType(name = "ReliquaryLevelExcelConfigData.json")
public class ReliquaryLevelData extends GenshinResource {
public class ReliquaryLevelData extends GameResource {
private int id;
private Int2ObjectMap<Float> propMap;
......
package emu.grasscutter.data.def;
import emu.grasscutter.data.GenshinResource;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import emu.grasscutter.game.props.FightProperty;
@ResourceType(name = "ReliquaryMainPropExcelConfigData.json")
public class ReliquaryMainPropData extends GenshinResource {
public class ReliquaryMainPropData extends GameResource {
private int Id;
private int PropDepotId;
......
package emu.grasscutter.data.def;
import emu.grasscutter.data.GenshinResource;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
@ResourceType(name = "ReliquarySetExcelConfigData.json")
public class ReliquarySetData extends GenshinResource {
public class ReliquarySetData extends GameResource {
private int SetId;
private int[] SetNeedNum;
private int EquipAffixId;
......
......@@ -2,12 +2,12 @@ package emu.grasscutter.data.def;
import java.util.List;
import emu.grasscutter.data.GenshinResource;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import emu.grasscutter.data.common.RewardItemData;
@ResourceType(name = "RewardExcelConfigData.json")
public class RewardData extends GenshinResource {
public class RewardData extends GameResource {
public int RewardId;
public List<RewardItemData> RewardItemList;
......
package emu.grasscutter.data.def;
import emu.grasscutter.data.GenshinData;
import emu.grasscutter.data.GenshinResource;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import emu.grasscutter.game.props.SceneType;
@ResourceType(name = "SceneExcelConfigData.json")
public class SceneData extends GenshinResource {
public class SceneData extends GameResource {
private int Id;
private SceneType SceneType;
private String ScriptData;
......
......@@ -4,12 +4,12 @@ import java.util.HashMap;
import java.util.Map;
import java.util.stream.Stream;
import emu.grasscutter.data.GenshinResource;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import emu.grasscutter.data.common.CurveInfo;
@ResourceType(name = "WeaponCurveExcelConfigData.json")
public class WeaponCurveData extends GenshinResource {
public class WeaponCurveData extends GameResource {
private int Level;
private CurveInfo[] CurveInfos;
......
package emu.grasscutter.data.def;
import emu.grasscutter.data.GenshinResource;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
@ResourceType(name = "WeaponLevelExcelConfigData.json")
public class WeaponLevelData extends GenshinResource {
public class WeaponLevelData extends GameResource {
private int Level;
private int[] RequiredExps;
......
package emu.grasscutter.data.def;
import java.util.ArrayList;
import emu.grasscutter.data.GenshinResource;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import emu.grasscutter.data.common.FightPropData;
import emu.grasscutter.data.common.ItemParamData;
@ResourceType(name = "WeaponPromoteExcelConfigData.json")
public class WeaponPromoteData extends GenshinResource {
public class WeaponPromoteData extends GameResource {
private int WeaponPromoteId;
private int PromoteLevel;
......
package emu.grasscutter.data.def;
import emu.grasscutter.data.GenshinResource;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
@ResourceType(name = "WorldLevelExcelConfigData.json")
public class WorldLevelData extends GenshinResource {
public class WorldLevelData extends GameResource {
private int Level;
private int MonsterLevel;
......
......@@ -4,12 +4,12 @@ import java.util.List;
import com.mongodb.client.result.DeleteResult;
import dev.morphia.query.experimental.filters.Filters;
import emu.grasscutter.GenshinConstants;
import emu.grasscutter.GameConstants;
import emu.grasscutter.game.Account;
import emu.grasscutter.game.GenshinPlayer;
import emu.grasscutter.game.avatar.GenshinAvatar;
import emu.grasscutter.game.avatar.Avatar;
import emu.grasscutter.game.friends.Friendship;
import emu.grasscutter.game.inventory.GenshinItem;
import emu.grasscutter.game.inventory.GameItem;
import emu.grasscutter.game.player.Player;
public final class DatabaseHelper {
public static Account createAccount(String username) {
......@@ -26,7 +26,7 @@ public final class DatabaseHelper {
// Make sure there are no id collisions
if (reservedId > 0) {
// Cannot make account with the same uid as the server console
if (reservedId == GenshinConstants.SERVER_CONSOLE_UID) {
if (reservedId == GameConstants.SERVER_CONSOLE_UID) {
return null;
}
exists = DatabaseHelper.getAccountByPlayerId(reservedId);
......@@ -90,15 +90,19 @@ public final class DatabaseHelper {
return DatabaseManager.getDatastore().find(Account.class).filter(Filters.eq("username", username)).delete().getDeletedCount() > 0;
}
public static GenshinPlayer getPlayerById(int id) {
return DatabaseManager.getDatastore().find(GenshinPlayer.class).filter(Filters.eq("_id", id)).first();
public static List<Player> getAllPlayers() {
return DatabaseManager.getDatastore().find(Player.class).stream().toList();
}
public static Player getPlayerById(int id) {
return DatabaseManager.getDatastore().find(Player.class).filter(Filters.eq("_id", id)).first();
}
public static boolean checkPlayerExists(int id) {
return DatabaseManager.getDatastore().find(GenshinPlayer.class).filter(Filters.eq("_id", id)).first() != null;
return DatabaseManager.getDatastore().find(Player.class).filter(Filters.eq("_id", id)).first() != null;
}
public static synchronized GenshinPlayer createPlayer(GenshinPlayer character, int reservedId) {
public static synchronized Player createPlayer(Player character, int reservedId) {
// Check if reserved id
int id;
if (reservedId > 0 && !checkPlayerExists(reservedId)) {
......@@ -123,42 +127,42 @@ public final class DatabaseHelper {
id = reservedId;
} else {
do {
id = DatabaseManager.getNextId(GenshinPlayer.class);
id = DatabaseManager.getNextId(Player.class);
}
while (checkPlayerExists(id));
}
return id;
}
public static void savePlayer(GenshinPlayer character) {
public static void savePlayer(Player character) {
DatabaseManager.getDatastore().save(character);
}
public static void saveAvatar(GenshinAvatar avatar) {
public static void saveAvatar(Avatar avatar) {
DatabaseManager.getDatastore().save(avatar);
}
public static List<GenshinAvatar> getAvatars(GenshinPlayer player) {
return DatabaseManager.getDatastore().find(GenshinAvatar.class).filter(Filters.eq("ownerId", player.getUid())).stream().toList();
public static List<Avatar> getAvatars(Player player) {
return DatabaseManager.getDatastore().find(Avatar.class).filter(Filters.eq("ownerId", player.getUid())).stream().toList();
}
public static void saveItem(GenshinItem item) {
public static void saveItem(GameItem item) {
DatabaseManager.getDatastore().save(item);
}
public static boolean deleteItem(GenshinItem item) {
public static boolean deleteItem(GameItem item) {
DeleteResult result = DatabaseManager.getDatastore().delete(item);
return result.wasAcknowledged();
}
public static List<GenshinItem> getInventoryItems(GenshinPlayer player) {
return DatabaseManager.getDatastore().find(GenshinItem.class).filter(Filters.eq("ownerId", player.getUid())).stream().toList();
public static List<GameItem> getInventoryItems(Player player) {
return DatabaseManager.getDatastore().find(GameItem.class).filter(Filters.eq("ownerId", player.getUid())).stream().toList();
}
public static List<Friendship> getFriends(GenshinPlayer player) {
public static List<Friendship> getFriends(Player player) {
return DatabaseManager.getDatastore().find(Friendship.class).filter(Filters.eq("ownerId", player.getUid())).stream().toList();
}
public static List<Friendship> getReverseFriends(GenshinPlayer player) {
public static List<Friendship> getReverseFriends(Player player) {
return DatabaseManager.getDatastore().find(Friendship.class).filter(Filters.eq("friendId", player.getUid())).stream().toList();
}
......
......@@ -13,10 +13,10 @@ import dev.morphia.mapping.MapperOptions;
import dev.morphia.query.experimental.filters.Filters;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.game.Account;
import emu.grasscutter.game.GenshinPlayer;
import emu.grasscutter.game.avatar.GenshinAvatar;
import emu.grasscutter.game.avatar.Avatar;
import emu.grasscutter.game.friends.Friendship;
import emu.grasscutter.game.inventory.GenshinItem;
import emu.grasscutter.game.inventory.GameItem;
import emu.grasscutter.game.player.Player;
public final class DatabaseManager {
......@@ -27,7 +27,7 @@ public final class DatabaseManager {
private static Datastore dispatchDatastore;
private static final Class<?>[] mappedClasses = new Class<?>[] {
DatabaseCounter.class, Account.class, GenshinPlayer.class, GenshinAvatar.class, GenshinItem.class, Friendship.class
DatabaseCounter.class, Account.class, Player.class, Avatar.class, GameItem.class, Friendship.class
};
public static Datastore getDatastore() {
......
package emu.grasscutter.game;
import emu.grasscutter.game.player.Player;
public class CoopRequest {
private final GenshinPlayer requester;
private final Player requester;
private final long requestTime;
private final long expireTime;
public CoopRequest(GenshinPlayer requester) {
public CoopRequest(Player requester) {
this.requester = requester;
this.requestTime = System.currentTimeMillis();
this.expireTime = this.requestTime + 10000;
}
public GenshinPlayer getRequester() {
public Player getRequester() {
return requester;
}
......
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