Copy some files from Grasscutter-Quests

NOT completely finished, nor is it completely done. Protocol issues remain! (including lack of packet IDs)
This commit is contained in:
KingRainbow44 2023-04-01 18:06:30 -04:00
parent 262ee38ded
commit daa51e53b7
No known key found for this signature in database
GPG Key ID: FC2CB64B00D257BE
381 changed files with 10285 additions and 9150 deletions

View File

@ -3,7 +3,7 @@ package emu.grasscutter.command.commands;
import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.excels.AchievementData;
import emu.grasscutter.data.excels.achievement.AchievementData;
import emu.grasscutter.game.achievement.AchievementControlReturns;
import emu.grasscutter.game.achievement.Achievements;
import emu.grasscutter.game.player.Player;
@ -24,7 +24,7 @@ import java.util.concurrent.atomic.AtomicInteger;
permissionTargeted = "player.achievement.others",
targetRequirement = Command.TargetRequirement.PLAYER,
threading = true)
public class AchievementCommand implements CommandHandler {
public final class AchievementCommand implements CommandHandler {
private static void sendSuccessMessage(Player sender, String cmd, Object... args) {
CommandHandler.sendTranslatedMessage(
sender, AchievementControlReturns.Return.SUCCESS.getKey() + cmd, args);

View File

@ -1,137 +1,139 @@
package emu.grasscutter.command.commands;
import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.entity.*;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.game.props.ElementType;
import emu.grasscutter.game.props.FightProperty;
import emu.grasscutter.game.world.Scene;
import emu.grasscutter.server.event.entity.EntityDamageEvent;
import emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify;
import lombok.Setter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.BiConsumer;
import java.util.regex.Pattern;
import static emu.grasscutter.command.CommandHelpers.*;
import static emu.grasscutter.utils.Language.translate;
@Command(
label = "entity",
usage = {
"<configId gadget> [state<state>] [maxhp<maxhp>] [hp<hp>(0 for infinite)] [atk<atk>] [def<def>]",
"<configId monster> [ai<aiId>] [maxhp<maxhp>] [hp<hp>(0 for infinite)] [atk<atk>] [def<def>]"},
permission = "server.entity")
public final class EntityCommand implements CommandHandler {
private static final Map<Pattern, BiConsumer<EntityParameters, Integer>> intCommandHandlers = Map.ofEntries(
Map.entry(stateRegex, EntityParameters::setState),
Map.entry(maxHPRegex, EntityParameters::setMaxHP),
Map.entry(hpRegex, EntityParameters::setHp),
Map.entry(defRegex, EntityParameters::setDef),
Map.entry(atkRegex, EntityParameters::setAtk),
Map.entry(aiRegex, EntityParameters::setAi)
);
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
EntityParameters param = new EntityParameters();
parseIntParameters(args, param, intCommandHandlers);
// At this point, first remaining argument MUST be the id and the rest the pos
if (args.size() != 1) {
sendUsageMessage(sender); // Reachable if someone does `/give lv90` or similar
throw new IllegalArgumentException();
}
try {
param.configId = Integer.parseInt(args.get(0));
} catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, translate(sender, "commands.generic.invalid.cfgId"));
}
param.scene = targetPlayer.getScene();
var entity = param.scene.getEntityByConfigId(param.configId);
if(entity == null){
CommandHandler.sendMessage(sender, translate(sender, "commands.entity.not_found_error"));
return;
}
applyFightProps(entity, param);
applyGadgetParams(entity, param);
applyMonsterParams(entity, param);
CommandHandler.sendMessage(sender, translate(sender, "commands.status.success"));
}
private void applyGadgetParams(GameEntity entity, EntityParameters param) {
if(!(entity instanceof EntityGadget)){
return;
}
if(param.state != -1 ){
((EntityGadget) entity).updateState(param.state);
}
}
private void applyMonsterParams(GameEntity entity, EntityParameters param) {
if(!(entity instanceof EntityMonster)){
return;
}
if(param.ai != -1 ){
((EntityMonster) entity).setAiId(param.ai);
//TODO notify
}
}
private void applyFightProps(GameEntity entity, EntityParameters param) {
var changedFields = new ArrayList<FightProperty>();
if (param.maxHP != -1) {
setFightProperty(entity, FightProperty.FIGHT_PROP_MAX_HP, param.maxHP, changedFields);
}
if (param.hp != -1) {
float targetHp = param.hp == 0 ? Float.MAX_VALUE : param.hp;
float oldHp = entity.getFightProperty(FightProperty.FIGHT_PROP_CUR_HP);
setFightProperty(entity, FightProperty.FIGHT_PROP_CUR_HP, targetHp, changedFields);
EntityDamageEvent event = new EntityDamageEvent(entity, oldHp-targetHp, ElementType.None, null);
callHPEvents(entity, event);
}
if (param.atk != -1) {
setFightProperty(entity, FightProperty.FIGHT_PROP_ATTACK, param.atk, changedFields);
setFightProperty(entity, FightProperty.FIGHT_PROP_CUR_ATTACK, param.atk, changedFields);
}
if (param.def != -1) {
setFightProperty(entity, FightProperty.FIGHT_PROP_DEFENSE, param.def, changedFields);
setFightProperty(entity, FightProperty.FIGHT_PROP_CUR_DEFENSE, param.def, changedFields);
}
if(!changedFields.isEmpty()) {
entity.getScene().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, changedFields));
}
}
private void callHPEvents(GameEntity entity, EntityDamageEvent event){
entity.callLuaHPEvent(event);
}
private void setFightProperty(GameEntity entity, FightProperty property, float value, List<FightProperty> modifiedProps){
entity.setFightProperty(property, value);
modifiedProps.add(property);
}
private static class EntityParameters {
@Setter public int configId = -1;
@Setter public int state = -1;
@Setter public int hp = -1;
@Setter public int maxHP = -1;
@Setter public int atk = -1;
@Setter public int def = -1;
@Setter public int ai = -1;
public Scene scene = null;
}
}
package emu.grasscutter.command.commands;
import static emu.grasscutter.command.CommandHelpers.*;
import static emu.grasscutter.utils.Language.translate;
import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.entity.*;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.game.props.ElementType;
import emu.grasscutter.game.props.FightProperty;
import emu.grasscutter.game.world.Scene;
import emu.grasscutter.server.event.entity.EntityDamageEvent;
import emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.BiConsumer;
import java.util.regex.Pattern;
import lombok.Setter;
@Command(
label = "entity",
usage = {
"<configId gadget> [state<state>] [maxhp<maxhp>] [hp<hp>(0 for infinite)] [atk<atk>] [def<def>]",
"<configId monster> [ai<aiId>] [maxhp<maxhp>] [hp<hp>(0 for infinite)] [atk<atk>] [def<def>]"
},
permission = "server.entity")
public final class EntityCommand implements CommandHandler {
private static final Map<Pattern, BiConsumer<EntityParameters, Integer>> intCommandHandlers =
Map.ofEntries(
Map.entry(stateRegex, EntityParameters::setState),
Map.entry(maxHPRegex, EntityParameters::setMaxHP),
Map.entry(hpRegex, EntityParameters::setHp),
Map.entry(defRegex, EntityParameters::setDef),
Map.entry(atkRegex, EntityParameters::setAtk),
Map.entry(aiRegex, EntityParameters::setAi));
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
EntityParameters param = new EntityParameters();
parseIntParameters(args, param, intCommandHandlers);
// At this point, first remaining argument MUST be the id and the rest the pos
if (args.size() != 1) {
sendUsageMessage(sender); // Reachable if someone does `/give lv90` or similar
throw new IllegalArgumentException();
}
try {
param.configId = Integer.parseInt(args.get(0));
} catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, translate(sender, "commands.generic.invalid.cfgId"));
}
param.scene = targetPlayer.getScene();
var entity = param.scene.getEntityByConfigId(param.configId);
if (entity == null) {
CommandHandler.sendMessage(sender, translate(sender, "commands.entity.not_found_error"));
return;
}
applyFightProps(entity, param);
applyGadgetParams(entity, param);
applyMonsterParams(entity, param);
CommandHandler.sendMessage(sender, translate(sender, "commands.status.success"));
}
private void applyGadgetParams(GameEntity entity, EntityParameters param) {
if (!(entity instanceof EntityGadget)) {
return;
}
if (param.state != -1) {
((EntityGadget) entity).updateState(param.state);
}
}
private void applyMonsterParams(GameEntity entity, EntityParameters param) {
if (!(entity instanceof EntityMonster)) {
return;
}
if (param.ai != -1) {
((EntityMonster) entity).setAiId(param.ai);
// TODO notify
}
}
private void applyFightProps(GameEntity entity, EntityParameters param) {
var changedFields = new ArrayList<FightProperty>();
if (param.maxHP != -1) {
setFightProperty(entity, FightProperty.FIGHT_PROP_MAX_HP, param.maxHP, changedFields);
}
if (param.hp != -1) {
float targetHp = param.hp == 0 ? Float.MAX_VALUE : param.hp;
float oldHp = entity.getFightProperty(FightProperty.FIGHT_PROP_CUR_HP);
setFightProperty(entity, FightProperty.FIGHT_PROP_CUR_HP, targetHp, changedFields);
EntityDamageEvent event =
new EntityDamageEvent(entity, oldHp - targetHp, ElementType.None, null);
callHPEvents(entity, event);
}
if (param.atk != -1) {
setFightProperty(entity, FightProperty.FIGHT_PROP_ATTACK, param.atk, changedFields);
setFightProperty(entity, FightProperty.FIGHT_PROP_CUR_ATTACK, param.atk, changedFields);
}
if (param.def != -1) {
setFightProperty(entity, FightProperty.FIGHT_PROP_DEFENSE, param.def, changedFields);
setFightProperty(entity, FightProperty.FIGHT_PROP_CUR_DEFENSE, param.def, changedFields);
}
if (!changedFields.isEmpty()) {
entity
.getScene()
.broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, changedFields));
}
}
private void callHPEvents(GameEntity entity, EntityDamageEvent event) {
entity.callLuaHPEvent(event);
}
private void setFightProperty(
GameEntity entity, FightProperty property, float value, List<FightProperty> modifiedProps) {
entity.setFightProperty(property, value);
modifiedProps.add(property);
}
private static class EntityParameters {
@Setter public int configId = -1;
@Setter public int state = -1;
@Setter public int hp = -1;
@Setter public int maxHP = -1;
@Setter public int atk = -1;
@Setter public int def = -1;
@Setter public int ai = -1;
public Scene scene = null;
}
}

View File

@ -4,10 +4,10 @@ import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.GameDepot;
import emu.grasscutter.data.excels.AvatarData;
import emu.grasscutter.data.excels.avatar.AvatarData;
import emu.grasscutter.data.excels.ItemData;
import emu.grasscutter.data.excels.ReliquaryAffixData;
import emu.grasscutter.data.excels.ReliquaryMainPropData;
import emu.grasscutter.data.excels.reliquary.ReliquaryAffixData;
import emu.grasscutter.data.excels.reliquary.ReliquaryMainPropData;
import emu.grasscutter.game.avatar.Avatar;
import emu.grasscutter.game.inventory.GameItem;
import emu.grasscutter.game.inventory.ItemType;

View File

@ -1,72 +1,72 @@
package emu.grasscutter.command.commands;
import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.game.world.SceneGroupInstance;
import java.util.List;
import static emu.grasscutter.utils.Language.translate;
@Command(label = "group",
aliases = {"g"},
usage = {"(refresh) [<groupId>] [<suiteId>]"},
permission = "player.group",
permissionTargeted = "player.group.others")
public final class GroupCommand implements CommandHandler {
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
if (args.isEmpty()) {
return;
}
String cmd = args.remove(0).toLowerCase();
int groupId = 0;
int suiteId = 0;
switch (args.size()){
case 2:
try {
suiteId = Integer.parseInt(args.get(1));
}
catch (Exception e) {
CommandHandler.sendMessage(sender, translate(sender, "commands.group.invalid_suiteid"));
return;
} // Fallthrough
case 1:
try {
groupId = Integer.parseInt(args.get(0));
}
catch (Exception e) {
CommandHandler.sendMessage(sender, translate(sender, "commands.group.invalid_groupid"));
return;
}
break;
default:
sendUsageMessage(sender);
return;
}
switch (cmd) {
case "refresh" -> {
SceneGroupInstance groupInstance = targetPlayer.getScene().getScriptManager().getGroupInstanceById(groupId);
if(groupInstance == null) {
CommandHandler.sendMessage(sender, translate(sender, "commands.group.group_not_found", groupId));
return;
}
if(args.size() >= 2) {
targetPlayer.getScene().getScriptManager().refreshGroup(groupInstance, suiteId, false);
} else {
targetPlayer.getScene().getScriptManager().refreshGroup(groupInstance);
}
CommandHandler.sendMessage(sender, translate(sender, "commands.group.refreshed", groupId));
}
default -> {
sendUsageMessage(sender);
}
}
}
}
package emu.grasscutter.command.commands;
import static emu.grasscutter.utils.Language.translate;
import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.game.world.SceneGroupInstance;
import java.util.List;
@Command(
label = "group",
aliases = {"g"},
usage = {"(refresh) [<groupId>] [<suiteId>]"},
permission = "player.group",
permissionTargeted = "player.group.others")
public final class GroupCommand implements CommandHandler {
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
if (args.isEmpty()) {
return;
}
String cmd = args.remove(0).toLowerCase();
int groupId = 0;
int suiteId = 0;
switch (args.size()) {
case 2:
try {
suiteId = Integer.parseInt(args.get(1));
} catch (Exception e) {
CommandHandler.sendMessage(sender, translate(sender, "commands.group.invalid_suiteid"));
return;
} // Fallthrough
case 1:
try {
groupId = Integer.parseInt(args.get(0));
} catch (Exception e) {
CommandHandler.sendMessage(sender, translate(sender, "commands.group.invalid_groupid"));
return;
}
break;
default:
sendUsageMessage(sender);
return;
}
switch (cmd) {
case "refresh" -> {
SceneGroupInstance groupInstance =
targetPlayer.getScene().getScriptManager().getGroupInstanceById(groupId);
if (groupInstance == null) {
CommandHandler.sendMessage(
sender, translate(sender, "commands.group.group_not_found", groupId));
return;
}
if (args.size() >= 2) {
targetPlayer.getScene().getScriptManager().refreshGroup(groupInstance, suiteId, false);
} else {
targetPlayer.getScene().getScriptManager().refreshGroup(groupInstance);
}
CommandHandler.sendMessage(sender, translate(sender, "commands.group.refreshed", groupId));
}
default -> {
sendUsageMessage(sender);
}
}
}
}

View File

@ -9,7 +9,7 @@ import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.excels.GadgetData;
import emu.grasscutter.data.excels.ItemData;
import emu.grasscutter.data.excels.MonsterData;
import emu.grasscutter.data.excels.monster.MonsterData;
import emu.grasscutter.game.entity.*;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.game.props.EntityType;

View File

@ -3,7 +3,7 @@ package emu.grasscutter.command.commands;
import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.excels.AvatarSkillDepotData;
import emu.grasscutter.data.excels.avatar.AvatarSkillDepotData;
import emu.grasscutter.game.avatar.Avatar;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.utils.Language;

View File

