Format code [skip actions]

This commit is contained in:
github-actions 2024-06-09 13:49:49 +00:00
parent d4ce7aac08
commit 8c53f2b679
189 changed files with 1138 additions and 1185 deletions

View File

@ -230,7 +230,11 @@ public final class CommandMap {
if (SERVER.logCommands) { if (SERVER.logCommands) {
if (player != null) { if (player != null) {
Grasscutter.getLogger() Grasscutter.getLogger()
.info("Command used by [{} (Player UID: {})]: {}", player.getAccount().getUsername(), player.getUid(), rawMessage); .info(
"Command used by [{} (Player UID: {})]: {}",
player.getAccount().getUsername(),
player.getUid(),
rawMessage);
} else { } else {
Grasscutter.getLogger().info("Command used by server console: {}", rawMessage); Grasscutter.getLogger().info("Command used by server console: {}", rawMessage);
} }
@ -344,10 +348,13 @@ public final class CommandMap {
this.registerCommand(cmdData.label(), (CommandHandler) object); this.registerCommand(cmdData.label(), (CommandHandler) object);
else else
Grasscutter.getLogger() Grasscutter.getLogger()
.error("Class {} is not a CommandHandler!", annotated.getName()); .error("Class {} is not a CommandHandler!", annotated.getName());
} catch (Exception exception) { } catch (Exception exception) {
Grasscutter.getLogger() Grasscutter.getLogger()
.error("Failed to register command handler for {}", annotated.getSimpleName(), exception); .error(
"Failed to register command handler for {}",
annotated.getSimpleName(),
exception);
} }
}); });
} }

View File

@ -136,18 +136,19 @@ public final class AchievementCommand implements CommandHandler {
parseInt(args.remove(0)) parseInt(args.remove(0))
.ifPresentOrElse( .ifPresentOrElse(
integer -> parseInt(args.remove(0)) integer ->
.ifPresentOrElse( parseInt(args.remove(0))
progress -> { .ifPresentOrElse(
var ret = achievements.progress(integer, progress); progress -> {
switch (ret.getRet()) { var ret = achievements.progress(integer, progress);
case SUCCESS -> sendSuccessMessage( switch (ret.getRet()) {
sender, "progress", targetPlayer.getNickname(), integer, progress); case SUCCESS -> sendSuccessMessage(
case ACHIEVEMENT_NOT_FOUND -> CommandHandler.sendTranslatedMessage( sender, "progress", targetPlayer.getNickname(), integer, progress);
sender, ret.getRet().getKey()); case ACHIEVEMENT_NOT_FOUND -> CommandHandler.sendTranslatedMessage(
} sender, ret.getRet().getKey());
}, }
() -> this.sendUsageMessage(sender)), },
() -> this.sendUsageMessage(sender)),
() -> this.sendUsageMessage(sender)); () -> this.sendUsageMessage(sender));
} }
} }

View File

@ -1,5 +1,8 @@
package emu.grasscutter.command.commands; package emu.grasscutter.command.commands;
import static emu.grasscutter.GameConstants.*;
import static emu.grasscutter.command.CommandHelpers.*;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.data.GameData; import emu.grasscutter.data.GameData;
@ -14,30 +17,50 @@ import emu.grasscutter.game.inventory.ItemType;
import emu.grasscutter.game.player.Player; import emu.grasscutter.game.player.Player;
import emu.grasscutter.game.props.ActionReason; import emu.grasscutter.game.props.ActionReason;
import emu.grasscutter.game.props.FightProperty; import emu.grasscutter.game.props.FightProperty;
import lombok.Setter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import lombok.Setter;
import static emu.grasscutter.GameConstants.*; @Command(
import static emu.grasscutter.command.CommandHelpers.*; label = "give",
aliases = {"g", "item", "giveitem"},
@Command(label = "give", aliases = {"g", "item", "giveitem"}, usage = {"(<itemId>|<avatarId>|all|weapons|mats|avatars) [lv<level>] [r<refinement>] [x<amount>] [c<constellation>] [sl<skilllevel>]", "<artifactId> [lv<level>] [x<amount>] [<mainPropId>] [<appendPropId>[,<times>]]..."}, permission = "player.give", permissionTargeted = "player.give.others", threading = true) usage = {
"(<itemId>|<avatarId>|all|weapons|mats|avatars) [lv<level>] [r<refinement>] [x<amount>] [c<constellation>] [sl<skilllevel>]",
"<artifactId> [lv<level>] [x<amount>] [<mainPropId>] [<appendPropId>[,<times>]]..."
},
permission = "player.give",
permissionTargeted = "player.give.others",
threading = true)
public final class GiveCommand implements CommandHandler { public final class GiveCommand implements CommandHandler {
private static final Map<Pattern, BiConsumer<GiveItemParameters, Integer>> intCommandHandlers = Map.ofEntries(Map.entry(lvlRegex, GiveItemParameters::setLvl), Map.entry(refineRegex, GiveItemParameters::setRefinement), Map.entry(amountRegex, GiveItemParameters::setAmount), Map.entry(constellationRegex, GiveItemParameters::setConstellation), Map.entry(skillLevelRegex, GiveItemParameters::setSkillLevel)); private static final Map<Pattern, BiConsumer<GiveItemParameters, Integer>> intCommandHandlers =
Map.ofEntries(
Map.entry(lvlRegex, GiveItemParameters::setLvl),
Map.entry(refineRegex, GiveItemParameters::setRefinement),
Map.entry(amountRegex, GiveItemParameters::setAmount),
Map.entry(constellationRegex, GiveItemParameters::setConstellation),
Map.entry(skillLevelRegex, GiveItemParameters::setSkillLevel));
private static Avatar makeAvatar(GiveItemParameters param) { private static Avatar makeAvatar(GiveItemParameters param) {
return makeAvatar(param.avatarData, param.lvl, Avatar.getMinPromoteLevel(param.lvl), param.constellation, param.skillLevel); return makeAvatar(
param.avatarData,
param.lvl,
Avatar.getMinPromoteLevel(param.lvl),
param.constellation,
param.skillLevel);
} }
private static Avatar makeAvatar(AvatarData avatarData, int level, int promoteLevel, int constellation, int skillLevel) { private static Avatar makeAvatar(
AvatarData avatarData, int level, int promoteLevel, int constellation, int skillLevel) {
Avatar avatar = new Avatar(avatarData); Avatar avatar = new Avatar(avatarData);
avatar.setLevel(level); avatar.setLevel(level);
avatar.setPromoteLevel(promoteLevel); avatar.setPromoteLevel(promoteLevel);
avatar.getSkillDepot().getSkillsAndEnergySkill().forEach(id -> avatar.setSkillLevel(id, skillLevel)); avatar
.getSkillDepot()
.getSkillsAndEnergySkill()
.forEach(id -> avatar.setSkillLevel(id, skillLevel));
avatar.forceConstellationLevel(constellation); avatar.forceConstellationLevel(constellation);
avatar.recalcStats(true); avatar.recalcStats(true);
avatar.save(); avatar.save();
@ -47,13 +70,16 @@ public final class GiveCommand implements CommandHandler {
private static void giveAllAvatars(Player player, GiveItemParameters param) { private static void giveAllAvatars(Player player, GiveItemParameters param) {
int promoteLevel = Avatar.getMinPromoteLevel(param.lvl); int promoteLevel = Avatar.getMinPromoteLevel(param.lvl);
if (param.constellation < 0 || param.constellation > 6) if (param.constellation < 0 || param.constellation > 6)
param.constellation = 6; // constellation's default is -1 so if no parameters set for constellations it'll param.constellation =
6; // constellation's default is -1 so if no parameters set for constellations it'll
// automatically be 6 // automatically be 6
for (AvatarData avatarData : GameData.getAvatarDataMap().values()) { for (AvatarData avatarData : GameData.getAvatarDataMap().values()) {
int id = avatarData.getId(); int id = avatarData.getId();
if (id < 10000002 || id >= 11000000) continue; // Exclude test avatars if (id < 10000002 || id >= 11000000) continue; // Exclude test avatars
// Don't try to add each avatar to the current team // Don't try to add each avatar to the current team
player.addAvatar(makeAvatar(avatarData, param.lvl, promoteLevel, param.constellation, param.skillLevel), false); player.addAvatar(
makeAvatar(avatarData, param.lvl, promoteLevel, param.constellation, param.skillLevel),
false);
} }
} }
@ -93,7 +119,7 @@ public final class GiveCommand implements CommandHandler {
item.setTotalExp(totalExp); item.setTotalExp(totalExp);
int numAffixes = param.data.getAppendPropNum() + (param.lvl - 1) / 4; int numAffixes = param.data.getAppendPropNum() + (param.lvl - 1) / 4;
if (param.mainPropId > 0) // Keep random mainProp if we didn't specify one if (param.mainPropId > 0) // Keep random mainProp if we didn't specify one
item.setMainPropId(param.mainPropId); item.setMainPropId(param.mainPropId);
if (param.appendPropIdList != null) { if (param.appendPropIdList != null) {
item.getAppendPropIdList().clear(); item.getAppendPropIdList().clear();
item.getAppendPropIdList().addAll(param.appendPropIdList); item.getAppendPropIdList().addAll(param.appendPropIdList);
@ -105,14 +131,17 @@ public final class GiveCommand implements CommandHandler {
return items; return items;
} }
private static int getArtifactMainProp(ItemData itemData, FightProperty prop) throws IllegalArgumentException { private static int getArtifactMainProp(ItemData itemData, FightProperty prop)
throws IllegalArgumentException {
if (prop != FightProperty.FIGHT_PROP_NONE) if (prop != FightProperty.FIGHT_PROP_NONE)
for (ReliquaryMainPropData data : GameDepot.getRelicMainPropList(itemData.getMainPropDepotId())) for (ReliquaryMainPropData data :
GameDepot.getRelicMainPropList(itemData.getMainPropDepotId()))
if (data.getWeight() > 0 && data.getFightProp() == prop) return data.getId(); if (data.getWeight() > 0 && data.getFightProp() == prop) return data.getId();
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
private static List<Integer> getArtifactAffixes(ItemData itemData, FightProperty prop) throws IllegalArgumentException { private static List<Integer> getArtifactAffixes(ItemData itemData, FightProperty prop)
throws IllegalArgumentException {
if (prop == FightProperty.FIGHT_PROP_NONE) { if (prop == FightProperty.FIGHT_PROP_NONE) {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
@ -125,7 +154,8 @@ public final class GiveCommand implements CommandHandler {
return affixes; return affixes;
} }
private static int getAppendPropId(String substatText, ItemData itemData) throws IllegalArgumentException { private static int getAppendPropId(String substatText, ItemData itemData)
throws IllegalArgumentException {
// If the given substat text is an integer, we just use that as the append prop ID. // If the given substat text is an integer, we just use that as the append prop ID.
try { try {
return Integer.parseInt(substatText); return Integer.parseInt(substatText);
@ -142,7 +172,8 @@ public final class GiveCommand implements CommandHandler {
substatTier = Integer.parseInt(substatArgs[1]); substatTier = Integer.parseInt(substatArgs[1]);
} }
List<Integer> substats = getArtifactAffixes(itemData, FightProperty.getPropByShortName(substatType)); List<Integer> substats =
getArtifactAffixes(itemData, FightProperty.getPropByShortName(substatType));
if (substats.isEmpty()) { if (substats.isEmpty()) {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
@ -154,7 +185,8 @@ public final class GiveCommand implements CommandHandler {
} }
} }
private static void parseRelicArgs(GiveItemParameters param, List<String> args) throws IllegalArgumentException { private static void parseRelicArgs(GiveItemParameters param, List<String> args)
throws IllegalArgumentException {
// Get the main stat from the arguments. // Get the main stat from the arguments.
// If the given argument is an integer, we use that. // If the given argument is an integer, we use that.
// If not, we check if the argument string is in the main prop map. // If not, we check if the argument string is in the main prop map.
@ -164,7 +196,8 @@ public final class GiveCommand implements CommandHandler {
param.mainPropId = Integer.parseInt(mainPropIdString); param.mainPropId = Integer.parseInt(mainPropIdString);
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
// This can in turn throw an exception which we don't want to catch here. // This can in turn throw an exception which we don't want to catch here.
param.mainPropId = getArtifactMainProp(param.data, FightProperty.getPropByShortName(mainPropIdString)); param.mainPropId =
getArtifactMainProp(param.data, FightProperty.getPropByShortName(mainPropIdString));
} }
// Get substats. // Get substats.
@ -245,7 +278,8 @@ public final class GiveCommand implements CommandHandler {
giveAllWeapons(player, param); giveAllWeapons(player, param);
} }
private GiveItemParameters parseArgs(Player sender, List<String> args) throws IllegalArgumentException { private GiveItemParameters parseArgs(Player sender, List<String> args)
throws IllegalArgumentException {
GiveItemParameters param = new GiveItemParameters(); GiveItemParameters param = new GiveItemParameters();
// Extract any tagged arguments (e.g. "lv90", "x100", "r5") // Extract any tagged arguments (e.g. "lv90", "x100", "r5")
@ -287,7 +321,9 @@ public final class GiveCommand implements CommandHandler {
param.avatarData = GameData.getAvatarDataMap().get(param.id - 1000 + 10_000_000); param.avatarData = GameData.getAvatarDataMap().get(param.id - 1000 + 10_000_000);
isRelic = ((param.data != null) && (param.data.getItemType() == ItemType.ITEM_RELIQUARY)); isRelic = ((param.data != null) && (param.data.getItemType() == ItemType.ITEM_RELIQUARY));
if (!isRelic && !args.isEmpty() && (param.amount == 1)) { // A concession for the people that truly hate [x<amount>]. if (!isRelic
&& !args.isEmpty()
&& (param.amount == 1)) { // A concession for the people that truly hate [x<amount>].
try { try {
param.amount = Integer.parseInt(args.remove(0)); param.amount = Integer.parseInt(args.remove(0));
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
@ -365,7 +401,8 @@ public final class GiveCommand implements CommandHandler {
if (param.avatarData != null) { if (param.avatarData != null) {
Avatar avatar = makeAvatar(param); Avatar avatar = makeAvatar(param);
targetPlayer.addAvatar(avatar); targetPlayer.addAvatar(avatar);
CommandHandler.sendTranslatedMessage(sender, "commands.give.given_avatar", param.id, param.lvl, targetPlayer.getUid()); CommandHandler.sendTranslatedMessage(
sender, "commands.give.given_avatar", param.id, param.lvl, targetPlayer.getUid());
return; return;
} }
// If it's not an avatar, it needs to be a valid item // If it's not an avatar, it needs to be a valid item
@ -376,37 +413,54 @@ public final class GiveCommand implements CommandHandler {
switch (param.data.getItemType()) { switch (param.data.getItemType()) {
case ITEM_WEAPON: case ITEM_WEAPON:
targetPlayer.getInventory().addItems(makeUnstackableItems(param), ActionReason.SubfieldDrop); targetPlayer
CommandHandler.sendTranslatedMessage(sender, "commands.give.given_with_level_and_refinement", param.id, param.lvl, param.refinement, param.amount, targetPlayer.getUid()); .getInventory()
.addItems(makeUnstackableItems(param), ActionReason.SubfieldDrop);
CommandHandler.sendTranslatedMessage(
sender,
"commands.give.given_with_level_and_refinement",
param.id,
param.lvl,
param.refinement,
param.amount,
targetPlayer.getUid());
return; return;
case ITEM_RELIQUARY: case ITEM_RELIQUARY:
targetPlayer.getInventory().addItems(makeArtifacts(param), ActionReason.SubfieldDrop); targetPlayer.getInventory().addItems(makeArtifacts(param), ActionReason.SubfieldDrop);
CommandHandler.sendTranslatedMessage(sender, "commands.give.given_level", param.id, param.lvl, param.amount, targetPlayer.getUid()); CommandHandler.sendTranslatedMessage(
sender,
"commands.give.given_level",
param.id,
param.lvl,
param.amount,
targetPlayer.getUid());
return; return;
default: default:
targetPlayer.getInventory().addItem(new GameItem(param.data, param.amount), ActionReason.SubfieldDrop); targetPlayer
CommandHandler.sendTranslatedMessage(sender, "commands.give.given", param.amount, param.id, targetPlayer.getUid()); .getInventory()
.addItem(new GameItem(param.data, param.amount), ActionReason.SubfieldDrop);
CommandHandler.sendTranslatedMessage(
sender, "commands.give.given", param.amount, param.id, targetPlayer.getUid());
} }
} catch (IllegalArgumentException ignored) { } catch (IllegalArgumentException ignored) {
} }
} }
private enum GiveAllType { private enum GiveAllType {
NONE, ALL, WEAPONS, MATS, AVATARS NONE,
ALL,
WEAPONS,
MATS,
AVATARS
} }
private static class GiveItemParameters { private static class GiveItemParameters {
public int id; public int id;
@Setter @Setter public int lvl = 0;
public int lvl = 0; @Setter public int amount = 1;
@Setter @Setter public int refinement = 1;
public int amount = 1; @Setter public int constellation = -1;
@Setter @Setter public int skillLevel = 1;
public int refinement = 1;
@Setter
public int constellation = -1;
@Setter
public int skillLevel = 1;
public int mainPropId = -1; public int mainPropId = -1;
public List<Integer> appendPropIdList; public List<Integer> appendPropIdList;
public ItemData data; public ItemData data;

View File

@ -24,8 +24,7 @@ public final class SendMailCommand implements CommandHandler {
// the command system (again). For now this will do // the command system (again). For now this will do
// Key = User that is constructing the mail. // Key = User that is constructing the mail.
private static final HashMap<Integer, MailBuilder> mailBeingConstructed = private static final HashMap<Integer, MailBuilder> mailBeingConstructed = new HashMap<>();
new HashMap<>();
// Yes this is awful and I hate it. // Yes this is awful and I hate it.
@Override @Override

View File

@ -95,7 +95,8 @@ public final class SetSceneTagCommand implements CommandHandler {
// Only remove for big world as some other scenes only have defaults // Only remove for big world as some other scenes only have defaults
.filter(sceneTag -> sceneTag.getSceneId() == 3) .filter(sceneTag -> sceneTag.getSceneId() == 3)
.forEach( .forEach(
sceneTag -> targetPlayer.getSceneTags().get(sceneTag.getSceneId()).remove(sceneTag.getId())); sceneTag ->
targetPlayer.getSceneTags().get(sceneTag.getSceneId()).remove(sceneTag.getId()));
this.setSceneTags(targetPlayer); this.setSceneTags(targetPlayer);
} }

View File

@ -4,8 +4,6 @@ import emu.grasscutter.Grasscutter;
import emu.grasscutter.utils.FileUtils; import emu.grasscutter.utils.FileUtils;
import emu.grasscutter.utils.JsonUtils; import emu.grasscutter.utils.JsonUtils;
import emu.grasscutter.utils.TsvUtils; import emu.grasscutter.utils.TsvUtils;
import lombok.val;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -14,6 +12,7 @@ import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import lombok.val;
public class DataLoader { public class DataLoader {
@ -36,7 +35,7 @@ public class DataLoader {
* *
* @param resourcePath The path to the data file to be loaded. * @param resourcePath The path to the data file to be loaded.
* @return InputStreamReader of the data file. * @return InputStreamReader of the data file.
* @throws IOException If the file is not found. * @throws IOException If the file is not found.
* @throws FileNotFoundException If the file is not found. * @throws FileNotFoundException If the file is not found.
* @see #load(String, boolean) * @see #load(String, boolean)
*/ */
@ -50,19 +49,22 @@ public class DataLoader {
* Load a data file by its name. * Load a data file by its name.
* *
* @param resourcePath The path to the data file to be loaded. * @param resourcePath The path to the data file to be loaded.
* @param useFallback If the file does not exist in the /data directory, should it use the default * @param useFallback If the file does not exist in the /data directory, should it use the default
* file in the jar? * file in the jar?
* @return InputStream of the data file. * @return InputStream of the data file.
* @throws FileNotFoundException If the file is not found. * @throws FileNotFoundException If the file is not found.
*/ */
public static InputStream load(String resourcePath, boolean useFallback) throws FileNotFoundException { public static InputStream load(String resourcePath, boolean useFallback)
Path path = useFallback ? FileUtils.getDataPath(resourcePath) : FileUtils.getDataUserPath(resourcePath); throws FileNotFoundException {
Path path =
useFallback ? FileUtils.getDataPath(resourcePath) : FileUtils.getDataUserPath(resourcePath);
if (Files.exists(path)) { if (Files.exists(path)) {
// Data is in the resource directory // Data is in the resource directory
try { try {
return Files.newInputStream(path); return Files.newInputStream(path);
} catch (IOException e) { } catch (IOException e) {
throw new FileNotFoundException(e.getMessage()); // This is evil but so is changing the function signature at this point throw new FileNotFoundException(
e.getMessage()); // This is evil but so is changing the function signature at this point
} }
} }
return null; return null;
@ -80,13 +82,15 @@ public class DataLoader {
} }
} }
public static <T1, T2> Map<T1, T2> loadMap(String resourcePath, Class<T1> keyType, Class<T2> valueType) throws IOException { public static <T1, T2> Map<T1, T2> loadMap(
String resourcePath, Class<T1> keyType, Class<T2> valueType) throws IOException {
try (InputStreamReader reader = loadReader(resourcePath)) { try (InputStreamReader reader = loadReader(resourcePath)) {
return JsonUtils.loadToMap(reader, keyType, valueType); return JsonUtils.loadToMap(reader, keyType, valueType);
} }
} }
public static <T> List<T> loadTableToList(String resourcePath, Class<T> classType) throws IOException { public static <T> List<T> loadTableToList(String resourcePath, Class<T> classType)
throws IOException {
val path = FileUtils.getDataPathTsjJsonTsv(resourcePath); val path = FileUtils.getDataPathTsjJsonTsv(resourcePath);
Grasscutter.getLogger().trace("Loading data table from: {}", path); Grasscutter.getLogger().trace("Loading data table from: {}", path);
return switch (FileUtils.getFileExtension(path)) { return switch (FileUtils.getFileExtension(path)) {

View File

@ -630,15 +630,21 @@ public final class GameData {
// Non-nullable value getters // Non-nullable value getters
public static int getAvatarLevelExpRequired(int level) { public static int getAvatarLevelExpRequired(int level) {
return Optional.ofNullable(avatarLevelDataMap.get(level)).map(AvatarLevelData::getExp).orElse(0); return Optional.ofNullable(avatarLevelDataMap.get(level))
.map(AvatarLevelData::getExp)
.orElse(0);
} }
public static int getAvatarFetterLevelExpRequired(int level) { public static int getAvatarFetterLevelExpRequired(int level) {
return Optional.ofNullable(avatarFetterLevelDataMap.get(level)).map(AvatarFetterLevelData::getExp).orElse(0); return Optional.ofNullable(avatarFetterLevelDataMap.get(level))
.map(AvatarFetterLevelData::getExp)
.orElse(0);
} }
public static int getRelicExpRequired(int rankLevel, int level) { public static int getRelicExpRequired(int rankLevel, int level) {
return Optional.ofNullable(getRelicLevelData(rankLevel, level)).map(ReliquaryLevelData::getExp).orElse(0); return Optional.ofNullable(getRelicLevelData(rankLevel, level))
.map(ReliquaryLevelData::getExp)
.orElse(0);
} }
// Generic getter // Generic getter
@ -655,7 +661,7 @@ public final class GameData {
field.setAccessible(false); field.setAccessible(false);
} catch (Exception e) { } catch (Exception e) {
Grasscutter.getLogger() Grasscutter.getLogger()
.error("Error fetching resource map for {}", resourceDefinition.getSimpleName(), e); .error("Error fetching resource map for {}", resourceDefinition.getSimpleName(), e);
} }
return map; return map;

View File

@ -140,27 +140,28 @@ public final class ResourceLoader {
getResourceDefClassesPrioritySets() getResourceDefClassesPrioritySets()
.forEach( .forEach(
classes -> classes.stream() classes ->
.parallel() classes.stream()
.unordered() .parallel()
.forEach( .unordered()
c -> { .forEach(
val type = c.getAnnotation(ResourceType.class); c -> {
if (type == null) return; val type = c.getAnnotation(ResourceType.class);
if (type == null) return;
val map = GameData.getMapByResourceDef(c); val map = GameData.getMapByResourceDef(c);
if (map == null) return; if (map == null) return;
try { try {
loadFromResource(c, type, map, doReload); loadFromResource(c, type, map, doReload);
} catch (Exception e) { } catch (Exception e) {
errors.add(Pair.of(Arrays.toString(type.name()), e)); errors.add(Pair.of(Arrays.toString(type.name()), e));
} }
})); }));
errors.forEach( errors.forEach(
pair -> pair ->
Grasscutter.getLogger() Grasscutter.getLogger()
.error("Error loading resource file: {}", pair.left(), pair.right())); .error("Error loading resource file: {}", pair.left(), pair.right()));
long endTime = System.nanoTime(); long endTime = System.nanoTime();
long ns = (endTime - startTime); // divide by 1000000 to get milliseconds. long ns = (endTime - startTime); // divide by 1000000 to get milliseconds.
Grasscutter.getLogger().debug("Loading resources took {}ns == {}ms", ns, ns / 1000000); Grasscutter.getLogger().debug("Loading resources took {}ns == {}ms", ns, ns / 1000000);
@ -168,7 +169,7 @@ public final class ResourceLoader {
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
private static void loadFromResource( private static void loadFromResource(
Class<?> c, ResourceType type, Int2ObjectMap map, boolean doReload) throws Exception { Class<?> c, ResourceType type, Int2ObjectMap map, boolean doReload) throws Exception {
val simpleName = c.getSimpleName(); val simpleName = c.getSimpleName();
if (doReload || !loadedResources.contains(simpleName)) { if (doReload || !loadedResources.contains(simpleName)) {
for (String name : type.name()) { for (String name : type.name()) {
@ -281,7 +282,7 @@ public final class ResourceLoader {
} }
}); });
Grasscutter.getLogger() Grasscutter.getLogger()
.debug("Loaded {} SceneRouteDatas.", GameData.getSceneNpcBornData().size()); .debug("Loaded {} SceneRouteDatas.", GameData.getSceneNpcBornData().size());
} catch (IOException e) { } catch (IOException e) {
Grasscutter.getLogger().error("Failed to load SceneRouteData folder."); Grasscutter.getLogger().error("Failed to load SceneRouteData folder.");
} }
@ -402,7 +403,7 @@ public final class ResourceLoader {
.forEach(data -> loadAbilityData(data.Default)); .forEach(data -> loadAbilityData(data.Default));
} catch (IOException e) { } catch (IOException e) {
Grasscutter.getLogger() Grasscutter.getLogger()
.error("Error loading ability modifiers from path {}: ", path.toString(), e); .error("Error loading ability modifiers from path {}: ", path.toString(), e);
} }
} }
@ -464,7 +465,7 @@ public final class ResourceLoader {
path, String.class, new TypeToken<List<TalentData>>() {}.getType())); path, String.class, new TypeToken<List<TalentData>>() {}.getType()));
} catch (IOException e) { } catch (IOException e) {
Grasscutter.getLogger() Grasscutter.getLogger()
.error("Error loading ability modifiers from path {}: ", path.toString(), e); .error("Error loading ability modifiers from path {}: ", path.toString(), e);
} }
} }
@ -531,7 +532,7 @@ public final class ResourceLoader {
}); });
} catch (IOException e) { } catch (IOException e) {
Grasscutter.getLogger() Grasscutter.getLogger()
.error("Error loading open config: no files found in {}", folderName); .error("Error loading open config: no files found in {}", folderName);
return; return;
} }
} }
@ -587,7 +588,7 @@ public final class ResourceLoader {
} }
Grasscutter.getLogger() Grasscutter.getLogger()
.debug("Loaded {} MainQuestDatas.", GameData.getMainQuestDataMap().size()); .debug("Loaded {} MainQuestDatas.", GameData.getMainQuestDataMap().size());
} }
public static void loadScriptSceneData() { public static void loadScriptSceneData() {
@ -605,7 +606,7 @@ public final class ResourceLoader {
} }
}); });
Grasscutter.getLogger() Grasscutter.getLogger()
.debug("Loaded {} ScriptSceneDatas.", GameData.getScriptSceneDataMap().size()); .debug("Loaded {} ScriptSceneDatas.", GameData.getScriptSceneDataMap().size());
} catch (IOException e) { } catch (IOException e) {
Grasscutter.getLogger().debug("ScriptSceneData folder missing or empty."); Grasscutter.getLogger().debug("ScriptSceneData folder missing or empty.");
} }
@ -629,7 +630,9 @@ public final class ResourceLoader {
} }
}); });
Grasscutter.getLogger() Grasscutter.getLogger()
.debug("Loaded {} HomeworldDefaultSaveDatas.", GameData.getHomeworldDefaultSaveData().size()); .debug(
"Loaded {} HomeworldDefaultSaveDatas.",
GameData.getHomeworldDefaultSaveData().size());
} catch (IOException e) { } catch (IOException e) {
Grasscutter.getLogger().error("Failed to load HomeworldDefaultSave folder."); Grasscutter.getLogger().error("Failed to load HomeworldDefaultSave folder.");
} }
@ -654,7 +657,7 @@ public final class ResourceLoader {
} }
}); });
Grasscutter.getLogger() Grasscutter.getLogger()
.debug("Loaded {} SceneNpcBornDatas.", GameData.getSceneNpcBornData().size()); .debug("Loaded {} SceneNpcBornDatas.", GameData.getSceneNpcBornData().size());
} catch (IOException e) { } catch (IOException e) {
Grasscutter.getLogger().error("Failed to load SceneNpcBorn folder."); Grasscutter.getLogger().error("Failed to load SceneNpcBorn folder.");
} }

