mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-02-02 19:12:53 +08:00
Fix whitespace [skip actions]
This commit is contained in:
parent
005a0bce96
commit
6e5d986687
@ -225,7 +225,7 @@ public final class CommandMap {
|
|||||||
Grasscutter.getLogger().info("Command used by server console: " + rawMessage);
|
Grasscutter.getLogger().info("Command used by server console: " + rawMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rawMessage = rawMessage.trim();
|
rawMessage = rawMessage.trim();
|
||||||
if (rawMessage.length() == 0) {
|
if (rawMessage.length() == 0) {
|
||||||
CommandHandler.sendTranslatedMessage(player, "commands.generic.not_specified");
|
CommandHandler.sendTranslatedMessage(player, "commands.generic.not_specified");
|
||||||
|
@ -96,7 +96,7 @@ public class ConfigContainer {
|
|||||||
public Set<Integer> debugBlacklist = Set.of();
|
public Set<Integer> debugBlacklist = Set.of();
|
||||||
public ServerRunMode runMode = ServerRunMode.HYBRID;
|
public ServerRunMode runMode = ServerRunMode.HYBRID;
|
||||||
public boolean logCommands = false;
|
public boolean logCommands = false;
|
||||||
|
|
||||||
public HTTP http = new HTTP();
|
public HTTP http = new HTTP();
|
||||||
public Game game = new Game();
|
public Game game = new Game();
|
||||||
|
|
||||||
|
@ -10,71 +10,71 @@ import it.unimi.dsi.fastutil.ints.IntArrayList;
|
|||||||
import it.unimi.dsi.fastutil.ints.IntList;
|
import it.unimi.dsi.fastutil.ints.IntList;
|
||||||
|
|
||||||
public class PointData {
|
public class PointData {
|
||||||
private int id;
|
private int id;
|
||||||
private String $type;
|
private String $type;
|
||||||
private Position tranPos;
|
private Position tranPos;
|
||||||
|
|
||||||
@SerializedName(value="dungeonIds", alternate={"JHHFPGJNMIN"})
|
@SerializedName(value="dungeonIds", alternate={"JHHFPGJNMIN"})
|
||||||
private int[] dungeonIds;
|
private int[] dungeonIds;
|
||||||
|
|
||||||
@SerializedName(value="dungeonRandomList", alternate={"OIBKFJNBLHO"})
|
@SerializedName(value="dungeonRandomList", alternate={"OIBKFJNBLHO"})
|
||||||
private int[] dungeonRandomList;
|
private int[] dungeonRandomList;
|
||||||
|
|
||||||
@SerializedName(value="tranSceneId", alternate={"JHBICGBAPIH"})
|
@SerializedName(value="tranSceneId", alternate={"JHBICGBAPIH"})
|
||||||
private int tranSceneId;
|
private int tranSceneId;
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(int id) {
|
public void setId(int id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return $type;
|
return $type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Position getTranPos() {
|
public Position getTranPos() {
|
||||||
return tranPos;
|
return tranPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int[] getDungeonIds() {
|
public int[] getDungeonIds() {
|
||||||
return dungeonIds;
|
return dungeonIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int[] getDungeonRandomList() {
|
public int[] getDungeonRandomList() {
|
||||||
return dungeonRandomList;
|
return dungeonRandomList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTranSceneId() {
|
public int getTranSceneId() {
|
||||||
return tranSceneId;
|
return tranSceneId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTranSceneId(int tranSceneId) {
|
public void setTranSceneId(int tranSceneId) {
|
||||||
this.tranSceneId = tranSceneId;
|
this.tranSceneId = tranSceneId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateDailyDungeon() {
|
public void updateDailyDungeon() {
|
||||||
if (getDungeonRandomList() == null || getDungeonRandomList().length == 0) {
|
if (getDungeonRandomList() == null || getDungeonRandomList().length == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IntList newDungeons = new IntArrayList();
|
IntList newDungeons = new IntArrayList();
|
||||||
int day = Grasscutter.getCurrentDayOfWeek();
|
int day = Grasscutter.getCurrentDayOfWeek();
|
||||||
|
|
||||||
for (int randomId : getDungeonRandomList()) {
|
for (int randomId : getDungeonRandomList()) {
|
||||||
DailyDungeonData data = GameData.getDailyDungeonDataMap().get(randomId);
|
DailyDungeonData data = GameData.getDailyDungeonDataMap().get(randomId);
|
||||||
|
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
int[] addDungeons = data.getDungeonsByDay(day);
|
int[] addDungeons = data.getDungeonsByDay(day);
|
||||||
|
|
||||||
for (int d : addDungeons) {
|
for (int d : addDungeons) {
|
||||||
newDungeons.add(d);
|
newDungeons.add(d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.dungeonIds = newDungeons.toIntArray();
|
this.dungeonIds = newDungeons.toIntArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,30 +6,30 @@ import emu.grasscutter.data.ResourceType;
|
|||||||
|
|
||||||
@ResourceType(name = "AvatarCostumeExcelConfigData.json")
|
@ResourceType(name = "AvatarCostumeExcelConfigData.json")
|
||||||
public class AvatarCostumeData extends GameResource {
|
public class AvatarCostumeData extends GameResource {
|
||||||
private int costumeId;
|
private int costumeId;
|
||||||
private int itemId;
|
private int itemId;
|
||||||
private int characterId;
|
private int characterId;
|
||||||
private int quality;
|
private int quality;
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getId() {
|
|
||||||
return this.costumeId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getItemId() {
|
|
||||||
return this.itemId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCharacterId() {
|
@Override
|
||||||
return characterId;
|
public int getId() {
|
||||||
}
|
return this.costumeId;
|
||||||
|
}
|
||||||
public int getQuality() {
|
|
||||||
|
public int getItemId() {
|
||||||
|
return this.itemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCharacterId() {
|
||||||
|
return characterId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getQuality() {
|
||||||
return quality;
|
return quality;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
GameData.getAvatarCostumeDataItemIdMap().put(this.getItemId(), this);
|
GameData.getAvatarCostumeDataItemIdMap().put(this.getItemId(), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,52 +8,52 @@ import emu.grasscutter.data.common.FightPropData;
|
|||||||
@ResourceType(name = "EquipAffixExcelConfigData.json")
|
@ResourceType(name = "EquipAffixExcelConfigData.json")
|
||||||
public class EquipAffixData extends GameResource {
|
public class EquipAffixData extends GameResource {
|
||||||
|
|
||||||
private int affixId;
|
private int affixId;
|
||||||
private int id;
|
private int id;
|
||||||
private int level;
|
private int level;
|
||||||
private long nameTextMapHash;
|
private long nameTextMapHash;
|
||||||
private String openConfig;
|
private String openConfig;
|
||||||
private FightPropData[] addProps;
|
private FightPropData[] addProps;
|
||||||
private float[] paramList;
|
private float[] paramList;
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getId() {
|
|
||||||
return affixId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMainId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getLevel() {
|
@Override
|
||||||
return level;
|
public int getId() {
|
||||||
}
|
return affixId;
|
||||||
|
}
|
||||||
|
|
||||||
public long getNameTextMapHash() {
|
public int getMainId() {
|
||||||
return nameTextMapHash;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getOpenConfig() {
|
public int getLevel() {
|
||||||
return openConfig;
|
return level;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FightPropData[] getAddProps() {
|
public long getNameTextMapHash() {
|
||||||
return addProps;
|
return nameTextMapHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float[] getParamList() {
|
public String getOpenConfig() {
|
||||||
return paramList;
|
return openConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public FightPropData[] getAddProps() {
|
||||||
public void onLoad() {
|
return addProps;
|
||||||
ArrayList<FightPropData> parsed = new ArrayList<FightPropData>(getAddProps().length);
|
}
|
||||||
for (FightPropData prop : getAddProps()) {
|
|
||||||
if (prop.getPropType() != null && prop.getValue() != 0f) {
|
public float[] getParamList() {
|
||||||
prop.onLoad();
|
return paramList;
|
||||||
parsed.add(prop);
|
}
|
||||||
}
|
|
||||||
}
|
@Override
|
||||||
this.addProps = parsed.toArray(new FightPropData[parsed.size()]);
|
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()]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ public class ItemData extends GameResource {
|
|||||||
if (this.getFurnitureGadgetID() != null) {
|
if (this.getFurnitureGadgetID() != null) {
|
||||||
this.furnitureGadgetID = this.furnitureGadgetID.stream().filter(x -> x > 0).toList();
|
this.furnitureGadgetID = this.furnitureGadgetID.stream().filter(x -> x > 0).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prevent material type from being null
|
// Prevent material type from being null
|
||||||
this.materialType = this.materialType == null ? MaterialType.MATERIAL_NONE : this.materialType;
|
this.materialType = this.materialType == null ? MaterialType.MATERIAL_NONE : this.materialType;
|
||||||
}
|
}
|
||||||
|
@ -7,27 +7,27 @@ import emu.grasscutter.data.ResourceType;
|
|||||||
|
|
||||||
@ResourceType(name = "ReliquarySetExcelConfigData.json")
|
@ResourceType(name = "ReliquarySetExcelConfigData.json")
|
||||||
public class ReliquarySetData extends GameResource {
|
public class ReliquarySetData extends GameResource {
|
||||||
private int setId;
|
private int setId;
|
||||||
private int[] setNeedNum;
|
private int[] setNeedNum;
|
||||||
|
|
||||||
@SerializedName(value="equipAffixId", alternate={"EquipAffixId"})
|
@SerializedName(value="equipAffixId", alternate={"EquipAffixId"})
|
||||||
private int equipAffixId;
|
private int equipAffixId;
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getId() {
|
|
||||||
return setId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int[] getSetNeedNum() {
|
|
||||||
return setNeedNum;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getEquipAffixId() {
|
@Override
|
||||||
return equipAffixId;
|
public int getId() {
|
||||||
}
|
return setId;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
public int[] getSetNeedNum() {
|
||||||
public void onLoad() {
|
return setNeedNum;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
public int getEquipAffixId() {
|
||||||
|
return equipAffixId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoad() {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,103 +25,103 @@ import emu.grasscutter.game.quest.GameMainQuest;
|
|||||||
import static com.mongodb.client.model.Filters.eq;
|
import static com.mongodb.client.model.Filters.eq;
|
||||||
|
|
||||||
public final class DatabaseHelper {
|
public final class DatabaseHelper {
|
||||||
public static Account createAccount(String username) {
|
public static Account createAccount(String username) {
|
||||||
return createAccountWithUid(username, 0);
|
return createAccountWithUid(username, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Account createAccountWithUid(String username, int reservedUid) {
|
public static Account createAccountWithUid(String username, int reservedUid) {
|
||||||
// Unique names only
|
// Unique names only
|
||||||
if (DatabaseHelper.checkIfAccountExists(username)) {
|
if (DatabaseHelper.checkIfAccountExists(username)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure there are no id collisions
|
// Make sure there are no id collisions
|
||||||
if (reservedUid > 0) {
|
if (reservedUid > 0) {
|
||||||
// Cannot make account with the same uid as the server console
|
// Cannot make account with the same uid as the server console
|
||||||
if (reservedUid == GameConstants.SERVER_CONSOLE_UID) {
|
if (reservedUid == GameConstants.SERVER_CONSOLE_UID) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DatabaseHelper.checkIfAccountExists(reservedUid)) {
|
if (DatabaseHelper.checkIfAccountExists(reservedUid)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure no existing player already has this id.
|
// Make sure no existing player already has this id.
|
||||||
if (DatabaseHelper.checkIfPlayerExists(reservedUid)) {
|
if (DatabaseHelper.checkIfPlayerExists(reservedUid)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Account
|
// Account
|
||||||
Account account = new Account();
|
Account account = new Account();
|
||||||
account.setUsername(username);
|
account.setUsername(username);
|
||||||
account.setId(Integer.toString(DatabaseManager.getNextId(account)));
|
account.setId(Integer.toString(DatabaseManager.getNextId(account)));
|
||||||
|
|
||||||
if (reservedUid > 0) {
|
if (reservedUid > 0) {
|
||||||
account.setReservedPlayerUid(reservedUid);
|
account.setReservedPlayerUid(reservedUid);
|
||||||
}
|
}
|
||||||
|
|
||||||
DatabaseHelper.saveAccount(account);
|
DatabaseHelper.saveAccount(account);
|
||||||
return account;
|
return account;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static Account createAccountWithPassword(String username, String password) {
|
public static Account createAccountWithPassword(String username, String password) {
|
||||||
// Unique names only
|
// Unique names only
|
||||||
Account exists = DatabaseHelper.getAccountByName(username);
|
Account exists = DatabaseHelper.getAccountByName(username);
|
||||||
if (exists != null) {
|
if (exists != null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Account
|
// Account
|
||||||
Account account = new Account();
|
Account account = new Account();
|
||||||
account.setId(Integer.toString(DatabaseManager.getNextId(account)));
|
account.setId(Integer.toString(DatabaseManager.getNextId(account)));
|
||||||
account.setUsername(username);
|
account.setUsername(username);
|
||||||
account.setPassword(password);
|
account.setPassword(password);
|
||||||
DatabaseHelper.saveAccount(account);
|
DatabaseHelper.saveAccount(account);
|
||||||
return account;
|
return account;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void saveAccount(Account account) {
|
public static void saveAccount(Account account) {
|
||||||
DatabaseManager.getAccountDatastore().save(account);
|
DatabaseManager.getAccountDatastore().save(account);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Account getAccountByName(String username) {
|
public static Account getAccountByName(String username) {
|
||||||
return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("username", username)).first();
|
return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("username", username)).first();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Account getAccountByToken(String token) {
|
public static Account getAccountByToken(String token) {
|
||||||
if(token == null) return null;
|
if (token == null) return null;
|
||||||
return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("token", token)).first();
|
return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("token", token)).first();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Account getAccountBySessionKey(String sessionKey) {
|
public static Account getAccountBySessionKey(String sessionKey) {
|
||||||
if(sessionKey == null) return null;
|
if (sessionKey == null) return null;
|
||||||
return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("sessionKey", sessionKey)).first();
|
return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("sessionKey", sessionKey)).first();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Account getAccountById(String uid) {
|
public static Account getAccountById(String uid) {
|
||||||
return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("_id", uid)).first();
|
return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("_id", uid)).first();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Account getAccountByPlayerId(int playerId) {
|
public static Account getAccountByPlayerId(int playerId) {
|
||||||
return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("reservedPlayerId", playerId)).first();
|
return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("reservedPlayerId", playerId)).first();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkIfAccountExists(String name) {
|
public static boolean checkIfAccountExists(String name) {
|
||||||
return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("username", name)).count() > 0;
|
return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("username", name)).count() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkIfAccountExists(int reservedUid) {
|
public static boolean checkIfAccountExists(int reservedUid) {
|
||||||
return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("reservedPlayerId", reservedUid)).count() > 0;
|
return DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("reservedPlayerId", reservedUid)).count() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized void deleteAccount(Account target) {
|
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.
|
// 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
|
// 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 ...
|
// 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
|
// Close session first
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
@ -152,187 +152,187 @@ public final class DatabaseHelper {
|
|||||||
|
|
||||||
// Finally, delete the account itself.
|
// Finally, delete the account itself.
|
||||||
DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("id", target.getId())).delete();
|
DatabaseManager.getAccountDatastore().find(Account.class).filter(Filters.eq("id", target.getId())).delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Player> getAllPlayers() {
|
public static List<Player> getAllPlayers() {
|
||||||
return DatabaseManager.getGameDatastore().find(Player.class).stream().toList();
|
return DatabaseManager.getGameDatastore().find(Player.class).stream().toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Player getPlayerByUid(int id) {
|
public static Player getPlayerByUid(int id) {
|
||||||
return DatabaseManager.getGameDatastore().find(Player.class).filter(Filters.eq("_id", id)).first();
|
return DatabaseManager.getGameDatastore().find(Player.class).filter(Filters.eq("_id", id)).first();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static Player getPlayerByAccount(Account account) {
|
public static Player getPlayerByAccount(Account account) {
|
||||||
return DatabaseManager.getGameDatastore().find(Player.class).filter(Filters.eq("accountId", account.getId())).first();
|
return DatabaseManager.getGameDatastore().find(Player.class).filter(Filters.eq("accountId", account.getId())).first();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Player getPlayerByAccount(Account account, Class<? extends Player> playerClass) {
|
public static Player getPlayerByAccount(Account account, Class<? extends Player> playerClass) {
|
||||||
return DatabaseManager.getGameDatastore().find(playerClass).filter(Filters.eq("accountId", account.getId())).first();
|
return DatabaseManager.getGameDatastore().find(playerClass).filter(Filters.eq("accountId", account.getId())).first();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkIfPlayerExists(int uid) {
|
public static boolean checkIfPlayerExists(int uid) {
|
||||||
return DatabaseManager.getGameDatastore().find(Player.class).filter(Filters.eq("_id", uid)).count() > 0;
|
return DatabaseManager.getGameDatastore().find(Player.class).filter(Filters.eq("_id", uid)).count() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized Player generatePlayerUid(Player character, int reservedId) {
|
public static synchronized Player generatePlayerUid(Player character, int reservedId) {
|
||||||
// Check if reserved id
|
// Check if reserved id
|
||||||
int id;
|
int id;
|
||||||
if (reservedId > 0 && !checkIfPlayerExists(reservedId)) {
|
if (reservedId > 0 && !checkIfPlayerExists(reservedId)) {
|
||||||
id = reservedId;
|
id = reservedId;
|
||||||
character.setUid(id);
|
character.setUid(id);
|
||||||
} else {
|
} else {
|
||||||
do {
|
do {
|
||||||
id = DatabaseManager.getNextId(character);
|
id = DatabaseManager.getNextId(character);
|
||||||
}
|
}
|
||||||
while (checkIfPlayerExists(id));
|
while (checkIfPlayerExists(id));
|
||||||
character.setUid(id);
|
character.setUid(id);
|
||||||
}
|
}
|
||||||
// Save to database
|
// Save to database
|
||||||
DatabaseManager.getGameDatastore().save(character);
|
DatabaseManager.getGameDatastore().save(character);
|
||||||
return character;
|
return character;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized int getNextPlayerId(int reservedId) {
|
public static synchronized int getNextPlayerId(int reservedId) {
|
||||||
// Check if reserved id
|
// Check if reserved id
|
||||||
int id;
|
int id;
|
||||||
if (reservedId > 0 && !checkIfPlayerExists(reservedId)) {
|
if (reservedId > 0 && !checkIfPlayerExists(reservedId)) {
|
||||||
id = reservedId;
|
id = reservedId;
|
||||||
} else {
|
} else {
|
||||||
do {
|
do {
|
||||||
id = DatabaseManager.getNextId(Player.class);
|
id = DatabaseManager.getNextId(Player.class);
|
||||||
}
|
}
|
||||||
while (checkIfPlayerExists(id));
|
while (checkIfPlayerExists(id));
|
||||||
}
|
}
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void savePlayer(Player character) {
|
public static void savePlayer(Player character) {
|
||||||
DatabaseManager.getGameDatastore().save(character);
|
DatabaseManager.getGameDatastore().save(character);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void saveAvatar(Avatar avatar) {
|
public static void saveAvatar(Avatar avatar) {
|
||||||
DatabaseManager.getGameDatastore().save(avatar);
|
DatabaseManager.getGameDatastore().save(avatar);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Avatar> getAvatars(Player player) {
|
public static List<Avatar> getAvatars(Player player) {
|
||||||
return DatabaseManager.getGameDatastore().find(Avatar.class).filter(Filters.eq("ownerId", player.getUid())).stream().toList();
|
return DatabaseManager.getGameDatastore().find(Avatar.class).filter(Filters.eq("ownerId", player.getUid())).stream().toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void saveItem(GameItem item) {
|
public static void saveItem(GameItem item) {
|
||||||
DatabaseManager.getGameDatastore().save(item);
|
DatabaseManager.getGameDatastore().save(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean deleteItem(GameItem item) {
|
public static boolean deleteItem(GameItem item) {
|
||||||
DeleteResult result = DatabaseManager.getGameDatastore().delete(item);
|
DeleteResult result = DatabaseManager.getGameDatastore().delete(item);
|
||||||
return result.wasAcknowledged();
|
return result.wasAcknowledged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<GameItem> getInventoryItems(Player player) {
|
public static List<GameItem> getInventoryItems(Player player) {
|
||||||
return DatabaseManager.getGameDatastore().find(GameItem.class).filter(Filters.eq("ownerId", player.getUid())).stream().toList();
|
return DatabaseManager.getGameDatastore().find(GameItem.class).filter(Filters.eq("ownerId", player.getUid())).stream().toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Friendship> getFriends(Player player) {
|
public static List<Friendship> getFriends(Player player) {
|
||||||
return DatabaseManager.getGameDatastore().find(Friendship.class).filter(Filters.eq("ownerId", player.getUid())).stream().toList();
|
return DatabaseManager.getGameDatastore().find(Friendship.class).filter(Filters.eq("ownerId", player.getUid())).stream().toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Friendship> getReverseFriends(Player player) {
|
public static List<Friendship> getReverseFriends(Player player) {
|
||||||
return DatabaseManager.getGameDatastore().find(Friendship.class).filter(Filters.eq("friendId", player.getUid())).stream().toList();
|
return DatabaseManager.getGameDatastore().find(Friendship.class).filter(Filters.eq("friendId", player.getUid())).stream().toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void saveFriendship(Friendship friendship) {
|
public static void saveFriendship(Friendship friendship) {
|
||||||
DatabaseManager.getGameDatastore().save(friendship);
|
DatabaseManager.getGameDatastore().save(friendship);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void deleteFriendship(Friendship friendship) {
|
public static void deleteFriendship(Friendship friendship) {
|
||||||
DatabaseManager.getGameDatastore().delete(friendship);
|
DatabaseManager.getGameDatastore().delete(friendship);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Friendship getReverseFriendship(Friendship friendship) {
|
public static Friendship getReverseFriendship(Friendship friendship) {
|
||||||
return DatabaseManager.getGameDatastore().find(Friendship.class).filter(Filters.and(
|
return DatabaseManager.getGameDatastore().find(Friendship.class).filter(Filters.and(
|
||||||
Filters.eq("ownerId", friendship.getFriendId()),
|
Filters.eq("ownerId", friendship.getFriendId()),
|
||||||
Filters.eq("friendId", friendship.getOwnerId())
|
Filters.eq("friendId", friendship.getOwnerId())
|
||||||
)).first();
|
)).first();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<GachaRecord> getGachaRecords(int ownerId, int page, int gachaType){
|
public static List<GachaRecord> getGachaRecords(int ownerId, int page, int gachaType) {
|
||||||
return getGachaRecords(ownerId, page, gachaType, 10);
|
return getGachaRecords(ownerId, page, gachaType, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<GachaRecord> getGachaRecords(int ownerId, int page, int gachaType, int pageSize){
|
public static List<GachaRecord> getGachaRecords(int ownerId, int page, int gachaType, int pageSize) {
|
||||||
return DatabaseManager.getGameDatastore().find(GachaRecord.class).filter(
|
return DatabaseManager.getGameDatastore().find(GachaRecord.class).filter(
|
||||||
Filters.eq("ownerId", ownerId),
|
Filters.eq("ownerId", ownerId),
|
||||||
Filters.eq("gachaType", gachaType)
|
Filters.eq("gachaType", gachaType)
|
||||||
).iterator(new FindOptions()
|
).iterator(new FindOptions()
|
||||||
.sort(Sort.descending("transactionDate"))
|
.sort(Sort.descending("transactionDate"))
|
||||||
.skip(pageSize * page)
|
.skip(pageSize * page)
|
||||||
.limit(pageSize)
|
.limit(pageSize)
|
||||||
).toList();
|
).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long getGachaRecordsMaxPage(int ownerId, int page, int gachaType){
|
public static long getGachaRecordsMaxPage(int ownerId, int page, int gachaType) {
|
||||||
return getGachaRecordsMaxPage(ownerId, page, gachaType, 10);
|
return getGachaRecordsMaxPage(ownerId, page, gachaType, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long getGachaRecordsMaxPage(int ownerId, int page, int gachaType, int pageSize){
|
public static long getGachaRecordsMaxPage(int ownerId, int page, int gachaType, int pageSize) {
|
||||||
long count = DatabaseManager.getGameDatastore().find(GachaRecord.class).filter(
|
long count = DatabaseManager.getGameDatastore().find(GachaRecord.class).filter(
|
||||||
Filters.eq("ownerId", ownerId),
|
Filters.eq("ownerId", ownerId),
|
||||||
Filters.eq("gachaType", gachaType)
|
Filters.eq("gachaType", gachaType)
|
||||||
).count();
|
).count();
|
||||||
return count / 10 + (count % 10 > 0 ? 1 : 0 );
|
return count / 10 + (count % 10 > 0 ? 1 : 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void saveGachaRecord(GachaRecord gachaRecord){
|
public static void saveGachaRecord(GachaRecord gachaRecord) {
|
||||||
DatabaseManager.getGameDatastore().save(gachaRecord);
|
DatabaseManager.getGameDatastore().save(gachaRecord);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Mail> getAllMail(Player player) {
|
public static List<Mail> getAllMail(Player player) {
|
||||||
return DatabaseManager.getGameDatastore().find(Mail.class).filter(Filters.eq("ownerUid", player.getUid())).stream().toList();
|
return DatabaseManager.getGameDatastore().find(Mail.class).filter(Filters.eq("ownerUid", player.getUid())).stream().toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void saveMail(Mail mail) {
|
public static void saveMail(Mail mail) {
|
||||||
DatabaseManager.getGameDatastore().save(mail);
|
DatabaseManager.getGameDatastore().save(mail);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean deleteMail(Mail mail) {
|
public static boolean deleteMail(Mail mail) {
|
||||||
DeleteResult result = DatabaseManager.getGameDatastore().delete(mail);
|
DeleteResult result = DatabaseManager.getGameDatastore().delete(mail);
|
||||||
return result.wasAcknowledged();
|
return result.wasAcknowledged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<GameMainQuest> getAllQuests(Player player) {
|
public static List<GameMainQuest> getAllQuests(Player player) {
|
||||||
return DatabaseManager.getGameDatastore().find(GameMainQuest.class).filter(Filters.eq("ownerUid", player.getUid())).stream().toList();
|
return DatabaseManager.getGameDatastore().find(GameMainQuest.class).filter(Filters.eq("ownerUid", player.getUid())).stream().toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void saveQuest(GameMainQuest quest) {
|
public static void saveQuest(GameMainQuest quest) {
|
||||||
DatabaseManager.getGameDatastore().save(quest);
|
DatabaseManager.getGameDatastore().save(quest);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean deleteQuest(GameMainQuest quest) {
|
public static boolean deleteQuest(GameMainQuest quest) {
|
||||||
return DatabaseManager.getGameDatastore().delete(quest).wasAcknowledged();
|
return DatabaseManager.getGameDatastore().delete(quest).wasAcknowledged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GameHome getHomeByUid(int id) {
|
public static GameHome getHomeByUid(int id) {
|
||||||
return DatabaseManager.getGameDatastore().find(GameHome.class).filter(Filters.eq("ownerUid", id)).first();
|
return DatabaseManager.getGameDatastore().find(GameHome.class).filter(Filters.eq("ownerUid", id)).first();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void saveHome(GameHome gameHome) {
|
public static void saveHome(GameHome gameHome) {
|
||||||
DatabaseManager.getGameDatastore().save(gameHome);
|
DatabaseManager.getGameDatastore().save(gameHome);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BattlePassManager loadBattlePass(Player player) {
|
public static BattlePassManager loadBattlePass(Player player) {
|
||||||
BattlePassManager manager = DatabaseManager.getGameDatastore().find(BattlePassManager.class).filter(Filters.eq("ownerUid", player.getUid())).first();
|
BattlePassManager manager = DatabaseManager.getGameDatastore().find(BattlePassManager.class).filter(Filters.eq("ownerUid", player.getUid())).first();
|
||||||
if (manager == null) {
|
if (manager == null) {
|
||||||
manager = new BattlePassManager(player);
|
manager = new BattlePassManager(player);
|
||||||
manager.save();
|
manager.save();
|
||||||
} else {
|
} else {
|
||||||
manager.setPlayer(player);
|
manager.setPlayer(player);
|
||||||
}
|
}
|
||||||
return manager;
|
return manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void saveBattlePass(BattlePassManager manager) {
|
public static void saveBattlePass(BattlePassManager manager) {
|
||||||
DatabaseManager.getGameDatastore().save(manager);
|
DatabaseManager.getGameDatastore().save(manager);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PlayerActivityData getPlayerActivityData(int uid, int activityId) {
|
public static PlayerActivityData getPlayerActivityData(int uid, int activityId) {
|
||||||
return DatabaseManager.getGameDatastore().find(PlayerActivityData.class)
|
return DatabaseManager.getGameDatastore().find(PlayerActivityData.class)
|
||||||
|
@ -600,7 +600,7 @@ public class Avatar {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addToExtraAbilityEmbryos(String openConfig) {
|
public void addToExtraAbilityEmbryos(String openConfig) {
|
||||||
this.addToExtraAbilityEmbryos(openConfig, false);
|
this.addToExtraAbilityEmbryos(openConfig, false);
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ public class EntityAvatar extends GameEntity {
|
|||||||
if (!this.isAlive()) {
|
if (!this.isAlive()) {
|
||||||
return 0f;
|
return 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
float healed = super.heal(amount);
|
float healed = super.heal(amount);
|
||||||
|
|
||||||
if (healed > 0f) {
|
if (healed > 0f) {
|
||||||
|
@ -16,66 +16,66 @@ import emu.grasscutter.server.packet.send.PacketGadgetInteractRsp;
|
|||||||
import emu.grasscutter.utils.Utils;
|
import emu.grasscutter.utils.Utils;
|
||||||
|
|
||||||
public class GadgetGatherObject extends GadgetContent {
|
public class GadgetGatherObject extends GadgetContent {
|
||||||
private int itemId;
|
private int itemId;
|
||||||
private boolean isForbidGuest;
|
private boolean isForbidGuest;
|
||||||
|
|
||||||
public GadgetGatherObject(EntityGadget gadget) {
|
|
||||||
super(gadget);
|
|
||||||
|
|
||||||
if (gadget.getSpawnEntry() != null) {
|
|
||||||
this.itemId = gadget.getSpawnEntry().getGatherItemId();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getItemId() {
|
|
||||||
return this.itemId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isForbidGuest() {
|
public GadgetGatherObject(EntityGadget gadget) {
|
||||||
return isForbidGuest;
|
super(gadget);
|
||||||
}
|
|
||||||
|
|
||||||
public boolean onInteract(Player player, GadgetInteractReq req) {
|
if (gadget.getSpawnEntry() != null) {
|
||||||
// Sanity check
|
this.itemId = gadget.getSpawnEntry().getGatherItemId();
|
||||||
ItemData itemData = GameData.getItemDataMap().get(getItemId());
|
}
|
||||||
if (itemData == null) {
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameItem item = new GameItem(itemData, 1);
|
public int getItemId() {
|
||||||
player.getInventory().addItem(item, ActionReason.Gather);
|
return this.itemId;
|
||||||
|
}
|
||||||
getGadget().getScene().broadcastPacket(new PacketGadgetInteractRsp(getGadget(), InteractType.INTERACT_TYPE_GATHER));
|
|
||||||
|
|
||||||
return true;
|
public boolean isForbidGuest() {
|
||||||
}
|
return isForbidGuest;
|
||||||
|
}
|
||||||
|
|
||||||
public void onBuildProto(SceneGadgetInfo.Builder gadgetInfo) {
|
public boolean onInteract(Player player, GadgetInteractReq req) {
|
||||||
GatherGadgetInfo gatherGadgetInfo = GatherGadgetInfo.newBuilder()
|
// Sanity check
|
||||||
.setItemId(this.getItemId())
|
ItemData itemData = GameData.getItemDataMap().get(getItemId());
|
||||||
.setIsForbidGuest(this.isForbidGuest())
|
if (itemData == null) {
|
||||||
.build();
|
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++) {
|
for (int i = 0 ; i < times ; i++) {
|
||||||
EntityItem item = new EntityItem(
|
EntityItem item = new EntityItem(
|
||||||
scene,
|
scene,
|
||||||
player,
|
player,
|
||||||
GameData.getItemDataMap().get(itemId),
|
GameData.getItemDataMap().get(itemId),
|
||||||
getGadget().getPosition().nearby2d(1f).addY(2f),
|
getGadget().getPosition().nearby2d(1f).addY(2f),
|
||||||
1,
|
1,
|
||||||
true);
|
true);
|
||||||
|
|
||||||
scene.addEntity(item);
|
scene.addEntity(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
scene.killEntity(this.getGadget(), player.getTeamManager().getCurrentAvatarEntity().getId());
|
scene.killEntity(this.getGadget(), player.getTeamManager().getCurrentAvatarEntity().getId());
|
||||||
// Todo: add record
|
// Todo: add record
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,50 +14,50 @@ import emu.grasscutter.net.proto.SceneGadgetInfoOuterClass.SceneGadgetInfo;
|
|||||||
import emu.grasscutter.utils.Utils;
|
import emu.grasscutter.utils.Utils;
|
||||||
|
|
||||||
public class GadgetGatherPoint extends GadgetContent {
|
public class GadgetGatherPoint extends GadgetContent {
|
||||||
private int itemId;
|
private int itemId;
|
||||||
private boolean isForbidGuest;
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isForbidGuest() {
|
public GadgetGatherPoint(EntityGadget gadget) {
|
||||||
return isForbidGuest;
|
super(gadget);
|
||||||
}
|
|
||||||
|
|
||||||
public boolean onInteract(Player player, GadgetInteractReq req) {
|
if (gadget.getSpawnEntry() != null) {
|
||||||
GameItem item = new GameItem(getItemId(), 1);
|
this.itemId = gadget.getSpawnEntry().getGatherItemId();
|
||||||
|
} else {
|
||||||
player.getInventory().addItem(item, ActionReason.Gather);
|
GatherData gatherData = GameData.getGatherDataMap().get(gadget.getPointType());
|
||||||
|
this.itemId = gatherData.getItemId();
|
||||||
return true;
|
this.isForbidGuest = gatherData.isForbidGuest();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void onBuildProto(SceneGadgetInfo.Builder gadgetInfo) {
|
public int getItemId() {
|
||||||
GatherGadgetInfo gatherGadgetInfo = GatherGadgetInfo.newBuilder()
|
return this.itemId;
|
||||||
.setItemId(this.getItemId())
|
}
|
||||||
.setIsForbidGuest(this.isForbidGuest())
|
|
||||||
.build();
|
|
||||||
|
|
||||||
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++) {
|
for (int i = 0 ; i < times ; i++) {
|
||||||
EntityItem item = new EntityItem(
|
EntityItem item = new EntityItem(
|
||||||
scene,
|
scene,
|
||||||
@ -69,11 +69,11 @@ public class GadgetGatherPoint extends GadgetContent {
|
|||||||
.addZ(Utils.randomFloatRange(-1f, 1f)),
|
.addZ(Utils.randomFloatRange(-1f, 1f)),
|
||||||
1,
|
1,
|
||||||
true);
|
true);
|
||||||
|
|
||||||
scene.addEntity(item);
|
scene.addEntity(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
scene.killEntity(this.getGadget(), player.getTeamManager().getCurrentAvatarEntity().getId());
|
scene.killEntity(this.getGadget(), player.getTeamManager().getCurrentAvatarEntity().getId());
|
||||||
// Todo: add record
|
// Todo: add record
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ public class HomeBlockItem {
|
|||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int calComfort(){
|
public int calComfort() {
|
||||||
return this.deployFurnitureList.stream()
|
return this.deployFurnitureList.stream()
|
||||||
.mapToInt(HomeFurnitureItem::getComfort)
|
.mapToInt(HomeFurnitureItem::getComfort)
|
||||||
.sum();
|
.sum();
|
||||||
|
@ -15,11 +15,11 @@ public class MapMark {
|
|||||||
private int monsterId;
|
private int monsterId;
|
||||||
private MapMarkFromType mapMarkFromType;
|
private MapMarkFromType mapMarkFromType;
|
||||||
private int questId;
|
private int questId;
|
||||||
|
|
||||||
@Deprecated // Morhpia
|
@Deprecated // Morhpia
|
||||||
public MapMark() {
|
public MapMark() {
|
||||||
this.mapMarkPointType = MapMarkPointType.MAP_MARK_POINT_TYPE_MONSTER;
|
this.mapMarkPointType = MapMarkPointType.MAP_MARK_POINT_TYPE_MONSTER;
|
||||||
this.mapMarkFromType = MapMarkFromType.MAP_MARK_FROM_TYPE_MONSTER;
|
this.mapMarkFromType = MapMarkFromType.MAP_MARK_FROM_TYPE_MONSTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapMark(MapMarkPoint mapMarkPoint) {
|
public MapMark(MapMarkPoint mapMarkPoint) {
|
||||||
@ -35,28 +35,28 @@ public class MapMark {
|
|||||||
public int getSceneId() {
|
public int getSceneId() {
|
||||||
return this.sceneId;
|
return this.sceneId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Position getPosition() {
|
public Position getPosition() {
|
||||||
return this.position;
|
return this.position;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapMarkPointType getMapMarkPointType() {
|
public MapMarkPointType getMapMarkPointType() {
|
||||||
return this.mapMarkPointType;
|
return this.mapMarkPointType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMonsterId() {
|
public int getMonsterId() {
|
||||||
return this.monsterId;
|
return this.monsterId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapMarkFromType getMapMarkFromType() {
|
public MapMarkFromType getMapMarkFromType() {
|
||||||
return this.mapMarkFromType;
|
return this.mapMarkFromType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getQuestId() {
|
public int getQuestId() {
|
||||||
return this.questId;
|
return this.questId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -181,7 +181,7 @@ public class GameQuest {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
getMainQuest().save();
|
getMainQuest().save();
|
||||||
}
|
}
|
||||||
|
@ -313,20 +313,20 @@ public class QuestManager extends BasePlayerManager {
|
|||||||
}
|
}
|
||||||
public void loadFromDatabase() {
|
public void loadFromDatabase() {
|
||||||
List<GameMainQuest> quests = DatabaseHelper.getAllQuests(getPlayer());
|
List<GameMainQuest> quests = DatabaseHelper.getAllQuests(getPlayer());
|
||||||
|
|
||||||
for (GameMainQuest mainQuest : quests) {
|
for (GameMainQuest mainQuest : quests) {
|
||||||
boolean cancelAdd = false;
|
boolean cancelAdd = false;
|
||||||
mainQuest.setOwner(this.getPlayer());
|
mainQuest.setOwner(this.getPlayer());
|
||||||
|
|
||||||
for (GameQuest quest : mainQuest.getChildQuests().values()) {
|
for (GameQuest quest : mainQuest.getChildQuests().values()) {
|
||||||
QuestData questConfig = GameData.getQuestDataMap().get(quest.getSubQuestId());
|
QuestData questConfig = GameData.getQuestDataMap().get(quest.getSubQuestId());
|
||||||
|
|
||||||
if (questConfig == null) {
|
if (questConfig == null) {
|
||||||
mainQuest.delete();
|
mainQuest.delete();
|
||||||
cancelAdd = true;
|
cancelAdd = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
quest.setMainQuest(mainQuest);
|
quest.setMainQuest(mainQuest);
|
||||||
quest.setConfig(questConfig);
|
quest.setConfig(questConfig);
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ public interface Router {
|
|||||||
* @param javalin A Javalin instance.
|
* @param javalin A Javalin instance.
|
||||||
*/
|
*/
|
||||||
void applyRoutes(Javalin javalin);
|
void applyRoutes(Javalin javalin);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies this handler to all endpoint types
|
* Applies this handler to all endpoint types
|
||||||
* @param javalin A Javalin instance.
|
* @param javalin A Javalin instance.
|
||||||
|
@ -15,12 +15,12 @@ import emu.grasscutter.server.packet.send.PacketMusicGameSettleRsp;
|
|||||||
@Opcodes(PacketOpcodes.MusicGameSettleReq)
|
@Opcodes(PacketOpcodes.MusicGameSettleReq)
|
||||||
public class HandlerMusicGameSettleReq extends PacketHandler {
|
public class HandlerMusicGameSettleReq extends PacketHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||||
var req = MusicGameSettleReqOuterClass.MusicGameSettleReq.parseFrom(payload);
|
var req = MusicGameSettleReqOuterClass.MusicGameSettleReq.parseFrom(payload);
|
||||||
|
|
||||||
var playerData = session.getPlayer().getActivityManager().getPlayerActivityDataByActivityType(ActivityType.NEW_ACTIVITY_MUSIC_GAME);
|
var playerData = session.getPlayer().getActivityManager().getPlayerActivityDataByActivityType(ActivityType.NEW_ACTIVITY_MUSIC_GAME);
|
||||||
if(playerData.isEmpty()){
|
if (playerData.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var handler = (MusicGameActivityHandler) playerData.get().getActivityHandler();
|
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.
|
// Probably was an issue in 2.8 but was discovered in 3.0 port.
|
||||||
// - Benj
|
// - Benj
|
||||||
|
|
||||||
/*if(req.getMusicShareId() == 0){
|
/*if (req.getMusicShareId() == 0) {
|
||||||
session.getPlayer().getActivityManager().triggerWatcher(
|
session.getPlayer().getActivityManager().triggerWatcher(
|
||||||
WatcherTriggerType.TRIGGER_FLEUR_FAIR_MUSIC_GAME_REACH_SCORE,
|
WatcherTriggerType.TRIGGER_FLEUR_FAIR_MUSIC_GAME_REACH_SCORE,
|
||||||
String.valueOf(req.getMusicBasicId()),
|
String.valueOf(req.getMusicBasicId()),
|
||||||
@ -48,7 +48,7 @@ public class HandlerMusicGameSettleReq extends PacketHandler {
|
|||||||
|
|
||||||
// update activity info
|
// update activity info
|
||||||
session.send(new PacketActivityInfoNotify(handler.toProto(playerData.get())));
|
session.send(new PacketActivityInfoNotify(handler.toProto(playerData.get())));
|
||||||
}else{
|
}else {
|
||||||
handler.setMusicGameCustomBeatmapRecord(playerData.get(),
|
handler.setMusicGameCustomBeatmapRecord(playerData.get(),
|
||||||
MusicGamePlayerData.CustomBeatmapRecord.of()
|
MusicGamePlayerData.CustomBeatmapRecord.of()
|
||||||
.musicShareId(req.getMusicShareId())
|
.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));*/
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,24 +13,24 @@ import emu.grasscutter.utils.Position;
|
|||||||
|
|
||||||
@Opcodes(PacketOpcodes.PersonalSceneJumpReq)
|
@Opcodes(PacketOpcodes.PersonalSceneJumpReq)
|
||||||
public class HandlerPersonalSceneJumpReq extends PacketHandler {
|
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
|
@Override
|
||||||
String code = player.getSceneId() + "_" + req.getPointId();
|
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||||
ScenePointEntry scenePointEntry = GameData.getScenePointEntries().get(code);
|
PersonalSceneJumpReq req = PersonalSceneJumpReq.parseFrom(payload);
|
||||||
|
var player = session.getPlayer();
|
||||||
|
|
||||||
if (scenePointEntry != null) {
|
// get the scene point
|
||||||
Position pos = scenePointEntry.getPointData().getTranPos().clone(); // This might not need cloning
|
String code = player.getSceneId() + "_" + req.getPointId();
|
||||||
int sceneId = scenePointEntry.getPointData().getTranSceneId();
|
ScenePointEntry scenePointEntry = GameData.getScenePointEntries().get(code);
|
||||||
|
|
||||||
player.getWorld().transferPlayerToScene(player, sceneId, pos);
|
if (scenePointEntry != null) {
|
||||||
session.send(new PacketPersonalSceneJumpRsp(sceneId, pos));
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ public class PacketAddCustomTeamRsp extends BasePacket {
|
|||||||
AddCustomTeamRsp proto = AddCustomTeamRsp.newBuilder()
|
AddCustomTeamRsp proto = AddCustomTeamRsp.newBuilder()
|
||||||
.setRetcode(retcode.getNumber())
|
.setRetcode(retcode.getNumber())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
this.setData(proto);
|
this.setData(proto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,17 +11,17 @@ import emu.grasscutter.net.proto.AvatarTeamOuterClass.AvatarTeam;
|
|||||||
import emu.grasscutter.net.proto.AvatarTeamUpdateNotifyOuterClass.AvatarTeamUpdateNotify;
|
import emu.grasscutter.net.proto.AvatarTeamUpdateNotifyOuterClass.AvatarTeamUpdateNotify;
|
||||||
|
|
||||||
public class PacketAvatarTeamUpdateNotify extends BasePacket {
|
public class PacketAvatarTeamUpdateNotify extends BasePacket {
|
||||||
|
|
||||||
public PacketAvatarTeamUpdateNotify(Player player) {
|
|
||||||
super(PacketOpcodes.AvatarTeamUpdateNotify);
|
|
||||||
|
|
||||||
AvatarTeamUpdateNotify.Builder proto = AvatarTeamUpdateNotify.newBuilder();
|
public PacketAvatarTeamUpdateNotify(Player player) {
|
||||||
|
super(PacketOpcodes.AvatarTeamUpdateNotify);
|
||||||
for (Entry<Integer, TeamInfo> entry : player.getTeamManager().getTeams().entrySet()) {
|
|
||||||
TeamInfo teamInfo = entry.getValue();
|
AvatarTeamUpdateNotify.Builder proto = AvatarTeamUpdateNotify.newBuilder();
|
||||||
proto.putAvatarTeamMap(entry.getKey(), teamInfo.toProto(player));
|
|
||||||
}
|
for (Entry<Integer, TeamInfo> entry : player.getTeamManager().getTeams().entrySet()) {
|
||||||
|
TeamInfo teamInfo = entry.getValue();
|
||||||
this.setData(proto);
|
proto.putAvatarTeamMap(entry.getKey(), teamInfo.toProto(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.setData(proto);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,33 +17,33 @@ import java.util.List;
|
|||||||
|
|
||||||
public class PacketCreateVehicleRsp extends BasePacket {
|
public class PacketCreateVehicleRsp extends BasePacket {
|
||||||
|
|
||||||
public PacketCreateVehicleRsp(Player player, int vehicleId, int pointId, Position pos, Position rot) {
|
public PacketCreateVehicleRsp(Player player, int vehicleId, int pointId, Position pos, Position rot) {
|
||||||
super(PacketOpcodes.CreateVehicleRsp);
|
super(PacketOpcodes.CreateVehicleRsp);
|
||||||
CreateVehicleRsp.Builder proto = CreateVehicleRsp.newBuilder();
|
CreateVehicleRsp.Builder proto = CreateVehicleRsp.newBuilder();
|
||||||
|
|
||||||
// Eject vehicle members and Kill previous vehicles if there are any
|
// Eject vehicle members and Kill previous vehicles if there are any
|
||||||
List<GameEntity> previousVehicles = player.getScene().getEntities().values().stream()
|
List<GameEntity> previousVehicles = player.getScene().getEntities().values().stream()
|
||||||
.filter(entity -> entity instanceof EntityVehicle
|
.filter(entity -> entity instanceof EntityVehicle
|
||||||
&& ((EntityVehicle) entity).getGadgetId() == vehicleId
|
&& ((EntityVehicle) entity).getGadgetId() == vehicleId
|
||||||
&& ((EntityVehicle) entity).getOwner().equals(player))
|
&& ((EntityVehicle) entity).getOwner().equals(player))
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
previousVehicles.stream().forEach(entity -> {
|
previousVehicles.stream().forEach(entity -> {
|
||||||
List<VehicleMember> vehicleMembers = ((EntityVehicle) entity).getVehicleMembers().stream().toList();
|
List<VehicleMember> vehicleMembers = ((EntityVehicle) entity).getVehicleMembers().stream().toList();
|
||||||
|
|
||||||
vehicleMembers.stream().forEach(vehicleMember -> {
|
vehicleMembers.stream().forEach(vehicleMember -> {
|
||||||
player.getScene().broadcastPacket(new PacketVehicleInteractRsp(((EntityVehicle) entity), vehicleMember, VehicleInteractTypeOuterClass.VehicleInteractType.VEHICLE_INTERACT_TYPE_OUT));
|
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);
|
EntityVehicle vehicle = new EntityVehicle(player.getScene(), player, vehicleId, pointId, pos, rot);
|
||||||
player.getScene().addEntity(vehicle);
|
player.getScene().addEntity(vehicle);
|
||||||
|
|
||||||
proto.setVehicleId(vehicleId);
|
proto.setVehicleId(vehicleId);
|
||||||
proto.setEntityId(vehicle.getId());
|
proto.setEntityId(vehicle.getId());
|
||||||
|
|
||||||
this.setData(proto.build());
|
this.setData(proto.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ public class PacketCustomTeamListNotify extends BasePacket {
|
|||||||
TeamInfo teamInfo = entry.getValue();
|
TeamInfo teamInfo = entry.getValue();
|
||||||
proto.putAvatarTeamMap(entry.getKey(), teamInfo.toProto(player));
|
proto.putAvatarTeamMap(entry.getKey(), teamInfo.toProto(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setData(proto);
|
this.setData(proto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ public class PacketRemoveCustomTeamRsp extends BasePacket {
|
|||||||
.setRetcode(retcode.getNumber())
|
.setRetcode(retcode.getNumber())
|
||||||
.setId(id)
|
.setId(id)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
this.setData(proto);
|
this.setData(proto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user