mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2026-03-26 09:32:45 +01:00
Fix whitespace [skip actions]
This commit is contained in:
@@ -95,7 +95,7 @@ public final class Grasscutter {
|
||||
Crypto.loadKeys(); // Load keys from buffers.
|
||||
|
||||
// Parse start-up arguments.
|
||||
if(StartupArguments.parse(args)) {
|
||||
if (StartupArguments.parse(args)) {
|
||||
System.exit(0); // Exit early.
|
||||
}
|
||||
|
||||
|
||||
@@ -45,8 +45,8 @@ public final class AccountCommand implements CommandHandler {
|
||||
int uid = 0;
|
||||
String password = "";
|
||||
|
||||
if(Configuration.ACCOUNT.EXPERIMENTAL_RealPassword == true) {
|
||||
if(args.size() < 3) {
|
||||
if (Configuration.ACCOUNT.EXPERIMENTAL_RealPassword == true) {
|
||||
if (args.size() < 3) {
|
||||
CommandHandler.sendMessage(sender, "EXPERIMENTAL_RealPassword requires a password argument");
|
||||
CommandHandler.sendMessage(sender, "Usage: account create <username> <password> [uid]");
|
||||
return;
|
||||
@@ -58,7 +58,7 @@ public final class AccountCommand implements CommandHandler {
|
||||
uid = Integer.parseInt(args.get(3));
|
||||
} catch (NumberFormatException ignored) {
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.account.invalid"));
|
||||
if(Configuration.ACCOUNT.EXPERIMENTAL_RealPassword == true) {
|
||||
if (Configuration.ACCOUNT.EXPERIMENTAL_RealPassword == true) {
|
||||
CommandHandler.sendMessage(sender, "EXPERIMENTAL_RealPassword requires argument 2 to be a password, not a uid");
|
||||
CommandHandler.sendMessage(sender, "Usage: account create <username> <password> [uid]");
|
||||
}
|
||||
@@ -107,12 +107,12 @@ public final class AccountCommand implements CommandHandler {
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.account.delete"));
|
||||
return;
|
||||
case "resetpass":
|
||||
if(Configuration.ACCOUNT.EXPERIMENTAL_RealPassword != true) {
|
||||
if (Configuration.ACCOUNT.EXPERIMENTAL_RealPassword != true) {
|
||||
CommandHandler.sendMessage(sender, "resetpass requires EXPERIMENTAL_RealPassword to be true.");
|
||||
return;
|
||||
}
|
||||
|
||||
if(args.size() != 3) {
|
||||
if (args.size() != 3) {
|
||||
CommandHandler.sendMessage(sender, "Invalid Args");
|
||||
CommandHandler.sendMessage(sender, "Usage: account resetpass <username> <password>");
|
||||
return;
|
||||
|
||||
@@ -61,4 +61,4 @@ public final class BanCommand implements CommandHandler {
|
||||
CommandHandler.sendTranslatedMessage(sender, "commands.ban.failure");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,55 +1,55 @@
|
||||
package emu.grasscutter.command.commands;
|
||||
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.command.Command;
|
||||
import emu.grasscutter.command.CommandHandler;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.utils.Utils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(label = "language", usage = {"[<language code>]"}, aliases = {"lang"}, targetRequirement = Command.TargetRequirement.NONE)
|
||||
public final class LanguageCommand implements CommandHandler {
|
||||
|
||||
@Override
|
||||
public void execute(Player sender, Player targetPlayer, List<String> args) {
|
||||
if (args.isEmpty()) {
|
||||
String curLangCode = null;
|
||||
if (sender != null) {
|
||||
curLangCode = Utils.getLanguageCode(sender.getAccount().getLocale());
|
||||
}
|
||||
else {
|
||||
curLangCode = Grasscutter.getLanguage().getLanguageCode();
|
||||
}
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.language.current_language", curLangCode));
|
||||
return;
|
||||
}
|
||||
|
||||
String langCode = args.get(0);
|
||||
|
||||
var languageInst = Grasscutter.getLanguage(langCode);
|
||||
var actualLangCode = languageInst.getLanguageCode();
|
||||
var locale = Locale.forLanguageTag(actualLangCode);
|
||||
if (sender != null) {
|
||||
var account = sender.getAccount();
|
||||
account.setLocale(locale);
|
||||
account.save();
|
||||
}
|
||||
else {
|
||||
Grasscutter.setLanguage(languageInst);
|
||||
var config = Grasscutter.getConfig();
|
||||
config.language.language = locale;
|
||||
Grasscutter.saveConfig(config);
|
||||
}
|
||||
|
||||
if (!langCode.equals(actualLangCode)) {
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.language.language_not_found", langCode));
|
||||
}
|
||||
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.language.language_changed", actualLangCode));
|
||||
|
||||
}
|
||||
}
|
||||
package emu.grasscutter.command.commands;
|
||||
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.command.Command;
|
||||
import emu.grasscutter.command.CommandHandler;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.utils.Utils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(label = "language", usage = {"[<language code>]"}, aliases = {"lang"}, targetRequirement = Command.TargetRequirement.NONE)
|
||||
public final class LanguageCommand implements CommandHandler {
|
||||
|
||||
@Override
|
||||
public void execute(Player sender, Player targetPlayer, List<String> args) {
|
||||
if (args.isEmpty()) {
|
||||
String curLangCode = null;
|
||||
if (sender != null) {
|
||||
curLangCode = Utils.getLanguageCode(sender.getAccount().getLocale());
|
||||
}
|
||||
else {
|
||||
curLangCode = Grasscutter.getLanguage().getLanguageCode();
|
||||
}
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.language.current_language", curLangCode));
|
||||
return;
|
||||
}
|
||||
|
||||
String langCode = args.get(0);
|
||||
|
||||
var languageInst = Grasscutter.getLanguage(langCode);
|
||||
var actualLangCode = languageInst.getLanguageCode();
|
||||
var locale = Locale.forLanguageTag(actualLangCode);
|
||||
if (sender != null) {
|
||||
var account = sender.getAccount();
|
||||
account.setLocale(locale);
|
||||
account.save();
|
||||
}
|
||||
else {
|
||||
Grasscutter.setLanguage(languageInst);
|
||||
var config = Grasscutter.getConfig();
|
||||
config.language.language = locale;
|
||||
Grasscutter.saveConfig(config);
|
||||
}
|
||||
|
||||
if (!langCode.equals(actualLangCode)) {
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.language.language_not_found", langCode));
|
||||
}
|
||||
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.language.language_changed", actualLangCode));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,53 +1,53 @@
|
||||
package emu.grasscutter.command.commands;
|
||||
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.command.Command;
|
||||
import emu.grasscutter.command.CommandHandler;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(label = "list", aliases = {"players"}, usage = {"[<UID>]"}, targetRequirement = Command.TargetRequirement.NONE)
|
||||
public final class ListCommand implements CommandHandler {
|
||||
|
||||
@Override
|
||||
public void execute(Player sender, Player targetPlayer, List<String> args) {
|
||||
Map<Integer, Player> playersMap = Grasscutter.getGameServer().getPlayers();
|
||||
boolean needUID = false;
|
||||
|
||||
if (args.size() > 0) {
|
||||
needUID = args.get(0).equals("uid");
|
||||
}
|
||||
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.list.success", playersMap.size()));
|
||||
|
||||
if (playersMap.size() != 0) {
|
||||
StringBuilder playerSet = new StringBuilder();
|
||||
boolean finalNeedUID = needUID;
|
||||
|
||||
playersMap.values().forEach(player -> {
|
||||
playerSet.append(player.getNickname());
|
||||
|
||||
if (finalNeedUID) {
|
||||
if (sender != null) {
|
||||
playerSet.append(" <color=green>(")
|
||||
.append(player.getUid())
|
||||
.append(")</color>");
|
||||
} else {
|
||||
playerSet.append(" (")
|
||||
.append(player.getUid())
|
||||
.append(")");
|
||||
}
|
||||
}
|
||||
|
||||
playerSet.append(", ");
|
||||
});
|
||||
|
||||
String players = playerSet.toString();
|
||||
CommandHandler.sendMessage(sender, players.substring(0, players.length() - 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
package emu.grasscutter.command.commands;
|
||||
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.command.Command;
|
||||
import emu.grasscutter.command.CommandHandler;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(label = "list", aliases = {"players"}, usage = {"[<UID>]"}, targetRequirement = Command.TargetRequirement.NONE)
|
||||
public final class ListCommand implements CommandHandler {
|
||||
|
||||
@Override
|
||||
public void execute(Player sender, Player targetPlayer, List<String> args) {
|
||||
Map<Integer, Player> playersMap = Grasscutter.getGameServer().getPlayers();
|
||||
boolean needUID = false;
|
||||
|
||||
if (args.size() > 0) {
|
||||
needUID = args.get(0).equals("uid");
|
||||
}
|
||||
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.list.success", playersMap.size()));
|
||||
|
||||
if (playersMap.size() != 0) {
|
||||
StringBuilder playerSet = new StringBuilder();
|
||||
boolean finalNeedUID = needUID;
|
||||
|
||||
playersMap.values().forEach(player -> {
|
||||
playerSet.append(player.getNickname());
|
||||
|
||||
if (finalNeedUID) {
|
||||
if (sender != null) {
|
||||
playerSet.append(" <color=green>(")
|
||||
.append(player.getUid())
|
||||
.append(")</color>");
|
||||
} else {
|
||||
playerSet.append(" (")
|
||||
.append(player.getUid())
|
||||
.append(")");
|
||||
}
|
||||
}
|
||||
|
||||
playerSet.append(", ");
|
||||
});
|
||||
|
||||
String players = playerSet.toString();
|
||||
CommandHandler.sendMessage(sender, players.substring(0, players.length() - 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public final class PermissionCommand implements CommandHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!Grasscutter.getPermissionHandler().EnablePermissionCommand()) {
|
||||
if (!Grasscutter.getPermissionHandler().EnablePermissionCommand()) {
|
||||
CommandHandler.sendTranslatedMessage(sender, "commands.generic.permission_error");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -14,47 +14,47 @@ public final class QuestCommand implements CommandHandler {
|
||||
|
||||
@Override
|
||||
public void execute(Player sender, Player targetPlayer, List<String> args) {
|
||||
if (args.size() != 2) {
|
||||
sendUsageMessage(sender);
|
||||
if (args.size() != 2) {
|
||||
sendUsageMessage(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
String cmd = args.get(0).toLowerCase();
|
||||
int questId;
|
||||
|
||||
try {
|
||||
questId = Integer.parseInt(args.get(1));
|
||||
} catch (Exception e) {
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.quest.invalid_id"));
|
||||
}
|
||||
|
||||
String cmd = args.get(0).toLowerCase();
|
||||
int questId;
|
||||
|
||||
try {
|
||||
questId = Integer.parseInt(args.get(1));
|
||||
} catch (Exception e) {
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.quest.invalid_id"));
|
||||
return;
|
||||
}
|
||||
|
||||
switch (cmd) {
|
||||
case "add" -> {
|
||||
GameQuest quest = targetPlayer.getQuestManager().addQuest(questId);
|
||||
|
||||
if (quest != null) {
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.quest.added", questId));
|
||||
return;
|
||||
}
|
||||
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.quest.not_found"));
|
||||
}
|
||||
case "finish" -> {
|
||||
GameQuest quest = targetPlayer.getQuestManager().getQuestById(questId);
|
||||
|
||||
if (quest == null) {
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.quest.not_found"));
|
||||
return;
|
||||
}
|
||||
|
||||
quest.finish();
|
||||
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.quest.finished", questId));
|
||||
}
|
||||
default -> {
|
||||
sendUsageMessage(sender);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (cmd) {
|
||||
case "add" -> {
|
||||
GameQuest quest = targetPlayer.getQuestManager().addQuest(questId);
|
||||
|
||||
if (quest != null) {
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.quest.added", questId));
|
||||
return;
|
||||
}
|
||||
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.quest.not_found"));
|
||||
}
|
||||
case "finish" -> {
|
||||
GameQuest quest = targetPlayer.getQuestManager().getQuestById(questId);
|
||||
|
||||
if (quest == null) {
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.quest.not_found"));
|
||||
return;
|
||||
}
|
||||
|
||||
quest.finish();
|
||||
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.quest.finished", questId));
|
||||
}
|
||||
default -> {
|
||||
sendUsageMessage(sender);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,50 +1,50 @@
|
||||
package emu.grasscutter.command.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import emu.grasscutter.command.Command;
|
||||
import emu.grasscutter.command.CommandHandler;
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.game.avatar.Avatar;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.server.packet.send.PacketAvatarFetterDataNotify;
|
||||
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(
|
||||
label = "setFetterLevel",
|
||||
usage = {"<level>"},
|
||||
aliases = {"setfetterlvl", "setfriendship"},
|
||||
permission = "player.setfetterlevel",
|
||||
permissionTargeted = "player.setfetterlevel.others")
|
||||
public final class SetFetterLevelCommand implements CommandHandler {
|
||||
|
||||
@Override
|
||||
public void execute(Player sender, Player targetPlayer, List<String> args) {
|
||||
if (args.size() != 1) {
|
||||
sendUsageMessage(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
int fetterLevel = Integer.parseInt(args.get(0));
|
||||
if (fetterLevel < 0 || fetterLevel > 10) {
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.setFetterLevel.range_error"));
|
||||
return;
|
||||
}
|
||||
Avatar avatar = targetPlayer.getTeamManager().getCurrentAvatarEntity().getAvatar();
|
||||
|
||||
avatar.setFetterLevel(fetterLevel);
|
||||
if (fetterLevel != 10) {
|
||||
avatar.setFetterExp(GameData.getAvatarFetterLevelDataMap().get(fetterLevel).getExp());
|
||||
}
|
||||
avatar.save();
|
||||
|
||||
targetPlayer.sendPacket(new PacketAvatarFetterDataNotify(avatar));
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.setFetterLevel.success", fetterLevel));
|
||||
} catch (NumberFormatException ignored) {
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.setFetterLevel.level_error"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
package emu.grasscutter.command.commands;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import emu.grasscutter.command.Command;
|
||||
import emu.grasscutter.command.CommandHandler;
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.game.avatar.Avatar;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.server.packet.send.PacketAvatarFetterDataNotify;
|
||||
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(
|
||||
label = "setFetterLevel",
|
||||
usage = {"<level>"},
|
||||
aliases = {"setfetterlvl", "setfriendship"},
|
||||
permission = "player.setfetterlevel",
|
||||
permissionTargeted = "player.setfetterlevel.others")
|
||||
public final class SetFetterLevelCommand implements CommandHandler {
|
||||
|
||||
@Override
|
||||
public void execute(Player sender, Player targetPlayer, List<String> args) {
|
||||
if (args.size() != 1) {
|
||||
sendUsageMessage(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
int fetterLevel = Integer.parseInt(args.get(0));
|
||||
if (fetterLevel < 0 || fetterLevel > 10) {
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.setFetterLevel.range_error"));
|
||||
return;
|
||||
}
|
||||
Avatar avatar = targetPlayer.getTeamManager().getCurrentAvatarEntity().getAvatar();
|
||||
|
||||
avatar.setFetterLevel(fetterLevel);
|
||||
if (fetterLevel != 10) {
|
||||
avatar.setFetterExp(GameData.getAvatarFetterLevelDataMap().get(fetterLevel).getExp());
|
||||
}
|
||||
avatar.save();
|
||||
|
||||
targetPlayer.sendPacket(new PacketAvatarFetterDataNotify(avatar));
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.setFetterLevel.success", fetterLevel));
|
||||
} catch (NumberFormatException ignored) {
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.setFetterLevel.level_error"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,180 +1,180 @@
|
||||
package emu.grasscutter.command.commands;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import emu.grasscutter.command.Command;
|
||||
import emu.grasscutter.command.CommandHandler;
|
||||
import emu.grasscutter.game.avatar.Avatar;
|
||||
import emu.grasscutter.game.entity.EntityAvatar;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.game.props.FightProperty;
|
||||
import emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify;
|
||||
|
||||
@Command(
|
||||
label = "setStats",
|
||||
aliases = {"stats", "stat"},
|
||||
usage = {
|
||||
"[set] <stat> <value>",
|
||||
"(lock|freeze) <stat> [<value>]", // Can lock to current value
|
||||
"(unlock|unfreeze) <stat>"},
|
||||
permission = "player.setstats",
|
||||
permissionTargeted = "player.setstats.others")
|
||||
public final class SetStatsCommand implements CommandHandler {
|
||||
private static class Stat {
|
||||
String name;
|
||||
FightProperty prop;
|
||||
|
||||
public Stat(FightProperty prop) {
|
||||
this.name = prop.toString();
|
||||
this.prop = prop;
|
||||
}
|
||||
|
||||
public Stat(String name, FightProperty prop) {
|
||||
this.name = name;
|
||||
this.prop = prop;
|
||||
}
|
||||
}
|
||||
|
||||
private static enum Action {
|
||||
ACTION_SET("commands.generic.set_to", "commands.generic.set_for_to"),
|
||||
ACTION_LOCK("commands.setStats.locked_to", "commands.setStats.locked_for_to"),
|
||||
ACTION_UNLOCK("commands.setStats.unlocked", "commands.setStats.unlocked_for");
|
||||
public final String messageKeySelf;
|
||||
public final String messageKeyOther;
|
||||
private Action(String messageKeySelf, String messageKeyOther) {
|
||||
this.messageKeySelf = messageKeySelf;
|
||||
this.messageKeyOther = messageKeyOther;
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, Stat> stats;
|
||||
|
||||
public SetStatsCommand() {
|
||||
this.stats = new HashMap<>();
|
||||
for (String key : FightProperty.getShortNames()) {
|
||||
this.stats.put(key, new Stat(FightProperty.getPropByShortName(key)));
|
||||
}
|
||||
// Full FightProperty enum that won't be advertised but can be used by devs
|
||||
// They have a prefix to avoid the "hp" clash
|
||||
for (FightProperty prop : FightProperty.values()) {
|
||||
String name = prop.toString().substring(10); // FIGHT_PROP_BASE_HP -> _BASE_HP
|
||||
String key = name.toLowerCase(); // _BASE_HP -> _base_hp
|
||||
name = name.substring(1); // _BASE_HP -> BASE_HP
|
||||
this.stats.put(key, new Stat(name, prop));
|
||||
}
|
||||
|
||||
// Compatibility aliases
|
||||
this.stats.put("mhp", this.stats.get("maxhp"));
|
||||
this.stats.put("hp", new Stat(FightProperty.FIGHT_PROP_CUR_HP)); // Overrides FIGHT_PROP_HP
|
||||
this.stats.put("atk", new Stat(FightProperty.FIGHT_PROP_CUR_ATTACK)); // Overrides FIGHT_PROP_ATTACK
|
||||
this.stats.put("atkb", new Stat(FightProperty.FIGHT_PROP_BASE_ATTACK)); // This doesn't seem to get used to recalculate ATK, so it's only useful for stuff like Bennett's buff.
|
||||
this.stats.put("eanemo", this.stats.get("anemo%"));
|
||||
this.stats.put("ecryo", this.stats.get("cryo%"));
|
||||
this.stats.put("edendro", this.stats.get("dendro%"));
|
||||
this.stats.put("edend", this.stats.get("dendro%"));
|
||||
this.stats.put("eelectro", this.stats.get("electro%"));
|
||||
this.stats.put("eelec", this.stats.get("electro%"));
|
||||
this.stats.put("ethunder", this.stats.get("electro%"));
|
||||
this.stats.put("egeo", this.stats.get("geo%"));
|
||||
this.stats.put("ehydro", this.stats.get("hydro%"));
|
||||
this.stats.put("epyro", this.stats.get("pyro%"));
|
||||
this.stats.put("ephys", this.stats.get("phys%"));
|
||||
}
|
||||
|
||||
public static float parsePercent(String input) throws NumberFormatException {
|
||||
if (input.endsWith("%")) {
|
||||
return Float.parseFloat(input.substring(0, input.length()-1))/100f;
|
||||
} else {
|
||||
return Float.parseFloat(input);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Player sender, Player targetPlayer, List<String> args) {
|
||||
String statStr = null;
|
||||
String valueStr;
|
||||
float value = 0f;
|
||||
|
||||
if (args.size() < 2) {
|
||||
sendUsageMessage(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the action and stat
|
||||
String arg0 = args.remove(0).toLowerCase();
|
||||
Action action = switch (arg0) {
|
||||
default -> {statStr = arg0; yield Action.ACTION_SET;} // Implicit set command
|
||||
case "set" -> Action.ACTION_SET; // Explicit set command
|
||||
case "lock", "freeze" -> Action.ACTION_LOCK;
|
||||
case "unlock", "unfreeze" -> Action.ACTION_UNLOCK;
|
||||
};
|
||||
if (statStr == null) {
|
||||
statStr = args.remove(0).toLowerCase();
|
||||
}
|
||||
if (!stats.containsKey(statStr)) {
|
||||
sendUsageMessage(sender); // Invalid stat or action
|
||||
return;
|
||||
}
|
||||
Stat stat = stats.get(statStr);
|
||||
EntityAvatar entity = targetPlayer.getTeamManager().getCurrentAvatarEntity();
|
||||
Avatar avatar = entity.getAvatar();
|
||||
|
||||
// Get the value if the action requires it
|
||||
try {
|
||||
switch (action) {
|
||||
case ACTION_LOCK:
|
||||
if (args.isEmpty()) { // Lock to current value
|
||||
value = avatar.getFightProperty(stat.prop);
|
||||
break;
|
||||
} // Else fall-through and lock to supplied value
|
||||
case ACTION_SET:
|
||||
value = parsePercent(args.remove(0));
|
||||
break;
|
||||
case ACTION_UNLOCK:
|
||||
break;
|
||||
}
|
||||
} catch (NumberFormatException ignored) {
|
||||
CommandHandler.sendTranslatedMessage(sender, "commands.generic.invalid.statValue");
|
||||
return;
|
||||
} catch (IndexOutOfBoundsException ignored) {
|
||||
sendUsageMessage(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!args.isEmpty()) { // Leftover arguments!
|
||||
sendUsageMessage(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (action) {
|
||||
case ACTION_SET:
|
||||
entity.setFightProperty(stat.prop, value);
|
||||
entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, stat.prop));
|
||||
break;
|
||||
case ACTION_LOCK:
|
||||
avatar.getFightPropOverrides().put(stat.prop.getId(), value);
|
||||
avatar.recalcStats();
|
||||
break;
|
||||
case ACTION_UNLOCK:
|
||||
avatar.getFightPropOverrides().remove(stat.prop.getId());
|
||||
avatar.recalcStats();
|
||||
break;
|
||||
}
|
||||
|
||||
// Report action
|
||||
if (FightProperty.isPercentage(stat.prop)) {
|
||||
valueStr = String.format("%.1f%%", value * 100f);
|
||||
} else {
|
||||
valueStr = String.format("%.0f", value);
|
||||
}
|
||||
if (targetPlayer == sender) {
|
||||
CommandHandler.sendTranslatedMessage(sender, action.messageKeySelf, stat.name, valueStr);
|
||||
} else {
|
||||
String uidStr = targetPlayer.getAccount().getId();
|
||||
CommandHandler.sendTranslatedMessage(sender, action.messageKeyOther, stat.name, uidStr, valueStr);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
package emu.grasscutter.command.commands;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import emu.grasscutter.command.Command;
|
||||
import emu.grasscutter.command.CommandHandler;
|
||||
import emu.grasscutter.game.avatar.Avatar;
|
||||
import emu.grasscutter.game.entity.EntityAvatar;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.game.props.FightProperty;
|
||||
import emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify;
|
||||
|
||||
@Command(
|
||||
label = "setStats",
|
||||
aliases = {"stats", "stat"},
|
||||
usage = {
|
||||
"[set] <stat> <value>",
|
||||
"(lock|freeze) <stat> [<value>]", // Can lock to current value
|
||||
"(unlock|unfreeze) <stat>"},
|
||||
permission = "player.setstats",
|
||||
permissionTargeted = "player.setstats.others")
|
||||
public final class SetStatsCommand implements CommandHandler {
|
||||
private static class Stat {
|
||||
String name;
|
||||
FightProperty prop;
|
||||
|
||||
public Stat(FightProperty prop) {
|
||||
this.name = prop.toString();
|
||||
this.prop = prop;
|
||||
}
|
||||
|
||||
public Stat(String name, FightProperty prop) {
|
||||
this.name = name;
|
||||
this.prop = prop;
|
||||
}
|
||||
}
|
||||
|
||||
private static enum Action {
|
||||
ACTION_SET("commands.generic.set_to", "commands.generic.set_for_to"),
|
||||
ACTION_LOCK("commands.setStats.locked_to", "commands.setStats.locked_for_to"),
|
||||
ACTION_UNLOCK("commands.setStats.unlocked", "commands.setStats.unlocked_for");
|
||||
public final String messageKeySelf;
|
||||
public final String messageKeyOther;
|
||||
private Action(String messageKeySelf, String messageKeyOther) {
|
||||
this.messageKeySelf = messageKeySelf;
|
||||
this.messageKeyOther = messageKeyOther;
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, Stat> stats;
|
||||
|
||||
public SetStatsCommand() {
|
||||
this.stats = new HashMap<>();
|
||||
for (String key : FightProperty.getShortNames()) {
|
||||
this.stats.put(key, new Stat(FightProperty.getPropByShortName(key)));
|
||||
}
|
||||
// Full FightProperty enum that won't be advertised but can be used by devs
|
||||
// They have a prefix to avoid the "hp" clash
|
||||
for (FightProperty prop : FightProperty.values()) {
|
||||
String name = prop.toString().substring(10); // FIGHT_PROP_BASE_HP -> _BASE_HP
|
||||
String key = name.toLowerCase(); // _BASE_HP -> _base_hp
|
||||
name = name.substring(1); // _BASE_HP -> BASE_HP
|
||||
this.stats.put(key, new Stat(name, prop));
|
||||
}
|
||||
|
||||
// Compatibility aliases
|
||||
this.stats.put("mhp", this.stats.get("maxhp"));
|
||||
this.stats.put("hp", new Stat(FightProperty.FIGHT_PROP_CUR_HP)); // Overrides FIGHT_PROP_HP
|
||||
this.stats.put("atk", new Stat(FightProperty.FIGHT_PROP_CUR_ATTACK)); // Overrides FIGHT_PROP_ATTACK
|
||||
this.stats.put("atkb", new Stat(FightProperty.FIGHT_PROP_BASE_ATTACK)); // This doesn't seem to get used to recalculate ATK, so it's only useful for stuff like Bennett's buff.
|
||||
this.stats.put("eanemo", this.stats.get("anemo%"));
|
||||
this.stats.put("ecryo", this.stats.get("cryo%"));
|
||||
this.stats.put("edendro", this.stats.get("dendro%"));
|
||||
this.stats.put("edend", this.stats.get("dendro%"));
|
||||
this.stats.put("eelectro", this.stats.get("electro%"));
|
||||
this.stats.put("eelec", this.stats.get("electro%"));
|
||||
this.stats.put("ethunder", this.stats.get("electro%"));
|
||||
this.stats.put("egeo", this.stats.get("geo%"));
|
||||
this.stats.put("ehydro", this.stats.get("hydro%"));
|
||||
this.stats.put("epyro", this.stats.get("pyro%"));
|
||||
this.stats.put("ephys", this.stats.get("phys%"));
|
||||
}
|
||||
|
||||
public static float parsePercent(String input) throws NumberFormatException {
|
||||
if (input.endsWith("%")) {
|
||||
return Float.parseFloat(input.substring(0, input.length()-1))/100f;
|
||||
} else {
|
||||
return Float.parseFloat(input);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Player sender, Player targetPlayer, List<String> args) {
|
||||
String statStr = null;
|
||||
String valueStr;
|
||||
float value = 0f;
|
||||
|
||||
if (args.size() < 2) {
|
||||
sendUsageMessage(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the action and stat
|
||||
String arg0 = args.remove(0).toLowerCase();
|
||||
Action action = switch (arg0) {
|
||||
default -> {statStr = arg0; yield Action.ACTION_SET;} // Implicit set command
|
||||
case "set" -> Action.ACTION_SET; // Explicit set command
|
||||
case "lock", "freeze" -> Action.ACTION_LOCK;
|
||||
case "unlock", "unfreeze" -> Action.ACTION_UNLOCK;
|
||||
};
|
||||
if (statStr == null) {
|
||||
statStr = args.remove(0).toLowerCase();
|
||||
}
|
||||
if (!stats.containsKey(statStr)) {
|
||||
sendUsageMessage(sender); // Invalid stat or action
|
||||
return;
|
||||
}
|
||||
Stat stat = stats.get(statStr);
|
||||
EntityAvatar entity = targetPlayer.getTeamManager().getCurrentAvatarEntity();
|
||||
Avatar avatar = entity.getAvatar();
|
||||
|
||||
// Get the value if the action requires it
|
||||
try {
|
||||
switch (action) {
|
||||
case ACTION_LOCK:
|
||||
if (args.isEmpty()) { // Lock to current value
|
||||
value = avatar.getFightProperty(stat.prop);
|
||||
break;
|
||||
} // Else fall-through and lock to supplied value
|
||||
case ACTION_SET:
|
||||
value = parsePercent(args.remove(0));
|
||||
break;
|
||||
case ACTION_UNLOCK:
|
||||
break;
|
||||
}
|
||||
} catch (NumberFormatException ignored) {
|
||||
CommandHandler.sendTranslatedMessage(sender, "commands.generic.invalid.statValue");
|
||||
return;
|
||||
} catch (IndexOutOfBoundsException ignored) {
|
||||
sendUsageMessage(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!args.isEmpty()) { // Leftover arguments!
|
||||
sendUsageMessage(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (action) {
|
||||
case ACTION_SET:
|
||||
entity.setFightProperty(stat.prop, value);
|
||||
entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, stat.prop));
|
||||
break;
|
||||
case ACTION_LOCK:
|
||||
avatar.getFightPropOverrides().put(stat.prop.getId(), value);
|
||||
avatar.recalcStats();
|
||||
break;
|
||||
case ACTION_UNLOCK:
|
||||
avatar.getFightPropOverrides().remove(stat.prop.getId());
|
||||
avatar.recalcStats();
|
||||
break;
|
||||
}
|
||||
|
||||
// Report action
|
||||
if (FightProperty.isPercentage(stat.prop)) {
|
||||
valueStr = String.format("%.1f%%", value * 100f);
|
||||
} else {
|
||||
valueStr = String.format("%.0f", value);
|
||||
}
|
||||
if (targetPlayer == sender) {
|
||||
CommandHandler.sendTranslatedMessage(sender, action.messageKeySelf, stat.name, valueStr);
|
||||
} else {
|
||||
String uidStr = targetPlayer.getAccount().getId();
|
||||
CommandHandler.sendTranslatedMessage(sender, action.messageKeyOther, stat.name, uidStr, valueStr);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,102 +1,102 @@
|
||||
package emu.grasscutter.command.commands;
|
||||
|
||||
import emu.grasscutter.command.Command;
|
||||
import emu.grasscutter.command.CommandHandler;
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.excels.AvatarSkillDepotData;
|
||||
import emu.grasscutter.game.avatar.Avatar;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.utils.Language;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Command(
|
||||
label = "talent",
|
||||
usage = {"set <talentId> <level>", "(n|e|q) <level>", "getid"},
|
||||
permission = "player.settalent",
|
||||
permissionTargeted = "player.settalent.others")
|
||||
public final class TalentCommand implements CommandHandler {
|
||||
private void setTalentLevel(Player sender, Avatar avatar, int skillId, int newLevel) {
|
||||
if (avatar.setSkillLevel(skillId, newLevel)) {
|
||||
long nameHash = GameData.getAvatarSkillDataMap().get(skillId).getNameTextMapHash();
|
||||
var name = Language.getTextMapKey(nameHash);
|
||||
CommandHandler.sendTranslatedMessage(sender, "commands.talent.set_id", skillId, name, newLevel);
|
||||
} else {
|
||||
CommandHandler.sendTranslatedMessage(sender, "commands.talent.lower_16");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Player sender, Player targetPlayer, List<String> args) {
|
||||
if (args.size() < 1){
|
||||
sendUsageMessage(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
Avatar avatar = targetPlayer.getTeamManager().getCurrentAvatarEntity().getAvatar();
|
||||
AvatarSkillDepotData skillDepot = avatar.getSkillDepot();
|
||||
if (skillDepot == null) { // Avatars without skill depots aren't a suitable target even with manual skillId specified
|
||||
CommandHandler.sendTranslatedMessage(sender, "commands.talent.invalid_skill_id");
|
||||
return;
|
||||
}
|
||||
int skillId = 0;
|
||||
int newLevel = -1;
|
||||
|
||||
String cmdSwitch = args.get(0).toLowerCase();
|
||||
switch (cmdSwitch) {
|
||||
default -> {
|
||||
sendUsageMessage(sender);
|
||||
return;
|
||||
}
|
||||
case "set" -> {
|
||||
if (args.size() < 3) {
|
||||
sendUsageMessage(sender);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
skillId = Integer.parseInt(args.get(1));
|
||||
} catch (NumberFormatException ignored) {
|
||||
CommandHandler.sendTranslatedMessage(sender, "commands.talent.invalid_skill_id");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
newLevel = Integer.parseInt(args.get(2));
|
||||
} catch (NumberFormatException ignored) {
|
||||
CommandHandler.sendTranslatedMessage(sender, "commands.talent.invalid_level");
|
||||
return;
|
||||
}
|
||||
|
||||
setTalentLevel(sender, avatar, skillId, newLevel);
|
||||
}
|
||||
case "n", "e", "q" -> {
|
||||
if (args.size() < 2) {
|
||||
sendUsageMessage(sender);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
newLevel = Integer.parseInt(args.get(1));
|
||||
} catch (NumberFormatException ignored) {
|
||||
CommandHandler.sendTranslatedMessage(sender, "commands.talent.invalid_level");
|
||||
return;
|
||||
}
|
||||
|
||||
skillId = switch (cmdSwitch) {
|
||||
default -> skillDepot.getSkills().get(0);
|
||||
case "e" -> skillDepot.getSkills().get(1);
|
||||
case "q" -> skillDepot.getEnergySkill();
|
||||
};
|
||||
setTalentLevel(sender, avatar, skillId, newLevel);
|
||||
}
|
||||
case "getid" -> {
|
||||
var map = GameData.getAvatarSkillDataMap();
|
||||
skillDepot.getSkillsAndEnergySkill().forEach(id -> {
|
||||
var talent = map.get(id);
|
||||
if (talent == null) return;
|
||||
var talentName = Language.getTextMapKey(talent.getNameTextMapHash());
|
||||
var talentDesc = Language.getTextMapKey(talent.getDescTextMapHash());
|
||||
CommandHandler.sendTranslatedMessage(sender, "commands.talent.id_desc", id, talentName, talentDesc);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
package emu.grasscutter.command.commands;
|
||||
|
||||
import emu.grasscutter.command.Command;
|
||||
import emu.grasscutter.command.CommandHandler;
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.excels.AvatarSkillDepotData;
|
||||
import emu.grasscutter.game.avatar.Avatar;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.utils.Language;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Command(
|
||||
label = "talent",
|
||||
usage = {"set <talentId> <level>", "(n|e|q) <level>", "getid"},
|
||||
permission = "player.settalent",
|
||||
permissionTargeted = "player.settalent.others")
|
||||
public final class TalentCommand implements CommandHandler {
|
||||
private void setTalentLevel(Player sender, Avatar avatar, int skillId, int newLevel) {
|
||||
if (avatar.setSkillLevel(skillId, newLevel)) {
|
||||
long nameHash = GameData.getAvatarSkillDataMap().get(skillId).getNameTextMapHash();
|
||||
var name = Language.getTextMapKey(nameHash);
|
||||
CommandHandler.sendTranslatedMessage(sender, "commands.talent.set_id", skillId, name, newLevel);
|
||||
} else {
|
||||
CommandHandler.sendTranslatedMessage(sender, "commands.talent.lower_16");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Player sender, Player targetPlayer, List<String> args) {
|
||||
if (args.size() < 1) {
|
||||
sendUsageMessage(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
Avatar avatar = targetPlayer.getTeamManager().getCurrentAvatarEntity().getAvatar();
|
||||
AvatarSkillDepotData skillDepot = avatar.getSkillDepot();
|
||||
if (skillDepot == null) { // Avatars without skill depots aren't a suitable target even with manual skillId specified
|
||||
CommandHandler.sendTranslatedMessage(sender, "commands.talent.invalid_skill_id");
|
||||
return;
|
||||
}
|
||||
int skillId = 0;
|
||||
int newLevel = -1;
|
||||
|
||||
String cmdSwitch = args.get(0).toLowerCase();
|
||||
switch (cmdSwitch) {
|
||||
default -> {
|
||||
sendUsageMessage(sender);
|
||||
return;
|
||||
}
|
||||
case "set" -> {
|
||||
if (args.size() < 3) {
|
||||
sendUsageMessage(sender);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
skillId = Integer.parseInt(args.get(1));
|
||||
} catch (NumberFormatException ignored) {
|
||||
CommandHandler.sendTranslatedMessage(sender, "commands.talent.invalid_skill_id");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
newLevel = Integer.parseInt(args.get(2));
|
||||
} catch (NumberFormatException ignored) {
|
||||
CommandHandler.sendTranslatedMessage(sender, "commands.talent.invalid_level");
|
||||
return;
|
||||
}
|
||||
|
||||
setTalentLevel(sender, avatar, skillId, newLevel);
|
||||
}
|
||||
case "n", "e", "q" -> {
|
||||
if (args.size() < 2) {
|
||||
sendUsageMessage(sender);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
newLevel = Integer.parseInt(args.get(1));
|
||||
} catch (NumberFormatException ignored) {
|
||||
CommandHandler.sendTranslatedMessage(sender, "commands.talent.invalid_level");
|
||||
return;
|
||||
}
|
||||
|
||||
skillId = switch (cmdSwitch) {
|
||||
default -> skillDepot.getSkills().get(0);
|
||||
case "e" -> skillDepot.getSkills().get(1);
|
||||
case "q" -> skillDepot.getEnergySkill();
|
||||
};
|
||||
setTalentLevel(sender, avatar, skillId, newLevel);
|
||||
}
|
||||
case "getid" -> {
|
||||
var map = GameData.getAvatarSkillDataMap();
|
||||
skillDepot.getSkillsAndEnergySkill().forEach(id -> {
|
||||
var talent = map.get(id);
|
||||
if (talent == null) return;
|
||||
var talentName = Language.getTextMapKey(talent.getNameTextMapHash());
|
||||
var talentDesc = Language.getTextMapKey(talent.getDescTextMapHash());
|
||||
CommandHandler.sendTranslatedMessage(sender, "commands.talent.id_desc", id, talentName, talentDesc);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,4 +38,4 @@ public final class UnBanCommand implements CommandHandler {
|
||||
CommandHandler.sendTranslatedMessage(sender, "commands.unban.failure");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,13 +27,13 @@ public final class UnlockAllCommand implements CommandHandler {
|
||||
}
|
||||
|
||||
if (targetPlayer.getProgressManager().getOpenState(state.getId()) == 0) {
|
||||
targetPlayer.getOpenStates().put(state.getId(), 1);
|
||||
targetPlayer.getOpenStates().put(state.getId(), 1);
|
||||
changed.put(state.getId(), 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
targetPlayer.sendPacket(new PacketOpenStateChangeNotify(changed));
|
||||
|
||||
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.unlockall.success", targetPlayer.getNickname()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,454 +19,454 @@ import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import lombok.Getter;
|
||||
|
||||
public class GameData {
|
||||
// BinOutputs
|
||||
private static final Int2ObjectMap<String> abilityHashes = new Int2ObjectOpenHashMap<>();
|
||||
private static final Map<String, AbilityEmbryoEntry> abilityEmbryos = new HashMap<>();
|
||||
private static final Map<String, AbilityModifierEntry> abilityModifiers = new HashMap<>();
|
||||
private static final Map<String, OpenConfigEntry> openConfigEntries = new HashMap<>();
|
||||
private static final Map<String, ScenePointEntry> scenePointEntries = new HashMap<>();
|
||||
private static final Int2ObjectMap<MainQuestData> mainQuestData = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<QuestEncryptionKey> questsKeys = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<HomeworldDefaultSaveData> homeworldDefaultSaveData = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<SceneNpcBornData> npcBornData = new Int2ObjectOpenHashMap<>();
|
||||
// BinOutputs
|
||||
private static final Int2ObjectMap<String> abilityHashes = new Int2ObjectOpenHashMap<>();
|
||||
private static final Map<String, AbilityEmbryoEntry> abilityEmbryos = new HashMap<>();
|
||||
private static final Map<String, AbilityModifierEntry> abilityModifiers = new HashMap<>();
|
||||
private static final Map<String, OpenConfigEntry> openConfigEntries = new HashMap<>();
|
||||
private static final Map<String, ScenePointEntry> scenePointEntries = new HashMap<>();
|
||||
private static final Int2ObjectMap<MainQuestData> mainQuestData = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<QuestEncryptionKey> questsKeys = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<HomeworldDefaultSaveData> homeworldDefaultSaveData = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<SceneNpcBornData> npcBornData = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
// ExcelConfigs
|
||||
private static final Int2ObjectMap<PlayerLevelData> playerLevelDataMap = new Int2ObjectOpenHashMap<>();
|
||||
// ExcelConfigs
|
||||
private static final Int2ObjectMap<PlayerLevelData> playerLevelDataMap = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
private static final Int2ObjectMap<AvatarData> avatarDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<AvatarLevelData> avatarLevelDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<AvatarSkillDepotData> avatarSkillDepotDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<AvatarSkillData> avatarSkillDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<AvatarCurveData> avatarCurveDataMap = new Int2ObjectLinkedOpenHashMap<>();
|
||||
private static final Int2ObjectMap<AvatarFetterLevelData> avatarFetterLevelDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<AvatarPromoteData> avatarPromoteDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<AvatarTalentData> avatarTalentDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<ProudSkillData> proudSkillDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<AvatarData> avatarDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<AvatarLevelData> avatarLevelDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<AvatarSkillDepotData> avatarSkillDepotDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<AvatarSkillData> avatarSkillDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<AvatarCurveData> avatarCurveDataMap = new Int2ObjectLinkedOpenHashMap<>();
|
||||
private static final Int2ObjectMap<AvatarFetterLevelData> avatarFetterLevelDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<AvatarPromoteData> avatarPromoteDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<AvatarTalentData> avatarTalentDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<ProudSkillData> proudSkillDataMap = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
private static final Int2ObjectMap<ItemData> itemDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<ReliquaryLevelData> reliquaryLevelDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<ReliquaryAffixData> reliquaryAffixDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<ReliquaryMainPropData> reliquaryMainPropDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<ReliquarySetData> reliquarySetDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<WeaponLevelData> weaponLevelDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<WeaponPromoteData> weaponPromoteDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<WeaponCurveData> weaponCurveDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<EquipAffixData> equipAffixDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<ItemData> itemDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<ReliquaryLevelData> reliquaryLevelDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<ReliquaryAffixData> reliquaryAffixDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<ReliquaryMainPropData> reliquaryMainPropDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<ReliquarySetData> reliquarySetDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<WeaponLevelData> weaponLevelDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<WeaponPromoteData> weaponPromoteDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<WeaponCurveData> weaponCurveDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<EquipAffixData> equipAffixDataMap = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
private static final Int2ObjectMap<EnvAnimalGatherConfigData> envAnimalGatherConfigDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<MonsterData> monsterDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<NpcData> npcDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<GadgetData> gadgetDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<MonsterCurveData> monsterCurveDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<MonsterDescribeData> monsterDescribeDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<EnvAnimalGatherConfigData> envAnimalGatherConfigDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<MonsterData> monsterDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<NpcData> npcDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<GadgetData> gadgetDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<MonsterCurveData> monsterCurveDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<MonsterDescribeData> monsterDescribeDataMap = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
private static final Int2ObjectMap<AvatarFlycloakData> avatarFlycloakDataMap = new Int2ObjectLinkedOpenHashMap<>();
|
||||
private static final Int2ObjectMap<AvatarCostumeData> avatarCostumeDataMap = new Int2ObjectLinkedOpenHashMap<>();
|
||||
private static final Int2ObjectMap<AvatarCostumeData> avatarCostumeDataItemIdMap = new Int2ObjectLinkedOpenHashMap<>();
|
||||
private static final Int2ObjectMap<AvatarFlycloakData> avatarFlycloakDataMap = new Int2ObjectLinkedOpenHashMap<>();
|
||||
private static final Int2ObjectMap<AvatarCostumeData> avatarCostumeDataMap = new Int2ObjectLinkedOpenHashMap<>();
|
||||
private static final Int2ObjectMap<AvatarCostumeData> avatarCostumeDataItemIdMap = new Int2ObjectLinkedOpenHashMap<>();
|
||||
|
||||
private static final Int2ObjectMap<SceneData> sceneDataMap = new Int2ObjectLinkedOpenHashMap<>();
|
||||
private static final Int2ObjectMap<FetterData> fetterDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<CodexQuestData> codexQuestDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<CodexQuestData> codexQuestDataIdMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<CodexAnimalData> codexAnimalDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<CodexWeaponData> codexWeaponDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<CodexWeaponData> codexWeaponDataIdMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<CodexMaterialData> codexMaterialDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<CodexMaterialData> codexMaterialDataIdMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<CodexReliquaryData> codexReliquaryDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<CodexReliquaryData> codexReliquaryDataIdMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final ArrayList<CodexReliquaryData> codexReliquaryArrayList = new ArrayList<>();
|
||||
private static final Int2ObjectMap<FetterCharacterCardData> fetterCharacterCardDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<RewardData> rewardDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<SceneData> sceneDataMap = new Int2ObjectLinkedOpenHashMap<>();
|
||||
private static final Int2ObjectMap<FetterData> fetterDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<CodexQuestData> codexQuestDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<CodexQuestData> codexQuestDataIdMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<CodexAnimalData> codexAnimalDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<CodexWeaponData> codexWeaponDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<CodexWeaponData> codexWeaponDataIdMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<CodexMaterialData> codexMaterialDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<CodexMaterialData> codexMaterialDataIdMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<CodexReliquaryData> codexReliquaryDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<CodexReliquaryData> codexReliquaryDataIdMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final ArrayList<CodexReliquaryData> codexReliquaryArrayList = new ArrayList<>();
|
||||
private static final Int2ObjectMap<FetterCharacterCardData> fetterCharacterCardDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<RewardData> rewardDataMap = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
private static final Int2ObjectMap<WorldAreaData> worldAreaDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<WorldLevelData> worldLevelDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<DailyDungeonData> dailyDungeonDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<DungeonEntryData> dungeonEntryDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<WorldAreaData> worldAreaDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<WorldLevelData> worldLevelDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<DailyDungeonData> dailyDungeonDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<DungeonEntryData> dungeonEntryDataMap = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
private static final Int2ObjectMap<DungeonData> dungeonDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<QuestData> questDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<ShopGoodsData> shopGoodsDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<CombineData> combineDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<RewardPreviewData> rewardPreviewDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<GatherData> gatherDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<TowerFloorData> towerFloorDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<TowerLevelData> towerLevelDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<TowerScheduleData> towerScheduleDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<BuffData> buffDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<ForgeData> forgeDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<HomeWorldLevelData> homeWorldLevelDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<FurnitureMakeConfigData> furnitureMakeConfigDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<InvestigationMonsterData> investigationMonsterDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<CityData> cityDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<WeatherData> weatherDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<BattlePassMissionData> battlePassMissionDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<BattlePassRewardData> battlePassRewardDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<CookRecipeData> cookRecipeDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<CookBonusData> cookBonusDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<DungeonData> dungeonDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<QuestData> questDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<ShopGoodsData> shopGoodsDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<CombineData> combineDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<RewardPreviewData> rewardPreviewDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<GatherData> gatherDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<TowerFloorData> towerFloorDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<TowerLevelData> towerLevelDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<TowerScheduleData> towerScheduleDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<BuffData> buffDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<ForgeData> forgeDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<HomeWorldLevelData> homeWorldLevelDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<FurnitureMakeConfigData> furnitureMakeConfigDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<InvestigationMonsterData> investigationMonsterDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<CityData> cityDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<WeatherData> weatherDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<BattlePassMissionData> battlePassMissionDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<BattlePassRewardData> battlePassRewardDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<CookRecipeData> cookRecipeDataMap = new Int2ObjectOpenHashMap<>();
|
||||
private static final Int2ObjectMap<CookBonusData> cookBonusDataMap = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
@Getter private static final Int2ObjectMap<ActivityData> activityDataMap = new Int2ObjectOpenHashMap<>();
|
||||
@Getter private static final Int2ObjectMap<ActivityData> activityDataMap = new Int2ObjectOpenHashMap<>();
|
||||
@Getter private static final Int2ObjectMap<ActivityWatcherData> activityWatcherDataMap = new Int2ObjectOpenHashMap<>();
|
||||
@Getter private static final Int2ObjectMap<MusicGameBasicData> musicGameBasicDataMap = new Int2ObjectOpenHashMap<>();
|
||||
@Getter private static final Int2ObjectMap<PersonalLineData> personalLineDataMap = new Int2ObjectOpenHashMap<>();
|
||||
@Getter private static final Int2ObjectMap<ChapterData> chapterDataMap = new Int2ObjectOpenHashMap<>();
|
||||
@Getter private static final Int2ObjectMap<TriggerExcelConfigData> triggerExcelConfigDataMap = new Int2ObjectOpenHashMap<>();
|
||||
@Getter private static final Map<String,ScriptSceneData> scriptSceneDataMap = new HashMap<>();
|
||||
@Getter private static final Map<Integer, List<Integer>> scenePointsPerScene = new HashMap<>();
|
||||
@Getter private static final Map<Integer, List<Integer>> scenePointsPerScene = new HashMap<>();
|
||||
@Getter private static final Int2ObjectMap<BlossomRefreshExcelConfigData> blossomRefreshExcelConfigDataMap = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
@Getter private static final Int2ObjectMap<OpenStateData> openStateDataMap = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
// Cache
|
||||
private static Map<Integer, List<Integer>> fetters = new HashMap<>();
|
||||
private static Map<Integer, List<ShopGoodsData>> shopGoods = new HashMap<>();
|
||||
private static final IntList scenePointIdList = new IntArrayList();
|
||||
// Cache
|
||||
private static Map<Integer, List<Integer>> fetters = new HashMap<>();
|
||||
private static Map<Integer, List<ShopGoodsData>> shopGoods = new HashMap<>();
|
||||
private static final IntList scenePointIdList = new IntArrayList();
|
||||
|
||||
|
||||
|
||||
@Getter private static final List<OpenStateData> openStateList = new ArrayList<>();
|
||||
@Getter private static final List<OpenStateData> openStateList = new ArrayList<>();
|
||||
|
||||
|
||||
public static Int2ObjectMap<?> getMapByResourceDef(Class<?> resourceDefinition) {
|
||||
Int2ObjectMap<?> map = null;
|
||||
public static Int2ObjectMap<?> getMapByResourceDef(Class<?> resourceDefinition) {
|
||||
Int2ObjectMap<?> map = null;
|
||||
|
||||
try {
|
||||
Field field = GameData.class.getDeclaredField(Utils.lowerCaseFirstChar(resourceDefinition.getSimpleName()) + "Map");
|
||||
field.setAccessible(true);
|
||||
try {
|
||||
Field field = GameData.class.getDeclaredField(Utils.lowerCaseFirstChar(resourceDefinition.getSimpleName()) + "Map");
|
||||
field.setAccessible(true);
|
||||
|
||||
map = (Int2ObjectMap<?>) field.get(null);
|
||||
map = (Int2ObjectMap<?>) field.get(null);
|
||||
|
||||
field.setAccessible(false);
|
||||
} catch (Exception e) {
|
||||
Grasscutter.getLogger().error("Error fetching resource map for " + resourceDefinition.getSimpleName(), e);
|
||||
}
|
||||
field.setAccessible(false);
|
||||
} catch (Exception e) {
|
||||
Grasscutter.getLogger().error("Error fetching resource map for " + resourceDefinition.getSimpleName(), e);
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<String> getAbilityHashes() {
|
||||
return abilityHashes;
|
||||
}
|
||||
public static Int2ObjectMap<String> getAbilityHashes() {
|
||||
return abilityHashes;
|
||||
}
|
||||
|
||||
public static Map<String, AbilityEmbryoEntry> getAbilityEmbryoInfo() {
|
||||
return abilityEmbryos;
|
||||
}
|
||||
public static Map<String, AbilityEmbryoEntry> getAbilityEmbryoInfo() {
|
||||
return abilityEmbryos;
|
||||
}
|
||||
|
||||
public static Map<String, AbilityModifierEntry> getAbilityModifiers() {
|
||||
return abilityModifiers;
|
||||
}
|
||||
public static Map<String, AbilityModifierEntry> getAbilityModifiers() {
|
||||
return abilityModifiers;
|
||||
}
|
||||
|
||||
public static Map<String, OpenConfigEntry> getOpenConfigEntries() {
|
||||
return openConfigEntries;
|
||||
}
|
||||
public static Map<String, OpenConfigEntry> getOpenConfigEntries() {
|
||||
return openConfigEntries;
|
||||
}
|
||||
|
||||
public static Map<String, ScenePointEntry> getScenePointEntries() {
|
||||
return scenePointEntries;
|
||||
}
|
||||
public static Map<String, ScenePointEntry> getScenePointEntries() {
|
||||
return scenePointEntries;
|
||||
}
|
||||
|
||||
// TODO optimize
|
||||
public static ScenePointEntry getScenePointEntryById(int sceneId, int pointId) {
|
||||
return getScenePointEntries().get(sceneId + "_" + pointId);
|
||||
}
|
||||
// TODO optimize
|
||||
public static ScenePointEntry getScenePointEntryById(int sceneId, int pointId) {
|
||||
return getScenePointEntries().get(sceneId + "_" + pointId);
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<MainQuestData> getMainQuestDataMap() {
|
||||
return mainQuestData;
|
||||
}
|
||||
public static Int2ObjectMap<MainQuestData> getMainQuestDataMap() {
|
||||
return mainQuestData;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<QuestEncryptionKey> getMainQuestEncryptionMap() {
|
||||
return questsKeys;
|
||||
}
|
||||
public static Int2ObjectMap<QuestEncryptionKey> getMainQuestEncryptionMap() {
|
||||
return questsKeys;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<HomeworldDefaultSaveData> getHomeworldDefaultSaveData() {
|
||||
return homeworldDefaultSaveData;
|
||||
}
|
||||
public static Int2ObjectMap<HomeworldDefaultSaveData> getHomeworldDefaultSaveData() {
|
||||
return homeworldDefaultSaveData;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<SceneNpcBornData> getSceneNpcBornData() {
|
||||
return npcBornData;
|
||||
}
|
||||
public static Int2ObjectMap<SceneNpcBornData> getSceneNpcBornData() {
|
||||
return npcBornData;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<AvatarData> getAvatarDataMap() {
|
||||
return avatarDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<ItemData> getItemDataMap() {
|
||||
return itemDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<AvatarSkillDepotData> getAvatarSkillDepotDataMap() {
|
||||
return avatarSkillDepotDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<AvatarSkillData> getAvatarSkillDataMap() {
|
||||
return avatarSkillDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<PlayerLevelData> getPlayerLevelDataMap() {
|
||||
return playerLevelDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<AvatarFetterLevelData> getAvatarFetterLevelDataMap() {
|
||||
return avatarFetterLevelDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<FetterCharacterCardData> getFetterCharacterCardDataMap() {
|
||||
return fetterCharacterCardDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<AvatarLevelData> getAvatarLevelDataMap() {
|
||||
return avatarLevelDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<WeaponLevelData> getWeaponLevelDataMap() {
|
||||
return weaponLevelDataMap;
|
||||
}
|
||||
public static Int2ObjectMap<AvatarData> getAvatarDataMap() {
|
||||
return avatarDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<ItemData> getItemDataMap() {
|
||||
return itemDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<AvatarSkillDepotData> getAvatarSkillDepotDataMap() {
|
||||
return avatarSkillDepotDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<AvatarSkillData> getAvatarSkillDataMap() {
|
||||
return avatarSkillDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<PlayerLevelData> getPlayerLevelDataMap() {
|
||||
return playerLevelDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<AvatarFetterLevelData> getAvatarFetterLevelDataMap() {
|
||||
return avatarFetterLevelDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<FetterCharacterCardData> getFetterCharacterCardDataMap() {
|
||||
return fetterCharacterCardDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<AvatarLevelData> getAvatarLevelDataMap() {
|
||||
return avatarLevelDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<WeaponLevelData> getWeaponLevelDataMap() {
|
||||
return weaponLevelDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<ReliquaryAffixData> getReliquaryAffixDataMap() {
|
||||
return reliquaryAffixDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<ReliquaryMainPropData> getReliquaryMainPropDataMap() {
|
||||
return reliquaryMainPropDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<WeaponPromoteData> getWeaponPromoteDataMap() {
|
||||
return weaponPromoteDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<WeaponCurveData> getWeaponCurveDataMap() {
|
||||
return weaponCurveDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<AvatarCurveData> getAvatarCurveDataMap() {
|
||||
return avatarCurveDataMap;
|
||||
}
|
||||
|
||||
public static int getRelicExpRequired(int rankLevel, int level) {
|
||||
ReliquaryLevelData levelData = reliquaryLevelDataMap.get((rankLevel << 8) + level);
|
||||
return levelData != null ? levelData.getExp() : 0;
|
||||
}
|
||||
|
||||
public static ReliquaryLevelData getRelicLevelData(int rankLevel, int level) {
|
||||
return reliquaryLevelDataMap.get((rankLevel << 8) + level);
|
||||
}
|
||||
|
||||
public static WeaponPromoteData getWeaponPromoteData(int promoteId, int promoteLevel) {
|
||||
return weaponPromoteDataMap.get((promoteId << 8) + promoteLevel);
|
||||
}
|
||||
|
||||
public static int getWeaponExpRequired(int rankLevel, int level) {
|
||||
WeaponLevelData levelData = weaponLevelDataMap.get(level);
|
||||
if (levelData == null) {
|
||||
return 0;
|
||||
}
|
||||
try {
|
||||
return levelData.getRequiredExps()[rankLevel - 1];
|
||||
} catch (Exception e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static AvatarPromoteData getAvatarPromoteData(int promoteId, int promoteLevel) {
|
||||
return avatarPromoteDataMap.get((promoteId << 8) + promoteLevel);
|
||||
}
|
||||
|
||||
public static int getAvatarLevelExpRequired(int level) {
|
||||
AvatarLevelData levelData = avatarLevelDataMap.get(level);
|
||||
return levelData != null ? levelData.getExp() : 0;
|
||||
}
|
||||
|
||||
public static int getAvatarFetterLevelExpRequired(int level) {
|
||||
AvatarFetterLevelData levelData = avatarFetterLevelDataMap.get(level);
|
||||
return levelData != null ? levelData.getExp() : 0;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<ProudSkillData> getProudSkillDataMap() {
|
||||
return proudSkillDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<MonsterData> getMonsterDataMap() {
|
||||
return monsterDataMap;
|
||||
}
|
||||
public static Int2ObjectMap<EnvAnimalGatherConfigData> getEnvAnimalGatherConfigDataMap() {
|
||||
return envAnimalGatherConfigDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<NpcData> getNpcDataMap() {
|
||||
return npcDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<GadgetData> getGadgetDataMap() {
|
||||
return gadgetDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<ReliquarySetData> getReliquarySetDataMap() {
|
||||
return reliquarySetDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<EquipAffixData> getEquipAffixDataMap() {
|
||||
return equipAffixDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<MonsterCurveData> getMonsterCurveDataMap() {
|
||||
return monsterCurveDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<MonsterDescribeData> getMonsterDescribeDataMap() {
|
||||
return monsterDescribeDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<AvatarTalentData> getAvatarTalentDataMap() {
|
||||
return avatarTalentDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<AvatarFlycloakData> getAvatarFlycloakDataMap() {
|
||||
return avatarFlycloakDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<AvatarCostumeData> getAvatarCostumeDataMap() {
|
||||
return avatarCostumeDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<AvatarCostumeData> getAvatarCostumeDataItemIdMap() {
|
||||
return avatarCostumeDataItemIdMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<SceneData> getSceneDataMap() {
|
||||
return sceneDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<RewardData> getRewardDataMap() {
|
||||
return rewardDataMap;
|
||||
}
|
||||
|
||||
public static Map<Integer, List<Integer>> getFetterDataEntries() {
|
||||
if (fetters.isEmpty()) {
|
||||
fetterDataMap.forEach((k, v) -> {
|
||||
if (!fetters.containsKey(v.getAvatarId())) {
|
||||
fetters.put(v.getAvatarId(), new ArrayList<>());
|
||||
}
|
||||
fetters.get(v.getAvatarId()).add(k);
|
||||
});
|
||||
}
|
||||
|
||||
return fetters;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<CodexQuestData> getCodexQuestDataIdMap(){return codexQuestDataIdMap;}
|
||||
|
||||
public static Int2ObjectMap<CodexAnimalData> getCodexAnimalDataMap(){return codexAnimalDataMap;}
|
||||
|
||||
public static Int2ObjectMap<CodexWeaponData> getCodexWeaponDataIdMap(){return codexWeaponDataIdMap;}
|
||||
|
||||
public static Int2ObjectMap<CodexMaterialData> getCodexMaterialDataIdMap(){return codexMaterialDataIdMap;}
|
||||
|
||||
public static Int2ObjectMap<CodexReliquaryData> getcodexReliquaryIdMap(){return codexReliquaryDataIdMap;}
|
||||
|
||||
public static ArrayList<CodexReliquaryData> getcodexReliquaryArrayList(){return codexReliquaryArrayList;}
|
||||
public static Int2ObjectMap<ReliquaryAffixData> getReliquaryAffixDataMap() {
|
||||
return reliquaryAffixDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<ReliquaryMainPropData> getReliquaryMainPropDataMap() {
|
||||
return reliquaryMainPropDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<WeaponPromoteData> getWeaponPromoteDataMap() {
|
||||
return weaponPromoteDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<WeaponCurveData> getWeaponCurveDataMap() {
|
||||
return weaponCurveDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<AvatarCurveData> getAvatarCurveDataMap() {
|
||||
return avatarCurveDataMap;
|
||||
}
|
||||
|
||||
public static int getRelicExpRequired(int rankLevel, int level) {
|
||||
ReliquaryLevelData levelData = reliquaryLevelDataMap.get((rankLevel << 8) + level);
|
||||
return levelData != null ? levelData.getExp() : 0;
|
||||
}
|
||||
|
||||
public static ReliquaryLevelData getRelicLevelData(int rankLevel, int level) {
|
||||
return reliquaryLevelDataMap.get((rankLevel << 8) + level);
|
||||
}
|
||||
|
||||
public static WeaponPromoteData getWeaponPromoteData(int promoteId, int promoteLevel) {
|
||||
return weaponPromoteDataMap.get((promoteId << 8) + promoteLevel);
|
||||
}
|
||||
|
||||
public static int getWeaponExpRequired(int rankLevel, int level) {
|
||||
WeaponLevelData levelData = weaponLevelDataMap.get(level);
|
||||
if (levelData == null) {
|
||||
return 0;
|
||||
}
|
||||
try {
|
||||
return levelData.getRequiredExps()[rankLevel - 1];
|
||||
} catch (Exception e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static AvatarPromoteData getAvatarPromoteData(int promoteId, int promoteLevel) {
|
||||
return avatarPromoteDataMap.get((promoteId << 8) + promoteLevel);
|
||||
}
|
||||
|
||||
public static int getAvatarLevelExpRequired(int level) {
|
||||
AvatarLevelData levelData = avatarLevelDataMap.get(level);
|
||||
return levelData != null ? levelData.getExp() : 0;
|
||||
}
|
||||
|
||||
public static int getAvatarFetterLevelExpRequired(int level) {
|
||||
AvatarFetterLevelData levelData = avatarFetterLevelDataMap.get(level);
|
||||
return levelData != null ? levelData.getExp() : 0;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<ProudSkillData> getProudSkillDataMap() {
|
||||
return proudSkillDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<MonsterData> getMonsterDataMap() {
|
||||
return monsterDataMap;
|
||||
}
|
||||
public static Int2ObjectMap<EnvAnimalGatherConfigData> getEnvAnimalGatherConfigDataMap() {
|
||||
return envAnimalGatherConfigDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<NpcData> getNpcDataMap() {
|
||||
return npcDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<GadgetData> getGadgetDataMap() {
|
||||
return gadgetDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<ReliquarySetData> getReliquarySetDataMap() {
|
||||
return reliquarySetDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<EquipAffixData> getEquipAffixDataMap() {
|
||||
return equipAffixDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<MonsterCurveData> getMonsterCurveDataMap() {
|
||||
return monsterCurveDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<MonsterDescribeData> getMonsterDescribeDataMap() {
|
||||
return monsterDescribeDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<AvatarTalentData> getAvatarTalentDataMap() {
|
||||
return avatarTalentDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<AvatarFlycloakData> getAvatarFlycloakDataMap() {
|
||||
return avatarFlycloakDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<AvatarCostumeData> getAvatarCostumeDataMap() {
|
||||
return avatarCostumeDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<AvatarCostumeData> getAvatarCostumeDataItemIdMap() {
|
||||
return avatarCostumeDataItemIdMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<SceneData> getSceneDataMap() {
|
||||
return sceneDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<RewardData> getRewardDataMap() {
|
||||
return rewardDataMap;
|
||||
}
|
||||
|
||||
public static Map<Integer, List<Integer>> getFetterDataEntries() {
|
||||
if (fetters.isEmpty()) {
|
||||
fetterDataMap.forEach((k, v) -> {
|
||||
if (!fetters.containsKey(v.getAvatarId())) {
|
||||
fetters.put(v.getAvatarId(), new ArrayList<>());
|
||||
}
|
||||
fetters.get(v.getAvatarId()).add(k);
|
||||
});
|
||||
}
|
||||
|
||||
return fetters;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<CodexQuestData> getCodexQuestDataIdMap() {return codexQuestDataIdMap;}
|
||||
|
||||
public static Int2ObjectMap<CodexAnimalData> getCodexAnimalDataMap() {return codexAnimalDataMap;}
|
||||
|
||||
public static Int2ObjectMap<CodexWeaponData> getCodexWeaponDataIdMap() {return codexWeaponDataIdMap;}
|
||||
|
||||
public static Int2ObjectMap<CodexMaterialData> getCodexMaterialDataIdMap() {return codexMaterialDataIdMap;}
|
||||
|
||||
public static Int2ObjectMap<CodexReliquaryData> getcodexReliquaryIdMap() {return codexReliquaryDataIdMap;}
|
||||
|
||||
public static ArrayList<CodexReliquaryData> getcodexReliquaryArrayList() {return codexReliquaryArrayList;}
|
||||
|
||||
public static Int2ObjectMap<WorldAreaData> getWorldAreaDataMap() {
|
||||
return worldAreaDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<WorldLevelData> getWorldLevelDataMap() {
|
||||
return worldLevelDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<DungeonData> getDungeonDataMap() {
|
||||
return dungeonDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<DailyDungeonData> getDailyDungeonDataMap() {
|
||||
return dailyDungeonDataMap;
|
||||
}
|
||||
public static Int2ObjectMap<WorldAreaData> getWorldAreaDataMap() {
|
||||
return worldAreaDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<WorldLevelData> getWorldLevelDataMap() {
|
||||
return worldLevelDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<DungeonData> getDungeonDataMap() {
|
||||
return dungeonDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<DailyDungeonData> getDailyDungeonDataMap() {
|
||||
return dailyDungeonDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<DungeonEntryData> getDungeonEntryDatatMap(){
|
||||
return dungeonEntryDataMap;
|
||||
}
|
||||
public static Int2ObjectMap<DungeonEntryData> getDungeonEntryDatatMap() {
|
||||
return dungeonEntryDataMap;
|
||||
}
|
||||
|
||||
public static Map<Integer, List<ShopGoodsData>> getShopGoodsDataEntries() {
|
||||
if (shopGoods.isEmpty()) {
|
||||
shopGoodsDataMap.forEach((k, v) -> {
|
||||
if (!shopGoods.containsKey(v.getShopType()))
|
||||
shopGoods.put(v.getShopType(), new ArrayList<>());
|
||||
shopGoods.get(v.getShopType()).add(v);
|
||||
});
|
||||
}
|
||||
public static Map<Integer, List<ShopGoodsData>> getShopGoodsDataEntries() {
|
||||
if (shopGoods.isEmpty()) {
|
||||
shopGoodsDataMap.forEach((k, v) -> {
|
||||
if (!shopGoods.containsKey(v.getShopType()))
|
||||
shopGoods.put(v.getShopType(), new ArrayList<>());
|
||||
shopGoods.get(v.getShopType()).add(v);
|
||||
});
|
||||
}
|
||||
|
||||
return shopGoods;
|
||||
}
|
||||
return shopGoods;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<RewardPreviewData> getRewardPreviewDataMap() {
|
||||
return rewardPreviewDataMap;
|
||||
}
|
||||
public static Int2ObjectMap<RewardPreviewData> getRewardPreviewDataMap() {
|
||||
return rewardPreviewDataMap;
|
||||
}
|
||||
|
||||
public static IntList getScenePointIdList() {
|
||||
return scenePointIdList;
|
||||
}
|
||||
public static IntList getScenePointIdList() {
|
||||
return scenePointIdList;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<CombineData> getCombineDataMap() {
|
||||
return combineDataMap;
|
||||
}
|
||||
public static Int2ObjectMap<CombineData> getCombineDataMap() {
|
||||
return combineDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<TowerFloorData> getTowerFloorDataMap(){
|
||||
return towerFloorDataMap;
|
||||
}
|
||||
public static Int2ObjectMap<TowerFloorData> getTowerFloorDataMap() {
|
||||
return towerFloorDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<TowerLevelData> getTowerLevelDataMap(){
|
||||
return towerLevelDataMap;
|
||||
}
|
||||
public static Int2ObjectMap<TowerLevelData> getTowerLevelDataMap() {
|
||||
return towerLevelDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<TowerScheduleData> getTowerScheduleDataMap(){
|
||||
return towerScheduleDataMap;
|
||||
}
|
||||
public static Int2ObjectMap<TowerScheduleData> getTowerScheduleDataMap() {
|
||||
return towerScheduleDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<QuestData> getQuestDataMap() {
|
||||
return questDataMap;
|
||||
}
|
||||
public static Int2ObjectMap<QuestData> getQuestDataMap() {
|
||||
return questDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<ForgeData> getForgeDataMap() {
|
||||
return forgeDataMap;
|
||||
}
|
||||
public static Int2ObjectMap<ForgeData> getForgeDataMap() {
|
||||
return forgeDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<HomeWorldLevelData> getHomeWorldLevelDataMap() {
|
||||
return homeWorldLevelDataMap;
|
||||
}
|
||||
public static Int2ObjectMap<HomeWorldLevelData> getHomeWorldLevelDataMap() {
|
||||
return homeWorldLevelDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<FurnitureMakeConfigData> getFurnitureMakeConfigDataMap() {
|
||||
return furnitureMakeConfigDataMap;
|
||||
}
|
||||
public static Int2ObjectMap<FurnitureMakeConfigData> getFurnitureMakeConfigDataMap() {
|
||||
return furnitureMakeConfigDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<GatherData> getGatherDataMap() {
|
||||
return gatherDataMap;
|
||||
}
|
||||
public static Int2ObjectMap<GatherData> getGatherDataMap() {
|
||||
return gatherDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<InvestigationMonsterData> getInvestigationMonsterDataMap() {
|
||||
return investigationMonsterDataMap;
|
||||
}
|
||||
public static Int2ObjectMap<InvestigationMonsterData> getInvestigationMonsterDataMap() {
|
||||
return investigationMonsterDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<CityData> getCityDataMap() {
|
||||
return cityDataMap;
|
||||
}
|
||||
public static Int2ObjectMap<CityData> getCityDataMap() {
|
||||
return cityDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<WeatherData> getWeatherDataMap() {
|
||||
return weatherDataMap;
|
||||
}
|
||||
public static Int2ObjectMap<WeatherData> getWeatherDataMap() {
|
||||
return weatherDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<BattlePassMissionData> getBattlePassMissionDataMap() {
|
||||
return battlePassMissionDataMap;
|
||||
}
|
||||
public static Int2ObjectMap<BattlePassMissionData> getBattlePassMissionDataMap() {
|
||||
return battlePassMissionDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<BattlePassRewardData> getBattlePassRewardDataMap() {
|
||||
return battlePassRewardDataMap;
|
||||
}
|
||||
public static Int2ObjectMap<BattlePassRewardData> getBattlePassRewardDataMap() {
|
||||
return battlePassRewardDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<CookRecipeData> getCookRecipeDataMap() {
|
||||
return cookRecipeDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<CookBonusData> getCookBonusDataMap() {
|
||||
return cookBonusDataMap;
|
||||
}
|
||||
public static Int2ObjectMap<CookRecipeData> getCookRecipeDataMap() {
|
||||
return cookRecipeDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<CookBonusData> getCookBonusDataMap() {
|
||||
return cookBonusDataMap;
|
||||
}
|
||||
|
||||
public static Int2ObjectMap<BuffData> getBuffDataMap() {
|
||||
return buffDataMap;
|
||||
|
||||
@@ -59,23 +59,23 @@ public class ResourceLoader {
|
||||
if (loadedAll) return;
|
||||
Grasscutter.getLogger().info(translate("messages.status.resources.loading"));
|
||||
|
||||
// Load ability lists
|
||||
loadAbilityEmbryos();
|
||||
loadOpenConfig();
|
||||
loadAbilityModifiers();
|
||||
// Load resources
|
||||
loadResources(true);
|
||||
// Process into depots
|
||||
GameDepot.load();
|
||||
// Load spawn data and quests
|
||||
loadSpawnData();
|
||||
loadQuests();
|
||||
// Load ability lists
|
||||
loadAbilityEmbryos();
|
||||
loadOpenConfig();
|
||||
loadAbilityModifiers();
|
||||
// Load resources
|
||||
loadResources(true);
|
||||
// Process into depots
|
||||
GameDepot.load();
|
||||
// Load spawn data and quests
|
||||
loadSpawnData();
|
||||
loadQuests();
|
||||
loadScriptSceneData();
|
||||
// Load scene points - must be done AFTER resources are loaded
|
||||
loadScenePoints();
|
||||
// Load default home layout
|
||||
loadHomeworldDefaultSaveData();
|
||||
loadNpcBornData();
|
||||
// Load scene points - must be done AFTER resources are loaded
|
||||
loadScenePoints();
|
||||
// Load default home layout
|
||||
loadHomeworldDefaultSaveData();
|
||||
loadNpcBornData();
|
||||
loadBlossomResources();
|
||||
|
||||
Grasscutter.getLogger().info(translate("messages.status.resources.finish"));
|
||||
@@ -141,7 +141,7 @@ public class ResourceLoader {
|
||||
}
|
||||
|
||||
for (File file : Objects.requireNonNull(folder.listFiles())) {
|
||||
ScenePointConfig config;
|
||||
ScenePointConfig config;
|
||||
Integer sceneId;
|
||||
|
||||
Matcher matcher = pattern.matcher(file.getName());
|
||||
|
||||
@@ -7,16 +7,16 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class MainQuestData {
|
||||
private int id;
|
||||
private int id;
|
||||
private int ICLLDPJFIMA;
|
||||
private int series;
|
||||
private QuestType type;
|
||||
private int series;
|
||||
private QuestType type;
|
||||
|
||||
private long titleTextMapHash;
|
||||
private int[] suggestTrackMainQuestList;
|
||||
private int[] rewardIdList;
|
||||
private long titleTextMapHash;
|
||||
private int[] suggestTrackMainQuestList;
|
||||
private int[] rewardIdList;
|
||||
|
||||
private SubQuestData[] subQuests;
|
||||
private SubQuestData[] subQuests;
|
||||
private List<TalkData> talks;
|
||||
private long[] preloadLuaList;
|
||||
|
||||
@@ -24,29 +24,29 @@ public class MainQuestData {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getSeries() {
|
||||
return series;
|
||||
}
|
||||
public int getSeries() {
|
||||
return series;
|
||||
}
|
||||
|
||||
public QuestType getType() {
|
||||
return type;
|
||||
}
|
||||
public QuestType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public long getTitleTextMapHash() {
|
||||
return titleTextMapHash;
|
||||
}
|
||||
public long getTitleTextMapHash() {
|
||||
return titleTextMapHash;
|
||||
}
|
||||
|
||||
public int[] getSuggestTrackMainQuestList() {
|
||||
return suggestTrackMainQuestList;
|
||||
}
|
||||
public int[] getSuggestTrackMainQuestList() {
|
||||
return suggestTrackMainQuestList;
|
||||
}
|
||||
|
||||
public int[] getRewardIdList() {
|
||||
return rewardIdList;
|
||||
}
|
||||
public int[] getRewardIdList() {
|
||||
return rewardIdList;
|
||||
}
|
||||
|
||||
public SubQuestData[] getSubQuests() {
|
||||
return subQuests;
|
||||
}
|
||||
public SubQuestData[] getSubQuests() {
|
||||
return subQuests;
|
||||
}
|
||||
public List<TalkData> getTalks() {
|
||||
return talks;
|
||||
}
|
||||
@@ -56,10 +56,10 @@ public class MainQuestData {
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class SubQuestData {
|
||||
private int subId;
|
||||
public static class SubQuestData {
|
||||
private int subId;
|
||||
private int order;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Data @Entity
|
||||
@@ -67,10 +67,10 @@ public class MainQuestData {
|
||||
private int id;
|
||||
private String heroTalk;
|
||||
|
||||
public TalkData() {}
|
||||
public TalkData(int id, String heroTalk) {
|
||||
this.id = id;
|
||||
this.heroTalk = heroTalk;
|
||||
}
|
||||
public TalkData() {}
|
||||
public TalkData(int id, String heroTalk) {
|
||||
this.id = id;
|
||||
this.heroTalk = heroTalk;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,17 +3,17 @@ package emu.grasscutter.data.common;
|
||||
import emu.grasscutter.game.props.ItemUseOp;
|
||||
|
||||
public class ItemUseData {
|
||||
private ItemUseOp useOp;
|
||||
private String[] useParam;
|
||||
private ItemUseOp useOp;
|
||||
private String[] useParam;
|
||||
|
||||
public ItemUseOp getUseOp() {
|
||||
if (useOp == null) {
|
||||
useOp = ItemUseOp.ITEM_USE_NONE;
|
||||
}
|
||||
return useOp;
|
||||
}
|
||||
public ItemUseOp getUseOp() {
|
||||
if (useOp == null) {
|
||||
useOp = ItemUseOp.ITEM_USE_NONE;
|
||||
}
|
||||
return useOp;
|
||||
}
|
||||
|
||||
public String[] getUseParam() {
|
||||
return useParam;
|
||||
}
|
||||
public String[] getUseParam() {
|
||||
return useParam;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,62 +60,62 @@ public class AvatarData extends GameResource {
|
||||
@Getter private int nameCardRewardId;
|
||||
@Getter private int nameCardId;
|
||||
|
||||
@Override
|
||||
public int getId(){
|
||||
@Override
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public float getBaseHp(int level){
|
||||
try {
|
||||
return this.hpBase * this.hpGrowthCurve[level - 1];
|
||||
} catch (Exception e) {
|
||||
return this.hpBase;
|
||||
}
|
||||
}
|
||||
|
||||
public float getBaseAttack(int level){
|
||||
public float getBaseHp(int level) {
|
||||
try {
|
||||
return this.attackBase * this.attackGrowthCurve[level - 1];
|
||||
} catch (Exception e) {
|
||||
return this.attackBase;
|
||||
}
|
||||
return this.hpBase * this.hpGrowthCurve[level - 1];
|
||||
} catch (Exception e) {
|
||||
return this.hpBase;
|
||||
}
|
||||
}
|
||||
|
||||
public float getBaseDefense(int level){
|
||||
|
||||
public float getBaseAttack(int level) {
|
||||
try {
|
||||
return this.defenseBase * this.defenseGrowthCurve[level - 1];
|
||||
} catch (Exception e) {
|
||||
return this.defenseBase;
|
||||
}
|
||||
return this.attackBase * this.attackGrowthCurve[level - 1];
|
||||
} catch (Exception e) {
|
||||
return this.attackBase;
|
||||
}
|
||||
}
|
||||
|
||||
public float getBaseCritical(){
|
||||
|
||||
public float getBaseDefense(int level) {
|
||||
try {
|
||||
return this.defenseBase * this.defenseGrowthCurve[level - 1];
|
||||
} catch (Exception e) {
|
||||
return this.defenseBase;
|
||||
}
|
||||
}
|
||||
|
||||
public float getBaseCritical() {
|
||||
return this.critical;
|
||||
}
|
||||
|
||||
public float getBaseCriticalHurt(){
|
||||
|
||||
public float getBaseCriticalHurt() {
|
||||
return this.criticalHurt;
|
||||
}
|
||||
|
||||
public float getGrowthCurveById(int level, FightProperty prop) {
|
||||
String growCurve = this.growthCurveMap.get(prop.getId());
|
||||
if (growCurve == null) {
|
||||
return 1f;
|
||||
}
|
||||
AvatarCurveData curveData = GameData.getAvatarCurveDataMap().get(level);
|
||||
if (curveData == null) {
|
||||
return 1f;
|
||||
}
|
||||
return curveData.getCurveInfos().getOrDefault(growCurve, 1f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
this.skillDepot = GameData.getAvatarSkillDepotDataMap().get(this.skillDepotId);
|
||||
public float getGrowthCurveById(int level, FightProperty prop) {
|
||||
String growCurve = this.growthCurveMap.get(prop.getId());
|
||||
if (growCurve == null) {
|
||||
return 1f;
|
||||
}
|
||||
AvatarCurveData curveData = GameData.getAvatarCurveDataMap().get(level);
|
||||
if (curveData == null) {
|
||||
return 1f;
|
||||
}
|
||||
return curveData.getCurveInfos().getOrDefault(growCurve, 1f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
this.skillDepot = GameData.getAvatarSkillDepotDataMap().get(this.skillDepotId);
|
||||
|
||||
// Get fetters from GameData
|
||||
this.fetters = GameData.getFetterDataEntries().get(this.id);
|
||||
|
||||
|
||||
if (GameData.getFetterCharacterCardDataMap().get(this.id) != null) {
|
||||
this.nameCardRewardId = GameData.getFetterCharacterCardDataMap().get(this.id).getRewardId();
|
||||
}
|
||||
@@ -123,51 +123,51 @@ public class AvatarData extends GameResource {
|
||||
if (GameData.getRewardDataMap().get(this.nameCardRewardId) != null) {
|
||||
this.nameCardId = GameData.getRewardDataMap().get(this.nameCardRewardId).getRewardItemList().get(0).getItemId();
|
||||
}
|
||||
|
||||
int size = GameData.getAvatarCurveDataMap().size();
|
||||
this.hpGrowthCurve = new float[size];
|
||||
this.attackGrowthCurve = new float[size];
|
||||
this.defenseGrowthCurve = new float[size];
|
||||
for (AvatarCurveData curveData : GameData.getAvatarCurveDataMap().values()) {
|
||||
int level = curveData.getLevel() - 1;
|
||||
for (PropGrowCurve growCurve : this.propGrowCurves) {
|
||||
FightProperty prop = FightProperty.getPropByName(growCurve.getType());
|
||||
switch (prop) {
|
||||
case FIGHT_PROP_BASE_HP:
|
||||
this.hpGrowthCurve[level] = curveData.getCurveInfos().get(growCurve.getGrowCurve());
|
||||
break;
|
||||
case FIGHT_PROP_BASE_ATTACK:
|
||||
this.attackGrowthCurve[level] = curveData.getCurveInfos().get(growCurve.getGrowCurve());
|
||||
break;
|
||||
case FIGHT_PROP_BASE_DEFENSE:
|
||||
this.defenseGrowthCurve[level] = curveData.getCurveInfos().get(growCurve.getGrowCurve());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
for (PropGrowCurve growCurve : this.PropGrowCurves) {
|
||||
FightProperty prop = FightProperty.getPropByName(growCurve.getType());
|
||||
this.growthCurveMap.put(prop.getId(), growCurve.getGrowCurve());
|
||||
}
|
||||
*/
|
||||
|
||||
// Cache abilities
|
||||
String[] split = this.iconName.split("_");
|
||||
if (split.length > 0) {
|
||||
this.name = split[split.length - 1];
|
||||
|
||||
AbilityEmbryoEntry info = GameData.getAbilityEmbryoInfo().get(this.name);
|
||||
if (info != null) {
|
||||
this.abilities = new IntArrayList(info.getAbilities().length);
|
||||
for (String ability : info.getAbilities()) {
|
||||
this.abilities.add(Utils.abilityHash(ability));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int size = GameData.getAvatarCurveDataMap().size();
|
||||
this.hpGrowthCurve = new float[size];
|
||||
this.attackGrowthCurve = new float[size];
|
||||
this.defenseGrowthCurve = new float[size];
|
||||
for (AvatarCurveData curveData : GameData.getAvatarCurveDataMap().values()) {
|
||||
int level = curveData.getLevel() - 1;
|
||||
for (PropGrowCurve growCurve : this.propGrowCurves) {
|
||||
FightProperty prop = FightProperty.getPropByName(growCurve.getType());
|
||||
switch (prop) {
|
||||
case FIGHT_PROP_BASE_HP:
|
||||
this.hpGrowthCurve[level] = curveData.getCurveInfos().get(growCurve.getGrowCurve());
|
||||
break;
|
||||
case FIGHT_PROP_BASE_ATTACK:
|
||||
this.attackGrowthCurve[level] = curveData.getCurveInfos().get(growCurve.getGrowCurve());
|
||||
break;
|
||||
case FIGHT_PROP_BASE_DEFENSE:
|
||||
this.defenseGrowthCurve[level] = curveData.getCurveInfos().get(growCurve.getGrowCurve());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
for (PropGrowCurve growCurve : this.PropGrowCurves) {
|
||||
FightProperty prop = FightProperty.getPropByName(growCurve.getType());
|
||||
this.growthCurveMap.put(prop.getId(), growCurve.getGrowCurve());
|
||||
}
|
||||
*/
|
||||
|
||||
// Cache abilities
|
||||
String[] split = this.iconName.split("_");
|
||||
if (split.length > 0) {
|
||||
this.name = split[split.length - 1];
|
||||
|
||||
AbilityEmbryoEntry info = GameData.getAbilityEmbryoInfo().get(this.name);
|
||||
if (info != null) {
|
||||
this.abilities = new IntArrayList(info.getAbilities().length);
|
||||
for (String ability : info.getAbilities()) {
|
||||
this.abilities.add(Utils.abilityHash(ability));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,12 +21,12 @@ public class AvatarSkillData extends GameResource {
|
||||
@Getter private String abilityName;
|
||||
|
||||
@Override
|
||||
public int getId(){
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import lombok.Getter;
|
||||
|
||||
@ResourceType(name = "AvatarSkillDepotExcelConfigData.json", loadPriority = LoadPriority.HIGH)
|
||||
public class AvatarSkillDepotData extends GameResource {
|
||||
|
||||
|
||||
private int id;
|
||||
@Getter private int energySkill;
|
||||
@Getter private int attackModeSkill;
|
||||
@@ -31,43 +31,43 @@ public class AvatarSkillDepotData extends GameResource {
|
||||
|
||||
@Getter private String talentStarName;
|
||||
@Getter private String skillDepotAbilityGroup;
|
||||
|
||||
|
||||
// Transient
|
||||
@Getter private AvatarSkillData energySkillData;
|
||||
@Getter private ElementType elementType;
|
||||
@Getter private IntList abilities;
|
||||
|
||||
@Override
|
||||
public int getId(){
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setAbilities(AbilityEmbryoEntry info) {
|
||||
this.abilities = new IntArrayList(info.getAbilities().length);
|
||||
for (String ability : info.getAbilities()) {
|
||||
this.abilities.add(Utils.abilityHash(ability));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
// Set energy skill data
|
||||
this.energySkillData = GameData.getAvatarSkillDataMap().get(this.energySkill);
|
||||
if (this.energySkillData != null) {
|
||||
this.elementType = this.energySkillData.getCostElemType();
|
||||
} else {
|
||||
this.elementType = ElementType.None;
|
||||
}
|
||||
// Set embryo abilities (if player skill depot)
|
||||
if (getSkillDepotAbilityGroup() != null && getSkillDepotAbilityGroup().length() > 0) {
|
||||
AvatarConfig config = GameDepot.getPlayerAbilities().get(getSkillDepotAbilityGroup());
|
||||
|
||||
if (config != null) {
|
||||
this.setAbilities(new AbilityEmbryoEntry(getSkillDepotAbilityGroup(), config.abilities.stream().map(Object::toString).toArray(String[]::new)));
|
||||
}
|
||||
}
|
||||
public void setAbilities(AbilityEmbryoEntry info) {
|
||||
this.abilities = new IntArrayList(info.getAbilities().length);
|
||||
for (String ability : info.getAbilities()) {
|
||||
this.abilities.add(Utils.abilityHash(ability));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
// Set energy skill data
|
||||
this.energySkillData = GameData.getAvatarSkillDataMap().get(this.energySkill);
|
||||
if (this.energySkillData != null) {
|
||||
this.elementType = this.energySkillData.getCostElemType();
|
||||
} else {
|
||||
this.elementType = ElementType.None;
|
||||
}
|
||||
// Set embryo abilities (if player skill depot)
|
||||
if (getSkillDepotAbilityGroup() != null && getSkillDepotAbilityGroup().length() > 0) {
|
||||
AvatarConfig config = GameDepot.getPlayerAbilities().get(getSkillDepotAbilityGroup());
|
||||
|
||||
if (config != null) {
|
||||
this.setAbilities(new AbilityEmbryoEntry(getSkillDepotAbilityGroup(), config.abilities.stream().map(Object::toString).toArray(String[]::new)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class InherentProudSkillOpens {
|
||||
@Getter private int proudSkillGroupId;
|
||||
@Getter private int needAvatarPromoteLevel;
|
||||
|
||||
@@ -9,17 +9,17 @@ import lombok.Getter;
|
||||
@Getter
|
||||
public class BuffData extends GameResource {
|
||||
private int groupId;
|
||||
private int serverBuffId;
|
||||
private float time;
|
||||
private boolean isPersistent;
|
||||
private ServerBuffType serverBuffType;
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return this.serverBuffId;
|
||||
}
|
||||
|
||||
public void onLoad() {
|
||||
this.serverBuffType = this.serverBuffType != null ? this.serverBuffType : ServerBuffType.SERVER_BUFF_NONE;
|
||||
}
|
||||
private int serverBuffId;
|
||||
private float time;
|
||||
private boolean isPersistent;
|
||||
private ServerBuffType serverBuffType;
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return this.serverBuffId;
|
||||
}
|
||||
|
||||
public void onLoad() {
|
||||
this.serverBuffType = this.serverBuffType != null ? this.serverBuffType : ServerBuffType.SERVER_BUFF_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,51 +6,51 @@ import emu.grasscutter.game.props.EntityType;
|
||||
|
||||
@ResourceType(name = "GadgetExcelConfigData.json")
|
||||
public class GadgetData extends GameResource {
|
||||
private int id;
|
||||
private int id;
|
||||
|
||||
private EntityType type;
|
||||
private String jsonName;
|
||||
private boolean isInteractive;
|
||||
private String[] tags;
|
||||
private String itemJsonName;
|
||||
private long nameTextMapHash;
|
||||
private int campID;
|
||||
private EntityType type;
|
||||
private String jsonName;
|
||||
private boolean isInteractive;
|
||||
private String[] tags;
|
||||
private String itemJsonName;
|
||||
private long nameTextMapHash;
|
||||
private int campID;
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
@Override
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public EntityType getType() {
|
||||
return type;
|
||||
}
|
||||
public EntityType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public String getJsonName() {
|
||||
return jsonName;
|
||||
}
|
||||
public String getJsonName() {
|
||||
return jsonName;
|
||||
}
|
||||
|
||||
public boolean isInteractive() {
|
||||
return isInteractive;
|
||||
}
|
||||
public boolean isInteractive() {
|
||||
return isInteractive;
|
||||
}
|
||||
|
||||
public String[] getTags() {
|
||||
return tags;
|
||||
}
|
||||
public String[] getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public String getItemJsonName() {
|
||||
return itemJsonName;
|
||||
}
|
||||
public String getItemJsonName() {
|
||||
return itemJsonName;
|
||||
}
|
||||
|
||||
public long getNameTextMapHash() {
|
||||
return nameTextMapHash;
|
||||
}
|
||||
public long getNameTextMapHash() {
|
||||
return nameTextMapHash;
|
||||
}
|
||||
|
||||
public int getCampID() {
|
||||
return campID;
|
||||
}
|
||||
public int getCampID() {
|
||||
return campID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
@Override
|
||||
public void onLoad() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ import lombok.Getter;
|
||||
})
|
||||
@Getter
|
||||
public class ItemData extends GameResource {
|
||||
// Main
|
||||
private int id;
|
||||
// Main
|
||||
private int id;
|
||||
private int stackLimit = 1;
|
||||
private int maxUseCount;
|
||||
private int rankLevel;
|
||||
@@ -30,25 +30,25 @@ public class ItemData extends GameResource {
|
||||
private int rank;
|
||||
private int weight;
|
||||
private int gadgetId;
|
||||
|
||||
|
||||
private int[] destroyReturnMaterial;
|
||||
private int[] destroyReturnMaterialCount;
|
||||
|
||||
|
||||
// Enums
|
||||
private ItemType itemType = ItemType.ITEM_NONE;
|
||||
private MaterialType materialType = MaterialType.MATERIAL_NONE;
|
||||
private EquipType equipType = EquipType.EQUIP_NONE;
|
||||
private String effectType;
|
||||
private String destroyRule;
|
||||
|
||||
|
||||
// Food
|
||||
private String foodQuality;
|
||||
private int[] satiationParams;
|
||||
|
||||
|
||||
// Usable item
|
||||
private ItemUseTarget useTarget;
|
||||
private List<ItemUseData> itemUse;
|
||||
|
||||
|
||||
// Relic
|
||||
private int mainPropDepotId;
|
||||
private int appendPropDepotId;
|
||||
@@ -57,7 +57,7 @@ public class ItemData extends GameResource {
|
||||
private int[] addPropLevels;
|
||||
private int baseConvExp;
|
||||
private int maxLevel;
|
||||
|
||||
|
||||
// Weapon
|
||||
private int weaponPromoteId;
|
||||
private int weaponBaseExp;
|
||||
@@ -67,7 +67,7 @@ public class ItemData extends GameResource {
|
||||
private int[] awakenCosts;
|
||||
private int[] skillAffix;
|
||||
private WeaponProperty[] weaponProp;
|
||||
|
||||
|
||||
// Hash
|
||||
private long nameTextMapHash;
|
||||
|
||||
@@ -77,42 +77,42 @@ public class ItemData extends GameResource {
|
||||
private List<Integer> furnitureGadgetID;
|
||||
@SerializedName("JFDLJGDFIGL")
|
||||
private int roomSceneId;
|
||||
|
||||
|
||||
// Custom
|
||||
private transient IntSet addPropLevelSet;
|
||||
|
||||
@Override
|
||||
public int getId(){
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
|
||||
public WeaponProperty[] getWeaponProperties() {
|
||||
return this.weaponProp;
|
||||
}
|
||||
|
||||
|
||||
public boolean canAddRelicProp(int level) {
|
||||
return this.addPropLevelSet != null && this.addPropLevelSet.contains(level);
|
||||
return this.addPropLevelSet != null && this.addPropLevelSet.contains(level);
|
||||
}
|
||||
|
||||
public boolean isEquip() {
|
||||
return this.itemType == ItemType.ITEM_RELIQUARY || this.itemType == ItemType.ITEM_WEAPON;
|
||||
}
|
||||
|
||||
|
||||
public boolean isEquip() {
|
||||
return this.itemType == ItemType.ITEM_RELIQUARY || this.itemType == ItemType.ITEM_WEAPON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
if (this.itemType == ItemType.ITEM_RELIQUARY) {
|
||||
if (this.addPropLevels != null && this.addPropLevels.length > 0) {
|
||||
this.addPropLevelSet = new IntOpenHashSet(this.addPropLevels);
|
||||
}
|
||||
} else if (this.itemType == ItemType.ITEM_WEAPON) {
|
||||
this.equipType = EquipType.EQUIP_WEAPON;
|
||||
} else {
|
||||
this.equipType = EquipType.EQUIP_NONE;
|
||||
}
|
||||
|
||||
if (this.weaponProp != null) {
|
||||
this.weaponProp = Arrays.stream(this.weaponProp).filter(prop -> prop.getPropType() != null).toArray(WeaponProperty[]::new);
|
||||
}
|
||||
public void onLoad() {
|
||||
if (this.itemType == ItemType.ITEM_RELIQUARY) {
|
||||
if (this.addPropLevels != null && this.addPropLevels.length > 0) {
|
||||
this.addPropLevelSet = new IntOpenHashSet(this.addPropLevels);
|
||||
}
|
||||
} else if (this.itemType == ItemType.ITEM_WEAPON) {
|
||||
this.equipType = EquipType.EQUIP_WEAPON;
|
||||
} else {
|
||||
this.equipType = EquipType.EQUIP_NONE;
|
||||
}
|
||||
|
||||
if (this.weaponProp != null) {
|
||||
this.weaponProp = Arrays.stream(this.weaponProp).filter(prop -> prop.getPropType() != null).toArray(WeaponProperty[]::new);
|
||||
}
|
||||
|
||||
if (this.getFurnType() != null) {
|
||||
this.furnType = this.furnType.stream().filter(x -> x > 0).toList();
|
||||
@@ -121,7 +121,7 @@ public class ItemData extends GameResource {
|
||||
this.furnitureGadgetID = this.furnitureGadgetID.stream().filter(x -> x > 0).toList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Getter
|
||||
public static class WeaponProperty {
|
||||
private FightProperty propType;
|
||||
|
||||
@@ -6,30 +6,30 @@ import emu.grasscutter.data.ResourceType.LoadPriority;
|
||||
|
||||
@ResourceType(name = "MonsterDescribeExcelConfigData.json", loadPriority = LoadPriority.HIGH)
|
||||
public class MonsterDescribeData extends GameResource {
|
||||
private int id;
|
||||
private int id;
|
||||
private long nameTextMapHash;
|
||||
private int titleID;
|
||||
private int specialNameLabID;
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public long getNameTextMapHash() {
|
||||
return nameTextMapHash;
|
||||
}
|
||||
@Override
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getTitleID() {
|
||||
return titleID;
|
||||
}
|
||||
public long getNameTextMapHash() {
|
||||
return nameTextMapHash;
|
||||
}
|
||||
|
||||
public int getSpecialNameLabID() {
|
||||
return specialNameLabID;
|
||||
}
|
||||
public int getTitleID() {
|
||||
return titleID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
public int getSpecialNameLabID() {
|
||||
return specialNameLabID;
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onLoad() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,15 +7,15 @@ import lombok.Getter;
|
||||
@ResourceType(name = "PlayerLevelExcelConfigData.json")
|
||||
@Getter
|
||||
public class PlayerLevelData extends GameResource {
|
||||
private int level;
|
||||
private int exp;
|
||||
private int rewardId;
|
||||
private int expeditionLimitAdd = 0;
|
||||
private int unlockWorldLevel;
|
||||
private long unlockDescTextMapHash;
|
||||
private int level;
|
||||
private int exp;
|
||||
private int rewardId;
|
||||
private int expeditionLimitAdd = 0;
|
||||
private int unlockWorldLevel;
|
||||
private long unlockDescTextMapHash;
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return this.level;
|
||||
}
|
||||
@Override
|
||||
public int getId() {
|
||||
return this.level;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,110 +18,110 @@ import lombok.experimental.FieldDefaults;
|
||||
@Getter
|
||||
@ToString
|
||||
public class QuestData extends GameResource {
|
||||
private int subId;
|
||||
private int mainId;
|
||||
private int order;
|
||||
private long descTextMapHash;
|
||||
private int subId;
|
||||
private int mainId;
|
||||
private int order;
|
||||
private long descTextMapHash;
|
||||
|
||||
private boolean finishParent;
|
||||
private boolean isRewind;
|
||||
private boolean finishParent;
|
||||
private boolean isRewind;
|
||||
|
||||
private LogicType acceptCondComb;
|
||||
private LogicType finishCondComb;
|
||||
private LogicType failCondComb;
|
||||
private LogicType acceptCondComb;
|
||||
private LogicType finishCondComb;
|
||||
private LogicType failCondComb;
|
||||
|
||||
private List<QuestCondition> acceptCond;
|
||||
private List<QuestCondition> finishCond;
|
||||
private List<QuestCondition> failCond;
|
||||
private List<QuestExecParam> beginExec;
|
||||
private List<QuestExecParam> finishExec;
|
||||
private List<QuestExecParam> failExec;
|
||||
private List<QuestCondition> acceptCond;
|
||||
private List<QuestCondition> finishCond;
|
||||
private List<QuestCondition> failCond;
|
||||
private List<QuestExecParam> beginExec;
|
||||
private List<QuestExecParam> finishExec;
|
||||
private List<QuestExecParam> failExec;
|
||||
private Guide guide;
|
||||
|
||||
//ResourceLoader not happy if you remove getId() ~~
|
||||
public int getId() {
|
||||
return subId;
|
||||
}
|
||||
public int getId() {
|
||||
return subId;
|
||||
}
|
||||
//Added getSubId() for clarity
|
||||
public int getSubId() {return subId;}
|
||||
|
||||
public int getMainId() {
|
||||
return mainId;
|
||||
}
|
||||
public int getMainId() {
|
||||
return mainId;
|
||||
}
|
||||
|
||||
public int getOrder() {
|
||||
return order;
|
||||
}
|
||||
public int getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
public long getDescTextMapHash() {
|
||||
return descTextMapHash;
|
||||
}
|
||||
public long getDescTextMapHash() {
|
||||
return descTextMapHash;
|
||||
}
|
||||
|
||||
public boolean finishParent() {
|
||||
return finishParent;
|
||||
}
|
||||
public boolean finishParent() {
|
||||
return finishParent;
|
||||
}
|
||||
|
||||
public boolean isRewind() {
|
||||
return isRewind;
|
||||
}
|
||||
public boolean isRewind() {
|
||||
return isRewind;
|
||||
}
|
||||
|
||||
public LogicType getAcceptCondComb() {
|
||||
return acceptCondComb == null ? LogicType.LOGIC_NONE : acceptCondComb;
|
||||
}
|
||||
public LogicType getAcceptCondComb() {
|
||||
return acceptCondComb == null ? LogicType.LOGIC_NONE : acceptCondComb;
|
||||
}
|
||||
|
||||
public List<QuestCondition> getAcceptCond() {
|
||||
return acceptCond;
|
||||
}
|
||||
public List<QuestCondition> getAcceptCond() {
|
||||
return acceptCond;
|
||||
}
|
||||
|
||||
public LogicType getFinishCondComb() {
|
||||
return finishCondComb == null ? LogicType.LOGIC_NONE : finishCondComb;
|
||||
}
|
||||
public LogicType getFinishCondComb() {
|
||||
return finishCondComb == null ? LogicType.LOGIC_NONE : finishCondComb;
|
||||
}
|
||||
|
||||
public List<QuestCondition> getFinishCond() {
|
||||
return finishCond;
|
||||
}
|
||||
public List<QuestCondition> getFinishCond() {
|
||||
return finishCond;
|
||||
}
|
||||
|
||||
public LogicType getFailCondComb() {
|
||||
return failCondComb == null ? LogicType.LOGIC_NONE : failCondComb;
|
||||
}
|
||||
public LogicType getFailCondComb() {
|
||||
return failCondComb == null ? LogicType.LOGIC_NONE : failCondComb;
|
||||
}
|
||||
|
||||
public List<QuestCondition> getFailCond() {
|
||||
return failCond;
|
||||
}
|
||||
public List<QuestCondition> getFailCond() {
|
||||
return failCond;
|
||||
}
|
||||
|
||||
public void onLoad() {
|
||||
this.acceptCond = acceptCond.stream().filter(p -> p.type != null).toList();
|
||||
this.finishCond = finishCond.stream().filter(p -> p.type != null).toList();
|
||||
this.failCond = failCond.stream().filter(p -> p.type != null).toList();
|
||||
public void onLoad() {
|
||||
this.acceptCond = acceptCond.stream().filter(p -> p.type != null).toList();
|
||||
this.finishCond = finishCond.stream().filter(p -> p.type != null).toList();
|
||||
this.failCond = failCond.stream().filter(p -> p.type != null).toList();
|
||||
|
||||
this.beginExec = beginExec.stream().filter(p -> p.type != null).toList();
|
||||
this.finishExec = finishExec.stream().filter(p -> p.type != null).toList();
|
||||
this.failExec = failExec.stream().filter(p -> p.type != null).toList();
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@FieldDefaults(level = AccessLevel.PRIVATE)
|
||||
public class QuestExecParam {
|
||||
public class QuestExecParam {
|
||||
@SerializedName("_type")
|
||||
QuestTrigger type;
|
||||
QuestTrigger type;
|
||||
@SerializedName("_param")
|
||||
String[] param;
|
||||
String[] param;
|
||||
@SerializedName("_count")
|
||||
String count;
|
||||
}
|
||||
String count;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class QuestCondition {
|
||||
public static class QuestCondition {
|
||||
@SerializedName("_type")
|
||||
private QuestTrigger type;
|
||||
private QuestTrigger type;
|
||||
@SerializedName("_param")
|
||||
private int[] param;
|
||||
private int[] param;
|
||||
@SerializedName("_param_str")
|
||||
private String paramStr;
|
||||
private String paramStr;
|
||||
@SerializedName("_count")
|
||||
private String count;
|
||||
private String count;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Guide {
|
||||
|
||||
@@ -56,7 +56,7 @@ public final class AbilityManager extends BasePlayerManager {
|
||||
}
|
||||
|
||||
// Check if the caster matches the player.
|
||||
if(player.getTeamManager().getCurrentAvatarEntity().getId() != casterId) {
|
||||
if (player.getTeamManager().getCurrentAvatarEntity().getId() != casterId) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public final class AbilityManager extends BasePlayerManager {
|
||||
}
|
||||
|
||||
// Check if the skill is an elemental burst.
|
||||
if(skillData.getCostElemVal() <= 0) {
|
||||
if (skillData.getCostElemVal() <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public final class AbilityManager extends BasePlayerManager {
|
||||
}
|
||||
|
||||
// Check if the player is invulnerable.
|
||||
if(!this.abilityInvulnerable) {
|
||||
if (!this.abilityInvulnerable) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,21 +39,21 @@ public class PlayerActivityData {
|
||||
String detail;
|
||||
@Transient Player player;
|
||||
@Transient ActivityHandler activityHandler;
|
||||
public void save(){
|
||||
public void save() {
|
||||
DatabaseHelper.savePlayerActivityData(this);
|
||||
}
|
||||
|
||||
public static PlayerActivityData getByPlayer(Player player, int activityId){
|
||||
public static PlayerActivityData getByPlayer(Player player, int activityId) {
|
||||
return DatabaseHelper.getPlayerActivityData(player.getUid(), activityId);
|
||||
}
|
||||
|
||||
public synchronized void addWatcherProgress(int watcherId){
|
||||
public synchronized void addWatcherProgress(int watcherId) {
|
||||
var watcherInfo = watcherInfoMap.get(watcherId);
|
||||
if(watcherInfo == null){
|
||||
if (watcherInfo == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(watcherInfo.curProgress >= watcherInfo.totalProgress){
|
||||
if (watcherInfo.curProgress >= watcherInfo.totalProgress) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -67,13 +67,13 @@ public class PlayerActivityData {
|
||||
.toList();
|
||||
}
|
||||
|
||||
public void setDetail(Object detail){
|
||||
public void setDetail(Object detail) {
|
||||
this.detail = JsonUtils.encode(detail);
|
||||
}
|
||||
|
||||
public void takeWatcherReward(int watcherId) {
|
||||
var watcher = watcherInfoMap.get(watcherId);
|
||||
if(watcher == null || watcher.isTakenReward()){
|
||||
if (watcher == null || watcher.isTakenReward()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ public class PlayerActivityData {
|
||||
.map(ActivityWatcherData::getRewardID)
|
||||
.map(id -> GameData.getRewardDataMap().get(id.intValue()));
|
||||
|
||||
if(reward.isEmpty()){
|
||||
if (reward.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -106,11 +106,11 @@ public class PlayerActivityData {
|
||||
int curProgress;
|
||||
boolean isTakenReward;
|
||||
|
||||
public ActivityWatcherData getMetadata(){
|
||||
public ActivityWatcherData getMetadata() {
|
||||
return GameData.getActivityWatcherDataMap().get(watcherId);
|
||||
}
|
||||
|
||||
public static WatcherInfo init(ActivityWatcher watcher){
|
||||
public static WatcherInfo init(ActivityWatcher watcher) {
|
||||
return WatcherInfo.of()
|
||||
.watcherId(watcher.getWatcherId())
|
||||
.totalProgress(watcher.getActivityWatcherData().getProgress())
|
||||
@@ -118,7 +118,7 @@ public class PlayerActivityData {
|
||||
.build();
|
||||
}
|
||||
|
||||
public ActivityWatcherInfoOuterClass.ActivityWatcherInfo toProto(){
|
||||
public ActivityWatcherInfoOuterClass.ActivityWatcherInfo toProto() {
|
||||
return ActivityWatcherInfoOuterClass.ActivityWatcherInfo.newBuilder()
|
||||
.setWatcherId(watcherId)
|
||||
.setCurProgress(curProgress)
|
||||
|
||||
@@ -681,7 +681,7 @@ public class Avatar {
|
||||
}
|
||||
|
||||
private boolean calcConstellationExtraLevels(OpenConfigEntry entry) {
|
||||
int skillId = switch(entry.getExtraTalentIndex()) {
|
||||
int skillId = switch (entry.getExtraTalentIndex()) {
|
||||
case 9 -> this.skillDepot.getEnergySkill(); // Ult skill
|
||||
case 2 -> (this.skillDepot.getSkills().size() >= 2) ? this.skillDepot.getSkills().get(1) : 0; // E skill
|
||||
default -> 0;
|
||||
|
||||
@@ -41,28 +41,28 @@ import it.unimi.dsi.fastutil.ints.Int2FloatMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap;
|
||||
|
||||
public class EntityAvatar extends GameEntity {
|
||||
private final Avatar avatar;
|
||||
private final Avatar avatar;
|
||||
|
||||
private PlayerDieType killedType;
|
||||
private int killedBy;
|
||||
private PlayerDieType killedType;
|
||||
private int killedBy;
|
||||
|
||||
public EntityAvatar(Scene scene, Avatar avatar) {
|
||||
super(scene);
|
||||
this.avatar = avatar;
|
||||
this.avatar.setCurrentEnergy();
|
||||
this.id = getScene().getWorld().getNextEntityId(EntityIdType.AVATAR);
|
||||
public EntityAvatar(Scene scene, Avatar avatar) {
|
||||
super(scene);
|
||||
this.avatar = avatar;
|
||||
this.avatar.setCurrentEnergy();
|
||||
this.id = getScene().getWorld().getNextEntityId(EntityIdType.AVATAR);
|
||||
|
||||
GameItem weapon = this.getAvatar().getWeapon();
|
||||
if (weapon != null) {
|
||||
weapon.setWeaponEntityId(getScene().getWorld().getNextEntityId(EntityIdType.WEAPON));
|
||||
}
|
||||
}
|
||||
GameItem weapon = this.getAvatar().getWeapon();
|
||||
if (weapon != null) {
|
||||
weapon.setWeaponEntityId(getScene().getWorld().getNextEntityId(EntityIdType.WEAPON));
|
||||
}
|
||||
}
|
||||
|
||||
public EntityAvatar(Avatar avatar) {
|
||||
super(null);
|
||||
this.avatar = avatar;
|
||||
this.avatar.setCurrentEnergy();
|
||||
}
|
||||
public EntityAvatar(Avatar avatar) {
|
||||
super(null);
|
||||
this.avatar = avatar;
|
||||
this.avatar.setCurrentEnergy();
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return avatar.getPlayer();
|
||||
@@ -71,41 +71,41 @@ public class EntityAvatar extends GameEntity {
|
||||
@Override
|
||||
public Position getPosition() {
|
||||
return getPlayer().getPosition();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Position getRotation() {
|
||||
return getPlayer().getRotation();
|
||||
}
|
||||
@Override
|
||||
public Position getRotation() {
|
||||
return getPlayer().getRotation();
|
||||
}
|
||||
|
||||
public Avatar getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
public Avatar getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public int getKilledBy() {
|
||||
return killedBy;
|
||||
}
|
||||
public int getKilledBy() {
|
||||
return killedBy;
|
||||
}
|
||||
|
||||
public PlayerDieType getKilledType() {
|
||||
return killedType;
|
||||
}
|
||||
public PlayerDieType getKilledType() {
|
||||
return killedType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlive() {
|
||||
return this.getFightProperty(FightProperty.FIGHT_PROP_CUR_HP) > 0f;
|
||||
}
|
||||
@Override
|
||||
public boolean isAlive() {
|
||||
return this.getFightProperty(FightProperty.FIGHT_PROP_CUR_HP) > 0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Int2FloatOpenHashMap getFightProperties() {
|
||||
return getAvatar().getFightProperties();
|
||||
}
|
||||
@Override
|
||||
public Int2FloatOpenHashMap getFightProperties() {
|
||||
return getAvatar().getFightProperties();
|
||||
}
|
||||
|
||||
public int getWeaponEntityId() {
|
||||
if (getAvatar().getWeapon() != null) {
|
||||
return getAvatar().getWeapon().getWeaponEntityId();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public int getWeaponEntityId() {
|
||||
if (getAvatar().getWeapon() != null) {
|
||||
return getAvatar().getWeapon().getWeaponEntityId();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeath(int killerId) {
|
||||
@@ -116,31 +116,31 @@ public class EntityAvatar extends GameEntity {
|
||||
clearEnergy(ChangeEnergyReason.CHANGE_ENERGY_REASON_NONE);
|
||||
}
|
||||
|
||||
public void onDeath(PlayerDieType dieType, int killerId) {
|
||||
public void onDeath(PlayerDieType dieType, int killerId) {
|
||||
super.onDeath(killerId); // Invoke super class's onDeath() method.
|
||||
|
||||
this.killedType = dieType;
|
||||
this.killedBy = killerId;
|
||||
clearEnergy(ChangeEnergyReason.CHANGE_ENERGY_REASON_NONE);
|
||||
}
|
||||
this.killedType = dieType;
|
||||
this.killedBy = killerId;
|
||||
clearEnergy(ChangeEnergyReason.CHANGE_ENERGY_REASON_NONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float heal(float amount) {
|
||||
float healed = super.heal(amount);
|
||||
@Override
|
||||
public float heal(float amount) {
|
||||
float healed = super.heal(amount);
|
||||
|
||||
if (healed > 0f) {
|
||||
getScene().broadcastPacket(
|
||||
if (healed > 0f) {
|
||||
getScene().broadcastPacket(
|
||||
new PacketEntityFightPropChangeReasonNotify(this, FightProperty.FIGHT_PROP_CUR_HP, healed, PropChangeReason.PROP_CHANGE_REASON_ABILITY, ChangeHpReason.CHANGE_HP_REASON_ADD_ABILITY)
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return healed;
|
||||
}
|
||||
return healed;
|
||||
}
|
||||
|
||||
public void clearEnergy(ChangeEnergyReason reason) {
|
||||
// Fight props.
|
||||
FightProperty curEnergyProp = this.getAvatar().getSkillDepot().getElementType().getCurEnergyProp();
|
||||
FightProperty maxEnergyProp = this.getAvatar().getSkillDepot().getElementType().getMaxEnergyProp();
|
||||
public void clearEnergy(ChangeEnergyReason reason) {
|
||||
// Fight props.
|
||||
FightProperty curEnergyProp = this.getAvatar().getSkillDepot().getElementType().getCurEnergyProp();
|
||||
FightProperty maxEnergyProp = this.getAvatar().getSkillDepot().getElementType().getMaxEnergyProp();
|
||||
|
||||
// Get max energy.
|
||||
float maxEnergy = this.avatar.getFightProperty(maxEnergyProp);
|
||||
@@ -151,174 +151,174 @@ public class EntityAvatar extends GameEntity {
|
||||
// Send packets.
|
||||
this.getScene().broadcastPacket(new PacketEntityFightPropUpdateNotify(this, curEnergyProp));
|
||||
|
||||
if (reason == ChangeEnergyReason.CHANGE_ENERGY_REASON_SKILL_START) {
|
||||
this.getScene().broadcastPacket(new PacketEntityFightPropChangeReasonNotify(this, curEnergyProp, -maxEnergy, reason));
|
||||
}
|
||||
}
|
||||
if (reason == ChangeEnergyReason.CHANGE_ENERGY_REASON_SKILL_START) {
|
||||
this.getScene().broadcastPacket(new PacketEntityFightPropChangeReasonNotify(this, curEnergyProp, -maxEnergy, reason));
|
||||
}
|
||||
}
|
||||
|
||||
public void addEnergy(float amount, PropChangeReason reason) {
|
||||
this.addEnergy(amount, reason, false);
|
||||
}
|
||||
public void addEnergy(float amount, PropChangeReason reason, boolean isFlat) {
|
||||
// Get current and maximum energy for this avatar.
|
||||
FightProperty curEnergyProp = this.getAvatar().getSkillDepot().getElementType().getCurEnergyProp();
|
||||
FightProperty maxEnergyProp = this.getAvatar().getSkillDepot().getElementType().getMaxEnergyProp();
|
||||
public void addEnergy(float amount, PropChangeReason reason) {
|
||||
this.addEnergy(amount, reason, false);
|
||||
}
|
||||
public void addEnergy(float amount, PropChangeReason reason, boolean isFlat) {
|
||||
// Get current and maximum energy for this avatar.
|
||||
FightProperty curEnergyProp = this.getAvatar().getSkillDepot().getElementType().getCurEnergyProp();
|
||||
FightProperty maxEnergyProp = this.getAvatar().getSkillDepot().getElementType().getMaxEnergyProp();
|
||||
|
||||
float curEnergy = this.getFightProperty(curEnergyProp);
|
||||
float maxEnergy = this.getFightProperty(maxEnergyProp);
|
||||
float curEnergy = this.getFightProperty(curEnergyProp);
|
||||
float maxEnergy = this.getFightProperty(maxEnergyProp);
|
||||
|
||||
// Get energy recharge.
|
||||
float energyRecharge = this.getFightProperty(FightProperty.FIGHT_PROP_CHARGE_EFFICIENCY);
|
||||
// Get energy recharge.
|
||||
float energyRecharge = this.getFightProperty(FightProperty.FIGHT_PROP_CHARGE_EFFICIENCY);
|
||||
|
||||
// Scale amount by energy recharge, if the amount is not flat.
|
||||
if (!isFlat) {
|
||||
amount *= energyRecharge;
|
||||
}
|
||||
|
||||
// Determine the new energy value.
|
||||
float newEnergy = Math.min(curEnergy + amount, maxEnergy);
|
||||
// Determine the new energy value.
|
||||
float newEnergy = Math.min(curEnergy + amount, maxEnergy);
|
||||
|
||||
// Set energy and notify.
|
||||
if (newEnergy != curEnergy) {
|
||||
this.avatar.setCurrentEnergy(curEnergyProp, newEnergy);
|
||||
// Set energy and notify.
|
||||
if (newEnergy != curEnergy) {
|
||||
this.avatar.setCurrentEnergy(curEnergyProp, newEnergy);
|
||||
|
||||
this.getScene().broadcastPacket(new PacketAvatarFightPropUpdateNotify(this.getAvatar(), curEnergyProp));
|
||||
this.getScene().broadcastPacket(new PacketEntityFightPropChangeReasonNotify(this, curEnergyProp, newEnergy, reason));
|
||||
}
|
||||
}
|
||||
this.getScene().broadcastPacket(new PacketAvatarFightPropUpdateNotify(this.getAvatar(), curEnergyProp));
|
||||
this.getScene().broadcastPacket(new PacketEntityFightPropChangeReasonNotify(this, curEnergyProp, newEnergy, reason));
|
||||
}
|
||||
}
|
||||
|
||||
public SceneAvatarInfo getSceneAvatarInfo() {
|
||||
SceneAvatarInfo.Builder avatarInfo = SceneAvatarInfo.newBuilder()
|
||||
.setUid(this.getPlayer().getUid())
|
||||
.setAvatarId(this.getAvatar().getAvatarId())
|
||||
.setGuid(this.getAvatar().getGuid())
|
||||
.setPeerId(this.getPlayer().getPeerId())
|
||||
.addAllTalentIdList(this.getAvatar().getTalentIdList())
|
||||
.setCoreProudSkillLevel(this.getAvatar().getCoreProudSkillLevel())
|
||||
.putAllSkillLevelMap(this.getAvatar().getSkillLevelMap())
|
||||
.setSkillDepotId(this.getAvatar().getSkillDepotId())
|
||||
.addAllInherentProudSkillList(this.getAvatar().getProudSkillList())
|
||||
.putAllProudSkillExtraLevelMap(this.getAvatar().getProudSkillBonusMap())
|
||||
.addAllTeamResonanceList(this.getAvatar().getPlayer().getTeamManager().getTeamResonances())
|
||||
.setWearingFlycloakId(this.getAvatar().getFlyCloak())
|
||||
.setCostumeId(this.getAvatar().getCostume())
|
||||
.setBornTime(this.getAvatar().getBornTime());
|
||||
public SceneAvatarInfo getSceneAvatarInfo() {
|
||||
SceneAvatarInfo.Builder avatarInfo = SceneAvatarInfo.newBuilder()
|
||||
.setUid(this.getPlayer().getUid())
|
||||
.setAvatarId(this.getAvatar().getAvatarId())
|
||||
.setGuid(this.getAvatar().getGuid())
|
||||
.setPeerId(this.getPlayer().getPeerId())
|
||||
.addAllTalentIdList(this.getAvatar().getTalentIdList())
|
||||
.setCoreProudSkillLevel(this.getAvatar().getCoreProudSkillLevel())
|
||||
.putAllSkillLevelMap(this.getAvatar().getSkillLevelMap())
|
||||
.setSkillDepotId(this.getAvatar().getSkillDepotId())
|
||||
.addAllInherentProudSkillList(this.getAvatar().getProudSkillList())
|
||||
.putAllProudSkillExtraLevelMap(this.getAvatar().getProudSkillBonusMap())
|
||||
.addAllTeamResonanceList(this.getAvatar().getPlayer().getTeamManager().getTeamResonances())
|
||||
.setWearingFlycloakId(this.getAvatar().getFlyCloak())
|
||||
.setCostumeId(this.getAvatar().getCostume())
|
||||
.setBornTime(this.getAvatar().getBornTime());
|
||||
|
||||
for (GameItem item : avatar.getEquips().values()) {
|
||||
if (item.getItemData().getEquipType() == EquipType.EQUIP_WEAPON) {
|
||||
avatarInfo.setWeapon(item.createSceneWeaponInfo());
|
||||
} else {
|
||||
avatarInfo.addReliquaryList(item.createSceneReliquaryInfo());
|
||||
}
|
||||
avatarInfo.addEquipIdList(item.getItemId());
|
||||
}
|
||||
for (GameItem item : avatar.getEquips().values()) {
|
||||
if (item.getItemData().getEquipType() == EquipType.EQUIP_WEAPON) {
|
||||
avatarInfo.setWeapon(item.createSceneWeaponInfo());
|
||||
} else {
|
||||
avatarInfo.addReliquaryList(item.createSceneReliquaryInfo());
|
||||
}
|
||||
avatarInfo.addEquipIdList(item.getItemId());
|
||||
}
|
||||
|
||||
return avatarInfo.build();
|
||||
}
|
||||
return avatarInfo.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SceneEntityInfo toProto() {
|
||||
EntityAuthorityInfo authority = EntityAuthorityInfo.newBuilder()
|
||||
.setAbilityInfo(AbilitySyncStateInfo.newBuilder())
|
||||
.setRendererChangedInfo(EntityRendererChangedInfo.newBuilder())
|
||||
.setAiInfo(SceneEntityAiInfo.newBuilder().setIsAiOpen(true).setBornPos(Vector.newBuilder()))
|
||||
.setBornPos(Vector.newBuilder())
|
||||
.build();
|
||||
@Override
|
||||
public SceneEntityInfo toProto() {
|
||||
EntityAuthorityInfo authority = EntityAuthorityInfo.newBuilder()
|
||||
.setAbilityInfo(AbilitySyncStateInfo.newBuilder())
|
||||
.setRendererChangedInfo(EntityRendererChangedInfo.newBuilder())
|
||||
.setAiInfo(SceneEntityAiInfo.newBuilder().setIsAiOpen(true).setBornPos(Vector.newBuilder()))
|
||||
.setBornPos(Vector.newBuilder())
|
||||
.build();
|
||||
|
||||
SceneEntityInfo.Builder entityInfo = SceneEntityInfo.newBuilder()
|
||||
.setEntityId(getId())
|
||||
.setEntityType(ProtEntityType.PROT_ENTITY_TYPE_AVATAR)
|
||||
.addAnimatorParaList(AnimatorParameterValueInfoPair.newBuilder())
|
||||
.setEntityClientData(EntityClientData.newBuilder())
|
||||
.setEntityAuthorityInfo(authority)
|
||||
.setLastMoveSceneTimeMs(this.getLastMoveSceneTimeMs())
|
||||
.setLastMoveReliableSeq(this.getLastMoveReliableSeq())
|
||||
.setLifeState(this.getLifeState().getValue());
|
||||
SceneEntityInfo.Builder entityInfo = SceneEntityInfo.newBuilder()
|
||||
.setEntityId(getId())
|
||||
.setEntityType(ProtEntityType.PROT_ENTITY_TYPE_AVATAR)
|
||||
.addAnimatorParaList(AnimatorParameterValueInfoPair.newBuilder())
|
||||
.setEntityClientData(EntityClientData.newBuilder())
|
||||
.setEntityAuthorityInfo(authority)
|
||||
.setLastMoveSceneTimeMs(this.getLastMoveSceneTimeMs())
|
||||
.setLastMoveReliableSeq(this.getLastMoveReliableSeq())
|
||||
.setLifeState(this.getLifeState().getValue());
|
||||
|
||||
if (this.getScene() != null) {
|
||||
entityInfo.setMotionInfo(this.getMotionInfo());
|
||||
}
|
||||
if (this.getScene() != null) {
|
||||
entityInfo.setMotionInfo(this.getMotionInfo());
|
||||
}
|
||||
|
||||
for (Int2FloatMap.Entry entry : getFightProperties().int2FloatEntrySet()) {
|
||||
if (entry.getIntKey() == 0) {
|
||||
continue;
|
||||
}
|
||||
FightPropPair fightProp = FightPropPair.newBuilder().setPropType(entry.getIntKey()).setPropValue(entry.getFloatValue()).build();
|
||||
entityInfo.addFightPropList(fightProp);
|
||||
}
|
||||
for (Int2FloatMap.Entry entry : getFightProperties().int2FloatEntrySet()) {
|
||||
if (entry.getIntKey() == 0) {
|
||||
continue;
|
||||
}
|
||||
FightPropPair fightProp = FightPropPair.newBuilder().setPropType(entry.getIntKey()).setPropValue(entry.getFloatValue()).build();
|
||||
entityInfo.addFightPropList(fightProp);
|
||||
}
|
||||
|
||||
PropPair pair = PropPair.newBuilder()
|
||||
.setType(PlayerProperty.PROP_LEVEL.getId())
|
||||
.setPropValue(ProtoHelper.newPropValue(PlayerProperty.PROP_LEVEL, getAvatar().getLevel()))
|
||||
.build();
|
||||
entityInfo.addPropList(pair);
|
||||
PropPair pair = PropPair.newBuilder()
|
||||
.setType(PlayerProperty.PROP_LEVEL.getId())
|
||||
.setPropValue(ProtoHelper.newPropValue(PlayerProperty.PROP_LEVEL, getAvatar().getLevel()))
|
||||
.build();
|
||||
entityInfo.addPropList(pair);
|
||||
|
||||
entityInfo.setAvatar(this.getSceneAvatarInfo());
|
||||
entityInfo.setAvatar(this.getSceneAvatarInfo());
|
||||
|
||||
return entityInfo.build();
|
||||
}
|
||||
return entityInfo.build();
|
||||
}
|
||||
|
||||
public AbilityControlBlock getAbilityControlBlock() {
|
||||
AvatarData data = this.getAvatar().getAvatarData();
|
||||
AbilityControlBlock.Builder abilityControlBlock = AbilityControlBlock.newBuilder();
|
||||
int embryoId = 0;
|
||||
public AbilityControlBlock getAbilityControlBlock() {
|
||||
AvatarData data = this.getAvatar().getAvatarData();
|
||||
AbilityControlBlock.Builder abilityControlBlock = AbilityControlBlock.newBuilder();
|
||||
int embryoId = 0;
|
||||
|
||||
// Add avatar abilities
|
||||
if (data.getAbilities() != null) {
|
||||
for (int id : data.getAbilities()) {
|
||||
AbilityEmbryo emb = AbilityEmbryo.newBuilder()
|
||||
.setAbilityId(++embryoId)
|
||||
.setAbilityNameHash(id)
|
||||
.setAbilityOverrideNameHash(GameConstants.DEFAULT_ABILITY_NAME)
|
||||
.build();
|
||||
abilityControlBlock.addAbilityEmbryoList(emb);
|
||||
}
|
||||
}
|
||||
// Add default abilities
|
||||
for (int id : GameConstants.DEFAULT_ABILITY_HASHES) {
|
||||
AbilityEmbryo emb = AbilityEmbryo.newBuilder()
|
||||
.setAbilityId(++embryoId)
|
||||
.setAbilityNameHash(id)
|
||||
.setAbilityOverrideNameHash(GameConstants.DEFAULT_ABILITY_NAME)
|
||||
.build();
|
||||
abilityControlBlock.addAbilityEmbryoList(emb);
|
||||
}
|
||||
// Add team resonances
|
||||
for (int id : this.getPlayer().getTeamManager().getTeamResonancesConfig()) {
|
||||
AbilityEmbryo emb = AbilityEmbryo.newBuilder()
|
||||
.setAbilityId(++embryoId)
|
||||
.setAbilityNameHash(id)
|
||||
.setAbilityOverrideNameHash(GameConstants.DEFAULT_ABILITY_NAME)
|
||||
.build();
|
||||
abilityControlBlock.addAbilityEmbryoList(emb);
|
||||
}
|
||||
// Add skill depot abilities
|
||||
AvatarSkillDepotData skillDepot = GameData.getAvatarSkillDepotDataMap().get(this.getAvatar().getSkillDepotId());
|
||||
if (skillDepot != null && skillDepot.getAbilities() != null) {
|
||||
for (int id : skillDepot.getAbilities()) {
|
||||
AbilityEmbryo emb = AbilityEmbryo.newBuilder()
|
||||
.setAbilityId(++embryoId)
|
||||
.setAbilityNameHash(id)
|
||||
.setAbilityOverrideNameHash(GameConstants.DEFAULT_ABILITY_NAME)
|
||||
.build();
|
||||
abilityControlBlock.addAbilityEmbryoList(emb);
|
||||
}
|
||||
}
|
||||
// Add equip abilities
|
||||
if (this.getAvatar().getExtraAbilityEmbryos().size() > 0) {
|
||||
for (String skill : this.getAvatar().getExtraAbilityEmbryos()) {
|
||||
AbilityEmbryo emb = AbilityEmbryo.newBuilder()
|
||||
.setAbilityId(++embryoId)
|
||||
.setAbilityNameHash(Utils.abilityHash(skill))
|
||||
.setAbilityOverrideNameHash(GameConstants.DEFAULT_ABILITY_NAME)
|
||||
.build();
|
||||
abilityControlBlock.addAbilityEmbryoList(emb);
|
||||
}
|
||||
}
|
||||
// Add avatar abilities
|
||||
if (data.getAbilities() != null) {
|
||||
for (int id : data.getAbilities()) {
|
||||
AbilityEmbryo emb = AbilityEmbryo.newBuilder()
|
||||
.setAbilityId(++embryoId)
|
||||
.setAbilityNameHash(id)
|
||||
.setAbilityOverrideNameHash(GameConstants.DEFAULT_ABILITY_NAME)
|
||||
.build();
|
||||
abilityControlBlock.addAbilityEmbryoList(emb);
|
||||
}
|
||||
}
|
||||
// Add default abilities
|
||||
for (int id : GameConstants.DEFAULT_ABILITY_HASHES) {
|
||||
AbilityEmbryo emb = AbilityEmbryo.newBuilder()
|
||||
.setAbilityId(++embryoId)
|
||||
.setAbilityNameHash(id)
|
||||
.setAbilityOverrideNameHash(GameConstants.DEFAULT_ABILITY_NAME)
|
||||
.build();
|
||||
abilityControlBlock.addAbilityEmbryoList(emb);
|
||||
}
|
||||
// Add team resonances
|
||||
for (int id : this.getPlayer().getTeamManager().getTeamResonancesConfig()) {
|
||||
AbilityEmbryo emb = AbilityEmbryo.newBuilder()
|
||||
.setAbilityId(++embryoId)
|
||||
.setAbilityNameHash(id)
|
||||
.setAbilityOverrideNameHash(GameConstants.DEFAULT_ABILITY_NAME)
|
||||
.build();
|
||||
abilityControlBlock.addAbilityEmbryoList(emb);
|
||||
}
|
||||
// Add skill depot abilities
|
||||
AvatarSkillDepotData skillDepot = GameData.getAvatarSkillDepotDataMap().get(this.getAvatar().getSkillDepotId());
|
||||
if (skillDepot != null && skillDepot.getAbilities() != null) {
|
||||
for (int id : skillDepot.getAbilities()) {
|
||||
AbilityEmbryo emb = AbilityEmbryo.newBuilder()
|
||||
.setAbilityId(++embryoId)
|
||||
.setAbilityNameHash(id)
|
||||
.setAbilityOverrideNameHash(GameConstants.DEFAULT_ABILITY_NAME)
|
||||
.build();
|
||||
abilityControlBlock.addAbilityEmbryoList(emb);
|
||||
}
|
||||
}
|
||||
// Add equip abilities
|
||||
if (this.getAvatar().getExtraAbilityEmbryos().size() > 0) {
|
||||
for (String skill : this.getAvatar().getExtraAbilityEmbryos()) {
|
||||
AbilityEmbryo emb = AbilityEmbryo.newBuilder()
|
||||
.setAbilityId(++embryoId)
|
||||
.setAbilityNameHash(Utils.abilityHash(skill))
|
||||
.setAbilityOverrideNameHash(GameConstants.DEFAULT_ABILITY_NAME)
|
||||
.build();
|
||||
abilityControlBlock.addAbilityEmbryoList(emb);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return abilityControlBlock.build();
|
||||
}
|
||||
//
|
||||
return abilityControlBlock.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Move this entity to a new position.
|
||||
|
||||
@@ -5,14 +5,14 @@ import emu.grasscutter.game.world.World;
|
||||
|
||||
public abstract class EntityBaseGadget extends GameEntity {
|
||||
|
||||
public EntityBaseGadget(Scene scene) {
|
||||
super(scene);
|
||||
}
|
||||
public EntityBaseGadget(Scene scene) {
|
||||
super(scene);
|
||||
}
|
||||
|
||||
public abstract int getGadgetId();
|
||||
public abstract int getGadgetId();
|
||||
|
||||
@Override
|
||||
public void onDeath(int killerId) {
|
||||
@Override
|
||||
public void onDeath(int killerId) {
|
||||
super.onDeath(killerId); // Invoke super class's onDeath() method.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,140 +22,140 @@ import emu.grasscutter.utils.ProtoHelper;
|
||||
import it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap;
|
||||
|
||||
public class EntityClientGadget extends EntityBaseGadget {
|
||||
private final Player owner;
|
||||
private final Player owner;
|
||||
|
||||
private final Position pos;
|
||||
private final Position rot;
|
||||
private final Position pos;
|
||||
private final Position rot;
|
||||
|
||||
private int configId;
|
||||
private int campId;
|
||||
private int campType;
|
||||
private int ownerEntityId;
|
||||
private int targetEntityId;
|
||||
private boolean asyncLoad;
|
||||
private int configId;
|
||||
private int campId;
|
||||
private int campType;
|
||||
private int ownerEntityId;
|
||||
private int targetEntityId;
|
||||
private boolean asyncLoad;
|
||||
|
||||
private int originalOwnerEntityId;
|
||||
private int originalOwnerEntityId;
|
||||
|
||||
public EntityClientGadget(Scene scene, Player player, EvtCreateGadgetNotify notify) {
|
||||
super(scene);
|
||||
this.owner = player;
|
||||
this.id = notify.getEntityId();
|
||||
this.pos = new Position(notify.getInitPos());
|
||||
this.rot = new Position(notify.getInitEulerAngles());
|
||||
this.configId = notify.getConfigId();
|
||||
this.campId = notify.getCampId();
|
||||
this.campType = notify.getCampType();
|
||||
this.ownerEntityId = notify.getPropOwnerEntityId();
|
||||
this.targetEntityId = notify.getTargetEntityId();
|
||||
this.asyncLoad = notify.getIsAsyncLoad();
|
||||
public EntityClientGadget(Scene scene, Player player, EvtCreateGadgetNotify notify) {
|
||||
super(scene);
|
||||
this.owner = player;
|
||||
this.id = notify.getEntityId();
|
||||
this.pos = new Position(notify.getInitPos());
|
||||
this.rot = new Position(notify.getInitEulerAngles());
|
||||
this.configId = notify.getConfigId();
|
||||
this.campId = notify.getCampId();
|
||||
this.campType = notify.getCampType();
|
||||
this.ownerEntityId = notify.getPropOwnerEntityId();
|
||||
this.targetEntityId = notify.getTargetEntityId();
|
||||
this.asyncLoad = notify.getIsAsyncLoad();
|
||||
|
||||
GameEntity owner = scene.getEntityById(this.ownerEntityId);
|
||||
if (owner instanceof EntityClientGadget ownerGadget) {
|
||||
this.originalOwnerEntityId = ownerGadget.getOriginalOwnerEntityId();
|
||||
}
|
||||
else {
|
||||
this.originalOwnerEntityId = this.ownerEntityId;
|
||||
}
|
||||
}
|
||||
GameEntity owner = scene.getEntityById(this.ownerEntityId);
|
||||
if (owner instanceof EntityClientGadget ownerGadget) {
|
||||
this.originalOwnerEntityId = ownerGadget.getOriginalOwnerEntityId();
|
||||
}
|
||||
else {
|
||||
this.originalOwnerEntityId = this.ownerEntityId;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGadgetId() {
|
||||
return configId;
|
||||
}
|
||||
@Override
|
||||
public int getGadgetId() {
|
||||
return configId;
|
||||
}
|
||||
|
||||
public Player getOwner() {
|
||||
return owner;
|
||||
}
|
||||
public Player getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public int getCampId() {
|
||||
return campId;
|
||||
}
|
||||
public int getCampId() {
|
||||
return campId;
|
||||
}
|
||||
|
||||
public int getCampType() {
|
||||
return campType;
|
||||
}
|
||||
public int getCampType() {
|
||||
return campType;
|
||||
}
|
||||
|
||||
public int getOwnerEntityId() {
|
||||
return ownerEntityId;
|
||||
}
|
||||
public int getOwnerEntityId() {
|
||||
return ownerEntityId;
|
||||
}
|
||||
|
||||
public int getTargetEntityId() {
|
||||
return targetEntityId;
|
||||
}
|
||||
public int getTargetEntityId() {
|
||||
return targetEntityId;
|
||||
}
|
||||
|
||||
public boolean isAsyncLoad() {
|
||||
return this.asyncLoad;
|
||||
}
|
||||
public boolean isAsyncLoad() {
|
||||
return this.asyncLoad;
|
||||
}
|
||||
|
||||
public int getOriginalOwnerEntityId() {
|
||||
return this.originalOwnerEntityId;
|
||||
}
|
||||
public int getOriginalOwnerEntityId() {
|
||||
return this.originalOwnerEntityId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeath(int killerId) {
|
||||
@Override
|
||||
public void onDeath(int killerId) {
|
||||
super.onDeath(killerId); // Invoke super class's onDeath() method.
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Int2FloatOpenHashMap getFightProperties() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public Int2FloatOpenHashMap getFightProperties() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Position getPosition() {
|
||||
// TODO Auto-generated method stub
|
||||
return this.pos;
|
||||
}
|
||||
@Override
|
||||
public Position getPosition() {
|
||||
// TODO Auto-generated method stub
|
||||
return this.pos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Position getRotation() {
|
||||
// TODO Auto-generated method stub
|
||||
return this.rot;
|
||||
}
|
||||
@Override
|
||||
public Position getRotation() {
|
||||
// TODO Auto-generated method stub
|
||||
return this.rot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SceneEntityInfo toProto() {
|
||||
EntityAuthorityInfo authority = EntityAuthorityInfo.newBuilder()
|
||||
.setAbilityInfo(AbilitySyncStateInfo.newBuilder())
|
||||
.setRendererChangedInfo(EntityRendererChangedInfo.newBuilder())
|
||||
.setAiInfo(SceneEntityAiInfo.newBuilder().setIsAiOpen(true).setBornPos(Vector.newBuilder()))
|
||||
.setBornPos(Vector.newBuilder())
|
||||
.build();
|
||||
@Override
|
||||
public SceneEntityInfo toProto() {
|
||||
EntityAuthorityInfo authority = EntityAuthorityInfo.newBuilder()
|
||||
.setAbilityInfo(AbilitySyncStateInfo.newBuilder())
|
||||
.setRendererChangedInfo(EntityRendererChangedInfo.newBuilder())
|
||||
.setAiInfo(SceneEntityAiInfo.newBuilder().setIsAiOpen(true).setBornPos(Vector.newBuilder()))
|
||||
.setBornPos(Vector.newBuilder())
|
||||
.build();
|
||||
|
||||
SceneEntityInfo.Builder entityInfo = SceneEntityInfo.newBuilder()
|
||||
.setEntityId(getId())
|
||||
.setEntityType(ProtEntityType.PROT_ENTITY_TYPE_GADGET)
|
||||
.setMotionInfo(MotionInfo.newBuilder().setPos(getPosition().toProto()).setRot(getRotation().toProto()).setSpeed(Vector.newBuilder()))
|
||||
.addAnimatorParaList(AnimatorParameterValueInfoPair.newBuilder())
|
||||
.setEntityClientData(EntityClientData.newBuilder())
|
||||
.setEntityAuthorityInfo(authority)
|
||||
.setLifeState(1);
|
||||
SceneEntityInfo.Builder entityInfo = SceneEntityInfo.newBuilder()
|
||||
.setEntityId(getId())
|
||||
.setEntityType(ProtEntityType.PROT_ENTITY_TYPE_GADGET)
|
||||
.setMotionInfo(MotionInfo.newBuilder().setPos(getPosition().toProto()).setRot(getRotation().toProto()).setSpeed(Vector.newBuilder()))
|
||||
.addAnimatorParaList(AnimatorParameterValueInfoPair.newBuilder())
|
||||
.setEntityClientData(EntityClientData.newBuilder())
|
||||
.setEntityAuthorityInfo(authority)
|
||||
.setLifeState(1);
|
||||
|
||||
PropPair pair = PropPair.newBuilder()
|
||||
.setType(PlayerProperty.PROP_LEVEL.getId())
|
||||
.setPropValue(ProtoHelper.newPropValue(PlayerProperty.PROP_LEVEL, 1))
|
||||
.build();
|
||||
entityInfo.addPropList(pair);
|
||||
PropPair pair = PropPair.newBuilder()
|
||||
.setType(PlayerProperty.PROP_LEVEL.getId())
|
||||
.setPropValue(ProtoHelper.newPropValue(PlayerProperty.PROP_LEVEL, 1))
|
||||
.build();
|
||||
entityInfo.addPropList(pair);
|
||||
|
||||
ClientGadgetInfoOuterClass.ClientGadgetInfo clientGadget = ClientGadgetInfoOuterClass.ClientGadgetInfo.newBuilder()
|
||||
.setCampId(this.getCampId())
|
||||
.setCampType(this.getCampType())
|
||||
.setOwnerEntityId(this.getOwnerEntityId())
|
||||
.setTargetEntityId(this.getTargetEntityId())
|
||||
.setAsyncLoad(this.isAsyncLoad())
|
||||
.build();
|
||||
ClientGadgetInfoOuterClass.ClientGadgetInfo clientGadget = ClientGadgetInfoOuterClass.ClientGadgetInfo.newBuilder()
|
||||
.setCampId(this.getCampId())
|
||||
.setCampType(this.getCampType())
|
||||
.setOwnerEntityId(this.getOwnerEntityId())
|
||||
.setTargetEntityId(this.getTargetEntityId())
|
||||
.setAsyncLoad(this.isAsyncLoad())
|
||||
.build();
|
||||
|
||||
SceneGadgetInfo.Builder gadgetInfo = SceneGadgetInfo.newBuilder()
|
||||
.setGadgetId(this.getGadgetId())
|
||||
.setOwnerEntityId(this.getOwnerEntityId())
|
||||
.setIsEnableInteract(true)
|
||||
.setClientGadget(clientGadget)
|
||||
.setPropOwnerEntityId(this.getOwnerEntityId())
|
||||
.setAuthorityPeerId(this.getOwner().getPeerId());
|
||||
SceneGadgetInfo.Builder gadgetInfo = SceneGadgetInfo.newBuilder()
|
||||
.setGadgetId(this.getGadgetId())
|
||||
.setOwnerEntityId(this.getOwnerEntityId())
|
||||
.setIsEnableInteract(true)
|
||||
.setClientGadget(clientGadget)
|
||||
.setPropOwnerEntityId(this.getOwnerEntityId())
|
||||
.setAuthorityPeerId(this.getOwner().getPeerId());
|
||||
|
||||
entityInfo.setGadget(gadgetInfo);
|
||||
entityInfo.setGadget(gadgetInfo);
|
||||
|
||||
return entityInfo.build();
|
||||
}
|
||||
return entityInfo.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ public class EntityGadget extends EntityBaseGadget {
|
||||
.setIsEnableInteract(true)
|
||||
.setAuthorityPeerId(this.getScene().getWorld().getHostPeerId());
|
||||
|
||||
if(this.metaGadget != null) {
|
||||
if (this.metaGadget != null) {
|
||||
gadgetInfo.setDraftId(this.metaGadget.draft_id);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,64 +25,64 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
public abstract class GameEntity {
|
||||
protected int id;
|
||||
private final Scene scene;
|
||||
private SpawnDataEntry spawnEntry;
|
||||
protected int id;
|
||||
private final Scene scene;
|
||||
private SpawnDataEntry spawnEntry;
|
||||
|
||||
private int blockId;
|
||||
private int configId;
|
||||
private int groupId;
|
||||
private int blockId;
|
||||
private int configId;
|
||||
private int groupId;
|
||||
|
||||
private MotionState moveState;
|
||||
private int lastMoveSceneTimeMs;
|
||||
private int lastMoveReliableSeq;
|
||||
private MotionState moveState;
|
||||
private int lastMoveSceneTimeMs;
|
||||
private int lastMoveReliableSeq;
|
||||
|
||||
// Abilities
|
||||
private Map<String, Float> metaOverrideMap;
|
||||
private Int2ObjectMap<String> metaModifiers;
|
||||
// Abilities
|
||||
private Map<String, Float> metaOverrideMap;
|
||||
private Int2ObjectMap<String> metaModifiers;
|
||||
|
||||
public GameEntity(Scene scene) {
|
||||
this.scene = scene;
|
||||
this.moveState = MotionState.MOTION_STATE_NONE;
|
||||
}
|
||||
public GameEntity(Scene scene) {
|
||||
this.scene = scene;
|
||||
this.moveState = MotionState.MOTION_STATE_NONE;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public int getEntityType() {
|
||||
return this.getId() >> 24;
|
||||
}
|
||||
public int getEntityType() {
|
||||
return this.getId() >> 24;
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return this.getScene().getWorld();
|
||||
}
|
||||
public World getWorld() {
|
||||
return this.getScene().getWorld();
|
||||
}
|
||||
|
||||
public Scene getScene() {
|
||||
return this.scene;
|
||||
}
|
||||
public Scene getScene() {
|
||||
return this.scene;
|
||||
}
|
||||
|
||||
public boolean isAlive() {
|
||||
return true;
|
||||
}
|
||||
public boolean isAlive() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public LifeState getLifeState() {
|
||||
return this.isAlive() ? LifeState.LIFE_ALIVE : LifeState.LIFE_DEAD;
|
||||
}
|
||||
public LifeState getLifeState() {
|
||||
return this.isAlive() ? LifeState.LIFE_ALIVE : LifeState.LIFE_DEAD;
|
||||
}
|
||||
|
||||
public Map<String, Float> getMetaOverrideMap() {
|
||||
if (this.metaOverrideMap == null) {
|
||||
this.metaOverrideMap = new HashMap<>();
|
||||
}
|
||||
return this.metaOverrideMap;
|
||||
}
|
||||
public Map<String, Float> getMetaOverrideMap() {
|
||||
if (this.metaOverrideMap == null) {
|
||||
this.metaOverrideMap = new HashMap<>();
|
||||
}
|
||||
return this.metaOverrideMap;
|
||||
}
|
||||
|
||||
public Int2ObjectMap<String> getMetaModifiers() {
|
||||
if (this.metaModifiers == null) {
|
||||
this.metaModifiers = new Int2ObjectOpenHashMap<>();
|
||||
}
|
||||
return this.metaModifiers;
|
||||
}
|
||||
public Int2ObjectMap<String> getMetaModifiers() {
|
||||
if (this.metaModifiers == null) {
|
||||
this.metaModifiers = new Int2ObjectOpenHashMap<>();
|
||||
}
|
||||
return this.metaModifiers;
|
||||
}
|
||||
|
||||
public abstract Int2FloatOpenHashMap getFightProperties();
|
||||
|
||||
@@ -215,12 +215,12 @@ public abstract class GameEntity {
|
||||
|
||||
// Invoke entity damage event.
|
||||
EntityDamageEvent event = new EntityDamageEvent(this, amount, this.getScene().getEntityById(killerId));
|
||||
event.call();
|
||||
event.call();
|
||||
if (event.isCanceled()) {
|
||||
return; // If the event is canceled, do not damage the entity.
|
||||
}
|
||||
|
||||
if(getFightProperty(FightProperty.FIGHT_PROP_CUR_HP) != Float.POSITIVE_INFINITY){
|
||||
|
||||
if (getFightProperty(FightProperty.FIGHT_PROP_CUR_HP) != Float.POSITIVE_INFINITY) {
|
||||
// Add negative HP to the current HP property.
|
||||
this.addFightProperty(FightProperty.FIGHT_PROP_CUR_HP, -(event.getDamage()));
|
||||
}
|
||||
|
||||
@@ -35,10 +35,10 @@ public class GadgetChest extends GadgetContent {
|
||||
return false;
|
||||
}else {
|
||||
boolean success;
|
||||
if(handler instanceof BossChestInteractHandler bossChestInteractHandler){
|
||||
if (handler instanceof BossChestInteractHandler bossChestInteractHandler) {
|
||||
success = bossChestInteractHandler.onInteract(this, player,
|
||||
req.getResinCostType()== ResinCostTypeOuterClass.ResinCostType.RESIN_COST_TYPE_CONDENSE);
|
||||
}else{
|
||||
}else {
|
||||
success = handler.onInteract(this, player);
|
||||
}
|
||||
if (!success) {
|
||||
|
||||
@@ -13,46 +13,46 @@ import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||
|
||||
public class GadgetWorktop extends GadgetContent {
|
||||
private IntSet worktopOptions;
|
||||
private IntSet worktopOptions;
|
||||
private WorktopWorktopOptionHandler handler;
|
||||
|
||||
public GadgetWorktop(EntityGadget gadget) {
|
||||
super(gadget);
|
||||
}
|
||||
public GadgetWorktop(EntityGadget gadget) {
|
||||
super(gadget);
|
||||
}
|
||||
|
||||
public IntSet getWorktopOptions() {
|
||||
return worktopOptions;
|
||||
}
|
||||
public IntSet getWorktopOptions() {
|
||||
return worktopOptions;
|
||||
}
|
||||
|
||||
public void addWorktopOptions(int[] options) {
|
||||
if (this.worktopOptions == null) {
|
||||
this.worktopOptions = new IntOpenHashSet();
|
||||
}
|
||||
Arrays.stream(options).forEach(this.worktopOptions::add);
|
||||
}
|
||||
public void addWorktopOptions(int[] options) {
|
||||
if (this.worktopOptions == null) {
|
||||
this.worktopOptions = new IntOpenHashSet();
|
||||
}
|
||||
Arrays.stream(options).forEach(this.worktopOptions::add);
|
||||
}
|
||||
|
||||
public void removeWorktopOption(int option) {
|
||||
if (this.worktopOptions == null) {
|
||||
return;
|
||||
}
|
||||
this.worktopOptions.remove(option);
|
||||
}
|
||||
public void removeWorktopOption(int option) {
|
||||
if (this.worktopOptions == null) {
|
||||
return;
|
||||
}
|
||||
this.worktopOptions.remove(option);
|
||||
}
|
||||
|
||||
public boolean onInteract(Player player, GadgetInteractReq req) {
|
||||
return false;
|
||||
}
|
||||
public boolean onInteract(Player player, GadgetInteractReq req) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void onBuildProto(SceneGadgetInfo.Builder gadgetInfo) {
|
||||
if (this.worktopOptions == null) {
|
||||
return;
|
||||
}
|
||||
public void onBuildProto(SceneGadgetInfo.Builder gadgetInfo) {
|
||||
if (this.worktopOptions == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
WorktopInfo worktop = WorktopInfo.newBuilder()
|
||||
.addAllOptionList(this.getWorktopOptions())
|
||||
.build();
|
||||
WorktopInfo worktop = WorktopInfo.newBuilder()
|
||||
.addAllOptionList(this.getWorktopOptions())
|
||||
.build();
|
||||
|
||||
gadgetInfo.setWorktop(worktop);
|
||||
}
|
||||
gadgetInfo.setWorktop(worktop);
|
||||
}
|
||||
|
||||
public void setOnSelectWorktopOptionEvent(WorktopWorktopOptionHandler handler) {
|
||||
this.handler = handler;
|
||||
|
||||
@@ -24,7 +24,7 @@ public class BossChestInteractHandler implements ChestInteractHandler{
|
||||
|
||||
public boolean onInteract(GadgetChest chest, Player player,boolean useCondensedResin) {
|
||||
var blossomRewards = player.getScene().getBlossomManager().onReward(player,chest.getGadget(),useCondensedResin);
|
||||
if(blossomRewards!=null) {
|
||||
if (blossomRewards!=null) {
|
||||
player.getInventory().addItems(blossomRewards, ActionReason.OpenWorldBossChest);
|
||||
player.sendPacket(new PacketGadgetAutoPickDropInfoNotify(blossomRewards));
|
||||
return true;
|
||||
|
||||
@@ -3,4 +3,4 @@ package emu.grasscutter.game.entity.gadget.worktop;
|
||||
import emu.grasscutter.game.entity.gadget.GadgetWorktop;
|
||||
public interface WorktopWorktopOptionHandler {
|
||||
boolean onSelectWorktopOption(GadgetWorktop gadgetWorktop,int option);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,31 +47,31 @@ public enum MaterialType {
|
||||
MATERIAL_ACTIVITY_ROBOT (38),
|
||||
MATERIAL_ACTIVITY_GEAR (39),
|
||||
MATERIAL_ACTIVITY_JIGSAW (40);
|
||||
|
||||
private final int value;
|
||||
private static final Int2ObjectMap<MaterialType> map = new Int2ObjectOpenHashMap<>();
|
||||
private static final Map<String, MaterialType> stringMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
Stream.of(values()).forEach(e -> {
|
||||
map.put(e.getValue(), e);
|
||||
stringMap.put(e.name(), e);
|
||||
});
|
||||
}
|
||||
|
||||
private MaterialType(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static MaterialType getTypeByValue(int value) {
|
||||
return map.getOrDefault(value, MATERIAL_NONE);
|
||||
}
|
||||
|
||||
public static MaterialType getTypeByName(String name) {
|
||||
return stringMap.getOrDefault(name, MATERIAL_NONE);
|
||||
}
|
||||
private final int value;
|
||||
private static final Int2ObjectMap<MaterialType> map = new Int2ObjectOpenHashMap<>();
|
||||
private static final Map<String, MaterialType> stringMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
Stream.of(values()).forEach(e -> {
|
||||
map.put(e.getValue(), e);
|
||||
stringMap.put(e.name(), e);
|
||||
});
|
||||
}
|
||||
|
||||
private MaterialType(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static MaterialType getTypeByValue(int value) {
|
||||
return map.getOrDefault(value, MATERIAL_NONE);
|
||||
}
|
||||
|
||||
public static MaterialType getTypeByName(String name) {
|
||||
return stringMap.getOrDefault(name, MATERIAL_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class FurnitureManager extends BasePlayerManager {
|
||||
|
||||
public synchronized boolean unlockFurnitureOrSuite(GameItem useItem) {
|
||||
ItemUseOp itemUseOp = useItem.getItemData().getItemUse().get(0).getUseOp();
|
||||
|
||||
|
||||
// Check
|
||||
if (itemUseOp != ItemUseOp.ITEM_USE_UNLOCK_FURNITURE_SUITE && itemUseOp != ItemUseOp.ITEM_USE_UNLOCK_FURNITURE_FORMULA) {
|
||||
return false;
|
||||
|
||||
@@ -54,36 +54,36 @@ public class BlossomActivity {
|
||||
challengeTriggers.add(new KillMonsterTrigger());
|
||||
//this.challengeTriggers.add(new InTimeTrigger());
|
||||
}
|
||||
public WorldChallenge getChallenge(){
|
||||
public WorldChallenge getChallenge() {
|
||||
return this.challenge;
|
||||
}
|
||||
public void setMonsters(List<EntityMonster> monsters) {
|
||||
this.activeMonsters.clear();
|
||||
this.activeMonsters.addAll(monsters);
|
||||
for(EntityMonster monster : monsters){
|
||||
for (EntityMonster monster : monsters) {
|
||||
monster.setGroupId(this.tempSceneGroup.id);
|
||||
}
|
||||
}
|
||||
public int getAliveMonstersCount(){
|
||||
public int getAliveMonstersCount() {
|
||||
int count=0;
|
||||
for(EntityMonster monster: activeMonsters) {
|
||||
if(monster.isAlive()){
|
||||
for (EntityMonster monster: activeMonsters) {
|
||||
if (monster.isAlive()) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
public boolean getPass(){
|
||||
public boolean getPass() {
|
||||
return pass;
|
||||
}
|
||||
public void start(){
|
||||
public void start() {
|
||||
challenge.start();
|
||||
}
|
||||
public void onTick() {
|
||||
Scene scene = gadget.getScene();
|
||||
Position pos = gadget.getPosition();
|
||||
if(getAliveMonstersCount() <= 2){
|
||||
if(generatedCount<goal){
|
||||
if (getAliveMonstersCount() <= 2) {
|
||||
if (generatedCount<goal) {
|
||||
step++;
|
||||
|
||||
WorldLevelData worldLevelData = GameData.getWorldLevelDataMap().get(worldLevel);
|
||||
@@ -94,7 +94,7 @@ public class BlossomActivity {
|
||||
|
||||
List<EntityMonster> newMonsters = new ArrayList<>();
|
||||
int willSpawn = Utils.randomRange(3,5);
|
||||
if(generatedCount+willSpawn>goal){
|
||||
if (generatedCount+willSpawn>goal) {
|
||||
willSpawn = goal - generatedCount;
|
||||
}
|
||||
generatedCount+=willSpawn;
|
||||
@@ -106,19 +106,19 @@ public class BlossomActivity {
|
||||
newMonsters.add(entity);
|
||||
}
|
||||
setMonsters(newMonsters);
|
||||
}else{
|
||||
if(getAliveMonstersCount() == 0) {
|
||||
}else {
|
||||
if (getAliveMonstersCount() == 0) {
|
||||
this.pass = true;
|
||||
this.challenge.done();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public EntityGadget getGadget(){
|
||||
public EntityGadget getGadget() {
|
||||
return gadget;
|
||||
}
|
||||
public EntityGadget getChest(){
|
||||
if(chest==null) {
|
||||
public EntityGadget getChest() {
|
||||
if (chest==null) {
|
||||
EntityGadget rewardGadget = new EntityGadget(gadget.getScene(), BLOOMING_GADGET_ID, gadget.getPosition());
|
||||
SceneGadget metaGadget = new SceneGadget();
|
||||
metaGadget.boss_chest = new SceneBossChest();
|
||||
|
||||
@@ -37,10 +37,10 @@ public class BlossomManager {
|
||||
|
||||
private final List<SpawnDataEntry> blossomConsumed = new ArrayList<>();
|
||||
|
||||
public void onTick(){
|
||||
synchronized (blossomActivities){
|
||||
public void onTick() {
|
||||
synchronized (blossomActivities) {
|
||||
var it = blossomActivities.iterator();
|
||||
while(it.hasNext()){
|
||||
while (it.hasNext()) {
|
||||
var active = it.next();
|
||||
active.onTick();
|
||||
if (active.getPass()) {
|
||||
@@ -54,24 +54,24 @@ public class BlossomManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void recycleGadgetEntity(List<GameEntity> entities){
|
||||
for(var entity : entities){
|
||||
if(entity instanceof EntityGadget gadget){
|
||||
public void recycleGadgetEntity(List<GameEntity> entities) {
|
||||
for (var entity : entities) {
|
||||
if (entity instanceof EntityGadget gadget) {
|
||||
createdEntity.remove(gadget);
|
||||
}
|
||||
}
|
||||
notifyIcon();
|
||||
}
|
||||
|
||||
public void initBlossom(EntityGadget gadget){
|
||||
if(createdEntity.contains(gadget)){
|
||||
public void initBlossom(EntityGadget gadget) {
|
||||
if (createdEntity.contains(gadget)) {
|
||||
return;
|
||||
}
|
||||
if(blossomConsumed.contains(gadget.getSpawnEntry())){
|
||||
if (blossomConsumed.contains(gadget.getSpawnEntry())) {
|
||||
return;
|
||||
}
|
||||
var id = gadget.getGadgetId();
|
||||
if(BlossomType.valueOf(id)==null){
|
||||
if (BlossomType.valueOf(id)==null) {
|
||||
return;
|
||||
}
|
||||
gadget.buildContent();
|
||||
@@ -91,19 +91,19 @@ public class BlossomManager {
|
||||
|
||||
int volume=0;
|
||||
IntList monsters = new IntArrayList();
|
||||
while(true){
|
||||
while (true) {
|
||||
var remain = GameDepot.getBlossomConfig().getMonsterFightingVolume() - volume;
|
||||
if(remain<=0){
|
||||
if (remain<=0) {
|
||||
break;
|
||||
}
|
||||
var rand = Utils.randomRange(1,100);
|
||||
if(rand>85 && remain>=50){//15% ,generate strong monster
|
||||
if (rand>85 && remain>=50) {//15% ,generate strong monster
|
||||
monsters.addAll(getRandomMonstersID(2,1));
|
||||
volume+=50;
|
||||
}else if(rand>50 && remain>=20) {//35% ,generate normal monster
|
||||
}else if (rand>50 && remain>=20) {//35% ,generate normal monster
|
||||
monsters.addAll(getRandomMonstersID(1,1));
|
||||
volume+=20;
|
||||
}else{//50% ,generate weak monster
|
||||
}else {//50% ,generate weak monster
|
||||
monsters.addAll(getRandomMonstersID(0,1));
|
||||
volume+=10;
|
||||
}
|
||||
@@ -155,7 +155,7 @@ public class BlossomManager {
|
||||
scene.broadcastPacket(new PacketBlossomBriefInfoNotify(blossoms));
|
||||
}
|
||||
|
||||
public int getWorldLevel(){
|
||||
public int getWorldLevel() {
|
||||
return scene.getWorld().getWorldLevel();
|
||||
}
|
||||
|
||||
@@ -226,10 +226,10 @@ public class BlossomManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static IntList getRandomMonstersID(int difficulty,int count){
|
||||
public static IntList getRandomMonstersID(int difficulty,int count) {
|
||||
IntList result = new IntArrayList();
|
||||
List<Integer> monsters = GameDepot.getBlossomConfig().getMonsterIdsPerDifficulty().get(difficulty);
|
||||
for(int i=0; i<count; i++){
|
||||
for (int i=0; i<count; i++) {
|
||||
result.add((int) monsters.get(Utils.randomRange(0, monsters.size()-1)));
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -554,9 +554,9 @@ public class Player {
|
||||
|
||||
public void onEnterRegion(SceneRegion region) {
|
||||
getQuestManager().forEachActiveQuest(quest -> {
|
||||
if(quest.getTriggers().containsKey("ENTER_REGION_"+ String.valueOf(region.config_id))) {
|
||||
if (quest.getTriggers().containsKey("ENTER_REGION_"+ String.valueOf(region.config_id))) {
|
||||
// If trigger hasn't been fired yet
|
||||
if(!Boolean.TRUE.equals(quest.getTriggers().put("ENTER_REGION_"+ String.valueOf(region.config_id), true))) {
|
||||
if (!Boolean.TRUE.equals(quest.getTriggers().put("ENTER_REGION_"+ String.valueOf(region.config_id), true))) {
|
||||
//getSession().send(new PacketServerCondMeetQuestListUpdateNotify());
|
||||
getQuestManager().triggerEvent(QuestTrigger.QUEST_CONTENT_TRIGGER_FIRE, quest.getTriggerData().get("ENTER_REGION_"+ String.valueOf(region.config_id)).getId(),0);
|
||||
}
|
||||
@@ -567,9 +567,9 @@ public class Player {
|
||||
|
||||
public void onLeaveRegion(SceneRegion region) {
|
||||
getQuestManager().forEachActiveQuest(quest -> {
|
||||
if(quest.getTriggers().containsKey("LEAVE_REGION_"+ String.valueOf(region.config_id))) {
|
||||
if (quest.getTriggers().containsKey("LEAVE_REGION_"+ String.valueOf(region.config_id))) {
|
||||
// If trigger hasn't been fired yet
|
||||
if(!Boolean.TRUE.equals(quest.getTriggers().put("LEAVE_REGION_"+ String.valueOf(region.config_id), true))) {
|
||||
if (!Boolean.TRUE.equals(quest.getTriggers().put("LEAVE_REGION_"+ String.valueOf(region.config_id), true))) {
|
||||
getSession().send(new PacketServerCondMeetQuestListUpdateNotify());
|
||||
getQuestManager().triggerEvent(QuestTrigger.QUEST_CONTENT_TRIGGER_FIRE, quest.getTriggerData().get("LEAVE_REGION_"+ String.valueOf(region.config_id)).getId(),0);
|
||||
}
|
||||
|
||||
@@ -18,16 +18,16 @@ import lombok.Getter;
|
||||
@Getter(AccessLevel.PRIVATE)
|
||||
public class PlayerBuffManager extends BasePlayerManager {
|
||||
private int nextBuffUid;
|
||||
|
||||
|
||||
private final List<PlayerBuff> pendingBuffs;
|
||||
private final Int2ObjectMap<PlayerBuff> buffs; // Server buffs
|
||||
|
||||
|
||||
public PlayerBuffManager(Player player) {
|
||||
super(player);
|
||||
this.buffs = new Int2ObjectOpenHashMap<>();
|
||||
this.pendingBuffs = new LinkedList<>();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets a new uid for a server buff
|
||||
* @return New integer buff uid
|
||||
@@ -35,7 +35,7 @@ public class PlayerBuffManager extends BasePlayerManager {
|
||||
private int getNextBuffUid() {
|
||||
return ++nextBuffUid;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if the player has a buff with this group id
|
||||
* @param groupId Buff group id
|
||||
@@ -44,7 +44,7 @@ public class PlayerBuffManager extends BasePlayerManager {
|
||||
public synchronized boolean hasBuff(int groupId) {
|
||||
return this.getBuffs().containsKey(groupId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clears all player buffs
|
||||
*/
|
||||
@@ -53,11 +53,11 @@ public class PlayerBuffManager extends BasePlayerManager {
|
||||
getPlayer().sendPacket(
|
||||
new PacketServerBuffChangeNotify(getPlayer(), ServerBuffChangeType.SERVER_BUFF_CHANGE_TYPE_DEL_SERVER_BUFF, getBuffs().values())
|
||||
);
|
||||
|
||||
|
||||
// Clear
|
||||
getBuffs().clear();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds a server buff to the player.
|
||||
* @param buffId Server buff id
|
||||
@@ -66,7 +66,7 @@ public class PlayerBuffManager extends BasePlayerManager {
|
||||
public boolean addBuff(int buffId) {
|
||||
return addBuff(buffId, -1f);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds a server buff to the player.
|
||||
* @param buffId Server buff id
|
||||
@@ -77,32 +77,32 @@ public class PlayerBuffManager extends BasePlayerManager {
|
||||
// Get buff excel data
|
||||
BuffData buffData = GameData.getBuffDataMap().get(buffId);
|
||||
if (buffData == null) return false;
|
||||
|
||||
|
||||
// Set duration
|
||||
if (duration < 0f) {
|
||||
duration = buffData.getTime();
|
||||
}
|
||||
|
||||
|
||||
// Dont add buff if duration is equal or less than 0
|
||||
if (duration <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Clear previous buff if it exists
|
||||
if (this.hasBuff(buffData.getGroupId())) {
|
||||
this.removeBuff(buffData.getGroupId());
|
||||
}
|
||||
|
||||
|
||||
// Create and store buff
|
||||
PlayerBuff buff = new PlayerBuff(getNextBuffUid(), buffData, duration);
|
||||
getBuffs().put(buff.getGroupId(), buff);
|
||||
|
||||
|
||||
// Packet
|
||||
getPlayer().sendPacket(new PacketServerBuffChangeNotify(getPlayer(), ServerBuffChangeType.SERVER_BUFF_CHANGE_TYPE_ADD_SERVER_BUFF, buff));
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Removes a buff by its group id
|
||||
* @param buffGroupId Server buff group id
|
||||
@@ -110,36 +110,36 @@ public class PlayerBuffManager extends BasePlayerManager {
|
||||
*/
|
||||
public synchronized boolean removeBuff(int buffGroupId) {
|
||||
PlayerBuff buff = this.getBuffs().get(buffGroupId);
|
||||
|
||||
|
||||
if (buff != null) {
|
||||
getPlayer().sendPacket(
|
||||
new PacketServerBuffChangeNotify(getPlayer(), ServerBuffChangeType.SERVER_BUFF_CHANGE_TYPE_DEL_SERVER_BUFF, buff)
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public synchronized void onTick() {
|
||||
// Skip if no buffs
|
||||
if (getBuffs().size() == 0) return;
|
||||
|
||||
|
||||
long currentTime = System.currentTimeMillis();
|
||||
|
||||
|
||||
// Add to pending buffs to remove if buff has expired
|
||||
for (PlayerBuff buff : getBuffs().values()) {
|
||||
if (currentTime > buff.getEndTime()) {
|
||||
this.getPendingBuffs().add(buff);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (this.getPendingBuffs().size() > 0) {
|
||||
// Send packet
|
||||
getPlayer().sendPacket(
|
||||
new PacketServerBuffChangeNotify(getPlayer(), ServerBuffChangeType.SERVER_BUFF_CHANGE_TYPE_DEL_SERVER_BUFF, this.pendingBuffs)
|
||||
);
|
||||
|
||||
|
||||
// Remove buff from player buff map
|
||||
for (PlayerBuff buff : this.getPendingBuffs()) {
|
||||
getBuffs().remove(buff.getGroupId());
|
||||
@@ -147,19 +147,19 @@ public class PlayerBuffManager extends BasePlayerManager {
|
||||
this.getPendingBuffs().clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Getter
|
||||
public static class PlayerBuff {
|
||||
private final int uid;
|
||||
private final BuffData buffData;
|
||||
private final long endTime;
|
||||
|
||||
|
||||
public PlayerBuff(int uid, BuffData buffData, float duration) {
|
||||
this.uid = uid;
|
||||
this.buffData = buffData;
|
||||
this.endTime = System.currentTimeMillis() + ((long) duration * 1000);
|
||||
}
|
||||
|
||||
|
||||
public int getGroupId() {
|
||||
return getBuffData().getGroupId();
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public class PlayerProgressManager extends BasePlayerDataManager {
|
||||
// that particular statue interactable.
|
||||
this.player.getUnlockedScenePoints(3).add(7);
|
||||
this.player.getUnlockedSceneAreas(3).add(1);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/******************************************************************************************************************
|
||||
@@ -199,9 +199,9 @@ public class PlayerProgressManager extends BasePlayerDataManager {
|
||||
public boolean unlockTransPoint(int sceneId, int pointId, boolean isStatue) {
|
||||
// Check whether the unlocked point exists and whether it is still locked.
|
||||
String key = sceneId + "_" + pointId;
|
||||
ScenePointEntry scenePointEntry = GameData.getScenePointEntries().get(key);
|
||||
ScenePointEntry scenePointEntry = GameData.getScenePointEntries().get(key);
|
||||
|
||||
if (scenePointEntry == null || this.player.getUnlockedScenePoints(sceneId).contains(pointId)) {
|
||||
if (scenePointEntry == null || this.player.getUnlockedScenePoints(sceneId).contains(pointId)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,60 +10,60 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import lombok.Getter;
|
||||
|
||||
public enum ElementType {
|
||||
None (0, FightProperty.FIGHT_PROP_CUR_FIRE_ENERGY, FightProperty.FIGHT_PROP_MAX_FIRE_ENERGY),
|
||||
Fire (1, FightProperty.FIGHT_PROP_CUR_FIRE_ENERGY, FightProperty.FIGHT_PROP_MAX_FIRE_ENERGY, 10101, "TeamResonance_Fire_Lv2", 2),
|
||||
Water (2, FightProperty.FIGHT_PROP_CUR_WATER_ENERGY, FightProperty.FIGHT_PROP_MAX_WATER_ENERGY, 10201, "TeamResonance_Water_Lv2", 3),
|
||||
Grass (3, FightProperty.FIGHT_PROP_CUR_GRASS_ENERGY, FightProperty.FIGHT_PROP_MAX_GRASS_ENERGY),
|
||||
Electric (4, FightProperty.FIGHT_PROP_CUR_ELEC_ENERGY, FightProperty.FIGHT_PROP_MAX_ELEC_ENERGY, 10401, "TeamResonance_Electric_Lv2", 7),
|
||||
Ice (5, FightProperty.FIGHT_PROP_CUR_ICE_ENERGY, FightProperty.FIGHT_PROP_MAX_ICE_ENERGY, 10601, "TeamResonance_Ice_Lv2", 5),
|
||||
Frozen (6, FightProperty.FIGHT_PROP_CUR_ICE_ENERGY, FightProperty.FIGHT_PROP_MAX_ICE_ENERGY),
|
||||
Wind (7, FightProperty.FIGHT_PROP_CUR_WIND_ENERGY, FightProperty.FIGHT_PROP_MAX_WIND_ENERGY, 10301, "TeamResonance_Wind_Lv2", 4),
|
||||
Rock (8, FightProperty.FIGHT_PROP_CUR_ROCK_ENERGY, FightProperty.FIGHT_PROP_MAX_ROCK_ENERGY, 10701, "TeamResonance_Rock_Lv2", 6),
|
||||
AntiFire (9, FightProperty.FIGHT_PROP_CUR_FIRE_ENERGY, FightProperty.FIGHT_PROP_MAX_FIRE_ENERGY),
|
||||
Default (255, FightProperty.FIGHT_PROP_CUR_FIRE_ENERGY, FightProperty.FIGHT_PROP_MAX_FIRE_ENERGY, 10801, "TeamResonance_AllDifferent");
|
||||
|
||||
@Getter private final int value;
|
||||
@Getter private final int teamResonanceId;
|
||||
@Getter private final FightProperty curEnergyProp;
|
||||
@Getter private final FightProperty maxEnergyProp;
|
||||
@Getter private int depotValue;
|
||||
@Getter private final int configHash;
|
||||
private static final Int2ObjectMap<ElementType> map = new Int2ObjectOpenHashMap<>();
|
||||
private static final Map<String, ElementType> stringMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
Stream.of(values()).forEach(e -> {
|
||||
map.put(e.getValue(), e);
|
||||
stringMap.put(e.name(), e);
|
||||
});
|
||||
}
|
||||
|
||||
private ElementType(int value, FightProperty curEnergyProp, FightProperty maxEnergyProp) {
|
||||
this(value, curEnergyProp, maxEnergyProp, 0, null);
|
||||
}
|
||||
|
||||
private ElementType(int value, FightProperty curEnergyProp, FightProperty maxEnergyProp, int teamResonanceId, String configName) {
|
||||
this.value = value;
|
||||
this.curEnergyProp = curEnergyProp;
|
||||
this.maxEnergyProp = maxEnergyProp;
|
||||
this.teamResonanceId = teamResonanceId;
|
||||
if (configName != null) {
|
||||
this.configHash = Utils.abilityHash(configName);
|
||||
} else {
|
||||
this.configHash = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private ElementType(int value, FightProperty curEnergyProp, FightProperty maxEnergyProp, int teamResonanceId, String configName, int depotValue) {
|
||||
this(value, curEnergyProp, maxEnergyProp, teamResonanceId, configName);
|
||||
this.depotValue = depotValue;
|
||||
}
|
||||
None (0, FightProperty.FIGHT_PROP_CUR_FIRE_ENERGY, FightProperty.FIGHT_PROP_MAX_FIRE_ENERGY),
|
||||
Fire (1, FightProperty.FIGHT_PROP_CUR_FIRE_ENERGY, FightProperty.FIGHT_PROP_MAX_FIRE_ENERGY, 10101, "TeamResonance_Fire_Lv2", 2),
|
||||
Water (2, FightProperty.FIGHT_PROP_CUR_WATER_ENERGY, FightProperty.FIGHT_PROP_MAX_WATER_ENERGY, 10201, "TeamResonance_Water_Lv2", 3),
|
||||
Grass (3, FightProperty.FIGHT_PROP_CUR_GRASS_ENERGY, FightProperty.FIGHT_PROP_MAX_GRASS_ENERGY),
|
||||
Electric (4, FightProperty.FIGHT_PROP_CUR_ELEC_ENERGY, FightProperty.FIGHT_PROP_MAX_ELEC_ENERGY, 10401, "TeamResonance_Electric_Lv2", 7),
|
||||
Ice (5, FightProperty.FIGHT_PROP_CUR_ICE_ENERGY, FightProperty.FIGHT_PROP_MAX_ICE_ENERGY, 10601, "TeamResonance_Ice_Lv2", 5),
|
||||
Frozen (6, FightProperty.FIGHT_PROP_CUR_ICE_ENERGY, FightProperty.FIGHT_PROP_MAX_ICE_ENERGY),
|
||||
Wind (7, FightProperty.FIGHT_PROP_CUR_WIND_ENERGY, FightProperty.FIGHT_PROP_MAX_WIND_ENERGY, 10301, "TeamResonance_Wind_Lv2", 4),
|
||||
Rock (8, FightProperty.FIGHT_PROP_CUR_ROCK_ENERGY, FightProperty.FIGHT_PROP_MAX_ROCK_ENERGY, 10701, "TeamResonance_Rock_Lv2", 6),
|
||||
AntiFire (9, FightProperty.FIGHT_PROP_CUR_FIRE_ENERGY, FightProperty.FIGHT_PROP_MAX_FIRE_ENERGY),
|
||||
Default (255, FightProperty.FIGHT_PROP_CUR_FIRE_ENERGY, FightProperty.FIGHT_PROP_MAX_FIRE_ENERGY, 10801, "TeamResonance_AllDifferent");
|
||||
|
||||
public static ElementType getTypeByValue(int value) {
|
||||
return map.getOrDefault(value, None);
|
||||
}
|
||||
|
||||
public static ElementType getTypeByName(String name) {
|
||||
return stringMap.getOrDefault(name, None);
|
||||
}
|
||||
@Getter private final int value;
|
||||
@Getter private final int teamResonanceId;
|
||||
@Getter private final FightProperty curEnergyProp;
|
||||
@Getter private final FightProperty maxEnergyProp;
|
||||
@Getter private int depotValue;
|
||||
@Getter private final int configHash;
|
||||
private static final Int2ObjectMap<ElementType> map = new Int2ObjectOpenHashMap<>();
|
||||
private static final Map<String, ElementType> stringMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
Stream.of(values()).forEach(e -> {
|
||||
map.put(e.getValue(), e);
|
||||
stringMap.put(e.name(), e);
|
||||
});
|
||||
}
|
||||
|
||||
private ElementType(int value, FightProperty curEnergyProp, FightProperty maxEnergyProp) {
|
||||
this(value, curEnergyProp, maxEnergyProp, 0, null);
|
||||
}
|
||||
|
||||
private ElementType(int value, FightProperty curEnergyProp, FightProperty maxEnergyProp, int teamResonanceId, String configName) {
|
||||
this.value = value;
|
||||
this.curEnergyProp = curEnergyProp;
|
||||
this.maxEnergyProp = maxEnergyProp;
|
||||
this.teamResonanceId = teamResonanceId;
|
||||
if (configName != null) {
|
||||
this.configHash = Utils.abilityHash(configName);
|
||||
} else {
|
||||
this.configHash = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private ElementType(int value, FightProperty curEnergyProp, FightProperty maxEnergyProp, int teamResonanceId, String configName, int depotValue) {
|
||||
this(value, curEnergyProp, maxEnergyProp, teamResonanceId, configName);
|
||||
this.depotValue = depotValue;
|
||||
}
|
||||
|
||||
public static ElementType getTypeByValue(int value) {
|
||||
return map.getOrDefault(value, None);
|
||||
}
|
||||
|
||||
public static ElementType getTypeByName(String name) {
|
||||
return stringMap.getOrDefault(name, None);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,25 +48,25 @@ public enum ItemUseOp {
|
||||
ITEM_USE_UNLOCK_HOME_MODULE (44),
|
||||
ITEM_USE_UNLOCK_HOME_BGM (45),
|
||||
ITEM_USE_ADD_REGIONAL_PLAY_VAR (46);
|
||||
|
||||
private final int value;
|
||||
private static final Int2ObjectMap<ItemUseOp> map = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
static {
|
||||
Stream.of(values()).forEach(e -> {
|
||||
map.put(e.getValue(), e);
|
||||
});
|
||||
}
|
||||
|
||||
private ItemUseOp(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static ItemUseOp getTypeByValue(int value) {
|
||||
return map.getOrDefault(value, ITEM_USE_NONE);
|
||||
}
|
||||
private final int value;
|
||||
private static final Int2ObjectMap<ItemUseOp> map = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
static {
|
||||
Stream.of(values()).forEach(e -> {
|
||||
map.put(e.getValue(), e);
|
||||
});
|
||||
}
|
||||
|
||||
private ItemUseOp(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static ItemUseOp getTypeByValue(int value) {
|
||||
return map.getOrDefault(value, ITEM_USE_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,25 +12,25 @@ public enum ItemUseTarget {
|
||||
ITEM_USE_TARGET_SPECIFY_AVATAR (3),
|
||||
ITEM_USE_TARGET_SPECIFY_ALIVE_AVATAR (4),
|
||||
ITEM_USE_TARGET_SPECIFY_DEAD_AVATAR (5);
|
||||
|
||||
private final int value;
|
||||
private static final Int2ObjectMap<ItemUseTarget> map = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
static {
|
||||
Stream.of(values()).forEach(e -> {
|
||||
map.put(e.getValue(), e);
|
||||
});
|
||||
}
|
||||
|
||||
private ItemUseTarget(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static ItemUseTarget getTypeByValue(int value) {
|
||||
return map.getOrDefault(value, ITEM_USE_TARGET_NONE);
|
||||
}
|
||||
private final int value;
|
||||
private static final Int2ObjectMap<ItemUseTarget> map = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
static {
|
||||
Stream.of(values()).forEach(e -> {
|
||||
map.put(e.getValue(), e);
|
||||
});
|
||||
}
|
||||
|
||||
private ItemUseTarget(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static ItemUseTarget getTypeByValue(int value) {
|
||||
return map.getOrDefault(value, ITEM_USE_TARGET_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,25 +10,25 @@ public enum ServerBuffType {
|
||||
SERVER_BUFF_AVATAR (1),
|
||||
SERVER_BUFF_TEAM (2),
|
||||
SERVER_BUFF_TOWER (3);
|
||||
|
||||
private final int value;
|
||||
private static final Int2ObjectMap<ServerBuffType> map = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
static {
|
||||
Stream.of(values()).forEach(e -> {
|
||||
map.put(e.getValue(), e);
|
||||
});
|
||||
}
|
||||
|
||||
private ServerBuffType(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static ServerBuffType getTypeByValue(int value) {
|
||||
return map.getOrDefault(value, SERVER_BUFF_NONE);
|
||||
}
|
||||
private final int value;
|
||||
private static final Int2ObjectMap<ServerBuffType> map = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
static {
|
||||
Stream.of(values()).forEach(e -> {
|
||||
map.put(e.getValue(), e);
|
||||
});
|
||||
}
|
||||
|
||||
private ServerBuffType(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static ServerBuffType getTypeByValue(int value) {
|
||||
return map.getOrDefault(value, SERVER_BUFF_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,17 +41,17 @@ import static emu.grasscutter.config.Configuration.SCRIPT;
|
||||
|
||||
@Entity(value = "quests", useDiscriminator = false)
|
||||
public class GameMainQuest {
|
||||
@Id private ObjectId id;
|
||||
@Indexed @Getter private int ownerUid;
|
||||
@Transient @Getter private Player owner;
|
||||
@Id private ObjectId id;
|
||||
@Indexed @Getter private int ownerUid;
|
||||
@Transient @Getter private Player owner;
|
||||
@Transient @Getter private QuestManager questManager;
|
||||
@Getter private Map<Integer, GameQuest> childQuests;
|
||||
@Getter private int parentQuestId;
|
||||
@Getter private int[] questVars;
|
||||
@Getter private Map<Integer, GameQuest> childQuests;
|
||||
@Getter private int parentQuestId;
|
||||
@Getter private int[] questVars;
|
||||
//QuestUpdateQuestVarReq is sent in two stages...
|
||||
@Getter private List<Integer> questVarsUpdate;
|
||||
@Getter private ParentQuestState state;
|
||||
@Getter private boolean isFinished;
|
||||
@Getter private ParentQuestState state;
|
||||
@Getter private boolean isFinished;
|
||||
@Getter List<QuestGroupSuite> questGroupSuites;
|
||||
|
||||
@Getter int[] suggestTrackMainQuestList;
|
||||
@@ -60,25 +60,25 @@ public class GameMainQuest {
|
||||
private Map<Integer,Position> rewindPositions;
|
||||
private Map<Integer,Position> rewindRotations;
|
||||
|
||||
@Deprecated // Morphia only. Do not use.
|
||||
public GameMainQuest() {}
|
||||
@Deprecated // Morphia only. Do not use.
|
||||
public GameMainQuest() {}
|
||||
|
||||
public GameMainQuest(Player player, int parentQuestId) {
|
||||
this.owner = player;
|
||||
this.ownerUid = player.getUid();
|
||||
public GameMainQuest(Player player, int parentQuestId) {
|
||||
this.owner = player;
|
||||
this.ownerUid = player.getUid();
|
||||
this.questManager = player.getQuestManager();
|
||||
this.parentQuestId = parentQuestId;
|
||||
this.childQuests = new HashMap<>();
|
||||
this.parentQuestId = parentQuestId;
|
||||
this.childQuests = new HashMap<>();
|
||||
this.talks = new HashMap<>();
|
||||
//official server always has a list of 5 questVars, with default value 0
|
||||
this.questVars = new int[] {0,0,0,0,0};
|
||||
this.state = ParentQuestState.PARENT_QUEST_STATE_NONE;
|
||||
this.questVars = new int[] {0,0,0,0,0};
|
||||
this.state = ParentQuestState.PARENT_QUEST_STATE_NONE;
|
||||
this.questGroupSuites = new ArrayList<>();
|
||||
this.rewindPositions = new HashMap<>();
|
||||
this.rewindRotations = new HashMap<>();
|
||||
addAllChildQuests();
|
||||
addRewindPoints();
|
||||
}
|
||||
}
|
||||
|
||||
private void addAllChildQuests() {
|
||||
List<Integer> subQuestIds = Arrays.stream(GameData.getMainQuestDataMap().get(this.parentQuestId).getSubQuests()).map(SubQuestData::getSubId).toList();
|
||||
@@ -88,10 +88,10 @@ public class GameMainQuest {
|
||||
}
|
||||
}
|
||||
|
||||
public void setOwner(Player player) {
|
||||
if (player.getUid() != this.getOwnerUid()) return;
|
||||
this.owner = player;
|
||||
}
|
||||
public void setOwner(Player player) {
|
||||
if (player.getUid() != this.getOwnerUid()) return;
|
||||
this.owner = player;
|
||||
}
|
||||
|
||||
public int getQuestVar(int i) {
|
||||
return questVars[i];
|
||||
@@ -115,71 +115,71 @@ public class GameMainQuest {
|
||||
}
|
||||
|
||||
|
||||
public GameQuest getChildQuestById(int id) {
|
||||
return this.getChildQuests().get(id);
|
||||
}
|
||||
public GameQuest getChildQuestById(int id) {
|
||||
return this.getChildQuests().get(id);
|
||||
}
|
||||
public GameQuest getChildQuestByOrder(int order) {
|
||||
return this.getChildQuests().values().stream().filter(p -> p.getQuestData().getOrder() == order).toList().get(0);
|
||||
}
|
||||
|
||||
public void finish() {
|
||||
this.isFinished = true;
|
||||
this.state = ParentQuestState.PARENT_QUEST_STATE_FINISHED;
|
||||
this.isFinished = true;
|
||||
this.state = ParentQuestState.PARENT_QUEST_STATE_FINISHED;
|
||||
|
||||
this.getOwner().getSession().send(new PacketFinishedParentQuestUpdateNotify(this));
|
||||
this.getOwner().getSession().send(new PacketCodexDataUpdateNotify(this));
|
||||
this.getOwner().getSession().send(new PacketFinishedParentQuestUpdateNotify(this));
|
||||
this.getOwner().getSession().send(new PacketCodexDataUpdateNotify(this));
|
||||
|
||||
this.save();
|
||||
this.save();
|
||||
|
||||
// Add rewards
|
||||
MainQuestData mainQuestData = GameData.getMainQuestDataMap().get(this.getParentQuestId());
|
||||
for (int rewardId : mainQuestData.getRewardIdList()) {
|
||||
RewardData rewardData = GameData.getRewardDataMap().get(rewardId);
|
||||
// Add rewards
|
||||
MainQuestData mainQuestData = GameData.getMainQuestDataMap().get(this.getParentQuestId());
|
||||
for (int rewardId : mainQuestData.getRewardIdList()) {
|
||||
RewardData rewardData = GameData.getRewardDataMap().get(rewardId);
|
||||
|
||||
if (rewardData == null) {
|
||||
continue;
|
||||
}
|
||||
if (rewardData == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
getOwner().getInventory().addItemParamDatas(rewardData.getRewardItemList(), ActionReason.QuestReward);
|
||||
}
|
||||
getOwner().getInventory().addItemParamDatas(rewardData.getRewardItemList(), ActionReason.QuestReward);
|
||||
}
|
||||
|
||||
// handoff main quest
|
||||
if(mainQuestData.getSuggestTrackMainQuestList() != null){
|
||||
if (mainQuestData.getSuggestTrackMainQuestList() != null) {
|
||||
Arrays.stream(mainQuestData.getSuggestTrackMainQuestList())
|
||||
.forEach(getQuestManager()::startMainQuest);
|
||||
}
|
||||
}
|
||||
}
|
||||
//TODO
|
||||
public void fail() {}
|
||||
public void cancel() {}
|
||||
|
||||
// Rewinds to the last finished/unfinished rewind quest, and returns the avatar rewind position (if it exists)
|
||||
public List<Position> rewind() {
|
||||
if(this.questManager == null) {
|
||||
if (this.questManager == null) {
|
||||
this.questManager = getOwner().getQuestManager();
|
||||
}
|
||||
List<GameQuest> sortedByOrder = new ArrayList<>(getChildQuests().values().stream().filter(q -> q.getQuestData().isRewind()).toList());
|
||||
sortedByOrder.sort((a,b) -> {
|
||||
if( a == b){
|
||||
if ( a == b) {
|
||||
return 0;
|
||||
}
|
||||
return a.getQuestData().getOrder() > b.getQuestData().getOrder() ? 1 : -1;});
|
||||
boolean didRewind = false;
|
||||
for (GameQuest quest : sortedByOrder) {
|
||||
int i = sortedByOrder.indexOf(quest);
|
||||
if( i == sortedByOrder.size()) {
|
||||
if ( i == sortedByOrder.size()) {
|
||||
didRewind = quest.rewind(null);
|
||||
} else {
|
||||
didRewind = quest.rewind(sortedByOrder.get(i+1));
|
||||
}
|
||||
if(didRewind) {
|
||||
if (didRewind) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
List<GameQuest> rewindQuests = getChildQuests().values().stream()
|
||||
.filter(p -> (p.getState() == QuestState.QUEST_STATE_UNFINISHED || p.getState() == QuestState.QUEST_STATE_FINISHED) && p.getQuestData().isRewind()).toList();
|
||||
for (GameQuest quest : rewindQuests) {
|
||||
if(rewindPositions.containsKey(quest.getSubQuestId())) {
|
||||
if (rewindPositions.containsKey(quest.getSubQuestId())) {
|
||||
List<Position> posAndRot = new ArrayList<>();
|
||||
posAndRot.add(0,rewindPositions.get(quest.getSubQuestId()));
|
||||
posAndRot.add(1,rewindRotations.get(quest.getSubQuestId()));
|
||||
@@ -206,17 +206,17 @@ public class GameMainQuest {
|
||||
cs.eval(bindings);
|
||||
|
||||
var rewindDataMap = ScriptLoader.getSerializer().toMap(RewindData.class, bindings.get("rewind_data"));
|
||||
for(String subId : rewindDataMap.keySet()) {
|
||||
for (String subId : rewindDataMap.keySet()) {
|
||||
RewindData questRewind = rewindDataMap.get(subId);
|
||||
if(questRewind != null) {
|
||||
if (questRewind != null) {
|
||||
RewindData.AvatarData avatarData = questRewind.getAvatar();
|
||||
if(avatarData != null) {
|
||||
if (avatarData != null) {
|
||||
String avatarPos = avatarData.getPos();
|
||||
QuestData.Guide guide = GameData.getQuestDataMap().get(Integer.valueOf(subId)).getGuide();
|
||||
if (guide != null) {
|
||||
int sceneId = guide.getGuideScene();
|
||||
ScriptSceneData fullGlobals = GameData.getScriptSceneDataMap().get("flat.luas.scenes.full_globals.lua.json");
|
||||
if(fullGlobals != null) {
|
||||
if (fullGlobals != null) {
|
||||
ScriptSceneData.ScriptObject dummyPointScript = fullGlobals.getScriptObjectList().get(sceneId + "/scene" + sceneId + "_dummy_points.lua");
|
||||
if (dummyPointScript != null) {
|
||||
Map<String, List<Float>> dummyPointMap = dummyPointScript.getDummyPoints();
|
||||
@@ -287,10 +287,10 @@ public class GameMainQuest {
|
||||
|
||||
for (int i = 0; i < subQuestWithCond.getQuestData().getFailCond().size(); i++) {
|
||||
QuestData.QuestCondition condition = failCond.get(i);
|
||||
if(condition.getType() == condType) {
|
||||
if (condition.getType() == condType) {
|
||||
boolean result = this.getOwner().getServer().getQuestSystem().triggerContent(subQuestWithCond, condition, paramStr, params);
|
||||
subQuestWithCond.getFailProgressList()[i] = result ? 1 : 0;
|
||||
if(result) {
|
||||
if (result) {
|
||||
getOwner().getSession().send(new PacketQuestProgressUpdateNotify(subQuestWithCond));
|
||||
}
|
||||
}
|
||||
@@ -322,10 +322,10 @@ public class GameMainQuest {
|
||||
|
||||
for (int i = 0; i < finishCond.size(); i++) {
|
||||
QuestData.QuestCondition condition = finishCond.get(i);
|
||||
if(condition.getType() == condType) {
|
||||
if (condition.getType() == condType) {
|
||||
boolean result = this.getOwner().getServer().getQuestSystem().triggerContent(subQuestWithCond, condition, paramStr, params);
|
||||
subQuestWithCond.getFinishProgressList()[i] = result ? 1 : 0;
|
||||
if(result) {
|
||||
if (result) {
|
||||
getOwner().getSession().send(new PacketQuestProgressUpdateNotify(subQuestWithCond));
|
||||
}
|
||||
}
|
||||
@@ -343,14 +343,14 @@ public class GameMainQuest {
|
||||
}
|
||||
}
|
||||
|
||||
public void save() {
|
||||
DatabaseHelper.saveQuest(this);
|
||||
}
|
||||
public void save() {
|
||||
DatabaseHelper.saveQuest(this);
|
||||
}
|
||||
|
||||
public ParentQuest toProto() {
|
||||
ParentQuest.Builder proto = ParentQuest.newBuilder()
|
||||
.setParentQuestId(getParentQuestId())
|
||||
.setIsFinished(isFinished());
|
||||
public ParentQuest toProto() {
|
||||
ParentQuest.Builder proto = ParentQuest.newBuilder()
|
||||
.setParentQuestId(getParentQuestId())
|
||||
.setIsFinished(isFinished());
|
||||
|
||||
|
||||
proto.setParentQuestState(getState().getValue())
|
||||
@@ -371,7 +371,7 @@ public class GameMainQuest {
|
||||
}
|
||||
|
||||
|
||||
return proto.build();
|
||||
}
|
||||
return proto.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,33 +29,33 @@ import java.util.Map;
|
||||
|
||||
@Entity
|
||||
public class GameQuest {
|
||||
@Transient @Getter @Setter private GameMainQuest mainQuest;
|
||||
@Transient @Getter private QuestData questData;
|
||||
@Transient @Getter @Setter private GameMainQuest mainQuest;
|
||||
@Transient @Getter private QuestData questData;
|
||||
|
||||
@Getter private int subQuestId;
|
||||
@Getter private int mainQuestId;
|
||||
@Getter @Setter
|
||||
@Getter private int subQuestId;
|
||||
@Getter private int mainQuestId;
|
||||
@Getter @Setter
|
||||
private QuestState state;
|
||||
|
||||
@Getter @Setter private int startTime;
|
||||
@Getter @Setter private int acceptTime;
|
||||
@Getter @Setter private int finishTime;
|
||||
@Getter @Setter private int startTime;
|
||||
@Getter @Setter private int acceptTime;
|
||||
@Getter @Setter private int finishTime;
|
||||
|
||||
@Getter private int[] finishProgressList;
|
||||
@Getter private int[] failProgressList;
|
||||
@Getter private int[] finishProgressList;
|
||||
@Getter private int[] failProgressList;
|
||||
@Transient @Getter private Map<String, TriggerExcelConfigData> triggerData;
|
||||
@Getter private Map<String, Boolean> triggers;
|
||||
private transient Bindings bindings;
|
||||
|
||||
@Deprecated // Morphia only. Do not use.
|
||||
public GameQuest() {}
|
||||
@Deprecated // Morphia only. Do not use.
|
||||
public GameQuest() {}
|
||||
|
||||
public GameQuest(GameMainQuest mainQuest, QuestData questData) {
|
||||
this.mainQuest = mainQuest;
|
||||
this.subQuestId = questData.getId();
|
||||
this.mainQuestId = questData.getMainId();
|
||||
this.questData = questData;
|
||||
this.state = QuestState.QUEST_STATE_UNSTARTED;
|
||||
public GameQuest(GameMainQuest mainQuest, QuestData questData) {
|
||||
this.mainQuest = mainQuest;
|
||||
this.subQuestId = questData.getId();
|
||||
this.mainQuestId = questData.getMainId();
|
||||
this.questData = questData;
|
||||
this.state = QuestState.QUEST_STATE_UNSTARTED;
|
||||
this.triggerData = new HashMap<>();
|
||||
this.triggers = new HashMap<>();
|
||||
}
|
||||
@@ -66,11 +66,11 @@ public class GameQuest {
|
||||
this.state = QuestState.QUEST_STATE_UNFINISHED;
|
||||
List<QuestData.QuestCondition> triggerCond = questData.getFinishCond().stream()
|
||||
.filter(p -> p.getType() == QuestTrigger.QUEST_CONTENT_TRIGGER_FIRE).toList();
|
||||
if(triggerCond.size() > 0) {
|
||||
if (triggerCond.size() > 0) {
|
||||
for (QuestData.QuestCondition cond : triggerCond) {
|
||||
TriggerExcelConfigData newTrigger = GameData.getTriggerExcelConfigDataMap().get(cond.getParam()[0]);
|
||||
if(newTrigger != null) {
|
||||
if(this.triggerData == null) {
|
||||
if (newTrigger != null) {
|
||||
if (this.triggerData == null) {
|
||||
this.triggerData = new HashMap<>();
|
||||
}
|
||||
triggerData.put(newTrigger.getTriggerName(), newTrigger);
|
||||
@@ -92,7 +92,7 @@ public class GameQuest {
|
||||
getQuestData().getBeginExec().forEach(e -> getOwner().getServer().getQuestSystem().triggerExec(this, e, e.getParam()));
|
||||
|
||||
|
||||
if (ChapterData.beginQuestChapterMap.containsKey(subQuestId)){
|
||||
if (ChapterData.beginQuestChapterMap.containsKey(subQuestId)) {
|
||||
mainQuest.getOwner().sendPacket(new PacketChapterStateNotify(
|
||||
ChapterData.beginQuestChapterMap.get(subQuestId).getId(),
|
||||
ChapterStateOuterClass.ChapterState.CHAPTER_STATE_BEGIN
|
||||
@@ -108,7 +108,7 @@ public class GameQuest {
|
||||
|
||||
public String getTriggerNameById(int id) {
|
||||
TriggerExcelConfigData trigger = GameData.getTriggerExcelConfigDataMap().get(id);
|
||||
if(trigger != null) {
|
||||
if (trigger != null) {
|
||||
String triggerName = trigger.getTriggerName();
|
||||
return triggerName;
|
||||
}
|
||||
@@ -116,38 +116,38 @@ public class GameQuest {
|
||||
return "";
|
||||
}
|
||||
|
||||
public Player getOwner() {
|
||||
return this.getMainQuest().getOwner();
|
||||
}
|
||||
public Player getOwner() {
|
||||
return this.getMainQuest().getOwner();
|
||||
}
|
||||
|
||||
public void setConfig(QuestData config) {
|
||||
if (getSubQuestId() != config.getId()) return;
|
||||
this.questData = config;
|
||||
}
|
||||
public void setConfig(QuestData config) {
|
||||
if (getSubQuestId() != config.getId()) return;
|
||||
this.questData = config;
|
||||
}
|
||||
|
||||
public void setFinishProgress(int index, int value) {
|
||||
finishProgressList[index] = value;
|
||||
}
|
||||
public void setFinishProgress(int index, int value) {
|
||||
finishProgressList[index] = value;
|
||||
}
|
||||
|
||||
public void setFailProgress(int index, int value) {
|
||||
failProgressList[index] = value;
|
||||
}
|
||||
public void setFailProgress(int index, int value) {
|
||||
failProgressList[index] = value;
|
||||
}
|
||||
|
||||
public void finish() {
|
||||
this.state = QuestState.QUEST_STATE_FINISHED;
|
||||
this.finishTime = Utils.getCurrentSeconds();
|
||||
public void finish() {
|
||||
this.state = QuestState.QUEST_STATE_FINISHED;
|
||||
this.finishTime = Utils.getCurrentSeconds();
|
||||
|
||||
if (getQuestData().finishParent()) {
|
||||
// This quest finishes the questline - the main quest will also save the quest to db, so we don't have to call save() here
|
||||
getMainQuest().finish();
|
||||
}
|
||||
if (getQuestData().finishParent()) {
|
||||
// This quest finishes the questline - the main quest will also save the quest to db, so we don't have to call save() here
|
||||
getMainQuest().finish();
|
||||
}
|
||||
|
||||
getQuestData().getFinishExec().forEach(e -> getOwner().getServer().getQuestSystem().triggerExec(this, e, e.getParam()));
|
||||
//Some subQuests have conditions that subQuests are finished (even from different MainQuests)
|
||||
getOwner().getQuestManager().triggerEvent(QuestTrigger.QUEST_CONTENT_QUEST_STATE_EQUAL, this.subQuestId, this.state.getValue(),0,0,0);
|
||||
getOwner().getQuestManager().triggerEvent(QuestTrigger.QUEST_COND_STATE_EQUAL, this.subQuestId, this.state.getValue(),0,0,0);
|
||||
|
||||
if (ChapterData.endQuestChapterMap.containsKey(subQuestId)){
|
||||
if (ChapterData.endQuestChapterMap.containsKey(subQuestId)) {
|
||||
mainQuest.getOwner().sendPacket(new PacketChapterStateNotify(
|
||||
ChapterData.endQuestChapterMap.get(subQuestId).getId(),
|
||||
ChapterStateOuterClass.ChapterState.CHAPTER_STATE_END
|
||||
@@ -155,7 +155,7 @@ public class GameQuest {
|
||||
}
|
||||
|
||||
Grasscutter.getLogger().debug("Quest {} is finished", subQuestId);
|
||||
}
|
||||
}
|
||||
|
||||
//TODO
|
||||
public void fail() {
|
||||
@@ -171,9 +171,9 @@ public class GameQuest {
|
||||
// Return true if ParentQuest should rewind to this childQuest
|
||||
public boolean rewind(GameQuest nextRewind) {
|
||||
if (questData.isRewind()) {
|
||||
if(nextRewind == null) {return true;}
|
||||
if (nextRewind == null) {return true;}
|
||||
// if the next isRewind subQuest is none or unstarted, reset all subQuests with order higher than this one, and restart this quest
|
||||
if(nextRewind.getState() == QuestState.QUEST_STATE_NONE|| nextRewind.getState() == QuestState.QUEST_STATE_UNSTARTED) {
|
||||
if (nextRewind.getState() == QuestState.QUEST_STATE_NONE|| nextRewind.getState() == QuestState.QUEST_STATE_UNSTARTED) {
|
||||
getMainQuest().getChildQuests().values().stream().filter(p -> p.getQuestData().getOrder() > this.getQuestData().getOrder()).forEach(q -> q.setState(QuestState.QUEST_STATE_UNSTARTED));
|
||||
this.start();
|
||||
return true;
|
||||
@@ -181,31 +181,31 @@ public class GameQuest {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void save() {
|
||||
getMainQuest().save();
|
||||
}
|
||||
public void save() {
|
||||
getMainQuest().save();
|
||||
}
|
||||
|
||||
public Quest toProto() {
|
||||
Quest.Builder proto = Quest.newBuilder()
|
||||
.setQuestId(getSubQuestId())
|
||||
.setState(getState().getValue())
|
||||
.setParentQuestId(getMainQuestId())
|
||||
.setStartTime(getStartTime())
|
||||
.setStartGameTime(438)
|
||||
.setAcceptTime(getAcceptTime());
|
||||
public Quest toProto() {
|
||||
Quest.Builder proto = Quest.newBuilder()
|
||||
.setQuestId(getSubQuestId())
|
||||
.setState(getState().getValue())
|
||||
.setParentQuestId(getMainQuestId())
|
||||
.setStartTime(getStartTime())
|
||||
.setStartGameTime(438)
|
||||
.setAcceptTime(getAcceptTime());
|
||||
|
||||
if (getFinishProgressList() != null) {
|
||||
for (int i : getFinishProgressList()) {
|
||||
proto.addFinishProgressList(i);
|
||||
}
|
||||
}
|
||||
if (getFinishProgressList() != null) {
|
||||
for (int i : getFinishProgressList()) {
|
||||
proto.addFinishProgressList(i);
|
||||
}
|
||||
}
|
||||
|
||||
if (getFailProgressList() != null) {
|
||||
for (int i : getFailProgressList()) {
|
||||
proto.addFailProgressList(i);
|
||||
}
|
||||
}
|
||||
if (getFailProgressList() != null) {
|
||||
for (int i : getFailProgressList()) {
|
||||
proto.addFailProgressList(i);
|
||||
}
|
||||
}
|
||||
|
||||
return proto.build();
|
||||
}
|
||||
return proto.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import lombok.Getter;
|
||||
|
||||
public class QuestManager extends BasePlayerManager {
|
||||
|
||||
@Getter private final Player player;
|
||||
@Getter private final Player player;
|
||||
@Getter private final Int2ObjectMap<GameMainQuest> mainQuests;
|
||||
@Getter private List<GameQuest> addToQuestListUpdateNotify;
|
||||
/*
|
||||
@@ -62,17 +62,17 @@ public class QuestManager extends BasePlayerManager {
|
||||
|
||||
*/
|
||||
|
||||
public static long getQuestKey(int mainQuestId){
|
||||
public static long getQuestKey(int mainQuestId) {
|
||||
QuestEncryptionKey questEncryptionKey = GameData.getMainQuestEncryptionMap().get(mainQuestId);
|
||||
return questEncryptionKey != null ? questEncryptionKey.getEncryptionKey() : 0L;
|
||||
}
|
||||
public QuestManager(Player player) {
|
||||
public QuestManager(Player player) {
|
||||
|
||||
super(player);
|
||||
this.player = player;
|
||||
this.mainQuests = new Int2ObjectOpenHashMap<>();
|
||||
this.player = player;
|
||||
this.mainQuests = new Int2ObjectOpenHashMap<>();
|
||||
this.addToQuestListUpdateNotify = new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
public void onNewPlayerCreate() {
|
||||
|
||||
@@ -86,9 +86,9 @@ public class QuestManager extends BasePlayerManager {
|
||||
public void onLogin() {
|
||||
|
||||
List<GameMainQuest> activeQuests = getActiveMainQuests();
|
||||
for(GameMainQuest quest : activeQuests) {
|
||||
for (GameMainQuest quest : activeQuests) {
|
||||
List<Position> rewindPos = quest.rewind(); // <pos, rotation>
|
||||
if(rewindPos != null) {
|
||||
if (rewindPos != null) {
|
||||
getPlayer().getPosition().set(rewindPos.get(0));
|
||||
getPlayer().getRotation().set(rewindPos.get(1));
|
||||
}
|
||||
@@ -97,7 +97,7 @@ public class QuestManager extends BasePlayerManager {
|
||||
|
||||
private List<GameMainQuest> addMultMainQuests(Set<Integer> mainQuestIds) {
|
||||
List<GameMainQuest> newQuests = new ArrayList<>();
|
||||
for(Integer id : mainQuestIds) {
|
||||
for (Integer id : mainQuestIds) {
|
||||
getMainQuests().put(id.intValue(),new GameMainQuest(this.player, id));
|
||||
getMainQuestById(id).save();
|
||||
newQuests.add(getMainQuestById(id));
|
||||
@@ -130,9 +130,9 @@ public class QuestManager extends BasePlayerManager {
|
||||
Grasscutter.getLogger().debug("Decremented questGlobalVar {} value from {} to {}", variable, previousValue, previousValue - dec);
|
||||
}
|
||||
|
||||
public GameMainQuest getMainQuestById(int mainQuestId) {
|
||||
return getMainQuests().get(mainQuestId);
|
||||
}
|
||||
public GameMainQuest getMainQuestById(int mainQuestId) {
|
||||
return getMainQuests().get(mainQuestId);
|
||||
}
|
||||
|
||||
public GameQuest getQuestById(int questId) {
|
||||
QuestData questConfig = GameData.getQuestDataMap().get(questId);
|
||||
@@ -140,7 +140,7 @@ public class QuestManager extends BasePlayerManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
GameMainQuest mainQuest = getMainQuests().get(questConfig.getMainId());
|
||||
GameMainQuest mainQuest = getMainQuests().get(questConfig.getMainId());
|
||||
|
||||
if (mainQuest == null) {
|
||||
return null;
|
||||
@@ -149,34 +149,34 @@ public class QuestManager extends BasePlayerManager {
|
||||
return mainQuest.getChildQuests().get(questId);
|
||||
}
|
||||
|
||||
public void forEachQuest(Consumer<GameQuest> callback) {
|
||||
for (GameMainQuest mainQuest : getMainQuests().values()) {
|
||||
for (GameQuest quest : mainQuest.getChildQuests().values()) {
|
||||
callback.accept(quest);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void forEachQuest(Consumer<GameQuest> callback) {
|
||||
for (GameMainQuest mainQuest : getMainQuests().values()) {
|
||||
for (GameQuest quest : mainQuest.getChildQuests().values()) {
|
||||
callback.accept(quest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void forEachMainQuest(Consumer<GameMainQuest> callback) {
|
||||
for (GameMainQuest mainQuest : getMainQuests().values()) {
|
||||
callback.accept(mainQuest);
|
||||
}
|
||||
}
|
||||
public void forEachMainQuest(Consumer<GameMainQuest> callback) {
|
||||
for (GameMainQuest mainQuest : getMainQuests().values()) {
|
||||
callback.accept(mainQuest);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO
|
||||
public void forEachActiveQuest(Consumer<GameQuest> callback) {
|
||||
for (GameMainQuest mainQuest : getMainQuests().values()) {
|
||||
for (GameQuest quest : mainQuest.getChildQuests().values()) {
|
||||
if (quest.getState() != QuestState.QUEST_STATE_FINISHED) {
|
||||
callback.accept(quest);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO
|
||||
public void forEachActiveQuest(Consumer<GameQuest> callback) {
|
||||
for (GameMainQuest mainQuest : getMainQuests().values()) {
|
||||
for (GameQuest quest : mainQuest.getChildQuests().values()) {
|
||||
if (quest.getState() != QuestState.QUEST_STATE_FINISHED) {
|
||||
callback.accept(quest);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public GameMainQuest addMainQuest(QuestData questConfig) {
|
||||
GameMainQuest mainQuest = new GameMainQuest(getPlayer(), questConfig.getMainId());
|
||||
getMainQuests().put(mainQuest.getParentQuestId(), mainQuest);
|
||||
public GameMainQuest addMainQuest(QuestData questConfig) {
|
||||
GameMainQuest mainQuest = new GameMainQuest(getPlayer(), questConfig.getMainId());
|
||||
getMainQuests().put(mainQuest.getParentQuestId(), mainQuest);
|
||||
|
||||
getPlayer().sendPacket(new PacketFinishedParentQuestUpdateNotify(mainQuest));
|
||||
|
||||
@@ -200,14 +200,14 @@ public class QuestManager extends BasePlayerManager {
|
||||
// Sub quest
|
||||
GameQuest quest = mainQuest.getChildQuestById(questId);
|
||||
|
||||
// Forcefully start
|
||||
quest.start();
|
||||
// Forcefully start
|
||||
quest.start();
|
||||
|
||||
// Save main quest
|
||||
mainQuest.save();
|
||||
|
||||
// Send packet
|
||||
getPlayer().sendPacket(new PacketQuestListUpdateNotify(mainQuest.getChildQuests().values().stream()
|
||||
// Send packet
|
||||
getPlayer().sendPacket(new PacketQuestListUpdateNotify(mainQuest.getChildQuests().values().stream()
|
||||
.filter(p -> p.getState() != QuestState.QUEST_STATE_UNSTARTED)
|
||||
.toList()));
|
||||
|
||||
@@ -230,12 +230,12 @@ public class QuestManager extends BasePlayerManager {
|
||||
}
|
||||
|
||||
//TODO
|
||||
public void triggerEvent(QuestTrigger condType, String paramStr, int... params) {
|
||||
public void triggerEvent(QuestTrigger condType, String paramStr, int... params) {
|
||||
Grasscutter.getLogger().debug("Trigger Event {}, {}, {}", condType, paramStr, params);
|
||||
List<GameMainQuest> checkMainQuests = this.getMainQuests().values().stream()
|
||||
.filter(i -> i.getState() != ParentQuestState.PARENT_QUEST_STATE_FINISHED)
|
||||
.toList();
|
||||
switch(condType){
|
||||
switch (condType) {
|
||||
//accept Conds
|
||||
case QUEST_COND_STATE_EQUAL:
|
||||
case QUEST_COND_STATE_NOT_EQUAL:
|
||||
@@ -295,12 +295,12 @@ public class QuestManager extends BasePlayerManager {
|
||||
default:
|
||||
Grasscutter.getLogger().error("Unhandled QuestTrigger {}", condType);
|
||||
}
|
||||
if(this.addToQuestListUpdateNotify.size() != 0){
|
||||
if (this.addToQuestListUpdateNotify.size() != 0) {
|
||||
this.getPlayer().getSession().send(new PacketQuestListUpdateNotify(this.addToQuestListUpdateNotify));
|
||||
this.addToQuestListUpdateNotify.clear();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public List<QuestGroupSuite> getSceneGroupSuite(int sceneId) {
|
||||
return getMainQuests().values().stream()
|
||||
@@ -317,14 +317,14 @@ public class QuestManager extends BasePlayerManager {
|
||||
for (GameMainQuest mainQuest : quests) {
|
||||
mainQuest.setOwner(this.getPlayer());
|
||||
|
||||
for (GameQuest quest : mainQuest.getChildQuests().values()) {
|
||||
quest.setMainQuest(mainQuest);
|
||||
quest.setConfig(GameData.getQuestDataMap().get(quest.getSubQuestId()));
|
||||
}
|
||||
for (GameQuest quest : mainQuest.getChildQuests().values()) {
|
||||
quest.setMainQuest(mainQuest);
|
||||
quest.setConfig(GameData.getQuestDataMap().get(quest.getSubQuestId()));
|
||||
}
|
||||
|
||||
this.getMainQuests().put(mainQuest.getParentQuestId(), mainQuest);
|
||||
}
|
||||
}
|
||||
this.getMainQuests().put(mainQuest.getParentQuestId(), mainQuest);
|
||||
}
|
||||
}
|
||||
|
||||
public List<GameMainQuest> getActiveMainQuests() {
|
||||
return getMainQuests().values().stream().filter(p -> !p.isFinished()).toList();
|
||||
|
||||
@@ -9,9 +9,9 @@ import emu.grasscutter.game.quest.handlers.QuestBaseHandler;
|
||||
@QuestValue(QuestTrigger.QUEST_COND_LUA_NOTIFY)
|
||||
public class ConditionLuaNotify extends QuestBaseHandler {
|
||||
//Wrong implementation. Example: 7010226 has no paramStr
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
return condition.getParam()[0] == Integer.parseInt(paramStr);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,4 +17,4 @@ public class ConditionQuestGlobalVarEqual extends QuestBaseHandler {
|
||||
Grasscutter.getLogger().debug("questGlobarVar {} : {}", params[0],questGlobalVarValue);
|
||||
return questGlobalVarValue.intValue() == params[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,4 +17,4 @@ public class ConditionQuestGlobalVarGreater extends QuestBaseHandler {
|
||||
Grasscutter.getLogger().debug("questGlobarVar {} : {}", params[0],questGlobalVarValue);
|
||||
return questGlobalVarValue.intValue() > params[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,4 +17,4 @@ public class ConditionQuestGlobalVarLess extends QuestBaseHandler {
|
||||
Grasscutter.getLogger().debug("questGlobarVar {} : {}", params[0],questGlobalVarValue);
|
||||
return questGlobalVarValue.intValue() < params[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ import emu.grasscutter.game.quest.handlers.QuestBaseHandler;
|
||||
@QuestValue(QuestTrigger.QUEST_COND_STATE_EQUAL)
|
||||
public class ConditionStateEqual extends QuestBaseHandler {
|
||||
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
GameQuest checkQuest = quest.getOwner().getQuestManager().getQuestById(condition.getParam()[0]);
|
||||
if (checkQuest == null) {
|
||||
/*
|
||||
@@ -22,6 +22,6 @@ public class ConditionStateEqual extends QuestBaseHandler {
|
||||
return false;
|
||||
}
|
||||
return checkQuest.getState().getValue() == condition.getParam()[1];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,14 +9,14 @@ import emu.grasscutter.game.quest.handlers.QuestBaseHandler;
|
||||
@QuestValue(QuestTrigger.QUEST_CONTENT_ADD_QUEST_PROGRESS)
|
||||
public class ContentAddQuestProgress extends QuestBaseHandler {
|
||||
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
/*
|
||||
//paramStr is a lua group, params[0] may also be a lua group!
|
||||
questid = xxxxxx lua group = xxxxxxyy
|
||||
count seems relevant only for lua group
|
||||
*/
|
||||
return condition.getParam()[0] == params[0]; //missing params[1], paramStr, and count
|
||||
}
|
||||
return condition.getParam()[0] == params[0]; //missing params[1], paramStr, and count
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,4 +19,4 @@ public class ContentCompleteAnyTalk extends QuestBaseHandler {
|
||||
return talkData == null || condition.getParamStr().contains(paramStr) || checkMainQuest.getChildQuestById(params[0]) != null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,17 +11,17 @@ import emu.grasscutter.game.quest.handlers.QuestBaseHandler;
|
||||
@QuestValue(QuestTrigger.QUEST_CONTENT_COMPLETE_TALK)
|
||||
public class ContentCompleteTalk extends QuestBaseHandler {
|
||||
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
GameMainQuest checkMainQuest = quest.getOwner().getQuestManager().getMainQuestById(params[0] / 100);
|
||||
if (checkMainQuest == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
MainQuestData.TalkData talkData = checkMainQuest.getTalks().get(condition.getParam()[0]);
|
||||
return talkData != null;
|
||||
|
||||
// This expression makes zero sense.
|
||||
// return talkData == null || condition.getParamStr().contains(paramStr) || checkMainQuest.getChildQuestById(params[0]) != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,9 @@ import emu.grasscutter.game.quest.handlers.QuestBaseHandler;
|
||||
@QuestValue(QuestTrigger.QUEST_CONTENT_ENTER_DUNGEON)
|
||||
public class ContentEnterDungeon extends QuestBaseHandler {
|
||||
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
return condition.getParam()[0] == params[0]; //missing params[1]
|
||||
}
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
return condition.getParam()[0] == params[0]; //missing params[1]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ import emu.grasscutter.game.quest.handlers.QuestBaseHandler;
|
||||
@QuestValue(QuestTrigger.QUEST_CONTENT_FINISH_PLOT)
|
||||
public class ContentFinishPlot extends QuestBaseHandler {
|
||||
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
MainQuestData.TalkData talkData = quest.getMainQuest().getTalks().get(Integer.valueOf(params[0]));
|
||||
GameQuest subQuest = quest.getMainQuest().getChildQuestById(params[0]);
|
||||
return talkData != null || subQuest != null;
|
||||
|
||||
@@ -9,11 +9,11 @@ import emu.grasscutter.game.quest.handlers.QuestBaseHandler;
|
||||
@QuestValue(QuestTrigger.QUEST_CONTENT_QUEST_STATE_EQUAL)
|
||||
public class ContentQuestStateEqual extends QuestBaseHandler {
|
||||
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestCondition condition, String paramStr, int... params) {
|
||||
GameQuest checkQuest = quest.getOwner().getQuestManager().getQuestById(condition.getParam()[0]);
|
||||
if (checkQuest == null) {return false;}
|
||||
return checkQuest.getState().getValue() == params[1];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,4 +20,4 @@ public class ContentQuestStateNotEqual extends QuestBaseHandler {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public class ContentTriggerFire extends QuestBaseHandler {
|
||||
|
||||
@Override
|
||||
public boolean execute(GameQuest quest, QuestData.QuestCondition condition, String paramStr, int... params) {
|
||||
if(quest.getTriggers().containsKey(quest.getTriggerNameById(params[0]))) {
|
||||
if (quest.getTriggers().containsKey(quest.getTriggerNameById(params[0]))) {
|
||||
//We don't want to put a new key here
|
||||
return quest.getTriggers().get(quest.getTriggerNameById(params[0]));
|
||||
} else {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package emu.grasscutter.game.quest.enums;
|
||||
|
||||
public enum QuestState {
|
||||
QUEST_STATE_NONE (0),
|
||||
QUEST_STATE_UNSTARTED (1),
|
||||
QUEST_STATE_UNFINISHED (2),
|
||||
QUEST_STATE_FINISHED (3),
|
||||
QUEST_STATE_FAILED (4),
|
||||
QUEST_STATE_NONE (0),
|
||||
QUEST_STATE_UNSTARTED (1),
|
||||
QUEST_STATE_UNFINISHED (2),
|
||||
QUEST_STATE_FINISHED (3),
|
||||
QUEST_STATE_FAILED (4),
|
||||
|
||||
// Used by lua
|
||||
NONE (0),
|
||||
@@ -14,13 +14,13 @@ public enum QuestState {
|
||||
FINISHED(3),
|
||||
FAILED(4);
|
||||
|
||||
private final int value;
|
||||
private final int value;
|
||||
|
||||
QuestState(int id) {
|
||||
this.value = id;
|
||||
}
|
||||
QuestState(int id) {
|
||||
this.value = id;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,4 +13,4 @@ public class ExecIncQuestGlobalVar extends QuestExecHandler {
|
||||
quest.getOwner().getQuestManager().incQuestGlobalVarValue(Integer.valueOf(paramStr[0]),Integer.valueOf(paramStr[1]));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -725,7 +725,7 @@ public class InventorySystem extends BaseGameSystem {
|
||||
// Invoke player use food event.
|
||||
PlayerUseFoodEvent event = new PlayerUseFoodEvent(player, itemData, target.getAsEntity());
|
||||
// Call the event.
|
||||
event.call(); if(!event.isCanceled()) {
|
||||
event.call(); if (!event.isCanceled()) {
|
||||
used = player.getTeamManager().reviveAvatar(target) ? 1 : 0;
|
||||
}
|
||||
} else {
|
||||
@@ -741,7 +741,7 @@ public class InventorySystem extends BaseGameSystem {
|
||||
// Invoke player use food event.
|
||||
PlayerUseFoodEvent event = new PlayerUseFoodEvent(player, itemData, target.getAsEntity());
|
||||
// Call the event.
|
||||
event.call(); if(!event.isCanceled()) {
|
||||
event.call(); if (!event.isCanceled()) {
|
||||
int[] SatiationParams = itemData.getSatiationParams();
|
||||
used = player.getTeamManager().healAvatar(target, SatiationParams[0], SatiationParams[1]) ? 1 : 0;
|
||||
}
|
||||
|
||||
@@ -547,9 +547,9 @@ public class Scene {
|
||||
.flatMap(Collection::stream)
|
||||
.toList();
|
||||
|
||||
onLoadGroup(groups);
|
||||
Grasscutter.getLogger().info("Scene {} Block {} loaded.", this.getId(), block.id);
|
||||
}
|
||||
onLoadGroup(groups);
|
||||
Grasscutter.getLogger().info("Scene {} Block {} loaded.", this.getId(), block.id);
|
||||
}
|
||||
public void loadTriggerFromGroup(SceneGroup group, String triggerName) {
|
||||
//Load triggers and regions
|
||||
getScriptManager().registerTrigger(group.triggers.values().stream().filter(p -> p.name.contains(triggerName)).toList());
|
||||
|
||||
@@ -70,7 +70,7 @@ public final class ServerHook {
|
||||
*/
|
||||
public void registerCommand(CommandHandler handler) {
|
||||
Class<? extends CommandHandler> clazz = handler.getClass();
|
||||
if(!clazz.isAnnotationPresent(Command.class))
|
||||
if (!clazz.isAnnotationPresent(Command.class))
|
||||
throw new IllegalArgumentException("Command handler must be annotated with @Command.");
|
||||
Command commandData = clazz.getAnnotation(Command.class);
|
||||
CommandMap.getInstance().registerCommand(commandData.label(), handler);
|
||||
@@ -107,4 +107,4 @@ public final class ServerHook {
|
||||
public void setPermissionHandler(PermissionHandler permHandler) {
|
||||
Grasscutter.setPermissionHandler(permHandler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,196 +24,196 @@ import java.util.concurrent.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class SceneScriptManager {
|
||||
private final Scene scene;
|
||||
private final Map<String, Integer> variables;
|
||||
private SceneMeta meta;
|
||||
private boolean isInit;
|
||||
/**
|
||||
* current triggers controlled by RefreshGroup
|
||||
*/
|
||||
private final Map<Integer, Set<SceneTrigger>> currentTriggers;
|
||||
private final Scene scene;
|
||||
private final Map<String, Integer> variables;
|
||||
private SceneMeta meta;
|
||||
private boolean isInit;
|
||||
/**
|
||||
* current triggers controlled by RefreshGroup
|
||||
*/
|
||||
private final Map<Integer, Set<SceneTrigger>> currentTriggers;
|
||||
private final Map<Integer, EntityRegion> regions; // <EntityId-Region>
|
||||
private final Map<Integer,SceneGroup> sceneGroups;
|
||||
private ScriptMonsterTideService scriptMonsterTideService;
|
||||
private ScriptMonsterSpawnService scriptMonsterSpawnService;
|
||||
/**
|
||||
* blockid - loaded groupSet
|
||||
*/
|
||||
private final Map<Integer, Set<SceneGroup>> loadedGroupSetPerBlock;
|
||||
public static final ExecutorService eventExecutor;
|
||||
static {
|
||||
eventExecutor = new ThreadPoolExecutor(4, 4,
|
||||
60, TimeUnit.SECONDS, new LinkedBlockingDeque<>(1000),
|
||||
FastThreadLocalThread::new, new ThreadPoolExecutor.AbortPolicy());
|
||||
}
|
||||
public SceneScriptManager(Scene scene) {
|
||||
this.scene = scene;
|
||||
this.currentTriggers = new ConcurrentHashMap<>();
|
||||
private final Map<Integer,SceneGroup> sceneGroups;
|
||||
private ScriptMonsterTideService scriptMonsterTideService;
|
||||
private ScriptMonsterSpawnService scriptMonsterSpawnService;
|
||||
/**
|
||||
* blockid - loaded groupSet
|
||||
*/
|
||||
private final Map<Integer, Set<SceneGroup>> loadedGroupSetPerBlock;
|
||||
public static final ExecutorService eventExecutor;
|
||||
static {
|
||||
eventExecutor = new ThreadPoolExecutor(4, 4,
|
||||
60, TimeUnit.SECONDS, new LinkedBlockingDeque<>(1000),
|
||||
FastThreadLocalThread::new, new ThreadPoolExecutor.AbortPolicy());
|
||||
}
|
||||
public SceneScriptManager(Scene scene) {
|
||||
this.scene = scene;
|
||||
this.currentTriggers = new ConcurrentHashMap<>();
|
||||
|
||||
this.regions = new ConcurrentHashMap<>();
|
||||
this.variables = new ConcurrentHashMap<>();
|
||||
this.sceneGroups = new ConcurrentHashMap<>();
|
||||
this.scriptMonsterSpawnService = new ScriptMonsterSpawnService(this);
|
||||
this.loadedGroupSetPerBlock = new ConcurrentHashMap<>();
|
||||
this.regions = new ConcurrentHashMap<>();
|
||||
this.variables = new ConcurrentHashMap<>();
|
||||
this.sceneGroups = new ConcurrentHashMap<>();
|
||||
this.scriptMonsterSpawnService = new ScriptMonsterSpawnService(this);
|
||||
this.loadedGroupSetPerBlock = new ConcurrentHashMap<>();
|
||||
|
||||
// TEMPORARY
|
||||
if (this.getScene().getId() < 10 && !Grasscutter.getConfig().server.game.enableScriptInBigWorld) {
|
||||
return;
|
||||
}
|
||||
// TEMPORARY
|
||||
if (this.getScene().getId() < 10 && !Grasscutter.getConfig().server.game.enableScriptInBigWorld) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Create
|
||||
this.init();
|
||||
}
|
||||
// Create
|
||||
this.init();
|
||||
}
|
||||
|
||||
public Scene getScene() {
|
||||
return scene;
|
||||
}
|
||||
public Scene getScene() {
|
||||
return scene;
|
||||
}
|
||||
|
||||
public SceneConfig getConfig() {
|
||||
if(!isInit){
|
||||
return null;
|
||||
}
|
||||
return meta.config;
|
||||
}
|
||||
public SceneConfig getConfig() {
|
||||
if (!isInit) {
|
||||
return null;
|
||||
}
|
||||
return meta.config;
|
||||
}
|
||||
|
||||
public Map<Integer, SceneBlock> getBlocks() {
|
||||
return meta.blocks;
|
||||
}
|
||||
public Map<Integer, SceneBlock> getBlocks() {
|
||||
return meta.blocks;
|
||||
}
|
||||
|
||||
public Map<String, Integer> getVariables() {
|
||||
return variables;
|
||||
}
|
||||
public Map<String, Integer> getVariables() {
|
||||
return variables;
|
||||
}
|
||||
|
||||
public Set<SceneTrigger> getTriggersByEvent(int eventId) {
|
||||
return currentTriggers.computeIfAbsent(eventId, e -> new HashSet<>());
|
||||
}
|
||||
public void registerTrigger(List<SceneTrigger> triggers) {
|
||||
triggers.forEach(this::registerTrigger);
|
||||
}
|
||||
public void registerTrigger(SceneTrigger trigger) {
|
||||
getTriggersByEvent(trigger.event).add(trigger);
|
||||
public Set<SceneTrigger> getTriggersByEvent(int eventId) {
|
||||
return currentTriggers.computeIfAbsent(eventId, e -> new HashSet<>());
|
||||
}
|
||||
public void registerTrigger(List<SceneTrigger> triggers) {
|
||||
triggers.forEach(this::registerTrigger);
|
||||
}
|
||||
public void registerTrigger(SceneTrigger trigger) {
|
||||
getTriggersByEvent(trigger.event).add(trigger);
|
||||
Grasscutter.getLogger().debug("Registered trigger {}", trigger.name);
|
||||
}
|
||||
public void deregisterTrigger(List<SceneTrigger> triggers) {
|
||||
triggers.forEach(this::deregisterTrigger);
|
||||
}
|
||||
public void deregisterTrigger(SceneTrigger trigger) {
|
||||
getTriggersByEvent(trigger.event).remove(trigger);
|
||||
}
|
||||
public void resetTriggers(int eventId) {
|
||||
currentTriggers.put(eventId, new HashSet<>());
|
||||
}
|
||||
public void refreshGroup(SceneGroup group, int suiteIndex){
|
||||
var suite = group.getSuiteByIndex(suiteIndex);
|
||||
if(suite == null){
|
||||
return;
|
||||
}
|
||||
if(suite.sceneTriggers.size() > 0){
|
||||
for(var trigger : suite.sceneTriggers){
|
||||
resetTriggers(trigger.event);
|
||||
this.currentTriggers.get(trigger.event).add(trigger);
|
||||
}
|
||||
}
|
||||
spawnMonstersInGroup(group, suite);
|
||||
spawnGadgetsInGroup(group, suite);
|
||||
}
|
||||
public EntityRegion getRegionById(int id) {
|
||||
return regions.get(id);
|
||||
}
|
||||
}
|
||||
public void deregisterTrigger(List<SceneTrigger> triggers) {
|
||||
triggers.forEach(this::deregisterTrigger);
|
||||
}
|
||||
public void deregisterTrigger(SceneTrigger trigger) {
|
||||
getTriggersByEvent(trigger.event).remove(trigger);
|
||||
}
|
||||
public void resetTriggers(int eventId) {
|
||||
currentTriggers.put(eventId, new HashSet<>());
|
||||
}
|
||||
public void refreshGroup(SceneGroup group, int suiteIndex) {
|
||||
var suite = group.getSuiteByIndex(suiteIndex);
|
||||
if (suite == null) {
|
||||
return;
|
||||
}
|
||||
if (suite.sceneTriggers.size() > 0) {
|
||||
for (var trigger : suite.sceneTriggers) {
|
||||
resetTriggers(trigger.event);
|
||||
this.currentTriggers.get(trigger.event).add(trigger);
|
||||
}
|
||||
}
|
||||
spawnMonstersInGroup(group, suite);
|
||||
spawnGadgetsInGroup(group, suite);
|
||||
}
|
||||
public EntityRegion getRegionById(int id) {
|
||||
return regions.get(id);
|
||||
}
|
||||
|
||||
public void registerRegion(EntityRegion region) {
|
||||
regions.put(region.getId(), region);
|
||||
public void registerRegion(EntityRegion region) {
|
||||
regions.put(region.getId(), region);
|
||||
Grasscutter.getLogger().debug("Registered region {} from group {}", region.getMetaRegion().config_id, region.getGroupId());
|
||||
}
|
||||
public void registerRegionInGroupSuite(SceneGroup group, SceneSuite suite){
|
||||
}
|
||||
public void registerRegionInGroupSuite(SceneGroup group, SceneSuite suite) {
|
||||
suite.sceneRegions.stream().map(region -> new EntityRegion(this.getScene(), region))
|
||||
.forEach(this::registerRegion);
|
||||
}
|
||||
public synchronized void deregisterRegion(SceneRegion region) {
|
||||
var instance = regions.values().stream()
|
||||
public synchronized void deregisterRegion(SceneRegion region) {
|
||||
var instance = regions.values().stream()
|
||||
.filter(r -> r.getConfigId() == region.config_id)
|
||||
.findFirst();
|
||||
instance.ifPresent(entityRegion -> regions.remove(entityRegion.getId()));
|
||||
}
|
||||
}
|
||||
|
||||
public Map<Integer, Set<SceneGroup>> getLoadedGroupSetPerBlock() {
|
||||
return loadedGroupSetPerBlock;
|
||||
}
|
||||
public Map<Integer, Set<SceneGroup>> getLoadedGroupSetPerBlock() {
|
||||
return loadedGroupSetPerBlock;
|
||||
}
|
||||
|
||||
// TODO optimize
|
||||
public SceneGroup getGroupById(int groupId) {
|
||||
for (SceneBlock block : this.getScene().getLoadedBlocks()) {
|
||||
var group = block.groups.get(groupId);
|
||||
if(group == null){
|
||||
continue;
|
||||
}
|
||||
// TODO optimize
|
||||
public SceneGroup getGroupById(int groupId) {
|
||||
for (SceneBlock block : this.getScene().getLoadedBlocks()) {
|
||||
var group = block.groups.get(groupId);
|
||||
if (group == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!group.isLoaded()){
|
||||
getScene().onLoadGroup(List.of(group));
|
||||
}
|
||||
return group;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (!group.isLoaded()) {
|
||||
getScene().onLoadGroup(List.of(group));
|
||||
}
|
||||
return group;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void init() {
|
||||
var meta = ScriptLoader.getSceneMeta(getScene().getId());
|
||||
if (meta == null){
|
||||
return;
|
||||
}
|
||||
this.meta = meta;
|
||||
private void init() {
|
||||
var meta = ScriptLoader.getSceneMeta(getScene().getId());
|
||||
if (meta == null) {
|
||||
return;
|
||||
}
|
||||
this.meta = meta;
|
||||
|
||||
// TEMP
|
||||
this.isInit = true;
|
||||
}
|
||||
// TEMP
|
||||
this.isInit = true;
|
||||
}
|
||||
|
||||
public boolean isInit() {
|
||||
return isInit;
|
||||
}
|
||||
public boolean isInit() {
|
||||
return isInit;
|
||||
}
|
||||
|
||||
public void loadBlockFromScript(SceneBlock block) {
|
||||
block.load(scene.getId(), meta.context);
|
||||
}
|
||||
public void loadBlockFromScript(SceneBlock block) {
|
||||
block.load(scene.getId(), meta.context);
|
||||
}
|
||||
|
||||
public void loadGroupFromScript(SceneGroup group) {
|
||||
group.load(getScene().getId());
|
||||
public void loadGroupFromScript(SceneGroup group) {
|
||||
group.load(getScene().getId());
|
||||
|
||||
if (group.variables != null) {
|
||||
group.variables.forEach(var -> this.getVariables().put(var.name, var.value));
|
||||
}
|
||||
if (group.variables != null) {
|
||||
group.variables.forEach(var -> this.getVariables().put(var.name, var.value));
|
||||
}
|
||||
|
||||
this.sceneGroups.put(group.id, group);
|
||||
}
|
||||
this.sceneGroups.put(group.id, group);
|
||||
}
|
||||
|
||||
public void checkRegions() {
|
||||
if (this.regions.size() == 0) {
|
||||
return;
|
||||
}
|
||||
public void checkRegions() {
|
||||
if (this.regions.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (var region : this.regions.values()) {
|
||||
for (var region : this.regions.values()) {
|
||||
// currently all condition_ENTER_REGION Events check for avatar, so we have no necessary to add other types of entity
|
||||
getScene().getEntities().values()
|
||||
.stream()
|
||||
.filter(e -> e.getEntityType() == EntityType.Avatar.getValue() && region.getMetaRegion().contains(e.getPosition()))
|
||||
.forEach(region::addEntity);
|
||||
getScene().getEntities().values()
|
||||
.stream()
|
||||
.filter(e -> e.getEntityType() == EntityType.Avatar.getValue() && region.getMetaRegion().contains(e.getPosition()))
|
||||
.forEach(region::addEntity);
|
||||
|
||||
var players = region.getScene().getPlayers();
|
||||
int targetID = 0;
|
||||
if(players.size() > 0)
|
||||
if (players.size() > 0)
|
||||
targetID = players.get(0).getUid();
|
||||
|
||||
if (region.hasNewEntities()) {
|
||||
if (region.hasNewEntities()) {
|
||||
Grasscutter.getLogger().trace("Call EVENT_ENTER_REGION_{}",region.getMetaRegion().config_id);
|
||||
callEvent(EventType.EVENT_ENTER_REGION, new ScriptArgs(region.getConfigId())
|
||||
callEvent(EventType.EVENT_ENTER_REGION, new ScriptArgs(region.getConfigId())
|
||||
.setSourceEntityId(region.getId())
|
||||
.setTargetEntityId(targetID)
|
||||
);
|
||||
|
||||
region.resetNewEntities();
|
||||
}
|
||||
region.resetNewEntities();
|
||||
}
|
||||
|
||||
for(int entityId : region.getEntities()) {
|
||||
if(getScene().getEntityById(entityId) == null || !region.getMetaRegion().contains(getScene().getEntityById(entityId).getPosition())) {
|
||||
for (int entityId : region.getEntities()) {
|
||||
if (getScene().getEntityById(entityId) == null || !region.getMetaRegion().contains(getScene().getEntityById(entityId).getPosition())) {
|
||||
region.removeEntity(entityId);
|
||||
|
||||
}
|
||||
@@ -224,24 +224,24 @@ public class SceneScriptManager {
|
||||
.setTargetEntityId(region.getFirstEntityId())
|
||||
);
|
||||
|
||||
region.resetNewEntities();
|
||||
}
|
||||
}
|
||||
}
|
||||
region.resetNewEntities();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<EntityGadget> getGadgetsInGroupSuite(SceneGroup group, SceneSuite suite){
|
||||
public List<EntityGadget> getGadgetsInGroupSuite(SceneGroup group, SceneSuite suite) {
|
||||
return suite.sceneGadgets.stream()
|
||||
.map(g -> createGadget(group.id, group.block_id, g))
|
||||
.filter(Objects::nonNull)
|
||||
.toList();
|
||||
}
|
||||
public List<EntityMonster> getMonstersInGroupSuite(SceneGroup group, SceneSuite suite){
|
||||
public List<EntityMonster> getMonstersInGroupSuite(SceneGroup group, SceneSuite suite) {
|
||||
return suite.sceneMonsters.stream()
|
||||
.map(mob -> createMonster(group.id, group.block_id, mob))
|
||||
.filter(Objects::nonNull)
|
||||
.toList();
|
||||
}
|
||||
public void addGroupSuite(SceneGroup group, SceneSuite suite){
|
||||
public void addGroupSuite(SceneGroup group, SceneSuite suite) {
|
||||
// we added trigger first
|
||||
registerTrigger(suite.sceneTriggers);
|
||||
|
||||
@@ -251,67 +251,67 @@ public class SceneScriptManager {
|
||||
addEntities(toCreate);
|
||||
|
||||
registerRegionInGroupSuite(group, suite);
|
||||
}
|
||||
public void removeGroupSuite(SceneGroup group, SceneSuite suite){
|
||||
}
|
||||
public void removeGroupSuite(SceneGroup group, SceneSuite suite) {
|
||||
deregisterTrigger(suite.sceneTriggers);
|
||||
removeMonstersInGroup(group, suite);
|
||||
removeGadgetsInGroup(group, suite);
|
||||
removeMonstersInGroup(group, suite);
|
||||
removeGadgetsInGroup(group, suite);
|
||||
|
||||
suite.sceneRegions.forEach(this::deregisterRegion);
|
||||
}
|
||||
}
|
||||
|
||||
public void spawnGadgetsInGroup(SceneGroup group, SceneSuite suite) {
|
||||
var gadgets = group.gadgets.values();
|
||||
public void spawnGadgetsInGroup(SceneGroup group, SceneSuite suite) {
|
||||
var gadgets = group.gadgets.values();
|
||||
|
||||
if (suite != null) {
|
||||
gadgets = suite.sceneGadgets;
|
||||
}
|
||||
if (suite != null) {
|
||||
gadgets = suite.sceneGadgets;
|
||||
}
|
||||
|
||||
var toCreate = gadgets.stream()
|
||||
.map(g -> createGadget(g.group.id, group.block_id, g))
|
||||
.filter(Objects::nonNull)
|
||||
.toList();
|
||||
this.addEntities(toCreate);
|
||||
}
|
||||
var toCreate = gadgets.stream()
|
||||
.map(g -> createGadget(g.group.id, group.block_id, g))
|
||||
.filter(Objects::nonNull)
|
||||
.toList();
|
||||
this.addEntities(toCreate);
|
||||
}
|
||||
|
||||
public void spawnMonstersInGroup(SceneGroup group, SceneSuite suite) {
|
||||
if(suite == null || suite.sceneMonsters.size() <= 0){
|
||||
return;
|
||||
}
|
||||
this.addEntities(suite.sceneMonsters.stream()
|
||||
.map(mob -> createMonster(group.id, group.block_id, mob)).toList());
|
||||
}
|
||||
public void spawnMonstersInGroup(SceneGroup group, SceneSuite suite) {
|
||||
if (suite == null || suite.sceneMonsters.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
this.addEntities(suite.sceneMonsters.stream()
|
||||
.map(mob -> createMonster(group.id, group.block_id, mob)).toList());
|
||||
}
|
||||
|
||||
public void startMonsterTideInGroup(SceneGroup group, Integer[] ordersConfigId, int tideCount, int sceneLimit) {
|
||||
this.scriptMonsterTideService =
|
||||
new ScriptMonsterTideService(this, group, tideCount, sceneLimit, ordersConfigId);
|
||||
public void startMonsterTideInGroup(SceneGroup group, Integer[] ordersConfigId, int tideCount, int sceneLimit) {
|
||||
this.scriptMonsterTideService =
|
||||
new ScriptMonsterTideService(this, group, tideCount, sceneLimit, ordersConfigId);
|
||||
|
||||
}
|
||||
public void unloadCurrentMonsterTide(){
|
||||
if(this.getScriptMonsterTideService() == null){
|
||||
return;
|
||||
}
|
||||
this.getScriptMonsterTideService().unload();
|
||||
}
|
||||
public void spawnMonstersByConfigId(SceneGroup group, int configId, int delayTime) {
|
||||
// TODO delay
|
||||
getScene().addEntity(createMonster(group.id, group.block_id, group.monsters.get(configId)));
|
||||
}
|
||||
// Events
|
||||
public void callEvent(int eventType, ScriptArgs params){
|
||||
/**
|
||||
* We use ThreadLocal to trans SceneScriptManager context to ScriptLib, to avoid eval script for every groups' trigger in every scene instances.
|
||||
* But when callEvent is called in a ScriptLib func, it may cause NPE because the inner call cleans the ThreadLocal so that outer call could not get it.
|
||||
* e.g. CallEvent -> set -> ScriptLib.xxx -> CallEvent -> set -> remove -> NPE -> (remove)
|
||||
* So we use thread pool to clean the stack to avoid this new issue.
|
||||
*/
|
||||
eventExecutor.submit(() -> this.realCallEvent(eventType, params));
|
||||
}
|
||||
}
|
||||
public void unloadCurrentMonsterTide() {
|
||||
if (this.getScriptMonsterTideService() == null) {
|
||||
return;
|
||||
}
|
||||
this.getScriptMonsterTideService().unload();
|
||||
}
|
||||
public void spawnMonstersByConfigId(SceneGroup group, int configId, int delayTime) {
|
||||
// TODO delay
|
||||
getScene().addEntity(createMonster(group.id, group.block_id, group.monsters.get(configId)));
|
||||
}
|
||||
// Events
|
||||
public void callEvent(int eventType, ScriptArgs params) {
|
||||
/**
|
||||
* We use ThreadLocal to trans SceneScriptManager context to ScriptLib, to avoid eval script for every groups' trigger in every scene instances.
|
||||
* But when callEvent is called in a ScriptLib func, it may cause NPE because the inner call cleans the ThreadLocal so that outer call could not get it.
|
||||
* e.g. CallEvent -> set -> ScriptLib.xxx -> CallEvent -> set -> remove -> NPE -> (remove)
|
||||
* So we use thread pool to clean the stack to avoid this new issue.
|
||||
*/
|
||||
eventExecutor.submit(() -> this.realCallEvent(eventType, params));
|
||||
}
|
||||
|
||||
private void realCallEvent(int eventType, ScriptArgs params) {
|
||||
private void realCallEvent(int eventType, ScriptArgs params) {
|
||||
try {
|
||||
Set<SceneTrigger> relevantTriggers = new HashSet<>();
|
||||
if(eventType == EventType.EVENT_ENTER_REGION || eventType == EventType.EVENT_LEAVE_REGION) {
|
||||
if (eventType == EventType.EVENT_ENTER_REGION || eventType == EventType.EVENT_LEAVE_REGION) {
|
||||
List<SceneTrigger> relevantTriggersList = this.getTriggersByEvent(eventType).stream()
|
||||
.filter(p -> p.condition.contains(String.valueOf(params.param1))).toList();
|
||||
relevantTriggers = new HashSet<>(relevantTriggersList);
|
||||
@@ -344,154 +344,154 @@ public class SceneScriptManager {
|
||||
}
|
||||
}
|
||||
}finally {
|
||||
// make sure it is removed
|
||||
ScriptLoader.getScriptLib().removeSceneScriptManager();
|
||||
}
|
||||
}
|
||||
// make sure it is removed
|
||||
ScriptLoader.getScriptLib().removeSceneScriptManager();
|
||||
}
|
||||
}
|
||||
|
||||
private LuaValue callScriptFunc(String funcName, SceneGroup group, ScriptArgs params){
|
||||
LuaValue funcLua = null;
|
||||
if (funcName != null && !funcName.isEmpty()) {
|
||||
funcLua = (LuaValue) group.getBindings().get(funcName);
|
||||
}
|
||||
private LuaValue callScriptFunc(String funcName, SceneGroup group, ScriptArgs params) {
|
||||
LuaValue funcLua = null;
|
||||
if (funcName != null && !funcName.isEmpty()) {
|
||||
funcLua = (LuaValue) group.getBindings().get(funcName);
|
||||
}
|
||||
|
||||
LuaValue ret = LuaValue.TRUE;
|
||||
LuaValue ret = LuaValue.TRUE;
|
||||
|
||||
if (funcLua != null) {
|
||||
LuaValue args = LuaValue.NIL;
|
||||
if (funcLua != null) {
|
||||
LuaValue args = LuaValue.NIL;
|
||||
|
||||
if (params != null) {
|
||||
args = CoerceJavaToLua.coerce(params);
|
||||
}
|
||||
if (params != null) {
|
||||
args = CoerceJavaToLua.coerce(params);
|
||||
}
|
||||
|
||||
ret = safetyCall(funcName, funcLua, args);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
ret = safetyCall(funcName, funcLua, args);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public LuaValue safetyCall(String name, LuaValue func, LuaValue args){
|
||||
try{
|
||||
return func.call(ScriptLoader.getScriptLibLua(), args);
|
||||
}catch (LuaError error){
|
||||
ScriptLib.logger.error("[LUA] call trigger failed {},{}",name,args,error);
|
||||
return LuaValue.valueOf(-1);
|
||||
}
|
||||
}
|
||||
public LuaValue safetyCall(String name, LuaValue func, LuaValue args) {
|
||||
try {
|
||||
return func.call(ScriptLoader.getScriptLibLua(), args);
|
||||
}catch (LuaError error) {
|
||||
ScriptLib.logger.error("[LUA] call trigger failed {},{}",name,args,error);
|
||||
return LuaValue.valueOf(-1);
|
||||
}
|
||||
}
|
||||
|
||||
public ScriptMonsterTideService getScriptMonsterTideService() {
|
||||
return scriptMonsterTideService;
|
||||
}
|
||||
public ScriptMonsterTideService getScriptMonsterTideService() {
|
||||
return scriptMonsterTideService;
|
||||
}
|
||||
|
||||
public ScriptMonsterSpawnService getScriptMonsterSpawnService() {
|
||||
return scriptMonsterSpawnService;
|
||||
}
|
||||
public ScriptMonsterSpawnService getScriptMonsterSpawnService() {
|
||||
return scriptMonsterSpawnService;
|
||||
}
|
||||
|
||||
public EntityGadget createGadget(int groupId, int blockId, SceneGadget g) {
|
||||
if(g.isOneoff){
|
||||
public EntityGadget createGadget(int groupId, int blockId, SceneGadget g) {
|
||||
if (g.isOneoff) {
|
||||
var hasEntity = getScene().getEntities().values().stream()
|
||||
.filter(e -> e instanceof EntityGadget)
|
||||
.filter(e -> e.getGroupId() == g.group.id)
|
||||
.filter(e -> e.getConfigId() == g.config_id)
|
||||
.findFirst();
|
||||
if(hasEntity.isPresent()){
|
||||
if (hasEntity.isPresent()) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
EntityGadget entity = new EntityGadget(getScene(), g.gadget_id, g.pos);
|
||||
EntityGadget entity = new EntityGadget(getScene(), g.gadget_id, g.pos);
|
||||
|
||||
if (entity.getGadgetData() == null){
|
||||
return null;
|
||||
}
|
||||
if (entity.getGadgetData() == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
entity.setBlockId(blockId);
|
||||
entity.setConfigId(g.config_id);
|
||||
entity.setGroupId(groupId);
|
||||
entity.getRotation().set(g.rot);
|
||||
entity.setState(g.state);
|
||||
entity.setPointType(g.point_type);
|
||||
entity.setMetaGadget(g);
|
||||
entity.buildContent();
|
||||
entity.setBlockId(blockId);
|
||||
entity.setConfigId(g.config_id);
|
||||
entity.setGroupId(groupId);
|
||||
entity.getRotation().set(g.rot);
|
||||
entity.setState(g.state);
|
||||
entity.setPointType(g.point_type);
|
||||
entity.setMetaGadget(g);
|
||||
entity.buildContent();
|
||||
|
||||
return entity;
|
||||
}
|
||||
public EntityNPC createNPC(SceneNPC npc, int blockId, int suiteId) {
|
||||
return new EntityNPC(getScene(), npc, blockId, suiteId);
|
||||
}
|
||||
public EntityMonster createMonster(int groupId, int blockId, SceneMonster monster) {
|
||||
if(monster == null){
|
||||
return null;
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
public EntityNPC createNPC(SceneNPC npc, int blockId, int suiteId) {
|
||||
return new EntityNPC(getScene(), npc, blockId, suiteId);
|
||||
}
|
||||
public EntityMonster createMonster(int groupId, int blockId, SceneMonster monster) {
|
||||
if (monster == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
MonsterData data = GameData.getMonsterDataMap().get(monster.monster_id);
|
||||
MonsterData data = GameData.getMonsterDataMap().get(monster.monster_id);
|
||||
|
||||
if (data == null) {
|
||||
return null;
|
||||
}
|
||||
if (data == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Calculate level
|
||||
int level = monster.level;
|
||||
// Calculate level
|
||||
int level = monster.level;
|
||||
|
||||
if (getScene().getDungeonData() != null) {
|
||||
level = getScene().getDungeonData().getShowLevel();
|
||||
} else if (getScene().getWorld().getWorldLevel() > 0) {
|
||||
WorldLevelData worldLevelData = GameData.getWorldLevelDataMap().get(getScene().getWorld().getWorldLevel());
|
||||
if (getScene().getDungeonData() != null) {
|
||||
level = getScene().getDungeonData().getShowLevel();
|
||||
} else if (getScene().getWorld().getWorldLevel() > 0) {
|
||||
WorldLevelData worldLevelData = GameData.getWorldLevelDataMap().get(getScene().getWorld().getWorldLevel());
|
||||
|
||||
if (worldLevelData != null) {
|
||||
level = worldLevelData.getMonsterLevel();
|
||||
}
|
||||
}
|
||||
if (worldLevelData != null) {
|
||||
level = worldLevelData.getMonsterLevel();
|
||||
}
|
||||
}
|
||||
|
||||
// Spawn mob
|
||||
EntityMonster entity = new EntityMonster(getScene(), data, monster.pos, level);
|
||||
entity.getRotation().set(monster.rot);
|
||||
entity.setGroupId(groupId);
|
||||
entity.setBlockId(blockId);
|
||||
entity.setConfigId(monster.config_id);
|
||||
entity.setPoseId(monster.pose_id);
|
||||
// Spawn mob
|
||||
EntityMonster entity = new EntityMonster(getScene(), data, monster.pos, level);
|
||||
entity.getRotation().set(monster.rot);
|
||||
entity.setGroupId(groupId);
|
||||
entity.setBlockId(blockId);
|
||||
entity.setConfigId(monster.config_id);
|
||||
entity.setPoseId(monster.pose_id);
|
||||
|
||||
this.getScriptMonsterSpawnService()
|
||||
.onMonsterCreatedListener.forEach(action -> action.onNotify(entity));
|
||||
this.getScriptMonsterSpawnService()
|
||||
.onMonsterCreatedListener.forEach(action -> action.onNotify(entity));
|
||||
|
||||
return entity;
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
public void addEntity(GameEntity gameEntity){
|
||||
getScene().addEntity(gameEntity);
|
||||
}
|
||||
public void addEntity(GameEntity gameEntity) {
|
||||
getScene().addEntity(gameEntity);
|
||||
}
|
||||
|
||||
public void meetEntities(List<? extends GameEntity> gameEntity){
|
||||
getScene().addEntities(gameEntity, VisionTypeOuterClass.VisionType.VISION_TYPE_MEET);
|
||||
}
|
||||
public void meetEntities(List<? extends GameEntity> gameEntity) {
|
||||
getScene().addEntities(gameEntity, VisionTypeOuterClass.VisionType.VISION_TYPE_MEET);
|
||||
}
|
||||
|
||||
public void addEntities(List<? extends GameEntity> gameEntity){
|
||||
getScene().addEntities(gameEntity);
|
||||
}
|
||||
public void addEntities(List<? extends GameEntity> gameEntity) {
|
||||
getScene().addEntities(gameEntity);
|
||||
}
|
||||
|
||||
public RTree<SceneBlock, Geometry> getBlocksIndex() {
|
||||
return meta.sceneBlockIndex;
|
||||
}
|
||||
public void removeMonstersInGroup(SceneGroup group, SceneSuite suite) {
|
||||
var configSet = suite.sceneMonsters.stream()
|
||||
.map(m -> m.config_id)
|
||||
.collect(Collectors.toSet());
|
||||
var toRemove = getScene().getEntities().values().stream()
|
||||
.filter(e -> e instanceof EntityMonster)
|
||||
.filter(e -> e.getGroupId() == group.id)
|
||||
.filter(e -> configSet.contains(e.getConfigId()))
|
||||
.toList();
|
||||
public RTree<SceneBlock, Geometry> getBlocksIndex() {
|
||||
return meta.sceneBlockIndex;
|
||||
}
|
||||
public void removeMonstersInGroup(SceneGroup group, SceneSuite suite) {
|
||||
var configSet = suite.sceneMonsters.stream()
|
||||
.map(m -> m.config_id)
|
||||
.collect(Collectors.toSet());
|
||||
var toRemove = getScene().getEntities().values().stream()
|
||||
.filter(e -> e instanceof EntityMonster)
|
||||
.filter(e -> e.getGroupId() == group.id)
|
||||
.filter(e -> configSet.contains(e.getConfigId()))
|
||||
.toList();
|
||||
|
||||
getScene().removeEntities(toRemove, VisionTypeOuterClass.VisionType.VISION_TYPE_MISS);
|
||||
}
|
||||
public void removeGadgetsInGroup(SceneGroup group, SceneSuite suite) {
|
||||
var configSet = suite.sceneGadgets.stream()
|
||||
.map(m -> m.config_id)
|
||||
.collect(Collectors.toSet());
|
||||
var toRemove = getScene().getEntities().values().stream()
|
||||
.filter(e -> e instanceof EntityGadget)
|
||||
.filter(e -> e.getGroupId() == group.id)
|
||||
.filter(e -> configSet.contains(e.getConfigId()))
|
||||
.toList();
|
||||
getScene().removeEntities(toRemove, VisionTypeOuterClass.VisionType.VISION_TYPE_MISS);
|
||||
}
|
||||
public void removeGadgetsInGroup(SceneGroup group, SceneSuite suite) {
|
||||
var configSet = suite.sceneGadgets.stream()
|
||||
.map(m -> m.config_id)
|
||||
.collect(Collectors.toSet());
|
||||
var toRemove = getScene().getEntities().values().stream()
|
||||
.filter(e -> e instanceof EntityGadget)
|
||||
.filter(e -> e.getGroupId() == group.id)
|
||||
.filter(e -> configSet.contains(e.getConfigId()))
|
||||
.toList();
|
||||
|
||||
getScene().removeEntities(toRemove, VisionTypeOuterClass.VisionType.VISION_TYPE_MISS);
|
||||
}
|
||||
getScene().removeEntities(toRemove, VisionTypeOuterClass.VisionType.VISION_TYPE_MISS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,15 +6,15 @@ import lombok.ToString;
|
||||
@ToString
|
||||
@Setter
|
||||
public class SceneGadget extends SceneObject{
|
||||
public int gadget_id;
|
||||
public int state;
|
||||
public int point_type;
|
||||
public SceneBossChest boss_chest;
|
||||
public int interact_id;
|
||||
public int gadget_id;
|
||||
public int state;
|
||||
public int point_type;
|
||||
public SceneBossChest boss_chest;
|
||||
public int interact_id;
|
||||
public boolean isOneoff;
|
||||
public int draft_id;
|
||||
|
||||
public void setIsOneoff(boolean isOneoff){
|
||||
public void setIsOneoff(boolean isOneoff) {
|
||||
this.isOneoff = isOneoff;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,29 +7,29 @@ import lombok.Setter;
|
||||
|
||||
@Setter
|
||||
public class SceneRegion {
|
||||
public int config_id;
|
||||
public int shape;
|
||||
public Position pos;
|
||||
public int config_id;
|
||||
public int shape;
|
||||
public Position pos;
|
||||
// for CUBIC
|
||||
public Position size;
|
||||
public Position size;
|
||||
// for SPHERE
|
||||
public int radius;
|
||||
|
||||
public transient SceneGroup group;
|
||||
public boolean contains(Position position) {
|
||||
switch (shape) {
|
||||
case ScriptRegionShape.CUBIC:
|
||||
return (Math.abs(pos.getX() - position.getX()) <= size.getX()) &&
|
||||
(Math.abs(pos.getY() - position.getY()) <= size.getY()) &&
|
||||
(Math.abs(pos.getZ() - position.getZ()) <= size.getZ());
|
||||
case ScriptRegionShape.SPHERE:
|
||||
public boolean contains(Position position) {
|
||||
switch (shape) {
|
||||
case ScriptRegionShape.CUBIC:
|
||||
return (Math.abs(pos.getX() - position.getX()) <= size.getX()) &&
|
||||
(Math.abs(pos.getY() - position.getY()) <= size.getY()) &&
|
||||
(Math.abs(pos.getZ() - position.getZ()) <= size.getZ());
|
||||
case ScriptRegionShape.SPHERE:
|
||||
var x = Math.pow(pos.getX() - position.getX(), 2);
|
||||
var y = Math.pow(pos.getY() - position.getY(), 2);
|
||||
var z = Math.pow(pos.getZ() - position.getZ(), 2);
|
||||
// ^ means XOR in java!
|
||||
return x + y + z <= (radius*radius);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return x + y + z <= (radius*radius);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,19 +16,19 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class LuaSerializer implements Serializer {
|
||||
|
||||
private final static Map<Class<?>, MethodAccess> methodAccessCache = new ConcurrentHashMap<>();
|
||||
private final static Map<Class<?>, ConstructorAccess<?>> constructorCache = new ConcurrentHashMap<>();
|
||||
private final static Map<Class<?>, Map<String, FieldMeta>> fieldMetaCache = new ConcurrentHashMap<>();
|
||||
private final static Map<Class<?>, MethodAccess> methodAccessCache = new ConcurrentHashMap<>();
|
||||
private final static Map<Class<?>, ConstructorAccess<?>> constructorCache = new ConcurrentHashMap<>();
|
||||
private final static Map<Class<?>, Map<String, FieldMeta>> fieldMetaCache = new ConcurrentHashMap<>();
|
||||
|
||||
@Override
|
||||
public <T> List<T> toList(Class<T> type, Object obj) {
|
||||
return serializeList(type, (LuaTable) obj);
|
||||
}
|
||||
@Override
|
||||
public <T> List<T> toList(Class<T> type, Object obj) {
|
||||
return serializeList(type, (LuaTable) obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T toObject(Class<T> type, Object obj) {
|
||||
return serialize(type, (LuaTable) obj);
|
||||
}
|
||||
@Override
|
||||
public <T> T toObject(Class<T> type, Object obj) {
|
||||
return serialize(type, (LuaTable) obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Map<String, T> toMap(Class<T> type, Object obj) {
|
||||
@@ -79,161 +79,161 @@ public class LuaSerializer implements Serializer {
|
||||
}
|
||||
|
||||
public <T> List<T> serializeList(Class<T> type, LuaTable table) {
|
||||
List<T> list = new ArrayList<>();
|
||||
List<T> list = new ArrayList<>();
|
||||
|
||||
if (table == null) {
|
||||
return list;
|
||||
}
|
||||
if (table == null) {
|
||||
return list;
|
||||
}
|
||||
|
||||
try {
|
||||
LuaValue[] keys = table.keys();
|
||||
for (LuaValue k : keys) {
|
||||
try {
|
||||
LuaValue keyValue = table.get(k);
|
||||
try {
|
||||
LuaValue[] keys = table.keys();
|
||||
for (LuaValue k : keys) {
|
||||
try {
|
||||
LuaValue keyValue = table.get(k);
|
||||
|
||||
T object = null;
|
||||
T object = null;
|
||||
|
||||
if (keyValue.istable()) {
|
||||
object = serialize(type, keyValue.checktable());
|
||||
} else if (keyValue.isint()) {
|
||||
object = (T) (Integer) keyValue.toint();
|
||||
} else if (keyValue.isnumber()) {
|
||||
object = (T) (Float) keyValue.tofloat(); // terrible...
|
||||
} else if (keyValue.isstring()) {
|
||||
object = (T) keyValue.tojstring();
|
||||
if (keyValue.istable()) {
|
||||
object = serialize(type, keyValue.checktable());
|
||||
} else if (keyValue.isint()) {
|
||||
object = (T) (Integer) keyValue.toint();
|
||||
} else if (keyValue.isnumber()) {
|
||||
object = (T) (Float) keyValue.tofloat(); // terrible...
|
||||
} else if (keyValue.isstring()) {
|
||||
object = (T) keyValue.tojstring();
|
||||
} else if (keyValue.isboolean()) {
|
||||
object = (T) (Boolean) keyValue.toboolean();
|
||||
} else {
|
||||
object = (T) keyValue;
|
||||
}
|
||||
object = (T) keyValue;
|
||||
}
|
||||
|
||||
if (object != null) {
|
||||
list.add(object);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
if (object != null) {
|
||||
list.add(object);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public <T> T serialize(Class<T> type, LuaTable table) {
|
||||
T object = null;
|
||||
public <T> T serialize(Class<T> type, LuaTable table) {
|
||||
T object = null;
|
||||
|
||||
if (type == List.class) {
|
||||
try {
|
||||
Class<T> listType = (Class<T>) type.getTypeParameters()[0].getClass();
|
||||
return (T) serializeList(listType, table);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (type == List.class) {
|
||||
try {
|
||||
Class<T> listType = (Class<T>) type.getTypeParameters()[0].getClass();
|
||||
return (T) serializeList(listType, table);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
if (!methodAccessCache.containsKey(type)) {
|
||||
cacheType(type);
|
||||
}
|
||||
var methodAccess = methodAccessCache.get(type);
|
||||
var fieldMetaMap = fieldMetaCache.get(type);
|
||||
try {
|
||||
if (!methodAccessCache.containsKey(type)) {
|
||||
cacheType(type);
|
||||
}
|
||||
var methodAccess = methodAccessCache.get(type);
|
||||
var fieldMetaMap = fieldMetaCache.get(type);
|
||||
|
||||
object = (T) constructorCache.get(type).newInstance();
|
||||
object = (T) constructorCache.get(type).newInstance();
|
||||
|
||||
if (table == null) {
|
||||
return object;
|
||||
}
|
||||
if (table == null) {
|
||||
return object;
|
||||
}
|
||||
|
||||
LuaValue[] keys = table.keys();
|
||||
for (LuaValue k : keys) {
|
||||
try {
|
||||
var keyName = k.checkjstring();
|
||||
if(!fieldMetaMap.containsKey(keyName)){
|
||||
continue;
|
||||
}
|
||||
var fieldMeta = fieldMetaMap.get(keyName);
|
||||
LuaValue keyValue = table.get(k);
|
||||
LuaValue[] keys = table.keys();
|
||||
for (LuaValue k : keys) {
|
||||
try {
|
||||
var keyName = k.checkjstring();
|
||||
if (!fieldMetaMap.containsKey(keyName)) {
|
||||
continue;
|
||||
}
|
||||
var fieldMeta = fieldMetaMap.get(keyName);
|
||||
LuaValue keyValue = table.get(k);
|
||||
|
||||
if (keyValue.istable()) {
|
||||
methodAccess.invoke(object, fieldMeta.index, serialize(fieldMeta.getType(), keyValue.checktable()));
|
||||
} else if (fieldMeta.getType().equals(float.class)) {
|
||||
methodAccess.invoke(object, fieldMeta.index, keyValue.tofloat());
|
||||
} else if (fieldMeta.getType().equals(int.class)) {
|
||||
methodAccess.invoke(object, fieldMeta.index, keyValue.toint());
|
||||
} else if (fieldMeta.getType().equals(String.class)) {
|
||||
methodAccess.invoke(object, fieldMeta.index, keyValue.tojstring());
|
||||
if (keyValue.istable()) {
|
||||
methodAccess.invoke(object, fieldMeta.index, serialize(fieldMeta.getType(), keyValue.checktable()));
|
||||
} else if (fieldMeta.getType().equals(float.class)) {
|
||||
methodAccess.invoke(object, fieldMeta.index, keyValue.tofloat());
|
||||
} else if (fieldMeta.getType().equals(int.class)) {
|
||||
methodAccess.invoke(object, fieldMeta.index, keyValue.toint());
|
||||
} else if (fieldMeta.getType().equals(String.class)) {
|
||||
methodAccess.invoke(object, fieldMeta.index, keyValue.tojstring());
|
||||
} else if (fieldMeta.getType().equals(boolean.class)) {
|
||||
methodAccess.invoke(object, fieldMeta.index, keyValue.toboolean());
|
||||
} else {
|
||||
methodAccess.invoke(object, fieldMeta.index, keyValue.tojstring());
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
//ex.printStackTrace();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Grasscutter.getLogger().info(ScriptUtils.toMap(table).toString());
|
||||
e.printStackTrace();
|
||||
}
|
||||
methodAccess.invoke(object, fieldMeta.index, keyValue.tojstring());
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
//ex.printStackTrace();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Grasscutter.getLogger().info(ScriptUtils.toMap(table).toString());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return object;
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
public <T> Map<String, FieldMeta> cacheType(Class<T> type){
|
||||
if(fieldMetaCache.containsKey(type)) {
|
||||
return fieldMetaCache.get(type);
|
||||
}
|
||||
if(!constructorCache.containsKey(type)){
|
||||
constructorCache.putIfAbsent(type, ConstructorAccess.get(type));
|
||||
}
|
||||
var methodAccess = Optional.ofNullable(methodAccessCache.get(type)).orElse(MethodAccess.get(type));
|
||||
methodAccessCache.putIfAbsent(type, methodAccess);
|
||||
public <T> Map<String, FieldMeta> cacheType(Class<T> type) {
|
||||
if (fieldMetaCache.containsKey(type)) {
|
||||
return fieldMetaCache.get(type);
|
||||
}
|
||||
if (!constructorCache.containsKey(type)) {
|
||||
constructorCache.putIfAbsent(type, ConstructorAccess.get(type));
|
||||
}
|
||||
var methodAccess = Optional.ofNullable(methodAccessCache.get(type)).orElse(MethodAccess.get(type));
|
||||
methodAccessCache.putIfAbsent(type, methodAccess);
|
||||
|
||||
var fieldMetaMap = new HashMap<String, FieldMeta>();
|
||||
var methodNameSet = new HashSet<>(Arrays.stream(methodAccess.getMethodNames()).toList());
|
||||
var fieldMetaMap = new HashMap<String, FieldMeta>();
|
||||
var methodNameSet = new HashSet<>(Arrays.stream(methodAccess.getMethodNames()).toList());
|
||||
|
||||
Arrays.stream(type.getDeclaredFields())
|
||||
.filter(field -> methodNameSet.contains(getSetterName(field.getName())))
|
||||
.forEach(field -> {
|
||||
var setter = getSetterName(field.getName());
|
||||
var index = methodAccess.getIndex(setter);
|
||||
fieldMetaMap.put(field.getName(), new FieldMeta(field.getName(), setter, index, field.getType()));
|
||||
});
|
||||
Arrays.stream(type.getDeclaredFields())
|
||||
.filter(field -> methodNameSet.contains(getSetterName(field.getName())))
|
||||
.forEach(field -> {
|
||||
var setter = getSetterName(field.getName());
|
||||
var index = methodAccess.getIndex(setter);
|
||||
fieldMetaMap.put(field.getName(), new FieldMeta(field.getName(), setter, index, field.getType()));
|
||||
});
|
||||
|
||||
Arrays.stream(type.getFields())
|
||||
.filter(field -> !fieldMetaMap.containsKey(field.getName()))
|
||||
.filter(field -> methodNameSet.contains(getSetterName(field.getName())))
|
||||
.forEach(field -> {
|
||||
var setter = getSetterName(field.getName());
|
||||
var index = methodAccess.getIndex(setter);
|
||||
fieldMetaMap.put(field.getName(), new FieldMeta(field.getName(), setter, index, field.getType()));
|
||||
});
|
||||
Arrays.stream(type.getFields())
|
||||
.filter(field -> !fieldMetaMap.containsKey(field.getName()))
|
||||
.filter(field -> methodNameSet.contains(getSetterName(field.getName())))
|
||||
.forEach(field -> {
|
||||
var setter = getSetterName(field.getName());
|
||||
var index = methodAccess.getIndex(setter);
|
||||
fieldMetaMap.put(field.getName(), new FieldMeta(field.getName(), setter, index, field.getType()));
|
||||
});
|
||||
|
||||
fieldMetaCache.put(type, fieldMetaMap);
|
||||
return fieldMetaMap;
|
||||
}
|
||||
fieldMetaCache.put(type, fieldMetaMap);
|
||||
return fieldMetaMap;
|
||||
}
|
||||
|
||||
public String getSetterName(String fieldName){
|
||||
if(fieldName == null || fieldName.length() == 0){
|
||||
return null;
|
||||
}
|
||||
if(fieldName.length() == 1){
|
||||
return "set" + fieldName.toUpperCase();
|
||||
}
|
||||
return "set" + Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1);
|
||||
}
|
||||
public String getSetterName(String fieldName) {
|
||||
if (fieldName == null || fieldName.length() == 0) {
|
||||
return null;
|
||||
}
|
||||
if (fieldName.length() == 1) {
|
||||
return "set" + fieldName.toUpperCase();
|
||||
}
|
||||
return "set" + Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1);
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@FieldDefaults(level = AccessLevel.PRIVATE)
|
||||
static class FieldMeta{
|
||||
String name;
|
||||
String setter;
|
||||
int index;
|
||||
Class<?> type;
|
||||
}
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@FieldDefaults(level = AccessLevel.PRIVATE)
|
||||
static class FieldMeta{
|
||||
String name;
|
||||
String setter;
|
||||
int index;
|
||||
Class<?> type;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ import java.util.Map;
|
||||
|
||||
public interface Serializer {
|
||||
|
||||
public <T> List<T> toList(Class<T> type, Object obj);
|
||||
public <T> List<T> toList(Class<T> type, Object obj);
|
||||
|
||||
public <T> T toObject(Class<T> type, Object obj);
|
||||
public <T> T toObject(Class<T> type, Object obj);
|
||||
|
||||
public <T> Map<String,T> toMap(Class<T> type, Object obj);
|
||||
}
|
||||
|
||||
@@ -17,4 +17,4 @@ public final class EntityDeathEvent extends EntityEvent {
|
||||
this.deathLocation = new Location(entity.getScene(), entity.getPosition());
|
||||
this.killer = entity.getScene().getEntityById(killerId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,4 +43,4 @@ public final class PlayerMoveEvent extends PlayerEvent {
|
||||
*/
|
||||
SERVER
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,4 +17,4 @@ public final class PlayerTeamDeathEvent extends PlayerEvent {
|
||||
|
||||
this.selectedAvatar = selectedAvatar;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,4 +60,4 @@ public final class PlayerTeleportEvent extends PlayerEvent implements Cancellabl
|
||||
*/
|
||||
COMMAND
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,4 +21,4 @@ public final class PlayerUseFoodEvent extends PlayerEvent implements Cancellable
|
||||
this.foodUsed = foodUsed;
|
||||
this.selectedAvatar = selectedAvatar;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public final class DispatchHandler implements Router {
|
||||
express.post("/hk4e_global/mdk/shield/api/verify", DispatchHandler::tokenLogin);
|
||||
// Combo token login (from session key).
|
||||
express.post("/hk4e_global/combo/granter/login/v2/login", DispatchHandler::sessionKeyLogin);
|
||||
|
||||
|
||||
// External login (from other clients).
|
||||
express.get("/authentication/type", (request, response) -> response.send(Grasscutter.getAuthenticationSystem().getClass().getSimpleName()));
|
||||
express.post("/authentication/login", (request, response) -> Grasscutter.getAuthenticationSystem().getExternalAuthenticator()
|
||||
@@ -54,18 +54,18 @@ public final class DispatchHandler implements Router {
|
||||
// Parse body data.
|
||||
String rawBodyData = request.ctx().body();
|
||||
var bodyData = JsonUtils.decode(rawBodyData, LoginAccountRequestJson.class);
|
||||
|
||||
|
||||
// Validate body data.
|
||||
if(bodyData == null)
|
||||
if (bodyData == null)
|
||||
return;
|
||||
|
||||
|
||||
// Pass data to authentication handler.
|
||||
var responseData = Grasscutter.getAuthenticationSystem()
|
||||
.getPasswordAuthenticator()
|
||||
.authenticate(AuthenticationSystem.fromPasswordRequest(request, bodyData));
|
||||
// Send response.
|
||||
response.send(responseData);
|
||||
|
||||
|
||||
// Log to console.
|
||||
Grasscutter.getLogger().info(translate("messages.dispatch.account.login_attempt", request.ip()));
|
||||
}
|
||||
@@ -79,7 +79,7 @@ public final class DispatchHandler implements Router {
|
||||
var bodyData = JsonUtils.decode(rawBodyData, LoginTokenRequestJson.class);
|
||||
|
||||
// Validate body data.
|
||||
if(bodyData == null)
|
||||
if (bodyData == null)
|
||||
return;
|
||||
|
||||
// Pass data to authentication handler.
|
||||
@@ -102,9 +102,9 @@ public final class DispatchHandler implements Router {
|
||||
var bodyData = JsonUtils.decode(rawBodyData, ComboTokenReqJson.class);
|
||||
|
||||
// Validate body data.
|
||||
if(bodyData == null || bodyData.data == null)
|
||||
if (bodyData == null || bodyData.data == null)
|
||||
return;
|
||||
|
||||
|
||||
// Decode additional body data.
|
||||
var tokenData = JsonUtils.decode(bodyData.data, LoginTokenData.class);
|
||||
|
||||
|
||||
@@ -17,18 +17,18 @@ import java.util.stream.Stream;
|
||||
@Opcodes(PacketOpcodes.AddQuestContentProgressReq)
|
||||
public class HandlerAddQuestContentProgressReq extends PacketHandler {
|
||||
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
var req = AddQuestContentProgressReqOuterClass.AddQuestContentProgressReq.parseFrom(payload);
|
||||
//Find all conditions in quest that are the same as the given one
|
||||
Stream<QuestCondition> finishCond = GameData.getQuestDataMap().get(req.getParam()).getFinishCond().stream();
|
||||
Stream<QuestCondition> acceptCond = GameData.getQuestDataMap().get(req.getParam()).getAcceptCond().stream();
|
||||
Stream<QuestCondition> failCond = GameData.getQuestDataMap().get(req.getParam()).getFailCond().stream();
|
||||
List<QuestCondition> allCondMatch = Stream.concat(Stream.concat(acceptCond,failCond),finishCond).filter(p -> p.getType().getValue() == req.getContentType()).toList();
|
||||
for(QuestCondition cond : allCondMatch ) {
|
||||
for (QuestCondition cond : allCondMatch ) {
|
||||
session.getPlayer().getQuestManager().triggerEvent(QuestTrigger.getContentTriggerByValue(req.getContentType()), cond.getParam());
|
||||
}
|
||||
session.send(new PacketAddQuestContentProgressRsp(req.getContentType()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,22 +12,22 @@ import emu.grasscutter.utils.Utils;
|
||||
@Opcodes(PacketOpcodes.ClientAbilityInitFinishNotify)
|
||||
public class HandlerClientAbilityInitFinishNotify extends PacketHandler {
|
||||
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
ClientAbilityInitFinishNotify notif = ClientAbilityInitFinishNotify.parseFrom(payload);
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
ClientAbilityInitFinishNotify notif = ClientAbilityInitFinishNotify.parseFrom(payload);
|
||||
|
||||
Player player = session.getPlayer();
|
||||
Player player = session.getPlayer();
|
||||
|
||||
// Call skill end in the player's ability manager.
|
||||
player.getAbilityManager().onSkillEnd(player);
|
||||
|
||||
for (AbilityInvokeEntry entry : notif.getInvokesList()) {
|
||||
player.getAbilityManager().onAbilityInvoke(entry);
|
||||
player.getClientAbilityInitFinishHandler().addEntry(entry.getForwardType(), entry);
|
||||
}
|
||||
for (AbilityInvokeEntry entry : notif.getInvokesList()) {
|
||||
player.getAbilityManager().onAbilityInvoke(entry);
|
||||
player.getClientAbilityInitFinishHandler().addEntry(entry.getForwardType(), entry);
|
||||
}
|
||||
|
||||
if (notif.getInvokesList().size() > 0) {
|
||||
session.getPlayer().getClientAbilityInitFinishHandler().update(session.getPlayer());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (notif.getInvokesList().size() > 0) {
|
||||
session.getPlayer().getClientAbilityInitFinishHandler().update(session.getPlayer());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,15 +24,15 @@ import emu.grasscutter.utils.Position;
|
||||
@Opcodes(PacketOpcodes.CombatInvocationsNotify)
|
||||
public class HandlerCombatInvocationsNotify extends PacketHandler {
|
||||
|
||||
private float cachedLandingSpeed = 0;
|
||||
private long cachedLandingTimeMillisecond = 0;
|
||||
private boolean monitorLandingEvent = false;
|
||||
private float cachedLandingSpeed = 0;
|
||||
private long cachedLandingTimeMillisecond = 0;
|
||||
private boolean monitorLandingEvent = false;
|
||||
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
CombatInvocationsNotify notif = CombatInvocationsNotify.parseFrom(payload);
|
||||
for (CombatInvokeEntry entry : notif.getInvokeListList()) {
|
||||
// Handle combat invoke
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
CombatInvocationsNotify notif = CombatInvocationsNotify.parseFrom(payload);
|
||||
for (CombatInvokeEntry entry : notif.getInvokeListList()) {
|
||||
// Handle combat invoke
|
||||
switch (entry.getArgumentType()) {
|
||||
case COMBAT_TYPE_ARGUMENT_EVT_BEING_HIT -> {
|
||||
EvtBeingHitInfo hitInfo = EvtBeingHitInfo.parseFrom(entry.getCombatData());
|
||||
@@ -106,55 +106,55 @@ public class HandlerCombatInvocationsNotify extends PacketHandler {
|
||||
}
|
||||
}
|
||||
|
||||
session.getPlayer().getCombatInvokeHandler().addEntry(entry.getForwardType(), entry);
|
||||
}
|
||||
}
|
||||
session.getPlayer().getCombatInvokeHandler().addEntry(entry.getForwardType(), entry);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleFallOnGround(GameSession session, GameEntity entity, MotionState motionState) {
|
||||
if (session.getPlayer().inGodmode()) {
|
||||
return;
|
||||
}
|
||||
// People have reported that after plunge attack (client sends a FIGHT instead of FALL_ON_GROUND) they will die
|
||||
// if they talk to an NPC (this is when the client sends a FALL_ON_GROUND) without jumping again.
|
||||
// A dirty patch: if not received immediately after MOTION_LAND_SPEED, discard this packet.
|
||||
// 200ms seems to be a reasonable delay.
|
||||
int maxDelay = 200;
|
||||
long actualDelay = System.currentTimeMillis() - cachedLandingTimeMillisecond;
|
||||
Grasscutter.getLogger().trace("MOTION_FALL_ON_GROUND received after " + actualDelay + "/" + maxDelay + "ms." + (actualDelay > maxDelay ? " Discard" : ""));
|
||||
if (actualDelay > maxDelay) {
|
||||
return;
|
||||
}
|
||||
float currentHP = entity.getFightProperty(FightProperty.FIGHT_PROP_CUR_HP);
|
||||
float maxHP = entity.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP);
|
||||
float damageFactor = 0;
|
||||
if (cachedLandingSpeed < -23.5) {
|
||||
damageFactor = 0.33f;
|
||||
}
|
||||
if (cachedLandingSpeed < -25) {
|
||||
damageFactor = 0.5f;
|
||||
}
|
||||
if (cachedLandingSpeed < -26.5) {
|
||||
damageFactor = 0.66f;
|
||||
}
|
||||
if (cachedLandingSpeed < -28) {
|
||||
damageFactor = 1f;
|
||||
}
|
||||
float damage = maxHP * damageFactor;
|
||||
float newHP = currentHP - damage;
|
||||
if (newHP < 0) {
|
||||
newHP = 0;
|
||||
}
|
||||
if (damageFactor > 0) {
|
||||
Grasscutter.getLogger().debug(currentHP + "/" + maxHP + "\tLandingSpeed: " + cachedLandingSpeed +
|
||||
"\tDamageFactor: " + damageFactor + "\tDamage: " + damage + "\tNewHP: " + newHP);
|
||||
} else {
|
||||
Grasscutter.getLogger().trace(currentHP + "/" + maxHP + "\tLandingSpeed: 0\tNo damage");
|
||||
}
|
||||
entity.setFightProperty(FightProperty.FIGHT_PROP_CUR_HP, newHP);
|
||||
entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_CUR_HP));
|
||||
if (newHP == 0) {
|
||||
session.getPlayer().getStaminaManager().killAvatar(session, entity, PlayerDieTypeOuterClass.PlayerDieType.PLAYER_DIE_TYPE_FALL);
|
||||
}
|
||||
cachedLandingSpeed = 0;
|
||||
}
|
||||
private void handleFallOnGround(GameSession session, GameEntity entity, MotionState motionState) {
|
||||
if (session.getPlayer().inGodmode()) {
|
||||
return;
|
||||
}
|
||||
// People have reported that after plunge attack (client sends a FIGHT instead of FALL_ON_GROUND) they will die
|
||||
// if they talk to an NPC (this is when the client sends a FALL_ON_GROUND) without jumping again.
|
||||
// A dirty patch: if not received immediately after MOTION_LAND_SPEED, discard this packet.
|
||||
// 200ms seems to be a reasonable delay.
|
||||
int maxDelay = 200;
|
||||
long actualDelay = System.currentTimeMillis() - cachedLandingTimeMillisecond;
|
||||
Grasscutter.getLogger().trace("MOTION_FALL_ON_GROUND received after " + actualDelay + "/" + maxDelay + "ms." + (actualDelay > maxDelay ? " Discard" : ""));
|
||||
if (actualDelay > maxDelay) {
|
||||
return;
|
||||
}
|
||||
float currentHP = entity.getFightProperty(FightProperty.FIGHT_PROP_CUR_HP);
|
||||
float maxHP = entity.getFightProperty(FightProperty.FIGHT_PROP_MAX_HP);
|
||||
float damageFactor = 0;
|
||||
if (cachedLandingSpeed < -23.5) {
|
||||
damageFactor = 0.33f;
|
||||
}
|
||||
if (cachedLandingSpeed < -25) {
|
||||
damageFactor = 0.5f;
|
||||
}
|
||||
if (cachedLandingSpeed < -26.5) {
|
||||
damageFactor = 0.66f;
|
||||
}
|
||||
if (cachedLandingSpeed < -28) {
|
||||
damageFactor = 1f;
|
||||
}
|
||||
float damage = maxHP * damageFactor;
|
||||
float newHP = currentHP - damage;
|
||||
if (newHP < 0) {
|
||||
newHP = 0;
|
||||
}
|
||||
if (damageFactor > 0) {
|
||||
Grasscutter.getLogger().debug(currentHP + "/" + maxHP + "\tLandingSpeed: " + cachedLandingSpeed +
|
||||
"\tDamageFactor: " + damageFactor + "\tDamage: " + damage + "\tNewHP: " + newHP);
|
||||
} else {
|
||||
Grasscutter.getLogger().trace(currentHP + "/" + maxHP + "\tLandingSpeed: 0\tNo damage");
|
||||
}
|
||||
entity.setFightProperty(FightProperty.FIGHT_PROP_CUR_HP, newHP);
|
||||
entity.getWorld().broadcastPacket(new PacketEntityFightPropUpdateNotify(entity, FightProperty.FIGHT_PROP_CUR_HP));
|
||||
if (newHP == 0) {
|
||||
session.getPlayer().getStaminaManager().killAvatar(session, entity, PlayerDieTypeOuterClass.PlayerDieType.PLAYER_DIE_TYPE_FALL);
|
||||
}
|
||||
cachedLandingSpeed = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,25 +12,25 @@ import emu.grasscutter.server.packet.send.*;
|
||||
@Opcodes(PacketOpcodes.EnterSceneDoneReq)
|
||||
public class HandlerEnterSceneDoneReq extends PacketHandler {
|
||||
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
// Finished loading
|
||||
session.getPlayer().setSceneLoadState(SceneLoadState.LOADED);
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
// Finished loading
|
||||
session.getPlayer().setSceneLoadState(SceneLoadState.LOADED);
|
||||
|
||||
// Done
|
||||
// Done
|
||||
|
||||
session.send(new PacketPlayerTimeNotify(session.getPlayer())); // Probably not the right place
|
||||
session.send(new PacketPlayerTimeNotify(session.getPlayer())); // Probably not the right place
|
||||
|
||||
// Spawn player in world
|
||||
session.getPlayer().getScene().spawnPlayer(session.getPlayer());
|
||||
// Spawn player in world
|
||||
session.getPlayer().getScene().spawnPlayer(session.getPlayer());
|
||||
|
||||
// Spawn other entites already in world
|
||||
session.getPlayer().getScene().showOtherEntities(session.getPlayer());
|
||||
// Spawn other entites already in world
|
||||
session.getPlayer().getScene().showOtherEntities(session.getPlayer());
|
||||
|
||||
// Locations
|
||||
session.send(new PacketWorldPlayerLocationNotify(session.getPlayer().getWorld()));
|
||||
session.send(new PacketScenePlayerLocationNotify(session.getPlayer().getScene()));
|
||||
session.send(new PacketWorldPlayerRTTNotify(session.getPlayer().getWorld()));
|
||||
// Locations
|
||||
session.send(new PacketWorldPlayerLocationNotify(session.getPlayer().getWorld()));
|
||||
session.send(new PacketScenePlayerLocationNotify(session.getPlayer().getScene()));
|
||||
session.send(new PacketWorldPlayerRTTNotify(session.getPlayer().getWorld()));
|
||||
|
||||
// spawn NPC
|
||||
session.getPlayer().getScene().loadNpcForPlayerEnter(session.getPlayer());
|
||||
@@ -42,10 +42,10 @@ public class HandlerEnterSceneDoneReq extends PacketHandler {
|
||||
Grasscutter.getLogger().debug("Loaded Scene {} Quest(s) Groupsuite(s): {}", session.getPlayer().getSceneId(), questGroupSuites);
|
||||
session.send(new PacketGroupSuiteNotify(questGroupSuites));
|
||||
|
||||
// Reset timer for sending player locations
|
||||
session.getPlayer().resetSendPlayerLocTime();
|
||||
// Reset timer for sending player locations
|
||||
session.getPlayer().resetSendPlayerLocTime();
|
||||
//Rsp
|
||||
session.send(new PacketEnterSceneDoneRsp(session.getPlayer()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,4 +24,4 @@ public class HandlerEvtDoSkillSuccNotify extends PacketHandler {
|
||||
player.getStaminaManager().handleEvtDoSkillSuccNotify(session, skillId, casterId);
|
||||
player.getEnergyManager().handleEvtDoSkillSuccNotify(session, skillId, casterId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,12 +9,12 @@ import emu.grasscutter.server.packet.send.PacketGetSceneAreaRsp;
|
||||
|
||||
@Opcodes(PacketOpcodes.GetSceneAreaReq)
|
||||
public class HandlerGetSceneAreaReq extends PacketHandler {
|
||||
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
GetSceneAreaReq req = GetSceneAreaReq.parseFrom(payload);
|
||||
|
||||
session.send(new PacketGetSceneAreaRsp(session.getPlayer(), req.getSceneId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
GetSceneAreaReq req = GetSceneAreaReq.parseFrom(payload);
|
||||
|
||||
session.send(new PacketGetSceneAreaRsp(session.getPlayer(), req.getSceneId()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,12 +9,12 @@ import emu.grasscutter.server.packet.send.PacketGetScenePointRsp;
|
||||
|
||||
@Opcodes(PacketOpcodes.GetScenePointReq)
|
||||
public class HandlerGetScenePointReq extends PacketHandler {
|
||||
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
GetScenePointReq req = GetScenePointReq.parseFrom(payload);
|
||||
|
||||
session.send(new PacketGetScenePointRsp(session.getPlayer(), req.getSceneId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
GetScenePointReq req = GetScenePointReq.parseFrom(payload);
|
||||
|
||||
session.send(new PacketGetScenePointRsp(session.getPlayer(), req.getSceneId()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class HandlerNpcTalkReq extends PacketHandler {
|
||||
int mainQuestId = talkId/100;
|
||||
MainQuestData mainQuestData = GameData.getMainQuestDataMap().get(mainQuestId);
|
||||
|
||||
if(mainQuestData != null) {
|
||||
if (mainQuestData != null) {
|
||||
// This talk is associated with a quest. Handle it.
|
||||
// If the quest has no talk data defined on it, create one.
|
||||
TalkData talkForQuest = new TalkData(talkId, "");
|
||||
@@ -37,13 +37,13 @@ public class HandlerNpcTalkReq extends PacketHandler {
|
||||
talkForQuest = talks.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Add to the list of done talks for this quest.
|
||||
var mainQuest = session.getPlayer().getQuestManager().getMainQuestById(mainQuestId);
|
||||
if (mainQuest != null) {
|
||||
session.getPlayer().getQuestManager().getMainQuestById(mainQuestId).getTalks().put(talkId, talkForQuest);
|
||||
}
|
||||
|
||||
|
||||
// Fire quest triggers.
|
||||
session.getPlayer().getQuestManager().triggerEvent(QuestTrigger.QUEST_CONTENT_COMPLETE_ANY_TALK, String.valueOf(req.getTalkId()), 0, 0);
|
||||
session.getPlayer().getQuestManager().triggerEvent(QuestTrigger.QUEST_CONTENT_COMPLETE_TALK, req.getTalkId(), 0);
|
||||
@@ -52,4 +52,4 @@ public class HandlerNpcTalkReq extends PacketHandler {
|
||||
|
||||
session.send(new PacketNpcTalkRsp(req.getNpcEntityId(), req.getTalkId(), req.getEntityId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,9 @@ import emu.grasscutter.server.packet.send.PacketPersonalLineAllDataRsp;
|
||||
@Opcodes(PacketOpcodes.PersonalLineAllDataReq)
|
||||
public class HandlerPersonalLineAllDataReq extends PacketHandler {
|
||||
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
session.send(new PacketPersonalLineAllDataRsp(session.getPlayer().getQuestManager().getMainQuests().values()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,19 +10,19 @@ import emu.grasscutter.server.packet.send.PacketPlayerChatRsp;
|
||||
|
||||
@Opcodes(PacketOpcodes.PlayerChatReq)
|
||||
public class HandlerPlayerChatReq extends PacketHandler {
|
||||
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
PlayerChatReq req = PlayerChatReq.parseFrom(payload);
|
||||
ChatInfo.ContentCase content = req.getChatInfo().getContentCase();
|
||||
|
||||
if (content == ChatInfo.ContentCase.TEXT) {
|
||||
session.getServer().getChatSystem().sendTeamMessage(session.getPlayer(), req.getChannelId(), req.getChatInfo().getText());
|
||||
} else if (content == ChatInfo.ContentCase.ICON) {
|
||||
session.getServer().getChatSystem().sendTeamMessage(session.getPlayer(), req.getChannelId(), req.getChatInfo().getIcon());
|
||||
}
|
||||
|
||||
session.send(new PacketPlayerChatRsp());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
PlayerChatReq req = PlayerChatReq.parseFrom(payload);
|
||||
ChatInfo.ContentCase content = req.getChatInfo().getContentCase();
|
||||
|
||||
if (content == ChatInfo.ContentCase.TEXT) {
|
||||
session.getServer().getChatSystem().sendTeamMessage(session.getPlayer(), req.getChannelId(), req.getChatInfo().getText());
|
||||
} else if (content == ChatInfo.ContentCase.ICON) {
|
||||
session.getServer().getChatSystem().sendTeamMessage(session.getPlayer(), req.getChannelId(), req.getChatInfo().getIcon());
|
||||
}
|
||||
|
||||
session.send(new PacketPlayerChatRsp());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,13 +11,13 @@ import emu.grasscutter.server.packet.send.PacketPostEnterSceneRsp;
|
||||
@Opcodes(PacketOpcodes.PostEnterSceneReq)
|
||||
public class HandlerPostEnterSceneReq extends PacketHandler {
|
||||
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
if(session.getPlayer().getScene().getSceneType() == SceneType.SCENE_ROOM){
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
if (session.getPlayer().getScene().getSceneType() == SceneType.SCENE_ROOM) {
|
||||
session.getPlayer().getQuestManager().triggerEvent(QuestTrigger.QUEST_CONTENT_ENTER_ROOM, session.getPlayer().getSceneId(),0);
|
||||
}
|
||||
|
||||
session.send(new PacketPostEnterSceneRsp(session.getPlayer()));
|
||||
}
|
||||
session.send(new PacketPostEnterSceneRsp(session.getPlayer()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,17 +8,17 @@ import emu.grasscutter.server.game.GameSession;
|
||||
|
||||
@Opcodes(PacketOpcodes.PrivateChatReq)
|
||||
public class HandlerPrivateChatReq extends PacketHandler {
|
||||
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
PrivateChatReq req = PrivateChatReq.parseFrom(payload);
|
||||
PrivateChatReq.ContentCase content = req.getContentCase();
|
||||
|
||||
if (content == PrivateChatReq.ContentCase.TEXT) {
|
||||
session.getServer().getChatSystem().sendPrivateMessage(session.getPlayer(), req.getTargetUid(), req.getText());
|
||||
} else if (content == PrivateChatReq.ContentCase.ICON) {
|
||||
session.getServer().getChatSystem().sendPrivateMessage(session.getPlayer(), req.getTargetUid(), req.getIcon());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
PrivateChatReq req = PrivateChatReq.parseFrom(payload);
|
||||
PrivateChatReq.ContentCase content = req.getContentCase();
|
||||
|
||||
if (content == PrivateChatReq.ContentCase.TEXT) {
|
||||
session.getServer().getChatSystem().sendPrivateMessage(session.getPlayer(), req.getTargetUid(), req.getText());
|
||||
} else if (content == PrivateChatReq.ContentCase.ICON) {
|
||||
session.getServer().getChatSystem().sendPrivateMessage(session.getPlayer(), req.getTargetUid(), req.getIcon());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,24 +14,24 @@ import emu.grasscutter.utils.Position;
|
||||
@Opcodes(PacketOpcodes.SceneTransToPointReq)
|
||||
public class HandlerSceneTransToPointReq extends PacketHandler {
|
||||
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
SceneTransToPointReq req = SceneTransToPointReq.parseFrom(payload);
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
SceneTransToPointReq req = SceneTransToPointReq.parseFrom(payload);
|
||||
|
||||
String code = req.getSceneId() + "_" + req.getPointId();
|
||||
ScenePointEntry scenePointEntry = GameData.getScenePointEntries().get(code);
|
||||
String code = req.getSceneId() + "_" + req.getPointId();
|
||||
ScenePointEntry scenePointEntry = GameData.getScenePointEntries().get(code);
|
||||
|
||||
if (scenePointEntry != null) {
|
||||
float x = scenePointEntry.getPointData().getTranPos().getX();
|
||||
float y = scenePointEntry.getPointData().getTranPos().getY();
|
||||
float z = scenePointEntry.getPointData().getTranPos().getZ();
|
||||
if (scenePointEntry != null) {
|
||||
float x = scenePointEntry.getPointData().getTranPos().getX();
|
||||
float y = scenePointEntry.getPointData().getTranPos().getY();
|
||||
float z = scenePointEntry.getPointData().getTranPos().getZ();
|
||||
|
||||
if (session.getPlayer().getWorld().transferPlayerToScene(session.getPlayer(), req.getSceneId(), TeleportType.WAYPOINT, new Position(x, y, z))) {
|
||||
session.send(new PacketSceneTransToPointRsp(session.getPlayer(), req.getPointId(), req.getSceneId()));
|
||||
}
|
||||
} else {
|
||||
session.send(new PacketSceneTransToPointRsp());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
session.send(new PacketSceneTransToPointRsp());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,25 +14,25 @@ import emu.grasscutter.server.packet.send.PacketSelectWorktopOptionRsp;
|
||||
@Opcodes(PacketOpcodes.SelectWorktopOptionReq)
|
||||
public class HandlerSelectWorktopOptionReq extends PacketHandler {
|
||||
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
SelectWorktopOptionReq req = SelectWorktopOptionReq.parseFrom(payload);
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
SelectWorktopOptionReq req = SelectWorktopOptionReq.parseFrom(payload);
|
||||
|
||||
try {
|
||||
GameEntity entity = session.getPlayer().getScene().getEntityById(req.getGadgetEntityId());
|
||||
try {
|
||||
GameEntity entity = session.getPlayer().getScene().getEntityById(req.getGadgetEntityId());
|
||||
|
||||
if (!(entity instanceof EntityGadget)) {
|
||||
return;
|
||||
}
|
||||
if (!(entity instanceof EntityGadget)) {
|
||||
return;
|
||||
}
|
||||
session.getPlayer().getScene().selectWorktopOptionWith(req);
|
||||
session.getPlayer().getScene().getScriptManager().callEvent(
|
||||
EventType.EVENT_SELECT_OPTION,
|
||||
new ScriptArgs(entity.getConfigId(), req.getOptionId())
|
||||
);
|
||||
} finally {
|
||||
// Always send packet
|
||||
session.send(new PacketSelectWorktopOptionRsp(req.getGadgetEntityId(), req.getOptionId()));
|
||||
}
|
||||
}
|
||||
session.getPlayer().getScene().getScriptManager().callEvent(
|
||||
EventType.EVENT_SELECT_OPTION,
|
||||
new ScriptArgs(entity.getConfigId(), req.getOptionId())
|
||||
);
|
||||
} finally {
|
||||
// Always send packet
|
||||
session.send(new PacketSelectWorktopOptionRsp(req.getGadgetEntityId(), req.getOptionId()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,40 +11,40 @@ import emu.grasscutter.net.proto.AvatarDataNotifyOuterClass.AvatarDataNotify;
|
||||
import emu.grasscutter.net.proto.AvatarTeamOuterClass.AvatarTeam;
|
||||
|
||||
public class PacketAvatarDataNotify extends BasePacket {
|
||||
|
||||
public PacketAvatarDataNotify(Player player) {
|
||||
super(PacketOpcodes.AvatarDataNotify, true);
|
||||
|
||||
AvatarDataNotify.Builder proto = AvatarDataNotify.newBuilder()
|
||||
.setCurAvatarTeamId(player.getTeamManager().getCurrentTeamId())
|
||||
//.setChooseAvatarGuid(player.getTeamManager().getCurrentCharacterGuid())
|
||||
.addAllOwnedFlycloakList(player.getFlyCloakList())
|
||||
.addAllOwnedCostumeList(player.getCostumeList());
|
||||
|
||||
for (Avatar avatar : player.getAvatars()) {
|
||||
proto.addAvatarList(avatar.toProto());
|
||||
}
|
||||
|
||||
for (Entry<Integer, TeamInfo> entry : player.getTeamManager().getTeams().entrySet()) {
|
||||
TeamInfo teamInfo = entry.getValue();
|
||||
AvatarTeam.Builder avatarTeam = AvatarTeam.newBuilder()
|
||||
.setTeamName(teamInfo.getName());
|
||||
|
||||
for (int i = 0; i < teamInfo.getAvatars().size(); i++) {
|
||||
Avatar avatar = player.getAvatars().getAvatarById(teamInfo.getAvatars().get(i));
|
||||
avatarTeam.addAvatarGuidList(avatar.getGuid());
|
||||
}
|
||||
|
||||
proto.putAvatarTeamMap(entry.getKey(), avatarTeam.build());
|
||||
}
|
||||
|
||||
// Set main character
|
||||
Avatar mainCharacter = player.getAvatars().getAvatarById(player.getMainCharacterId());
|
||||
if (mainCharacter != null) {
|
||||
proto.setChooseAvatarGuid(mainCharacter.getGuid());
|
||||
}
|
||||
|
||||
this.setData(proto.build());
|
||||
}
|
||||
|
||||
public PacketAvatarDataNotify(Player player) {
|
||||
super(PacketOpcodes.AvatarDataNotify, true);
|
||||
|
||||
AvatarDataNotify.Builder proto = AvatarDataNotify.newBuilder()
|
||||
.setCurAvatarTeamId(player.getTeamManager().getCurrentTeamId())
|
||||
//.setChooseAvatarGuid(player.getTeamManager().getCurrentCharacterGuid())
|
||||
.addAllOwnedFlycloakList(player.getFlyCloakList())
|
||||
.addAllOwnedCostumeList(player.getCostumeList());
|
||||
|
||||
for (Avatar avatar : player.getAvatars()) {
|
||||
proto.addAvatarList(avatar.toProto());
|
||||
}
|
||||
|
||||
for (Entry<Integer, TeamInfo> entry : player.getTeamManager().getTeams().entrySet()) {
|
||||
TeamInfo teamInfo = entry.getValue();
|
||||
AvatarTeam.Builder avatarTeam = AvatarTeam.newBuilder()
|
||||
.setTeamName(teamInfo.getName());
|
||||
|
||||
for (int i = 0; i < teamInfo.getAvatars().size(); i++) {
|
||||
Avatar avatar = player.getAvatars().getAvatarById(teamInfo.getAvatars().get(i));
|
||||
avatarTeam.addAvatarGuidList(avatar.getGuid());
|
||||
}
|
||||
|
||||
proto.putAvatarTeamMap(entry.getKey(), avatarTeam.build());
|
||||
}
|
||||
|
||||
// Set main character
|
||||
Avatar mainCharacter = player.getAvatars().getAvatarById(player.getMainCharacterId());
|
||||
if (mainCharacter != null) {
|
||||
proto.setChooseAvatarGuid(mainCharacter.getGuid());
|
||||
}
|
||||
|
||||
this.setData(proto.build());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,4 +16,4 @@ public class PacketAvatarExpeditionCallBackRsp extends BasePacket {
|
||||
|
||||
this.setData(proto.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,4 +10,4 @@ public class PacketBlossomBriefInfoNotify extends BasePacket {
|
||||
super(PacketOpcodes.BlossomBriefInfoNotify);
|
||||
this.setData(BlossomBriefInfoNotifyOuterClass.BlossomBriefInfoNotify.newBuilder().addAllBriefInfoList(blossoms));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,18 +9,18 @@ import emu.grasscutter.net.proto.FinishedParentQuestNotifyOuterClass.FinishedPar
|
||||
|
||||
public class PacketFinishedParentQuestNotify extends BasePacket {
|
||||
|
||||
public PacketFinishedParentQuestNotify(Player player) {
|
||||
super(PacketOpcodes.FinishedParentQuestNotify, true);
|
||||
public PacketFinishedParentQuestNotify(Player player) {
|
||||
super(PacketOpcodes.FinishedParentQuestNotify, true);
|
||||
|
||||
FinishedParentQuestNotify.Builder proto = FinishedParentQuestNotify.newBuilder();
|
||||
FinishedParentQuestNotify.Builder proto = FinishedParentQuestNotify.newBuilder();
|
||||
|
||||
for (GameMainQuest mainQuest : player.getQuestManager().getMainQuests().values()) {
|
||||
for (GameMainQuest mainQuest : player.getQuestManager().getMainQuests().values()) {
|
||||
//Canceled Quests do not appear in this packet
|
||||
if(mainQuest.getState() != ParentQuestState.PARENT_QUEST_STATE_CANCELED) {
|
||||
if (mainQuest.getState() != ParentQuestState.PARENT_QUEST_STATE_CANCELED) {
|
||||
proto.addParentQuestList(mainQuest.toProto());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.setData(proto);
|
||||
}
|
||||
this.setData(proto);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,22 +9,22 @@ import java.util.List;
|
||||
|
||||
public class PacketFinishedParentQuestUpdateNotify extends BasePacket {
|
||||
|
||||
public PacketFinishedParentQuestUpdateNotify(GameMainQuest quest) {
|
||||
super(PacketOpcodes.FinishedParentQuestUpdateNotify);
|
||||
public PacketFinishedParentQuestUpdateNotify(GameMainQuest quest) {
|
||||
super(PacketOpcodes.FinishedParentQuestUpdateNotify);
|
||||
|
||||
FinishedParentQuestUpdateNotify proto = FinishedParentQuestUpdateNotify.newBuilder()
|
||||
.addParentQuestList(quest.toProto())
|
||||
.build();
|
||||
FinishedParentQuestUpdateNotify proto = FinishedParentQuestUpdateNotify.newBuilder()
|
||||
.addParentQuestList(quest.toProto())
|
||||
.build();
|
||||
|
||||
this.setData(proto);
|
||||
}
|
||||
this.setData(proto);
|
||||
}
|
||||
|
||||
public PacketFinishedParentQuestUpdateNotify(List<GameMainQuest> quests) {
|
||||
super(PacketOpcodes.FinishedParentQuestUpdateNotify);
|
||||
|
||||
var proto = FinishedParentQuestUpdateNotify.newBuilder();
|
||||
|
||||
for(GameMainQuest mainQuest : quests) {
|
||||
for (GameMainQuest mainQuest : quests) {
|
||||
proto.addParentQuestList(mainQuest.toProto());
|
||||
}
|
||||
proto.build();
|
||||
|
||||
@@ -7,25 +7,25 @@ import emu.grasscutter.net.packet.PacketOpcodes;
|
||||
import emu.grasscutter.net.proto.GetScenePointRspOuterClass.GetScenePointRsp;
|
||||
|
||||
public class PacketGetScenePointRsp extends BasePacket {
|
||||
|
||||
public PacketGetScenePointRsp(Player player, int sceneId) {
|
||||
super(PacketOpcodes.GetScenePointRsp);
|
||||
|
||||
GetScenePointRsp.Builder p = GetScenePointRsp.newBuilder()
|
||||
.setSceneId(sceneId);
|
||||
|
||||
if (GameData.getScenePointIdList().size() == 0) {
|
||||
for (int i = 1; i < 1000; i++) {
|
||||
p.addUnlockedPointList(i);
|
||||
}
|
||||
} else {
|
||||
p.addAllUnlockedPointList(player.getUnlockedScenePoints(sceneId));
|
||||
}
|
||||
|
||||
for (int i = 1; i < 9; i++) {
|
||||
p.addUnlockAreaList(i);
|
||||
}
|
||||
public PacketGetScenePointRsp(Player player, int sceneId) {
|
||||
super(PacketOpcodes.GetScenePointRsp);
|
||||
|
||||
this.setData(p);
|
||||
}
|
||||
GetScenePointRsp.Builder p = GetScenePointRsp.newBuilder()
|
||||
.setSceneId(sceneId);
|
||||
|
||||
if (GameData.getScenePointIdList().size() == 0) {
|
||||
for (int i = 1; i < 1000; i++) {
|
||||
p.addUnlockedPointList(i);
|
||||
}
|
||||
} else {
|
||||
p.addAllUnlockedPointList(player.getUnlockedScenePoints(sceneId));
|
||||
}
|
||||
|
||||
for (int i = 1; i < 9; i++) {
|
||||
p.addUnlockAreaList(i);
|
||||
}
|
||||
|
||||
this.setData(p);
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user