@ -1,125 +1,156 @@
package emu.grasscutter.command.commands;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.activity.PlayerActivityData;
import emu.grasscutter.game.activity.trialavatar.TrialAvatarActivityHandler;
import emu.grasscutter.game.activity.trialavatar.TrialAvatarPlayerData;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.game.props.ActivityType;
import emu.grasscutter.net.proto.ActivityInfoOuterClass.ActivityInfo;
import emu.grasscutter.server.packet.send.PacketActivityInfoNotify;
import emu.grasscutter.utils.JsonUtils;
import java.util.List;
import lombok.val;
import static emu.grasscutter.utils.Language.translate;
@Command(
label = "trialAvatarActivity",
aliases = {"taa"},
usage = {"change <scheduleId>", "toggleDungeon <index(start from 1)|all>", "toggleReward <index(start from 1)|all>"},
permission = "player.trialavataractivity",
permissionTargeted = "player.trialavataractivity.others")
public final class TrialAvatarActivityCommand implements CommandHandler {
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
if (args.size() < 2) {
sendUsageMessage(sender);
return;
}
String action = args.get(0).toLowerCase();
String param = args.get(1);
val playerDataOption = targetPlayer.getActivityManager()
.getPlayerActivityDataByActivityType(ActivityType.NEW_ACTIVITY_TRIAL_AVATAR);
if (playerDataOption == null) {
CommandHandler.sendMessage(sender, translate(sender, "commands.trialAvatarActivity.not_found"));
return;
}
val playerData = playerDataOption.get();
if (playerData == null) {
CommandHandler.sendMessage(sender, translate(sender, "commands.trialAvatarActivity.not_found"));
return;
}
var handler = (TrialAvatarActivityHandler) playerData.getActivityHandler();
if (handler == null) {
CommandHandler.sendMessage(sender, translate(sender, "commands.trialAvatarActivity.not_found"));
return;
}
TrialAvatarPlayerData trialAvatarPlayerData = JsonUtils.decode(playerData.getDetail(), TrialAvatarPlayerData.class);
if (trialAvatarPlayerData == null) {
CommandHandler.sendMessage(sender, translate(sender, "commands.trialAvatarActivity.not_found"));
return;
}
switch (action) {
default -> {
sendUsageMessage(sender);
}
case "change" -> {
if (!param.chars().allMatch(Character::isDigit)) { // if its not number
CommandHandler.sendMessage(sender, translate(sender, "commands.trialAvatarActivity.invalid_param"));
return;
}
if (TrialAvatarPlayerData.getAvatarIdList(Integer.parseInt(param)).isEmpty()) {
CommandHandler.sendMessage(sender, translate(sender, "commands.trialAvatarActivity.schedule_not_found", Integer.parseInt(param)));
return;
}
playerData.setDetail(TrialAvatarPlayerData.create(Integer.parseInt(param)));
playerData.save();
CommandHandler.sendMessage(sender, translate(sender, "commands.trialAvatarActivity.success_schedule", Integer.parseInt(param)));
}
case "toggledungeon" -> {
if (param.chars().allMatch(Character::isDigit)) { // if its number
if (Integer.parseInt(param)-1 >= trialAvatarPlayerData.getRewardInfoList().size()
|| Integer.parseInt(param)-1 <= 0) {
CommandHandler.sendMessage(sender, translate(sender, "commands.trialAvatarActivity.invalid_param"));
return;
}
TrialAvatarPlayerData.RewardInfoItem rewardInfo = trialAvatarPlayerData.getRewardInfoList().get(Integer.parseInt(param)-1);
rewardInfo.setPassedDungeon(!rewardInfo.isPassedDungeon());
playerData.setDetail(trialAvatarPlayerData);
playerData.save();
CommandHandler.sendMessage(sender, translate(sender, "commands.trialAvatarActivity.success_dungeon", Integer.parseInt(param)));
} else {
if (!param.equals("all")) {
CommandHandler.sendMessage(sender, translate(sender, "commands.trialAvatarActivity.invalid_param"));
return;
}
trialAvatarPlayerData.getRewardInfoList().forEach(r -> r.setPassedDungeon(!r.isPassedDungeon()));
playerData.setDetail(trialAvatarPlayerData);
playerData.save();
CommandHandler.sendMessage(sender, translate(sender, "commands.trialAvatarActivity.success_dungeon_all"));
}
}
case "togglereward" -> {
if (param.chars().allMatch(Character::isDigit)) { // if its number
if (Integer.parseInt(param)-1 >= trialAvatarPlayerData.getRewardInfoList().size()
|| Integer.parseInt(param)-1 <= 0) {
CommandHandler.sendMessage(sender, translate(sender, "commands.trialAvatarActivity.invalid_param"));
return;
}
TrialAvatarPlayerData.RewardInfoItem rewardInfo = trialAvatarPlayerData.getRewardInfoList().get(Integer.parseInt(param)-1);
rewardInfo.setReceivedReward(!rewardInfo.isReceivedReward());
playerData.setDetail(trialAvatarPlayerData);
playerData.save();
CommandHandler.sendMessage(sender, translate(sender, "commands.trialAvatarActivity.success_reward", Integer.parseInt(param)));
} else {
if (!param.toLowerCase().equals("all")) {
CommandHandler.sendMessage(sender, translate(sender, "commands.trialAvatarActivity.invalid_param"));
return;
}
trialAvatarPlayerData.getRewardInfoList().forEach(r -> r.setReceivedReward(!r.isReceivedReward()));
playerData.setDetail(trialAvatarPlayerData);
playerData.save();
CommandHandler.sendMessage(sender, translate(sender, "commands.trialAvatarActivity.success_reward_all"));
}
}
}
targetPlayer.sendPacket(new PacketActivityInfoNotify(handler.toProto(playerData, targetPlayer.getActivityManager().getConditionExecutor())));
}
}
package emu.grasscutter.command.commands;
import static emu.grasscutter.utils.Language.translate;
import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.activity.trialavatar.TrialAvatarActivityHandler;
import emu.grasscutter.game.activity.trialavatar.TrialAvatarPlayerData;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.game.props.ActivityType;
import emu.grasscutter.server.packet.send.PacketActivityInfoNotify;
import emu.grasscutter.utils.JsonUtils;
import java.util.List;
@Command(
label = "trialAvatarActivity",
aliases = {"taa"},
usage = {
"change <scheduleId>",
"toggleDungeon <index(start from 1)|all>",
"toggleReward <index(start from 1)|all>"
},
permission = "player.trialavataractivity",
permissionTargeted = "player.trialavataractivity.others")
public final class TrialAvatarActivityCommand implements CommandHandler {
@Override
public void execute(Player sender, Player targetPlayer, List<String> args) {
if (args.size() < 2) {
sendUsageMessage(sender);
return;
}
var action = args.get(0).toLowerCase();
var param = args.get(1);
var playerDataOption =
targetPlayer
.getActivityManager()
.getPlayerActivityDataByActivityType(ActivityType.NEW_ACTIVITY_TRIAL_AVATAR);
if (playerDataOption.isEmpty()) {
CommandHandler.sendMessage(
sender, translate(sender, "commands.trialAvatarActivity.not_found"));
return;
}
var playerData = playerDataOption.get();
var handler = (TrialAvatarActivityHandler) playerData.getActivityHandler();
if (handler == null) {
CommandHandler.sendMessage(
sender, translate(sender, "commands.trialAvatarActivity.not_found"));
return;
}
var trialAvatarPlayerData =
JsonUtils.decode(playerData.getDetail(), TrialAvatarPlayerData.class);
if (trialAvatarPlayerData == null) {
CommandHandler.sendMessage(
sender, translate(sender, "commands.trialAvatarActivity.not_found"));
return;
}
switch (action) {
default -> this.sendUsageMessage(sender);
case "change" -> {
if (!param.chars().allMatch(Character::isDigit)) { // if its not number
CommandHandler.sendMessage(
sender, translate(sender, "commands.trialAvatarActivity.invalid_param"));
return;
}
if (TrialAvatarPlayerData.getAvatarIdList(Integer.parseInt(param)).isEmpty()) {
CommandHandler.sendMessage(
sender,
translate(
sender,
"commands.trialAvatarActivity.schedule_not_found",
Integer.parseInt(param)));
return;
}
playerData.setDetail(TrialAvatarPlayerData.create(Integer.parseInt(param)));
playerData.save();
CommandHandler.sendMessage(
sender,
translate(
sender, "commands.trialAvatarActivity.success_schedule", Integer.parseInt(param)));
}
case "toggledungeon" -> {
if (param.chars().allMatch(Character::isDigit)) { // if its number
if (Integer.parseInt(param) - 1 >= trialAvatarPlayerData.getRewardInfoList().size()
|| Integer.parseInt(param) - 1 <= 0) {
CommandHandler.sendMessage(
sender, translate(sender, "commands.trialAvatarActivity.invalid_param"));
return;
}
TrialAvatarPlayerData.RewardInfoItem rewardInfo =
trialAvatarPlayerData.getRewardInfoList().get(Integer.parseInt(param) - 1);
rewardInfo.setPassedDungeon(!rewardInfo.isPassedDungeon());
playerData.setDetail(trialAvatarPlayerData);
playerData.save();
CommandHandler.sendMessage(
sender,
translate(
sender, "commands.trialAvatarActivity.success_dungeon", Integer.parseInt(param)));
} else {
if (!param.equals("all")) {
CommandHandler.sendMessage(
sender, translate(sender, "commands.trialAvatarActivity.invalid_param"));
return;
}
trialAvatarPlayerData
.getRewardInfoList()
.forEach(r -> r.setPassedDungeon(!r.isPassedDungeon()));
playerData.setDetail(trialAvatarPlayerData);
playerData.save();
CommandHandler.sendMessage(
sender, translate(sender, "commands.trialAvatarActivity.success_dungeon_all"));
}
}
case "togglereward" -> {
if (param.chars().allMatch(Character::isDigit)) { // if its number
if (Integer.parseInt(param) - 1 >= trialAvatarPlayerData.getRewardInfoList().size()
|| Integer.parseInt(param) - 1 <= 0) {
CommandHandler.sendMessage(
sender, translate(sender, "commands.trialAvatarActivity.invalid_param"));
return;
}
TrialAvatarPlayerData.RewardInfoItem rewardInfo =
trialAvatarPlayerData.getRewardInfoList().get(Integer.parseInt(param) - 1);
rewardInfo.setReceivedReward(!rewardInfo.isReceivedReward());
playerData.setDetail(trialAvatarPlayerData);
playerData.save();
CommandHandler.sendMessage(
sender,
translate(
sender, "commands.trialAvatarActivity.success_reward", Integer.parseInt(param)));
} else {
if (!param.toLowerCase().equals("all")) {
CommandHandler.sendMessage(
sender, translate(sender, "commands.trialAvatarActivity.invalid_param"));
return;
}
trialAvatarPlayerData
.getRewardInfoList()
.forEach(r -> r.setReceivedReward(!r.isReceivedReward()));
playerData.setDetail(trialAvatarPlayerData);
playerData.save();
CommandHandler.sendMessage(
sender, translate(sender, "commands.trialAvatarActivity.success_reward_all"));
}
}
}
targetPlayer.sendPacket(
new PacketActivityInfoNotify(
handler.toProto(playerData, targetPlayer.getActivityManager().getConditionExecutor())));
}
}

View File

