Fix whitespace [skip actions]

This commit is contained in:
github-actions 2022-09-03 03:36:51 +00:00
parent 005a0bce96
commit 6e5d986687
24 changed files with 510 additions and 510 deletions

View File

@ -225,7 +225,7 @@ public final class CommandMap {
Grasscutter.getLogger().info("Command used by server console: " + rawMessage);
}
}
rawMessage = rawMessage.trim();
if (rawMessage.length() == 0) {
CommandHandler.sendTranslatedMessage(player, "commands.generic.not_specified");

View File

@ -96,7 +96,7 @@ public class ConfigContainer {
public Set<Integer> debugBlacklist = Set.of();
public ServerRunMode runMode = ServerRunMode.HYBRID;
public boolean logCommands = false;
public HTTP http = new HTTP();
public Game game = new Game();

View File

@ -10,71 +10,71 @@ import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
public class PointData {
private int id;
private String $type;
private Position tranPos;
private int id;
private String $type;
private Position tranPos;
@SerializedName(value="dungeonIds", alternate={"JHHFPGJNMIN"})
private int[] dungeonIds;
@SerializedName(value="dungeonIds", alternate={"JHHFPGJNMIN"})
private int[] dungeonIds;
@SerializedName(value="dungeonRandomList", alternate={"OIBKFJNBLHO"})
private int[] dungeonRandomList;
@SerializedName(value="dungeonRandomList", alternate={"OIBKFJNBLHO"})
private int[] dungeonRandomList;
@SerializedName(value="tranSceneId", alternate={"JHBICGBAPIH"})
private int tranSceneId;
@SerializedName(value="tranSceneId", alternate={"JHBICGBAPIH"})
private int tranSceneId;
public int getId() {
return id;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public void setId(int id) {
this.id = id;
}
public String getType() {
return $type;
}
public String getType() {
return $type;
}
public Position getTranPos() {
return tranPos;
}
public Position getTranPos() {
return tranPos;
}
public int[] getDungeonIds() {
return dungeonIds;
}
public int[] getDungeonIds() {
return dungeonIds;
}
public int[] getDungeonRandomList() {
return dungeonRandomList;
}
public int[] getDungeonRandomList() {
return dungeonRandomList;
}
public int getTranSceneId() {
return tranSceneId;
}
public int getTranSceneId() {
return tranSceneId;
}
public void setTranSceneId(int tranSceneId) {
this.tranSceneId = tranSceneId;
}
public void setTranSceneId(int tranSceneId) {
this.tranSceneId = tranSceneId;
}
public void updateDailyDungeon() {
public void updateDailyDungeon() {
if (getDungeonRandomList() == null || getDungeonRandomList().length == 0) {
return;
}
}
IntList newDungeons = new IntArrayList();
int day = Grasscutter.getCurrentDayOfWeek();
IntList newDungeons = new IntArrayList();
int day = Grasscutter.getCurrentDayOfWeek();
for (int randomId : getDungeonRandomList()) {
DailyDungeonData data = GameData.getDailyDungeonDataMap().get(randomId);
for (int randomId : getDungeonRandomList()) {
DailyDungeonData data = GameData.getDailyDungeonDataMap().get(randomId);
if (data != null) {
int[] addDungeons = data.getDungeonsByDay(day);
if (data != null) {
int[] addDungeons = data.getDungeonsByDay(day);
for (int d : addDungeons) {
newDungeons.add(d);
}
}
}
for (int d : addDungeons) {
newDungeons.add(d);
}
}
}
this.dungeonIds = newDungeons.toIntArray();
}
this.dungeonIds = newDungeons.toIntArray();
}
}

View File

@ -6,30 +6,30 @@ import emu.grasscutter.data.ResourceType;
@ResourceType(name = "AvatarCostumeExcelConfigData.json")
public class AvatarCostumeData extends GameResource {
private int costumeId;
private int itemId;
private int costumeId;
private int itemId;
private int characterId;
private int quality;
@Override
public int getId() {
return this.costumeId;
}
public int getItemId() {
return this.itemId;
}
public int getCharacterId() {
return characterId;
}
public int getQuality() {
@Override
public int getId() {
return this.costumeId;
}
public int getItemId() {
return this.itemId;
}
public int getCharacterId() {
return characterId;
}
public int getQuality() {
return quality;
}
@Override
public void onLoad() {
GameData.getAvatarCostumeDataItemIdMap().put(this.getItemId(), this);
}
public void onLoad() {
GameData.getAvatarCostumeDataItemIdMap().put(this.getItemId(), this);
}
}

View File

@ -8,52 +8,52 @@ import emu.grasscutter.data.common.FightPropData;
@ResourceType(name = "EquipAffixExcelConfigData.json")
public class EquipAffixData extends GameResource {
private int affixId;
private int affixId;
private int id;
private int level;
private long nameTextMapHash;
private String openConfig;
private FightPropData[] addProps;
private float[] paramList;
@Override
public int getId() {
return affixId;
}
public int getMainId() {
return id;
}
public int getLevel() {
return level;
}
@Override
public int getId() {
return affixId;
}
public long getNameTextMapHash() {
return nameTextMapHash;
}
public int getMainId() {
return id;
}
public String getOpenConfig() {
return openConfig;
}
public int getLevel() {
return level;
}
public FightPropData[] getAddProps() {
return addProps;
}
public long getNameTextMapHash() {
return nameTextMapHash;
}
public float[] getParamList() {
return paramList;
}
public String getOpenConfig() {
return openConfig;
}
@Override
public void onLoad() {
ArrayList<FightPropData> parsed = new ArrayList<FightPropData>(getAddProps().length);
for (FightPropData prop : getAddProps()) {
if (prop.getPropType() != null && prop.getValue() != 0f) {
prop.onLoad();
parsed.add(prop);
}
}
this.addProps = parsed.toArray(new FightPropData[parsed.size()]);
}
public FightPropData[] getAddProps() {
return addProps;
}
public float[] getParamList() {
return paramList;
}
@Override
public void onLoad() {
ArrayList<FightPropData> parsed = new ArrayList<FightPropData>(getAddProps().length);
for (FightPropData prop : getAddProps()) {
if (prop.getPropType() != null && prop.getValue() != 0f) {
prop.onLoad();
parsed.add(prop);
}
}
this.addProps = parsed.toArray(new FightPropData[parsed.size()]);
}
}

View File

@ -120,7 +120,7 @@ public class ItemData extends GameResource {
if (this.getFurnitureGadgetID() != null) {
this.furnitureGadgetID = this.furnitureGadgetID.stream().filter(x -> x > 0).toList();
}
// Prevent material type from being null
this.materialType = this.materialType == null ? MaterialType.MATERIAL_NONE : this.materialType;
}

View File

@ -7,27 +7,27 @@ import emu.grasscutter.data.ResourceType;
@ResourceType(name = "ReliquarySetExcelConfigData.json")
public class ReliquarySetData extends GameResource {
private int setId;
private int setId;
private int[] setNeedNum;
@SerializedName(value="equipAffixId", alternate={"EquipAffixId"})
private int equipAffixId;
@Override
public int getId() {
return setId;
}
public int[] getSetNeedNum() {
return setNeedNum;
}
public int getEquipAffixId() {
return equipAffixId;
}
@Override
public int getId() {
return setId;
}
@Override
public void onLoad() {
public int[] getSetNeedNum() {
return setNeedNum;
}
}
public int getEquipAffixId() {
return equipAffixId;
}
@Override
public void onLoad() {
}
}

View File

@ -25,103 +25,103 @@ import emu.grasscutter.game.quest.GameMainQuest;
import static com.mongodb.client.model.Filters.eq;
public final class DatabaseHelper {
public static Account createAccount(String username) {
return createAccountWithUid(username, 0);
}
public static Account createAccount(String username) {
return createAccountWithUid(username, 0);
}
public static Account createAccountWithUid(String username, int reservedUid) {
// Unique names only
if (DatabaseHelper.checkIfAccountExists(username)) {
return null;
}
public static Account createAccountWithUid(String username, int reservedUid) {
// Unique names only
if (DatabaseHelper.checkIfAccountExists(username)) {
return null;
}
// Make sure there are no id collisions
if (reservedUid > 0) {
// Cannot make account with the same uid as the server console
if (reservedUid == GameConstants.SERVER_CONSOLE_UID) {
return null;
}
// Make sure there are no id collisions
if (reservedUid > 0) {
// Cannot make account with the same uid as the server console
if (reservedUid == GameConstants.SERVER_CONSOLE_UID) {
return null;
}
if (DatabaseHelper.checkIfAccountExists(reservedUid)) {
return null;
}
if (DatabaseHelper.checkIfAccountExists(reservedUid)) {
return null;
}
// Make sure no existing player already has this id.
if (DatabaseHelper.checkIfPlayerExists(reservedUid)) {
return null;
}
}
// Make sure no existing player already has this id.
if (DatabaseHelper.checkIfPlayerExists(reservedUid)) {
return null;
}
}
// Account
Account account = new Account();
account.setUsername(username);
account.setId(Integer.toString(DatabaseManager.getNextId(account)));
// Account
Account account = new Account();
account.setUsername(username);
account.setId(Integer.toString(DatabaseManager.getNextId(account)));
if (reservedUid > 0) {
account.setReservedPlayerUid(reservedUid);
}
if (reservedUid > 0) {
account.setReservedPlayerUid(reservedUid);
}
DatabaseHelper.saveAccount(account);
return account;
}
DatabaseHelper.saveAccount(account);
return account;
}
@Deprecated
public static Account createAccountWithPassword(String username, String password) {
// Unique names only
Account exists = DatabaseHelper.getAccountByName(username);
if (exists != null) {
return null;
}
@Deprecated
public static Account createAccountWithPassword(String username, String password) {
// Unique names only
Account exists = DatabaseHelper.getAccountByName(username);
if (exists != null) {
return null;
}
// Account
Account account = new Account();
account.setId(Integer.toString(DatabaseManager.getNextId(account)));
account.setUsername(username);
account.setPassword(password);
DatabaseHelper.saveAccount(account);
return account;
}
// Account
Account account = new Account();
account.setId(Integer.toString(DatabaseManager.getNextId(account)));
account.setUsername(username);
account.setPassword(password);
DatabaseHelper.saveAccount(account);
return account;
}
public static void saveAccount(Account account) {
DatabaseManager.getAccountDatastore().save(account);
}
public static void saveAccount(Account account) {
DatabaseManager.getAccountDatastore().save(account);
}
public static Account getAccountByName(String username) {
return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("username", username)).first();
}
public static Account getAccountByName(String username) {
return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("username", username)).first();
}
public static Account getAccountByToken(String token) {
if(token == null) return null;
return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("token", token)).first();
}
public static Account getAccountByToken(String token) {
if (token == null) return null;
return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("token", token)).first();
}
public static Account getAccountBySessionKey(String sessionKey) {
if(sessionKey == null) return null;
return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("sessionKey", sessionKey)).first();
}
public static Account getAccountBySessionKey(String sessionKey) {
if (sessionKey == null) return null;
return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("sessionKey", sessionKey)).first();
}
public static Account getAccountById(String uid) {
return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("_id", uid)).first();
}
public static Account getAccountById(String uid) {
return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("_id", uid)).first();
}
public static Account getAccountByPlayerId(int playerId) {
return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("reservedPlayerId", playerId)).first();
}
public static Account getAccountByPlayerId(int playerId) {
return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("reservedPlayerId", playerId)).first();
}
public static boolean checkIfAccountExists(String name) {
return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("username", name)).count() > 0;
}
public static boolean checkIfAccountExists(String name) {
return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("username", name)).count() > 0;
}
public static boolean checkIfAccountExists(int reservedUid) {
return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("reservedPlayerId", reservedUid)).count() > 0;
}
public static boolean checkIfAccountExists(int reservedUid) {
return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("reservedPlayerId", reservedUid)).count() > 0;
}
public static synchronized void deleteAccount(Account target) {
// To delete an account, we need to also delete all the other documents in the database that reference the account.
// This should optimally be wrapped inside a transaction, to make sure an error thrown mid-way does not leave the
// database in an inconsistent state, but unfortunately Mongo only supports that when we have a replica set ...
public static synchronized void deleteAccount(Account target) {
// To delete an account, we need to also delete all the other documents in the database that reference the account.
// This should optimally be wrapped inside a transaction, to make sure an error thrown mid-way does not leave the
// database in an inconsistent state, but unfortunately Mongo only supports that when we have a replica set ...
Player player = Grasscutter.getGameServer().getPlayerByAccountId(target.getId());
Player player = Grasscutter.getGameServer().getPlayerByAccountId(target.getId());
// Close session first
if (player != null) {
@ -152,187 +152,187 @@ public final class DatabaseHelper {
// Finally, delete the account itself.
DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("id", target.getId())).delete();
}
}
public static List<Player> getAllPlayers() {
return DatabaseManager.getGameDatastore().find(Player.class).stream().toList();
}
public static List<Player> getAllPlayers() {
return DatabaseManager.getGameDatastore().find(Player.class).stream().toList();
}
public static Player getPlayerByUid(int id) {
return DatabaseManager.getGameDatastore().find(Player.class).filter(Filters.eq("_id", id)).first();
}
public static Player getPlayerByUid(int id) {
return DatabaseManager.getGameDatastore().find(Player.class).filter(Filters.eq("_id", id)).first();
}
@Deprecated
public static Player getPlayerByAccount(Account account) {
return DatabaseManager.getGameDatastore().find(Player.class).filter(Filters.eq("accountId", account.getId())).first();
}
public static Player getPlayerByAccount(Account account) {
return DatabaseManager.getGameDatastore().find(Player.class).filter(Filters.eq("accountId", account.getId())).first();
}
public static Player getPlayerByAccount(Account account, Class<? extends Player> playerClass) {
return DatabaseManager.getGameDatastore().find(playerClass).filter(Filters.eq("accountId", account.getId())).first();
}
public static boolean checkIfPlayerExists(int uid) {
return DatabaseManager.getGameDatastore().find(Player.class).filter(Filters.eq("_id", uid)).count() > 0;
}
public static boolean checkIfPlayerExists(int uid) {
return DatabaseManager.getGameDatastore().find(Player.class).filter(Filters.eq("_id", uid)).count() > 0;
}
public static synchronized Player generatePlayerUid(Player character, int reservedId) {
// Check if reserved id
int id;
if (reservedId > 0 && !checkIfPlayerExists(reservedId)) {
id = reservedId;
character.setUid(id);
} else {
do {
id = DatabaseManager.getNextId(character);
}
while (checkIfPlayerExists(id));
character.setUid(id);
}
// Save to database
DatabaseManager.getGameDatastore().save(character);
return character;
}
public static synchronized Player generatePlayerUid(Player character, int reservedId) {
// Check if reserved id
int id;
if (reservedId > 0 && !checkIfPlayerExists(reservedId)) {
id = reservedId;
character.setUid(id);
} else {
do {
id = DatabaseManager.getNextId(character);
}
while (checkIfPlayerExists(id));
character.setUid(id);
}
// Save to database
DatabaseManager.getGameDatastore().save(character);
return character;
}
public static synchronized int getNextPlayerId(int reservedId) {
// Check if reserved id
int id;
if (reservedId > 0 && !checkIfPlayerExists(reservedId)) {
id = reservedId;
} else {
do {
id = DatabaseManager.getNextId(Player.class);
}
while (checkIfPlayerExists(id));
}
return id;
}
public static synchronized int getNextPlayerId(int reservedId) {
// Check if reserved id
int id;
if (reservedId > 0 && !checkIfPlayerExists(reservedId)) {
id = reservedId;
} else {
do {
id = DatabaseManager.getNextId(Player.class);
}
while (checkIfPlayerExists(id));
}
return id;
}
public static void savePlayer(Player character) {
DatabaseManager.getGameDatastore().save(character);
}
public static void savePlayer(Player character) {
DatabaseManager.getGameDatastore().save(character);
}
public static void saveAvatar(Avatar avatar) {
DatabaseManager.getGameDatastore().save(avatar);
}
public static void saveAvatar(Avatar avatar) {
DatabaseManager.getGameDatastore().save(avatar);
}
public static List<Avatar> getAvatars(Player player) {
return DatabaseManager.getGameDatastore().find(Avatar.class).filter(Filters.eq("ownerId", player.getUid())).stream().toList();
}
public static List<Avatar> getAvatars(Player player) {
return DatabaseManager.getGameDatastore().find(Avatar.class).filter(Filters.eq("ownerId", player.getUid())).stream().toList();
}
public static void saveItem(GameItem item) {
DatabaseManager.getGameDatastore().save(item);
}
public static void saveItem(GameItem item) {
DatabaseManager.getGameDatastore().save(item);
}
public static boolean deleteItem(GameItem item) {
DeleteResult result = DatabaseManager.getGameDatastore().delete(item);
return result.wasAcknowledged();
}
public static boolean deleteItem(GameItem item) {
DeleteResult result = DatabaseManager.getGameDatastore().delete(item);
return result.wasAcknowledged();
}
public static List<GameItem> getInventoryItems(Player player) {
return DatabaseManager.getGameDatastore().find(GameItem.class).filter(Filters.eq("ownerId", player.getUid())).stream().toList();
}
public static List<GameItem> getInventoryItems(Player player) {
return DatabaseManager.getGameDatastore().find(GameItem.class).filter(Filters.eq("ownerId", player.getUid())).stream().toList();
}
public static List<Friendship> getFriends(Player player) {
return DatabaseManager.getGameDatastore().find(Friendship.class).filter(Filters.eq("ownerId", player.getUid())).stream().toList();
}
public static List<Friendship> getFriends(Player player) {
return DatabaseManager.getGameDatastore().find(Friendship.class).filter(Filters.eq("ownerId", player.getUid())).stream().toList();
}
public static List<Friendship> getReverseFriends(Player player) {
return DatabaseManager.getGameDatastore().find(Friendship.class).filter(Filters.eq("friendId", player.getUid())).stream().toList();
}
public static List<Friendship> getReverseFriends(Player player) {
return DatabaseManager.getGameDatastore().find(Friendship.class).filter(Filters.eq("friendId", player.getUid())).stream().toList();
}
public static void saveFriendship(Friendship friendship) {
DatabaseManager.getGameDatastore().save(friendship);
}
public static void saveFriendship(Friendship friendship) {
DatabaseManager.getGameDatastore().save(friendship);
}
public static void deleteFriendship(Friendship friendship) {
DatabaseManager.getGameDatastore().delete(friendship);
}
public static void deleteFriendship(Friendship friendship) {
DatabaseManager.getGameDatastore().delete(friendship);
}
public static Friendship getReverseFriendship(Friendship friendship) {
return DatabaseManager.getGameDatastore().find(Friendship.class).filter(Filters.and(
Filters.eq("ownerId", friendship.getFriendId()),
Filters.eq("friendId", friendship.getOwnerId())
)).first();
}
public static Friendship getReverseFriendship(Friendship friendship) {
return DatabaseManager.getGameDatastore().find(Friendship.class).filter(Filters.and(
Filters.eq("ownerId", friendship.getFriendId()),
Filters.eq("friendId", friendship.getOwnerId())
)).first();
}
public static List<GachaRecord> getGachaRecords(int ownerId, int page, int gachaType){
return getGachaRecords(ownerId, page, gachaType, 10);
}
public static List<GachaRecord> getGachaRecords(int ownerId, int page, int gachaType) {
return getGachaRecords(ownerId, page, gachaType, 10);
}
public static List<GachaRecord> getGachaRecords(int ownerId, int page, int gachaType, int pageSize){
return DatabaseManager.getGameDatastore().find(GachaRecord.class).filter(
Filters.eq("ownerId", ownerId),
Filters.eq("gachaType", gachaType)
).iterator(new FindOptions()
.sort(Sort.descending("transactionDate"))
.skip(pageSize * page)
.limit(pageSize)
).toList();
}
public static List<GachaRecord> getGachaRecords(int ownerId, int page, int gachaType, int pageSize) {
return DatabaseManager.getGameDatastore().find(GachaRecord.class).filter(
Filters.eq("ownerId", ownerId),
Filters.eq("gachaType", gachaType)
).iterator(new FindOptions()
.sort(Sort.descending("transactionDate"))
.skip(pageSize * page)
.limit(pageSize)
).toList();
}
public static long getGachaRecordsMaxPage(int ownerId, int page, int gachaType){
return getGachaRecordsMaxPage(ownerId, page, gachaType, 10);
}
public static long getGachaRecordsMaxPage(int ownerId, int page, int gachaType) {
return getGachaRecordsMaxPage(ownerId, page, gachaType, 10);
}
public static long getGachaRecordsMaxPage(int ownerId, int page, int gachaType, int pageSize){
long count = DatabaseManager.getGameDatastore().find(GachaRecord.class).filter(
Filters.eq("ownerId", ownerId),
Filters.eq("gachaType", gachaType)
).count();
return count / 10 + (count % 10 > 0 ? 1 : 0 );
}
public static long getGachaRecordsMaxPage(int ownerId, int page, int gachaType, int pageSize) {
long count = DatabaseManager.getGameDatastore().find(GachaRecord.class).filter(
Filters.eq("ownerId", ownerId),
Filters.eq("gachaType", gachaType)
).count();
return count / 10 + (count % 10 > 0 ? 1 : 0 );
}
public static void saveGachaRecord(GachaRecord gachaRecord){
DatabaseManager.getGameDatastore().save(gachaRecord);
}
public static void saveGachaRecord(GachaRecord gachaRecord) {
DatabaseManager.getGameDatastore().save(gachaRecord);
}
public static List<Mail> getAllMail(Player player) {
return DatabaseManager.getGameDatastore().find(Mail.class).filter(Filters.eq("ownerUid", player.getUid())).stream().toList();
}
public static List<Mail> getAllMail(Player player) {
return DatabaseManager.getGameDatastore().find(Mail.class).filter(Filters.eq("ownerUid", player.getUid())).stream().toList();
}
public static void saveMail(Mail mail) {
DatabaseManager.getGameDatastore().save(mail);
}
public static void saveMail(Mail mail) {
DatabaseManager.getGameDatastore().save(mail);
}
public static boolean deleteMail(Mail mail) {
DeleteResult result = DatabaseManager.getGameDatastore().delete(mail);
return result.wasAcknowledged();
}
public static boolean deleteMail(Mail mail) {
DeleteResult result = DatabaseManager.getGameDatastore().delete(mail);
return result.wasAcknowledged();
}
public static List<GameMainQuest> getAllQuests(Player player) {
return DatabaseManager.getGameDatastore().find(GameMainQuest.class).filter(Filters.eq("ownerUid", player.getUid())).stream().toList();
}
public static List<GameMainQuest> getAllQuests(Player player) {
return DatabaseManager.getGameDatastore().find(GameMainQuest.class).filter(Filters.eq("ownerUid", player.getUid())).stream().toList();
}
public static void saveQuest(GameMainQuest quest) {
DatabaseManager.getGameDatastore().save(quest);
}
public static void saveQuest(GameMainQuest quest) {
DatabaseManager.getGameDatastore().save(quest);
}
public static boolean deleteQuest(GameMainQuest quest) {
return DatabaseManager.getGameDatastore().delete(quest).wasAcknowledged();
}
public static boolean deleteQuest(GameMainQuest quest) {
return DatabaseManager.getGameDatastore().delete(quest).wasAcknowledged();
}
public static GameHome getHomeByUid(int id) {
return DatabaseManager.getGameDatastore().find(GameHome.class).filter(Filters.eq("ownerUid", id)).first();
}
public static GameHome getHomeByUid(int id) {
return DatabaseManager.getGameDatastore().find(GameHome.class).filter(Filters.eq("ownerUid", id)).first();
}
public static void saveHome(GameHome gameHome) {
DatabaseManager.getGameDatastore().save(gameHome);
}
public static void saveHome(GameHome gameHome) {
DatabaseManager.getGameDatastore().save(gameHome);
}
public static BattlePassManager loadBattlePass(Player player) {
BattlePassManager manager = DatabaseManager.getGameDatastore().find(BattlePassManager.class).filter(Filters.eq("ownerUid", player.getUid())).first();
if (manager == null) {
manager = new BattlePassManager(player);
manager.save();
} else {
manager.setPlayer(player);
}
return manager;
}
public static BattlePassManager loadBattlePass(Player player) {
BattlePassManager manager = DatabaseManager.getGameDatastore().find(BattlePassManager.class).filter(Filters.eq("ownerUid", player.getUid())).first();
if (manager == null) {
manager = new BattlePassManager(player);
manager.save();
} else {
manager.setPlayer(player);
}
return manager;
}
public static void saveBattlePass(BattlePassManager manager) {
DatabaseManager.getGameDatastore().save(manager);
}
public static void saveBattlePass(BattlePassManager manager) {
DatabaseManager.getGameDatastore().save(manager);
}
public static PlayerActivityData getPlayerActivityData(int uid, int activityId) {
return DatabaseManager.getGameDatastore().find(PlayerActivityData.class)

View File

@ -600,7 +600,7 @@ public class Avatar {
}
}
}
public void addToExtraAbilityEmbryos(String openConfig) {
this.addToExtraAbilityEmbryos(openConfig, false);
}