View File

@ -13,5 +13,4 @@ public class AbilityEmbryoEntry {
this.name = avatarName; this.name = avatarName;
this.abilities = array; this.abilities = array;
} }
} }

View File

@ -3,14 +3,12 @@ package emu.grasscutter.data.binout;
import com.google.gson.*; import com.google.gson.*;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import java.io.Serial; import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
import java.util.*; import java.util.*;
public class AbilityMixinData implements Serializable { public class AbilityMixinData implements Serializable {
@Serial @Serial private static final long serialVersionUID = -2001232313615923575L;
private static final long serialVersionUID = -2001232313615923575L;
public enum Type { public enum Type {
AttachToGadgetStateMixin, AttachToGadgetStateMixin,

View File

@ -3,14 +3,12 @@ package emu.grasscutter.data.binout;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
import emu.grasscutter.data.common.DynamicFloat; import emu.grasscutter.data.common.DynamicFloat;
import emu.grasscutter.game.props.ElementType; import emu.grasscutter.game.props.ElementType;
import java.io.Serial; import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
import lombok.ToString; import lombok.ToString;
public class AbilityModifier implements Serializable { public class AbilityModifier implements Serializable {
@Serial @Serial private static final long serialVersionUID = -2001232313615923575L;
private static final long serialVersionUID = -2001232313615923575L;
public State state; public State state;

View File

@ -1,18 +1,14 @@
package emu.grasscutter.data.binout; package emu.grasscutter.data.binout;
import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction; import emu.grasscutter.data.binout.AbilityModifier.AbilityModifierAction;
import lombok.Getter;
import java.util.*; import java.util.*;
import lombok.Getter;
public class AbilityModifierEntry { public class AbilityModifierEntry {
public final List<AbilityModifierAction> onModifierAdded; public final List<AbilityModifierAction> onModifierAdded;
@Getter @Getter public final List<AbilityModifierAction> onThinkInterval;
public final List<AbilityModifierAction> onThinkInterval; @Getter public final List<AbilityModifierAction> onRemoved;
@Getter @Getter private final String name; // Custom value
public final List<AbilityModifierAction> onRemoved;
@Getter
private final String name; // Custom value
public AbilityModifierEntry(String name) { public AbilityModifierEntry(String name) {
this.name = name; this.name = name;
@ -24,5 +20,4 @@ public class AbilityModifierEntry {
public List<AbilityModifierAction> getOnAdded() { public List<AbilityModifierAction> getOnAdded() {
return onModifierAdded; return onModifierAdded;
} }
} }

View File

@ -8,25 +8,17 @@ import lombok.Data;
import lombok.Getter; import lombok.Getter;
public class MainQuestData { public class MainQuestData {
@Getter @Getter private int id;
private int id;
private int ICLLDPJFIMA; private int ICLLDPJFIMA;
@Getter @Getter private int series;
private int series; @Getter private QuestType type;
@Getter
private QuestType type;
@Getter @Getter private long titleTextMapHash;
private long titleTextMapHash; @Getter private int[] suggestTrackMainQuestList;
@Getter @Getter private int[] rewardIdList;
private int[] suggestTrackMainQuestList;
@Getter
private int[] rewardIdList;
@Getter @Getter private SubQuestData[] subQuests;
private SubQuestData[] subQuests; @Getter private List<TalkData> talks;
@Getter
private List<TalkData> talks;
private long[] preloadLuaList; private long[] preloadLuaList;
public void onLoad() { public void onLoad() {

View File

@ -1,9 +1,8 @@
package emu.grasscutter.data.binout; package emu.grasscutter.data.binout;
import emu.grasscutter.data.ResourceLoader.OpenConfigData; import emu.grasscutter.data.ResourceLoader.OpenConfigData;
import lombok.Getter;
import java.util.*; import java.util.*;
import lombok.Getter;
@Getter @Getter
public class OpenConfigEntry { public class OpenConfigEntry {
@ -46,6 +45,5 @@ public class OpenConfigEntry {
this.skillId = skillId; this.skillId = skillId;
this.delta = delta; this.delta = delta;
} }
} }
} }

View File

@ -7,5 +7,4 @@ public class CurveInfo {
private String type; private String type;
private String arith; private String arith;
private float value; private float value;
} }

View File

@ -5,8 +5,7 @@ import lombok.Getter;
public class ItemUseData { public class ItemUseData {
private ItemUseOp useOp; private ItemUseOp useOp;
@Getter @Getter private String[] useParam;
private String[] useParam;
public ItemUseOp getUseOp() { public ItemUseOp getUseOp() {
if (useOp == null) { if (useOp == null) {
@ -14,5 +13,4 @@ public class ItemUseData {
} }
return useOp; return useOp;
} }
} }

View File

@ -1,8 +1,7 @@
package emu.grasscutter.data.common; package emu.grasscutter.data.common;
import lombok.Getter;
import java.util.List; import java.util.List;
import lombok.Getter;
@Getter @Getter
public class OpenCondData { public class OpenCondData {

View File

@ -6,5 +6,4 @@ import lombok.Getter;
public class PropGrowCurve { public class PropGrowCurve {
private String type; private String type;
private String growCurve; private String growCurve;
} }

View File

@ -2,35 +2,24 @@ package emu.grasscutter.data.excels;
import emu.grasscutter.data.*; import emu.grasscutter.data.*;
import emu.grasscutter.data.common.ItemParamData; import emu.grasscutter.data.common.ItemParamData;
import lombok.Getter;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import lombok.Getter;
@ResourceType(name = "CombineExcelConfigData.json") @ResourceType(name = "CombineExcelConfigData.json")
public class CombineData extends GameResource { public class CombineData extends GameResource {
@Getter @Getter private int combineId;
private int combineId; @Getter private int playerLevel;
@Getter
private int playerLevel;
private boolean isDefaultShow; private boolean isDefaultShow;
@Getter @Getter private int combineType;
private int combineType; @Getter private int subCombineType;
@Getter @Getter private int resultItemId;
private int subCombineType; @Getter private int resultItemCount;
@Getter @Getter private int scoinCost;
private int resultItemId; @Getter private List<ItemParamData> randomItems;
@Getter @Getter private List<ItemParamData> materialItems;
private int resultItemCount; @Getter private String recipeType;
@Getter
private int scoinCost;
@Getter
private List<ItemParamData> randomItems;
@Getter
private List<ItemParamData> materialItems;
@Getter
private String recipeType;
@Override @Override
public int getId() { public int getId() {
@ -50,5 +39,4 @@ public class CombineData extends GameResource {
public boolean isDefaultShow() { public boolean isDefaultShow() {
return isDefaultShow; return isDefaultShow;
} }
} }

View File

@ -2,18 +2,15 @@ package emu.grasscutter.data.excels;
import emu.grasscutter.data.*; import emu.grasscutter.data.*;
import emu.grasscutter.data.common.ItemParamData; import emu.grasscutter.data.common.ItemParamData;
import lombok.Getter;
import java.util.List; import java.util.List;
import lombok.Getter;
@ResourceType( @ResourceType(
name = "EnvAnimalGatherExcelConfigData.json", name = "EnvAnimalGatherExcelConfigData.json",
loadPriority = ResourceType.LoadPriority.LOW) loadPriority = ResourceType.LoadPriority.LOW)
public class EnvAnimalGatherConfigData extends GameResource { public class EnvAnimalGatherConfigData extends GameResource {
@Getter @Getter private int animalId;
private int animalId; @Getter private String entityType;
@Getter
private String entityType;
private List<ItemParamData> gatherItemId; private List<ItemParamData> gatherItemId;
private String excludeWeathers; private String excludeWeathers;
private int aliveTime; private int aliveTime;

View File

@ -2,25 +2,19 @@ package emu.grasscutter.data.excels;
import emu.grasscutter.data.*; import emu.grasscutter.data.*;
import emu.grasscutter.data.common.FightPropData; import emu.grasscutter.data.common.FightPropData;
import lombok.Getter;
import java.util.ArrayList; import java.util.ArrayList;
import lombok.Getter;
@ResourceType(name = "EquipAffixExcelConfigData.json") @ResourceType(name = "EquipAffixExcelConfigData.json")
public class EquipAffixData extends GameResource { public class EquipAffixData extends GameResource {
private int affixId; private int affixId;
private int id; private int id;
@Getter @Getter private int level;
private int level; @Getter private long nameTextMapHash;
@Getter @Getter private String openConfig;
private long nameTextMapHash; @Getter private FightPropData[] addProps;
@Getter @Getter private float[] paramList;
private String openConfig;
@Getter
private FightPropData[] addProps;
@Getter
private float[] paramList;
@Override @Override
public int getId() { public int getId() {

View File

@ -7,8 +7,7 @@ import lombok.Getter;
@ResourceType(name = "FetterCharacterCardExcelConfigData.json", loadPriority = LoadPriority.HIGHEST) @ResourceType(name = "FetterCharacterCardExcelConfigData.json", loadPriority = LoadPriority.HIGHEST)
public class FetterCharacterCardData extends GameResource { public class FetterCharacterCardData extends GameResource {
private int avatarId; private int avatarId;
@Getter @Getter private int rewardId;
private int rewardId;
@Override @Override
public int getId() { public int getId() {

View File

@ -3,9 +3,8 @@ package emu.grasscutter.data.excels;
import emu.grasscutter.data.*; import emu.grasscutter.data.*;
import emu.grasscutter.data.ResourceType.LoadPriority; import emu.grasscutter.data.ResourceType.LoadPriority;
import emu.grasscutter.data.common.OpenCondData; import emu.grasscutter.data.common.OpenCondData;
import lombok.Getter;
import java.util.List; import java.util.List;
import lombok.Getter;
@ResourceType( @ResourceType(
name = { name = {
@ -17,8 +16,7 @@ import java.util.List;
}, },
loadPriority = LoadPriority.HIGHEST) loadPriority = LoadPriority.HIGHEST)
public class FetterData extends GameResource { public class FetterData extends GameResource {
@Getter @Getter private int avatarId;
private int avatarId;
private int fetterId; private int fetterId;
private List<OpenCondData> openCond; private List<OpenCondData> openCond;

View File

@ -7,12 +7,9 @@ import lombok.Getter;
public class GatherData extends GameResource { public class GatherData extends GameResource {
private int pointType; private int pointType;
private int id; private int id;
@Getter @Getter private int gadgetId;
private int gadgetId; @Getter private int itemId;
@Getter @Getter private int cd; // Probably hours
private int itemId;
@Getter
private int cd; // Probably hours
private boolean isForbidGuest; private boolean isForbidGuest;
private boolean initDisableInteract; private boolean initDisableInteract;

View File

@ -25,7 +25,8 @@ public class ProudSkillData extends GameResource {
@Getter private long nameTextMapHash; @Getter private long nameTextMapHash;
@Transient private Iterable<ItemParamData> totalCostItems; @Transient private Iterable<ItemParamData> totalCostItems;
@Transient @Getter private final Object2FloatMap<String> paramListMap = new Object2FloatOpenHashMap<>(); @Transient @Getter
private final Object2FloatMap<String> paramListMap = new Object2FloatOpenHashMap<>();
@Override @Override
public int getId() { public int getId() {

View File

@ -2,15 +2,13 @@ package emu.grasscutter.data.excels;
import emu.grasscutter.data.*; import emu.grasscutter.data.*;
import emu.grasscutter.data.common.ItemParamData; import emu.grasscutter.data.common.ItemParamData;
import lombok.Getter;
import java.util.List; import java.util.List;
import lombok.Getter;
@ResourceType(name = "RewardExcelConfigData.json") @ResourceType(name = "RewardExcelConfigData.json")
public class RewardData extends GameResource { public class RewardData extends GameResource {
public int rewardId; public int rewardId;
@Getter @Getter public List<ItemParamData> rewardItemList;
public List<ItemParamData> rewardItemList;
@Override @Override
public int getId() { public int getId() {

View File

@ -4,38 +4,26 @@ import com.google.gson.annotations.SerializedName;
import emu.grasscutter.data.*; import emu.grasscutter.data.*;
import emu.grasscutter.data.common.ItemParamData; import emu.grasscutter.data.common.ItemParamData;
import emu.grasscutter.game.shop.ShopInfo; import emu.grasscutter.game.shop.ShopInfo;
import lombok.Getter;
import java.util.List; import java.util.List;
import lombok.Getter;
@ResourceType(name = "ShopGoodsExcelConfigData.json") @ResourceType(name = "ShopGoodsExcelConfigData.json")
public class ShopGoodsData extends GameResource { public class ShopGoodsData extends GameResource {
@Getter @Getter private int goodsId;
private int goodsId; @Getter private int shopType;
@Getter @Getter private int itemId;
private int shopType;
@Getter
private int itemId;
@Getter @Getter private int itemCount;
private int itemCount;
@Getter @Getter private int costScoin;
private int costScoin; @Getter private int costHcoin;
@Getter @Getter private int costMcoin;
private int costHcoin;
@Getter
private int costMcoin;
@Getter @Getter private List<ItemParamData> costItems;
private List<ItemParamData> costItems; @Getter private int minPlayerLevel;
@Getter @Getter private int maxPlayerLevel;
private int minPlayerLevel;
@Getter
private int maxPlayerLevel;
@Getter @Getter private int buyLimit;
private int buyLimit;
@Getter @Getter
@SerializedName( @SerializedName(
@ -46,8 +34,7 @@ public class ShopGoodsData extends GameResource {
private String refreshType; private String refreshType;
private transient ShopInfo.ShopRefreshType refreshTypeEnum; private transient ShopInfo.ShopRefreshType refreshTypeEnum;
@Getter @Getter private int refreshParam;
private int refreshParam;
@Override @Override
public void onLoad() { public void onLoad() {
@ -71,5 +58,4 @@ public class ShopGoodsData extends GameResource {
public ShopInfo.ShopRefreshType getRefreshType() { public ShopInfo.ShopRefreshType getRefreshType() {
return refreshTypeEnum; return refreshTypeEnum;
} }
} }

View File

@ -9,12 +9,9 @@ public class AvatarCostumeData extends GameResource {
@SerializedName(value = "skinId", alternate = "costumeId") @SerializedName(value = "skinId", alternate = "costumeId")
private int skinId; private int skinId;
@Getter @Getter private int itemId;
private int itemId; @Getter private int characterId;
@Getter @Getter private int quality;
private int characterId;
@Getter
private int quality;
@Override @Override
public int getId() { public int getId() {

View File

@ -2,15 +2,13 @@ package emu.grasscutter.data.excels.avatar;
import emu.grasscutter.data.*; import emu.grasscutter.data.*;
import emu.grasscutter.data.common.CurveInfo; import emu.grasscutter.data.common.CurveInfo;
import lombok.Getter;
import java.util.*; import java.util.*;
import java.util.stream.Stream; import java.util.stream.Stream;
import lombok.Getter;
@ResourceType(name = "AvatarCurveExcelConfigData.json") @ResourceType(name = "AvatarCurveExcelConfigData.json")
public class AvatarCurveData extends GameResource { public class AvatarCurveData extends GameResource {
@Getter @Getter private int level;
private int level;
private CurveInfo[] curveInfos; private CurveInfo[] curveInfos;
private Map<String, Float> curveInfoMap; private Map<String, Float> curveInfoMap;

View File

@ -6,8 +6,7 @@ import lombok.Getter;
@ResourceType(name = "AvatarFlycloakExcelConfigData.json") @ResourceType(name = "AvatarFlycloakExcelConfigData.json")
public class AvatarFlycloakData extends GameResource { public class AvatarFlycloakData extends GameResource {
private int flycloakId; private int flycloakId;
@Getter @Getter private long nameTextMapHash;
private long nameTextMapHash;
@Override @Override
public int getId() { public int getId() {

View File

@ -13,5 +13,4 @@ public class AvatarLevelData extends GameResource {
public int getId() { public int getId() {
return this.level; return this.level;
} }
} }

View File

@ -2,26 +2,19 @@ package emu.grasscutter.data.excels.avatar;
import emu.grasscutter.data.*; import emu.grasscutter.data.*;
import emu.grasscutter.data.common.*; import emu.grasscutter.data.common.*;
import lombok.Getter;
import java.util.ArrayList; import java.util.ArrayList;
import lombok.Getter;
@ResourceType(name = "AvatarPromoteExcelConfigData.json") @ResourceType(name = "AvatarPromoteExcelConfigData.json")
public class AvatarPromoteData extends GameResource { public class AvatarPromoteData extends GameResource {
@Getter @Getter private int avatarPromoteId;
private int avatarPromoteId; @Getter private int promoteLevel;
@Getter
private int promoteLevel;
private int scoinCost; private int scoinCost;
@Getter @Getter private ItemParamData[] costItems;
private ItemParamData[] costItems; @Getter private int unlockMaxLevel;
@Getter @Getter private FightPropData[] addProps;
private int unlockMaxLevel; @Getter private int requiredPlayerLevel;
@Getter
private FightPropData[] addProps;
@Getter
private int requiredPlayerLevel;
@Override @Override
public int getId() { public int getId() {

View File

@ -3,28 +3,20 @@ package emu.grasscutter.data.excels.avatar;
import emu.grasscutter.data.*; import emu.grasscutter.data.*;
import emu.grasscutter.data.ResourceType.LoadPriority; import emu.grasscutter.data.ResourceType.LoadPriority;
import emu.grasscutter.data.common.FightPropData; import emu.grasscutter.data.common.FightPropData;
import lombok.Getter;
import java.util.ArrayList; import java.util.ArrayList;
import lombok.Getter;
@ResourceType(name = "AvatarTalentExcelConfigData.json", loadPriority = LoadPriority.HIGHEST) @ResourceType(name = "AvatarTalentExcelConfigData.json", loadPriority = LoadPriority.HIGHEST)
public class AvatarTalentData extends GameResource { public class AvatarTalentData extends GameResource {
private int talentId; private int talentId;
private int prevTalent; private int prevTalent;
@Getter @Getter private long nameTextMapHash;
private long nameTextMapHash; @Getter private String icon;
@Getter @Getter private int mainCostItemId;
private String icon; @Getter private int mainCostItemCount;
@Getter @Getter private String openConfig;
private int mainCostItemId; @Getter private FightPropData[] addProps;
@Getter @Getter private float[] paramList;
private int mainCostItemCount;
@Getter
private String openConfig;
@Getter
private FightPropData[] addProps;
@Getter
private float[] paramList;
@Override @Override
public int getId() { public int getId() {

View File

@ -5,14 +5,10 @@ import lombok.Getter;
@ResourceType(name = {"QuestCodexExcelConfigData.json"}) @ResourceType(name = {"QuestCodexExcelConfigData.json"})
public class CodexQuestData extends GameResource { public class CodexQuestData extends GameResource {
@Getter @Getter private int Id;
private int Id; @Getter private int parentQuestId;
@Getter @Getter private int chapterId;
private int parentQuestId; @Getter private int sortOrder;
@Getter
private int chapterId;
@Getter
private int sortOrder;
private boolean isDisuse; private boolean isDisuse;
public boolean getIsDisuse() { public boolean getIsDisuse() {

View File

@ -5,13 +5,10 @@ import lombok.Getter;
@ResourceType(name = {"WeaponCodexExcelConfigData.json"}) @ResourceType(name = {"WeaponCodexExcelConfigData.json"})
public class CodexWeaponData extends GameResource { public class CodexWeaponData extends GameResource {
@Getter @Getter private int Id;
private int Id; @Getter private int weaponId;
@Getter
private int weaponId;
private int gadgetId; private int gadgetId;
@Getter @Getter private int sortOrder;
private int sortOrder;
public int getGadgetId() { public int getGadgetId() {
return weaponId; return weaponId;

View File

@ -9,8 +9,7 @@ import lombok.Getter;
@Getter @Getter
@ResourceType(name = "DungeonChallengeConfigData.json") @ResourceType(name = "DungeonChallengeConfigData.json")
public class DungeonChallengeConfigData extends GameResource { public class DungeonChallengeConfigData extends GameResource {
@Getter @Getter private int id;
private int id;
private ChallengeType challengeType; private ChallengeType challengeType;
private boolean noSuccessHint; private boolean noSuccessHint;
private boolean noFailHint; private boolean noFailHint;
@ -43,7 +42,7 @@ public class DungeonChallengeConfigData extends GameResource {
alternate = {"NJBJIKAIENN"}) alternate = {"NJBJIKAIENN"})
private AllowAnimationType animationOnSubFail; private AllowAnimationType animationOnSubFail;
public enum InterruptButtonType { public enum InterruptButtonType {
INTERRUPT_BUTTON_TYPE_NONE, INTERRUPT_BUTTON_TYPE_NONE,
INTERRUPT_BUTTON_TYPE_HOST, INTERRUPT_BUTTON_TYPE_HOST,
INTERRUPT_BUTTON_TYPE_ALL INTERRUPT_BUTTON_TYPE_ALL

View File

@ -7,8 +7,7 @@ import lombok.Getter;
@ResourceType(name = "ReliquarySetExcelConfigData.json") @ResourceType(name = "ReliquarySetExcelConfigData.json")
public class ReliquarySetData extends GameResource { public class ReliquarySetData extends GameResource {
private int setId; private int setId;
@Getter @Getter private int[] setNeedNum;
private int[] setNeedNum;
@Getter @Getter
@SerializedName( @SerializedName(

View File

@ -1,9 +1,8 @@
package emu.grasscutter.data.excels.tower; package emu.grasscutter.data.excels.tower;
import emu.grasscutter.data.*; import emu.grasscutter.data.*;
import lombok.Getter;
import java.util.List; import java.util.List;
import lombok.Getter;
@Getter @Getter
@ResourceType(name = "TowerScheduleExcelConfigData.json") @ResourceType(name = "TowerScheduleExcelConfigData.json")
@ -28,6 +27,5 @@ public class TowerScheduleData extends GameResource {
@Getter @Getter
public static class ScheduleDetail { public static class ScheduleDetail {
private List<Integer> floorList; private List<Integer> floorList;
} }
} }

View File

@ -13,5 +13,4 @@ public class WeaponLevelData extends GameResource {
public int getId() { public int getId() {
return this.level; return this.level;
} }
} }

View File

@ -2,9 +2,8 @@ package emu.grasscutter.data.excels.weapon;
import emu.grasscutter.data.*; import emu.grasscutter.data.*;
import emu.grasscutter.data.common.*; import emu.grasscutter.data.common.*;
import lombok.Getter;
import java.util.ArrayList; import java.util.ArrayList;
import lombok.Getter;
@Getter @Getter
@ResourceType(name = "WeaponPromoteExcelConfigData.json") @ResourceType(name = "WeaponPromoteExcelConfigData.json")

View File

@ -6,8 +6,7 @@ import lombok.Getter;
@ResourceType(name = "WorldLevelExcelConfigData.json") @ResourceType(name = "WorldLevelExcelConfigData.json")
public class WorldLevelData extends GameResource { public class WorldLevelData extends GameResource {
private int level; private int level;
@Getter @Getter private int monsterLevel;
private int monsterLevel;
@Override @Override
public int getId() { public int getId() {

View File

@ -5,9 +5,8 @@ import com.github.davidmoten.rtreemulti.geometry.Geometry;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
import emu.grasscutter.game.world.*; import emu.grasscutter.game.world.*;
import emu.grasscutter.scripts.SceneIndexManager; import emu.grasscutter.scripts.SceneIndexManager;
import lombok.Getter;
import java.util.*; import java.util.*;
import lombok.Getter;
public class Grid { public class Grid {
public transient RTree<Map.Entry<GridPosition, Set<Integer>>, Geometry> gridOptimized = null; public transient RTree<Map.Entry<GridPosition, Set<Integer>>, Geometry> gridOptimized = null;
@ -18,8 +17,7 @@ public class Grid {
* *
* @return The correctly loaded grid map. * @return The correctly loaded grid map.
*/ */
@Getter @Getter public Map<GridPosition, Set<Integer>> grid = new LinkedHashMap<>();
public Map<GridPosition, Set<Integer>> grid = new LinkedHashMap<>();
/** Creates an optimized cache of the grid. */ /** Creates an optimized cache of the grid. */
private void optimize() { private void optimize() {

View File

@ -550,7 +550,7 @@ public final class DatabaseHelper {
.first(); .first();
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
Grasscutter.getLogger() Grasscutter.getLogger()
.debug("Error occurred while getting uid {}'s achievement data", uid, e); .debug("Error occurred while getting uid {}'s achievement data", uid, e);
DatabaseManager.getGameDatabase().getCollection("achievements").deleteMany(eq("uid", uid)); DatabaseManager.getGameDatabase().getCollection("achievements").deleteMany(eq("uid", uid));
return null; return null;
} }

View File

@ -14,8 +14,7 @@ import emu.grasscutter.game.Account;
import lombok.Getter; import lombok.Getter;
public final class DatabaseManager { public final class DatabaseManager {
@Getter @Getter private static Datastore gameDatastore;
private static Datastore gameDatastore;
private static Datastore dispatchDatastore; private static Datastore dispatchDatastore;
public static Datastore getAccountDatastore() { public static Datastore getAccountDatastore() {

View File

@ -7,16 +7,13 @@ import emu.grasscutter.database.DatabaseHelper;
import emu.grasscutter.utils.*; import emu.grasscutter.utils.*;
import java.util.*; import java.util.*;
import java.util.stream.Stream; import java.util.stream.Stream;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.bson.Document; import org.bson.Document;
@Entity(value = "accounts", useDiscriminator = false) @Entity(value = "accounts", useDiscriminator = false)
public class Account { public class Account {
@Setter @Setter @Getter @Id private String id;
@Getter
@Id private String id;
@Setter @Setter
@Getter @Getter
@ -24,38 +21,21 @@ public class Account {
@Collation(locale = "simple", caseLevel = true) @Collation(locale = "simple", caseLevel = true)
private String username; private String username;
@Setter @Setter @Getter private String password; // Unused for now
@Getter
private String password; // Unused for now
private int reservedPlayerId; private int reservedPlayerId;
@Setter @Setter private String email;
private String email;
@Setter @Setter @Getter private String token;
@Getter @Getter private String sessionKey; // Session token for dispatch server
private String token; /** -- GETTER -- The collection of a player's permissions. */
@Getter @Getter private final List<String> permissions;
private String sessionKey; // Session token for dispatch server
/**
* -- GETTER --
* The collection of a player's permissions.
*/
@Getter
private final List<String> permissions;
@Setter
@Getter
private Locale locale;
@Setter @Setter @Getter private Locale locale;
@Getter
private String banReason; @Setter @Getter private String banReason;
@Setter @Setter @Getter private int banEndTime;
@Getter @Setter @Getter private int banStartTime;
private int banEndTime;
@Setter
@Getter
private int banStartTime;
private boolean isBanned; private boolean isBanned;
@Deprecated @Deprecated

View File

@ -22,7 +22,8 @@ public class Ability {
@Getter private final Object2FloatMap<String> abilitySpecials = new Object2FloatOpenHashMap<>(); @Getter private final Object2FloatMap<String> abilitySpecials = new Object2FloatOpenHashMap<>();
@Getter @Getter
private static final Map<String, Object2FloatMap<String>> abilitySpecialsModified = new HashMap<>(); private static final Map<String, Object2FloatMap<String>> abilitySpecialsModified =
new HashMap<>();
@Getter private final int hash; @Getter private final int hash;
@Getter private final Set<Integer> avatarSkillStartIds; @Getter private final Set<Integer> avatarSkillStartIds;

View File

@ -83,12 +83,13 @@ public final class AbilityManager extends BasePlayerManager {
boolean skillInvincibility = modifier.state == AbilityModifier.State.Invincible; boolean skillInvincibility = modifier.state == AbilityModifier.State.Invincible;
if (modifier.onAdded != null) { if (modifier.onAdded != null) {
skillInvincibility |= skillInvincibility |=
!Arrays.stream(modifier.onAdded) !Arrays.stream(modifier.onAdded)
.filter( .filter(
action -> action ->
action.type == AbilityModifierAction.Type.AttachAbilityStateResistance action.type == AbilityModifierAction.Type.AttachAbilityStateResistance
&& action.resistanceListID == 11002) && action.resistanceListID == 11002)
.toList().isEmpty(); .toList()
.isEmpty();
} }
if (this.burstCasterId == entityId if (this.burstCasterId == entityId
@ -177,7 +178,12 @@ public final class AbilityManager extends BasePlayerManager {
public void onAbilityInvoke(AbilityInvokeEntry invoke) throws Exception { public void onAbilityInvoke(AbilityInvokeEntry invoke) throws Exception {
Grasscutter.getLogger() Grasscutter.getLogger()
.trace("Ability invoke: {} {} ({}): {}", invoke, invoke.getArgumentType(), invoke.getArgumentTypeValue(), this.player.getScene().getEntityById(invoke.getEntityId())); .trace(
"Ability invoke: {} {} ({}): {}",
invoke,
invoke.getArgumentType(),
invoke.getArgumentTypeValue(),
this.player.getScene().getEntityById(invoke.getEntityId()));
var entity = this.player.getScene().getEntityById(invoke.getEntityId()); var entity = this.player.getScene().getEntityById(invoke.getEntityId());
if (entity != null) { if (entity != null) {
Grasscutter.getLogger() Grasscutter.getLogger()
@ -204,7 +210,8 @@ public final class AbilityManager extends BasePlayerManager {
if (invoke.getHead().getTargetId() != 0) { if (invoke.getHead().getTargetId() != 0) {
Grasscutter.getLogger() Grasscutter.getLogger()
.trace("Target: {}", this.player.getScene().getEntityById(invoke.getHead().getTargetId())); .trace(
"Target: {}", this.player.getScene().getEntityById(invoke.getHead().getTargetId()));
} }
if (invoke.getHead().getLocalId() != 0) { if (invoke.getHead().getLocalId() != 0) {
this.handleServerInvoke(invoke); this.handleServerInvoke(invoke);

View File

@ -61,9 +61,10 @@ public class Achievements {
GameData.getAchievementDataMap().values().stream() GameData.getAchievementDataMap().values().stream()
.filter(AchievementData::isUsed) .filter(AchievementData::isUsed)
.forEach( .forEach(
a -> map.put( a ->
a.getId(), map.put(
new Achievement(Status.STATUS_UNFINISHED, a.getId(), a.getProgress(), 0, 0))); a.getId(),
new Achievement(Status.STATUS_UNFINISHED, a.getId(), a.getProgress(), 0, 0)));
return map; return map;
} }
@ -175,12 +176,13 @@ public class Achievements {
return this.getAchievementList() return this.getAchievementList()
.computeIfAbsent( .computeIfAbsent(
achievementId, achievementId,
id -> new Achievement( id ->
Status.STATUS_UNFINISHED, new Achievement(
id, Status.STATUS_UNFINISHED,
GameData.getAchievementDataMap().get(id.intValue()).getProgress(), id,
0, GameData.getAchievementDataMap().get(id.intValue()).getProgress(),
0)); 0,
0));
} }
public boolean isInvalid(int achievementId) { public boolean isInvalid(int achievementId) {
@ -231,7 +233,7 @@ public class Achievements {
}); });
var a = this.getAchievement(i); var a = this.getAchievement(i);
if(a == null) { if (a == null) {
Grasscutter.getLogger().warn("null returned while getting achievement!"); Grasscutter.getLogger().warn("null returned while getting achievement!");
return; return;
} }

View File

@ -25,7 +25,8 @@ public class AllActivityConditionBuilder {
private Map<ActivityConditions, ActivityConditionBaseHandler> initActivityConditions() { private Map<ActivityConditions, ActivityConditionBaseHandler> initActivityConditions() {
Reflections reflector = Grasscutter.reflector; Reflections reflector = Grasscutter.reflector;
return reflector.getTypesAnnotatedWith(ActivityCondition.class).stream() return reflector.getTypesAnnotatedWith(ActivityCondition.class).stream()
.map(this::newInstance).filter(Objects::nonNull) .map(this::newInstance)
.filter(Objects::nonNull)
.map(h -> new AbstractMap.SimpleEntry<>(extractActionType(h), h)) .map(h -> new AbstractMap.SimpleEntry<>(extractActionType(h), h))
.collect( .collect(
Collectors.toMap(AbstractMap.SimpleEntry::getKey, AbstractMap.SimpleEntry::getValue)); Collectors.toMap(AbstractMap.SimpleEntry::getKey, AbstractMap.SimpleEntry::getValue));

View File

@ -1,5 +1,7 @@
package emu.grasscutter.game.avatar; package emu.grasscutter.game.avatar;
import static emu.grasscutter.config.Configuration.GAME_OPTIONS;
import dev.morphia.annotations.*; import dev.morphia.annotations.*;
import emu.grasscutter.GameConstants; import emu.grasscutter.GameConstants;
import emu.grasscutter.data.GameData; import emu.grasscutter.data.GameData;
@ -44,130 +46,72 @@ import emu.grasscutter.net.proto.TrialAvatarInfoOuterClass.TrialAvatarInfo;
import emu.grasscutter.server.packet.send.*; import emu.grasscutter.server.packet.send.*;
import emu.grasscutter.utils.helpers.ProtoHelper; import emu.grasscutter.utils.helpers.ProtoHelper;
import it.unimi.dsi.fastutil.ints.*; import it.unimi.dsi.fastutil.ints.*;
import java.util.*;
import java.util.stream.Stream;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.val; import lombok.val;
import org.bson.types.ObjectId; import org.bson.types.ObjectId;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.*;
import java.util.stream.Stream;
import static emu.grasscutter.config.Configuration.GAME_OPTIONS;
@Entity(value = "avatars", useDiscriminator = false) @Entity(value = "avatars", useDiscriminator = false)
public class Avatar { public class Avatar {
@Transient @Transient @Getter private final Int2ObjectMap<GameItem> equips;
@Getter @Transient @Getter private final Int2FloatOpenHashMap fightProperties;
private final Int2ObjectMap<GameItem> equips; @Transient @Getter private final Int2FloatOpenHashMap fightPropOverrides;
@Transient @Id private ObjectId id;
@Getter @Indexed @Getter private int ownerId; // Id of player that this avatar belongs to
private final Int2FloatOpenHashMap fightProperties; @Transient private Player owner;
@Transient @Transient @Getter private AvatarData avatarData;
@Getter @Nullable @Transient @Getter private AvatarSkillDepotData skillDepot;
private final Int2FloatOpenHashMap fightPropOverrides; @Transient @Getter private long guid; // Player unique id
@Id @Getter private int avatarId; // Id of avatar
private ObjectId id; @Getter @Setter private int level = 1;
@Indexed @Getter @Setter private int exp;
@Getter @Getter @Setter private int promoteLevel;
private int ownerId; // Id of player that this avatar belongs to @Getter @Setter private int satiation; // Fullness
@Transient @Getter @Setter private int satiationPenalty; // When eating too much
private Player owner; @Getter @Setter private float currentHp;
@Transient
@Getter
private AvatarData avatarData;
@Nullable
@Transient
@Getter
private AvatarSkillDepotData skillDepot;
@Transient
@Getter
private long guid; // Player unique id
@Getter
private int avatarId; // Id of avatar
@Getter
@Setter
private int level = 1;
@Getter
@Setter
private int exp;
@Getter
@Setter
private int promoteLevel;
@Getter
@Setter
private int satiation; // Fullness
@Getter
@Setter
private int satiationPenalty; // When eating too much
@Getter
@Setter
private float currentHp;
private float currentEnergy; private float currentEnergy;
@Transient @Transient @Getter private Set<String> extraAbilityEmbryos;
@Getter
private Set<String> extraAbilityEmbryos;
private List<Integer> fetters; private List<Integer> fetters;
private final Map<Integer, Integer> skillLevelMap = new Int2IntArrayMap(7); // Talent levels private final Map<Integer, Integer> skillLevelMap = new Int2IntArrayMap(7); // Talent levels
@Transient @Transient @Getter
@Getter
private final Map<Integer, Integer> skillExtraChargeMap = new Int2IntArrayMap(2); // Charges private final Map<Integer, Integer> skillExtraChargeMap = new Int2IntArrayMap(2); // Charges
@Transient @Transient
private final Map<Integer, Integer> proudSkillBonusMap = new Int2IntArrayMap(2); // Talent bonus levels (from const) private final Map<Integer, Integer> proudSkillBonusMap =
new Int2IntArrayMap(2); // Talent bonus levels (from const)
@Getter @Getter private int skillDepotId;
private int skillDepotId;
private Set<Integer> talentIdList; // Constellation id list private Set<Integer> talentIdList; // Constellation id list
@Getter @Getter private Set<Integer> proudSkillList; // Character passives
private Set<Integer> proudSkillList; // Character passives
@Getter @Getter @Setter private int flyCloak;
@Setter @Getter @Setter private int costume;
private int flyCloak; @Getter private int bornTime;
@Getter
@Setter
private int costume;
@Getter
private int bornTime;
@Getter @Getter @Setter private int fetterLevel = 1;
@Setter @Getter @Setter private int fetterExp;
private int fetterLevel = 1;
@Getter
@Setter
private int fetterExp;
@Getter @Getter @Setter private int nameCardRewardId;
@Setter @Getter @Setter private int nameCardId;
private int nameCardRewardId;
@Getter
@Setter
private int nameCardId;
// trial avatar property // trial avatar property
@Getter @Getter @Setter private int trialAvatarId = 0;
@Setter
private int trialAvatarId = 0;
// cannot store to db if grant reason is not integer // cannot store to db if grant reason is not integer
@Getter @Getter @Setter
@Setter
private int grantReason = TrialAvatarGrantRecord.GrantReason.GRANT_REASON_INVALID.getNumber(); private int grantReason = TrialAvatarGrantRecord.GrantReason.GRANT_REASON_INVALID.getNumber();
@Getter @Getter @Setter private int fromParentQuestId = 0;
@Setter
private int fromParentQuestId = 0;
// so far no outer class or prop value has information of this, but from packet: // so far no outer class or prop value has information of this, but from packet:
// 1 = normal, 2 = trial avatar // 1 = normal, 2 = trial avatar
@Transient @Transient @Getter @Setter private int avatarType = Type.NORMAL.getNumber();
@Getter
@Setter
private int avatarType = Type.NORMAL.getNumber();
@Deprecated // Do not use. Morhpia only! @Deprecated // Do not use. Morhpia only!
public Avatar() { public Avatar() {
@ -197,13 +141,18 @@ public class Avatar {
this.proudSkillList = new HashSet<>(); this.proudSkillList = new HashSet<>();
// Combat properties // Combat properties
Stream.of(FightProperty.values()).map(FightProperty::getId).filter(id -> (id > 0) && (id < 3000)).forEach(id -> this.setFightProperty(id, 0f)); Stream.of(FightProperty.values())
.map(FightProperty::getId)
.filter(id -> (id > 0) && (id < 3000))
.forEach(id -> this.setFightProperty(id, 0f));
this.setSkillDepotData(switch (this.getAvatarId()) { this.setSkillDepotData(
case GameConstants.MAIN_CHARACTER_MALE -> GameData.getAvatarSkillDepotDataMap().get(501); switch (this.getAvatarId()) {
case GameConstants.MAIN_CHARACTER_FEMALE -> GameData.getAvatarSkillDepotDataMap().get(701); case GameConstants.MAIN_CHARACTER_MALE -> GameData.getAvatarSkillDepotDataMap().get(501);
default -> data.getSkillDepot(); case GameConstants.MAIN_CHARACTER_FEMALE -> GameData.getAvatarSkillDepotDataMap()
}); .get(701);
default -> data.getSkillDepot();
});
// Set stats // Set stats
this.recalcStats(); this.recalcStats();
@ -235,7 +184,8 @@ public class Avatar {
* @return True if the avatar is a main character. * @return True if the avatar is a main character.
*/ */
public boolean isMainCharacter() { public boolean isMainCharacter() {
return List.of(GameConstants.MAIN_CHARACTER_MALE, GameConstants.MAIN_CHARACTER_FEMALE).contains(this.getAvatarId()); return List.of(GameConstants.MAIN_CHARACTER_MALE, GameConstants.MAIN_CHARACTER_FEMALE)
.contains(this.getAvatarId());
} }
public Player getPlayer() { public Player getPlayer() {
@ -297,8 +247,7 @@ public class Avatar {
/** /**
* @return The avatar's equipped weapon. * @return The avatar's equipped weapon.
*/ */
@Nullable @Nullable public GameItem getWeapon() {
public GameItem getWeapon() {
return this.getEquipBySlot(EquipType.EQUIP_WEAPON); return this.getEquipBySlot(EquipType.EQUIP_WEAPON);
} }
@ -328,17 +277,24 @@ public class Avatar {
* Changes this avatar's skill depot. * Changes this avatar's skill depot.
* *
* @param skillDepot The new skill depot. * @param skillDepot The new skill depot.
* @param notify Whether to notify the player of the change. * @param notify Whether to notify the player of the change.
*/ */
public void setSkillDepotData(AvatarSkillDepotData skillDepot, boolean notify) { public void setSkillDepotData(AvatarSkillDepotData skillDepot, boolean notify) {
// Set id and depot // Set id and depot
this.skillDepotId = skillDepot.getId(); this.skillDepotId = skillDepot.getId();
this.skillDepot = skillDepot; this.skillDepot = skillDepot;
// Add any missing skills // Add any missing skills
this.skillDepot.getSkillsAndEnergySkill().forEach(skillId -> this.skillLevelMap.putIfAbsent(skillId, 1)); this.skillDepot
.getSkillsAndEnergySkill()
.forEach(skillId -> this.skillLevelMap.putIfAbsent(skillId, 1));
// Add proud skills // Add proud skills
this.proudSkillList.clear(); this.proudSkillList.clear();
skillDepot.getInherentProudSkillOpens().stream().filter(openData -> openData.getProudSkillGroupId() > 0).filter(openData -> openData.getNeedAvatarPromoteLevel() <= this.getPromoteLevel()).mapToInt(openData -> (openData.getProudSkillGroupId() * 100) + 1).filter(proudSkillId -> GameData.getProudSkillDataMap().containsKey(proudSkillId)).forEach(proudSkillId -> this.proudSkillList.add(proudSkillId)); skillDepot.getInherentProudSkillOpens().stream()
.filter(openData -> openData.getProudSkillGroupId() > 0)
.filter(openData -> openData.getNeedAvatarPromoteLevel() <= this.getPromoteLevel())
.mapToInt(openData -> (openData.getProudSkillGroupId() * 100) + 1)
.filter(proudSkillId -> GameData.getProudSkillDataMap().containsKey(proudSkillId))
.forEach(proudSkillId -> this.proudSkillList.add(proudSkillId));
this.recalcStats(); this.recalcStats();
if (notify) { if (notify) {
@ -362,7 +318,7 @@ public class Avatar {
* in its 'candSkillDepot's. * in its 'candSkillDepot's.
* *
* @param elementTypeToChange The new element to change to. * @param elementTypeToChange The new element to change to.
* @param notify Whether to notify the player of the change. * @param notify Whether to notify the player of the change.
* @return True if the element was changed, false otherwise. * @return True if the element was changed, false otherwise.
*/ */
public boolean changeElement(@Nonnull ElementType elementTypeToChange, boolean notify) { public boolean changeElement(@Nonnull ElementType elementTypeToChange, boolean notify) {
@ -410,7 +366,8 @@ public class Avatar {
ElementType element = depot.getElementType(); ElementType element = depot.getElementType();
var maxEnergy = depot.getEnergySkillData().getCostElemVal(); var maxEnergy = depot.getEnergySkillData().getCostElemVal();
this.setFightProperty(element.getMaxEnergyProp(), maxEnergy); this.setFightProperty(element.getMaxEnergyProp(), maxEnergy);
this.setFightProperty(element.getCurEnergyProp(), GAME_OPTIONS.energyUsage ? currentEnergy : maxEnergy); this.setFightProperty(
element.getCurEnergyProp(), GAME_OPTIONS.energyUsage ? currentEnergy : maxEnergy);
} }
} }
@ -438,10 +395,14 @@ public class Avatar {
return getFightProperties().getOrDefault(prop.getId(), 0f); return getFightProperties().getOrDefault(prop.getId(), 0f);
} }
public Map<Integer, Integer> getSkillLevelMap() { // Returns a copy of the skill levels for the current skillDepot. public Map<Integer, Integer>
getSkillLevelMap() { // Returns a copy of the skill levels for the current skillDepot.
var map = new Int2IntOpenHashMap(); var map = new Int2IntOpenHashMap();
if (this.skillDepot == null) return map; if (this.skillDepot == null) return map;
this.skillDepot.getSkillsAndEnergySkill().forEach(skillId -> map.put(skillId, this.skillLevelMap.putIfAbsent(skillId, 1).intValue())); this.skillDepot
.getSkillsAndEnergySkill()
.forEach(
skillId -> map.put(skillId, this.skillLevelMap.putIfAbsent(skillId, 1).intValue()));
return map; return map;
} }
@ -450,18 +411,21 @@ public class Avatar {
public Map<Integer, Integer> getProudSkillBonusMap() { public Map<Integer, Integer> getProudSkillBonusMap() {
var map = new Int2IntArrayMap(); var map = new Int2IntArrayMap();
if (this.skillDepot == null) return map; if (this.skillDepot == null) return map;
this.skillDepot.getSkillsAndEnergySkill().forEach(skillId -> { this.skillDepot
val skillData = GameData.getAvatarSkillDataMap().get(skillId); .getSkillsAndEnergySkill()
if (skillData == null) return; .forEach(
int proudSkillGroupId = skillData.getProudSkillGroupId(); skillId -> {
int bonus = this.proudSkillBonusMap.getOrDefault(proudSkillGroupId, 0); val skillData = GameData.getAvatarSkillDataMap().get(skillId);
int maxLevel = GameData.getProudSkillGroupMaxLevel(proudSkillGroupId); if (skillData == null) return;
int curLevel = this.skillLevelMap.getOrDefault(skillId, 0); int proudSkillGroupId = skillData.getProudSkillGroupId();
if (maxLevel > 0) { int bonus = this.proudSkillBonusMap.getOrDefault(proudSkillGroupId, 0);
bonus = Math.min(bonus, maxLevel - curLevel); int maxLevel = GameData.getProudSkillGroupMaxLevel(proudSkillGroupId);
} int curLevel = this.skillLevelMap.getOrDefault(skillId, 0);
map.put(proudSkillGroupId, bonus); if (maxLevel > 0) {
}); bonus = Math.min(bonus, maxLevel - curLevel);
}
map.put(proudSkillGroupId, bonus);
});
return map; return map;
} }
@ -495,7 +459,9 @@ public class Avatar {
if (otherAvatar != null) { if (otherAvatar != null) {
// Unequip other avatar's item // Unequip other avatar's item
if (otherAvatar.unequipItem(item.getItemData().getEquipType())) { if (otherAvatar.unequipItem(item.getItemData().getEquipType())) {
getPlayer().sendPacket(new PacketAvatarEquipChangeNotify(otherAvatar, item.getItemData().getEquipType())); getPlayer()
.sendPacket(
new PacketAvatarEquipChangeNotify(otherAvatar, item.getItemData().getEquipType()));
} }
// Swap with other avatar // Swap with other avatar
if (getEquips().containsKey(itemEquipType.getValue())) { if (getEquips().containsKey(itemEquipType.getValue())) {
@ -513,9 +479,14 @@ public class Avatar {
this.getEquips().put(itemEquipType.getValue(), item); this.getEquips().put(itemEquipType.getValue(), item);
if (itemEquipType == EquipType.EQUIP_WEAPON && getPlayer().getWorld() != null) { if (itemEquipType == EquipType.EQUIP_WEAPON && getPlayer().getWorld() != null) {
if (!(item.getWeaponEntity() != null && item.getWeaponEntity().getScene() == getPlayer().getScene())) { if (!(item.getWeaponEntity() != null
item.setWeaponEntity(new EntityWeapon(this.getPlayer().getScene(), item.getItemData().getGadgetId())); && item.getWeaponEntity().getScene() == getPlayer().getScene())) {
this.getPlayer().getScene().getWeaponEntities().put(item.getWeaponEntity().getId(), item.getWeaponEntity()); item.setWeaponEntity(
new EntityWeapon(this.getPlayer().getScene(), item.getItemData().getGadgetId()));
this.getPlayer()
.getScene()
.getWeaponEntities()
.put(item.getWeaponEntity().getId(), item.getWeaponEntity());
} }
// item.setWeaponEntityId(this.getPlayer().getWorld().getNextEntityId(EntityIdType.WEAPON)); // item.setWeaponEntityId(this.getPlayer().getWorld().getNextEntityId(EntityIdType.WEAPON));
} }
@ -553,7 +524,8 @@ public class Avatar {
public void recalcStats(boolean forceSendAbilityChange) { public void recalcStats(boolean forceSendAbilityChange) {
// Setup // Setup
var data = this.getAvatarData(); var data = this.getAvatarData();
var promoteData = GameData.getAvatarPromoteData(data.getAvatarPromoteId(), this.getPromoteLevel()); var promoteData =
GameData.getAvatarPromoteData(data.getAvatarPromoteId(), this.getPromoteLevel());
var setMap = new Int2IntOpenHashMap(); var setMap = new Int2IntOpenHashMap();
// Extra ability embryos // Extra ability embryos
@ -566,18 +538,27 @@ public class Avatar {
this.setNameCardId(data.getNameCardId()); this.setNameCardId(data.getNameCardId());
// Get hp percent, set to 100% if none // Get hp percent, set to 100% if none
float hpPercent = this.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP) <= 0 ? 1f : this.getFightProperty(FightProperty.FIGHT_PROP_CUR_HP) / this.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP); float hpPercent =
this.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP) <= 0
? 1f
: this.getFightProperty(FightProperty.FIGHT_PROP_CUR_HP)
/ this.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP);
// Store current energy value for later // Store current energy value for later
float currentEnergy = (this.getSkillDepot() != null) ? this.getFightProperty(this.getSkillDepot().getElementType().getCurEnergyProp()) : 0f; float currentEnergy =
(this.getSkillDepot() != null)
? this.getFightProperty(this.getSkillDepot().getElementType().getCurEnergyProp())
: 0f;
// Clear properties // Clear properties
this.getFightProperties().clear(); this.getFightProperties().clear();
// Base stats // Base stats
this.setFightProperty(FightProperty.FIGHT_PROP_BASE_HP, data.getBaseHp(this.getLevel())); this.setFightProperty(FightProperty.FIGHT_PROP_BASE_HP, data.getBaseHp(this.getLevel()));
this.setFightProperty(FightProperty.FIGHT_PROP_BASE_ATTACK, data.getBaseAttack(this.getLevel())); this.setFightProperty(
this.setFightProperty(FightProperty.FIGHT_PROP_BASE_DEFENSE, data.getBaseDefense(this.getLevel())); FightProperty.FIGHT_PROP_BASE_ATTACK, data.getBaseAttack(this.getLevel()));
this.setFightProperty(
FightProperty.FIGHT_PROP_BASE_DEFENSE, data.getBaseDefense(this.getLevel()));
this.setFightProperty(FightProperty.FIGHT_PROP_CRITICAL, data.getBaseCritical()); this.setFightProperty(FightProperty.FIGHT_PROP_CRITICAL, data.getBaseCritical());
this.setFightProperty(FightProperty.FIGHT_PROP_CRITICAL_HURT, data.getBaseCriticalHurt()); this.setFightProperty(FightProperty.FIGHT_PROP_CRITICAL_HURT, data.getBaseCriticalHurt());
this.setFightProperty(FightProperty.FIGHT_PROP_CHARGE_EFFICIENCY, 1f); this.setFightProperty(FightProperty.FIGHT_PROP_CHARGE_EFFICIENCY, 1f);
@ -599,11 +580,14 @@ public class Avatar {
continue; continue;
} }
// Artifact main stat // Artifact main stat
ReliquaryMainPropData mainPropData = GameData.getReliquaryMainPropDataMap().get(equip.getMainPropId()); ReliquaryMainPropData mainPropData =
GameData.getReliquaryMainPropDataMap().get(equip.getMainPropId());
if (mainPropData != null) { if (mainPropData != null) {
ReliquaryLevelData levelData = GameData.getRelicLevelData(equip.getItemData().getRankLevel(), equip.getLevel()); ReliquaryLevelData levelData =
GameData.getRelicLevelData(equip.getItemData().getRankLevel(), equip.getLevel());
if (levelData != null) { if (levelData != null) {
this.addFightProperty(mainPropData.getFightProp(), levelData.getPropValue(mainPropData.getFightProp())); this.addFightProperty(
mainPropData.getFightProp(), levelData.getPropValue(mainPropData.getFightProp()));
} }
} }
// Artifact sub stats // Artifact sub stats
@ -620,31 +604,32 @@ public class Avatar {
} }
// Set stuff // Set stuff
setMap.forEach((setId, amount) -> { setMap.forEach(
ReliquarySetData setData = GameData.getReliquarySetDataMap().get((int) setId); (setId, amount) -> {
if (setData == null) return; ReliquarySetData setData = GameData.getReliquarySetDataMap().get((int) setId);
if (setData == null) return;
// Calculate how many items are from the set // Calculate how many items are from the set
// Add affix data from set bonus // Add affix data from set bonus
val setNeedNum = setData.getSetNeedNum(); val setNeedNum = setData.getSetNeedNum();
for (int setIndex = 0; setIndex < setNeedNum.length; setIndex++) { for (int setIndex = 0; setIndex < setNeedNum.length; setIndex++) {
if (amount < setNeedNum[setIndex]) break; if (amount < setNeedNum[setIndex]) break;
int affixId = (setData.getEquipAffixId() * 10) + setIndex; int affixId = (setData.getEquipAffixId() * 10) + setIndex;
EquipAffixData affix = GameData.getEquipAffixDataMap().get(affixId); EquipAffixData affix = GameData.getEquipAffixDataMap().get(affixId);
if (affix == null) { if (affix == null) {
continue; continue;
} }
// Add properties from this affix to our avatar // Add properties from this affix to our avatar
for (FightPropData prop : affix.getAddProps()) { for (FightPropData prop : affix.getAddProps()) {
this.addFightProperty(prop.getProp(), prop.getValue()); this.addFightProperty(prop.getProp(), prop.getValue());
} }
// Add any skill strings from this affix // Add any skill strings from this affix
this.addToExtraAbilityEmbryos(affix.getOpenConfig(), true); this.addToExtraAbilityEmbryos(affix.getOpenConfig(), true);
} }
}); });
// Weapon // Weapon
GameItem weapon = this.getWeapon(); GameItem weapon = this.getWeapon();
@ -653,11 +638,15 @@ public class Avatar {
WeaponCurveData curveData = GameData.getWeaponCurveDataMap().get(weapon.getLevel()); WeaponCurveData curveData = GameData.getWeaponCurveDataMap().get(weapon.getLevel());
if (curveData != null) { if (curveData != null) {
for (WeaponProperty weaponProperty : weapon.getItemData().getWeaponProperties()) { for (WeaponProperty weaponProperty : weapon.getItemData().getWeaponProperties()) {
this.addFightProperty(weaponProperty.getPropType(), weaponProperty.getInitValue() * curveData.getMultByProp(weaponProperty.getType())); this.addFightProperty(
weaponProperty.getPropType(),
weaponProperty.getInitValue() * curveData.getMultByProp(weaponProperty.getType()));
} }
} }
// Weapon promotion stats // Weapon promotion stats
WeaponPromoteData wepPromoteData = GameData.getWeaponPromoteData(weapon.getItemData().getWeaponPromoteId(), weapon.getPromoteLevel()); WeaponPromoteData wepPromoteData =
GameData.getWeaponPromoteData(
weapon.getItemData().getWeaponPromoteId(), weapon.getPromoteLevel());
if (wepPromoteData != null) { if (wepPromoteData != null) {
for (FightPropData prop : wepPromoteData.getAddProps()) { for (FightPropData prop : wepPromoteData.getAddProps()) {
if (prop.getValue() == 0f || prop.getProp() == null) { if (prop.getValue() == 0f || prop.getProp() == null) {
@ -692,7 +681,8 @@ public class Avatar {
} }
// Add proud skills and unlock them if needed // Add proud skills and unlock them if needed
AvatarSkillDepotData skillDepot = GameData.getAvatarSkillDepotDataMap().get(this.getSkillDepotId()); AvatarSkillDepotData skillDepot =
GameData.getAvatarSkillDepotDataMap().get(this.getSkillDepotId());
this.getProudSkillList().clear(); this.getProudSkillList().clear();
if (skillDepot != null) { if (skillDepot != null) {
for (InherentProudSkillOpens openData : skillDepot.getInherentProudSkillOpens()) { for (InherentProudSkillOpens openData : skillDepot.getInherentProudSkillOpens()) {
@ -725,17 +715,31 @@ public class Avatar {
} }
// Constellations // Constellations
this.getTalentIdList().intStream().mapToObj(GameData.getAvatarTalentDataMap()::get).filter(Objects::nonNull).map(AvatarTalentData::getOpenConfig).filter(Objects::nonNull).forEach(this::addToExtraAbilityEmbryos); this.getTalentIdList()
.intStream()
.mapToObj(GameData.getAvatarTalentDataMap()::get)
.filter(Objects::nonNull)
.map(AvatarTalentData::getOpenConfig)
.filter(Objects::nonNull)
.forEach(this::addToExtraAbilityEmbryos);
// Add any skill strings from this constellation // Add any skill strings from this constellation
// Set % stats // Set % stats
FightProperty.forEachCompoundProperty(c -> this.setFightProperty(c.getResult(), this.getFightProperty(c.getFlat()) + (this.getFightProperty(c.getBase()) * (1f + this.getFightProperty(c.getPercent()))))); FightProperty.forEachCompoundProperty(
c ->
this.setFightProperty(
c.getResult(),
this.getFightProperty(c.getFlat())
+ (this.getFightProperty(c.getBase())
* (1f + this.getFightProperty(c.getPercent())))));
// Reapply all overrides // Reapply all overrides
this.fightProperties.putAll(this.fightPropOverrides); this.fightProperties.putAll(this.fightPropOverrides);
// Set current hp // Set current hp
this.setFightProperty(FightProperty.FIGHT_PROP_CUR_HP, this.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP) * hpPercent); this.setFightProperty(
FightProperty.FIGHT_PROP_CUR_HP,
this.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP) * hpPercent);
// Packet // Packet
if (getPlayer() != null && getPlayer().hasSentLoginPackets()) { if (getPlayer() != null && getPlayer().hasSentLoginPackets()) {
@ -743,7 +747,9 @@ public class Avatar {
getPlayer().sendPacket(new PacketAvatarFightPropNotify(this)); getPlayer().sendPacket(new PacketAvatarFightPropNotify(this));
// Update client abilities // Update client abilities
EntityAvatar entity = this.getAsEntity(); EntityAvatar entity = this.getAsEntity();
if (entity != null && (!this.getExtraAbilityEmbryos().equals(prevExtraAbilityEmbryos) || forceSendAbilityChange)) { if (entity != null
&& (!this.getExtraAbilityEmbryos().equals(prevExtraAbilityEmbryos)
|| forceSendAbilityChange)) {
getPlayer().sendPacket(new PacketAbilityChangeNotify(entity)); getPlayer().sendPacket(new PacketAbilityChangeNotify(entity));
} }
} }
@ -781,12 +787,22 @@ public class Avatar {
// Check if new constellation adds +3 to a skill level // Check if new constellation adds +3 to a skill level
if (this.calcConstellationExtraLevels(entry) && notifyClient) { if (this.calcConstellationExtraLevels(entry) && notifyClient) {
// Packet // Packet
this.getPlayer().sendPacket(new PacketProudSkillExtraLevelNotify(this, entry.getExtraTalentIndex())); this.getPlayer()
.sendPacket(new PacketProudSkillExtraLevelNotify(this, entry.getExtraTalentIndex()));
} }
// Check if new constellation adds skill charges // Check if new constellation adds skill charges
if (this.calcConstellationExtraCharges(entry) && notifyClient) { if (this.calcConstellationExtraCharges(entry) && notifyClient) {
// Packet // Packet
Stream.of(entry.getSkillPointModifiers()).mapToInt(SkillPointModifier::getSkillId).forEach(skillId -> this.getPlayer().sendPacket(new PacketAvatarSkillMaxChargeCountNotify(this, skillId, this.getSkillExtraChargeMap().getOrDefault(skillId, 0)))); Stream.of(entry.getSkillPointModifiers())
.mapToInt(SkillPointModifier::getSkillId)
.forEach(
skillId ->
this.getPlayer()
.sendPacket(
new PacketAvatarSkillMaxChargeCountNotify(
this,
skillId,
this.getSkillExtraChargeMap().getOrDefault(skillId, 0))));
} }
} }
@ -800,7 +816,16 @@ public class Avatar {
return; return;
} }
this.getTalentIdList().intStream().mapToObj(GameData.getAvatarTalentDataMap()::get).filter(Objects::nonNull).map(AvatarTalentData::getOpenConfig).filter(Objects::nonNull).filter(openConfig -> !openConfig.isEmpty()).map(GameData.getOpenConfigEntries()::get).filter(Objects::nonNull).forEach(e -> this.calcConstellation(e, false)); this.getTalentIdList()
.intStream()
.mapToObj(GameData.getAvatarTalentDataMap()::get)
.filter(Objects::nonNull)
.map(AvatarTalentData::getOpenConfig)
.filter(Objects::nonNull)
.filter(openConfig -> !openConfig.isEmpty())
.map(GameData.getOpenConfigEntries()::get)
.filter(Objects::nonNull)
.forEach(e -> this.calcConstellation(e, false));
} }
private boolean calcConstellationExtraCharges(OpenConfigEntry entry) { private boolean calcConstellationExtraCharges(OpenConfigEntry entry) {
@ -820,14 +845,18 @@ public class Avatar {
} }
private boolean calcConstellationExtraLevels(OpenConfigEntry entry) { private boolean calcConstellationExtraLevels(OpenConfigEntry entry) {
if(this.skillDepot == null) return false; if (this.skillDepot == null) return false;
int skillId = switch (entry.getExtraTalentIndex()) { int skillId =
case 9 -> this.skillDepot.getEnergySkill(); // Ult skill switch (entry.getExtraTalentIndex()) {
case 2 -> (this.skillDepot.getSkills().size() >= 2) ? this.skillDepot.getSkills().get(1) : 0; // E skill case 9 -> this.skillDepot.getEnergySkill(); // Ult skill
case 1 -> case 2 -> (this.skillDepot.getSkills().size() >= 2)
(!this.skillDepot.getSkills().isEmpty()) ? this.skillDepot.getSkills().get(0) : 0; // Normal Attack (Liney) ? this.skillDepot.getSkills().get(1)
default -> 0; : 0; // E skill
}; case 1 -> (!this.skillDepot.getSkills().isEmpty())
? this.skillDepot.getSkills().get(0)
: 0; // Normal Attack (Liney)
default -> 0;
};
// Sanity check // Sanity check
if (skillId == 0) { if (skillId == 0) {
return false; return false;
@ -846,7 +875,8 @@ public class Avatar {
} }
private int addProudSkillLevelBonus(int proudSkillGroupId, int bonus) { private int addProudSkillLevelBonus(int proudSkillGroupId, int bonus) {
return this.proudSkillBonusMap.compute(proudSkillGroupId, (k, v) -> (v == null) ? bonus : v + bonus); return this.proudSkillBonusMap.compute(
proudSkillGroupId, (k, v) -> (v == null) ? bonus : v + bonus);
} }
public boolean upgradeSkill(int skillId) { public boolean upgradeSkill(int skillId) {
@ -877,7 +907,9 @@ public class Avatar {
if (level < 0 || level > 15) return false; if (level < 0 || level > 15) return false;
var validLevels = GameData.getAvatarSkillLevels(skillId); var validLevels = GameData.getAvatarSkillLevels(skillId);
if (validLevels != null && !validLevels.contains(level)) return false; if (validLevels != null && !validLevels.contains(level)) return false;
int oldLevel = this.skillLevelMap.getOrDefault(skillId, 0); // just taking the return value of put would have null concerns int oldLevel =
this.skillLevelMap.getOrDefault(
skillId, 0); // just taking the return value of put would have null concerns
this.skillLevelMap.put(skillId, level); this.skillLevelMap.put(skillId, level);
this.save(); this.save();
@ -912,7 +944,9 @@ public class Avatar {
var player = this.getPlayer(); var player = this.getPlayer();
// Pay constellation item if possible // Pay constellation item if possible
if (!skipPayment && (player != null) && !player.getInventory().payItem(talentData.getMainCostItemId(), 1)) { if (!skipPayment
&& (player != null)
&& !player.getInventory().payItem(talentData.getMainCostItemId(), 1)) {
return false; return false;
} }
@ -943,7 +977,8 @@ public class Avatar {
this.save(); this.save();
return; return;
} }
this.talentIdList.removeAll(this.getTalentIdList()); // Only remove constellations from active depot this.talentIdList.removeAll(
this.getTalentIdList()); // Only remove constellations from active depot
for (int i = 0; i < level; i++) this.unlockConstellation(true); for (int i = 0; i < level; i++) this.unlockConstellation(true);
this.recalcStats(); this.recalcStats();
this.save(); this.save();
@ -952,7 +987,12 @@ public class Avatar {
public boolean sendSkillExtraChargeMap() { public boolean sendSkillExtraChargeMap() {
val map = this.getSkillExtraChargeMap(); val map = this.getSkillExtraChargeMap();
if (map.isEmpty()) return false; if (map.isEmpty()) return false;
this.getPlayer().sendPacket(new PacketAvatarSkillInfoNotify(this.guid, new Int2IntArrayMap(map))); // TODO: Remove this allocation when updating interfaces to FastUtils this.getPlayer()
.sendPacket(
new PacketAvatarSkillInfoNotify(
this.guid,
new Int2IntArrayMap(
map))); // TODO: Remove this allocation when updating interfaces to FastUtils
// later // later
return true; return true;
} }
@ -984,7 +1024,12 @@ public class Avatar {
} }
if (this.fetters != null) { if (this.fetters != null) {
this.fetters.forEach(fetterId -> avatarFetter.addFetterList(FetterData.newBuilder().setFetterId(fetterId).setFetterState(FetterState.FINISH.getValue()))); this.fetters.forEach(
fetterId ->
avatarFetter.addFetterList(
FetterData.newBuilder()
.setFetterId(fetterId)
.setFetterState(FetterState.FINISH.getValue())));
} }
int cardId = this.getNameCardId(); int cardId = this.getNameCardId();
@ -993,40 +1038,100 @@ public class Avatar {
avatarFetter.addRewardedFetterLevelList(10); avatarFetter.addRewardedFetterLevelList(10);
} }
AvatarInfo.Builder avatarInfo = AvatarInfo.newBuilder().setAvatarId(this.getAvatarId()).setGuid(this.getGuid()).setLifeState(1).addAllTalentIdList(this.getTalentIdList()).putAllFightPropMap(this.getFightProperties()).setSkillDepotId(this.getSkillDepotId()).setCoreProudSkillLevel(this.getCoreProudSkillLevel()).putAllSkillLevelMap(this.getSkillLevelMap()).addAllInherentProudSkillList(this.getProudSkillList()).putAllProudSkillExtraLevelMap(this.getProudSkillBonusMap()).setAvatarType(this.getAvatarType()).setBornTime(this.getBornTime()).setFetterInfo(avatarFetter).setWearingFlycloakId(this.getFlyCloak()).setCostumeId(this.getCostume()); AvatarInfo.Builder avatarInfo =
AvatarInfo.newBuilder()
.setAvatarId(this.getAvatarId())
.setGuid(this.getGuid())
.setLifeState(1)
.addAllTalentIdList(this.getTalentIdList())
.putAllFightPropMap(this.getFightProperties())
.setSkillDepotId(this.getSkillDepotId())
.setCoreProudSkillLevel(this.getCoreProudSkillLevel())
.putAllSkillLevelMap(this.getSkillLevelMap())
.addAllInherentProudSkillList(this.getProudSkillList())
.putAllProudSkillExtraLevelMap(this.getProudSkillBonusMap())
.setAvatarType(this.getAvatarType())
.setBornTime(this.getBornTime())
.setFetterInfo(avatarFetter)
.setWearingFlycloakId(this.getFlyCloak())
.setCostumeId(this.getCostume());
this.getSkillExtraChargeMap().forEach((skillId, count) -> avatarInfo.putSkillMap(skillId, AvatarSkillInfo.newBuilder().setMaxChargeCount(count).build())); this.getSkillExtraChargeMap()
.forEach(
(skillId, count) ->
avatarInfo.putSkillMap(
skillId, AvatarSkillInfo.newBuilder().setMaxChargeCount(count).build()));
this.getEquips().forEach((k, item) -> avatarInfo.addEquipGuidList(item.getGuid())); this.getEquips().forEach((k, item) -> avatarInfo.addEquipGuidList(item.getGuid()));
avatarInfo.putPropMap(PlayerProperty.PROP_LEVEL.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_LEVEL, this.getLevel())); avatarInfo.putPropMap(
avatarInfo.putPropMap(PlayerProperty.PROP_EXP.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_EXP, this.getExp())); PlayerProperty.PROP_LEVEL.getId(),
avatarInfo.putPropMap(PlayerProperty.PROP_BREAK_LEVEL.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_BREAK_LEVEL, this.getPromoteLevel())); ProtoHelper.newPropValue(PlayerProperty.PROP_LEVEL, this.getLevel()));
avatarInfo.putPropMap(PlayerProperty.PROP_SATIATION_VAL.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_SATIATION_VAL, this.getSatiation())); avatarInfo.putPropMap(
avatarInfo.putPropMap(PlayerProperty.PROP_SATIATION_PENALTY_TIME.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_SATIATION_PENALTY_TIME, this.getSatiationPenalty())); PlayerProperty.PROP_EXP.getId(),
ProtoHelper.newPropValue(PlayerProperty.PROP_EXP, this.getExp()));
avatarInfo.putPropMap(
PlayerProperty.PROP_BREAK_LEVEL.getId(),
ProtoHelper.newPropValue(PlayerProperty.PROP_BREAK_LEVEL, this.getPromoteLevel()));
avatarInfo.putPropMap(
PlayerProperty.PROP_SATIATION_VAL.getId(),
ProtoHelper.newPropValue(PlayerProperty.PROP_SATIATION_VAL, this.getSatiation()));
avatarInfo.putPropMap(
PlayerProperty.PROP_SATIATION_PENALTY_TIME.getId(),
ProtoHelper.newPropValue(
PlayerProperty.PROP_SATIATION_PENALTY_TIME, this.getSatiationPenalty()));
return avatarInfo.build(); return avatarInfo.build();
} }
// used only in character showcase // used only in character showcase
public ShowAvatarInfo toShowAvatarInfoProto() { public ShowAvatarInfo toShowAvatarInfoProto() {
AvatarFetterInfo.Builder avatarFetter = AvatarFetterInfo.newBuilder().setExpLevel(this.getFetterLevel()); AvatarFetterInfo.Builder avatarFetter =
AvatarFetterInfo.newBuilder().setExpLevel(this.getFetterLevel());
ShowAvatarInfo.Builder showAvatarInfo = ShowAvatarInfoOuterClass.ShowAvatarInfo.newBuilder().setAvatarId(avatarId).addAllTalentIdList(this.getTalentIdList()).putAllFightPropMap(this.getFightProperties()).setSkillDepotId(this.getSkillDepotId()).setCoreProudSkillLevel(this.getCoreProudSkillLevel()).addAllInherentProudSkillList(this.getProudSkillList()).putAllSkillLevelMap(this.getSkillLevelMap()).putAllProudSkillExtraLevelMap(this.getProudSkillBonusMap()).setFetterInfo(avatarFetter).setCostumeId(this.getCostume()); ShowAvatarInfo.Builder showAvatarInfo =
ShowAvatarInfoOuterClass.ShowAvatarInfo.newBuilder()
.setAvatarId(avatarId)
.addAllTalentIdList(this.getTalentIdList())
.putAllFightPropMap(this.getFightProperties())
.setSkillDepotId(this.getSkillDepotId())
.setCoreProudSkillLevel(this.getCoreProudSkillLevel())
.addAllInherentProudSkillList(this.getProudSkillList())
.putAllSkillLevelMap(this.getSkillLevelMap())
.putAllProudSkillExtraLevelMap(this.getProudSkillBonusMap())
.setFetterInfo(avatarFetter)
.setCostumeId(this.getCostume());
showAvatarInfo.putPropMap(PlayerProperty.PROP_LEVEL.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_LEVEL, this.getLevel())); showAvatarInfo.putPropMap(
showAvatarInfo.putPropMap(PlayerProperty.PROP_EXP.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_EXP, this.getExp())); PlayerProperty.PROP_LEVEL.getId(),
showAvatarInfo.putPropMap(PlayerProperty.PROP_BREAK_LEVEL.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_BREAK_LEVEL, this.getPromoteLevel())); ProtoHelper.newPropValue(PlayerProperty.PROP_LEVEL, this.getLevel()));
showAvatarInfo.putPropMap(PlayerProperty.PROP_SATIATION_VAL.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_SATIATION_VAL, this.getSatiation())); showAvatarInfo.putPropMap(
showAvatarInfo.putPropMap(PlayerProperty.PROP_SATIATION_PENALTY_TIME.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_SATIATION_PENALTY_TIME, this.getSatiationPenalty())); PlayerProperty.PROP_EXP.getId(),
ProtoHelper.newPropValue(PlayerProperty.PROP_EXP, this.getExp()));
showAvatarInfo.putPropMap(
PlayerProperty.PROP_BREAK_LEVEL.getId(),
ProtoHelper.newPropValue(PlayerProperty.PROP_BREAK_LEVEL, this.getPromoteLevel()));
showAvatarInfo.putPropMap(
PlayerProperty.PROP_SATIATION_VAL.getId(),
ProtoHelper.newPropValue(PlayerProperty.PROP_SATIATION_VAL, this.getSatiation()));
showAvatarInfo.putPropMap(
PlayerProperty.PROP_SATIATION_PENALTY_TIME.getId(),
ProtoHelper.newPropValue(
PlayerProperty.PROP_SATIATION_PENALTY_TIME, this.getSatiationPenalty()));
int maxStamina = this.getPlayer().getProperty(PlayerProperty.PROP_MAX_STAMINA); int maxStamina = this.getPlayer().getProperty(PlayerProperty.PROP_MAX_STAMINA);
showAvatarInfo.putPropMap(PlayerProperty.PROP_MAX_STAMINA.getId(), ProtoHelper.newPropValue(PlayerProperty.PROP_MAX_STAMINA, maxStamina)); showAvatarInfo.putPropMap(
PlayerProperty.PROP_MAX_STAMINA.getId(),
ProtoHelper.newPropValue(PlayerProperty.PROP_MAX_STAMINA, maxStamina));
for (GameItem item : this.getEquips().values()) { for (GameItem item : this.getEquips().values()) {
if (item.getItemType() == ItemType.ITEM_RELIQUARY) { if (item.getItemType() == ItemType.ITEM_RELIQUARY) {
showAvatarInfo.addEquipList(ShowEquip.newBuilder().setItemId(item.getItemId()).setReliquary(item.toReliquaryProto())); showAvatarInfo.addEquipList(
ShowEquip.newBuilder()
.setItemId(item.getItemId())
.setReliquary(item.toReliquaryProto()));
} else if (item.getItemType() == ItemType.ITEM_WEAPON) { } else if (item.getItemType() == ItemType.ITEM_WEAPON) {
showAvatarInfo.addEquipList(ShowEquip.newBuilder().setItemId(item.getItemId()).setWeapon(item.toWeaponProto())); showAvatarInfo.addEquipList(
ShowEquip.newBuilder().setItemId(item.getItemId()).setWeapon(item.toWeaponProto()));
} }
} }
@ -1036,12 +1141,13 @@ public class Avatar {
/** /**
* Converts this avatar into a trial avatar. * Converts this avatar into a trial avatar.
* *
* @param level The avatar's level. * @param level The avatar's level.
* @param avatarId The ID of the avatar. * @param avatarId The ID of the avatar.
* @param grantReason The reason for granting the avatar. * @param grantReason The reason for granting the avatar.
* @param questId The ID of the quest that granted the avatar. * @param questId The ID of the quest that granted the avatar.
*/ */
public void setTrialAvatarInfo(int level, int avatarId, TrialAvatarGrantRecord.GrantReason grantReason, int questId) { public void setTrialAvatarInfo(
int level, int avatarId, TrialAvatarGrantRecord.GrantReason grantReason, int questId) {
this.setLevel(level); this.setLevel(level);
this.setPromoteLevel(getMinPromoteLevel(level)); this.setPromoteLevel(getMinPromoteLevel(level));
this.setTrialAvatarId(avatarId); this.setTrialAvatarId(avatarId);
@ -1058,7 +1164,10 @@ public class Avatar {
* @return The avatar's template. * @return The avatar's template.
*/ */
private int getTrialTemplate() { private int getTrialTemplate() {
return this.getLevel() <= 9 ? 1 : (int) (Math.floor(this.getLevel() / 10f) * 10); // round trial level to fit template levels return this.getLevel() <= 9
? 1
: (int)
(Math.floor(this.getLevel() / 10f) * 10); // round trial level to fit template levels
} }
/** /**
@ -1080,11 +1189,11 @@ public class Avatar {
return trialData.getCoreProudSkillLevel(); // enhanced version of weapon return trialData.getCoreProudSkillLevel(); // enhanced version of weapon
} }
/** /** Applies the correct skill level for the trial avatar. */
* Applies the correct skill level for the trial avatar.
*/
public void applyTrialSkillLevels() { public void applyTrialSkillLevels() {
this.getSkillLevelMap().keySet().forEach(skill -> this.setSkillLevel(skill, this.getTrialSkillLevel())); this.getSkillLevelMap()
.keySet()
.forEach(skill -> this.setSkillLevel(skill, this.getTrialSkillLevel()));
} }
/** /**
@ -1096,7 +1205,9 @@ public class Avatar {
if (GameData.getTrialAvatarDataMap().get(this.getTrialAvatarId()) == null) if (GameData.getTrialAvatarDataMap().get(this.getTrialAvatarId()) == null)
return this.getAvatarData().getInitialWeapon(); return this.getAvatarData().getInitialWeapon();
return GameData.getItemDataMap().get(this.getAvatarData().getInitialWeapon() + 100) == null ? getAvatarData().getInitialWeapon() : getAvatarData().getInitialWeapon() + 100; // enhanced version of weapon return GameData.getItemDataMap().get(this.getAvatarData().getInitialWeapon() + 100) == null
? getAvatarData().getInitialWeapon()
: getAvatarData().getInitialWeapon() + 100; // enhanced version of weapon
} }
// Use custom data. // Use custom data.
@ -1104,7 +1215,9 @@ public class Avatar {
if (trialData == null) return 0; if (trialData == null) return 0;
var trialCustomParams = trialData.getTrialAvatarParamList(); var trialCustomParams = trialData.getTrialAvatarParamList();
return trialCustomParams.size() < 2 ? getAvatarData().getInitialWeapon() : Integer.parseInt(trialCustomParams.get(1).split(";")[0]); return trialCustomParams.size() < 2
? getAvatarData().getInitialWeapon()
: Integer.parseInt(trialCustomParams.get(1).split(";")[0]);
} }
/** /**
@ -1115,7 +1228,8 @@ public class Avatar {
if (GameData.getTrialAvatarCustomData().isEmpty()) { if (GameData.getTrialAvatarCustomData().isEmpty()) {
int trialAvatarTemplateLevel = getTrialTemplate(); int trialAvatarTemplateLevel = getTrialTemplate();
TrialAvatarTemplateData templateData = GameData.getTrialAvatarTemplateDataMap().get(trialAvatarTemplateLevel); TrialAvatarTemplateData templateData =
GameData.getTrialAvatarTemplateDataMap().get(trialAvatarTemplateLevel);
return templateData == null ? List.of() : templateData.getTrialReliquaryList(); return templateData == null ? List.of() : templateData.getTrialReliquaryList();
} }
@ -1123,13 +1237,14 @@ public class Avatar {
var trialData = GameData.getTrialAvatarCustomData().get(this.getTrialAvatarId()); var trialData = GameData.getTrialAvatarCustomData().get(this.getTrialAvatarId());
if (trialData == null) return List.of(); if (trialData == null) return List.of();
var trialCustomParams = GameData.getTrialAvatarCustomData().get(getTrialAvatarId()).getTrialAvatarParamList(); var trialCustomParams =
return trialCustomParams.size() < 3 ? List.of() : Stream.of(trialCustomParams.get(2).split(";")).map(Integer::parseInt).toList(); GameData.getTrialAvatarCustomData().get(getTrialAvatarId()).getTrialAvatarParamList();
return trialCustomParams.size() < 3
? List.of()
: Stream.of(trialCustomParams.get(2).split(";")).map(Integer::parseInt).toList();
} }
/** /** Applies the correct items for the trial avatar. */
* Applies the correct items for the trial avatar.
*/
public void applyTrialItems() { public void applyTrialItems() {
// Use an enhanced version of the weapon if available. // Use an enhanced version of the weapon if available.
var weapon = new GameItem(this.getTrialWeaponId()); var weapon = new GameItem(this.getTrialWeaponId());
@ -1139,44 +1254,55 @@ public class Avatar {
this.getEquips().put(weapon.getEquipSlot(), weapon); this.getEquips().put(weapon.getEquipSlot(), weapon);
// Add artifacts for the trial avatar. // Add artifacts for the trial avatar.
this.getTrialReliquary().forEach(id -> { this.getTrialReliquary()
var reliquaryData = GameData.getTrialReliquaryDataMap().get((int) id); .forEach(
if (reliquaryData == null) return; id -> {
var reliquaryData = GameData.getTrialReliquaryDataMap().get((int) id);
if (reliquaryData == null) return;
var relic = new GameItem(reliquaryData.getReliquaryId()); var relic = new GameItem(reliquaryData.getReliquaryId());
relic.setLevel(reliquaryData.getLevel()); relic.setLevel(reliquaryData.getLevel());
relic.setMainPropId(reliquaryData.getMainPropId()); relic.setMainPropId(reliquaryData.getMainPropId());
relic.getAppendPropIdList().addAll(reliquaryData.getAppendPropList()); relic.getAppendPropIdList().addAll(reliquaryData.getAppendPropList());
this.getEquips().put(relic.getEquipSlot(), relic); this.getEquips().put(relic.getEquipSlot(), relic);
}); });
// Add costume if avatar has a costume. // Add costume if avatar has a costume.
if (GAME_OPTIONS.trialCostumes) { if (GAME_OPTIONS.trialCostumes) {
GameData.getAvatarCostumeDataItemIdMap().values().forEach(costumeData -> { GameData.getAvatarCostumeDataItemIdMap()
if (costumeData.getCharacterId() != this.getAvatarId()) return; .values()
this.setCostume(costumeData.getId()); .forEach(
}); costumeData -> {
if (costumeData.getCharacterId() != this.getAvatarId()) return;
this.setCostume(costumeData.getId());
});
} }
} }
/** /** Equips the items applied from {@link Avatar#applyTrialItems()}. */
* Equips the items applied from {@link Avatar#applyTrialItems()}.
*/
public void equipTrialItems() { public void equipTrialItems() {
var player = this.getPlayer(); var player = this.getPlayer();
this.getEquips().values().forEach(item -> { this.getEquips()
item.setEquipCharacter(this.getAvatarId()); .values()
item.setOwner(player); .forEach(
if (item.getItemData().getEquipType() == EquipType.EQUIP_WEAPON) { item -> {
if (!(item.getWeaponEntity() != null && item.getWeaponEntity().getScene() == player.getScene())) { item.setEquipCharacter(this.getAvatarId());
item.setWeaponEntity(new EntityWeapon(player.getScene(), item.getItemData().getGadgetId())); item.setOwner(player);
player.getScene().getWeaponEntities().put(item.getWeaponEntity().getId(), item.getWeaponEntity()); if (item.getItemData().getEquipType() == EquipType.EQUIP_WEAPON) {
} if (!(item.getWeaponEntity() != null
&& item.getWeaponEntity().getScene() == player.getScene())) {
item.setWeaponEntity(
new EntityWeapon(player.getScene(), item.getItemData().getGadgetId()));
player
.getScene()
.getWeaponEntities()
.put(item.getWeaponEntity().getId(), item.getWeaponEntity());
}
player.sendPacket(new PacketAvatarEquipChangeNotify(this, item)); player.sendPacket(new PacketAvatarEquipChangeNotify(this, item));
} }
}); });
} }
/** /**
@ -1185,20 +1311,26 @@ public class Avatar {
* @return The trial info protocol buffer. * @return The trial info protocol buffer.
*/ */
public TrialAvatarInfo toTrialInfo() { public TrialAvatarInfo toTrialInfo() {
var trialAvatar = TrialAvatarInfo.newBuilder().setTrialAvatarId(this.getTrialAvatarId()).setGrantRecord(TrialAvatarGrantRecord.newBuilder().setGrantReason(this.getGrantReason()).setFromParentQuestId(this.getFromParentQuestId())); var trialAvatar =
TrialAvatarInfo.newBuilder()
.setTrialAvatarId(this.getTrialAvatarId())
.setGrantRecord(
TrialAvatarGrantRecord.newBuilder()
.setGrantReason(this.getGrantReason())
.setFromParentQuestId(this.getFromParentQuestId()));
// Check if the avatar is a trial avatar. // Check if the avatar is a trial avatar.
if (this.getTrialAvatarId() > 0) { if (this.getTrialAvatarId() > 0) {
// Add the artifacts and weapons for the avatar. // Add the artifacts and weapons for the avatar.
trialAvatar.addAllTrialEquipList(this.getEquips().values().stream().map(GameItem::toProto).toList()); trialAvatar.addAllTrialEquipList(
this.getEquips().values().stream().map(GameItem::toProto).toList());
} }
return trialAvatar.build(); return trialAvatar.build();
} }
@PostLoad @PostLoad
private void onLoad() { private void onLoad() {}
}
@PrePersist @PrePersist
private void prePersist() { private void prePersist() {
@ -1208,7 +1340,8 @@ public class Avatar {
@AllArgsConstructor @AllArgsConstructor
@Getter @Getter
enum Type { enum Type {
NORMAL(1), TRIAL(2); NORMAL(1),
TRIAL(2);
final int number; final int number;
} }

View File

@ -15,14 +15,12 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import lombok.Getter;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import lombok.Getter;
public class AvatarStorage extends BasePlayerManager implements Iterable<Avatar> { public class AvatarStorage extends BasePlayerManager implements Iterable<Avatar> {
@Getter @Getter private final Int2ObjectMap<Avatar> avatars;
private final Int2ObjectMap<Avatar> avatars;
private final Long2ObjectMap<Avatar> avatarsGuid; private final Long2ObjectMap<Avatar> avatarsGuid;
public AvatarStorage(Player player) { public AvatarStorage(Player player) {

View File

@ -9,13 +9,9 @@ import lombok.Setter;
@Entity @Entity
public class BattlePassMission { public class BattlePassMission {
@Getter @Getter private int id;
private int id; @Setter @Getter private int progress;
@Setter @Setter private BattlePassMissionStatus status;
@Getter
private int progress;
@Setter
private BattlePassMissionStatus status;
@Transient private BattlePassMissionData data; @Transient private BattlePassMissionData data;

View File

@ -8,12 +8,9 @@ import lombok.Getter;
@Entity @Entity
public class BattlePassReward { public class BattlePassReward {
@Getter @Getter private int level;
private int level; @Getter private int rewardId;
@Getter @Getter private boolean paid;
private int rewardId;
@Getter
private boolean paid;
@Transient private BattlePassMissionData data; @Transient private BattlePassMissionData data;

View File

@ -10,10 +10,9 @@ import emu.grasscutter.server.event.player.PlayerChatEvent;
import emu.grasscutter.server.game.GameServer; import emu.grasscutter.server.game.GameServer;
import emu.grasscutter.server.packet.send.*; import emu.grasscutter.server.packet.send.*;
import emu.grasscutter.utils.Utils; import emu.grasscutter.utils.Utils;
import lombok.Getter;
import java.util.*; import java.util.*;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import lombok.Getter;
public class ChatSystem implements ChatSystemHandler { public class ChatSystem implements ChatSystemHandler {
static final String PREFIXES = "[/!]"; static final String PREFIXES = "[/!]";
@ -24,8 +23,7 @@ public class ChatSystem implements ChatSystemHandler {
// user id -> chat partner id -> [messages] // user id -> chat partner id -> [messages]
private final Map<Integer, Map<Integer, List<ChatInfo>>> history = new HashMap<>(); private final Map<Integer, Map<Integer, List<ChatInfo>>> history = new HashMap<>();
@Getter @Getter private final GameServer server;
private final GameServer server;
public ChatSystem(GameServer server) { public ChatSystem(GameServer server) {
this.server = server; this.server = server;

View File

@ -27,8 +27,7 @@ public class CombineManger extends BaseGameSystem {
// Read the data we need for strongbox. // Read the data we need for strongbox.
try { try {
DataLoader.loadList("ReliquaryDecompose.json", ReliquaryDecomposeEntry.class) DataLoader.loadList("ReliquaryDecompose.json", ReliquaryDecomposeEntry.class)
.forEach( .forEach(entry -> reliquaryDecomposeData.put(entry.getConfigId(), entry.getItems()));
entry -> reliquaryDecomposeData.put(entry.getConfigId(), entry.getItems()));
Grasscutter.getLogger() Grasscutter.getLogger()
.debug("Loaded {} reliquary decompose entries.", reliquaryDecomposeData.size()); .debug("Loaded {} reliquary decompose entries.", reliquaryDecomposeData.size());
} catch (Exception ex) { } catch (Exception ex) {

View File

@ -1,11 +1,10 @@
package emu.grasscutter.game.combine; package emu.grasscutter.game.combine;
import emu.grasscutter.data.common.ItemParamData; import emu.grasscutter.data.common.ItemParamData;
import java.util.List;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.util.List;
@Setter @Setter
@Getter @Getter
public class CombineResult { public class CombineResult {
@ -13,5 +12,4 @@ public class CombineResult {
private List<ItemParamData> result; private List<ItemParamData> result;
private List<ItemParamData> extra; private List<ItemParamData> extra;
private List<ItemParamData> back; private List<ItemParamData> back;
} }

View File

@ -1,14 +1,12 @@
package emu.grasscutter.game.combine; package emu.grasscutter.game.combine;
import java.util.List;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.util.List;
@Setter @Setter
@Getter @Getter
public class ReliquaryDecomposeEntry { public class ReliquaryDecomposeEntry {
private int configId; private int configId;
private List<Integer> items; private List<Integer> items;
} }

View File

@ -8,13 +8,11 @@ import lombok.Setter;
public class DropData { public class DropData {
private int minWeight; private int minWeight;
private int maxWeight; private int maxWeight;
@Setter @Setter private int itemId;
private int itemId;
private int minCount; private int minCount;
private int maxCount; private int maxCount;
private boolean share = false; private boolean share = false;
@Setter @Setter private boolean give = false;
private boolean give = false;
public void setIsShare(boolean share) { public void setIsShare(boolean share) {
this.share = share; this.share = share;

View File

@ -1,13 +1,11 @@
package emu.grasscutter.game.drop; package emu.grasscutter.game.drop;
import lombok.Getter;
import java.util.List; import java.util.List;
import lombok.Getter;
@Getter @Getter
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class DropInfo { public class DropInfo {
private int monsterId; private int monsterId;
private List<DropData> dropDataList; private List<DropData> dropDataList;
} }

View File

@ -11,9 +11,8 @@ import emu.grasscutter.game.world.*;
import emu.grasscutter.server.game.*; import emu.grasscutter.server.game.*;
import emu.grasscutter.utils.Utils; import emu.grasscutter.utils.Utils;
import it.unimi.dsi.fastutil.ints.*; import it.unimi.dsi.fastutil.ints.*;
import lombok.Getter;
import java.util.List; import java.util.List;
import lombok.Getter;
@Getter @Getter
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")

View File

@ -1,14 +1,12 @@
package emu.grasscutter.game.dungeons; package emu.grasscutter.game.dungeons;
import java.util.List;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.util.List;
@Setter @Setter
@Getter @Getter
public class DungeonDrop { public class DungeonDrop {
private int dungeonId; private int dungeonId;
private List<DungeonDropEntry> drops; private List<DungeonDropEntry> drops;
} }

View File

@ -1,10 +1,9 @@
package emu.grasscutter.game.dungeons; package emu.grasscutter.game.dungeons;
import java.util.List;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.util.List;
@Setter @Setter
@Getter @Getter
public class DungeonDropEntry { public class DungeonDropEntry {
@ -13,5 +12,4 @@ public class DungeonDropEntry {
private List<Integer> probabilities; private List<Integer> probabilities;
private List<Integer> itemProbabilities; private List<Integer> itemProbabilities;
private boolean mpDouble; private boolean mpDouble;
} }

View File

@ -29,7 +29,8 @@ public class KillMonsterTimeChallengeFactoryHandler implements ChallengeFactoryH
Scene scene, Scene scene,
SceneGroup group) { SceneGroup group) {
val realGroup = scene.getScriptManager().getGroupById(groupId); val realGroup = scene.getScriptManager().getGroupById(groupId);
val challengeTriggers = new ArrayList<>(List.of(new KillMonsterCountTrigger(), new InTimeTrigger())); val challengeTriggers =
new ArrayList<>(List.of(new KillMonsterCountTrigger(), new InTimeTrigger()));
val challengeData = GameData.getDungeonChallengeConfigDataMap().get(challengeId); val challengeData = GameData.getDungeonChallengeConfigDataMap().get(challengeId);
val challengeType = challengeData.getChallengeType(); val challengeType = challengeData.getChallengeType();

View File

@ -82,7 +82,7 @@ public class EntityRegion extends GameEntity {
@Override @Override
public SceneEntityInfoOuterClass.SceneEntityInfo toProto() { public SceneEntityInfoOuterClass.SceneEntityInfo toProto() {
/* The Region Entity would not be sent to client. */ /* The Region Entity would not be sent to client. */
return null; return null;
} }

View File

@ -19,8 +19,7 @@ import emu.grasscutter.utils.Utils;
import lombok.Getter; import lombok.Getter;
public final class GadgetGatherObject extends GadgetContent { public final class GadgetGatherObject extends GadgetContent {
@Getter @Getter private int itemId;
private int itemId;
private boolean isForbidGuest; private boolean isForbidGuest;
public GadgetGatherObject(EntityGadget gadget) { public GadgetGatherObject(EntityGadget gadget) {

View File

@ -15,19 +15,12 @@ import org.bson.types.ObjectId;
public class Friendship { public class Friendship {
@Id private ObjectId id; @Id private ObjectId id;
@Setter @Setter @Getter @Transient private Player owner;
@Getter
@Transient private Player owner;
@Getter @Getter @Indexed private int ownerId;
@Indexed private int ownerId; @Getter @Indexed private int friendId;
@Getter @Setter private boolean isFriend;
@Indexed private int friendId; @Setter @Getter private int askerId;
@Setter
private boolean isFriend;
@Setter
@Getter
private int askerId;
private PlayerProfile profile; private PlayerProfile profile;

View File

@ -96,7 +96,10 @@ public class GachaBanner {
private void warnDeprecated(String name, String replacement) { private void warnDeprecated(String name, String replacement) {
Grasscutter.getLogger() Grasscutter.getLogger()
.error("Deprecated field found in Banners config: {} was replaced back in early May 2022, use {} instead. You MUST remove this field from your config.", name, replacement); .error(
"Deprecated field found in Banners config: {} was replaced back in early May 2022, use {} instead. You MUST remove this field from your config.",
name,
replacement);
this.deprecated = true; this.deprecated = true;
} }

View File

@ -2,7 +2,6 @@ package emu.grasscutter.game.gacha;
import dev.morphia.annotations.*; import dev.morphia.annotations.*;
import java.util.Date; import java.util.Date;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.bson.types.ObjectId; import org.bson.types.ObjectId;

View File

@ -26,15 +26,13 @@ import it.unimi.dsi.fastutil.ints.*;
import java.nio.file.*; import java.nio.file.*;
import java.util.*; import java.util.*;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
import lombok.Getter; import lombok.Getter;
import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.Subscribe;
public class GachaSystem extends BaseGameSystem { public class GachaSystem extends BaseGameSystem {
private static final int starglitterId = 221; private static final int starglitterId = 221;
private static final int stardustId = 222; private static final int stardustId = 222;
@Getter @Getter private final Int2ObjectMap<GachaBanner> gachaBanners;
private final Int2ObjectMap<GachaBanner> gachaBanners;
private WatchService watchService; private WatchService watchService;
public GachaSystem(GameServer server) { public GachaSystem(GameServer server) {

View File

@ -281,10 +281,11 @@ public class GameHome {
return this.finishedTalkIdMap.entrySet().stream() return this.finishedTalkIdMap.entrySet().stream()
.map( .map(
e -> HomeAvatarTalkFinishInfo.newBuilder() e ->
.setAvatarId(e.getKey()) HomeAvatarTalkFinishInfo.newBuilder()
.addAllFinishTalkIdList(e.getValue()) .setAvatarId(e.getKey())
.build()) .addAllFinishTalkIdList(e.getValue())
.build())
.toList(); .toList();
} }
@ -393,9 +394,7 @@ public class GameHome {
.get(player.getCurrentRealmId() + 2000) .get(player.getCurrentRealmId() + 2000)
.getBlockItems() .getBlockItems()
.forEach( .forEach(
(i, e) -> e.getDeployNPCList() (i, e) -> e.getDeployNPCList().forEach(id -> invitedAvatars.add(id.getAvatarId())));
.forEach(
id -> invitedAvatars.add(id.getAvatarId())));
// Check as realm 5 inside is not in defaults and will be null // Check as realm 5 inside is not in defaults and will be null
if (Objects.nonNull(mainHouseMap.get(player.getCurrentRealmId() + 2000))) { if (Objects.nonNull(mainHouseMap.get(player.getCurrentRealmId() + 2000))) {
@ -404,9 +403,7 @@ public class GameHome {
.get(player.getCurrentRealmId() + 2000) .get(player.getCurrentRealmId() + 2000)
.getBlockItems() .getBlockItems()
.forEach( .forEach(
(i, e) -> e.getDeployNPCList() (i, e) -> e.getDeployNPCList().forEach(id -> invitedAvatars.add(id.getAvatarId())));
.forEach(
id -> invitedAvatars.add(id.getAvatarId())));
} }
// Add exp to all avatars // Add exp to all avatars

View File

@ -93,24 +93,25 @@ public class HomeModuleManager {
.map(HomeBlockItem::getDeployNPCList) .map(HomeBlockItem::getDeployNPCList)
.flatMap(Collection::stream) .flatMap(Collection::stream)
.forEach( .forEach(
avatar -> suites.forEach( avatar ->
suite -> { suites.forEach(
var data = suite -> {
SuiteEventType.HOME_AVATAR_REWARD_EVENT.getEventDataFrom( var data =
avatar.getAvatarId(), suite.getSuiteId()); SuiteEventType.HOME_AVATAR_REWARD_EVENT.getEventDataFrom(
if (data == null || this.home.isRewardEventFinished(data.getId())) { avatar.getAvatarId(), suite.getSuiteId());
return; if (data == null || this.home.isRewardEventFinished(data.getId())) {
} return;
}
this.rewardEvents.add( this.rewardEvents.add(
new HomeAvatarRewardEvent( new HomeAvatarRewardEvent(
homeOwner, homeOwner,
data.getId(), data.getId(),
data.getRewardID(), data.getRewardID(),
data.getAvatarID(), data.getAvatarID(),
data.getSuiteId(), data.getSuiteId(),
suite.getGuid())); suite.getGuid()));
})); }));
if (this.summonEvents != null) { if (this.summonEvents != null) {
var suiteIdList = this.rewardEvents.stream().map(HomeAvatarRewardEvent::getSuiteId).toList(); var suiteIdList = this.rewardEvents.stream().map(HomeAvatarRewardEvent::getSuiteId).toList();

View File

@ -103,11 +103,12 @@ public class HomeSceneItem {
homeAnimalItem -> homeAnimalItem ->
GameData.getHomeWorldAnimalDataMap().containsKey(homeAnimalItem.getFurnitureId())) GameData.getHomeWorldAnimalDataMap().containsKey(homeAnimalItem.getFurnitureId()))
.map( .map(
homeAnimalItem -> new EntityHomeAnimal( homeAnimalItem ->
scene, new EntityHomeAnimal(
GameData.getHomeWorldAnimalDataMap().get(homeAnimalItem.getFurnitureId()), scene,
homeAnimalItem.getSpawnPos(), GameData.getHomeWorldAnimalDataMap().get(homeAnimalItem.getFurnitureId()),
homeAnimalItem.getSpawnRot())) homeAnimalItem.getSpawnPos(),
homeAnimalItem.getSpawnRot()))
.toList(); .toList();
} }

View File

@ -28,8 +28,7 @@ import org.bson.types.ObjectId;
@Entity(value = "items", useDiscriminator = false) @Entity(value = "items", useDiscriminator = false)
public class GameItem { public class GameItem {
@Id private ObjectId id; @Id private ObjectId id;
@Getter @Getter @Indexed private int ownerId;
@Indexed private int ownerId;
@Getter @Setter private int itemId; @Getter @Setter private int itemId;
@Getter @Setter private int count; @Getter @Setter private int count;

View File

@ -21,14 +21,12 @@ import it.unimi.dsi.fastutil.ints.*;
import it.unimi.dsi.fastutil.longs.*; import it.unimi.dsi.fastutil.longs.*;
import java.util.*; import java.util.*;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import lombok.Getter; import lombok.Getter;
import lombok.val; import lombok.val;
public class Inventory extends BasePlayerManager implements Iterable<GameItem> { public class Inventory extends BasePlayerManager implements Iterable<GameItem> {
private final Long2ObjectMap<GameItem> store; private final Long2ObjectMap<GameItem> store;
@Getter @Getter private final Int2ObjectMap<InventoryTab> inventoryTypes;
private final Int2ObjectMap<InventoryTab> inventoryTypes;
public Inventory(Player player) { public Inventory(Player player) {
super(player); super(player);
@ -321,7 +319,9 @@ public class Inventory extends BasePlayerManager implements Iterable<GameItem> {
case MATERIAL_COSTUME: case MATERIAL_COSTUME:
case MATERIAL_NAMECARD: case MATERIAL_NAMECARD:
Grasscutter.getLogger() Grasscutter.getLogger()
.warn("Attempted to add a {} to inventory, but item definition lacks isUseOnGain. This indicates a Resources error.", item.getItemData().getMaterialType().name()); .warn(
"Attempted to add a {} to inventory, but item definition lacks isUseOnGain. This indicates a Resources error.",
item.getItemData().getMaterialType().name());
return null; return null;
default: default:
if (tab == null) { if (tab == null) {
@ -429,22 +429,24 @@ public class Inventory extends BasePlayerManager implements Iterable<GameItem> {
private int getVirtualItemCount(int itemId) { private int getVirtualItemCount(int itemId) {
return switch (itemId) { return switch (itemId) {
case 201 -> // Primogem case 201 -> // Primogem
this.player.getPrimogems(); this.player.getPrimogems();
case 202 -> // Mora case 202 -> // Mora
this.player.getMora(); this.player.getMora();
case 203 -> // Genesis Crystals case 203 -> // Genesis Crystals
this.player.getCrystals(); this.player.getCrystals();
case 106 -> // Resin case 106 -> // Resin
this.player.getProperty(PlayerProperty.PROP_PLAYER_RESIN); this.player.getProperty(PlayerProperty.PROP_PLAYER_RESIN);
case 107 -> // Legendary Key case 107 -> // Legendary Key
this.player.getProperty(PlayerProperty.PROP_PLAYER_LEGENDARY_KEY); this.player.getProperty(PlayerProperty.PROP_PLAYER_LEGENDARY_KEY);
case 204 -> // Home Coin case 204 -> // Home Coin
this.player.getHomeCoin(); this.player.getHomeCoin();
default -> { default -> {
GameItem item = GameItem item =
getInventoryTab(ItemType.ITEM_MATERIAL) getInventoryTab(ItemType.ITEM_MATERIAL)
.getItemById( .getItemById(
itemId); // What if we ever want to operate on weapons/relics/furniture? :Syield (item == null) ? 0 : item.getCount(); // What if we ever want to operate on weapons/relics/furniture? :S itemId); // What if we ever want to operate on weapons/relics/furniture? :Syield
// (item == null) ? 0 : item.getCount(); // What if we ever want to
// operate on weapons/relics/furniture? :S
} }
}; };
} }

View File

@ -13,5 +13,4 @@ public class ItemDef {
this.itemId = itemId; this.itemId = itemId;
this.count = count; this.count = count;
} }
} }

View File

@ -11,18 +11,14 @@ import emu.grasscutter.net.proto.MailCollectStateOuterClass.MailCollectState;
import emu.grasscutter.net.proto.MailTextContentOuterClass.MailTextContent; import emu.grasscutter.net.proto.MailTextContentOuterClass.MailTextContent;
import java.time.Instant; import java.time.Instant;
import java.util.*; import java.util.*;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.bson.types.ObjectId; import org.bson.types.ObjectId;
@Entity(value = "mail", useDiscriminator = false) @Entity(value = "mail", useDiscriminator = false)
public final class Mail { public final class Mail {
@Getter @Getter @Id private ObjectId id;
@Id private ObjectId id; @Setter @Getter @Indexed private int ownerUid;
@Setter
@Getter
@Indexed private int ownerUid;
public final MailContent mailContent; public final MailContent mailContent;
public final List<MailItem> itemList; public final List<MailItem> itemList;
public final long sendTime; public final long sendTime;
@ -36,7 +32,7 @@ public final class Mail {
public Mail() { public Mail() {
this( this(
new MailContent(), new MailContent(),
new ArrayList<>(), new ArrayList<>(),
(int) Instant.now().getEpochSecond() (int) Instant.now().getEpochSecond()
+ 604800); // TODO: add expire time to send mail command + 604800); // TODO: add expire time to send mail command
} }

View File

@ -5,9 +5,8 @@ import emu.grasscutter.database.DatabaseHelper;
import emu.grasscutter.game.player.*; import emu.grasscutter.game.player.*;
import emu.grasscutter.server.event.player.PlayerReceiveMailEvent; import emu.grasscutter.server.event.player.PlayerReceiveMailEvent;
import emu.grasscutter.server.packet.send.*; import emu.grasscutter.server.packet.send.*;
import lombok.Getter;
import java.util.*; import java.util.*;
import lombok.Getter;
@Getter @Getter
public class MailHandler extends BasePlayerManager { public class MailHandler extends BasePlayerManager {
@ -34,7 +33,10 @@ public class MailHandler extends BasePlayerManager {
this.mail.add(message); this.mail.add(message);
Grasscutter.getLogger() Grasscutter.getLogger()
.debug("Mail sent to user [{}:{}]!", this.getPlayer().getUid(), this.getPlayer().getNickname()); .debug(
"Mail sent to user [{}:{}]!",
this.getPlayer().getUid(),
this.getPlayer().getNickname());
if (this.getPlayer().isOnline()) { if (this.getPlayer().isOnline()) {
this.getPlayer().sendPacket(new PacketMailChangeNotify(this.getPlayer(), message)); this.getPlayer().sendPacket(new PacketMailChangeNotify(this.getPlayer(), message));
@ -57,7 +59,7 @@ public class MailHandler extends BasePlayerManager {
} }
public void deleteMail(List<Integer> mailList) { public void deleteMail(List<Integer> mailList) {
List<Integer> sortedMailList = new ArrayList<>(mailList); List<Integer> sortedMailList = new ArrayList<>(mailList);
sortedMailList.sort(Collections.reverseOrder()); sortedMailList.sort(Collections.reverseOrder());
List<Integer> deleted = new ArrayList<>(); List<Integer> deleted = new ArrayList<>();

View File

@ -180,7 +180,10 @@ public class SotSManager extends BasePlayerManager {
public void run() { public void run() {
refillSpringVolume(); refillSpringVolume();
logger.trace("isAutoRecoveryEnabled: {}\tautoRecoverPercentage: {}", getIsAutoRecoveryEnabled(), getAutoRecoveryPercentage()); logger.trace(
"isAutoRecoveryEnabled: {}\tautoRecoverPercentage: {}",
getIsAutoRecoveryEnabled(),
getAutoRecoveryPercentage());
if (getIsAutoRecoveryEnabled()) { if (getIsAutoRecoveryEnabled()) {
List<EntityAvatar> activeTeam = player.getTeamManager().getActiveTeam(); List<EntityAvatar> activeTeam = player.getTeamManager().getActiveTeam();

View File

@ -8,17 +8,14 @@ import emu.grasscutter.game.props.FightProperty;
import emu.grasscutter.game.world.*; import emu.grasscutter.game.world.*;
import emu.grasscutter.scripts.data.*; import emu.grasscutter.scripts.data.*;
import emu.grasscutter.utils.Utils; import emu.grasscutter.utils.Utils;
import lombok.Getter;
import java.util.*; import java.util.*;
import lombok.Getter;
public final class BlossomActivity { public final class BlossomActivity {
private final SceneGroup tempSceneGroup; private final SceneGroup tempSceneGroup;
@Getter @Getter private final WorldChallenge challenge;
private final WorldChallenge challenge; @Getter private final EntityGadget gadget;
@Getter
private final EntityGadget gadget;
private EntityGadget chest; private EntityGadget chest;
private int step; private int step;
private final int goal; private final int goal;

View File

@ -203,7 +203,7 @@ public class BlossomManager {
RewardPreviewData blossomRewards = getRewardList(type, worldLevel); RewardPreviewData blossomRewards = getRewardList(type, worldLevel);
if (blossomRewards == null) { if (blossomRewards == null) {
Grasscutter.getLogger() Grasscutter.getLogger()
.error("Blossom could not support world level : {}", worldLevel); .error("Blossom could not support world level : {}", worldLevel);
return null; return null;
} }
var rewards = blossomRewards.getPreviewItems(); var rewards = blossomRewards.getPreviewItems();

View File

@ -18,7 +18,6 @@ import emu.grasscutter.server.packet.send.PacketCompoundDataNotify;
import emu.grasscutter.server.packet.send.PacketGetCompoundDataRsp; import emu.grasscutter.server.packet.send.PacketGetCompoundDataRsp;
import emu.grasscutter.server.packet.send.PacketPlayerCompoundMaterialRsp; import emu.grasscutter.server.packet.send.PacketPlayerCompoundMaterialRsp;
import emu.grasscutter.utils.Utils; import emu.grasscutter.utils.Utils;
import java.util.*; import java.util.*;
public class CookingCompoundManager extends BasePlayerManager { public class CookingCompoundManager extends BasePlayerManager {
@ -34,24 +33,33 @@ public class CookingCompoundManager extends BasePlayerManager {
public static void initialize() { public static void initialize() {
defaultUnlockedCompounds = new HashSet<>(); defaultUnlockedCompounds = new HashSet<>();
compoundGroups = new HashMap<>(); compoundGroups = new HashMap<>();
GameData.getCompoundDataMap().forEach((id, compound) -> { GameData.getCompoundDataMap()
if (compound.isDefaultUnlocked()) { .forEach(
defaultUnlockedCompounds.add(id); (id, compound) -> {
} if (compound.isDefaultUnlocked()) {
compoundGroups.computeIfAbsent(compound.getGroupId(), gid -> new HashSet<>()).add(id); defaultUnlockedCompounds.add(id);
}); }
compoundGroups.computeIfAbsent(compound.getGroupId(), gid -> new HashSet<>()).add(id);
});
// TODO:Because we haven't implemented fishing feature,unlock all compounds related to // TODO:Because we haven't implemented fishing feature,unlock all compounds related to
// fish.Besides,it should be bound to player rather than manager. // fish.Besides,it should be bound to player rather than manager.
unlocked = new HashSet<>(defaultUnlockedCompounds); unlocked = new HashSet<>(defaultUnlockedCompounds);
if (compoundGroups.containsKey(3)) // Avoid NPE from Resources error if (compoundGroups.containsKey(3)) // Avoid NPE from Resources error
unlocked.addAll(compoundGroups.get(3)); unlocked.addAll(compoundGroups.get(3));
} }
private synchronized List<CompoundQueueData> getCompoundQueueData() { private synchronized List<CompoundQueueData> getCompoundQueueData() {
List<CompoundQueueData> compoundQueueData = new ArrayList<>(player.getActiveCookCompounds().size()); List<CompoundQueueData> compoundQueueData =
new ArrayList<>(player.getActiveCookCompounds().size());
int currentTime = Utils.getCurrentSeconds(); int currentTime = Utils.getCurrentSeconds();
for (var item : player.getActiveCookCompounds().values()) { for (var item : player.getActiveCookCompounds().values()) {
var data = CompoundQueueData.newBuilder().setCompoundId(item.getCompoundId()).setOutputCount(item.getOutputCount(currentTime)).setOutputTime(item.getOutputTime(currentTime)).setWaitCount(item.getWaitCount(currentTime)).build(); var data =
CompoundQueueData.newBuilder()
.setCompoundId(item.getCompoundId())
.setOutputCount(item.getOutputCount(currentTime))
.setOutputTime(item.getOutputTime(currentTime))
.setWaitCount(item.getWaitCount(currentTime))
.build();
compoundQueueData.add(data); compoundQueueData.add(data);
} }
return compoundQueueData; return compoundQueueData;
@ -73,14 +81,16 @@ public class CookingCompoundManager extends BasePlayerManager {
return; return;
} }
// check whether the queue is full // check whether the queue is full
if (activeCompounds.containsKey(id) && activeCompounds.get(id).getTotalCount() + count > compound.getQueueSize()) { if (activeCompounds.containsKey(id)
&& activeCompounds.get(id).getTotalCount() + count > compound.getQueueSize()) {
player.sendPacket(new PacketPlayerCompoundMaterialRsp(Retcode.RET_COMPOUND_QUEUE_FULL_VALUE)); player.sendPacket(new PacketPlayerCompoundMaterialRsp(Retcode.RET_COMPOUND_QUEUE_FULL_VALUE));
return; return;
} }
// try to consume raw materials // try to consume raw materials
if (!player.getInventory().payItems(compound.getInputVec(), count)) { if (!player.getInventory().payItems(compound.getInputVec(), count)) {
// TODO:I'm not sure whether retcode is correct. // TODO:I'm not sure whether retcode is correct.
player.sendPacket(new PacketPlayerCompoundMaterialRsp(Retcode.RET_ITEM_COUNT_NOT_ENOUGH_VALUE)); player.sendPacket(
new PacketPlayerCompoundMaterialRsp(Retcode.RET_ITEM_COUNT_NOT_ENOUGH_VALUE));
return; return;
} }
ActiveCookCompoundData c; ActiveCookCompoundData c;
@ -92,7 +102,13 @@ public class CookingCompoundManager extends BasePlayerManager {
c = new ActiveCookCompoundData(id, compound.getCostTime(), count, currentTime); c = new ActiveCookCompoundData(id, compound.getCostTime(), count, currentTime);
activeCompounds.put(id, c); activeCompounds.put(id, c);
} }
var data = CompoundQueueData.newBuilder().setCompoundId(id).setOutputCount(c.getOutputCount(currentTime)).setOutputTime(c.getOutputTime(currentTime)).setWaitCount(c.getWaitCount(currentTime)).build(); var data =
CompoundQueueData.newBuilder()
.setCompoundId(id)
.setOutputCount(c.getOutputCount(currentTime))
.setOutputTime(c.getOutputTime(currentTime))
.setWaitCount(c.getWaitCount(currentTime))
.build();
player.sendPacket(new PacketPlayerCompoundMaterialRsp(data)); player.sendPacket(new PacketPlayerCompoundMaterialRsp(data));
} }
@ -124,9 +140,20 @@ public class CookingCompoundManager extends BasePlayerManager {
// give player the rewards // give player the rewards
if (success) { if (success) {
player.getInventory().addItems(allRewards.values(), ActionReason.Compound); player.getInventory().addItems(allRewards.values(), ActionReason.Compound);
player.sendPacket(new PackageTakeCompoundOutputRsp(allRewards.values().stream().map(i -> ItemParam.newBuilder().setItemId(i.getItemId()).setCount(i.getCount()).build()).toList(), Retcode.RET_SUCC_VALUE)); player.sendPacket(
new PackageTakeCompoundOutputRsp(
allRewards.values().stream()
.map(
i ->
ItemParam.newBuilder()
.setItemId(i.getItemId())
.setCount(i.getCount())
.build())
.toList(),
Retcode.RET_SUCC_VALUE));
} else { } else {
player.sendPacket(new PackageTakeCompoundOutputRsp(null, Retcode.RET_COMPOUND_NOT_FINISH_VALUE)); player.sendPacket(
new PackageTakeCompoundOutputRsp(null, Retcode.RET_COMPOUND_NOT_FINISH_VALUE));
} }
} }

View File

@ -3,12 +3,9 @@ package emu.grasscutter.game.managers.deforestation;
import lombok.Getter; import lombok.Getter;
public class HitTreeRecord { public class HitTreeRecord {
/** /** -- GETTER -- get unique id */
* -- GETTER -- @Getter private final int unique;
* get unique id
*/
@Getter
private final int unique;
private short count; // hit this tree times private short count; // hit this tree times
private long time; // last available hitting time private long time; // last available hitting time

View File

@ -1,12 +1,10 @@
package emu.grasscutter.game.managers.energy; package emu.grasscutter.game.managers.energy;
import lombok.Getter;
import java.util.List; import java.util.List;
import lombok.Getter;
@Getter @Getter
public class EnergyDropEntry { public class EnergyDropEntry {
private int dropId; private int dropId;
private List<EnergyDropInfo> dropList; private List<EnergyDropInfo> dropList;
} }

View File

@ -6,5 +6,4 @@ import lombok.Getter;
public class EnergyDropInfo { public class EnergyDropInfo {
private int ballId; private int ballId;
private int count; private int count;
} }

View File

@ -45,8 +45,7 @@ public class EnergyManager extends BasePlayerManager {
// Read the data we need for monster energy drops. // Read the data we need for monster energy drops.
try { try {
DataLoader.loadList("EnergyDrop.json", EnergyDropEntry.class) DataLoader.loadList("EnergyDrop.json", EnergyDropEntry.class)
.forEach( .forEach(entry -> energyDropData.put(entry.getDropId(), entry.getDropList()));
entry -> energyDropData.put(entry.getDropId(), entry.getDropList()));
Grasscutter.getLogger().debug("Energy drop data successfully loaded."); Grasscutter.getLogger().debug("Energy drop data successfully loaded.");
} catch (Exception ex) { } catch (Exception ex) {

View File

@ -1,12 +1,10 @@
package emu.grasscutter.game.managers.energy; package emu.grasscutter.game.managers.energy;
import lombok.Getter;
import java.util.List; import java.util.List;
import lombok.Getter;
@Getter @Getter
public class SkillParticleGenerationEntry { public class SkillParticleGenerationEntry {
private int avatarId; private int avatarId;
private List<SkillParticleGenerationInfo> amountList; private List<SkillParticleGenerationInfo> amountList;
} }

View File

@ -6,5 +6,4 @@ import lombok.Getter;
public class SkillParticleGenerationInfo { public class SkillParticleGenerationInfo {
private int value; private int value;
private int chance; private int chance;
} }

View File

@ -6,27 +6,15 @@ import lombok.Setter;
@Entity @Entity
public class ActiveForgeData { public class ActiveForgeData {
@Setter @Setter @Getter private int forgeId;
@Getter @Setter @Getter private int avatarId;
private int forgeId; @Setter @Getter private int count;
@Setter
@Getter
private int avatarId;
@Setter
@Getter
private int count;
@Setter @Setter @Getter private int startTime;
@Getter @Setter @Getter private int forgeTime;
private int startTime;
@Setter
@Getter
private int forgeTime;
private int lastUnfinishedCount; private int lastUnfinishedCount;
@Setter @Setter @Getter private boolean changed;
@Getter
private boolean changed;
public int getFinishedCount(int currentTime) { public int getFinishedCount(int currentTime) {
int timeDelta = currentTime - this.startTime; int timeDelta = currentTime - this.startTime;

View File

@ -33,5 +33,4 @@ public class MapMark {
this.mapMarkFromType = mapMarkPoint.getFromType(); this.mapMarkFromType = mapMarkPoint.getFromType();
this.questId = mapMarkPoint.getQuestId(); this.questId = mapMarkPoint.getQuestId();
} }
} }

View File

@ -63,15 +63,15 @@ public class PlayerCodex {
MATERIAL_WIDGET, MATERIAL_WIDGET,
MATERIAL_EXCHANGE, MATERIAL_EXCHANGE,
MATERIAL_AVATAR_MATERIAL, MATERIAL_AVATAR_MATERIAL,
MATERIAL_NOTICE_ADD_HP -> Optional.ofNullable(GameData.getCodexMaterialDataIdMap().get(itemId)) MATERIAL_NOTICE_ADD_HP -> Optional.ofNullable(
.ifPresent( GameData.getCodexMaterialDataIdMap().get(itemId))
codexData -> { .ifPresent(
if (this.getUnlockedMaterial().add(itemId)) { codexData -> {
this.player.save(); if (this.getUnlockedMaterial().add(itemId)) {
this.player.sendPacket( this.player.save();
new PacketCodexDataUpdateNotify(4, codexData.getId())); this.player.sendPacket(new PacketCodexDataUpdateNotify(4, codexData.getId()));
} }
}); });
default -> {} default -> {}
} }
} }

View File

@ -1,9 +1,8 @@
package emu.grasscutter.game.player; package emu.grasscutter.game.player;
import dev.morphia.annotations.Entity; import dev.morphia.annotations.Entity;
import lombok.Getter;
import java.util.*; import java.util.*;
import lombok.Getter;
@Entity(useDiscriminator = false) @Entity(useDiscriminator = false)
public class PlayerCollectionRecords { public class PlayerCollectionRecords {
@ -58,6 +57,5 @@ public class PlayerCollectionRecords {
this.configId = configId; this.configId = configId;
this.expiredTime = expiredTime; this.expiredTime = expiredTime;
} }
} }
} }

View File

@ -5,16 +5,14 @@ import static emu.grasscutter.config.Configuration.GAME_OPTIONS;
import dev.morphia.annotations.Entity; import dev.morphia.annotations.Entity;
import emu.grasscutter.game.avatar.Avatar; import emu.grasscutter.game.avatar.Avatar;
import emu.grasscutter.net.proto.AvatarTeamOuterClass.AvatarTeam; import emu.grasscutter.net.proto.AvatarTeamOuterClass.AvatarTeam;
import java.util.*;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.util.*;
@Getter @Getter
@Entity @Entity
public final class TeamInfo { public final class TeamInfo {
@Setter @Setter private String name;
private String name;
private final List<Integer> avatars; private final List<Integer> avatars;
public TeamInfo() { public TeamInfo() {

View File

@ -1,10 +1,9 @@
package emu.grasscutter.game.props; package emu.grasscutter.game.props;
import it.unimi.dsi.fastutil.ints.*; import it.unimi.dsi.fastutil.ints.*;
import lombok.Getter;
import java.util.*; import java.util.*;
import java.util.stream.Stream; import java.util.stream.Stream;
import lombok.Getter;
@Getter @Getter
public enum ActionReason { public enum ActionReason {
@ -208,5 +207,4 @@ public enum ActionReason {
public static ActionReason getTypeByName(String name) { public static ActionReason getTypeByName(String name) {
return stringMap.getOrDefault(name, None); return stringMap.getOrDefault(name, None);
} }
} }

View File

@ -14,5 +14,4 @@ public enum BattlePassMissionRefreshType {
BattlePassMissionRefreshType(int value) { BattlePassMissionRefreshType(int value) {
this.value = value; this.value = value;
} }
} }

View File

@ -17,5 +17,4 @@ public enum BattlePassMissionStatus {
this.value = value; this.value = value;
this.missionStatus = missionStatus; // In case proto enum values change later this.missionStatus = missionStatus; // In case proto enum values change later
} }
} }

View File

@ -2,10 +2,9 @@ package emu.grasscutter.game.props;
import emu.grasscutter.scripts.constants.IntValueEnum; import emu.grasscutter.scripts.constants.IntValueEnum;
import it.unimi.dsi.fastutil.ints.*; import it.unimi.dsi.fastutil.ints.*;
import lombok.Getter;
import java.util.*; import java.util.*;
import java.util.stream.Stream; import java.util.stream.Stream;
import lombok.Getter;
@Getter @Getter
public enum CampTargetType implements IntValueEnum { public enum CampTargetType implements IntValueEnum {

View File

@ -1,10 +1,9 @@
package emu.grasscutter.game.props; package emu.grasscutter.game.props;
import it.unimi.dsi.fastutil.ints.*; import it.unimi.dsi.fastutil.ints.*;
import lombok.Getter;
import java.util.*; import java.util.*;
import java.util.stream.Stream; import java.util.stream.Stream;
import lombok.Getter;
@Getter @Getter
public enum ClimateType { public enum ClimateType {

View File

@ -1,10 +1,9 @@
package emu.grasscutter.game.props; package emu.grasscutter.game.props;
import it.unimi.dsi.fastutil.ints.*; import it.unimi.dsi.fastutil.ints.*;
import lombok.Getter;
import java.util.*; import java.util.*;
import java.util.stream.Stream; import java.util.stream.Stream;
import lombok.Getter;
@Getter @Getter
public enum EnterReason { public enum EnterReason {
@ -66,5 +65,4 @@ public enum EnterReason {
public static EnterReason getTypeByName(String name) { public static EnterReason getTypeByName(String name) {
return stringMap.getOrDefault(name, None); return stringMap.getOrDefault(name, None);
} }
} }

View File

@ -1,8 +1,7 @@
package emu.grasscutter.game.props; package emu.grasscutter.game.props;
import lombok.Getter;
import java.util.*; import java.util.*;
import lombok.Getter;
@Getter @Getter
public enum EntityIdType { public enum EntityIdType {
@ -37,5 +36,4 @@ public enum EntityIdType {
public static EntityType toEntityType(int entityId) { public static EntityType toEntityType(int entityId) {
return map.getOrDefault(entityId, EntityType.None); return map.getOrDefault(entityId, EntityType.None);
} }
} }

View File

@ -2,10 +2,9 @@ package emu.grasscutter.game.props;
import emu.grasscutter.scripts.constants.IntValueEnum; import emu.grasscutter.scripts.constants.IntValueEnum;
import it.unimi.dsi.fastutil.ints.*; import it.unimi.dsi.fastutil.ints.*;
import lombok.Getter;
import java.util.*; import java.util.*;
import java.util.stream.Stream; import java.util.stream.Stream;
import lombok.Getter;
@Getter @Getter
public enum EntityType implements IntValueEnum { public enum EntityType implements IntValueEnum {
@ -104,5 +103,4 @@ public enum EntityType implements IntValueEnum {
public static EntityType getTypeByName(String name) { public static EntityType getTypeByName(String name) {
return stringMap.getOrDefault(name, None); return stringMap.getOrDefault(name, None);
} }
} }

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