@ -2,19 +2,41 @@ package emu.grasscutter.data;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.data.binout.*;
import emu.grasscutter.data.binout.config.*;
import emu.grasscutter.data.binout.routes.*;
import emu.grasscutter.data.custom.*;
import emu.grasscutter.data.excels.*;
import emu.grasscutter.game.quest.QuestEncryptionKey;
import emu.grasscutter.data.excels.achievement.*;
import emu.grasscutter.data.excels.activity.*;
import emu.grasscutter.data.excels.avatar.*;
import emu.grasscutter.data.excels.codex.*;
import emu.grasscutter.data.excels.dungeon.*;
import emu.grasscutter.data.excels.monster.*;
import emu.grasscutter.data.excels.reliquary.*;
import emu.grasscutter.data.excels.tower.*;
import emu.grasscutter.data.excels.trial.*;
import emu.grasscutter.data.excels.weapon.*;
import emu.grasscutter.data.excels.world.*;
import emu.grasscutter.data.server.*;
import emu.grasscutter.game.dungeons.*;
import emu.grasscutter.game.quest.*;
import emu.grasscutter.game.world.*;
import emu.grasscutter.utils.Utils;
import it.unimi.dsi.fastutil.ints.*;
import java.lang.reflect.Field;
import java.util.*;
import javax.annotation.Nullable;
import lombok.Getter;
import lombok.experimental.Tolerate;
import lombok.val;
public class GameData {
protected static final Map<String, AbilityData> abilityDataMap = new HashMap<>();
protected static final Int2ObjectMap<ScenePointEntry> scenePointEntryMap =
@SuppressWarnings({"unused", "MismatchedQueryAndUpdateOfCollection"})
public final class GameData {
@Getter private static final Map<String, AbilityData> abilityDataMap = new HashMap<>();
@Getter
private static final Int2ObjectMap<ScenePointEntry> scenePointEntryMap =
new Int2ObjectOpenHashMap<>();
// BinOutputs
@Getter
private static final Int2ObjectMap<HomeworldDefaultSaveData> homeworldDefaultSaveData =
@ -29,16 +51,28 @@ public class GameData {
@Getter private static final Map<String, ConfigGadget> gadgetConfigData = new HashMap<>();
@Getter private static final Map<String, OpenConfigEntry> openConfigEntries = new HashMap<>();
@Deprecated(forRemoval = true)
@Getter
private static final Map<String, ScenePointEntry> scenePointEntries = new HashMap<>();
private static final Int2ObjectMap<MainQuestData> mainQuestData = new Int2ObjectOpenHashMap<>();
private static final Int2ObjectMap<QuestEncryptionKey> questsKeys = new Int2ObjectOpenHashMap<>();
private static final Int2ObjectMap<SceneNpcBornData> npcBornData = new Int2ObjectOpenHashMap<>();
private static final Map<String, AbilityEmbryoEntry> abilityEmbryos = new HashMap<>();
// ExcelConfigs
@Getter
private static final Int2ObjectMap<ActivityCondExcelConfigData> activityCondExcelConfigDataMap =
new Int2ObjectOpenHashMap<>();
@Getter
private static final Int2ObjectMap<DungeonPassConfigData> dungeonPassConfigDataMap =
new Int2ObjectOpenHashMap<>();
@Getter
private static final Int2ObjectMap<DungeonChallengeConfigData> dungeonChallengeConfigDataMap =
new Int2ObjectOpenHashMap<>();
@Getter
private static final Int2ObjectMap<Int2ObjectMap<Route>> sceneRouteData =
new Int2ObjectOpenHashMap<>();
@Getter
private static final ArrayList<CodexReliquaryData> codexReliquaryArrayList = new ArrayList<>();
@ -276,6 +310,26 @@ public class GameData {
private static final Int2ObjectMap<TriggerExcelConfigData> triggerExcelConfigDataMap =
new Int2ObjectOpenHashMap<>();
@Getter
private static final Int2ObjectMap<TrialAvatarData> trialAvatarDataMap =
new Int2ObjectOpenHashMap<>();
@Getter
private static final Int2ObjectMap<TrialAvatarActivityData> trialAvatarActivityDataMap =
new Int2ObjectOpenHashMap<>();
@Getter
private static final Int2ObjectMap<TrialAvatarActivityDataData> trialAvatarActivityDataDataMap =
new Int2ObjectOpenHashMap<>();
@Getter
private static final Int2ObjectMap<TrialAvatarTemplateData> trialAvatarTemplateDataMap =
new Int2ObjectOpenHashMap<>();
@Getter
private static final Int2ObjectMap<TrialReliquaryData> trialReliquaryDataMap =
new Int2ObjectOpenHashMap<>();
@Getter
private static final Int2ObjectMap<WeaponCurveData> weaponCurveDataMap =
new Int2ObjectOpenHashMap<>();
@ -299,6 +353,16 @@ public class GameData {
private static final Int2ObjectMap<WorldLevelData> worldLevelDataMap =
new Int2ObjectOpenHashMap<>();
@Getter
private static final Int2ObjectMap<RewindData> rewindDataMap = new Int2ObjectOpenHashMap<>();
@Getter
private static final Int2ObjectMap<TeleportData> teleportDataMap = new Int2ObjectOpenHashMap<>();
@Getter
private static final Int2ObjectMap<RefreshPolicyExcelConfigData> refreshPolicyExcelConfigDataMap =
new Int2ObjectOpenHashMap<>();
private static final Int2ObjectMap<AvatarPromoteData> avatarPromoteDataMap =
new Int2ObjectOpenHashMap<>();
private static final Int2ObjectMap<FetterData> fetterDataMap = new Int2ObjectOpenHashMap<>();
@ -306,6 +370,7 @@ public class GameData {
new Int2ObjectOpenHashMap<>();
private static final Int2ObjectMap<ShopGoodsData> shopGoodsDataMap =
new Int2ObjectOpenHashMap<>();
// The following are accessed via getMapByResourceDef, and will show as unused
private static final Int2ObjectMap<CodexMaterialData> codexMaterialDataMap =
new Int2ObjectOpenHashMap<>();
@ -316,34 +381,65 @@ public class GameData {
private static final Int2ObjectMap<CodexWeaponData> codexWeaponDataMap =
new Int2ObjectOpenHashMap<>();
// Custom community server resources
@Getter
private static final Int2ObjectMap<List<DungeonDropEntry>> dungeonDropDataMap =
new Int2ObjectOpenHashMap<>();
@Getter
private static final Int2ObjectMap<GadgetMapping> gadgetMappingMap =
new Int2ObjectOpenHashMap<>();
@Getter
private static final Int2ObjectMap<ActivityCondGroup> activityCondGroupMap =
new Int2ObjectOpenHashMap<>();
@Getter
private static final Int2ObjectMap<GroupReplacementData> groupReplacements =
new Int2ObjectOpenHashMap<>();
// Cache
@Getter private static final IntList scenePointIdList = new IntArrayList();
@Getter private static final List<OpenStateData> openStateList = new ArrayList<>();
@Getter private static final Map<Integer, List<Integer>> scenePointsPerScene = new HashMap<>();
@Getter private static final Map<String, ScriptSceneData> scriptSceneDataMap = new HashMap<>();
protected static Int2ObjectMap<IntSet> proudSkillGroupLevels = new Int2ObjectOpenHashMap<>();
protected static Int2IntMap proudSkillGroupMaxLevels = new Int2IntOpenHashMap();
protected static Int2ObjectMap<IntSet> avatarSkillLevels = new Int2ObjectOpenHashMap<>();
@Getter
private static final Map<String, ConfigLevelEntity> configLevelEntityDataMap = new HashMap<>();
@Getter
private static final Int2ObjectMap<IntSet> proudSkillGroupLevels = new Int2ObjectOpenHashMap<>();
@Getter private static final Int2IntMap proudSkillGroupMaxLevels = new Int2IntOpenHashMap();
@Getter
private static final Int2ObjectMap<IntSet> avatarSkillLevels = new Int2ObjectOpenHashMap<>();
@Getter
private static final Map<String, List<QuestData>> beginCondQuestMap =
new HashMap<>(); // cache filled by QuestData
@Getter private static final Map<Integer, Integer> questTalkMap = new HashMap<>();
@Getter
private static final Int2ObjectMap<TrialAvatarCustomData> trialAvatarCustomData =
new Int2ObjectOpenHashMap<>();
@Getter
private static final Map<Integer, TrialAvatarActivityCustomData> trialAvatarActivityCustomData =
new HashMap<>();
@Getter
private static final Map<Integer, TrialAvatarActivityDataData> trialAvatarActivityDataCustomData =
new HashMap<>();
@Getter
private static final Int2IntMap trialAvatarIndexIdTrialActivityDataDataMap =
new Int2IntOpenHashMap();
private static final Map<Integer, List<Integer>> fetters = new HashMap<>();
private static final Map<Integer, List<ShopGoodsData>> shopGoods = new HashMap<>();
// Getters with wrong names, remove later
@Deprecated(forRemoval = true)
public static Int2ObjectMap<CodexReliquaryData> getcodexReliquaryIdMap() {
return codexReliquaryDataIdMap;
}
@Deprecated(forRemoval = true)
public static Int2ObjectMap<DungeonEntryData> getDungeonEntryDatatMap() {
return dungeonEntryDataMap;
}
@Deprecated(forRemoval = true)
@Tolerate
public static ArrayList<CodexReliquaryData> getcodexReliquaryArrayList() {
return codexReliquaryArrayList;
}
// Getters with different names that stay for now
public static Int2ObjectMap<MainQuestData> getMainQuestDataMap() {
return mainQuestData;
@ -468,6 +564,33 @@ public class GameData {
return shopGoods;
}
/**
* Fetches the route data for a scene by ID.
*
* @param sceneId The ID of the scene to fetch the route data for.
* @return The route data for the scene, or an empty map if the scene has no route data.
*/
public static Int2ObjectMap<Route> getSceneRoutes(int sceneId) {
return sceneRouteData.computeIfAbsent(sceneId, k -> new Int2ObjectOpenHashMap<>());
}
/**
* Fetches the trial data
*
* @param trialAvatarIndexId
* @return
*/
@Nullable public static TrialAvatarActivityDataData getTrialAvatarActivityDataByAvatarIndex(
int trialAvatarIndexId) {
// prefer custom data over official data
val dataId = trialAvatarIndexIdTrialActivityDataDataMap.get(trialAvatarIndexId);
val datamap =
GameData.getTrialAvatarActivityDataCustomData().isEmpty()
? GameData.getTrialAvatarActivityDataDataMap()
: GameData.getTrialAvatarActivityDataCustomData();
return datamap.get(dataId);
}
public static Int2ObjectMap<AchievementData> getAchievementDataMap() {
AchievementData.divideIntoGroups();
return achievementDataMap;

View File

@ -2,8 +2,8 @@ package emu.grasscutter.data;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.data.ResourceLoader.AvatarConfig;
import emu.grasscutter.data.excels.ReliquaryAffixData;
import emu.grasscutter.data.excels.ReliquaryMainPropData;
import emu.grasscutter.data.excels.reliquary.ReliquaryAffixData;
import emu.grasscutter.data.excels.reliquary.ReliquaryMainPropData;
import emu.grasscutter.game.managers.blossom.BlossomConfig;
import emu.grasscutter.game.world.SpawnDataEntry;
import emu.grasscutter.utils.WeightedList;

View File

@ -221,14 +221,13 @@ public class ResourceLoader {
pointData.setId(pointId);
GameData.getScenePointIdList().add(pointId);
GameData.getScenePointEntries().put(scenePoint.getName(), scenePoint);
GameData.scenePointEntryMap.put((sceneId << 16) + pointId, scenePoint);
GameData.getScenePointEntryMap().put((sceneId << 16) + pointId, scenePoint);
pointData.updateDailyDungeon();
});
GameData.getScenePointsPerScene().put(sceneId, scenePoints);
});
} catch (IOException e) {
} catch (IOException ignored) {
Grasscutter.getLogger()
.error("Scene point files cannot be found, you cannot use teleport waypoints!");
}
@ -239,19 +238,23 @@ public class ResourceLoader {
GameData.getProudSkillDataMap()
.forEach(
(id, data) ->
GameData.proudSkillGroupLevels
GameData.getProudSkillGroupLevels()
.computeIfAbsent(data.getProudSkillGroupId(), i -> new IntArraySet())
.add(data.getLevel()));
// All known levels, keyed by avatarSkillId
GameData.getAvatarSkillDataMap()
.forEach(
(id, data) ->
GameData.avatarSkillLevels.put(
(int) id, GameData.proudSkillGroupLevels.get(data.getProudSkillGroupId())));
GameData.getAvatarSkillLevels()
.put(
(int) id,
GameData.getProudSkillGroupLevels().get(data.getProudSkillGroupId())));
// Maximum known levels, keyed by proudSkillGroupId
GameData.proudSkillGroupLevels.forEach(
(id, set) ->
GameData.proudSkillGroupMaxLevels.put((int) id, set.intStream().max().getAsInt()));
GameData.getProudSkillGroupLevels()
.forEach(
(id, set) ->
GameData.getProudSkillGroupMaxLevels()
.put((int) id, set.intStream().max().orElse(-1)));
}
private static void loadAbilityEmbryos() {
@ -266,42 +269,41 @@ public class ResourceLoader {
if (embryoList == null) {
// Load from BinOutput
val pattern = Pattern.compile("ConfigAvatar_(.+?)\\.json");
var pattern = Pattern.compile("ConfigAvatar_(.+?)\\.json");
val l = new ArrayList<AbilityEmbryoEntry>();
try {
Files.newDirectoryStream(getResourcePath("BinOutput/Avatar/"), "ConfigAvatar_*.json")
.forEach(
path -> {
val matcher = pattern.matcher(path.getFileName().toString());
if (!matcher.find()) return;
String avatarName = matcher.group(1);
AvatarConfig config;
var entries = new ArrayList<AbilityEmbryoEntry>();
try (var stream =
Files.newDirectoryStream(getResourcePath("BinOutput/Avatar/"), "ConfigAvatar_*.json")) {
try {
config = JsonUtils.loadToClass(path, AvatarConfig.class);
} catch (Exception e) {
Grasscutter.getLogger().error("Error loading player ability embryos:", e);
return;
}
stream.forEach(
path -> {
var matcher = pattern.matcher(path.getFileName().toString());
if (!matcher.find()) return;
if (config.abilities == null) return;
var avatarName = matcher.group(1);
AvatarConfig config;
try {
config = JsonUtils.loadToClass(path, AvatarConfig.class);
} catch (Exception e) {
Grasscutter.getLogger().error("Error loading player ability embryos:", e);
return;
}
int s = config.abilities.size();
AbilityEmbryoEntry al =
new AbilityEmbryoEntry(
avatarName,
config.abilities.stream()
.map(Object::toString)
.toArray(size -> new String[s]));
l.add(al);
});
if (config.abilities == null) return;
entries.add(
new AbilityEmbryoEntry(
avatarName,
config.abilities.stream()
.map(Object::toString)
.toArray(size -> new String[config.abilities.size()])));
});
} catch (IOException e) {
Grasscutter.getLogger().error("Error loading ability embryos: no files found");
return;
}
embryoList = l;
embryoList = entries;
try {
GameDepot.setPlayerAbilities(
@ -351,7 +353,7 @@ public class ResourceLoader {
}
private static void loadAbilityData(AbilityData data) {
GameData.abilityDataMap.put(data.abilityName, data);
GameData.getAbilityDataMap().put(data.abilityName, data);
val modifiers = data.modifiers;
if (modifiers == null || modifiers.size() == 0) return;

View File

@ -1,4 +1,3 @@
package emu.grasscutter.data.binout.config;
public class ConfigEntityAvatar extends ConfigEntityBase {
}
package emu.grasscutter.data.binout.config;
public class ConfigEntityAvatar extends ConfigEntityBase {}

View File

@ -1,21 +1,17 @@
package emu.grasscutter.data.binout.config;
import emu.grasscutter.data.binout.config.fields.ConfigAbilityData;
import emu.grasscutter.data.binout.config.fields.ConfigCombat;
import emu.grasscutter.data.binout.config.fields.ConfigCommon;
import emu.grasscutter.data.binout.config.fields.ConfigGlobalValue;
import lombok.Data;
import javax.annotation.Nullable;
import java.util.Collection;
@Data
public class ConfigEntityBase {
@Nullable
ConfigCommon configCommon;
@Nullable
ConfigCombat combat;
Collection<ConfigAbilityData> abilities;
ConfigGlobalValue globalValue; // used for SGV in monsters and Gadgets
}
package emu.grasscutter.data.binout.config;
import emu.grasscutter.data.binout.config.fields.ConfigAbilityData;
import emu.grasscutter.data.binout.config.fields.ConfigCombat;
import emu.grasscutter.data.binout.config.fields.ConfigCommon;
import emu.grasscutter.data.binout.config.fields.ConfigGlobalValue;
import java.util.Collection;
import javax.annotation.Nullable;
import lombok.Data;
@Data
public class ConfigEntityBase {
@Nullable ConfigCommon configCommon;
@Nullable ConfigCombat combat;
Collection<ConfigAbilityData> abilities;
ConfigGlobalValue globalValue; // used for SGV in monsters and Gadgets
}

View File

@ -1,11 +1,11 @@
package emu.grasscutter.data.binout.config;
import lombok.AccessLevel;
import lombok.Data;
import lombok.experimental.FieldDefaults;
@Data
@FieldDefaults(level = AccessLevel.PRIVATE)
public class ConfigEntityGadget extends ConfigEntityBase {
// There are more values that can be added that might be useful in the json
}
package emu.grasscutter.data.binout.config;
import lombok.AccessLevel;
import lombok.Data;
import lombok.experimental.FieldDefaults;
@Data
@FieldDefaults(level = AccessLevel.PRIVATE)
public class ConfigEntityGadget extends ConfigEntityBase {
// There are more values that can be added that might be useful in the json
}

View File

@ -1,7 +1,6 @@
package emu.grasscutter.data.binout.config;
import lombok.Data;
@Data
public class ConfigEntityMonster extends ConfigEntityBase {
}
package emu.grasscutter.data.binout.config;
import lombok.Data;
@Data
public class ConfigEntityMonster extends ConfigEntityBase {}

View File

@ -1,14 +1,13 @@
package emu.grasscutter.data.binout.config;
import java.util.List;
import emu.grasscutter.data.binout.config.fields.ConfigAbilityData;
import lombok.Getter;
public class ConfigLevelEntity {
@Getter private List<ConfigAbilityData> abilities; //monster abilities
@Getter private List<ConfigAbilityData> avatarAbilities;
@Getter private List<ConfigAbilityData> teamAbilities;
@Getter private List<Integer> preloadMonsterEntityIDs;
}
package emu.grasscutter.data.binout.config;
import emu.grasscutter.data.binout.config.fields.ConfigAbilityData;
import java.util.List;
import lombok.Getter;
public class ConfigLevelEntity {
@Getter private List<ConfigAbilityData> abilities; // monster abilities
@Getter private List<ConfigAbilityData> avatarAbilities;
@Getter private List<ConfigAbilityData> teamAbilities;
@Getter private List<Integer> preloadMonsterEntityIDs;
}

View File

@ -1,10 +1,10 @@
package emu.grasscutter.data.binout.config.fields;
import lombok.Data;
@Data
public class ConfigAbilityData {
public String abilityID;
public String abilityName;
public String abilityOverride;
}
package emu.grasscutter.data.binout.config.fields;
import lombok.Data;
@Data
public class ConfigAbilityData {
public String abilityID;
public String abilityName;
public String abilityOverride;
}

View File

@ -1,8 +1,8 @@
package emu.grasscutter.data.binout.config.fields;
import lombok.Data;
@Data
public class ConfigAiBeta {
boolean enable;
}
package emu.grasscutter.data.binout.config.fields;
import lombok.Data;
@Data
public class ConfigAiBeta {
boolean enable;
}

View File

@ -1,12 +1,12 @@
package emu.grasscutter.data.binout.config.fields;
import lombok.AccessLevel;
import lombok.Data;
import lombok.experimental.FieldDefaults;
@Data
@FieldDefaults(level = AccessLevel.PRIVATE)
public class ConfigCombat {
// There are more values that can be added that might be useful in the json
ConfigCombatProperty property;
}
package emu.grasscutter.data.binout.config.fields;
import lombok.AccessLevel;
import lombok.Data;
import lombok.experimental.FieldDefaults;
@Data
@FieldDefaults(level = AccessLevel.PRIVATE)
public class ConfigCombat {
// There are more values that can be added that might be useful in the json
ConfigCombatProperty property;
}

View File

@ -1,15 +1,18 @@
package emu.grasscutter.data.binout.config.fields;
import com.google.gson.annotations.SerializedName;
import lombok.AccessLevel;
import lombok.Data;
import lombok.experimental.FieldDefaults;
@Data
@FieldDefaults(level = AccessLevel.PRIVATE)
public class ConfigCombatDie {
@SerializedName(value="dieEndTime", alternate={"HGGPMFGGBNC"})
double dieEndTime;
double dieForceDisappearTime;
boolean hasAnimatorDie;
}
package emu.grasscutter.data.binout.config.fields;
import com.google.gson.annotations.SerializedName;
import lombok.AccessLevel;
import lombok.Data;
import lombok.experimental.FieldDefaults;
@Data
@FieldDefaults(level = AccessLevel.PRIVATE)
public class ConfigCombatDie {
@SerializedName(
value = "dieEndTime",
alternate = {"HGGPMFGGBNC"})
double dieEndTime;
double dieForceDisappearTime;
boolean hasAnimatorDie;
}

View File

@ -1,18 +1,18 @@
package emu.grasscutter.data.binout.config.fields;
import lombok.AccessLevel;
import lombok.Data;
import lombok.experimental.FieldDefaults;
@Data
@FieldDefaults(level = AccessLevel.PRIVATE)
public class ConfigCombatProperty {
float HP;
boolean isLockHP;
boolean isInvincible;
boolean isGhostToAllied;
float attack;
float defence;
float weight;
boolean useCreatorProperty;
}
package emu.grasscutter.data.binout.config.fields;
import lombok.AccessLevel;
import lombok.Data;
import lombok.experimental.FieldDefaults;
@Data
@FieldDefaults(level = AccessLevel.PRIVATE)
public class ConfigCombatProperty {
float HP;
boolean isLockHP;
boolean isInvincible;
boolean isGhostToAllied;
float attack;
float defence;
float weight;
boolean useCreatorProperty;
}

View File

@ -1,7 +1,6 @@
package emu.grasscutter.data.binout.config.fields;
import lombok.Data;
@Data
public class ConfigCommon {
}
package emu.grasscutter.data.binout.config.fields;
import lombok.Data;
@Data
public class ConfigCommon {}

View File

@ -1,15 +1,12 @@
package emu.grasscutter.data.binout.config.fields;
import lombok.Data;
import java.util.Map;
import java.util.Set;
/**
* Contains information about the entities SGVs
*/
@Data
public class ConfigGlobalValue {
Set<String> serverGlobalValues;
Map<String, Float> initServerGlobalValues;
}
package emu.grasscutter.data.binout.config.fields;
import java.util.Map;
import java.util.Set;
import lombok.Data;
/** Contains information about the entities SGVs */
@Data
public class ConfigGlobalValue {
Set<String> serverGlobalValues;
Map<String, Float> initServerGlobalValues;
}

View File

@ -1,23 +1,22 @@
package emu.grasscutter.data.binout.routes;
//import emu.grasscutter.scripts.constants.IntValueEnum;
import lombok.Getter;
public enum RotAngleType /*implements IntValueEnum */{
ROT_NONE(-1),
ROT_ANGLE_X(0),
ROT_ANGLE_Y(1),
ROT_ANGLE_Z(2);
@Getter
private final int id;
RotAngleType(int id) {
this.id = id;
}
//@Override
public int getValue() {
return id;
}
}
package emu.grasscutter.data.binout.routes;
// import emu.grasscutter.scripts.constants.IntValueEnum;
import lombok.Getter;
public enum RotAngleType /*implements IntValueEnum */ {
ROT_NONE(-1),
ROT_ANGLE_X(0),
ROT_ANGLE_Y(1),
ROT_ANGLE_Z(2);
@Getter private final int id;
RotAngleType(int id) {
this.id = id;
}
// @Override
public int getValue() {
return id;
}
}

View File

@ -1,7 +1,7 @@
package emu.grasscutter.data.binout.routes;
public enum RotType {
ROT_NONE,
ROT_ANGLE,
ROT_ROUND
}
package emu.grasscutter.data.binout.routes;
public enum RotType {
ROT_NONE,
ROT_ANGLE,
ROT_ROUND
}

View File

@ -1,31 +1,29 @@
package emu.grasscutter.data.binout.routes;
import emu.grasscutter.net.proto.RouteOuterClass;
import lombok.AccessLevel;
import lombok.Data;
import lombok.experimental.FieldDefaults;
import lombok.val;
@Data
@FieldDefaults(level = AccessLevel.PRIVATE)
public class Route {
private int localId;
private String name;
private RouteType type = RouteType.Unknown;
private RoutePoint[] points;
private float arriveRange; // optional
private RotType rotType; // optional
private RotAngleType rotAngleType; // optional
public RouteOuterClass.Route toProto(){
val builder = RouteOuterClass.Route.newBuilder()
.setRouteType(type.getValue());
if(points !=null){
for(var routePoint : points){
builder.addRoutePoints(routePoint.toProto()
.setArriveRange(arriveRange));
}
}
return builder.build();
}
}
package emu.grasscutter.data.binout.routes;
import emu.grasscutter.net.proto.RouteOuterClass;
import lombok.AccessLevel;
import lombok.Data;
import lombok.experimental.FieldDefaults;
import lombok.val;
@Data
@FieldDefaults(level = AccessLevel.PRIVATE)
public class Route {
private int localId;
private String name;
private RouteType type = RouteType.Unknown;
private RoutePoint[] points;
private float arriveRange; // optional
private RotType rotType; // optional
private RotAngleType rotAngleType; // optional
public RouteOuterClass.Route toProto() {
val builder = RouteOuterClass.Route.newBuilder().setRouteType(type.getValue());
if (points != null) {
for (var routePoint : points) {
builder.addRoutePoints(routePoint.toProto().setArriveRange(arriveRange));
}
}
return builder.build();
}
}

View File

@ -1,34 +1,31 @@
package emu.grasscutter.data.binout.routes;
import emu.grasscutter.net.proto.RoutePointOuterClass;
import emu.grasscutter.utils.Position;
import lombok.AccessLevel;
import lombok.Data;
import lombok.Getter;
import lombok.experimental.FieldDefaults;
import lombok.val;
@Data
@FieldDefaults(level = AccessLevel.PRIVATE)
public class RoutePoint {
private Position pos;
private int speedLevel; //optional
private float waitTime; //optional
private float targetVelocity; //optional
private boolean hasReachEvent; //optional
// rotRoundReachDir //optional Pos with optional values
// rotRoundLeaveDir //optional Pos with optional values
public RoutePointOuterClass.RoutePoint.Builder toProto(){
val builder = RoutePointOuterClass.RoutePoint.newBuilder()
.setPosition(pos.toProto());
if(waitTime!=0){
builder.setTime(waitTime);
} else if(targetVelocity!=0){
builder.setVelocity(targetVelocity);
}
return builder;
}
}
package emu.grasscutter.data.binout.routes;
import emu.grasscutter.net.proto.RoutePointOuterClass;
import emu.grasscutter.utils.Position;
import lombok.AccessLevel;
import lombok.Data;
import lombok.experimental.FieldDefaults;
import lombok.val;
@Data
@FieldDefaults(level = AccessLevel.PRIVATE)
public class RoutePoint {
private Position pos;
private int speedLevel; // optional
private float waitTime; // optional
private float targetVelocity; // optional
private boolean hasReachEvent; // optional
// rotRoundReachDir //optional Pos with optional values
// rotRoundLeaveDir //optional Pos with optional values
public RoutePointOuterClass.RoutePoint.Builder toProto() {
val builder = RoutePointOuterClass.RoutePoint.newBuilder().setPosition(pos.toProto());
if (waitTime != 0) {
builder.setTime(waitTime);
} else if (targetVelocity != 0) {
builder.setVelocity(targetVelocity);
}
return builder;
}
}

View File

@ -1,23 +1,22 @@
package emu.grasscutter.data.binout.routes;
//import emu.grasscutter.scripts.constants.IntValueEnum;
import lombok.Getter;
public enum RouteType /*implements IntValueEnum*/ {
Unknown(-1),
OneWay(0),
Reciprocate(1),
Loop(2);
@Getter
private final int id;
RouteType(int id) {
this.id = id;
}
//@Override
public int getValue() {
return id;
}
}
package emu.grasscutter.data.binout.routes;
// import emu.grasscutter.scripts.constants.IntValueEnum;
import lombok.Getter;
public enum RouteType /*implements IntValueEnum*/ {
Unknown(-1),
OneWay(0),
Reciprocate(1),
Loop(2);
@Getter private final int id;
RouteType(int id) {
this.id = id;
}
// @Override
public int getValue() {
return id;
}
}

View File

@ -1,15 +1,13 @@
package emu.grasscutter.data.binout.routes;
import lombok.AccessLevel;
import lombok.Data;
import lombok.Getter;
import lombok.experimental.FieldDefaults;
import javax.annotation.Nullable;
@Data
@FieldDefaults(level = AccessLevel.PRIVATE)
public class SceneRoutes {
private int sceneId;
@Nullable private Route[] routes;
}
package emu.grasscutter.data.binout.routes;
import javax.annotation.Nullable;
import lombok.AccessLevel;
import lombok.Data;
import lombok.experimental.FieldDefaults;
@Data
@FieldDefaults(level = AccessLevel.PRIVATE)
public class SceneRoutes {
private int sceneId;
@Nullable private Route[] routes;
}

View File

@ -1,8 +1,9 @@
package emu.grasscutter.data.common;
import java.util.List;
public interface BaseTrialActivityData {
List<Integer> getAvatarIndexIdList();
List<Integer> getRewardIdList();
}
package emu.grasscutter.data.common;
import java.util.List;
public interface BaseTrialActivityData {
List<Integer> getAvatarIndexIdList();
List<Integer> getRewardIdList();
}

View File

@ -3,7 +3,7 @@ package emu.grasscutter.data.common;
import com.google.gson.annotations.SerializedName;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.excels.DailyDungeonData;
import emu.grasscutter.data.excels.dungeon.DailyDungeonData;
import emu.grasscutter.utils.Position;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;

View File

@ -1,17 +1,17 @@
package emu.grasscutter.data.custom;
import emu.grasscutter.data.common.BaseTrialActivityData;
import lombok.*;
import java.util.List;
@Data
public class TrialAvatarActivityCustomData implements BaseTrialActivityData {
private int ScheduleId;
private List<Integer> AvatarIndexIdList;
private List<Integer> RewardIdList;
public void onLoad() {
this.AvatarIndexIdList = AvatarIndexIdList.stream().filter(x -> x > 0).toList();
this.RewardIdList = RewardIdList.stream().filter(x -> x > 0).toList();
}
}
package emu.grasscutter.data.custom;
import emu.grasscutter.data.common.BaseTrialActivityData;
import java.util.List;
import lombok.*;
@Data
public class TrialAvatarActivityCustomData implements BaseTrialActivityData {
private int ScheduleId;
private List<Integer> AvatarIndexIdList;
private List<Integer> RewardIdList;
public void onLoad() {
this.AvatarIndexIdList = AvatarIndexIdList.stream().filter(x -> x > 0).toList();
this.RewardIdList = RewardIdList.stream().filter(x -> x > 0).toList();
}
}

View File

@ -1,16 +1,16 @@
package emu.grasscutter.data.custom;
import lombok.*;
import java.util.List;
@Data
public class TrialAvatarCustomData {
private int trialAvatarId;
private List<String> trialAvatarParamList;
private int coreProudSkillLevel;
private int skillDepotId;
public void onLoad() {
this.trialAvatarParamList = trialAvatarParamList.stream().filter(x -> !x.isBlank()).toList();
}
}
package emu.grasscutter.data.custom;
import java.util.List;
import lombok.*;
@Data
public class TrialAvatarCustomData {
private int trialAvatarId;
private List<String> trialAvatarParamList;
private int coreProudSkillLevel;
private int skillDepotId;
public void onLoad() {
this.trialAvatarParamList = trialAvatarParamList.stream().filter(x -> !x.isBlank()).toList();
}
}

View File

@ -1,33 +0,0 @@
package emu.grasscutter.data.excels;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import lombok.Getter;
@ResourceType(name = "DungeonExcelConfigData.json")
public class DungeonData extends GameResource {
@Getter(onMethod_ = @Override)
private int id;
@Getter private int sceneId;
@Getter private int showLevel;
private int passRewardPreviewID;
private String involveType; // TODO enum
private RewardPreviewData previewData;
@Getter private int statueCostID;
@Getter private int statueCostCount;
public RewardPreviewData getRewardPreview() {
return previewData;
}
@Override
public void onLoad() {
if (this.passRewardPreviewID > 0) {
this.previewData = GameData.getRewardPreviewDataMap().get(this.passRewardPreviewID);
}
}
}

View File

@ -1,26 +1,27 @@
package emu.grasscutter.data.excels;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data @EqualsAndHashCode(callSuper=false)
@ResourceType(name = "GuideTriggerExcelConfigData.json")
public class GuideTriggerData extends GameResource {
// more like open state guide than quest guide
private int id; // dont use, just to prevent resource loader from not functioning
private String guideName;
private String type;
private String openState;
@Override
public int getId() {
return this.id;
}
public void onLoad() {
GameData.getGuideTriggerDataStringMap().put(getGuideName(), this);
}
}
package emu.grasscutter.data.excels;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = false)
@ResourceType(name = "GuideTriggerExcelConfigData.json")
public class GuideTriggerData extends GameResource {
// more like open state guide than quest guide
private int id; // dont use, just to prevent resource loader from not functioning
private String guideName;
private String type;
private String openState;
@Override
public int getId() {
return this.id;
}
public void onLoad() {
GameData.getGuideTriggerDataStringMap().put(getGuideName(), this);
}
}

View File

@ -1,109 +1,121 @@
package emu.grasscutter.data.excels;
import com.google.gson.annotations.SerializedName;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import emu.grasscutter.game.quest.enums.LogicType;
import emu.grasscutter.game.quest.enums.QuestTrigger;
import emu.grasscutter.game.quest.enums.*;
import java.util.ArrayList;
import java.util.List;
import lombok.AccessLevel;
import lombok.Data;
import lombok.Getter;
import lombok.ToString;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import lombok.*;
import lombok.experimental.FieldDefaults;
@ResourceType(name = "QuestExcelConfigData.json")
@Getter
@ToString
public class QuestData extends GameResource {
private int subId;
private int mainId;
private int order;
private long descTextMapHash;
@Getter private int subId;
@Getter private int mainId;
@Getter private int order;
@Getter private long descTextMapHash;
private boolean finishParent;
private boolean isRewind;
@Getter private boolean finishParent;
@Getter private boolean isRewind;
private LogicType acceptCondComb;
private LogicType finishCondComb;
private LogicType failCondComb;
@Getter private LogicType acceptCondComb;
@Getter private LogicType finishCondComb;
@Getter private LogicType failCondComb;
private List<QuestCondition> acceptCond;
private List<QuestCondition> finishCond;
private List<QuestCondition> failCond;
private List<QuestExecParam> beginExec;
private List<QuestExecParam> finishExec;
private List<QuestExecParam> failExec;
private Guide guide;
@Getter private List<QuestAcceptCondition> acceptCond;
@Getter private List<QuestContentCondition> finishCond;
@Getter private List<QuestContentCondition> failCond;
@Getter private List<QuestExecParam> beginExec;
@Getter private List<QuestExecParam> finishExec;
@Getter private List<QuestExecParam> failExec;
@Getter private Guide guide;
@Getter private List<Integer> trialAvatarList;
public static String questConditionKey(
@Nonnull Enum<?> type, int firstParam, @Nullable String paramsStr) {
return type.name() + firstParam + (paramsStr != null ? paramsStr : "");
}
// ResourceLoader not happy if you remove getId() ~~
public int getId() {
return subId;
}
// Added getSubId() for clarity
public int getSubId() {
return subId;
}
public int getMainId() {
return mainId;
}
public int getOrder() {
return order;
}
public long getDescTextMapHash() {
return descTextMapHash;
}
public boolean finishParent() {
return finishParent;
}
public boolean isRewind() {
return isRewind;
}
public LogicType getAcceptCondComb() {
return acceptCondComb == null ? LogicType.LOGIC_NONE : acceptCondComb;
}
public List<QuestCondition> getAcceptCond() {
return acceptCond;
}
public LogicType getFinishCondComb() {
return finishCondComb == null ? LogicType.LOGIC_NONE : finishCondComb;
}
public List<QuestCondition> getFinishCond() {
return finishCond;
}
public LogicType getFailCondComb() {
return failCondComb == null ? LogicType.LOGIC_NONE : failCondComb;
}
public List<QuestCondition> getFailCond() {
return failCond;
}
public void onLoad() {
this.acceptCond = acceptCond.stream().filter(p -> p.type != null).toList();
this.finishCond = finishCond.stream().filter(p -> p.type != null).toList();
this.failCond = failCond.stream().filter(p -> p.type != null).toList();
this.acceptCond = acceptCond.stream().filter(p -> p.getType() != null).toList();
this.finishCond = finishCond.stream().filter(p -> p.getType() != null).toList();
this.failCond = failCond.stream().filter(p -> p.getType() != null).toList();
this.beginExec = beginExec.stream().filter(p -> p.type != null).toList();
this.finishExec = finishExec.stream().filter(p -> p.type != null).toList();
this.failExec = failExec.stream().filter(p -> p.type != null).toList();
if (this.acceptCondComb == null) this.acceptCondComb = LogicType.LOGIC_NONE;
if (this.finishCondComb == null) this.finishCondComb = LogicType.LOGIC_NONE;
if (this.failCondComb == null) this.failCondComb = LogicType.LOGIC_NONE;
addToCache();
}
private void addToCache() {
if (this.acceptCond == null) {
Grasscutter.getLogger().warn("missing AcceptConditions for quest {}", getSubId());
return;
}
var cacheMap = GameData.getBeginCondQuestMap();
if (getAcceptCond().isEmpty()) {
var list =
cacheMap.computeIfAbsent(
QuestData.questConditionKey(QuestCond.QUEST_COND_NONE, 0, null),
e -> new ArrayList<>());
list.add(this);
} else {
this.getAcceptCond()
.forEach(
questCondition -> {
if (questCondition.getType() == null) {
Grasscutter.getLogger().warn("null accept type for quest {}", getSubId());
return;
}
var key = questCondition.asKey();
var list = cacheMap.computeIfAbsent(key, e -> new ArrayList<>());
list.add(this);
});
}
}
@Data
public static class QuestCondition {
@FieldDefaults(level = AccessLevel.PRIVATE)
public static class QuestExecParam {
@SerializedName("_type")
private QuestTrigger type;
QuestExec type;
@SerializedName("_param")
String[] param;
@SerializedName("_count")
String count;
}
public static class QuestAcceptCondition extends QuestCondition<QuestCond> {}
public static class QuestContentCondition extends QuestCondition<QuestContent> {}
@Data
public static class QuestCondition<TYPE extends Enum<?> & QuestTrigger> {
@SerializedName("_type")
private TYPE type;
@SerializedName("_param")
private int[] param;
@ -112,7 +124,11 @@ public class QuestData extends GameResource {
private String paramStr;
@SerializedName("_count")
private String count;
private int count;
public String asKey() {
return questConditionKey(getType(), getParam()[0], getParamStr());
}
}
@Data
@ -121,17 +137,4 @@ public class QuestData extends GameResource {
private List<String> param;
private int guideScene;
}
@Data
@FieldDefaults(level = AccessLevel.PRIVATE)
public class QuestExecParam {
@SerializedName("_type")
QuestTrigger type;
@SerializedName("_param")
String[] param;
@SerializedName("_count")
String count;
}
}

View File

@ -1,81 +1,85 @@
package emu.grasscutter.data.excels;
import java.util.Arrays;
import java.util.List;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import emu.grasscutter.game.props.RefreshType;
import emu.grasscutter.game.world.World;
import lombok.Getter;
@ResourceType(name = "RefreshPolicyExcelConfigData.json")
public class RefreshPolicyExcelConfigData extends GameResource {
@Getter private int id;
@Getter private RefreshType type;
@Getter private String time;
private static int upperBound(List<Integer> list, int low, int high, int value) {
while (low < high) {
int middle = (high + low) / 2;
if(list.size() >= middle) return low; //Just in case
if (list.get(middle) > value) {
high = middle;
} else {
low = middle + 1;
}
}
return low;
}
public int getIntervalInSeconds(World world) {
if(time.isEmpty()) return -1;
var currentTimestamp = world.getTotalGameTimeMinutes();
try {
List<String> paramsStr = Arrays.asList(time.split(";"));
List<Integer> params = paramsStr.stream().map(Integer::parseInt).toList();
switch(type) {
case REFRESH_NONE:
return -1;
case REFRESH_INTERVAL:
if(params.isEmpty()) return -1;
return params.get(0);
case REFRESH_DAILY:
{
var dayTime = (world.getTotalGameTimeMinutes() / (24 * 60)) * 24 * 60 * 60;
var temp = currentTimestamp - dayTime;
var upper_bound_idx = upperBound(params, (int)params.get(0), (int)params.get(params.size() - 1), (int)temp);
var upper_bound = params.get(upper_bound_idx);
if(params.get(params.size() - 1) == upper_bound) {
return (params.get(params.size() - 1) - params.get(0)) + 60 * 60 * 24 * 7;
} else if(params.get(0) == upper_bound) {
return (params.get(params.size() - 1) - params.get(0)) + 60 * 60 * 24 * 7;
}
return (params.get(upper_bound_idx - 1) - params.get(0));
}
case REFRESH_WEEKlY:
if(params.size() < 2) return -1;
{
var weekTime = (world.getTotalGameTimeDays() / 7) * 60 * 60 * 24 * 7;
var temp = currentTimestamp - weekTime;
var upper_bound_idx = upperBound(params, (int)params.get(0), (int)params.get(params.size() - 1), (int)temp);
var upper_bound = params.get(upper_bound_idx);
if(params.get(params.size() - 1) == upper_bound) {
return (params.get(params.size() - 1) - params.get(0)) + 60 * 60 * 24 * 7;
} else if(params.get(0) == upper_bound) {
return (params.get(params.size() - 1) - params.get(0)) + 60 * 60 * 24 * 7;
}
return (params.get(upper_bound_idx - 1) - params.get(0));
}
case REFRESH_DAYBEGIN_INTERVAL:
if(params.size() == 0) return -1;
return params.get(0) * 60 * 60 * 24;
}
} catch(Exception e) {}
return -1;
}
}
package emu.grasscutter.data.excels;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import emu.grasscutter.game.props.RefreshType;
import emu.grasscutter.game.world.World;
import java.util.Arrays;
import java.util.List;
import lombok.Getter;
@ResourceType(name = "RefreshPolicyExcelConfigData.json")
public class RefreshPolicyExcelConfigData extends GameResource {
@Getter private int id;
@Getter private RefreshType type;
@Getter private String time;
private static int upperBound(List<Integer> list, int low, int high, int value) {
while (low < high) {
int middle = (high + low) / 2;
if (list.size() >= middle) return low; // Just in case
if (list.get(middle) > value) {
high = middle;
} else {
low = middle + 1;
}
}
return low;
}
public int getIntervalInSeconds(World world) {
if (time.isEmpty()) return -1;
var currentTimestamp = world.getTotalGameTimeMinutes();
try {
List<String> paramsStr = Arrays.asList(time.split(";"));
List<Integer> params = paramsStr.stream().map(Integer::parseInt).toList();
switch (type) {
case REFRESH_NONE:
return -1;
case REFRESH_INTERVAL:
if (params.isEmpty()) return -1;
return params.get(0);
case REFRESH_DAILY:
{
var dayTime = (world.getTotalGameTimeMinutes() / (24 * 60)) * 24 * 60 * 60;
var temp = currentTimestamp - dayTime;
var upper_bound_idx =
upperBound(
params, (int) params.get(0), (int) params.get(params.size() - 1), (int) temp);
var upper_bound = params.get(upper_bound_idx);
if (params.get(params.size() - 1) == upper_bound) {
return (params.get(params.size() - 1) - params.get(0)) + 60 * 60 * 24 * 7;
} else if (params.get(0) == upper_bound) {
return (params.get(params.size() - 1) - params.get(0)) + 60 * 60 * 24 * 7;
}
return (params.get(upper_bound_idx - 1) - params.get(0));
}
case REFRESH_WEEKlY:
if (params.size() < 2) return -1;
{
var weekTime = (world.getTotalGameTimeDays() / 7) * 60 * 60 * 24 * 7;
var temp = currentTimestamp - weekTime;
var upper_bound_idx =
upperBound(
params, (int) params.get(0), (int) params.get(params.size() - 1), (int) temp);
var upper_bound = params.get(upper_bound_idx);
if (params.get(params.size() - 1) == upper_bound) {
return (params.get(params.size() - 1) - params.get(0)) + 60 * 60 * 24 * 7;
} else if (params.get(0) == upper_bound) {
return (params.get(params.size() - 1) - params.get(0)) + 60 * 60 * 24 * 7;
}
return (params.get(upper_bound_idx - 1) - params.get(0));
}
case REFRESH_DAYBEGIN_INTERVAL:
if (params.size() == 0) return -1;
return params.get(0) * 60 * 60 * 24;
}
} catch (Exception e) {
}
return -1;
}
}

View File

@ -4,6 +4,7 @@ import com.google.gson.annotations.SerializedName;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import emu.grasscutter.game.props.SceneType;
import java.util.List;
import lombok.Getter;
@ResourceType(name = "SceneExcelConfigData.json")
@ -16,4 +17,6 @@ public class SceneData extends GameResource {
private SceneType sceneType;
private String scriptData;
private String levelEntityConfig;
private List<Integer> specifiedAvatarList;
}

View File

@ -1,9 +1,10 @@
package emu.grasscutter.data.excels;
package emu.grasscutter.data.excels.achievement;
import com.github.davidmoten.guavamini.Lists;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import emu.grasscutter.data.excels.BattlePassMissionData;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

View File

@ -1,13 +1,13 @@
package emu.grasscutter.data.excels;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import lombok.Getter;
@Getter
@ResourceType(name = "AchievementGoalExcelConfigData.json")
public class AchievementGoalData extends GameResource {
private int id;
private long nameTextMapHash;
private int finishRewardId;
}
package emu.grasscutter.data.excels.achievement;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import lombok.Getter;
@Getter
@ResourceType(name = "AchievementGoalExcelConfigData.json")
public class AchievementGoalData extends GameResource {
private int id;
private long nameTextMapHash;
private int finishRewardId;
}

View File

@ -1,41 +1,38 @@
package emu.grasscutter.data.excels;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import emu.grasscutter.game.activity.condition.ActivityConditions;
import emu.grasscutter.game.quest.enums.LogicType;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.experimental.FieldDefaults;
import java.util.List;
@ResourceType(name = "NewActivityCondExcelConfigData.json")
@Getter
@FieldDefaults(level = AccessLevel.PRIVATE)
public class ActivityCondExcelConfigData extends GameResource {
int condId;
LogicType condComb;
List<ActivityConfigCondition> cond;
public static class ActivityConfigCondition {
@Getter
private ActivityConditions type;
@Getter
private List<Integer> param;
public int[] paramArray() {
return param.stream().mapToInt(Integer::intValue).toArray();
}
}
@Override
public int getId() {
return condId;
}
@Override
public void onLoad() {
cond.removeIf(c -> c.type == null);
}
}
package emu.grasscutter.data.excels.activity;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import emu.grasscutter.game.activity.condition.ActivityConditions;
import emu.grasscutter.game.quest.enums.LogicType;
import java.util.List;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.experimental.FieldDefaults;
@ResourceType(name = "NewActivityCondExcelConfigData.json")
@Getter
@FieldDefaults(level = AccessLevel.PRIVATE)
public class ActivityCondExcelConfigData extends GameResource {
int condId;
LogicType condComb;
List<ActivityConfigCondition> cond;
public static class ActivityConfigCondition {
@Getter private ActivityConditions type;
@Getter private List<Integer> param;
public int[] paramArray() {
return param.stream().mapToInt(Integer::intValue).toArray();
}
}
@Override
public int getId() {
return condId;
}
@Override
public void onLoad() {
cond.removeIf(c -> c.type == null);
}
}

View File

@ -1,4 +1,4 @@
package emu.grasscutter.data.excels;
package emu.grasscutter.data.excels.activity;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.GameResource;

View File

@ -1,4 +1,4 @@
package emu.grasscutter.data.excels;
package emu.grasscutter.data.excels.activity;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;

View File

@ -1,4 +1,4 @@
package emu.grasscutter.data.excels;
package emu.grasscutter.data.excels.activity;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
@ -23,9 +23,10 @@ public class ActivityWatcherData extends GameResource {
@Override
public void onLoad() {
triggerConfig.paramList =
triggerConfig.paramList.stream().filter(x -> (x != null) && !x.isBlank()).toList();
triggerConfig.watcherTriggerType = WatcherTriggerType.getTypeByName(triggerConfig.triggerType);
this.triggerConfig.paramList =
this.triggerConfig.paramList.stream().filter(x -> (x != null) && !x.isBlank()).toList();
this.triggerConfig.watcherTriggerType =
WatcherTriggerType.getTypeByName(this.triggerConfig.triggerType);
}
@Getter
@ -35,5 +36,10 @@ public class ActivityWatcherData extends GameResource {
List<String> paramList;
transient WatcherTriggerType watcherTriggerType;
public void onLoad() {
this.paramList = this.paramList.stream().filter(x -> (x != null) && !x.isBlank()).toList();
this.watcherTriggerType = WatcherTriggerType.getTypeByName(this.triggerType);
}
}
}

View File

@ -1,4 +1,4 @@
package emu.grasscutter.data.excels;
package emu.grasscutter.data.excels.avatar;
import com.google.gson.annotations.SerializedName;
import emu.grasscutter.data.GameData;

View File

@ -1,4 +1,4 @@
package emu.grasscutter.data.excels;
package emu.grasscutter.data.excels.avatar;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;

View File

@ -1,4 +1,4 @@
package emu.grasscutter.data.excels;
package emu.grasscutter.data.excels.avatar;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.GameResource;
@ -173,16 +173,22 @@ public class AvatarData extends GameResource {
*/
// Cache abilities
String[] split = this.iconName.split("_");
this.buildEmbryo();
}
/**
* Create ability embryos.
*/
public void buildEmbryo() {
var split = this.iconName.split("_");
if (split.length > 0) {
this.name = split[split.length - 1];
AbilityEmbryoEntry info = GameData.getAbilityEmbryoInfo().get(this.name);
var info = GameData.getAbilityEmbryoInfo().get(this.name);
if (info != null) {
this.abilities = new IntArrayList(info.getAbilities().length);
for (String ability : info.getAbilities()) {
for (var ability : info.getAbilities())
this.abilities.add(Utils.abilityHash(ability));
}
}
}
}

View File

@ -1,4 +1,4 @@
package emu.grasscutter.data.excels;
package emu.grasscutter.data.excels.avatar;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;

View File

@ -1,4 +1,4 @@
package emu.grasscutter.data.excels;
package emu.grasscutter.data.excels.avatar;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;

View File

@ -1,4 +1,4 @@
package emu.grasscutter.data.excels;
package emu.grasscutter.data.excels.avatar;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;

View File

@ -1,4 +1,4 @@
package emu.grasscutter.data.excels;
package emu.grasscutter.data.excels.avatar;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;

View File

@ -1,22 +1,24 @@
package emu.grasscutter.data.excels;
import com.google.gson.annotations.SerializedName;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@ResourceType(name = "AvatarReplaceCostumeExcelConfigData.json")
@EqualsAndHashCode(callSuper=false)
public class AvatarReplaceCostumeData extends GameResource {
private int avatarId;
@SerializedName(value = "costumeId", alternate={"MGLCOPOIJIC", "BDBMOBGKIAP"})
private int costumeId;
@Override
public int getId() {
return costumeId;
}
}
package emu.grasscutter.data.excels.avatar;
import com.google.gson.annotations.SerializedName;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@ResourceType(name = "AvatarReplaceCostumeExcelConfigData.json")
@EqualsAndHashCode(callSuper = false)
public class AvatarReplaceCostumeData extends GameResource {
private int avatarId;
@SerializedName(
value = "costumeId",
alternate = {"MGLCOPOIJIC", "BDBMOBGKIAP"})
private int costumeId;
@Override
public int getId() {
return costumeId;
}
}

View File

@ -1,4 +1,4 @@
package emu.grasscutter.data.excels;
package emu.grasscutter.data.excels.avatar;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;

View File

@ -1,4 +1,4 @@
package emu.grasscutter.data.excels;
package emu.grasscutter.data.excels.avatar;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.GameDepot;

View File

@ -1,4 +1,4 @@
package emu.grasscutter.data.excels;
package emu.grasscutter.data.excels.avatar;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;

View File

@ -1,4 +1,4 @@
package emu.grasscutter.data.excels;
package emu.grasscutter.data.excels.codex;
import com.google.gson.annotations.SerializedName;
import emu.grasscutter.data.GameResource;

View File

@ -1,29 +1,29 @@
package emu.grasscutter.data.excels;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
@ResourceType(name = {"MaterialCodexExcelConfigData.json"})
public class CodexMaterialData extends GameResource {
private int Id;
private int materialId;
private int sortOrder;
public int getSortOrder() {
return sortOrder;
}
public int getMaterialId() {
return materialId;
}
public int getId() {
return Id;
}
@Override
public void onLoad() {
GameData.getCodexMaterialDataIdMap().put(this.getMaterialId(), this);
}
}
package emu.grasscutter.data.excels.codex;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
@ResourceType(name = {"MaterialCodexExcelConfigData.json"})
public class CodexMaterialData extends GameResource {
private int Id;
private int materialId;
private int sortOrder;
public int getSortOrder() {
return sortOrder;
}
public int getMaterialId() {
return materialId;
}
public int getId() {
return Id;
}
@Override
public void onLoad() {
GameData.getCodexMaterialDataIdMap().put(this.getMaterialId(), this);
}
}

View File

@ -1,4 +1,4 @@
package emu.grasscutter.data.excels;
package emu.grasscutter.data.excels.codex;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.GameResource;

View File

@ -1,4 +1,4 @@
package emu.grasscutter.data.excels;
package emu.grasscutter.data.excels.codex;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.GameResource;

View File

@ -1,29 +1,29 @@
package emu.grasscutter.data.excels;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
@ResourceType(name = {"WeaponCodexExcelConfigData.json"})
public class CodexWeaponData extends GameResource {
private int Id;
private int weaponId;
private int sortOrder;
public int getSortOrder() {
return sortOrder;
}
public int getWeaponId() {
return weaponId;
}
public int getId() {
return Id;
}
@Override
public void onLoad() {
GameData.getCodexWeaponDataIdMap().put(this.getWeaponId(), this);
}
}
package emu.grasscutter.data.excels.codex;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
@ResourceType(name = {"WeaponCodexExcelConfigData.json"})
public class CodexWeaponData extends GameResource {
private int Id;
private int weaponId;
private int sortOrder;
public int getSortOrder() {
return sortOrder;
}
public int getWeaponId() {
return weaponId;
}
public int getId() {
return Id;
}
@Override
public void onLoad() {
GameData.getCodexWeaponDataIdMap().put(this.getWeaponId(), this);
}
}

View File

@ -1,4 +1,4 @@
package emu.grasscutter.data.excels;
package emu.grasscutter.data.excels.dungeon;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;

View File

@ -1,72 +1,82 @@
package emu.grasscutter.data.excels;
import com.google.gson.annotations.SerializedName;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import emu.grasscutter.game.dungeons.challenge.enums.ChallengeType;
import lombok.Getter;
import java.util.HashSet;
@Getter
@ResourceType(name = "DungeonChallengeConfigData.json")
public class DungeonChallengeConfigData extends GameResource {
private int id;
private ChallengeType challengeType;
private boolean noSuccessHint;
private boolean noFailHint;
private boolean isBlockTopTimer;
private int subChallengeFadeOutDelayTime;
private int activitySkillId;
private HashSet<String> teamAbilityGroupList;
private SubChallengeFadeOutType subChallengeFadeOutRule;
private SubChallengeBannerType subChallengeBannerRule;
private InterruptButtonType interruptButtonType;
@SerializedName(value = "subChallengeSortType", alternate={"PNCLDNBHKDJ"})
private SubChallengeSortType subChallengeSortType;
@SerializedName(value = "animationOnSubStart", alternate={"DNFAFNMMMDP"})
private AllowAnimationType animationOnSubStart;
@SerializedName(value = "animationOnSubSuccess", alternate={"ENONHOGJDDN"})
private AllowAnimationType animationOnSubSuccess;
@SerializedName(value = "animationOnSubFail", alternate={"NJBJIKAIENN"})
private AllowAnimationType animationOnSubFail;
public int getId() {
return id;
}
public enum InterruptButtonType{
INTERRUPT_BUTTON_TYPE_NONE,
INTERRUPT_BUTTON_TYPE_HOST,
INTERRUPT_BUTTON_TYPE_ALL
}
public enum SubChallengeFadeOutType{
SUBCHALLENGE_FADEOUT_TYPE_NONE,
SUBCHALLENGE_FADEOUT_TYPE_SUCCESS,
SUBCHALLENGE_FADEOUT_TYPE_FAIL,
SUBCHALLENGE_FADEOUT_TYPE_FINISH
}
public enum SubChallengeBannerType{
SUBCHALLENGE_BANNER_TYPE_NONE,
SUBCHALLENGE_BANNER_TYPE_SUCCESS,
SUBCHALLENGE_BANNER_TYPE_FAIL,
SUBCHALLENGE_BANNER_TYPE_HIDE_FINAL,
SUBCHALLENGE_BANNER_TYPE_SHOW_FINAL
}
public enum SubChallengeSortType{
SUB_CHALLENGE_SORT_TYPE_DEFAULT,
SUB_CHALLENGE_SORT_TYPE_CHALLENGEINDEX
}
public enum AllowAnimationType{
SUB_CHALLENGE_ANIM_TYPE_DEFAULT,
SUB_CHALLENGE_ANIM_TYPE_FORBID,
SUB_CHALLENGE_ANIM_TYPE_SUCCESS,
SUB_CHALLENGE_ANIM_TYPE_FAIL
}
}
package emu.grasscutter.data.excels.dungeon;
import com.google.gson.annotations.SerializedName;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import emu.grasscutter.game.dungeons.challenge.enums.ChallengeType;
import java.util.HashSet;
import lombok.Getter;
@Getter
@ResourceType(name = "DungeonChallengeConfigData.json")
public class DungeonChallengeConfigData extends GameResource {
private int id;
private ChallengeType challengeType;
private boolean noSuccessHint;
private boolean noFailHint;
private boolean isBlockTopTimer;
private int subChallengeFadeOutDelayTime;
private int activitySkillId;
private HashSet<String> teamAbilityGroupList;
private SubChallengeFadeOutType subChallengeFadeOutRule;
private SubChallengeBannerType subChallengeBannerRule;
private InterruptButtonType interruptButtonType;
@SerializedName(
value = "subChallengeSortType",
alternate = {"PNCLDNBHKDJ"})
private SubChallengeSortType subChallengeSortType;
@SerializedName(
value = "animationOnSubStart",
alternate = {"DNFAFNMMMDP"})
private AllowAnimationType animationOnSubStart;
@SerializedName(
value = "animationOnSubSuccess",
alternate = {"ENONHOGJDDN"})
private AllowAnimationType animationOnSubSuccess;
@SerializedName(
value = "animationOnSubFail",
alternate = {"NJBJIKAIENN"})
private AllowAnimationType animationOnSubFail;
public int getId() {
return id;
}
public enum InterruptButtonType {
INTERRUPT_BUTTON_TYPE_NONE,
INTERRUPT_BUTTON_TYPE_HOST,
INTERRUPT_BUTTON_TYPE_ALL
}
public enum SubChallengeFadeOutType {
SUBCHALLENGE_FADEOUT_TYPE_NONE,
SUBCHALLENGE_FADEOUT_TYPE_SUCCESS,
SUBCHALLENGE_FADEOUT_TYPE_FAIL,
SUBCHALLENGE_FADEOUT_TYPE_FINISH
}
public enum SubChallengeBannerType {
SUBCHALLENGE_BANNER_TYPE_NONE,
SUBCHALLENGE_BANNER_TYPE_SUCCESS,
SUBCHALLENGE_BANNER_TYPE_FAIL,
SUBCHALLENGE_BANNER_TYPE_HIDE_FINAL,
SUBCHALLENGE_BANNER_TYPE_SHOW_FINAL
}
public enum SubChallengeSortType {
SUB_CHALLENGE_SORT_TYPE_DEFAULT,
SUB_CHALLENGE_SORT_TYPE_CHALLENGEINDEX
}
public enum AllowAnimationType {
SUB_CHALLENGE_ANIM_TYPE_DEFAULT,
SUB_CHALLENGE_ANIM_TYPE_FORBID,
SUB_CHALLENGE_ANIM_TYPE_SUCCESS,
SUB_CHALLENGE_ANIM_TYPE_FAIL
}
}

View File

@ -0,0 +1,71 @@
package emu.grasscutter.data.excels.dungeon;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import emu.grasscutter.data.excels.RewardPreviewData;
import emu.grasscutter.game.dungeons.enums.*;
import java.util.List;
import lombok.Getter;
@ResourceType(name = "DungeonExcelConfigData.json")
public class DungeonData extends GameResource {
@Getter(onMethod = @__(@Override))
private int id;
@Getter private int sceneId;
@Getter private int showLevel;
private DungeonType type;
private DungeonSubType subType;
private DungeonPlayType playType;
private DungeonInvolveType involveType;
@Getter private int limitLevel;
@Getter private int passCond;
@Getter private int reviveMaxCount;
@Getter private int settleCountdownTime;
@Getter private int failSettleCountdownTime;
@Getter private int quitSettleCountdownTime;
@Getter private List<SettleShowType> settleShows;
@Getter private int passRewardPreviewID;
@Getter private int statueCostID;
@Getter private int statueCostCount;
// not part of DungeonExcelConfigData
@Getter private RewardPreviewData rewardPreviewData;
public DungeonType getType() {
if (type == null) {
return DungeonType.DUNGEON_NONE;
}
return type;
}
public DungeonSubType getSubType() {
if (subType == null) {
return DungeonSubType.DUNGEON_SUB_NONE;
}
return subType;
}
public DungeonPlayType getPlayType() {
if (playType == null) {
return DungeonPlayType.DUNGEON_PLAY_TYPE_NONE;
}
return playType;
}
public DungeonInvolveType getInvolveType() {
if (involveType == null) {
return DungeonInvolveType.INVOLVE_NONE;
}
return involveType;
}
@Override
public void onLoad() {
if (this.passRewardPreviewID > 0) {
this.rewardPreviewData = GameData.getRewardPreviewDataMap().get(this.passRewardPreviewID);
}
}
}

View File

@ -1,4 +1,4 @@
package emu.grasscutter.data.excels;
package emu.grasscutter.data.excels.dungeon;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;

View File

@ -1,28 +1,26 @@
package emu.grasscutter.data.excels;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import emu.grasscutter.game.dungeons.enums.DungeonPassConditionType;
import emu.grasscutter.game.quest.enums.LogicType;
import lombok.Getter;
import java.util.List;
@ResourceType(name = "DungeonPassExcelConfigData.json")
public class DungeonPassConfigData extends GameResource {
@Getter private int id;
@Getter private LogicType logicType;
@Getter private List<DungeonPassCondition> conds;
public static class DungeonPassCondition{
@Getter private DungeonPassConditionType condType;
@Getter int[] param;
}
@Override
public void onLoad() {
super.onLoad();
conds = conds.stream().filter(condition -> condition.getCondType()!=null).toList();
}
}
package emu.grasscutter.data.excels.dungeon;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import emu.grasscutter.game.dungeons.enums.DungeonPassConditionType;
import emu.grasscutter.game.quest.enums.LogicType;
import java.util.List;
import lombok.Getter;
@ResourceType(name = "DungeonPassExcelConfigData.json")
public class DungeonPassConfigData extends GameResource {
@Getter private int id;
@Getter private LogicType logicType;
@Getter private List<DungeonPassCondition> conds;
public static class DungeonPassCondition {
@Getter private DungeonPassConditionType condType;
@Getter int[] param;
}
@Override
public void onLoad() {
super.onLoad();
conds = conds.stream().filter(condition -> condition.getCondType() != null).toList();
}
}

View File

@ -1,4 +1,4 @@
package emu.grasscutter.data.excels;
package emu.grasscutter.data.excels.monster;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;

View File

@ -1,4 +1,4 @@
package emu.grasscutter.data.excels;
package emu.grasscutter.data.excels.monster;
import com.google.gson.annotations.SerializedName;
import emu.grasscutter.data.GameData;
@ -6,6 +6,7 @@ import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import emu.grasscutter.data.ResourceType.LoadPriority;
import emu.grasscutter.data.common.PropGrowCurve;
import emu.grasscutter.data.excels.GadgetData;
import emu.grasscutter.game.props.FightProperty;
import emu.grasscutter.game.props.MonsterType;
import java.util.List;

View File

@ -1,4 +1,4 @@
package emu.grasscutter.data.excels;
package emu.grasscutter.data.excels.monster;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;

View File

@ -1,21 +1,21 @@
package emu.grasscutter.data.excels;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import emu.grasscutter.data.ResourceType.LoadPriority;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ResourceType(name = "MonsterSpecialNameExcelConfigData.json", loadPriority = LoadPriority.HIGH)
@EqualsAndHashCode(callSuper=false)
@Data
public class MonsterSpecialNameData extends GameResource {
private int specialNameId;
private int specialNameLabId;
private long specialNameTextMapHash;
@Override
public int getId() {
return specialNameId;
}
}
package emu.grasscutter.data.excels.monster;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import emu.grasscutter.data.ResourceType.LoadPriority;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ResourceType(name = "MonsterSpecialNameExcelConfigData.json", loadPriority = LoadPriority.HIGH)
@EqualsAndHashCode(callSuper = false)
@Data
public class MonsterSpecialNameData extends GameResource {
private int specialNameId;
private int specialNameLabId;
private long specialNameTextMapHash;
@Override
public int getId() {
return specialNameId;
}
}

View File

@ -1,4 +1,4 @@
package emu.grasscutter.data.excels;
package emu.grasscutter.data.excels.reliquary;
import com.google.gson.annotations.SerializedName;
import emu.grasscutter.data.GameResource;

View File

@ -1,4 +1,4 @@
package emu.grasscutter.data.excels;
package emu.grasscutter.data.excels.reliquary;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;

View File

@ -1,4 +1,4 @@
package emu.grasscutter.data.excels;
package emu.grasscutter.data.excels.reliquary;
import com.google.gson.annotations.SerializedName;
import emu.grasscutter.data.GameResource;

View File

@ -1,4 +1,4 @@
package emu.grasscutter.data.excels;
package emu.grasscutter.data.excels.reliquary;
import com.google.gson.annotations.SerializedName;
import emu.grasscutter.data.GameResource;

View File

@ -1,21 +1,21 @@
package emu.grasscutter.data.excels;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import lombok.Getter;
@ResourceType(name = "TowerFloorExcelConfigData.json")
@Getter
public class TowerFloorData extends GameResource {
private int floorId;
private int floorIndex;
private int levelGroupId;
private int overrideMonsterLevel;
private int teamNum;
private int floorLevelConfigId;
@Override
public int getId() {
return this.floorId;
}
}
package emu.grasscutter.data.excels.tower;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import lombok.Getter;
@ResourceType(name = "TowerFloorExcelConfigData.json")
@Getter
public class TowerFloorData extends GameResource {
private int floorId;
private int floorIndex;
private int levelGroupId;
private int overrideMonsterLevel;
private int teamNum;
private int floorLevelConfigId;
@Override
public int getId() {
return this.floorId;
}
}

View File

@ -1,4 +1,4 @@
package emu.grasscutter.data.excels;
package emu.grasscutter.data.excels.tower;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;

View File

@ -1,4 +1,4 @@
package emu.grasscutter.data.excels;
package emu.grasscutter.data.excels.tower;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;

View File

@ -1,21 +1,21 @@
package emu.grasscutter.data.excels;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import emu.grasscutter.data.common.BaseTrialActivityData;
import lombok.*;
import java.util.List;
@ResourceType(name = "TrialAvatarActivityExcelConfigData.json")
@EqualsAndHashCode(callSuper=false)
@Data
public class TrialAvatarActivityData extends GameResource implements BaseTrialActivityData {
private int ScheduleId;
private List<Integer> AvatarIndexIdList;
private List<Integer> RewardIdList;
@Override
public int getId() {
return ScheduleId;
}
}
package emu.grasscutter.data.excels.trial;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import emu.grasscutter.data.common.BaseTrialActivityData;
import java.util.List;
import lombok.*;
@ResourceType(name = "TrialAvatarActivityExcelConfigData.json")
@EqualsAndHashCode(callSuper = false)
@Data
public class TrialAvatarActivityData extends GameResource implements BaseTrialActivityData {
private int ScheduleId;
private List<Integer> AvatarIndexIdList;
private List<Integer> RewardIdList;
@Override
public int getId() {
return ScheduleId;
}
}

View File

@ -1,29 +1,31 @@
package emu.grasscutter.data.excels;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import lombok.*;
import lombok.experimental.FieldDefaults;
@ResourceType(name = "TrialAvatarActivityDataExcelConfigData.json")
@EqualsAndHashCode(callSuper=false)
@Data
@FieldDefaults(level = AccessLevel.PRIVATE)
public class TrialAvatarActivityDataData extends GameResource {
@Getter(onMethod = @__(@Override))
private int id;
private int trialAvatarIndexId;
private int trialAvatarId;
private int dungeonId;
private String battleAvatarsList;
private int firstPassReward;
private ActivityWatcherData.WatcherTrigger triggerConfig;
private int progress;
@Override
public void onLoad() {
triggerConfig.onLoad();
GameData.getTrialAvatarIndexIdTrialActivityDataDataMap().put(trialAvatarIndexId, id);
}
}
package emu.grasscutter.data.excels.trial;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import emu.grasscutter.data.excels.activity.ActivityWatcherData;
import lombok.*;
import lombok.experimental.FieldDefaults;
@ResourceType(name = "TrialAvatarActivityDataExcelConfigData.json")
@EqualsAndHashCode(callSuper = false)
@Data
@FieldDefaults(level = AccessLevel.PRIVATE)
public class TrialAvatarActivityDataData extends GameResource {
@Getter(onMethod = @__(@Override))
private int id;
private int trialAvatarIndexId;
private int trialAvatarId;
private int dungeonId;
private String battleAvatarsList;
private int firstPassReward;
private ActivityWatcherData.WatcherTrigger triggerConfig;
private int progress;
@Override
public void onLoad() {
this.triggerConfig.onLoad();
GameData.getTrialAvatarIndexIdTrialActivityDataDataMap().put(trialAvatarIndexId, id);
}
}

View File

@ -1,19 +1,19 @@
package emu.grasscutter.data.excels;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import lombok.*;
import java.util.List;
@ResourceType(name = "TrialAvatarExcelConfigData.json")
@EqualsAndHashCode(callSuper=false)
@Data
public class TrialAvatarData extends GameResource {
private int trialAvatarId;
private List<Integer> trialAvatarParamList;
@Override
public int getId() {
return trialAvatarId;
}
}
package emu.grasscutter.data.excels.trial;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import java.util.List;
import lombok.*;
@ResourceType(name = "TrialAvatarExcelConfigData.json")
@EqualsAndHashCode(callSuper = false)
@Data
public class TrialAvatarData extends GameResource {
private int trialAvatarId;
private List<Integer> trialAvatarParamList;
@Override
public int getId() {
return trialAvatarId;
}
}

View File

@ -1,20 +1,20 @@
package emu.grasscutter.data.excels;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import lombok.*;
import java.util.List;
@ResourceType(name = "TrialAvatarTemplateExcelConfigData.json")
@EqualsAndHashCode(callSuper=false)
@Data
public class TrialAvatarTemplateData extends GameResource {
private int TrialAvatarLevel;
private List<Integer> TrialReliquaryList;
private int TrialAvatarSkillLevel;
@Override
public int getId() {
return TrialAvatarLevel;
}
}
package emu.grasscutter.data.excels.trial;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import java.util.List;
import lombok.*;
@ResourceType(name = "TrialAvatarTemplateExcelConfigData.json")
@EqualsAndHashCode(callSuper = false)
@Data
public class TrialAvatarTemplateData extends GameResource {
private int TrialAvatarLevel;
private List<Integer> TrialReliquaryList;
private int TrialAvatarSkillLevel;
@Override
public int getId() {
return TrialAvatarLevel;
}
}

View File

@ -1,22 +1,22 @@
package emu.grasscutter.data.excels;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import lombok.*;
import java.util.List;
@ResourceType(name = "TrialReliquaryExcelConfigData.json")
@EqualsAndHashCode(callSuper=false)
@Data
public class TrialReliquaryData extends GameResource {
private int Id;
private int ReliquaryId;
private int Level;
private int MainPropId;
private List<Integer> AppendPropList;
@Override
public int getId() {
return Id;
}
}
package emu.grasscutter.data.excels.trial;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;
import java.util.List;
import lombok.*;
@ResourceType(name = "TrialReliquaryExcelConfigData.json")
@EqualsAndHashCode(callSuper = false)
@Data
public class TrialReliquaryData extends GameResource {
private int Id;
private int ReliquaryId;
private int Level;
private int MainPropId;
private List<Integer> AppendPropList;
@Override
public int getId() {
return Id;
}
}

View File

@ -1,4 +1,4 @@
package emu.grasscutter.data.excels;
package emu.grasscutter.data.excels.weapon;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;

View File

@ -1,4 +1,4 @@
package emu.grasscutter.data.excels;
package emu.grasscutter.data.excels.weapon;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;

View File

@ -1,4 +1,4 @@
package emu.grasscutter.data.excels;
package emu.grasscutter.data.excels.weapon;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;

View File

@ -1,4 +1,4 @@
package emu.grasscutter.data.excels;
package emu.grasscutter.data.excels.world;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;

View File

@ -1,4 +1,4 @@
package emu.grasscutter.data.excels;
package emu.grasscutter.data.excels.world;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;

View File

@ -1,4 +1,4 @@
package emu.grasscutter.data.excels;
package emu.grasscutter.data.excels.world;
import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType;

View File

@ -1,11 +1,10 @@
package emu.grasscutter.data.server;
import lombok.Data;
import java.util.List;
@Data
public class ActivityCondGroup {
int condGroupId;
List<Integer> condIds;
}
package emu.grasscutter.data.server;
import java.util.List;
import lombok.Data;
@Data
public class ActivityCondGroup {
int condGroupId;
List<Integer> condIds;
}

View File

@ -1,9 +1,9 @@
package emu.grasscutter.data.server;
import lombok.Data;
@Data
public class GadgetMapping {
private int gadgetId;
private String serverController;
}
package emu.grasscutter.data.server;
import lombok.Data;
@Data
public class GadgetMapping {
private int gadgetId;
private String serverController;
}

View File

@ -1,34 +1,34 @@
package emu.grasscutter.data.server;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.utils.GridPosition;
import emu.grasscutter.utils.Position;
public class Grid {
public Map<GridPosition, Set<Integer>> grid;
public Set<Integer> getNearbyGroups(int vision_level, Position position) {
int width = Grasscutter.getConfig().server.game.visionOptions[vision_level].gridWidth;
int vision_range = Grasscutter.getConfig().server.game.visionOptions[vision_level].visionRange;
int vision_range_grid = vision_range / width;
GridPosition pos = new GridPosition(position, width);
Set<Integer> nearbyGroups = new HashSet<>();
//construct a nearby pisition list, add 1 more because a player can be in an edge case, this should not affect much the loading
for(int x = 0; x < vision_range_grid + 1; x++) {
for(int z = 0; z < vision_range_grid + 1; z++) {
nearbyGroups.addAll(grid.getOrDefault(pos.addClone( x, z), new HashSet<>()));
nearbyGroups.addAll(grid.getOrDefault(pos.addClone(-x, z), new HashSet<>()));
nearbyGroups.addAll(grid.getOrDefault(pos.addClone( x, -z), new HashSet<>()));
nearbyGroups.addAll(grid.getOrDefault(pos.addClone(-x, -z), new HashSet<>()));
}
}
return nearbyGroups;
}
}
package emu.grasscutter.data.server;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.utils.GridPosition;
import emu.grasscutter.utils.Position;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
public class Grid {
public Map<GridPosition, Set<Integer>> grid;
public Set<Integer> getNearbyGroups(int vision_level, Position position) {
int width = Grasscutter.getConfig().server.game.visionOptions[vision_level].gridWidth;
int vision_range = Grasscutter.getConfig().server.game.visionOptions[vision_level].visionRange;
int vision_range_grid = vision_range / width;
GridPosition pos = new GridPosition(position, width);
Set<Integer> nearbyGroups = new HashSet<>();
// construct a nearby pisition list, add 1 more because a player can be in an edge case, this
// should not affect much the loading
for (int x = 0; x < vision_range_grid + 1; x++) {
for (int z = 0; z < vision_range_grid + 1; z++) {
nearbyGroups.addAll(grid.getOrDefault(pos.addClone(x, z), new HashSet<>()));
nearbyGroups.addAll(grid.getOrDefault(pos.addClone(-x, z), new HashSet<>()));
nearbyGroups.addAll(grid.getOrDefault(pos.addClone(x, -z), new HashSet<>()));
nearbyGroups.addAll(grid.getOrDefault(pos.addClone(-x, -z), new HashSet<>()));
}
}
return nearbyGroups;
}
}

View File

@ -9,6 +9,7 @@ import emu.grasscutter.game.entity.GameEntity;
import emu.grasscutter.game.entity.gadget.GadgetGatherObject;
import emu.grasscutter.game.player.BasePlayerManager;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.game.quest.enums.QuestContent;
import emu.grasscutter.net.proto.AbilityInvokeEntryHeadOuterClass.AbilityInvokeEntryHead;
import emu.grasscutter.net.proto.AbilityInvokeEntryOuterClass.AbilityInvokeEntry;
import emu.grasscutter.net.proto.AbilityMetaModifierChangeOuterClass.AbilityMetaModifierChange;
@ -39,6 +40,7 @@ public final class AbilityManager extends BasePlayerManager {
case ABILITY_INVOKE_ARGUMENT_META_MODIFIER_CHANGE -> this.handleModifierChange(invoke);
case ABILITY_INVOKE_ARGUMENT_MIXIN_COST_STAMINA -> this.handleMixinCostStamina(invoke);
case ABILITY_INVOKE_ARGUMENT_ACTION_GENERATE_ELEM_BALL -> this.handleGenerateElemBall(invoke);
case ABILITY_INVOKE_ARGUMENT_META_GLOBAL_FLOAT_VALUE -> this.handleGlobalFloatValue(invoke);
default -> {}
}
}
@ -202,6 +204,22 @@ public final class AbilityManager extends BasePlayerManager {
this.player.getEnergyManager().handleGenerateElemBall(invoke);
}
/**
* Handles a float value ability entry.
*
* @param invoke The ability invoke entry.
*/
private void handleGlobalFloatValue(AbilityInvokeEntry invoke)
throws InvalidProtocolBufferException {
var entry = AbilityScalarValueEntry.parseFrom(invoke.getAbilityData());
if (entry.getKey().hasStr()
&& entry.hasFloatValue()
&& entry.getFloatValue() == 2.0f
&& entry.getKey().getStr().equals("_ABILITY_UziExplode_Count")) {
player.getQuestManager().queueEvent(QuestContent.QUEST_CONTENT_SKILL, 10006);
}
}
private void invokeAction(
AbilityModifierAction action, GameEntity target, GameEntity sourceEntity) {
switch (action.type) {

View File

@ -6,7 +6,7 @@ import dev.morphia.annotations.Id;
import dev.morphia.annotations.Transient;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.excels.AchievementData;
import emu.grasscutter.data.excels.achievement.AchievementData;
import emu.grasscutter.database.DatabaseHelper;
import emu.grasscutter.game.inventory.GameItem;
import emu.grasscutter.game.player.Player;

View File

@ -14,7 +14,19 @@ public class ActivityConfigItem {
int scheduleId;
List<Integer> meetCondList;
Date beginTime;
Date openTime;
Date closeTime;
Date endTime;
transient ActivityHandler activityHandler;
void onLoad() {
if (openTime == null) {
this.openTime = beginTime;
}
if (closeTime == null) {
this.closeTime = endTime;
}
}
}

View File

@ -2,9 +2,12 @@ package emu.grasscutter.game.activity;
import com.esotericsoftware.reflectasm.ConstructorAccess;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.excels.ActivityData;
import emu.grasscutter.data.excels.activity.ActivityData;
import emu.grasscutter.data.server.ActivityCondGroup;
import emu.grasscutter.game.activity.condition.ActivityConditionExecutor;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.game.props.WatcherTriggerType;
import emu.grasscutter.game.quest.enums.QuestCond;
import emu.grasscutter.net.proto.ActivityInfoOuterClass;
import emu.grasscutter.utils.DateHelper;
import java.util.*;
@ -19,9 +22,9 @@ import lombok.experimental.FieldDefaults;
@FieldDefaults(level = AccessLevel.PRIVATE)
public abstract class ActivityHandler {
/** Must set before initWatchers */
ActivityConfigItem activityConfigItem;
@Getter ActivityConfigItem activityConfigItem;
ActivityData activityData;
@Getter ActivityData activityData;
Map<WatcherTriggerType, List<ActivityWatcher>> watchersMap = new HashMap<>();
public abstract void onProtoBuild(
@ -57,6 +60,43 @@ public abstract class ActivityHandler {
});
}
protected void triggerCondEvents(Player player) {
if (activityData == null) {
return;
}
var questManager = player.getQuestManager();
activityData
.getCondGroupId()
.forEach(
condGroupId -> {
var condGroup = GameData.getActivityCondGroupMap().get((int) condGroupId);
condGroup
.getCondIds()
.forEach(
condition ->
questManager.queueEvent(QuestCond.QUEST_COND_ACTIVITY_COND, condition));
});
}
private List<Integer> getActivityConditions() {
if (activityData == null) {
return new ArrayList<>();
}
return activityData.getCondGroupId().stream()
.map(condGroupId -> GameData.getActivityCondGroupMap().get((int) condGroupId))
.filter(Objects::nonNull)
.map(ActivityCondGroup::getCondIds)
.flatMap(Collection::stream)
.toList();
}
// TODO handle possible overwrites
private List<Integer> getMeetConditions(ActivityConditionExecutor conditionExecutor) {
return conditionExecutor.getMeetActivitiesConditions(getActivityConditions());
}
private Map<Integer, PlayerActivityData.WatcherInfo> initWatchersDataForPlayer() {
return watchersMap.values().stream()
.flatMap(Collection::stream)
@ -76,7 +116,8 @@ public abstract class ActivityHandler {
return playerActivityData;
}
public ActivityInfoOuterClass.ActivityInfo toProto(PlayerActivityData playerActivityData) {
public ActivityInfoOuterClass.ActivityInfo toProto(
PlayerActivityData playerActivityData, ActivityConditionExecutor conditionExecutor) {
var proto = ActivityInfoOuterClass.ActivityInfo.newBuilder();
proto
.setActivityId(activityConfigItem.getActivityId())
@ -85,7 +126,7 @@ public abstract class ActivityHandler {
.setBeginTime(DateHelper.getUnixTime(activityConfigItem.getBeginTime()))
.setFirstDayStartTime(DateHelper.getUnixTime(activityConfigItem.getBeginTime()))
.setEndTime(DateHelper.getUnixTime(activityConfigItem.getEndTime()))
.addAllMeetCondList(activityConfigItem.getMeetCondList());
.addAllMeetCondList(getMeetConditions(conditionExecutor));
if (playerActivityData != null) {
proto.addAllWatcherInfoList(playerActivityData.getAllWatcherInfoList());

View File

@ -4,6 +4,7 @@ import com.esotericsoftware.reflectasm.ConstructorAccess;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.data.DataLoader;
import emu.grasscutter.data.GameData;
import emu.grasscutter.game.activity.condition.*;
import emu.grasscutter.game.player.BasePlayerManager;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.game.props.ActivityType;
@ -12,6 +13,7 @@ import emu.grasscutter.net.proto.ActivityInfoOuterClass;
import emu.grasscutter.server.packet.send.PacketActivityScheduleInfoNotify;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import lombok.Getter;
import org.reflections.Reflections;
@ -19,6 +21,8 @@ import org.reflections.Reflections;
public class ActivityManager extends BasePlayerManager {
private static final Map<Integer, ActivityConfigItem> activityConfigItemMap;
@Getter private static final Map<Integer, ActivityConfigItem> scheduleActivityConfigMap;
private final Map<Integer, PlayerActivityData> playerActivityDataMap;
private final ActivityConditionExecutor conditionExecutor;
static {
activityConfigItemMap = new HashMap<>();
@ -26,30 +30,6 @@ public class ActivityManager extends BasePlayerManager {
loadActivityConfigData();
}
private final Map<Integer, PlayerActivityData> playerActivityDataMap;
public ActivityManager(Player player) {
super(player);
playerActivityDataMap = new ConcurrentHashMap<>();
// load data for player
activityConfigItemMap
.values()
.forEach(
item -> {
var data = PlayerActivityData.getByPlayer(player, item.getActivityId());
if (data == null) {
data = item.getActivityHandler().initPlayerActivityData(player);
data.save();
}
data.setPlayer(player);
data.setActivityHandler(item.getActivityHandler());
playerActivityDataMap.put(item.getActivityId(), data);
});
player.sendPacket(new PacketActivityScheduleInfoNotify(activityConfigItemMap.values()));
}
private static void loadActivityConfigData() {
// scan activity type handler & watcher type
var activityHandlerTypeMap = new HashMap<ActivityType, ConstructorAccess<?>>();
@ -75,6 +55,7 @@ public class ActivityManager extends BasePlayerManager {
DataLoader.loadList("ActivityConfig.json", ActivityConfigItem.class)
.forEach(
item -> {
item.onLoad();
var activityData = GameData.getActivityDataMap().get(item.getActivityId());
if (activityData == null) {
Grasscutter.getLogger().warn("activity {} not exist.", item.getActivityId());
@ -104,6 +85,36 @@ public class ActivityManager extends BasePlayerManager {
}
}
public ActivityManager(Player player) {
super(player);
playerActivityDataMap = new ConcurrentHashMap<>();
// load data for player
activityConfigItemMap
.values()
.forEach(
item -> {
var data = PlayerActivityData.getByPlayer(player, item.getActivityId());
if (data == null) {
data = item.getActivityHandler().initPlayerActivityData(player);
data.save();
}
data.setPlayer(player);
data.setActivityHandler(item.getActivityHandler());
playerActivityDataMap.put(item.getActivityId(), data);
});
player.sendPacket(new PacketActivityScheduleInfoNotify(activityConfigItemMap.values()));
conditionExecutor =
new BasicActivityConditionExecutor(
activityConfigItemMap,
GameData.getActivityCondExcelConfigDataMap(),
PlayerActivityDataMappingBuilder.buildPlayerActivityDataByActivityCondId(
playerActivityDataMap),
AllActivityConditionBuilder.buildActivityConditions());
}
/** trigger activity watcher */
public void triggerWatcher(WatcherTriggerType watcherTriggerType, String... params) {
var watchers =
@ -124,11 +135,71 @@ public class ActivityManager extends BasePlayerManager {
params));
}
public boolean isActivityActive(int activityId) {
var activityConfig = activityConfigItemMap.get(activityId);
if (activityConfig == null) {
return false;
}
var now = new Date();
return now.after(activityConfig.getBeginTime()) && now.before(activityConfig.getEndTime());
}
public boolean hasActivityEnded(int activityId) {
var activityConfig = activityConfigItemMap.get(activityId);
if (activityConfig == null) {
return true;
}
return new Date().after(activityConfig.getEndTime());
}
public boolean isActivityOpen(int activityId) {
var activityConfig = activityConfigItemMap.get(activityId);
if (activityConfig == null) {
return false;
}
var now = new Date();
return now.after(activityConfig.getOpenTime()) && now.before(activityConfig.getCloseTime());
}
public int getOpenDay(int activityId) {
var activityConfig = activityConfigItemMap.get(activityId);
if (activityConfig == null) {
return 0;
}
var now = new Date();
return (int)
TimeUnit.DAYS.convert(
now.getTime() - activityConfig.getOpenTime().getTime(), TimeUnit.MILLISECONDS)
+ 1;
}
public boolean isActivityClosed(int activityId) {
var activityConfig = activityConfigItemMap.get(activityId);
if (activityConfig == null) {
return false;
}
var now = new Date();
return now.after(activityConfig.getCloseTime());
}
public boolean meetsCondition(int activityCondId) {
return conditionExecutor.meetsCondition(activityCondId);
}
public void triggerActivityConditions() {
activityConfigItemMap.forEach((k, v) -> v.getActivityHandler().triggerCondEvents(player));
}
public ActivityInfoOuterClass.ActivityInfo getInfoProtoByActivityId(int activityId) {
var activityHandler = activityConfigItemMap.get(activityId).getActivityHandler();
var activityData = playerActivityDataMap.get(activityId);
return activityHandler.toProto(activityData);
return activityHandler.toProto(activityData, conditionExecutor);
}
public Optional<ActivityHandler> getActivityHandler(ActivityType type) {
@ -138,7 +209,6 @@ public class ActivityManager extends BasePlayerManager {
.findFirst();
}
@SuppressWarnings("unchecked")
public <T extends ActivityHandler> Optional<T> getActivityHandlerAs(
ActivityType type, Class<T> clazz) {
return getActivityHandler(type).map(x -> (T) x);

View File

@ -1,6 +1,6 @@
package emu.grasscutter.game.activity;
import emu.grasscutter.data.excels.ActivityWatcherData;
import emu.grasscutter.data.excels.activity.ActivityWatcherData;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;

View File

@ -5,7 +5,7 @@ import dev.morphia.annotations.Id;
import dev.morphia.annotations.Transient;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.common.ItemParamData;
import emu.grasscutter.data.excels.ActivityWatcherData;
import emu.grasscutter.data.excels.activity.ActivityWatcherData;
import emu.grasscutter.database.DatabaseHelper;
import emu.grasscutter.game.inventory.GameItem;
import emu.grasscutter.game.player.Player;

View File

@ -1,17 +1,16 @@
package emu.grasscutter.game.activity.condition;
import emu.grasscutter.data.excels.ActivityCondExcelConfigData;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* This annotation marks condition types for NewActivityCondExcelConfigData.json ({@link ActivityCondExcelConfigData}). To use it you should mark
* class that extends ActivityConditionBaseHandler, and it will be automatically picked during activity manager initiation.
*
*/
@Retention(RetentionPolicy.RUNTIME)
public @interface ActivityCondition {
ActivityConditions value();
}
package emu.grasscutter.game.activity.condition;
import emu.grasscutter.data.excels.activity.ActivityCondExcelConfigData;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* This annotation marks condition types for NewActivityCondExcelConfigData.json ({@link
* ActivityCondExcelConfigData}). To use it you should mark class that extends
* ActivityConditionBaseHandler, and it will be automatically picked during activity manager
* initiation.
*/
@Retention(RetentionPolicy.RUNTIME)
public @interface ActivityCondition {
ActivityConditions value();
}

View File

@ -1,21 +1,23 @@
package emu.grasscutter.game.activity.condition;
import emu.grasscutter.data.excels.ActivityCondExcelConfigData;
import emu.grasscutter.game.activity.ActivityConfigItem;
import emu.grasscutter.game.activity.PlayerActivityData;
/**
* Base handler for all activity conditions that are listed in NewActivityCondExcelConfigData.json ({@link ActivityCondExcelConfigData})
*/
public abstract class ActivityConditionBaseHandler {
/**
* Execute activity condition handler and return result of it's calculation
*
* @param activityData {@link PlayerActivityData} object containing info about activity
* @param activityConfig
* @param params params for handler
* @return result of condition calculation
*/
public abstract boolean execute(PlayerActivityData activityData, ActivityConfigItem activityConfig, int... params);
}
package emu.grasscutter.game.activity.condition;
import emu.grasscutter.data.excels.activity.ActivityCondExcelConfigData;
import emu.grasscutter.game.activity.ActivityConfigItem;
import emu.grasscutter.game.activity.PlayerActivityData;
/**
* Base handler for all activity conditions that are listed in NewActivityCondExcelConfigData.json
* ({@link ActivityCondExcelConfigData})
*/
public abstract class ActivityConditionBaseHandler {
/**
* Execute activity condition handler and return result of it's calculation
*
* @param activityData {@link PlayerActivityData} object containing info about activity
* @param activityConfig
* @param params params for handler
* @return result of condition calculation
*/
public abstract boolean execute(
PlayerActivityData activityData, ActivityConfigItem activityConfig, int... params);
}

View File

@ -1,10 +1,10 @@
package emu.grasscutter.game.activity.condition;
import java.util.List;
public interface ActivityConditionExecutor {
List<Integer> getMeetActivitiesConditions(List<Integer> condIds);
boolean meetsCondition(int activityCondId);
}
package emu.grasscutter.game.activity.condition;
import java.util.List;
public interface ActivityConditionExecutor {
List<Integer> getMeetActivitiesConditions(List<Integer> condIds);
boolean meetsCondition(int activityCondId);
}

View File

@ -1,51 +1,51 @@
package emu.grasscutter.game.activity.condition;
public enum ActivityConditions {
NEW_ACTIVITY_COND_PLAYER_LEVEL_GREAT_EQUAL,
NEW_ACTIVITY_COND_NOT_FINISH_TALK,
NEW_ACTIVITY_COND_SALESMAN_CAN_DELIVER,
NEW_ACTIVITY_COND_FINISH_PHOTO_POS_ID,
NEW_ACTIVITY_COND_HACHI_FINISH_STEALTH_STAGE_EQUAL,
NEW_ACTIVITY_COND_UNLOCKED_ALL_LISTED_SCENE_POINTS,
NEW_ACTIVITY_COND_DAYS_GREAT_EQUAL,
NEW_ACTIVITY_COND_FINISH_BARTENDER_LEVEL,
NEW_ACTIVITY_COND_FINISH_HACHI_STAGE,
NEW_ACTIVITY_COND_FINISH_ANY_INSTABLE_SPRAY_CHALLENGE_STAGE,
NEW_ACTIVITY_COND_HACHI_FINISH_BATTLE_STAGE_EQUAL,
NEW_ACTIVITY_COND_FINISH_CHANNELLER_SLAB_APPOINTED_STAGE_ALL_CAMP,
NEW_ACTIVITY_COND_FINISH_WATCHER,
NEW_ACTIVITY_COND_FINISH_REGION_SEARCH,
NEW_ACTIVITY_COND_FINISH_WATER_SPIRIT_PHASE,
NEW_ACTIVITY_COND_SEA_LAMP_POPULARIT,
NEW_ACTIVITY_COND_FINISH_DIG_ACTIVITY,
NEW_ACTIVITY_COND_FINISH_FIND_HILICHURL_LEVEL_EQUAL,
NEW_ACTIVITY_COND_GACHA_CAN_CREATE_ROBOT,
NEW_ACTIVITY_COND_FINISH_SALVAGE_STAGE,
NEW_ACTIVITY_COND_FINISH_MUSIC_GAME_ALL_LEVEL,
NEW_ACTIVITY_COND_DAYS_LESS,
NEW_ACTIVITY_COND_QUEST_FINISH,
NEW_ACTIVITY_COND_QUEST_GLOBAL_VAR_EQUAL,
NEW_ACTIVITY_COND_GROUP_BUNDLE_FINISHED,
NEW_ACTIVITY_COND_SEA_LAMP_PHASE,
NEW_ACTIVITY_COND_FINISH_CHANNELLER_SLAB_ANY_STAGE_ALL_CAMP,
NEW_ACTIVITY_COND_LUMINANCE_STONE_CHALLENGE_FINAL_GALLERY_COMPLETE,
NEW_ACTIVITY_COND_PLANT_FLOWER_CAN_DELIVER,
NEW_ACTIVITY_COND_LUMINANCE_STONE_CHALLENGE_STAGE_GREAT_EQUAL,
NEW_ACTIVITY_COND_FINISH_ANY_ARENA_CHALLENGE_LEVEL,
NEW_ACTIVITY_COND_FINISH_CUSTOM_DUNGEON_OFFICIAL,
NEW_ACTIVITY_COND_SCENE_MP_PLAY_ACTIVATED,
NEW_ACTIVITY_COND_FINISH_FIND_HILICHURL_LEVEL_LESS,
NEW_ACTIVITY_COND_TIME_GREATER,
NEW_ACTIVITY_COND_CREATE_NPC,
NEW_ACTIVITY_COND_TREASURE_SEELIE_FINISH_REGION,
NEW_ACTIVITY_COND_LUNA_RITE_ATMOSPHERE,
NEW_ACTIVITY_COND_OFFERING_LEVEL_GREAT_EQUAL,
NEW_ACTIVITY_COND_FINISH_CHANNELLER_SLAB_ANY_ONEOFF_DUNGEON,
NEW_ACTIVITY_COND_QUEST_FINISH_ALLOW_QUICK_OPEN,
NEW_ACTIVITY_COND_FINISH_POTION_ANY_LEVEL,
NEW_ACTIVITY_COND_MECHANICUS_OPEN,
NEW_ACTIVITY_COND_PLAYER_LEVEL_GREATER,
NEW_ACTIVITY_COND_SALESMAN_CAN_GET_REWARD,
NEW_ACTIVITY_COND_FINISH_REGION_SEARCH_LOGIC,
NEW_ACTIVITY_COND_FINISH_CHANNELLER_SLAB_ONEOFF_DUNGEON_IN_STAGE
}
package emu.grasscutter.game.activity.condition;
public enum ActivityConditions {
NEW_ACTIVITY_COND_PLAYER_LEVEL_GREAT_EQUAL,
NEW_ACTIVITY_COND_NOT_FINISH_TALK,
NEW_ACTIVITY_COND_SALESMAN_CAN_DELIVER,
NEW_ACTIVITY_COND_FINISH_PHOTO_POS_ID,
NEW_ACTIVITY_COND_HACHI_FINISH_STEALTH_STAGE_EQUAL,
NEW_ACTIVITY_COND_UNLOCKED_ALL_LISTED_SCENE_POINTS,
NEW_ACTIVITY_COND_DAYS_GREAT_EQUAL,
NEW_ACTIVITY_COND_FINISH_BARTENDER_LEVEL,
NEW_ACTIVITY_COND_FINISH_HACHI_STAGE,
NEW_ACTIVITY_COND_FINISH_ANY_INSTABLE_SPRAY_CHALLENGE_STAGE,
NEW_ACTIVITY_COND_HACHI_FINISH_BATTLE_STAGE_EQUAL,
NEW_ACTIVITY_COND_FINISH_CHANNELLER_SLAB_APPOINTED_STAGE_ALL_CAMP,
NEW_ACTIVITY_COND_FINISH_WATCHER,
NEW_ACTIVITY_COND_FINISH_REGION_SEARCH,
NEW_ACTIVITY_COND_FINISH_WATER_SPIRIT_PHASE,
NEW_ACTIVITY_COND_SEA_LAMP_POPULARIT,
NEW_ACTIVITY_COND_FINISH_DIG_ACTIVITY,
NEW_ACTIVITY_COND_FINISH_FIND_HILICHURL_LEVEL_EQUAL,
NEW_ACTIVITY_COND_GACHA_CAN_CREATE_ROBOT,
NEW_ACTIVITY_COND_FINISH_SALVAGE_STAGE,
NEW_ACTIVITY_COND_FINISH_MUSIC_GAME_ALL_LEVEL,
NEW_ACTIVITY_COND_DAYS_LESS,
NEW_ACTIVITY_COND_QUEST_FINISH,
NEW_ACTIVITY_COND_QUEST_GLOBAL_VAR_EQUAL,
NEW_ACTIVITY_COND_GROUP_BUNDLE_FINISHED,
NEW_ACTIVITY_COND_SEA_LAMP_PHASE,
NEW_ACTIVITY_COND_FINISH_CHANNELLER_SLAB_ANY_STAGE_ALL_CAMP,
NEW_ACTIVITY_COND_LUMINANCE_STONE_CHALLENGE_FINAL_GALLERY_COMPLETE,
NEW_ACTIVITY_COND_PLANT_FLOWER_CAN_DELIVER,
NEW_ACTIVITY_COND_LUMINANCE_STONE_CHALLENGE_STAGE_GREAT_EQUAL,
NEW_ACTIVITY_COND_FINISH_ANY_ARENA_CHALLENGE_LEVEL,
NEW_ACTIVITY_COND_FINISH_CUSTOM_DUNGEON_OFFICIAL,
NEW_ACTIVITY_COND_SCENE_MP_PLAY_ACTIVATED,
NEW_ACTIVITY_COND_FINISH_FIND_HILICHURL_LEVEL_LESS,
NEW_ACTIVITY_COND_TIME_GREATER,
NEW_ACTIVITY_COND_CREATE_NPC,
NEW_ACTIVITY_COND_TREASURE_SEELIE_FINISH_REGION,
NEW_ACTIVITY_COND_LUNA_RITE_ATMOSPHERE,
NEW_ACTIVITY_COND_OFFERING_LEVEL_GREAT_EQUAL,
NEW_ACTIVITY_COND_FINISH_CHANNELLER_SLAB_ANY_ONEOFF_DUNGEON,
NEW_ACTIVITY_COND_QUEST_FINISH_ALLOW_QUICK_OPEN,
NEW_ACTIVITY_COND_FINISH_POTION_ANY_LEVEL,
NEW_ACTIVITY_COND_MECHANICUS_OPEN,
NEW_ACTIVITY_COND_PLAYER_LEVEL_GREATER,
NEW_ACTIVITY_COND_SALESMAN_CAN_GET_REWARD,
NEW_ACTIVITY_COND_FINISH_REGION_SEARCH_LOGIC,
NEW_ACTIVITY_COND_FINISH_CHANNELLER_SLAB_ONEOFF_DUNGEON_IN_STAGE
}

Some files were not shown because too many files have changed in this diff Show More