View File

@ -130,7 +130,7 @@ public class EntityAvatar extends GameEntity {
if (!this.isAlive()) {
return 0f;
}
float healed = super.heal(amount);
if (healed > 0f) {

View File

@ -16,66 +16,66 @@ import emu.grasscutter.server.packet.send.PacketGadgetInteractRsp;
import emu.grasscutter.utils.Utils;
public class GadgetGatherObject extends GadgetContent {
private int itemId;
private boolean isForbidGuest;
public GadgetGatherObject(EntityGadget gadget) {
super(gadget);
if (gadget.getSpawnEntry() != null) {
this.itemId = gadget.getSpawnEntry().getGatherItemId();
}
}
public int getItemId() {
return this.itemId;
}
private int itemId;
private boolean isForbidGuest;
public boolean isForbidGuest() {
return isForbidGuest;
}
public GadgetGatherObject(EntityGadget gadget) {
super(gadget);
public boolean onInteract(Player player, GadgetInteractReq req) {
// Sanity check
ItemData itemData = GameData.getItemDataMap().get(getItemId());
if (itemData == null) {
return false;
}
if (gadget.getSpawnEntry() != null) {
this.itemId = gadget.getSpawnEntry().getGatherItemId();
}
}
GameItem item = new GameItem(itemData, 1);
player.getInventory().addItem(item, ActionReason.Gather);
getGadget().getScene().broadcastPacket(new PacketGadgetInteractRsp(getGadget(), InteractType.INTERACT_TYPE_GATHER));
public int getItemId() {
return this.itemId;
}
return true;
}
public boolean isForbidGuest() {
return isForbidGuest;
}
public void onBuildProto(SceneGadgetInfo.Builder gadgetInfo) {
GatherGadgetInfo gatherGadgetInfo = GatherGadgetInfo.newBuilder()
.setItemId(this.getItemId())
.setIsForbidGuest(this.isForbidGuest())
.build();
public boolean onInteract(Player player, GadgetInteractReq req) {
// Sanity check
ItemData itemData = GameData.getItemDataMap().get(getItemId());
if (itemData == null) {
return false;
}
gadgetInfo.setGatherGadget(gatherGadgetInfo);
}
GameItem item = new GameItem(itemData, 1);
player.getInventory().addItem(item, ActionReason.Gather);
getGadget().getScene().broadcastPacket(new PacketGadgetInteractRsp(getGadget(), InteractType.INTERACT_TYPE_GATHER));
return true;
}
public void onBuildProto(SceneGadgetInfo.Builder gadgetInfo) {
GatherGadgetInfo gatherGadgetInfo = GatherGadgetInfo.newBuilder()
.setItemId(this.getItemId())
.setIsForbidGuest(this.isForbidGuest())
.build();
gadgetInfo.setGatherGadget(gatherGadgetInfo);
}
public void dropItems(Player player) {
Scene scene = getGadget().getScene();
int times = Utils.randomRange(1,2);
public void dropItems(Player player) {
Scene scene = getGadget().getScene();
int times = Utils.randomRange(1,2);
for (int i = 0 ; i < times ; i++) {
EntityItem item = new EntityItem(
scene,
player,
scene,
player,
GameData.getItemDataMap().get(itemId),
getGadget().getPosition().nearby2d(1f).addY(2f),
1,
true);
scene.addEntity(item);
}
scene.killEntity(this.getGadget(), player.getTeamManager().getCurrentAvatarEntity().getId());
// Todo: add record
}
}
}

View File

@ -14,50 +14,50 @@ import emu.grasscutter.net.proto.SceneGadgetInfoOuterClass.SceneGadgetInfo;
import emu.grasscutter.utils.Utils;
public class GadgetGatherPoint extends GadgetContent {
private int itemId;
private boolean isForbidGuest;
public GadgetGatherPoint(EntityGadget gadget) {
super(gadget);
if (gadget.getSpawnEntry() != null) {
this.itemId = gadget.getSpawnEntry().getGatherItemId();
} else {
GatherData gatherData = GameData.getGatherDataMap().get(gadget.getPointType());
this.itemId = gatherData.getItemId();
this.isForbidGuest = gatherData.isForbidGuest();
}
}
public int getItemId() {
return this.itemId;
}
private int itemId;
private boolean isForbidGuest;
public boolean isForbidGuest() {
return isForbidGuest;
}
public GadgetGatherPoint(EntityGadget gadget) {
super(gadget);
public boolean onInteract(Player player, GadgetInteractReq req) {
GameItem item = new GameItem(getItemId(), 1);
player.getInventory().addItem(item, ActionReason.Gather);
return true;
}
if (gadget.getSpawnEntry() != null) {
this.itemId = gadget.getSpawnEntry().getGatherItemId();
} else {
GatherData gatherData = GameData.getGatherDataMap().get(gadget.getPointType());
this.itemId = gatherData.getItemId();
this.isForbidGuest = gatherData.isForbidGuest();
}
}
public void onBuildProto(SceneGadgetInfo.Builder gadgetInfo) {
GatherGadgetInfo gatherGadgetInfo = GatherGadgetInfo.newBuilder()
.setItemId(this.getItemId())
.setIsForbidGuest(this.isForbidGuest())
.build();
public int getItemId() {
return this.itemId;
}
gadgetInfo.setGatherGadget(gatherGadgetInfo);
}
public boolean isForbidGuest() {
return isForbidGuest;
}
public boolean onInteract(Player player, GadgetInteractReq req) {
GameItem item = new GameItem(getItemId(), 1);
player.getInventory().addItem(item, ActionReason.Gather);
return true;
}
public void onBuildProto(SceneGadgetInfo.Builder gadgetInfo) {
GatherGadgetInfo gatherGadgetInfo = GatherGadgetInfo.newBuilder()
.setItemId(this.getItemId())
.setIsForbidGuest(this.isForbidGuest())
.build();
gadgetInfo.setGatherGadget(gatherGadgetInfo);
}
public void dropItems(Player player) {
Scene scene = getGadget().getScene();
int times = Utils.randomRange(1,2);
public void dropItems(Player player) {
Scene scene = getGadget().getScene();
int times = Utils.randomRange(1,2);
for (int i = 0 ; i < times ; i++) {
EntityItem item = new EntityItem(
scene,
@ -69,11 +69,11 @@ public class GadgetGatherPoint extends GadgetContent {
.addZ(Utils.randomFloatRange(-1f, 1f)),
1,
true);
scene.addEntity(item);
}
scene.killEntity(this.getGadget(), player.getTeamManager().getCurrentAvatarEntity().getId());
// Todo: add record
}
}
}

View File

@ -45,7 +45,7 @@ public class HomeBlockItem {
.toList();
}
public int calComfort(){
public int calComfort() {
return this.deployFurnitureList.stream()
.mapToInt(HomeFurnitureItem::getComfort)
.sum();

View File

@ -15,11 +15,11 @@ public class MapMark {
private int monsterId;
private MapMarkFromType mapMarkFromType;
private int questId;
@Deprecated // Morhpia
public MapMark() {
this.mapMarkPointType = MapMarkPointType.MAP_MARK_POINT_TYPE_MONSTER;
this.mapMarkFromType = MapMarkFromType.MAP_MARK_FROM_TYPE_MONSTER;
this.mapMarkPointType = MapMarkPointType.MAP_MARK_POINT_TYPE_MONSTER;
this.mapMarkFromType = MapMarkFromType.MAP_MARK_FROM_TYPE_MONSTER;
}
public MapMark(MapMarkPoint mapMarkPoint) {
@ -35,28 +35,28 @@ public class MapMark {
public int getSceneId() {
return this.sceneId;
}
public String getName() {
return this.name;
}
public Position getPosition() {
return this.position;
}
public MapMarkPointType getMapMarkPointType() {
return this.mapMarkPointType;
}
public int getMonsterId() {
return this.monsterId;
}
public MapMarkFromType getMapMarkFromType() {
return this.mapMarkFromType;
}
public int getQuestId() {
return this.questId;
}
}
}

View File

@ -181,7 +181,7 @@ public class GameQuest {
}
return false;
}
public void save() {
getMainQuest().save();
}

View File

@ -313,20 +313,20 @@ public class QuestManager extends BasePlayerManager {
}
public void loadFromDatabase() {
List<GameMainQuest> quests = DatabaseHelper.getAllQuests(getPlayer());
for (GameMainQuest mainQuest : quests) {
boolean cancelAdd = false;
mainQuest.setOwner(this.getPlayer());
for (GameQuest quest : mainQuest.getChildQuests().values()) {
QuestData questConfig = GameData.getQuestDataMap().get(quest.getSubQuestId());
if (questConfig == null) {
mainQuest.delete();
cancelAdd = true;
break;
}
quest.setMainQuest(mainQuest);
quest.setConfig(questConfig);
}

View File

@ -13,7 +13,7 @@ public interface Router {
* @param javalin A Javalin instance.
*/
void applyRoutes(Javalin javalin);
/**
* Applies this handler to all endpoint types
* @param javalin A Javalin instance.

View File

@ -15,12 +15,12 @@ import emu.grasscutter.server.packet.send.PacketMusicGameSettleRsp;
@Opcodes(PacketOpcodes.MusicGameSettleReq)
public class HandlerMusicGameSettleReq extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
var req = MusicGameSettleReqOuterClass.MusicGameSettleReq.parseFrom(payload);
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
var req = MusicGameSettleReqOuterClass.MusicGameSettleReq.parseFrom(payload);
var playerData = session.getPlayer().getActivityManager().getPlayerActivityDataByActivityType(ActivityType.NEW_ACTIVITY_MUSIC_GAME);
if(playerData.isEmpty()){
if (playerData.isEmpty()) {
return;
}
var handler = (MusicGameActivityHandler) playerData.get().getActivityHandler();
@ -32,7 +32,7 @@ public class HandlerMusicGameSettleReq extends PacketHandler {
// Probably was an issue in 2.8 but was discovered in 3.0 port.
// - Benj
/*if(req.getMusicShareId() == 0){
/*if (req.getMusicShareId() == 0) {
session.getPlayer().getActivityManager().triggerWatcher(
WatcherTriggerType.TRIGGER_FLEUR_FAIR_MUSIC_GAME_REACH_SCORE,
String.valueOf(req.getMusicBasicId()),
@ -48,7 +48,7 @@ public class HandlerMusicGameSettleReq extends PacketHandler {
// update activity info
session.send(new PacketActivityInfoNotify(handler.toProto(playerData.get())));
}else{
}else {
handler.setMusicGameCustomBeatmapRecord(playerData.get(),
MusicGamePlayerData.CustomBeatmapRecord.of()
.musicShareId(req.getMusicShareId())
@ -58,7 +58,7 @@ public class HandlerMusicGameSettleReq extends PacketHandler {
}
session.send(new PacketMusicGameSettleRsp(req.getMusicBasicId(), req.getMusicShareId(), isNewRecord));*/
}
session.send(new PacketMusicGameSettleRsp(req.getMusicBasicId(), req.getMusicShareId(), isNewRecord));*/
}
}

View File

@ -13,24 +13,24 @@ import emu.grasscutter.utils.Position;
@Opcodes(PacketOpcodes.PersonalSceneJumpReq)
public class HandlerPersonalSceneJumpReq extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
PersonalSceneJumpReq req = PersonalSceneJumpReq.parseFrom(payload);
var player = session.getPlayer();
// get the scene point
String code = player.getSceneId() + "_" + req.getPointId();
ScenePointEntry scenePointEntry = GameData.getScenePointEntries().get(code);
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
PersonalSceneJumpReq req = PersonalSceneJumpReq.parseFrom(payload);
var player = session.getPlayer();
if (scenePointEntry != null) {
Position pos = scenePointEntry.getPointData().getTranPos().clone(); // This might not need cloning
int sceneId = scenePointEntry.getPointData().getTranSceneId();
// get the scene point
String code = player.getSceneId() + "_" + req.getPointId();
ScenePointEntry scenePointEntry = GameData.getScenePointEntries().get(code);
player.getWorld().transferPlayerToScene(player, sceneId, pos);
session.send(new PacketPersonalSceneJumpRsp(sceneId, pos));
}
if (scenePointEntry != null) {
Position pos = scenePointEntry.getPointData().getTranPos().clone(); // This might not need cloning
int sceneId = scenePointEntry.getPointData().getTranSceneId();
}
player.getWorld().transferPlayerToScene(player, sceneId, pos);
session.send(new PacketPersonalSceneJumpRsp(sceneId, pos));
}
}
}

View File

@ -12,7 +12,7 @@ public class PacketAddCustomTeamRsp extends BasePacket {
AddCustomTeamRsp proto = AddCustomTeamRsp.newBuilder()
.setRetcode(retcode.getNumber())
.build();
this.setData(proto);
}

View File

@ -11,17 +11,17 @@ import emu.grasscutter.net.proto.AvatarTeamOuterClass.AvatarTeam;
import emu.grasscutter.net.proto.AvatarTeamUpdateNotifyOuterClass.AvatarTeamUpdateNotify;
public class PacketAvatarTeamUpdateNotify extends BasePacket {
public PacketAvatarTeamUpdateNotify(Player player) {
super(PacketOpcodes.AvatarTeamUpdateNotify);
AvatarTeamUpdateNotify.Builder proto = AvatarTeamUpdateNotify.newBuilder();
for (Entry<Integer, TeamInfo> entry : player.getTeamManager().getTeams().entrySet()) {
TeamInfo teamInfo = entry.getValue();
proto.putAvatarTeamMap(entry.getKey(), teamInfo.toProto(player));
}
this.setData(proto);
}
public PacketAvatarTeamUpdateNotify(Player player) {
super(PacketOpcodes.AvatarTeamUpdateNotify);
AvatarTeamUpdateNotify.Builder proto = AvatarTeamUpdateNotify.newBuilder();
for (Entry<Integer, TeamInfo> entry : player.getTeamManager().getTeams().entrySet()) {
TeamInfo teamInfo = entry.getValue();
proto.putAvatarTeamMap(entry.getKey(), teamInfo.toProto(player));
}
this.setData(proto);
}
}

View File

@ -17,33 +17,33 @@ import java.util.List;
public class PacketCreateVehicleRsp extends BasePacket {
public PacketCreateVehicleRsp(Player player, int vehicleId, int pointId, Position pos, Position rot) {
super(PacketOpcodes.CreateVehicleRsp);
CreateVehicleRsp.Builder proto = CreateVehicleRsp.newBuilder();
public PacketCreateVehicleRsp(Player player, int vehicleId, int pointId, Position pos, Position rot) {
super(PacketOpcodes.CreateVehicleRsp);
CreateVehicleRsp.Builder proto = CreateVehicleRsp.newBuilder();
// Eject vehicle members and Kill previous vehicles if there are any
List<GameEntity> previousVehicles = player.getScene().getEntities().values().stream()
.filter(entity -> entity instanceof EntityVehicle
&& ((EntityVehicle) entity).getGadgetId() == vehicleId
&& ((EntityVehicle) entity).getOwner().equals(player))
.toList();
// Eject vehicle members and Kill previous vehicles if there are any
List<GameEntity> previousVehicles = player.getScene().getEntities().values().stream()
.filter(entity -> entity instanceof EntityVehicle
&& ((EntityVehicle) entity).getGadgetId() == vehicleId
&& ((EntityVehicle) entity).getOwner().equals(player))
.toList();
previousVehicles.stream().forEach(entity -> {
List<VehicleMember> vehicleMembers = ((EntityVehicle) entity).getVehicleMembers().stream().toList();
previousVehicles.stream().forEach(entity -> {
List<VehicleMember> vehicleMembers = ((EntityVehicle) entity).getVehicleMembers().stream().toList();
vehicleMembers.stream().forEach(vehicleMember -> {
player.getScene().broadcastPacket(new PacketVehicleInteractRsp(((EntityVehicle) entity), vehicleMember, VehicleInteractTypeOuterClass.VehicleInteractType.VEHICLE_INTERACT_TYPE_OUT));
});
vehicleMembers.stream().forEach(vehicleMember -> {
player.getScene().broadcastPacket(new PacketVehicleInteractRsp(((EntityVehicle) entity), vehicleMember, VehicleInteractTypeOuterClass.VehicleInteractType.VEHICLE_INTERACT_TYPE_OUT));
});
player.getScene().killEntity(entity, 0);
});
player.getScene().killEntity(entity, 0);
});
EntityVehicle vehicle = new EntityVehicle(player.getScene(), player, vehicleId, pointId, pos, rot);
player.getScene().addEntity(vehicle);
EntityVehicle vehicle = new EntityVehicle(player.getScene(), player, vehicleId, pointId, pos, rot);
player.getScene().addEntity(vehicle);
proto.setVehicleId(vehicleId);
proto.setEntityId(vehicle.getId());
proto.setVehicleId(vehicleId);
proto.setEntityId(vehicle.getId());
this.setData(proto.build());
}
this.setData(proto.build());
}
}

View File

@ -28,7 +28,7 @@ public class PacketCustomTeamListNotify extends BasePacket {
TeamInfo teamInfo = entry.getValue();
proto.putAvatarTeamMap(entry.getKey(), teamInfo.toProto(player));
}
this.setData(proto);
}
}

View File

@ -13,7 +13,7 @@ public class PacketRemoveCustomTeamRsp extends BasePacket {
.setRetcode(retcode.getNumber())
.setId(id)
.build();
this.setData(proto);
}