Renamed all references to a certain game

This commit is contained in:
Melledy 2022-04-26 21:21:57 -07:00
parent 6b8902bee2
commit 1c36f0785b
270 changed files with 1328 additions and 1347 deletions

View File

@ -5,7 +5,7 @@ import java.util.Arrays;
import emu.grasscutter.utils.Position; import emu.grasscutter.utils.Position;
import emu.grasscutter.utils.Utils; import emu.grasscutter.utils.Utils;
public final class GenshinConstants { public final class GameConstants {
public static String VERSION = "2.6.0"; public static String VERSION = "2.6.0";
public static final int MAX_TEAMS = 4; public static final int MAX_TEAMS = 4;

View File

@ -1,7 +1,7 @@
package emu.grasscutter.command; package emu.grasscutter.command;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import java.util.List; import java.util.List;
@ -12,7 +12,7 @@ public interface CommandHandler {
* @param player The player to send the message to, or null for the server console. * @param player The player to send the message to, or null for the server console.
* @param message The message to send. * @param message The message to send.
*/ */
static void sendMessage(GenshinPlayer player, String message) { static void sendMessage(Player player, String message) {
if (player == null) { if (player == null) {
Grasscutter.getLogger().info(message); Grasscutter.getLogger().info(message);
} else { } else {
@ -25,6 +25,6 @@ public interface CommandHandler {
* @param sender The player/console that invoked the command. * @param sender The player/console that invoked the command.
* @param args The arguments to the command. * @param args The arguments to the command.
*/ */
default void execute(GenshinPlayer sender, List<String> args) { default void execute(Player sender, List<String> args) {
} }
} }

View File

@ -2,7 +2,7 @@ package emu.grasscutter.command;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
import emu.grasscutter.game.Account; import emu.grasscutter.game.Account;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import org.reflections.Reflections; import org.reflections.Reflections;
import java.util.*; import java.util.*;
@ -103,7 +103,7 @@ public final class CommandMap {
* @param player The player invoking the command or null for the server console. * @param player The player invoking the command or null for the server console.
* @param rawMessage The messaged used to invoke the command. * @param rawMessage The messaged used to invoke the command.
*/ */
public void invoke(GenshinPlayer player, String rawMessage) { public void invoke(Player player, String rawMessage) {
rawMessage = rawMessage.trim(); rawMessage = rawMessage.trim();
if (rawMessage.length() == 0) { if (rawMessage.length() == 0) {
CommandHandler.sendMessage(player, "No command specified."); CommandHandler.sendMessage(player, "No command specified.");

View File

@ -3,7 +3,7 @@ package emu.grasscutter.command.commands;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.database.DatabaseHelper; import emu.grasscutter.database.DatabaseHelper;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import java.util.List; import java.util.List;
@ -12,7 +12,7 @@ import java.util.List;
public final class AccountCommand implements CommandHandler { public final class AccountCommand implements CommandHandler {
@Override @Override
public void execute(GenshinPlayer sender, List<String> args) { public void execute(Player sender, List<String> args) {
if (sender != null) { if (sender != null) {
CommandHandler.sendMessage(sender, "This command can only be run from the console."); CommandHandler.sendMessage(sender, "This command can only be run from the console.");
return; return;

View File

@ -3,7 +3,7 @@ package emu.grasscutter.command.commands;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import java.util.List; import java.util.List;
@ -12,7 +12,7 @@ import java.util.List;
public final class BroadcastCommand implements CommandHandler { public final class BroadcastCommand implements CommandHandler {
@Override @Override
public void execute(GenshinPlayer sender, List<String> args) { public void execute(Player sender, List<String> args) {
if (args.size() < 1) { if (args.size() < 1) {
CommandHandler.sendMessage(sender, "Usage: broadcast <message>"); CommandHandler.sendMessage(sender, "Usage: broadcast <message>");
return; return;
@ -20,7 +20,7 @@ public final class BroadcastCommand implements CommandHandler {
String message = String.join(" ", args.subList(0, args.size())); String message = String.join(" ", args.subList(0, args.size()));
for (GenshinPlayer p : Grasscutter.getGameServer().getPlayers().values()) { for (Player p : Grasscutter.getGameServer().getPlayers().values()) {
CommandHandler.sendMessage(p, message); CommandHandler.sendMessage(p, message);
} }

View File

@ -2,7 +2,7 @@ package emu.grasscutter.command.commands;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import java.util.List; import java.util.List;
@ -10,7 +10,7 @@ import java.util.List;
description = "Changes your scene", aliases = {"scene"}, permission = "player.changescene") description = "Changes your scene", aliases = {"scene"}, permission = "player.changescene")
public final class ChangeSceneCommand implements CommandHandler { public final class ChangeSceneCommand implements CommandHandler {
@Override @Override
public void execute(GenshinPlayer sender, List<String> args) { public void execute(Player sender, List<String> args) {
if (sender == null) { if (sender == null) {
CommandHandler.sendMessage(null, "Run this command in-game."); CommandHandler.sendMessage(null, "Run this command in-game.");
return; return;

View File

@ -3,7 +3,7 @@ package emu.grasscutter.command.commands;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import emu.grasscutter.game.inventory.Inventory; import emu.grasscutter.game.inventory.Inventory;
import emu.grasscutter.game.inventory.ItemType; import emu.grasscutter.game.inventory.ItemType;
@ -16,7 +16,7 @@ import java.util.List;
public final class ClearCommand implements CommandHandler { public final class ClearCommand implements CommandHandler {
@Override @Override
public void execute(GenshinPlayer sender, List<String> args) { public void execute(Player sender, List<String> args) {
int target; int target;
if (sender == null) { if (sender == null) {
CommandHandler.sendMessage(null, "Run this command in-game."); CommandHandler.sendMessage(null, "Run this command in-game.");
@ -27,7 +27,7 @@ public final class ClearCommand implements CommandHandler {
Inventory playerInventory = sender.getInventory(); Inventory playerInventory = sender.getInventory();
try { try {
target = Integer.parseInt(args.get(0)); target = Integer.parseInt(args.get(0));
GenshinPlayer targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target); Player targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target);
if (targetPlayer == null) { if (targetPlayer == null) {
target = sender.getUid(); target = sender.getUid();
} else { } else {
@ -92,7 +92,7 @@ public final class ClearCommand implements CommandHandler {
return; return;
} }
GenshinPlayer targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target); Player targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target);
if (targetPlayer == null) { if (targetPlayer == null) {
CommandHandler.sendMessage(sender, "Player not found."); CommandHandler.sendMessage(sender, "Player not found.");
return; return;

View File

@ -2,9 +2,9 @@ package emu.grasscutter.command.commands;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.data.GenshinData; import emu.grasscutter.data.GameData;
import emu.grasscutter.data.def.ItemData; import emu.grasscutter.data.def.ItemData;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import emu.grasscutter.game.entity.EntityItem; import emu.grasscutter.game.entity.EntityItem;
import emu.grasscutter.utils.Position; import emu.grasscutter.utils.Position;
@ -15,7 +15,7 @@ import java.util.List;
public final class DropCommand implements CommandHandler { public final class DropCommand implements CommandHandler {
@Override @Override
public void execute(GenshinPlayer sender, List<String> args) { public void execute(Player sender, List<String> args) {
if (sender == null) { if (sender == null) {
CommandHandler.sendMessage(null, "Run this command in-game."); CommandHandler.sendMessage(null, "Run this command in-game.");
return; return;
@ -31,7 +31,7 @@ public final class DropCommand implements CommandHandler {
int amount = 1; int amount = 1;
if (args.size() > 1) amount = Integer.parseInt(args.get(1)); if (args.size() > 1) amount = Integer.parseInt(args.get(1));
ItemData itemData = GenshinData.getItemDataMap().get(item); ItemData itemData = GameData.getItemDataMap().get(item);
if (itemData == null) { if (itemData == null) {
CommandHandler.sendMessage(sender, "Invalid item id."); CommandHandler.sendMessage(sender, "Invalid item id.");
return; return;

View File

@ -3,12 +3,12 @@ package emu.grasscutter.command.commands;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.data.GenshinData; import emu.grasscutter.data.GameData;
import emu.grasscutter.data.def.AvatarData; import emu.grasscutter.data.def.AvatarData;
import emu.grasscutter.data.def.ItemData; import emu.grasscutter.data.def.ItemData;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import emu.grasscutter.game.avatar.GenshinAvatar; import emu.grasscutter.game.avatar.Avatar;
import emu.grasscutter.game.inventory.GenshinItem; import emu.grasscutter.game.inventory.GameItem;
import emu.grasscutter.game.inventory.ItemType; import emu.grasscutter.game.inventory.ItemType;
import java.util.*; import java.util.*;
@ -18,7 +18,7 @@ import java.util.*;
public class GiveAllCommand implements CommandHandler { public class GiveAllCommand implements CommandHandler {
@Override @Override
public void execute(GenshinPlayer sender, List<String> args) { public void execute(Player sender, List<String> args) {
int target, amount = 99999; int target, amount = 99999;
switch (args.size()) { switch (args.size()) {
@ -63,7 +63,7 @@ public class GiveAllCommand implements CommandHandler {
return; return;
} }
GenshinPlayer targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target); Player targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target);
if (targetPlayer == null) { if (targetPlayer == null) {
CommandHandler.sendMessage(sender, "Player not found."); CommandHandler.sendMessage(sender, "Player not found.");
return; return;
@ -73,14 +73,14 @@ public class GiveAllCommand implements CommandHandler {
CommandHandler.sendMessage(sender, "Giving all items done"); CommandHandler.sendMessage(sender, "Giving all items done");
} }
public void giveAllItems(GenshinPlayer player, int amount) { public void giveAllItems(Player player, int amount) {
CommandHandler.sendMessage(player, "Giving all items..."); CommandHandler.sendMessage(player, "Giving all items...");
for (AvatarData avatarData: GenshinData.getAvatarDataMap().values()) { for (AvatarData avatarData: GameData.getAvatarDataMap().values()) {
//Exclude test avatar //Exclude test avatar
if (isTestAvatar(avatarData.getId())) continue; if (isTestAvatar(avatarData.getId())) continue;
GenshinAvatar avatar = new GenshinAvatar(avatarData); Avatar avatar = new Avatar(avatarData);
avatar.setLevel(90); avatar.setLevel(90);
avatar.setPromoteLevel(6); avatar.setPromoteLevel(6);
for (int i = 1; i <= 6; ++i) { for (int i = 1; i <= 6; ++i) {
@ -92,41 +92,41 @@ public class GiveAllCommand implements CommandHandler {
} }
//some test items //some test items
List<GenshinItem> genshinItemList = new ArrayList<>(); List<GameItem> itemList = new ArrayList<>();
for (ItemData itemdata: GenshinData.getItemDataMap().values()) { for (ItemData itemdata: GameData.getItemDataMap().values()) {
//Exclude test item //Exclude test item
if (isTestItem(itemdata.getId())) continue; if (isTestItem(itemdata.getId())) continue;
if (itemdata.isEquip()) { if (itemdata.isEquip()) {
for (int i = 0; i < 10; ++i) { for (int i = 0; i < 10; ++i) {
GenshinItem genshinItem = new GenshinItem(itemdata); GameItem item = new GameItem(itemdata);
if (itemdata.getItemType() == ItemType.ITEM_WEAPON) { if (itemdata.getItemType() == ItemType.ITEM_WEAPON) {
genshinItem.setLevel(90); item.setLevel(90);
genshinItem.setPromoteLevel(6); item.setPromoteLevel(6);
genshinItem.setRefinement(4); item.setRefinement(4);
} }
genshinItemList.add(genshinItem); itemList.add(item);
} }
} }
else { else {
GenshinItem genshinItem = new GenshinItem(itemdata); GameItem item = new GameItem(itemdata);
genshinItem.setCount(amount); item.setCount(amount);
genshinItemList.add(genshinItem); itemList.add(item);
} }
} }
int packetNum = 20; int packetNum = 20;
int itemLength = genshinItemList.size(); int itemLength = itemList.size();
int number = itemLength / packetNum; int number = itemLength / packetNum;
int remainder = itemLength % packetNum; int remainder = itemLength % packetNum;
int offset = 0; int offset = 0;
for (int i = 0; i < packetNum; ++i) { for (int i = 0; i < packetNum; ++i) {
if (remainder > 0) { if (remainder > 0) {
player.getInventory().addItems(genshinItemList.subList(i * number + offset, (i + 1) * number + offset + 1)); player.getInventory().addItems(itemList.subList(i * number + offset, (i + 1) * number + offset + 1));
--remainder; --remainder;
++offset; ++offset;
} }
else { else {
player.getInventory().addItems(genshinItemList.subList(i * number + offset, (i + 1) * number + offset)); player.getInventory().addItems(itemList.subList(i * number + offset, (i + 1) * number + offset));
} }
} }
} }

View File

@ -3,10 +3,10 @@ package emu.grasscutter.command.commands;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.data.GenshinData; import emu.grasscutter.data.GameData;
import emu.grasscutter.data.def.AvatarData; import emu.grasscutter.data.def.AvatarData;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import emu.grasscutter.game.avatar.GenshinAvatar; import emu.grasscutter.game.avatar.Avatar;
import java.util.List; import java.util.List;
@ -15,7 +15,7 @@ import java.util.List;
public final class GiveCharCommand implements CommandHandler { public final class GiveCharCommand implements CommandHandler {
@Override @Override
public void execute(GenshinPlayer sender, List<String> args) { public void execute(Player sender, List<String> args) {
int target, avatarId, level = 1, ascension; int target, avatarId, level = 1, ascension;
if (sender == null && args.size() < 2) { if (sender == null && args.size() < 2) {
@ -61,13 +61,13 @@ public final class GiveCharCommand implements CommandHandler {
break; break;
} }
GenshinPlayer targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target); Player targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target);
if (targetPlayer == null) { if (targetPlayer == null) {
CommandHandler.sendMessage(sender, "Player not found."); CommandHandler.sendMessage(sender, "Player not found.");
return; return;
} }
AvatarData avatarData = GenshinData.getAvatarDataMap().get(avatarId); AvatarData avatarData = GameData.getAvatarDataMap().get(avatarId);
if (avatarData == null) { if (avatarData == null) {
CommandHandler.sendMessage(sender, "Invalid avatar id."); CommandHandler.sendMessage(sender, "Invalid avatar id.");
return; return;
@ -80,7 +80,7 @@ public final class GiveCharCommand implements CommandHandler {
ascension = (int) Math.ceil(level / 10f) - 3; ascension = (int) Math.ceil(level / 10f) - 3;
} }
GenshinAvatar avatar = new GenshinAvatar(avatarId); Avatar avatar = new Avatar(avatarId);
avatar.setLevel(level); avatar.setLevel(level);
avatar.setPromoteLevel(ascension); avatar.setPromoteLevel(ascension);

View File

@ -3,10 +3,10 @@ package emu.grasscutter.command.commands;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.data.GenshinData; import emu.grasscutter.data.GameData;
import emu.grasscutter.data.def.ItemData; import emu.grasscutter.data.def.ItemData;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import emu.grasscutter.game.inventory.GenshinItem; import emu.grasscutter.game.inventory.GameItem;
import emu.grasscutter.game.props.ActionReason; import emu.grasscutter.game.props.ActionReason;
import emu.grasscutter.server.packet.send.PacketItemAddHintNotify; import emu.grasscutter.server.packet.send.PacketItemAddHintNotify;
@ -18,7 +18,7 @@ import java.util.List;
public final class GiveCommand implements CommandHandler { public final class GiveCommand implements CommandHandler {
@Override @Override
public void execute(GenshinPlayer sender, List<String> args) { public void execute(Player sender, List<String> args) {
int target, item, lvl, amount = 1; int target, item, lvl, amount = 1;
if (sender == null && args.size() < 2) { if (sender == null && args.size() < 2) {
CommandHandler.sendMessage(null, "Usage: give <player> <itemId|itemName> [amount] [level]"); CommandHandler.sendMessage(null, "Usage: give <player> <itemId|itemName> [amount] [level]");
@ -99,14 +99,14 @@ public final class GiveCommand implements CommandHandler {
break; break;
} }
GenshinPlayer targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target); Player targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target);
if (targetPlayer == null) { if (targetPlayer == null) {
CommandHandler.sendMessage(sender, "Player not found."); CommandHandler.sendMessage(sender, "Player not found.");
return; return;
} }
ItemData itemData = GenshinData.getItemDataMap().get(item); ItemData itemData = GameData.getItemDataMap().get(item);
if (itemData == null) { if (itemData == null) {
CommandHandler.sendMessage(sender, "Invalid item id."); CommandHandler.sendMessage(sender, "Invalid item id.");
return; return;
@ -121,11 +121,11 @@ public final class GiveCommand implements CommandHandler {
String.format("Given %s with level %s %s times to %s", item, lvl, amount, target)); String.format("Given %s with level %s %s times to %s", item, lvl, amount, target));
} }
private void item(GenshinPlayer player, ItemData itemData, int amount, int lvl) { private void item(Player player, ItemData itemData, int amount, int lvl) {
if (itemData.isEquip()) { if (itemData.isEquip()) {
List<GenshinItem> items = new LinkedList<>(); List<GameItem> items = new LinkedList<>();
for (int i = 0; i < amount; i++) { for (int i = 0; i < amount; i++) {
GenshinItem item = new GenshinItem(itemData); GameItem item = new GameItem(itemData);
item.setCount(amount); item.setCount(amount);
item.setLevel(lvl); item.setLevel(lvl);
item.setPromoteLevel(0); item.setPromoteLevel(0);
@ -146,9 +146,9 @@ public final class GiveCommand implements CommandHandler {
} }
player.getInventory().addItems(items, ActionReason.SubfieldDrop); player.getInventory().addItems(items, ActionReason.SubfieldDrop);
} else { } else {
GenshinItem genshinItem = new GenshinItem(itemData); GameItem item = new GameItem(itemData);
genshinItem.setCount(amount); item.setCount(amount);
player.getInventory().addItem(genshinItem, ActionReason.SubfieldDrop); player.getInventory().addItem(item, ActionReason.SubfieldDrop);
} }
} }
} }

View File

@ -3,7 +3,7 @@ package emu.grasscutter.command.commands;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import java.util.List; import java.util.List;
@ -12,7 +12,7 @@ import java.util.List;
public final class GodModeCommand implements CommandHandler { public final class GodModeCommand implements CommandHandler {
@Override @Override
public void execute(GenshinPlayer sender, List<String> args) { public void execute(Player sender, List<String> args) {
if (sender == null) { if (sender == null) {
CommandHandler.sendMessage(null, "Run this command in-game."); CommandHandler.sendMessage(null, "Run this command in-game.");
return; // TODO: toggle player's godmode statue from console or other players return; // TODO: toggle player's godmode statue from console or other players
@ -32,7 +32,7 @@ public final class GodModeCommand implements CommandHandler {
} else { } else {
target = sender.getUid(); target = sender.getUid();
} }
GenshinPlayer targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target); Player targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target);
if (targetPlayer == null) { if (targetPlayer == null) {
CommandHandler.sendMessage(sender, "Player not found."); CommandHandler.sendMessage(sender, "Player not found.");
return; return;

View File

@ -2,7 +2,7 @@ package emu.grasscutter.command.commands;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import emu.grasscutter.game.props.FightProperty; import emu.grasscutter.game.props.FightProperty;
import emu.grasscutter.server.packet.send.PacketAvatarFightPropUpdateNotify; import emu.grasscutter.server.packet.send.PacketAvatarFightPropUpdateNotify;
import emu.grasscutter.server.packet.send.PacketAvatarLifeStateChangeNotify; import emu.grasscutter.server.packet.send.PacketAvatarLifeStateChangeNotify;
@ -13,7 +13,7 @@ import java.util.List;
description = "Heal all characters in your current team.", permission = "player.heal") description = "Heal all characters in your current team.", permission = "player.heal")
public final class HealCommand implements CommandHandler { public final class HealCommand implements CommandHandler {
@Override @Override
public void execute(GenshinPlayer sender, List<String> args) { public void execute(Player sender, List<String> args) {
if (sender == null) { if (sender == null) {
CommandHandler.sendMessage(null, "Run this command in-game."); CommandHandler.sendMessage(null, "Run this command in-game.");
return; return;

View File

@ -3,7 +3,7 @@ package emu.grasscutter.command.commands;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.command.CommandMap; import emu.grasscutter.command.CommandMap;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import java.util.*; import java.util.*;
@ -12,7 +12,7 @@ import java.util.*;
public final class HelpCommand implements CommandHandler { public final class HelpCommand implements CommandHandler {
@Override @Override
public void execute(GenshinPlayer player, List<String> args) { public void execute(Player player, List<String> args) {
if (args.size() < 1) { if (args.size() < 1) {
HashMap<String, CommandHandler> handlers = CommandMap.getInstance().getHandlers(); HashMap<String, CommandHandler> handlers = CommandMap.getInstance().getHandlers();
List<Command> annotations = new ArrayList<>(); List<Command> annotations = new ArrayList<>();
@ -53,7 +53,7 @@ public final class HelpCommand implements CommandHandler {
} }
} }
void SendAllHelpMessage(GenshinPlayer player, List<Command> annotations) { void SendAllHelpMessage(Player player, List<Command> annotations) {
if (player == null) { if (player == null) {
StringBuilder builder = new StringBuilder("\nAvailable commands:\n"); StringBuilder builder = new StringBuilder("\nAvailable commands:\n");
annotations.forEach(annotation -> { annotations.forEach(annotation -> {

View File

@ -3,7 +3,7 @@ package emu.grasscutter.command.commands;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import java.util.List; import java.util.List;
@ -12,10 +12,10 @@ import java.util.List;
public final class KickCommand implements CommandHandler { public final class KickCommand implements CommandHandler {
@Override @Override
public void execute(GenshinPlayer sender, List<String> args) { public void execute(Player sender, List<String> args) {
int target = Integer.parseInt(args.get(0)); int target = Integer.parseInt(args.get(0));
GenshinPlayer targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target); Player targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target);
if (targetPlayer == null) { if (targetPlayer == null) {
CommandHandler.sendMessage(sender, "Player not found."); CommandHandler.sendMessage(sender, "Player not found.");
return; return;

View File

@ -3,8 +3,8 @@ package emu.grasscutter.command.commands;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import emu.grasscutter.game.GenshinScene; import emu.grasscutter.game.Scene;
import emu.grasscutter.game.entity.EntityMonster; import emu.grasscutter.game.entity.EntityMonster;
import java.util.List; import java.util.List;
@ -14,9 +14,9 @@ import java.util.List;
public final class KillAllCommand implements CommandHandler { public final class KillAllCommand implements CommandHandler {
@Override @Override
public void execute(GenshinPlayer sender, List<String> args) { public void execute(Player sender, List<String> args) {
GenshinScene scene; Scene mainScene;
GenshinPlayer genshinPlayer; Player targetPlayer;
try { try {
switch (args.size()) { switch (args.size()) {
@ -25,38 +25,38 @@ public final class KillAllCommand implements CommandHandler {
CommandHandler.sendMessage(null, "Usage: killall [playerUid] [sceneId]"); CommandHandler.sendMessage(null, "Usage: killall [playerUid] [sceneId]");
return; return;
} }
scene = sender.getScene(); mainScene = sender.getScene();
break; break;
case 1: // [playerUid] case 1: // [playerUid]
genshinPlayer = Grasscutter.getGameServer().getPlayerByUid(Integer.parseInt(args.get(0))); targetPlayer = Grasscutter.getGameServer().getPlayerByUid(Integer.parseInt(args.get(0)));
if (genshinPlayer == null) { if (targetPlayer == null) {
CommandHandler.sendMessage(sender, "Player not found or offline."); CommandHandler.sendMessage(sender, "Player not found or offline.");
return; return;
} }
scene = genshinPlayer.getScene(); mainScene = targetPlayer.getScene();
break; break;
case 2: // [playerUid] [sceneId] case 2: // [playerUid] [sceneId]
genshinPlayer = Grasscutter.getGameServer().getPlayerByUid(Integer.parseInt(args.get(0))); targetPlayer = Grasscutter.getGameServer().getPlayerByUid(Integer.parseInt(args.get(0)));
if (genshinPlayer == null) { if (targetPlayer == null) {
CommandHandler.sendMessage(sender, "Player not found or offline."); CommandHandler.sendMessage(sender, "Player not found or offline.");
return; return;
} }
GenshinScene genshinScene = sender.getWorld().getSceneById(Integer.parseInt(args.get(1))); Scene scene = sender.getWorld().getSceneById(Integer.parseInt(args.get(1)));
if (genshinScene == null) { if (scene == null) {
CommandHandler.sendMessage(sender, "Scene not found in player world"); CommandHandler.sendMessage(sender, "Scene not found in player world");
return; return;
} }
scene = genshinScene; mainScene = scene;
break; break;
default: default:
CommandHandler.sendMessage(sender, "Usage: killall [playerUid] [sceneId]"); CommandHandler.sendMessage(sender, "Usage: killall [playerUid] [sceneId]");
return; return;
} }
scene.getEntities().values().stream() mainScene.getEntities().values().stream()
.filter(entity -> entity instanceof EntityMonster) .filter(entity -> entity instanceof EntityMonster)
.forEach(entity -> scene.killEntity(entity, 0)); .forEach(entity -> mainScene.killEntity(entity, 0));
CommandHandler.sendMessage(sender, "Killing all monsters in scene " + scene.getId()); CommandHandler.sendMessage(sender, "Killing all monsters in scene " + mainScene.getId());
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
CommandHandler.sendMessage(sender, "Invalid arguments."); CommandHandler.sendMessage(sender, "Invalid arguments.");
} }

View File

@ -3,7 +3,7 @@ package emu.grasscutter.command.commands;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import emu.grasscutter.game.entity.EntityAvatar; import emu.grasscutter.game.entity.EntityAvatar;
import emu.grasscutter.game.props.FightProperty; import emu.grasscutter.game.props.FightProperty;
import emu.grasscutter.game.props.LifeState; import emu.grasscutter.game.props.LifeState;
@ -17,7 +17,7 @@ import java.util.List;
public final class KillCharacterCommand implements CommandHandler { public final class KillCharacterCommand implements CommandHandler {
@Override @Override
public void execute(GenshinPlayer sender, List<String> args) { public void execute(Player sender, List<String> args) {
int target; int target;
if (sender == null) { if (sender == null) {
// from console // from console
@ -48,7 +48,7 @@ public final class KillCharacterCommand implements CommandHandler {
} }
} }
GenshinPlayer targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target); Player targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target);
if (targetPlayer == null) { if (targetPlayer == null) {
CommandHandler.sendMessage(sender, "Player not found or offline."); CommandHandler.sendMessage(sender, "Player not found or offline.");
return; return;

View File

@ -3,7 +3,7 @@ package emu.grasscutter.command.commands;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -12,8 +12,8 @@ import java.util.Map;
public final class ListCommand implements CommandHandler { public final class ListCommand implements CommandHandler {
@Override @Override
public void execute(GenshinPlayer sender, List<String> args) { public void execute(Player sender, List<String> args) {
Map<Integer, GenshinPlayer> playersMap = Grasscutter.getGameServer().getPlayers(); Map<Integer, Player> playersMap = Grasscutter.getGameServer().getPlayers();
CommandHandler.sendMessage(sender, String.format("There are %s player(s) online:", playersMap.size())); CommandHandler.sendMessage(sender, String.format("There are %s player(s) online:", playersMap.size()));

View File

@ -4,7 +4,7 @@ import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.Account; import emu.grasscutter.game.Account;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import java.util.List; import java.util.List;
@ -13,7 +13,7 @@ import java.util.List;
public final class PermissionCommand implements CommandHandler { public final class PermissionCommand implements CommandHandler {
@Override @Override
public void execute(GenshinPlayer sender, List<String> args) { public void execute(Player sender, List<String> args) {
if (args.size() < 3) { if (args.size() < 3) {
CommandHandler.sendMessage(sender, "Usage: permission <add|remove> <username> <permission>"); CommandHandler.sendMessage(sender, "Usage: permission <add|remove> <username> <permission>");
return; return;

View File

@ -2,7 +2,7 @@ package emu.grasscutter.command.commands;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import java.util.List; import java.util.List;
@ -11,7 +11,7 @@ import java.util.List;
public final class PositionCommand implements CommandHandler { public final class PositionCommand implements CommandHandler {
@Override @Override
public void execute(GenshinPlayer sender, List<String> args) { public void execute(Player sender, List<String> args) {
if (sender == null) { if (sender == null) {
CommandHandler.sendMessage(null, "Run this command in-game."); CommandHandler.sendMessage(null, "Run this command in-game.");
return; return;

View File

@ -3,7 +3,7 @@ package emu.grasscutter.command.commands;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import java.util.List; import java.util.List;
@ -12,7 +12,7 @@ import java.util.List;
public final class ReloadCommand implements CommandHandler { public final class ReloadCommand implements CommandHandler {
@Override @Override
public void execute(GenshinPlayer sender, List<String> args) { public void execute(Player sender, List<String> args) {
CommandHandler.sendMessage(sender, "Reloading config."); CommandHandler.sendMessage(sender, "Reloading config.");
Grasscutter.loadConfig(); Grasscutter.loadConfig();
Grasscutter.getGameServer().getGachaManager().load(); Grasscutter.getGameServer().getGachaManager().load();

View File

@ -2,8 +2,8 @@ package emu.grasscutter.command.commands;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import emu.grasscutter.game.avatar.GenshinAvatar; import emu.grasscutter.game.avatar.Avatar;
import emu.grasscutter.game.entity.EntityAvatar; import emu.grasscutter.game.entity.EntityAvatar;
import java.util.List; import java.util.List;
@ -14,7 +14,7 @@ import java.util.List;
public final class ResetConstCommand implements CommandHandler { public final class ResetConstCommand implements CommandHandler {
@Override @Override
public void execute(GenshinPlayer sender, List<String> args) { public void execute(Player sender, List<String> args) {
if (sender == null) { if (sender == null) {
CommandHandler.sendMessage(null, "Run this command in-game."); CommandHandler.sendMessage(null, "Run this command in-game.");
return; return;
@ -29,14 +29,14 @@ public final class ResetConstCommand implements CommandHandler {
return; return;
} }
GenshinAvatar avatar = entity.getAvatar(); Avatar avatar = entity.getAvatar();
this.resetConstellation(avatar); this.resetConstellation(avatar);
sender.dropMessage("Constellations for " + avatar.getAvatarData().getName() + " have been reset. Please relog to see changes."); sender.dropMessage("Constellations for " + avatar.getAvatarData().getName() + " have been reset. Please relog to see changes.");
} }
} }
private void resetConstellation(GenshinAvatar avatar) { private void resetConstellation(Avatar avatar) {
avatar.getTalentIdList().clear(); avatar.getTalentIdList().clear();
avatar.setCoreProudSkillLevel(0); avatar.setCoreProudSkillLevel(0);
avatar.recalcStats(); avatar.recalcStats();

View File

@ -2,7 +2,7 @@ package emu.grasscutter.command.commands;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import java.util.List; import java.util.List;
@ -10,7 +10,7 @@ import java.util.List;
public final class RestartCommand implements CommandHandler { public final class RestartCommand implements CommandHandler {
@Override @Override
public void execute(GenshinPlayer sender, List<String> args) { public void execute(Player sender, List<String> args) {
sender.getSession().close(); sender.getSession().close();
} }
} }

View File

@ -4,7 +4,7 @@ import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.database.DatabaseHelper; import emu.grasscutter.database.DatabaseHelper;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import emu.grasscutter.game.Mail; import emu.grasscutter.game.Mail;
import emu.grasscutter.server.packet.send.PacketMailChangeNotify; import emu.grasscutter.server.packet.send.PacketMailChangeNotify;
@ -27,7 +27,7 @@ public class SendMailCommand implements CommandHandler {
// Yes this is awful and I hate it. // Yes this is awful and I hate it.
@Override @Override
public void execute(GenshinPlayer sender, List<String> args) { public void execute(Player sender, List<String> args) {
int senderId; int senderId;
if(sender != null) { if(sender != null) {
senderId = sender.getUid(); senderId = sender.getUid();
@ -77,7 +77,7 @@ public class SendMailCommand implements CommandHandler {
Grasscutter.getGameServer().getPlayerByUid(mailBuilder.recipient, true).sendMail(mailBuilder.mail); Grasscutter.getGameServer().getPlayerByUid(mailBuilder.recipient, true).sendMail(mailBuilder.mail);
CommandHandler.sendMessage(sender, "Message sent to user " + mailBuilder.recipient + "!"); CommandHandler.sendMessage(sender, "Message sent to user " + mailBuilder.recipient + "!");
} else { } else {
for (GenshinPlayer player : DatabaseHelper.getAllPlayers()) { for (Player player : DatabaseHelper.getAllPlayers()) {
Grasscutter.getGameServer().getPlayerByUid(player.getUid(), true).sendMail(mailBuilder.mail); Grasscutter.getGameServer().getPlayerByUid(player.getUid(), true).sendMail(mailBuilder.mail);
} }
CommandHandler.sendMessage(sender, "Message sent to all users!"); CommandHandler.sendMessage(sender, "Message sent to all users!");

View File

@ -3,7 +3,7 @@ package emu.grasscutter.command.commands;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import java.util.List; import java.util.List;
@ -12,7 +12,7 @@ import java.util.List;
public final class SendMessageCommand implements CommandHandler { public final class SendMessageCommand implements CommandHandler {
@Override @Override
public void execute(GenshinPlayer sender, List<String> args) { public void execute(Player sender, List<String> args) {
if (args.size() < 2) { if (args.size() < 2) {
CommandHandler.sendMessage(null, "Usage: sendmessage <player> <message>"); CommandHandler.sendMessage(null, "Usage: sendmessage <player> <message>");
return; return;
@ -22,7 +22,7 @@ public final class SendMessageCommand implements CommandHandler {
int target = Integer.parseInt(args.get(0)); int target = Integer.parseInt(args.get(0));
String message = String.join(" ", args.subList(1, args.size())); String message = String.join(" ", args.subList(1, args.size()));
GenshinPlayer targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target); Player targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target);
if (targetPlayer == null) { if (targetPlayer == null) {
CommandHandler.sendMessage(sender, "Player not found."); CommandHandler.sendMessage(sender, "Player not found.");
return; return;

View File

@ -4,9 +4,9 @@ import java.util.List;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.data.GenshinData; import emu.grasscutter.data.GameData;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import emu.grasscutter.game.avatar.GenshinAvatar; import emu.grasscutter.game.avatar.Avatar;
import emu.grasscutter.server.packet.send.PacketAvatarFetterDataNotify; import emu.grasscutter.server.packet.send.PacketAvatarFetterDataNotify;
@Command(label = "setfetterlevel", usage = "setfetterlevel <level>", @Command(label = "setfetterlevel", usage = "setfetterlevel <level>",
@ -15,7 +15,7 @@ import emu.grasscutter.server.packet.send.PacketAvatarFetterDataNotify;
public final class SetFetterLevelCommand implements CommandHandler { public final class SetFetterLevelCommand implements CommandHandler {
@Override @Override
public void execute(GenshinPlayer sender, List<String> args) { public void execute(Player sender, List<String> args) {
if (sender == null) { if (sender == null) {
CommandHandler.sendMessage(null, "Run this command in-game."); CommandHandler.sendMessage(null, "Run this command in-game.");
return; return;
@ -32,11 +32,11 @@ public final class SetFetterLevelCommand implements CommandHandler {
CommandHandler.sendMessage(sender, "Fetter level must be between 0 and 10."); CommandHandler.sendMessage(sender, "Fetter level must be between 0 and 10.");
return; return;
} }
GenshinAvatar avatar = sender.getTeamManager().getCurrentAvatarEntity().getAvatar(); Avatar avatar = sender.getTeamManager().getCurrentAvatarEntity().getAvatar();
avatar.setFetterLevel(fetterLevel); avatar.setFetterLevel(fetterLevel);
if (fetterLevel != 10) { if (fetterLevel != 10) {
avatar.setFetterExp(GenshinData.getAvatarFetterLevelDataMap().get(fetterLevel).getExp()); avatar.setFetterExp(GameData.getAvatarFetterLevelDataMap().get(fetterLevel).getExp());
} }
avatar.save(); avatar.save();

View File

@ -2,7 +2,7 @@ package emu.grasscutter.command.commands;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import emu.grasscutter.game.entity.EntityAvatar; import emu.grasscutter.game.entity.EntityAvatar;
import emu.grasscutter.game.props.FightProperty; import emu.grasscutter.game.props.FightProperty;
import emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify; import emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify;
@ -14,7 +14,7 @@ import java.util.List;
public final class SetStatsCommand implements CommandHandler { public final class SetStatsCommand implements CommandHandler {
@Override @Override
public void execute(GenshinPlayer sender, List<String> args) { public void execute(Player sender, List<String> args) {
if (sender == null) { if (sender == null) {
CommandHandler.sendMessage(null, "Run this command in-game."); CommandHandler.sendMessage(null, "Run this command in-game.");
return; return;

View File

@ -2,7 +2,7 @@ package emu.grasscutter.command.commands;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import emu.grasscutter.game.props.PlayerProperty; import emu.grasscutter.game.props.PlayerProperty;
import java.util.List; import java.util.List;
@ -13,7 +13,7 @@ import java.util.List;
public final class SetWorldLevelCommand implements CommandHandler { public final class SetWorldLevelCommand implements CommandHandler {
@Override @Override
public void execute(GenshinPlayer sender, List<String> args) { public void execute(Player sender, List<String> args) {
if (sender == null) { if (sender == null) {
CommandHandler.sendMessage(null, "Run this command in-game."); CommandHandler.sendMessage(null, "Run this command in-game.");
return; // TODO: set player's world level from console or other players return; // TODO: set player's world level from console or other players

View File

@ -2,9 +2,9 @@ package emu.grasscutter.command.commands;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.data.GenshinData; import emu.grasscutter.data.GameData;
import emu.grasscutter.data.def.MonsterData; import emu.grasscutter.data.def.MonsterData;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import emu.grasscutter.game.entity.EntityMonster; import emu.grasscutter.game.entity.EntityMonster;
import emu.grasscutter.utils.Position; import emu.grasscutter.utils.Position;
@ -15,7 +15,7 @@ import java.util.List;
public final class SpawnCommand implements CommandHandler { public final class SpawnCommand implements CommandHandler {
@Override @Override
public void execute(GenshinPlayer sender, List<String> args) { public void execute(Player sender, List<String> args) {
if (sender == null) { if (sender == null) {
CommandHandler.sendMessage(null, "Run this command in-game."); CommandHandler.sendMessage(null, "Run this command in-game.");
return; return;
@ -31,7 +31,7 @@ public final class SpawnCommand implements CommandHandler {
int level = args.size() > 1 ? Integer.parseInt(args.get(1)) : 1; int level = args.size() > 1 ? Integer.parseInt(args.get(1)) : 1;
int amount = args.size() > 2 ? Integer.parseInt(args.get(2)) : 1; int amount = args.size() > 2 ? Integer.parseInt(args.get(2)) : 1;
MonsterData entityData = GenshinData.getMonsterDataMap().get(entity); MonsterData entityData = GameData.getMonsterDataMap().get(entity);
if (entityData == null) { if (entityData == null) {
CommandHandler.sendMessage(sender, "Invalid entity id."); CommandHandler.sendMessage(sender, "Invalid entity id.");
return; return;

View File

@ -3,7 +3,7 @@ package emu.grasscutter.command.commands;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import java.util.List; import java.util.List;
@ -12,9 +12,9 @@ import java.util.List;
public final class StopCommand implements CommandHandler { public final class StopCommand implements CommandHandler {
@Override @Override
public void execute(GenshinPlayer sender, List<String> args) { public void execute(Player sender, List<String> args) {
CommandHandler.sendMessage(null, "Server shutting down..."); CommandHandler.sendMessage(null, "Server shutting down...");
for (GenshinPlayer p : Grasscutter.getGameServer().getPlayers().values()) { for (Player p : Grasscutter.getGameServer().getPlayers().values()) {
CommandHandler.sendMessage(p, "Server shutting down..."); CommandHandler.sendMessage(p, "Server shutting down...");
} }

View File

@ -3,8 +3,8 @@ package emu.grasscutter.command.commands;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.data.def.AvatarSkillDepotData; import emu.grasscutter.data.def.AvatarSkillDepotData;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import emu.grasscutter.game.avatar.GenshinAvatar; import emu.grasscutter.game.avatar.Avatar;
import emu.grasscutter.game.entity.EntityAvatar; import emu.grasscutter.game.entity.EntityAvatar;
import emu.grasscutter.server.packet.send.PacketAvatarSkillChangeNotify; import emu.grasscutter.server.packet.send.PacketAvatarSkillChangeNotify;
import emu.grasscutter.server.packet.send.PacketAvatarSkillUpgradeRsp; import emu.grasscutter.server.packet.send.PacketAvatarSkillUpgradeRsp;
@ -16,7 +16,7 @@ import java.util.List;
public final class TalentCommand implements CommandHandler { public final class TalentCommand implements CommandHandler {
@Override @Override
public void execute(GenshinPlayer sender, List<String> args) { public void execute(Player sender, List<String> args) {
if (sender == null) { if (sender == null) {
CommandHandler.sendMessage(null, "Run this command in-game."); CommandHandler.sendMessage(null, "Run this command in-game.");
return; return;
@ -41,7 +41,7 @@ public final class TalentCommand implements CommandHandler {
int skillId = Integer.parseInt(args.get(1)); int skillId = Integer.parseInt(args.get(1));
int nextLevel = Integer.parseInt(args.get(2)); int nextLevel = Integer.parseInt(args.get(2));
EntityAvatar entity = sender.getTeamManager().getCurrentAvatarEntity(); EntityAvatar entity = sender.getTeamManager().getCurrentAvatarEntity();
GenshinAvatar avatar = entity.getAvatar(); Avatar avatar = entity.getAvatar();
int skillIdNorAtk = avatar.getData().getSkillDepot().getSkills().get(0); int skillIdNorAtk = avatar.getData().getSkillDepot().getSkills().get(0);
int skillIdE = avatar.getData().getSkillDepot().getSkills().get(1); int skillIdE = avatar.getData().getSkillDepot().getSkills().get(1);
int skillIdQ = avatar.getData().getSkillDepot().getEnergySkill(); int skillIdQ = avatar.getData().getSkillDepot().getEnergySkill();
@ -97,7 +97,7 @@ public final class TalentCommand implements CommandHandler {
case "n": case "e": case "q": case "n": case "e": case "q":
try { try {
EntityAvatar entity = sender.getTeamManager().getCurrentAvatarEntity(); EntityAvatar entity = sender.getTeamManager().getCurrentAvatarEntity();
GenshinAvatar avatar = entity.getAvatar(); Avatar avatar = entity.getAvatar();
AvatarSkillDepotData SkillDepot = avatar.getData().getSkillDepot(); AvatarSkillDepotData SkillDepot = avatar.getData().getSkillDepot();
int skillId; int skillId;
switch (cmdSwitch) { switch (cmdSwitch) {
@ -135,7 +135,7 @@ public final class TalentCommand implements CommandHandler {
break; break;
case "getid": case "getid":
EntityAvatar entity = sender.getTeamManager().getCurrentAvatarEntity(); EntityAvatar entity = sender.getTeamManager().getCurrentAvatarEntity();
GenshinAvatar avatar = entity.getAvatar(); Avatar avatar = entity.getAvatar();
int skillIdNorAtk = avatar.getData().getSkillDepot().getSkills().get(0); int skillIdNorAtk = avatar.getData().getSkillDepot().getSkills().get(0);
int skillIdE = avatar.getData().getSkillDepot().getSkills().get(1); int skillIdE = avatar.getData().getSkillDepot().getSkills().get(1);
int skillIdQ = avatar.getData().getSkillDepot().getEnergySkill(); int skillIdQ = avatar.getData().getSkillDepot().getEnergySkill();

View File

@ -2,7 +2,7 @@ package emu.grasscutter.command.commands;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import emu.grasscutter.utils.Position; import emu.grasscutter.utils.Position;
import java.util.List; import java.util.List;
@ -12,7 +12,7 @@ import java.util.List;
public final class TeleportCommand implements CommandHandler { public final class TeleportCommand implements CommandHandler {
@Override @Override
public void execute(GenshinPlayer sender, List<String> args) { public void execute(Player sender, List<String> args) {
if (sender == null) { if (sender == null) {
CommandHandler.sendMessage(null, "Run this command in-game."); CommandHandler.sendMessage(null, "Run this command in-game.");
return; return;

View File

@ -2,7 +2,7 @@ package emu.grasscutter.command.commands;
import emu.grasscutter.command.Command; import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import emu.grasscutter.game.props.ClimateType; import emu.grasscutter.game.props.ClimateType;
import emu.grasscutter.server.packet.send.PacketSceneAreaWeatherNotify; import emu.grasscutter.server.packet.send.PacketSceneAreaWeatherNotify;
@ -13,7 +13,7 @@ import java.util.List;
public final class WeatherCommand implements CommandHandler { public final class WeatherCommand implements CommandHandler {
@Override @Override
public void execute(GenshinPlayer sender, List<String> args) { public void execute(Player sender, List<String> args) {
if (sender == null) { if (sender == null) {
CommandHandler.sendMessage(null, "Run this command in-game."); CommandHandler.sendMessage(null, "Run this command in-game.");
return; return;

View File

@ -16,7 +16,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectLinkedOpenHashMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
public class GenshinData { public class GameData {
// BinOutputs // BinOutputs
private static final Int2ObjectMap<String> abilityHashes = new Int2ObjectOpenHashMap<>(); private static final Int2ObjectMap<String> abilityHashes = new Int2ObjectOpenHashMap<>();
private static final Map<String, AbilityEmbryoEntry> abilityEmbryos = new HashMap<>(); private static final Map<String, AbilityEmbryoEntry> abilityEmbryos = new HashMap<>();
@ -69,7 +69,7 @@ public class GenshinData {
Int2ObjectMap<?> map = null; Int2ObjectMap<?> map = null;
try { try {
Field field = GenshinData.class.getDeclaredField(Utils.lowerCaseFirstChar(resourceDefinition.getSimpleName()) + "Map"); Field field = GameData.class.getDeclaredField(Utils.lowerCaseFirstChar(resourceDefinition.getSimpleName()) + "Map");
field.setAccessible(true); field.setAccessible(true);
map = (Int2ObjectMap<?>) field.get(null); map = (Int2ObjectMap<?>) field.get(null);

View File

@ -15,21 +15,21 @@ import emu.grasscutter.utils.WeightedList;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
public class GenshinDepot { public class GameDepot {
private static Int2ObjectMap<WeightedList<ReliquaryMainPropData>> relicMainPropDepot = new Int2ObjectOpenHashMap<>(); private static Int2ObjectMap<WeightedList<ReliquaryMainPropData>> relicMainPropDepot = new Int2ObjectOpenHashMap<>();
private static Int2ObjectMap<List<ReliquaryAffixData>> relicAffixDepot = new Int2ObjectOpenHashMap<>(); private static Int2ObjectMap<List<ReliquaryAffixData>> relicAffixDepot = new Int2ObjectOpenHashMap<>();
private static Int2ObjectMap<SpatialIndex<SpawnGroupEntry>> spawnLists = new Int2ObjectOpenHashMap<>(); private static Int2ObjectMap<SpatialIndex<SpawnGroupEntry>> spawnLists = new Int2ObjectOpenHashMap<>();
public static void load() { public static void load() {
for (ReliquaryMainPropData data : GenshinData.getReliquaryMainPropDataMap().values()) { for (ReliquaryMainPropData data : GameData.getReliquaryMainPropDataMap().values()) {
if (data.getWeight() <= 0 || data.getPropDepotId() <= 0) { if (data.getWeight() <= 0 || data.getPropDepotId() <= 0) {
continue; continue;
} }
WeightedList<ReliquaryMainPropData> list = relicMainPropDepot.computeIfAbsent(data.getPropDepotId(), k -> new WeightedList<>()); WeightedList<ReliquaryMainPropData> list = relicMainPropDepot.computeIfAbsent(data.getPropDepotId(), k -> new WeightedList<>());
list.add(data.getWeight(), data); list.add(data.getWeight(), data);
} }
for (ReliquaryAffixData data : GenshinData.getReliquaryAffixDataMap().values()) { for (ReliquaryAffixData data : GameData.getReliquaryAffixDataMap().values()) {
if (data.getWeight() <= 0 || data.getDepotId() <= 0) { if (data.getWeight() <= 0 || data.getDepotId() <= 0) {
continue; continue;
} }

View File

@ -1,6 +1,6 @@
package emu.grasscutter.data; package emu.grasscutter.data;
public abstract class GenshinResource { public abstract class GameResource {
public int getId() { public int getId() {
return 0; return 0;

View File

@ -27,7 +27,7 @@ public class ResourceLoader {
public static List<Class<?>> getResourceDefClasses() { public static List<Class<?>> getResourceDefClasses() {
Reflections reflections = new Reflections(ResourceLoader.class.getPackage().getName()); Reflections reflections = new Reflections(ResourceLoader.class.getPackage().getName());
Set<?> classes = reflections.getSubTypesOf(GenshinResource.class); Set<?> classes = reflections.getSubTypesOf(GameResource.class);
List<Class<?>> classList = new ArrayList<>(classes.size()); List<Class<?>> classList = new ArrayList<>(classes.size());
classes.forEach(o -> { classes.forEach(o -> {
@ -50,12 +50,12 @@ public class ResourceLoader {
loadResources(); loadResources();
loadScenePoints(); loadScenePoints();
// Process into depots // Process into depots
GenshinDepot.load(); GameDepot.load();
// Load spawn data // Load spawn data
loadSpawnData(); loadSpawnData();
// Custom - TODO move this somewhere else // Custom - TODO move this somewhere else
try { try {
GenshinData.getAvatarSkillDepotDataMap().get(504).setAbilities( GameData.getAvatarSkillDepotDataMap().get(504).setAbilities(
new AbilityEmbryoEntry( new AbilityEmbryoEntry(
"", "",
new String[] { new String[] {
@ -68,7 +68,7 @@ public class ResourceLoader {
"Avatar_Player_WindBreathe_CameraController" "Avatar_Player_WindBreathe_CameraController"
} }
)); ));
GenshinData.getAvatarSkillDepotDataMap().get(704).setAbilities( GameData.getAvatarSkillDepotDataMap().get(704).setAbilities(
new AbilityEmbryoEntry( new AbilityEmbryoEntry(
"", "",
new String[] { new String[] {
@ -95,7 +95,7 @@ public class ResourceLoader {
} }
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
Int2ObjectMap map = GenshinData.getMapByResourceDef(resourceDefinition); Int2ObjectMap map = GameData.getMapByResourceDef(resourceDefinition);
if (map == null) { if (map == null) {
continue; continue;
@ -123,7 +123,7 @@ public class ResourceLoader {
List list = Grasscutter.getGsonFactory().fromJson(fileReader, TypeToken.getParameterized(Collection.class, c).getType()); List list = Grasscutter.getGsonFactory().fromJson(fileReader, TypeToken.getParameterized(Collection.class, c).getType());
for (Object o : list) { for (Object o : list) {
GenshinResource res = (GenshinResource) o; GameResource res = (GameResource) o;
res.onLoad(); res.onLoad();
map.put(res.getId(), res); map.put(res.getId(), res);
} }
@ -170,7 +170,7 @@ public class ResourceLoader {
} }
for (ScenePointEntry entry : scenePointList) { for (ScenePointEntry entry : scenePointList) {
GenshinData.getScenePointEntries().put(entry.getName(), entry); GameData.getScenePointEntries().put(entry.getName(), entry);
} }
} }
} }
@ -233,7 +233,7 @@ public class ResourceLoader {
} }
for (AbilityEmbryoEntry entry : embryoList) { for (AbilityEmbryoEntry entry : embryoList) {
GenshinData.getAbilityEmbryoInfo().put(entry.getName(), entry); GameData.getAbilityEmbryoInfo().put(entry.getName(), entry);
} }
} }
@ -260,7 +260,7 @@ public class ResourceLoader {
entry.getSpawns().stream().forEach(s -> { entry.getSpawns().stream().forEach(s -> {
s.setGroup(entry); s.setGroup(entry);
}); });
GenshinDepot.getSpawnListById(entry.getSceneId()).insert(entry, entry.getPos().getX(), entry.getPos().getZ()); GameDepot.getSpawnListById(entry.getSceneId()).insert(entry, entry.getPos().getX(), entry.getPos().getZ());
} }
} }
@ -328,7 +328,7 @@ public class ResourceLoader {
} }
for (OpenConfigEntry entry : list) { for (OpenConfigEntry entry : list) {
GenshinData.getOpenConfigEntries().put(entry.getName(), entry); GameData.getOpenConfigEntries().put(entry.getName(), entry);
} }
} }

View File

@ -1,11 +1,11 @@
package emu.grasscutter.data.def; package emu.grasscutter.data.def;
import emu.grasscutter.data.GenshinData; import emu.grasscutter.data.GameData;
import emu.grasscutter.data.GenshinResource; import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType; import emu.grasscutter.data.ResourceType;
@ResourceType(name = "AvatarCostumeExcelConfigData.json") @ResourceType(name = "AvatarCostumeExcelConfigData.json")
public class AvatarCostumeData extends GenshinResource { public class AvatarCostumeData extends GameResource {
private int CostumeId; private int CostumeId;
private int ItemId; private int ItemId;
private int AvatarId; private int AvatarId;
@ -25,6 +25,6 @@ public class AvatarCostumeData extends GenshinResource {
@Override @Override
public void onLoad() { public void onLoad() {
GenshinData.getAvatarCostumeDataItemIdMap().put(this.getItemId(), this); GameData.getAvatarCostumeDataItemIdMap().put(this.getItemId(), this);
} }
} }

View File

@ -4,12 +4,12 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.stream.Stream; import java.util.stream.Stream;
import emu.grasscutter.data.GenshinResource; import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType; import emu.grasscutter.data.ResourceType;
import emu.grasscutter.data.common.CurveInfo; import emu.grasscutter.data.common.CurveInfo;
@ResourceType(name = "AvatarCurveExcelConfigData.json") @ResourceType(name = "AvatarCurveExcelConfigData.json")
public class AvatarCurveData extends GenshinResource { public class AvatarCurveData extends GameResource {
private int Level; private int Level;
private CurveInfo[] CurveInfos; private CurveInfo[] CurveInfos;

View File

@ -2,8 +2,8 @@ package emu.grasscutter.data.def;
import java.util.List; import java.util.List;
import emu.grasscutter.data.GenshinData; import emu.grasscutter.data.GameData;
import emu.grasscutter.data.GenshinResource; import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType; import emu.grasscutter.data.ResourceType;
import emu.grasscutter.data.ResourceType.LoadPriority; import emu.grasscutter.data.ResourceType.LoadPriority;
import emu.grasscutter.data.common.PropGrowCurve; import emu.grasscutter.data.common.PropGrowCurve;
@ -15,7 +15,7 @@ import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList; import it.unimi.dsi.fastutil.ints.IntList;
@ResourceType(name = "AvatarExcelConfigData.json", loadPriority = LoadPriority.LOW) @ResourceType(name = "AvatarExcelConfigData.json", loadPriority = LoadPriority.LOW)
public class AvatarData extends GenshinResource { public class AvatarData extends GameResource {
private String name; private String name;
private String IconName; private String IconName;
@ -178,7 +178,7 @@ public class AvatarData extends GenshinResource {
if (growCurve == null) { if (growCurve == null) {
return 1f; return 1f;
} }
AvatarCurveData curveData = GenshinData.getAvatarCurveDataMap().get(level); AvatarCurveData curveData = GameData.getAvatarCurveDataMap().get(level);
if (curveData == null) { if (curveData == null) {
return 1f; return 1f;
} }
@ -211,24 +211,24 @@ public class AvatarData extends GenshinResource {
@Override @Override
public void onLoad() { public void onLoad() {
this.skillDepot = GenshinData.getAvatarSkillDepotDataMap().get(this.SkillDepotId); this.skillDepot = GameData.getAvatarSkillDepotDataMap().get(this.SkillDepotId);
// Get fetters from GenshinData // Get fetters from GameData
this.fetters = GenshinData.getFetterDataEntries().get(this.Id); this.fetters = GameData.getFetterDataEntries().get(this.Id);
if (GenshinData.getFetterCharacterCardDataMap().get(this.Id) != null) { if (GameData.getFetterCharacterCardDataMap().get(this.Id) != null) {
this.nameCardRewardId = GenshinData.getFetterCharacterCardDataMap().get(this.Id).getRewardId(); this.nameCardRewardId = GameData.getFetterCharacterCardDataMap().get(this.Id).getRewardId();
} }
if (GenshinData.getRewardDataMap().get(this.nameCardRewardId) != null) { if (GameData.getRewardDataMap().get(this.nameCardRewardId) != null) {
this.nameCardId = GenshinData.getRewardDataMap().get(this.nameCardRewardId).getRewardItemList().get(0).getItemId(); this.nameCardId = GameData.getRewardDataMap().get(this.nameCardRewardId).getRewardItemList().get(0).getItemId();
} }
int size = GenshinData.getAvatarCurveDataMap().size(); int size = GameData.getAvatarCurveDataMap().size();
this.hpGrowthCurve = new float[size]; this.hpGrowthCurve = new float[size];
this.attackGrowthCurve = new float[size]; this.attackGrowthCurve = new float[size];
this.defenseGrowthCurve = new float[size]; this.defenseGrowthCurve = new float[size];
for (AvatarCurveData curveData : GenshinData.getAvatarCurveDataMap().values()) { for (AvatarCurveData curveData : GameData.getAvatarCurveDataMap().values()) {
int level = curveData.getLevel() - 1; int level = curveData.getLevel() - 1;
for (PropGrowCurve growCurve : this.PropGrowCurves) { for (PropGrowCurve growCurve : this.PropGrowCurves) {
FightProperty prop = FightProperty.getPropByName(growCurve.getType()); FightProperty prop = FightProperty.getPropByName(growCurve.getType());
@ -260,7 +260,7 @@ public class AvatarData extends GenshinResource {
if (split.length > 0) { if (split.length > 0) {
this.name = split[split.length - 1]; this.name = split[split.length - 1];
AbilityEmbryoEntry info = GenshinData.getAbilityEmbryoInfo().get(this.name); AbilityEmbryoEntry info = GameData.getAbilityEmbryoInfo().get(this.name);
if (info != null) { if (info != null) {
this.abilities = new IntArrayList(info.getAbilities().length); this.abilities = new IntArrayList(info.getAbilities().length);
for (String ability : info.getAbilities()) { for (String ability : info.getAbilities()) {

View File

@ -1,10 +1,10 @@
package emu.grasscutter.data.def; package emu.grasscutter.data.def;
import emu.grasscutter.data.GenshinResource; import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType; import emu.grasscutter.data.ResourceType;
@ResourceType(name = "AvatarFettersLevelExcelConfigData.json") @ResourceType(name = "AvatarFettersLevelExcelConfigData.json")
public class AvatarFetterLevelData extends GenshinResource { public class AvatarFetterLevelData extends GameResource {
private int FetterLevel; private int FetterLevel;
private int NeedExp; private int NeedExp;

View File

@ -1,10 +1,10 @@
package emu.grasscutter.data.def; package emu.grasscutter.data.def;
import emu.grasscutter.data.GenshinResource; import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType; import emu.grasscutter.data.ResourceType;
@ResourceType(name = "AvatarFlycloakExcelConfigData.json") @ResourceType(name = "AvatarFlycloakExcelConfigData.json")
public class AvatarFlycloakData extends GenshinResource { public class AvatarFlycloakData extends GameResource {
private int FlycloakId; private int FlycloakId;
private long NameTextMapHash; private long NameTextMapHash;

View File

@ -1,10 +1,10 @@
package emu.grasscutter.data.def; package emu.grasscutter.data.def;
import emu.grasscutter.data.GenshinResource; import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType; import emu.grasscutter.data.ResourceType;
@ResourceType(name = "AvatarLevelExcelConfigData.json") @ResourceType(name = "AvatarLevelExcelConfigData.json")
public class AvatarLevelData extends GenshinResource { public class AvatarLevelData extends GameResource {
private int Level; private int Level;
private int Exp; private int Exp;

View File

@ -1,13 +1,13 @@
package emu.grasscutter.data.def; package emu.grasscutter.data.def;
import java.util.ArrayList; import java.util.ArrayList;
import emu.grasscutter.data.GenshinResource; import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType; import emu.grasscutter.data.ResourceType;
import emu.grasscutter.data.common.FightPropData; import emu.grasscutter.data.common.FightPropData;
import emu.grasscutter.data.common.ItemParamData; import emu.grasscutter.data.common.ItemParamData;
@ResourceType(name = "AvatarPromoteExcelConfigData.json") @ResourceType(name = "AvatarPromoteExcelConfigData.json")
public class AvatarPromoteData extends GenshinResource { public class AvatarPromoteData extends GameResource {
private int AvatarPromoteId; private int AvatarPromoteId;
private int PromoteLevel; private int PromoteLevel;

View File

@ -2,12 +2,12 @@ package emu.grasscutter.data.def;
import java.util.List; import java.util.List;
import emu.grasscutter.data.GenshinResource; import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType; import emu.grasscutter.data.ResourceType;
import emu.grasscutter.data.ResourceType.LoadPriority; import emu.grasscutter.data.ResourceType.LoadPriority;
@ResourceType(name = "AvatarSkillExcelConfigData.json", loadPriority = LoadPriority.HIGHEST) @ResourceType(name = "AvatarSkillExcelConfigData.json", loadPriority = LoadPriority.HIGHEST)
public class AvatarSkillData extends GenshinResource { public class AvatarSkillData extends GameResource {
private int Id; private int Id;
private float CdTime; private float CdTime;
private int CostElemVal; private int CostElemVal;

View File

@ -2,8 +2,8 @@ package emu.grasscutter.data.def;
import java.util.List; import java.util.List;
import emu.grasscutter.data.GenshinData; import emu.grasscutter.data.GameData;
import emu.grasscutter.data.GenshinResource; import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType; import emu.grasscutter.data.ResourceType;
import emu.grasscutter.data.ResourceType.LoadPriority; import emu.grasscutter.data.ResourceType.LoadPriority;
import emu.grasscutter.data.custom.AbilityEmbryoEntry; import emu.grasscutter.data.custom.AbilityEmbryoEntry;
@ -13,7 +13,7 @@ import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList; import it.unimi.dsi.fastutil.ints.IntList;
@ResourceType(name = "AvatarSkillDepotExcelConfigData.json", loadPriority = LoadPriority.HIGH) @ResourceType(name = "AvatarSkillDepotExcelConfigData.json", loadPriority = LoadPriority.HIGH)
public class AvatarSkillDepotData extends GenshinResource { public class AvatarSkillDepotData extends GameResource {
private int Id; private int Id;
private int EnergySkill; private int EnergySkill;
@ -94,7 +94,7 @@ public class AvatarSkillDepotData extends GenshinResource {
@Override @Override
public void onLoad() { public void onLoad() {
this.energySkillData = GenshinData.getAvatarSkillDataMap().get(this.EnergySkill); this.energySkillData = GameData.getAvatarSkillDataMap().get(this.EnergySkill);
if (getEnergySkillData() != null) { if (getEnergySkillData() != null) {
this.elementType = ElementType.getTypeByName(getEnergySkillData().getCostElemType()); this.elementType = ElementType.getTypeByName(getEnergySkillData().getCostElemType());
} else { } else {

View File

@ -1,13 +1,13 @@
package emu.grasscutter.data.def; package emu.grasscutter.data.def;
import java.util.ArrayList; import java.util.ArrayList;
import emu.grasscutter.data.GenshinResource; import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType; import emu.grasscutter.data.ResourceType;
import emu.grasscutter.data.ResourceType.LoadPriority; import emu.grasscutter.data.ResourceType.LoadPriority;
import emu.grasscutter.data.common.FightPropData; import emu.grasscutter.data.common.FightPropData;
@ResourceType(name = "AvatarTalentExcelConfigData.json", loadPriority = LoadPriority.HIGHEST) @ResourceType(name = "AvatarTalentExcelConfigData.json", loadPriority = LoadPriority.HIGHEST)
public class AvatarTalentData extends GenshinResource { public class AvatarTalentData extends GameResource {
private int TalentId; private int TalentId;
private int PrevTalent; private int PrevTalent;
private long NameTextMapHash; private long NameTextMapHash;

View File

@ -1,12 +1,12 @@
package emu.grasscutter.data.def; package emu.grasscutter.data.def;
import java.util.ArrayList; import java.util.ArrayList;
import emu.grasscutter.data.GenshinResource; import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType; import emu.grasscutter.data.ResourceType;
import emu.grasscutter.data.common.FightPropData; import emu.grasscutter.data.common.FightPropData;
@ResourceType(name = "EquipAffixExcelConfigData.json") @ResourceType(name = "EquipAffixExcelConfigData.json")
public class EquipAffixData extends GenshinResource { public class EquipAffixData extends GameResource {
private int AffixId; private int AffixId;
private int Id; private int Id;

View File

@ -1,11 +1,11 @@
package emu.grasscutter.data.def; package emu.grasscutter.data.def;
import emu.grasscutter.data.GenshinResource; import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType; import emu.grasscutter.data.ResourceType;
import emu.grasscutter.data.ResourceType.LoadPriority; import emu.grasscutter.data.ResourceType.LoadPriority;
@ResourceType(name = "FetterCharacterCardExcelConfigData.json", loadPriority = LoadPriority.HIGHEST) @ResourceType(name = "FetterCharacterCardExcelConfigData.json", loadPriority = LoadPriority.HIGHEST)
public class FetterCharacterCardData extends GenshinResource { public class FetterCharacterCardData extends GameResource {
private int AvatarId; private int AvatarId;
private int RewardId; private int RewardId;

View File

@ -2,13 +2,13 @@ package emu.grasscutter.data.def;
import java.util.List; import java.util.List;
import emu.grasscutter.data.GenshinResource; import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType; import emu.grasscutter.data.ResourceType;
import emu.grasscutter.data.ResourceType.LoadPriority; import emu.grasscutter.data.ResourceType.LoadPriority;
import emu.grasscutter.data.common.OpenCondData; import emu.grasscutter.data.common.OpenCondData;
@ResourceType(name = {"FetterInfoExcelConfigData.json", "FettersExcelConfigData.json", "FetterStoryExcelConfigData.json"}, loadPriority = LoadPriority.HIGHEST) @ResourceType(name = {"FetterInfoExcelConfigData.json", "FettersExcelConfigData.json", "FetterStoryExcelConfigData.json"}, loadPriority = LoadPriority.HIGHEST)
public class FetterData extends GenshinResource { public class FetterData extends GameResource {
private int AvatarId; private int AvatarId;
private int FetterId; private int FetterId;
private List<OpenCondData> OpenCond; private List<OpenCondData> OpenCond;

View File

@ -1,10 +1,10 @@
package emu.grasscutter.data.def; package emu.grasscutter.data.def;
import emu.grasscutter.data.GenshinResource; import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType; import emu.grasscutter.data.ResourceType;
@ResourceType(name = "GadgetExcelConfigData.json") @ResourceType(name = "GadgetExcelConfigData.json")
public class GadgetData extends GenshinResource { public class GadgetData extends GameResource {
private int Id; private int Id;
private String Type; private String Type;

View File

@ -1,13 +1,13 @@
package emu.grasscutter.data.def; package emu.grasscutter.data.def;
import emu.grasscutter.data.GenshinResource; import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType; import emu.grasscutter.data.ResourceType;
import emu.grasscutter.game.props.FightProperty; import emu.grasscutter.game.props.FightProperty;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet; import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import it.unimi.dsi.fastutil.ints.IntSet; import it.unimi.dsi.fastutil.ints.IntSet;
@ResourceType(name = {"MaterialExcelConfigData.json", "WeaponExcelConfigData.json", "ReliquaryExcelConfigData.json"}) @ResourceType(name = {"MaterialExcelConfigData.json", "WeaponExcelConfigData.json", "ReliquaryExcelConfigData.json"})
public class ItemData extends GenshinResource { public class ItemData extends GameResource {
private int Id; private int Id;
private int StackLimit = 1; private int StackLimit = 1;

View File

@ -4,12 +4,12 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.stream.Stream; import java.util.stream.Stream;
import emu.grasscutter.data.GenshinResource; import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType; import emu.grasscutter.data.ResourceType;
import emu.grasscutter.data.common.CurveInfo; import emu.grasscutter.data.common.CurveInfo;
@ResourceType(name = "MonsterCurveExcelConfigData.json") @ResourceType(name = "MonsterCurveExcelConfigData.json")
public class MonsterCurveData extends GenshinResource { public class MonsterCurveData extends GameResource {
private int Level; private int Level;
private CurveInfo[] CurveInfos; private CurveInfo[] CurveInfos;

View File

@ -2,14 +2,14 @@ package emu.grasscutter.data.def;
import java.util.List; import java.util.List;
import emu.grasscutter.data.GenshinData; import emu.grasscutter.data.GameData;
import emu.grasscutter.data.GenshinResource; import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType; import emu.grasscutter.data.ResourceType;
import emu.grasscutter.data.ResourceType.LoadPriority; import emu.grasscutter.data.ResourceType.LoadPriority;
import emu.grasscutter.data.common.PropGrowCurve; import emu.grasscutter.data.common.PropGrowCurve;
@ResourceType(name = "MonsterExcelConfigData.json", loadPriority = LoadPriority.LOW) @ResourceType(name = "MonsterExcelConfigData.json", loadPriority = LoadPriority.LOW)
public class MonsterData extends GenshinResource { public class MonsterData extends GameResource {
private int Id; private int Id;
private String MonsterName; private String MonsterName;
@ -168,13 +168,13 @@ public class MonsterData extends GenshinResource {
@Override @Override
public void onLoad() { public void onLoad() {
this.describeData = GenshinData.getMonsterDescribeDataMap().get(this.getDescribeId()); this.describeData = GameData.getMonsterDescribeDataMap().get(this.getDescribeId());
for (int id : this.Equips) { for (int id : this.Equips) {
if (id == 0) { if (id == 0) {
continue; continue;
} }
GadgetData gadget = GenshinData.getGadgetDataMap().get(id); GadgetData gadget = GameData.getGadgetDataMap().get(id);
if (gadget == null) { if (gadget == null) {
continue; continue;
} }

View File

@ -1,11 +1,11 @@
package emu.grasscutter.data.def; package emu.grasscutter.data.def;
import emu.grasscutter.data.GenshinResource; import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType; import emu.grasscutter.data.ResourceType;
import emu.grasscutter.data.ResourceType.LoadPriority; import emu.grasscutter.data.ResourceType.LoadPriority;
@ResourceType(name = "MonsterDescribeExcelConfigData.json", loadPriority = LoadPriority.HIGH) @ResourceType(name = "MonsterDescribeExcelConfigData.json", loadPriority = LoadPriority.HIGH)
public class MonsterDescribeData extends GenshinResource { public class MonsterDescribeData extends GameResource {
private int Id; private int Id;
private long NameTextMapHash; private long NameTextMapHash;
private int TitleID; private int TitleID;

View File

@ -1,10 +1,10 @@
package emu.grasscutter.data.def; package emu.grasscutter.data.def;
import emu.grasscutter.data.GenshinResource; import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType; import emu.grasscutter.data.ResourceType;
@ResourceType(name = "NpcExcelConfigData.json") @ResourceType(name = "NpcExcelConfigData.json")
public class NpcData extends GenshinResource { public class NpcData extends GameResource {
private int Id; private int Id;
private String JsonName; private String JsonName;

View File

@ -1,10 +1,10 @@
package emu.grasscutter.data.def; package emu.grasscutter.data.def;
import emu.grasscutter.data.GenshinResource; import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType; import emu.grasscutter.data.ResourceType;
@ResourceType(name = "PlayerLevelExcelConfigData.json") @ResourceType(name = "PlayerLevelExcelConfigData.json")
public class PlayerLevelData extends GenshinResource { public class PlayerLevelData extends GameResource {
private int Level; private int Level;
private int Exp; private int Exp;
private int RewardId; private int RewardId;

View File

@ -3,13 +3,13 @@ package emu.grasscutter.data.def;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import emu.grasscutter.data.GenshinResource; import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType; import emu.grasscutter.data.ResourceType;
import emu.grasscutter.data.common.FightPropData; import emu.grasscutter.data.common.FightPropData;
import emu.grasscutter.data.common.ItemParamData; import emu.grasscutter.data.common.ItemParamData;
@ResourceType(name = "ProudSkillExcelConfigData.json") @ResourceType(name = "ProudSkillExcelConfigData.json")
public class ProudSkillData extends GenshinResource { public class ProudSkillData extends GameResource {
private int ProudSkillId; private int ProudSkillId;
private int ProudSkillGroupId; private int ProudSkillGroupId;

View File

@ -1,11 +1,11 @@
package emu.grasscutter.data.def; package emu.grasscutter.data.def;
import emu.grasscutter.data.GenshinResource; import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType; import emu.grasscutter.data.ResourceType;
import emu.grasscutter.game.props.FightProperty; import emu.grasscutter.game.props.FightProperty;
@ResourceType(name = "ReliquaryAffixExcelConfigData.json") @ResourceType(name = "ReliquaryAffixExcelConfigData.json")
public class ReliquaryAffixData extends GenshinResource { public class ReliquaryAffixData extends GameResource {
private int Id; private int Id;
private int DepotId; private int DepotId;

View File

@ -2,14 +2,14 @@ package emu.grasscutter.data.def;
import java.util.List; import java.util.List;
import emu.grasscutter.data.GenshinResource; import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType; import emu.grasscutter.data.ResourceType;
import emu.grasscutter.game.props.FightProperty; import emu.grasscutter.game.props.FightProperty;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
@ResourceType(name = "ReliquaryLevelExcelConfigData.json") @ResourceType(name = "ReliquaryLevelExcelConfigData.json")
public class ReliquaryLevelData extends GenshinResource { public class ReliquaryLevelData extends GameResource {
private int id; private int id;
private Int2ObjectMap<Float> propMap; private Int2ObjectMap<Float> propMap;

View File

@ -1,11 +1,11 @@
package emu.grasscutter.data.def; package emu.grasscutter.data.def;
import emu.grasscutter.data.GenshinResource; import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType; import emu.grasscutter.data.ResourceType;
import emu.grasscutter.game.props.FightProperty; import emu.grasscutter.game.props.FightProperty;
@ResourceType(name = "ReliquaryMainPropExcelConfigData.json") @ResourceType(name = "ReliquaryMainPropExcelConfigData.json")
public class ReliquaryMainPropData extends GenshinResource { public class ReliquaryMainPropData extends GameResource {
private int Id; private int Id;
private int PropDepotId; private int PropDepotId;

View File

@ -1,10 +1,10 @@
package emu.grasscutter.data.def; package emu.grasscutter.data.def;
import emu.grasscutter.data.GenshinResource; import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType; import emu.grasscutter.data.ResourceType;
@ResourceType(name = "ReliquarySetExcelConfigData.json") @ResourceType(name = "ReliquarySetExcelConfigData.json")
public class ReliquarySetData extends GenshinResource { public class ReliquarySetData extends GameResource {
private int SetId; private int SetId;
private int[] SetNeedNum; private int[] SetNeedNum;
private int EquipAffixId; private int EquipAffixId;

View File

@ -2,12 +2,12 @@ package emu.grasscutter.data.def;
import java.util.List; import java.util.List;
import emu.grasscutter.data.GenshinResource; import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType; import emu.grasscutter.data.ResourceType;
import emu.grasscutter.data.common.RewardItemData; import emu.grasscutter.data.common.RewardItemData;
@ResourceType(name = "RewardExcelConfigData.json") @ResourceType(name = "RewardExcelConfigData.json")
public class RewardData extends GenshinResource { public class RewardData extends GameResource {
public int RewardId; public int RewardId;
public List<RewardItemData> RewardItemList; public List<RewardItemData> RewardItemList;

View File

@ -1,13 +1,13 @@
package emu.grasscutter.data.def; package emu.grasscutter.data.def;
import emu.grasscutter.data.GenshinData; import emu.grasscutter.data.GameData;
import emu.grasscutter.data.GenshinResource; import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType; import emu.grasscutter.data.ResourceType;
import emu.grasscutter.game.props.SceneType; import emu.grasscutter.game.props.SceneType;
@ResourceType(name = "SceneExcelConfigData.json") @ResourceType(name = "SceneExcelConfigData.json")
public class SceneData extends GenshinResource { public class SceneData extends GameResource {
private int Id; private int Id;
private SceneType SceneType; private SceneType SceneType;
private String ScriptData; private String ScriptData;

View File

@ -4,12 +4,12 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.stream.Stream; import java.util.stream.Stream;
import emu.grasscutter.data.GenshinResource; import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType; import emu.grasscutter.data.ResourceType;
import emu.grasscutter.data.common.CurveInfo; import emu.grasscutter.data.common.CurveInfo;
@ResourceType(name = "WeaponCurveExcelConfigData.json") @ResourceType(name = "WeaponCurveExcelConfigData.json")
public class WeaponCurveData extends GenshinResource { public class WeaponCurveData extends GameResource {
private int Level; private int Level;
private CurveInfo[] CurveInfos; private CurveInfo[] CurveInfos;

View File

@ -1,10 +1,10 @@
package emu.grasscutter.data.def; package emu.grasscutter.data.def;
import emu.grasscutter.data.GenshinResource; import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType; import emu.grasscutter.data.ResourceType;
@ResourceType(name = "WeaponLevelExcelConfigData.json") @ResourceType(name = "WeaponLevelExcelConfigData.json")
public class WeaponLevelData extends GenshinResource { public class WeaponLevelData extends GameResource {
private int Level; private int Level;
private int[] RequiredExps; private int[] RequiredExps;

View File

@ -1,13 +1,13 @@
package emu.grasscutter.data.def; package emu.grasscutter.data.def;
import java.util.ArrayList; import java.util.ArrayList;
import emu.grasscutter.data.GenshinResource; import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType; import emu.grasscutter.data.ResourceType;
import emu.grasscutter.data.common.FightPropData; import emu.grasscutter.data.common.FightPropData;
import emu.grasscutter.data.common.ItemParamData; import emu.grasscutter.data.common.ItemParamData;
@ResourceType(name = "WeaponPromoteExcelConfigData.json") @ResourceType(name = "WeaponPromoteExcelConfigData.json")
public class WeaponPromoteData extends GenshinResource { public class WeaponPromoteData extends GameResource {
private int WeaponPromoteId; private int WeaponPromoteId;
private int PromoteLevel; private int PromoteLevel;

View File

@ -1,10 +1,10 @@
package emu.grasscutter.data.def; package emu.grasscutter.data.def;
import emu.grasscutter.data.GenshinResource; import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.ResourceType; import emu.grasscutter.data.ResourceType;
@ResourceType(name = "WorldLevelExcelConfigData.json") @ResourceType(name = "WorldLevelExcelConfigData.json")
public class WorldLevelData extends GenshinResource { public class WorldLevelData extends GameResource {
private int Level; private int Level;
private int MonsterLevel; private int MonsterLevel;

View File

@ -4,12 +4,12 @@ import java.util.List;
import com.mongodb.client.result.DeleteResult; import com.mongodb.client.result.DeleteResult;
import dev.morphia.query.experimental.filters.Filters; import dev.morphia.query.experimental.filters.Filters;
import emu.grasscutter.GenshinConstants; import emu.grasscutter.GameConstants;
import emu.grasscutter.game.Account; import emu.grasscutter.game.Account;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import emu.grasscutter.game.avatar.GenshinAvatar; import emu.grasscutter.game.avatar.Avatar;
import emu.grasscutter.game.friends.Friendship; import emu.grasscutter.game.friends.Friendship;
import emu.grasscutter.game.inventory.GenshinItem; import emu.grasscutter.game.inventory.GameItem;
public final class DatabaseHelper { public final class DatabaseHelper {
public static Account createAccount(String username) { public static Account createAccount(String username) {
@ -26,7 +26,7 @@ public final class DatabaseHelper {
// Make sure there are no id collisions // Make sure there are no id collisions
if (reservedId > 0) { if (reservedId > 0) {
// Cannot make account with the same uid as the server console // Cannot make account with the same uid as the server console
if (reservedId == GenshinConstants.SERVER_CONSOLE_UID) { if (reservedId == GameConstants.SERVER_CONSOLE_UID) {
return null; return null;
} }
exists = DatabaseHelper.getAccountByPlayerId(reservedId); exists = DatabaseHelper.getAccountByPlayerId(reservedId);
@ -90,19 +90,19 @@ public final class DatabaseHelper {
return DatabaseManager.getDatastore().find(Account.class).filter(Filters.eq("username", username)).delete().getDeletedCount() > 0; return DatabaseManager.getDatastore().find(Account.class).filter(Filters.eq("username", username)).delete().getDeletedCount() > 0;
} }
public static List<GenshinPlayer> getAllPlayers() { public static List<Player> getAllPlayers() {
return DatabaseManager.getDatastore().find(GenshinPlayer.class).stream().toList(); return DatabaseManager.getDatastore().find(Player.class).stream().toList();
} }
public static GenshinPlayer getPlayerById(int id) { public static Player getPlayerById(int id) {
return DatabaseManager.getDatastore().find(GenshinPlayer.class).filter(Filters.eq("_id", id)).first(); return DatabaseManager.getDatastore().find(Player.class).filter(Filters.eq("_id", id)).first();
} }
public static boolean checkPlayerExists(int id) { public static boolean checkPlayerExists(int id) {
return DatabaseManager.getDatastore().find(GenshinPlayer.class).filter(Filters.eq("_id", id)).first() != null; return DatabaseManager.getDatastore().find(Player.class).filter(Filters.eq("_id", id)).first() != null;
} }
public static synchronized GenshinPlayer createPlayer(GenshinPlayer character, int reservedId) { public static synchronized Player createPlayer(Player character, int reservedId) {
// Check if reserved id // Check if reserved id
int id; int id;
if (reservedId > 0 && !checkPlayerExists(reservedId)) { if (reservedId > 0 && !checkPlayerExists(reservedId)) {
@ -127,42 +127,42 @@ public final class DatabaseHelper {
id = reservedId; id = reservedId;
} else { } else {
do { do {
id = DatabaseManager.getNextId(GenshinPlayer.class); id = DatabaseManager.getNextId(Player.class);
} }
while (checkPlayerExists(id)); while (checkPlayerExists(id));
} }
return id; return id;
} }
public static void savePlayer(GenshinPlayer character) { public static void savePlayer(Player character) {
DatabaseManager.getDatastore().save(character); DatabaseManager.getDatastore().save(character);
} }
public static void saveAvatar(GenshinAvatar avatar) { public static void saveAvatar(Avatar avatar) {
DatabaseManager.getDatastore().save(avatar); DatabaseManager.getDatastore().save(avatar);
} }
public static List<GenshinAvatar> getAvatars(GenshinPlayer player) { public static List<Avatar> getAvatars(Player player) {
return DatabaseManager.getDatastore().find(GenshinAvatar.class).filter(Filters.eq("ownerId", player.getUid())).stream().toList(); return DatabaseManager.getDatastore().find(Avatar.class).filter(Filters.eq("ownerId", player.getUid())).stream().toList();
} }
public static void saveItem(GenshinItem item) { public static void saveItem(GameItem item) {
DatabaseManager.getDatastore().save(item); DatabaseManager.getDatastore().save(item);
} }
public static boolean deleteItem(GenshinItem item) { public static boolean deleteItem(GameItem item) {
DeleteResult result = DatabaseManager.getDatastore().delete(item); DeleteResult result = DatabaseManager.getDatastore().delete(item);
return result.wasAcknowledged(); return result.wasAcknowledged();
} }
public static List<GenshinItem> getInventoryItems(GenshinPlayer player) { public static List<GameItem> getInventoryItems(Player player) {
return DatabaseManager.getDatastore().find(GenshinItem.class).filter(Filters.eq("ownerId", player.getUid())).stream().toList(); return DatabaseManager.getDatastore().find(GameItem.class).filter(Filters.eq("ownerId", player.getUid())).stream().toList();
} }
public static List<Friendship> getFriends(GenshinPlayer player) { public static List<Friendship> getFriends(Player player) {
return DatabaseManager.getDatastore().find(Friendship.class).filter(Filters.eq("ownerId", player.getUid())).stream().toList(); return DatabaseManager.getDatastore().find(Friendship.class).filter(Filters.eq("ownerId", player.getUid())).stream().toList();
} }
public static List<Friendship> getReverseFriends(GenshinPlayer player) { public static List<Friendship> getReverseFriends(Player player) {
return DatabaseManager.getDatastore().find(Friendship.class).filter(Filters.eq("friendId", player.getUid())).stream().toList(); return DatabaseManager.getDatastore().find(Friendship.class).filter(Filters.eq("friendId", player.getUid())).stream().toList();
} }

View File

@ -13,10 +13,10 @@ import dev.morphia.mapping.MapperOptions;
import dev.morphia.query.experimental.filters.Filters; import dev.morphia.query.experimental.filters.Filters;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
import emu.grasscutter.game.Account; import emu.grasscutter.game.Account;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import emu.grasscutter.game.avatar.GenshinAvatar; import emu.grasscutter.game.avatar.Avatar;
import emu.grasscutter.game.friends.Friendship; import emu.grasscutter.game.friends.Friendship;
import emu.grasscutter.game.inventory.GenshinItem; import emu.grasscutter.game.inventory.GameItem;
public final class DatabaseManager { public final class DatabaseManager {
@ -27,7 +27,7 @@ public final class DatabaseManager {
private static Datastore dispatchDatastore; private static Datastore dispatchDatastore;
private static final Class<?>[] mappedClasses = new Class<?>[] { private static final Class<?>[] mappedClasses = new Class<?>[] {
DatabaseCounter.class, Account.class, GenshinPlayer.class, GenshinAvatar.class, GenshinItem.class, Friendship.class DatabaseCounter.class, Account.class, Player.class, Avatar.class, GameItem.class, Friendship.class
}; };
public static Datastore getDatastore() { public static Datastore getDatastore() {

View File

@ -1,17 +1,17 @@
package emu.grasscutter.game; package emu.grasscutter.game;
public class CoopRequest { public class CoopRequest {
private final GenshinPlayer requester; private final Player requester;
private final long requestTime; private final long requestTime;
private final long expireTime; private final long expireTime;
public CoopRequest(GenshinPlayer requester) { public CoopRequest(Player requester) {
this.requester = requester; this.requester = requester;
this.requestTime = System.currentTimeMillis(); this.requestTime = System.currentTimeMillis();
this.expireTime = this.requestTime + 10000; this.expireTime = this.requestTime + 10000;
} }
public GenshinPlayer getRequester() { public Player getRequester() {
return requester; return requester;
} }

View File

@ -2,16 +2,16 @@ package emu.grasscutter.game;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.proto.ForwardTypeOuterClass.ForwardType; import emu.grasscutter.net.proto.ForwardTypeOuterClass.ForwardType;
public class InvokeHandler<T> { public class InvokeHandler<T> {
private final List<T> entryListForwardAll; private final List<T> entryListForwardAll;
private final List<T> entryListForwardAllExceptCur; private final List<T> entryListForwardAllExceptCur;
private final List<T> entryListForwardHost; private final List<T> entryListForwardHost;
private final Class<? extends GenshinPacket> packetClass; private final Class<? extends BasePacket> packetClass;
public InvokeHandler(Class<? extends GenshinPacket> packetClass) { public InvokeHandler(Class<? extends BasePacket> packetClass) {
this.entryListForwardAll = new ArrayList<>(); this.entryListForwardAll = new ArrayList<>();
this.entryListForwardAllExceptCur = new ArrayList<>(); this.entryListForwardAllExceptCur = new ArrayList<>();
this.entryListForwardHost = new ArrayList<>(); this.entryListForwardHost = new ArrayList<>();
@ -28,7 +28,7 @@ public class InvokeHandler<T> {
} }
} }
public synchronized void update(GenshinPlayer player) { public synchronized void update(Player player) {
if (player.getWorld() == null) { if (player.getWorld() == null) {
this.entryListForwardAll.clear(); this.entryListForwardAll.clear();
this.entryListForwardAllExceptCur.clear(); this.entryListForwardAllExceptCur.clear();
@ -38,17 +38,17 @@ public class InvokeHandler<T> {
try { try {
if (entryListForwardAll.size() > 0) { if (entryListForwardAll.size() > 0) {
GenshinPacket packet = packetClass.getDeclaredConstructor(List.class).newInstance(this.entryListForwardAll); BasePacket packet = packetClass.getDeclaredConstructor(List.class).newInstance(this.entryListForwardAll);
player.getScene().broadcastPacket(packet); player.getScene().broadcastPacket(packet);
this.entryListForwardAll.clear(); this.entryListForwardAll.clear();
} }
if (entryListForwardAllExceptCur.size() > 0) { if (entryListForwardAllExceptCur.size() > 0) {
GenshinPacket packet = packetClass.getDeclaredConstructor(List.class).newInstance(this.entryListForwardAllExceptCur); BasePacket packet = packetClass.getDeclaredConstructor(List.class).newInstance(this.entryListForwardAllExceptCur);
player.getScene().broadcastPacketToOthers(player, packet); player.getScene().broadcastPacketToOthers(player, packet);
this.entryListForwardAllExceptCur.clear(); this.entryListForwardAllExceptCur.clear();
} }
if (entryListForwardHost.size() > 0) { if (entryListForwardHost.size() > 0) {
GenshinPacket packet = packetClass.getDeclaredConstructor(List.class).newInstance(this.entryListForwardHost); BasePacket packet = packetClass.getDeclaredConstructor(List.class).newInstance(this.entryListForwardHost);
player.getWorld().getHost().sendPacket(packet); player.getWorld().getHost().sendPacket(packet);
this.entryListForwardHost.clear(); this.entryListForwardHost.clear();
} }

View File

@ -57,7 +57,7 @@ public class Mail {
this(title, content, "Server"); this(title, content, "Server");
} }
public MailContent(String title, String content, GenshinPlayer sender) { public MailContent(String title, String content, Player sender) {
this(title, content, sender.getNickname()); this(title, content, sender.getNickname());
} }

View File

@ -4,26 +4,26 @@ import java.time.Instant;
import java.util.*; import java.util.*;
import dev.morphia.annotations.*; import dev.morphia.annotations.*;
import emu.grasscutter.GenshinConstants; import emu.grasscutter.GameConstants;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.CommandHandler; import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.data.GenshinData; import emu.grasscutter.data.GameData;
import emu.grasscutter.data.def.PlayerLevelData; import emu.grasscutter.data.def.PlayerLevelData;
import emu.grasscutter.database.DatabaseHelper; import emu.grasscutter.database.DatabaseHelper;
import emu.grasscutter.game.avatar.AvatarProfileData; import emu.grasscutter.game.avatar.AvatarProfileData;
import emu.grasscutter.game.avatar.AvatarStorage; import emu.grasscutter.game.avatar.AvatarStorage;
import emu.grasscutter.game.avatar.GenshinAvatar; import emu.grasscutter.game.avatar.Avatar;
import emu.grasscutter.game.entity.EntityItem; import emu.grasscutter.game.entity.EntityItem;
import emu.grasscutter.game.entity.GenshinEntity; import emu.grasscutter.game.entity.GameEntity;
import emu.grasscutter.game.friends.FriendsList; import emu.grasscutter.game.friends.FriendsList;
import emu.grasscutter.game.friends.PlayerProfile; import emu.grasscutter.game.friends.PlayerProfile;
import emu.grasscutter.game.gacha.PlayerGachaInfo; import emu.grasscutter.game.gacha.PlayerGachaInfo;
import emu.grasscutter.game.inventory.GenshinItem; import emu.grasscutter.game.inventory.GameItem;
import emu.grasscutter.game.inventory.Inventory; import emu.grasscutter.game.inventory.Inventory;
import emu.grasscutter.game.player.PlayerBirthday; import emu.grasscutter.game.player.PlayerBirthday;
import emu.grasscutter.game.props.ActionReason; import emu.grasscutter.game.props.ActionReason;
import emu.grasscutter.game.props.PlayerProperty; import emu.grasscutter.game.props.PlayerProperty;
import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.proto.AbilityInvokeEntryOuterClass.AbilityInvokeEntry; import emu.grasscutter.net.proto.AbilityInvokeEntryOuterClass.AbilityInvokeEntry;
import emu.grasscutter.net.proto.CombatInvokeEntryOuterClass.CombatInvokeEntry; import emu.grasscutter.net.proto.CombatInvokeEntryOuterClass.CombatInvokeEntry;
import emu.grasscutter.net.proto.HeadImageOuterClass.HeadImage; import emu.grasscutter.net.proto.HeadImageOuterClass.HeadImage;
@ -46,7 +46,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import java.util.*; import java.util.*;
@Entity(value = "players", useDiscriminator = false) @Entity(value = "players", useDiscriminator = false)
public class GenshinPlayer { public class Player {
@Id private int id; @Id private int id;
@Indexed(options = @IndexOptions(unique = true)) private String accountId; @Indexed(options = @IndexOptions(unique = true)) private String accountId;
@ -67,7 +67,7 @@ public class GenshinPlayer {
@Transient private long nextGuid = 0; @Transient private long nextGuid = 0;
@Transient private int peerId; @Transient private int peerId;
@Transient private World world; @Transient private World world;
@Transient private GenshinScene scene; @Transient private Scene scene;
@Transient private GameSession session; @Transient private GameSession session;
@Transient private AvatarStorage avatars; @Transient private AvatarStorage avatars;
@Transient private Inventory inventory; @Transient private Inventory inventory;
@ -104,7 +104,7 @@ public class GenshinPlayer {
@Deprecated @Deprecated
@SuppressWarnings({"rawtypes", "unchecked"}) // Morphia only! @SuppressWarnings({"rawtypes", "unchecked"}) // Morphia only!
public GenshinPlayer() { public Player() {
this.inventory = new Inventory(this); this.inventory = new Inventory(this);
this.avatars = new AvatarStorage(this); this.avatars = new AvatarStorage(this);
this.friendsList = new FriendsList(this); this.friendsList = new FriendsList(this);
@ -140,7 +140,7 @@ public class GenshinPlayer {
} }
// On player creation // On player creation
public GenshinPlayer(GameSession session) { public Player(GameSession session) {
this(); this();
this.account = session.getAccount(); this.account = session.getAccount();
this.accountId = this.getAccount().getId(); this.accountId = this.getAccount().getId();
@ -159,7 +159,7 @@ public class GenshinPlayer {
this.setProperty(PlayerProperty.PROP_PLAYER_RESIN, 160); this.setProperty(PlayerProperty.PROP_PLAYER_RESIN, 160);
this.getFlyCloakList().add(140001); this.getFlyCloakList().add(140001);
this.getNameCardList().add(210001); this.getNameCardList().add(210001);
this.getPos().set(GenshinConstants.START_POSITION); this.getPos().set(GameConstants.START_POSITION);
this.getRotation().set(0, 307, 0); this.getRotation().set(0, 307, 0);
} }
@ -171,7 +171,7 @@ public class GenshinPlayer {
this.id = id; this.id = id;
} }
public long getNextGenshinGuid() { public long getNextGameGuid() {
long nextId = ++this.nextGuid; long nextId = ++this.nextGuid;
return ((long) this.getUid() << 32) + nextId; return ((long) this.getUid() << 32) + nextId;
} }
@ -209,11 +209,11 @@ public class GenshinPlayer {
this.world = world; this.world = world;
} }
public synchronized GenshinScene getScene() { public synchronized Scene getScene() {
return scene; return scene;
} }
public synchronized void setScene(GenshinScene scene) { public synchronized void setScene(Scene scene) {
this.scene = scene; this.scene = scene;
} }
@ -292,7 +292,7 @@ public class GenshinPlayer {
} }
private int getExpRequired(int level) { private int getExpRequired(int level) {
PlayerLevelData levelData = GenshinData.getPlayerLevelDataMap().get(level); PlayerLevelData levelData = GameData.getPlayerLevelDataMap().get(level);
return levelData != null ? levelData.getExp() : 0; return levelData != null ? levelData.getExp() : 0;
} }
@ -546,9 +546,9 @@ public class GenshinPlayer {
} }
public void rechargeMoonCard() { public void rechargeMoonCard() {
LinkedList<GenshinItem> items = new LinkedList<GenshinItem>(); LinkedList<GameItem> items = new LinkedList<GameItem>();
for (int i = 0; i < 300; i++) { for (int i = 0; i < 300; i++) {
items.add(new GenshinItem(203)); items.add(new GameItem(203));
} }
inventory.addItems(items); inventory.addItems(items);
if (!moonCard) { if (!moonCard) {
@ -583,8 +583,8 @@ public class GenshinPlayer {
} }
moonCardGetTimes.add(now); moonCardGetTimes.add(now);
addMoonCardDays(1); addMoonCardDays(1);
GenshinItem genshinItem = new GenshinItem(201, 90); GameItem item = new GameItem(201, 90);
getInventory().addItem(genshinItem, ActionReason.BlessingRedeemReward); getInventory().addItem(item, ActionReason.BlessingRedeemReward);
session.send(new PacketCardProductRewardNotify(getMoonCardRemainDays())); session.send(new PacketCardProductRewardNotify(getMoonCardRemainDays()));
} }
@ -604,29 +604,19 @@ public class GenshinPlayer {
this.hasSentAvatarDataNotify = hasSentAvatarDataNotify; this.hasSentAvatarDataNotify = hasSentAvatarDataNotify;
} }
public void addAvatar(GenshinAvatar avatar) { public void addAvatar(Avatar avatar) {
boolean result = getAvatars().addAvatar(avatar); boolean result = getAvatars().addAvatar(avatar);
if (result) { if (result) {
// Add starting weapon // Add starting weapon
getAvatars().addStartingWeapon(avatar); getAvatars().addStartingWeapon(avatar);
// Try adding to team if possible
//List<EntityAvatar> currentTeam = this.getTeamManager().getCurrentTeam();
boolean addedToTeam = false;
/*
if (currentTeam.size() <= GenshinConstants.MAX_AVATARS_IN_TEAM) {
addedToTeam = currentTeam
}
*/
// Done // Done
if (hasSentAvatarDataNotify()) { if (hasSentAvatarDataNotify()) {
// Recalc stats // Recalc stats
avatar.recalcStats(); avatar.recalcStats();
// Packet // Packet
sendPacket(new PacketAvatarAddNotify(avatar, addedToTeam)); sendPacket(new PacketAvatarAddNotify(avatar, false));
} }
} else { } else {
// Failed adding avatar // Failed adding avatar
@ -659,7 +649,7 @@ public class GenshinPlayer {
} }
public void dropMessage(Object message) { public void dropMessage(Object message) {
this.sendPacket(new PacketPrivateChatNotify(GenshinConstants.SERVER_CONSOLE_UID, getUid(), message.toString())); this.sendPacket(new PacketPrivateChatNotify(GameConstants.SERVER_CONSOLE_UID, getUid(), message.toString()));
} }
/** /**
@ -668,7 +658,7 @@ public class GenshinPlayer {
* @param sender The sender of the message. * @param sender The sender of the message.
* @param message The message to send. * @param message The message to send.
*/ */
public void sendMessage(GenshinPlayer sender, Object message) { public void sendMessage(Player sender, Object message) {
this.sendPacket(new PacketPrivateChatNotify(sender.getUid(), this.getUid(), message.toString())); this.sendPacket(new PacketPrivateChatNotify(sender.getUid(), this.getUid(), message.toString()));
} }
@ -714,7 +704,7 @@ public class GenshinPlayer {
} }
public void interactWith(int gadgetEntityId) { public void interactWith(int gadgetEntityId) {
GenshinEntity entity = getScene().getEntityById(gadgetEntityId); GameEntity entity = getScene().getEntityById(gadgetEntityId);
if (entity == null) { if (entity == null) {
return; return;
@ -727,7 +717,7 @@ public class GenshinPlayer {
if (entity instanceof EntityItem) { if (entity instanceof EntityItem) {
// Pick item // Pick item
EntityItem drop = (EntityItem) entity; EntityItem drop = (EntityItem) entity;
GenshinItem item = new GenshinItem(drop.getItemData(), drop.getCount()); GameItem item = new GameItem(drop.getItemData(), drop.getCount());
// Add to inventory // Add to inventory
boolean success = getInventory().addItem(item, ActionReason.SubfieldDrop); boolean success = getInventory().addItem(item, ActionReason.SubfieldDrop);
if (success) { if (success) {
@ -746,7 +736,7 @@ public class GenshinPlayer {
} }
public void sendPacket(GenshinPacket packet) { public void sendPacket(BasePacket packet) {
if (this.hasSentAvatarDataNotify) { if (this.hasSentAvatarDataNotify) {
this.getSession().send(packet); this.getSession().send(packet);
} }
@ -875,7 +865,7 @@ public class GenshinPlayer {
// Check if player object exists in server // Check if player object exists in server
// TODO - optimize // TODO - optimize
GenshinPlayer exists = this.getServer().getPlayerByUid(getUid()); Player exists = this.getServer().getPlayerByUid(getUid());
if (exists != null) { if (exists != null) {
exists.getSession().close(); exists.getSession().close();
} }

View File

@ -12,9 +12,9 @@ import java.util.Set;
import org.danilopianini.util.SpatialIndex; import org.danilopianini.util.SpatialIndex;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
import emu.grasscutter.data.GenshinData; import emu.grasscutter.data.GameData;
import emu.grasscutter.data.GenshinDepot; import emu.grasscutter.data.GameDepot;
import emu.grasscutter.data.GenshinResource; import emu.grasscutter.data.GameResource;
import emu.grasscutter.data.def.MonsterData; import emu.grasscutter.data.def.MonsterData;
import emu.grasscutter.data.def.SceneData; import emu.grasscutter.data.def.SceneData;
import emu.grasscutter.data.def.WorldLevelData; import emu.grasscutter.data.def.WorldLevelData;
@ -22,14 +22,14 @@ import emu.grasscutter.game.entity.EntityAvatar;
import emu.grasscutter.game.entity.EntityClientGadget; import emu.grasscutter.game.entity.EntityClientGadget;
import emu.grasscutter.game.entity.EntityGadget; import emu.grasscutter.game.entity.EntityGadget;
import emu.grasscutter.game.entity.EntityMonster; import emu.grasscutter.game.entity.EntityMonster;
import emu.grasscutter.game.entity.GenshinEntity; import emu.grasscutter.game.entity.GameEntity;
import emu.grasscutter.game.props.ClimateType; import emu.grasscutter.game.props.ClimateType;
import emu.grasscutter.game.props.FightProperty; import emu.grasscutter.game.props.FightProperty;
import emu.grasscutter.game.props.LifeState; import emu.grasscutter.game.props.LifeState;
import emu.grasscutter.game.props.SceneType; import emu.grasscutter.game.props.SceneType;
import emu.grasscutter.game.world.SpawnDataEntry; import emu.grasscutter.game.world.SpawnDataEntry;
import emu.grasscutter.game.world.SpawnDataEntry.SpawnGroupEntry; import emu.grasscutter.game.world.SpawnDataEntry.SpawnGroupEntry;
import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.proto.AttackResultOuterClass.AttackResult; import emu.grasscutter.net.proto.AttackResultOuterClass.AttackResult;
import emu.grasscutter.net.proto.VisionTypeOuterClass.VisionType; import emu.grasscutter.net.proto.VisionTypeOuterClass.VisionType;
import emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify; import emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify;
@ -41,11 +41,11 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectMaps; import it.unimi.dsi.fastutil.ints.Int2ObjectMaps;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
public class GenshinScene { public class Scene {
private final World world; private final World world;
private final SceneData sceneData; private final SceneData sceneData;
private final List<GenshinPlayer> players; private final List<Player> players;
private final Int2ObjectMap<GenshinEntity> entities; private final Int2ObjectMap<GameEntity> entities;
private final Set<SpawnDataEntry> spawnedEntities; private final Set<SpawnDataEntry> spawnedEntities;
private final Set<SpawnDataEntry> deadSpawnedEntities; private final Set<SpawnDataEntry> deadSpawnedEntities;
@ -55,7 +55,7 @@ public class GenshinScene {
private ClimateType climate; private ClimateType climate;
private int weather; private int weather;
public GenshinScene(World world, SceneData sceneData) { public Scene(World world, SceneData sceneData) {
this.world = world; this.world = world;
this.sceneData = sceneData; this.sceneData = sceneData;
this.players = Collections.synchronizedList(new ArrayList<>()); this.players = Collections.synchronizedList(new ArrayList<>());
@ -84,7 +84,7 @@ public class GenshinScene {
return getSceneData().getSceneType(); return getSceneData().getSceneType();
} }
public List<GenshinPlayer> getPlayers() { public List<Player> getPlayers() {
return players; return players;
} }
@ -92,11 +92,11 @@ public class GenshinScene {
return this.getPlayers().size(); return this.getPlayers().size();
} }
public Int2ObjectMap<GenshinEntity> getEntities() { public Int2ObjectMap<GameEntity> getEntities() {
return entities; return entities;
} }
public GenshinEntity getEntityById(int id) { public GameEntity getEntityById(int id) {
return this.entities.get(id); return this.entities.get(id);
} }
@ -140,11 +140,11 @@ public class GenshinScene {
return deadSpawnedEntities; return deadSpawnedEntities;
} }
public boolean isInScene(GenshinEntity entity) { public boolean isInScene(GameEntity entity) {
return this.entities.containsKey(entity.getId()); return this.entities.containsKey(entity.getId());
} }
public synchronized void addPlayer(GenshinPlayer player) { public synchronized void addPlayer(Player player) {
// Check if player already in // Check if player already in
if (getPlayers().contains(player)) { if (getPlayers().contains(player)) {
return; return;
@ -163,7 +163,7 @@ public class GenshinScene {
this.setupPlayerAvatars(player); this.setupPlayerAvatars(player);
} }
public synchronized void removePlayer(GenshinPlayer player) { public synchronized void removePlayer(Player player) {
// Remove player from scene // Remove player from scene
getPlayers().remove(player); getPlayers().remove(player);
player.setScene(null); player.setScene(null);
@ -182,7 +182,7 @@ public class GenshinScene {
} }
} }
private void setupPlayerAvatars(GenshinPlayer player) { private void setupPlayerAvatars(Player player) {
// Clear entities from old team // Clear entities from old team
player.getTeamManager().getActiveTeam().clear(); player.getTeamManager().getActiveTeam().clear();
@ -199,7 +199,7 @@ public class GenshinScene {
} }
} }
private void removePlayerAvatars(GenshinPlayer player) { private void removePlayerAvatars(Player player) {
Iterator<EntityAvatar> it = player.getTeamManager().getActiveTeam().iterator(); Iterator<EntityAvatar> it = player.getTeamManager().getActiveTeam().iterator();
while (it.hasNext()) { while (it.hasNext()) {
this.removeEntity(it.next(), VisionType.VISION_REMOVE); this.removeEntity(it.next(), VisionType.VISION_REMOVE);
@ -207,7 +207,7 @@ public class GenshinScene {
} }
} }
public void spawnPlayer(GenshinPlayer player) { public void spawnPlayer(Player player) {
if (this.isInScene(player.getTeamManager().getCurrentAvatarEntity())) { if (this.isInScene(player.getTeamManager().getCurrentAvatarEntity())) {
return; return;
} }
@ -219,33 +219,33 @@ public class GenshinScene {
this.addEntity(player.getTeamManager().getCurrentAvatarEntity()); this.addEntity(player.getTeamManager().getCurrentAvatarEntity());
} }
private void addEntityDirectly(GenshinEntity entity) { private void addEntityDirectly(GameEntity entity) {
getEntities().put(entity.getId(), entity); getEntities().put(entity.getId(), entity);
} }
public synchronized void addEntity(GenshinEntity entity) { public synchronized void addEntity(GameEntity entity) {
this.addEntityDirectly(entity); this.addEntityDirectly(entity);
this.broadcastPacket(new PacketSceneEntityAppearNotify(entity)); this.broadcastPacket(new PacketSceneEntityAppearNotify(entity));
} }
public synchronized void addEntities(Collection<GenshinEntity> entities) { public synchronized void addEntities(Collection<GameEntity> entities) {
for (GenshinEntity entity : entities) { for (GameEntity entity : entities) {
this.addEntityDirectly(entity); this.addEntityDirectly(entity);
} }
this.broadcastPacket(new PacketSceneEntityAppearNotify(entities, VisionType.VISION_BORN)); this.broadcastPacket(new PacketSceneEntityAppearNotify(entities, VisionType.VISION_BORN));
} }
private GenshinEntity removeEntityDirectly(GenshinEntity entity) { private GameEntity removeEntityDirectly(GameEntity entity) {
return getEntities().remove(entity.getId()); return getEntities().remove(entity.getId());
} }
public void removeEntity(GenshinEntity entity) { public void removeEntity(GameEntity entity) {
this.removeEntity(entity, VisionType.VISION_DIE); this.removeEntity(entity, VisionType.VISION_DIE);
} }
public synchronized void removeEntity(GenshinEntity entity, VisionType visionType) { public synchronized void removeEntity(GameEntity entity, VisionType visionType) {
GenshinEntity removed = this.removeEntityDirectly(entity); GameEntity removed = this.removeEntityDirectly(entity);
if (removed != null) { if (removed != null) {
this.broadcastPacket(new PacketSceneEntityDisappearNotify(removed, visionType)); this.broadcastPacket(new PacketSceneEntityDisappearNotify(removed, visionType));
} }
@ -258,11 +258,11 @@ public class GenshinScene {
this.broadcastPacket(new PacketSceneEntityAppearNotify(newEntity, VisionType.VISION_REPLACE, oldEntity.getId())); this.broadcastPacket(new PacketSceneEntityAppearNotify(newEntity, VisionType.VISION_REPLACE, oldEntity.getId()));
} }
public void showOtherEntities(GenshinPlayer player) { public void showOtherEntities(Player player) {
List<GenshinEntity> entities = new LinkedList<>(); List<GameEntity> entities = new LinkedList<>();
GenshinEntity currentEntity = player.getTeamManager().getCurrentAvatarEntity(); GameEntity currentEntity = player.getTeamManager().getCurrentAvatarEntity();
for (GenshinEntity entity : this.getEntities().values()) { for (GameEntity entity : this.getEntities().values()) {
if (entity == currentEntity) { if (entity == currentEntity) {
continue; continue;
} }
@ -273,8 +273,8 @@ public class GenshinScene {
} }
public void handleAttack(AttackResult result) { public void handleAttack(AttackResult result) {
//GenshinEntity attacker = getEntityById(result.getAttackerId()); //GameEntity attacker = getEntityById(result.getAttackerId());
GenshinEntity target = getEntityById(result.getDefenseId()); GameEntity target = getEntityById(result.getDefenseId());
if (target == null) { if (target == null) {
return; return;
@ -306,7 +306,7 @@ public class GenshinScene {
} }
} }
public void killEntity(GenshinEntity target, int attackerId) { public void killEntity(GameEntity target, int attackerId) {
// Packet // Packet
this.broadcastPacket(new PacketLifeStateChangeNotify(attackerId, target, LifeState.LIFE_DEAD)); this.broadcastPacket(new PacketLifeStateChangeNotify(attackerId, target, LifeState.LIFE_DEAD));
this.removeEntity(target); this.removeEntity(target);
@ -321,10 +321,10 @@ public class GenshinScene {
// TODO - Test // TODO - Test
public void checkSpawns() { public void checkSpawns() {
SpatialIndex<SpawnGroupEntry> list = GenshinDepot.getSpawnListById(this.getId()); SpatialIndex<SpawnGroupEntry> list = GameDepot.getSpawnListById(this.getId());
Set<SpawnDataEntry> visible = new HashSet<>(); Set<SpawnDataEntry> visible = new HashSet<>();
for (GenshinPlayer player : this.getPlayers()) { for (Player player : this.getPlayers()) {
int RANGE = 100; int RANGE = 100;
Collection<SpawnGroupEntry> entries = list.query( Collection<SpawnGroupEntry> entries = list.query(
new double[] {player.getPos().getX() - RANGE, player.getPos().getZ() - RANGE}, new double[] {player.getPos().getX() - RANGE, player.getPos().getZ() - RANGE},
@ -339,7 +339,7 @@ public class GenshinScene {
} }
// World level // World level
WorldLevelData worldLevelData = GenshinData.getWorldLevelDataMap().get(getWorld().getWorldLevel()); WorldLevelData worldLevelData = GameData.getWorldLevelDataMap().get(getWorld().getWorldLevel());
int worldLevelOverride = 0; int worldLevelOverride = 0;
if (worldLevelData != null) { if (worldLevelData != null) {
@ -347,13 +347,13 @@ public class GenshinScene {
} }
// Todo // Todo
List<GenshinEntity> toAdd = new LinkedList<>(); List<GameEntity> toAdd = new LinkedList<>();
List<GenshinEntity> toRemove = new LinkedList<>(); List<GameEntity> toRemove = new LinkedList<>();
for (SpawnDataEntry entry : visible) { for (SpawnDataEntry entry : visible) {
if (!this.getSpawnedEntities().contains(entry) && !this.getDeadSpawnedEntities().contains(entry)) { if (!this.getSpawnedEntities().contains(entry) && !this.getDeadSpawnedEntities().contains(entry)) {
// Spawn entity // Spawn entity
MonsterData data = GenshinData.getMonsterDataMap().get(entry.getMonsterId()); MonsterData data = GameData.getMonsterDataMap().get(entry.getMonsterId());
if (data == null) { if (data == null) {
continue; continue;
@ -373,7 +373,7 @@ public class GenshinScene {
} }
} }
for (GenshinEntity entity : this.getEntities().values()) { for (GameEntity entity : this.getEntities().values()) {
if (entity.getSpawnEntry() != null && !visible.contains(entity.getSpawnEntry())) { if (entity.getSpawnEntry() != null && !visible.contains(entity.getSpawnEntry())) {
toRemove.add(entity); toRemove.add(entity);
} }
@ -407,7 +407,7 @@ public class GenshinScene {
} }
public void onPlayerDestroyGadget(int entityId) { public void onPlayerDestroyGadget(int entityId) {
GenshinEntity entity = getEntities().get(entityId); GameEntity entity = getEntities().get(entityId);
if (entity == null || !(entity instanceof EntityClientGadget)) { if (entity == null || !(entity instanceof EntityClientGadget)) {
return; return;
@ -430,20 +430,20 @@ public class GenshinScene {
// Broadcasting // Broadcasting
public void broadcastPacket(GenshinPacket packet) { public void broadcastPacket(BasePacket packet) {
// Send to all players - might have to check if player has been sent data packets // Send to all players - might have to check if player has been sent data packets
for (GenshinPlayer player : this.getPlayers()) { for (Player player : this.getPlayers()) {
player.getSession().send(packet); player.getSession().send(packet);
} }
} }
public void broadcastPacketToOthers(GenshinPlayer excludedPlayer, GenshinPacket packet) { public void broadcastPacketToOthers(Player excludedPlayer, BasePacket packet) {
// Optimization // Optimization
if (this.getPlayerCount() == 1 && this.getPlayers().get(0) == excludedPlayer) { if (this.getPlayerCount() == 1 && this.getPlayers().get(0) == excludedPlayer) {
return; return;
} }
// Send to all players - might have to check if player has been sent data packets // Send to all players - might have to check if player has been sent data packets
for (GenshinPlayer player : this.getPlayers()) { for (Player player : this.getPlayers()) {
if (player == excludedPlayer) { if (player == excludedPlayer) {
continue; continue;
} }

View File

@ -4,9 +4,9 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import dev.morphia.annotations.Entity; import dev.morphia.annotations.Entity;
import emu.grasscutter.GenshinConstants; import emu.grasscutter.GameConstants;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
import emu.grasscutter.game.avatar.GenshinAvatar; import emu.grasscutter.game.avatar.Avatar;
@Entity @Entity
public class TeamInfo { public class TeamInfo {
@ -34,11 +34,11 @@ public class TeamInfo {
return avatars.size(); return avatars.size();
} }
public boolean contains(GenshinAvatar avatar) { public boolean contains(Avatar avatar) {
return getAvatars().contains(avatar.getAvatarId()); return getAvatars().contains(avatar.getAvatarId());
} }
public boolean addAvatar(GenshinAvatar avatar) { public boolean addAvatar(Avatar avatar) {
if (size() >= Grasscutter.getConfig().getGameServerOptions().MaxAvatarsInTeam || contains(avatar)) { if (size() >= Grasscutter.getConfig().getGameServerOptions().MaxAvatarsInTeam || contains(avatar)) {
return false; return false;
} }

View File

@ -10,16 +10,16 @@ import java.util.Set;
import dev.morphia.annotations.Entity; import dev.morphia.annotations.Entity;
import dev.morphia.annotations.Transient; import dev.morphia.annotations.Transient;
import emu.grasscutter.GenshinConstants; import emu.grasscutter.GameConstants;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
import emu.grasscutter.data.def.AvatarSkillDepotData; import emu.grasscutter.data.def.AvatarSkillDepotData;
import emu.grasscutter.game.avatar.GenshinAvatar; import emu.grasscutter.game.avatar.Avatar;
import emu.grasscutter.game.entity.EntityAvatar; import emu.grasscutter.game.entity.EntityAvatar;
import emu.grasscutter.game.entity.EntityGadget; import emu.grasscutter.game.entity.EntityGadget;
import emu.grasscutter.game.props.ElementType; import emu.grasscutter.game.props.ElementType;
import emu.grasscutter.game.props.EnterReason; import emu.grasscutter.game.props.EnterReason;
import emu.grasscutter.game.props.FightProperty; import emu.grasscutter.game.props.FightProperty;
import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.EnterTypeOuterClass.EnterType; import emu.grasscutter.net.proto.EnterTypeOuterClass.EnterType;
import emu.grasscutter.net.proto.MotionStateOuterClass.MotionState; import emu.grasscutter.net.proto.MotionStateOuterClass.MotionState;
@ -44,7 +44,7 @@ import it.unimi.dsi.fastutil.ints.IntSet;
@Entity @Entity
public class TeamManager { public class TeamManager {
@Transient private GenshinPlayer player; @Transient private Player player;
private Map<Integer, TeamInfo> teams; private Map<Integer, TeamInfo> teams;
private int currentTeamIndex; private int currentTeamIndex;
@ -65,18 +65,18 @@ public class TeamManager {
this.teamResonancesConfig = new IntOpenHashSet(); this.teamResonancesConfig = new IntOpenHashSet();
} }
public TeamManager(GenshinPlayer player) { public TeamManager(Player player) {
this(); this();
this.player = player; this.player = player;
this.teams = new HashMap<>(); this.teams = new HashMap<>();
this.currentTeamIndex = 1; this.currentTeamIndex = 1;
for (int i = 1; i <= GenshinConstants.MAX_TEAMS; i++) { for (int i = 1; i <= GameConstants.MAX_TEAMS; i++) {
this.teams.put(i, new TeamInfo()); this.teams.put(i, new TeamInfo());
} }
} }
public GenshinPlayer getPlayer() { public Player getPlayer() {
return player; return player;
} }
@ -84,7 +84,7 @@ public class TeamManager {
return player.getWorld(); return player.getWorld();
} }
public void setPlayer(GenshinPlayer player) { public void setPlayer(Player player) {
this.player = player; this.player = player;
} }
@ -207,7 +207,7 @@ public class TeamManager {
} }
} }
public void updateTeamEntities(GenshinPacket responsePacket) { public void updateTeamEntities(BasePacket responsePacket) {
// Sanity check - Should never happen // Sanity check - Should never happen
if (this.getCurrentTeamInfo().getAvatars().size() <= 0) { if (this.getCurrentTeamInfo().getAvatars().size() <= 0) {
return; return;
@ -287,9 +287,9 @@ public class TeamManager {
} }
// Set team data // Set team data
LinkedHashSet<GenshinAvatar> newTeam = new LinkedHashSet<>(); LinkedHashSet<Avatar> newTeam = new LinkedHashSet<>();
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
GenshinAvatar avatar = getPlayer().getAvatars().getAvatarByGuid(list.get(i)); Avatar avatar = getPlayer().getAvatars().getAvatarByGuid(list.get(i));
if (avatar == null || newTeam.contains(avatar)) { if (avatar == null || newTeam.contains(avatar)) {
// Should never happen // Should never happen
return; return;
@ -299,7 +299,7 @@ public class TeamManager {
// Clear current team info and add avatars from our new team // Clear current team info and add avatars from our new team
teamInfo.getAvatars().clear(); teamInfo.getAvatars().clear();
for (GenshinAvatar avatar : newTeam) { for (Avatar avatar : newTeam) {
teamInfo.addAvatar(avatar); teamInfo.addAvatar(avatar);
} }
@ -323,9 +323,9 @@ public class TeamManager {
TeamInfo teamInfo = this.getMpTeam(); TeamInfo teamInfo = this.getMpTeam();
// Set team data // Set team data
LinkedHashSet<GenshinAvatar> newTeam = new LinkedHashSet<>(); LinkedHashSet<Avatar> newTeam = new LinkedHashSet<>();
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
GenshinAvatar avatar = getPlayer().getAvatars().getAvatarByGuid(list.get(i)); Avatar avatar = getPlayer().getAvatars().getAvatarByGuid(list.get(i));
if (avatar == null || newTeam.contains(avatar)) { if (avatar == null || newTeam.contains(avatar)) {
// Should never happen // Should never happen
return; return;
@ -335,7 +335,7 @@ public class TeamManager {
// Clear current team info and add avatars from our new team // Clear current team info and add avatars from our new team
teamInfo.getAvatars().clear(); teamInfo.getAvatars().clear();
for (GenshinAvatar avatar : newTeam) { for (Avatar avatar : newTeam) {
teamInfo.addAvatar(avatar); teamInfo.addAvatar(avatar);
} }
@ -437,7 +437,7 @@ public class TeamManager {
getPlayer().sendPacket(new PacketAvatarDieAnimationEndRsp(deadAvatar.getId(), 0)); getPlayer().sendPacket(new PacketAvatarDieAnimationEndRsp(deadAvatar.getId(), 0));
} }
public boolean reviveAvatar(GenshinAvatar avatar) { public boolean reviveAvatar(Avatar avatar) {
for (EntityAvatar entity : getActiveTeam()) { for (EntityAvatar entity : getActiveTeam()) {
if (entity.getAvatar() == avatar) { if (entity.getAvatar() == avatar) {
if (entity.isAlive()) { if (entity.isAlive()) {
@ -476,14 +476,14 @@ public class TeamManager {
} }
// Teleport player // Teleport player
getPlayer().sendPacket(new PacketPlayerEnterSceneNotify(getPlayer(), EnterType.ENTER_SELF, EnterReason.Revival, 3, GenshinConstants.START_POSITION)); getPlayer().sendPacket(new PacketPlayerEnterSceneNotify(getPlayer(), EnterType.ENTER_SELF, EnterReason.Revival, 3, GameConstants.START_POSITION));
// Set player position // Set player position
player.setSceneId(3); player.setSceneId(3);
player.getPos().set(GenshinConstants.START_POSITION); player.getPos().set(GameConstants.START_POSITION);
// Packets // Packets
getPlayer().sendPacket(new GenshinPacket(PacketOpcodes.WorldPlayerReviveRsp)); getPlayer().sendPacket(new BasePacket(PacketOpcodes.WorldPlayerReviveRsp));
} }
public void saveAvatars() { public void saveAvatars() {

View File

@ -8,19 +8,19 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import emu.grasscutter.game.entity.GenshinEntity; import emu.grasscutter.game.entity.GameEntity;
import emu.grasscutter.game.props.ClimateType; import emu.grasscutter.game.props.ClimateType;
import emu.grasscutter.game.props.EnterReason; import emu.grasscutter.game.props.EnterReason;
import emu.grasscutter.game.props.EntityIdType; import emu.grasscutter.game.props.EntityIdType;
import emu.grasscutter.game.props.FightProperty; import emu.grasscutter.game.props.FightProperty;
import emu.grasscutter.game.props.LifeState; import emu.grasscutter.game.props.LifeState;
import emu.grasscutter.data.GenshinData; import emu.grasscutter.data.GameData;
import emu.grasscutter.data.def.SceneData; import emu.grasscutter.data.def.SceneData;
import emu.grasscutter.game.GenshinPlayer.SceneLoadState; import emu.grasscutter.game.Player.SceneLoadState;
import emu.grasscutter.game.entity.EntityAvatar; import emu.grasscutter.game.entity.EntityAvatar;
import emu.grasscutter.game.entity.EntityClientGadget; import emu.grasscutter.game.entity.EntityClientGadget;
import emu.grasscutter.game.entity.EntityGadget; import emu.grasscutter.game.entity.EntityGadget;
import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.proto.AttackResultOuterClass.AttackResult; import emu.grasscutter.net.proto.AttackResultOuterClass.AttackResult;
import emu.grasscutter.net.proto.EnterTypeOuterClass.EnterType; import emu.grasscutter.net.proto.EnterTypeOuterClass.EnterType;
import emu.grasscutter.net.proto.VisionTypeOuterClass.VisionType; import emu.grasscutter.net.proto.VisionTypeOuterClass.VisionType;
@ -40,10 +40,10 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectMaps; import it.unimi.dsi.fastutil.ints.Int2ObjectMaps;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
public class World implements Iterable<GenshinPlayer> { public class World implements Iterable<Player> {
private final GenshinPlayer owner; private final Player owner;
private final List<GenshinPlayer> players; private final List<Player> players;
private final Int2ObjectMap<GenshinScene> scenes; private final Int2ObjectMap<Scene> scenes;
private int levelEntityId; private int levelEntityId;
private int nextEntityId = 0; private int nextEntityId = 0;
@ -52,11 +52,11 @@ public class World implements Iterable<GenshinPlayer> {
private boolean isMultiplayer; private boolean isMultiplayer;
public World(GenshinPlayer player) { public World(Player player) {
this(player, false); this(player, false);
} }
public World(GenshinPlayer player, boolean isMultiplayer) { public World(Player player, boolean isMultiplayer) {
this.owner = player; this.owner = player;
this.players = Collections.synchronizedList(new ArrayList<>()); this.players = Collections.synchronizedList(new ArrayList<>());
this.scenes = Int2ObjectMaps.synchronize(new Int2ObjectOpenHashMap<>()); this.scenes = Int2ObjectMaps.synchronize(new Int2ObjectOpenHashMap<>());
@ -68,7 +68,7 @@ public class World implements Iterable<GenshinPlayer> {
this.owner.getServer().registerWorld(this); this.owner.getServer().registerWorld(this);
} }
public GenshinPlayer getHost() { public Player getHost() {
return owner; return owner;
} }
@ -95,25 +95,25 @@ public class World implements Iterable<GenshinPlayer> {
this.worldLevel = worldLevel; this.worldLevel = worldLevel;
} }
public List<GenshinPlayer> getPlayers() { public List<Player> getPlayers() {
return players; return players;
} }
public Int2ObjectMap<GenshinScene> getScenes() { public Int2ObjectMap<Scene> getScenes() {
return this.scenes; return this.scenes;
} }
public GenshinScene getSceneById(int sceneId) { public Scene getSceneById(int sceneId) {
// Get scene normally // Get scene normally
GenshinScene scene = getScenes().get(sceneId); Scene scene = getScenes().get(sceneId);
if (scene != null) { if (scene != null) {
return scene; return scene;
} }
// Create scene from scene data if it doesnt exist // Create scene from scene data if it doesnt exist
SceneData sceneData = GenshinData.getSceneDataMap().get(sceneId); SceneData sceneData = GameData.getSceneDataMap().get(sceneId);
if (sceneData != null) { if (sceneData != null) {
scene = new GenshinScene(this, sceneData); scene = new Scene(this, sceneData);
this.registerScene(scene); this.registerScene(scene);
return scene; return scene;
} }
@ -133,7 +133,7 @@ public class World implements Iterable<GenshinPlayer> {
return (idType.getId() << 24) + ++this.nextEntityId; return (idType.getId() << 24) + ++this.nextEntityId;
} }
public synchronized void addPlayer(GenshinPlayer player) { public synchronized void addPlayer(Player player) {
// Check if player already in // Check if player already in
if (getPlayers().contains(player)) { if (getPlayers().contains(player)) {
return; return;
@ -159,7 +159,7 @@ public class World implements Iterable<GenshinPlayer> {
} }
// Add to scene // Add to scene
GenshinScene scene = this.getSceneById(player.getSceneId()); Scene scene = this.getSceneById(player.getSceneId());
scene.addPlayer(player); scene.addPlayer(player);
// Info packet for other players // Info packet for other players
@ -168,7 +168,7 @@ public class World implements Iterable<GenshinPlayer> {
} }
} }
public synchronized void removePlayer(GenshinPlayer player) { public synchronized void removePlayer(Player player) {
// Remove team entities // Remove team entities
player.sendPacket( player.sendPacket(
new PacketDelTeamEntityNotify( new PacketDelTeamEntityNotify(
@ -182,7 +182,7 @@ public class World implements Iterable<GenshinPlayer> {
player.setWorld(null); player.setWorld(null);
// Remove from scene // Remove from scene
GenshinScene scene = this.getSceneById(player.getSceneId()); Scene scene = this.getSceneById(player.getSceneId());
scene.removePlayer(player); scene.removePlayer(player);
// Info packet for other players // Info packet for other players
@ -192,8 +192,8 @@ public class World implements Iterable<GenshinPlayer> {
// Disband world if host leaves // Disband world if host leaves
if (getHost() == player) { if (getHost() == player) {
List<GenshinPlayer> kicked = new ArrayList<>(this.getPlayers()); List<Player> kicked = new ArrayList<>(this.getPlayers());
for (GenshinPlayer victim : kicked) { for (Player victim : kicked) {
World world = new World(victim); World world = new World(victim);
world.addPlayer(victim); world.addPlayer(victim);
@ -202,20 +202,20 @@ public class World implements Iterable<GenshinPlayer> {
} }
} }
public void registerScene(GenshinScene scene) { public void registerScene(Scene scene) {
this.getScenes().put(scene.getId(), scene); this.getScenes().put(scene.getId(), scene);
} }
public void deregisterScene(GenshinScene scene) { public void deregisterScene(Scene scene) {
this.getScenes().remove(scene.getId()); this.getScenes().remove(scene.getId());
} }
public boolean transferPlayerToScene(GenshinPlayer player, int sceneId, Position pos) { public boolean transferPlayerToScene(Player player, int sceneId, Position pos) {
if (GenshinData.getSceneDataMap().get(sceneId) == null) { if (GameData.getSceneDataMap().get(sceneId) == null) {
return false; return false;
} }
GenshinScene oldScene = null; Scene oldScene = null;
if (player.getScene() != null) { if (player.getScene() != null) {
oldScene = player.getScene(); oldScene = player.getScene();
@ -228,7 +228,7 @@ public class World implements Iterable<GenshinPlayer> {
oldScene.removePlayer(player); oldScene.removePlayer(player);
} }
GenshinScene newScene = this.getSceneById(sceneId); Scene newScene = this.getSceneById(sceneId);
newScene.addPlayer(player); newScene.addPlayer(player);
player.getPos().set(pos); player.getPos().set(pos);
@ -245,8 +245,8 @@ public class World implements Iterable<GenshinPlayer> {
return true; return true;
} }
private void updatePlayerInfos(GenshinPlayer paramPlayer) { private void updatePlayerInfos(Player paramPlayer) {
for (GenshinPlayer player : getPlayers()) { for (Player player : getPlayers()) {
// Dont send packets if player is loading in and filter out joining player // Dont send packets if player is loading in and filter out joining player
if (!player.hasSentAvatarDataNotify() || player.getSceneLoadState().getValue() < SceneLoadState.INIT.getValue() || player == paramPlayer) { if (!player.hasSentAvatarDataNotify() || player.getSceneLoadState().getValue() < SceneLoadState.INIT.getValue() || player == paramPlayer) {
continue; continue;
@ -269,15 +269,15 @@ public class World implements Iterable<GenshinPlayer> {
} }
} }
public void broadcastPacket(GenshinPacket packet) { public void broadcastPacket(BasePacket packet) {
// Send to all players - might have to check if player has been sent data packets // Send to all players - might have to check if player has been sent data packets
for (GenshinPlayer player : this.getPlayers()) { for (Player player : this.getPlayers()) {
player.getSession().send(packet); player.getSession().send(packet);
} }
} }
public void onTick() { public void onTick() {
for (GenshinScene scene : this.getScenes().values()) { for (Scene scene : this.getScenes().values()) {
scene.onTick(); scene.onTick();
} }
} }
@ -287,7 +287,7 @@ public class World implements Iterable<GenshinPlayer> {
} }
@Override @Override
public Iterator<GenshinPlayer> iterator() { public Iterator<Player> iterator() {
return getPlayers().iterator(); return getPlayers().iterator();
} }
} }

View File

@ -16,7 +16,7 @@ import dev.morphia.annotations.PostLoad;
import dev.morphia.annotations.PrePersist; import dev.morphia.annotations.PrePersist;
import dev.morphia.annotations.Transient; import dev.morphia.annotations.Transient;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
import emu.grasscutter.data.GenshinData; import emu.grasscutter.data.GameData;
import emu.grasscutter.data.common.FightPropData; import emu.grasscutter.data.common.FightPropData;
import emu.grasscutter.data.custom.OpenConfigEntry; import emu.grasscutter.data.custom.OpenConfigEntry;
import emu.grasscutter.data.def.AvatarData; import emu.grasscutter.data.def.AvatarData;
@ -35,10 +35,10 @@ import emu.grasscutter.data.def.WeaponPromoteData;
import emu.grasscutter.data.def.ItemData.WeaponProperty; import emu.grasscutter.data.def.ItemData.WeaponProperty;
import emu.grasscutter.data.def.ProudSkillData; import emu.grasscutter.data.def.ProudSkillData;
import emu.grasscutter.database.DatabaseHelper; import emu.grasscutter.database.DatabaseHelper;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import emu.grasscutter.game.entity.EntityAvatar; import emu.grasscutter.game.entity.EntityAvatar;
import emu.grasscutter.game.inventory.EquipType; import emu.grasscutter.game.inventory.EquipType;
import emu.grasscutter.game.inventory.GenshinItem; import emu.grasscutter.game.inventory.GameItem;
import emu.grasscutter.game.props.ElementType; import emu.grasscutter.game.props.ElementType;
import emu.grasscutter.game.props.EntityIdType; import emu.grasscutter.game.props.EntityIdType;
import emu.grasscutter.game.props.FetterState; import emu.grasscutter.game.props.FetterState;
@ -57,11 +57,11 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
@Entity(value = "avatars", useDiscriminator = false) @Entity(value = "avatars", useDiscriminator = false)
public class GenshinAvatar { public class Avatar {
@Id private ObjectId id; @Id private ObjectId id;
@Indexed private int ownerId; // Id of player that this avatar belongs to @Indexed private int ownerId; // Id of player that this avatar belongs to
@Transient private GenshinPlayer owner; @Transient private Player owner;
@Transient private AvatarData data; @Transient private AvatarData data;
@Transient private long guid; // Player unique id @Transient private long guid; // Player unique id
private int avatarId; // Id of avatar private int avatarId; // Id of avatar
@ -73,7 +73,7 @@ public class GenshinAvatar {
private int satiationPenalty; // ? private int satiationPenalty; // ?
private float currentHp; private float currentHp;
@Transient private final Int2ObjectMap<GenshinItem> equips; @Transient private final Int2ObjectMap<GameItem> equips;
@Transient private final Int2FloatOpenHashMap fightProp; @Transient private final Int2FloatOpenHashMap fightProp;
@Transient private Set<String> extraAbilityEmbryos; @Transient private Set<String> extraAbilityEmbryos;
@ -96,21 +96,21 @@ public class GenshinAvatar {
private int nameCardRewardId; private int nameCardRewardId;
private int nameCardId; private int nameCardId;
public GenshinAvatar() { public Avatar() {
// Morhpia only! // Morhpia only!
this.equips = new Int2ObjectOpenHashMap<>(); this.equips = new Int2ObjectOpenHashMap<>();
this.fightProp = new Int2FloatOpenHashMap(); this.fightProp = new Int2FloatOpenHashMap();
this.extraAbilityEmbryos = new HashSet<>(); this.extraAbilityEmbryos = new HashSet<>();
this.proudSkillBonusMap = new HashMap<>(); this.proudSkillBonusMap = new HashMap<>();
this.fetters = new ArrayList<>(); // TODO Move to genshin avatar this.fetters = new ArrayList<>(); // TODO Move to avatar
} }
// On creation // On creation
public GenshinAvatar(int avatarId) { public Avatar(int avatarId) {
this(GenshinData.getAvatarDataMap().get(avatarId)); this(GameData.getAvatarDataMap().get(avatarId));
} }
public GenshinAvatar(AvatarData data) { public Avatar(AvatarData data) {
this(); this();
this.avatarId = data.getId(); this.avatarId = data.getId();
this.nameCardRewardId = data.getNameCardRewardId(); this.nameCardRewardId = data.getNameCardRewardId();
@ -143,7 +143,7 @@ public class GenshinAvatar {
this.onLoad(); this.onLoad();
} }
public GenshinPlayer getPlayer() { public Player getPlayer() {
return this.owner; return this.owner;
} }
@ -163,10 +163,10 @@ public class GenshinAvatar {
return ownerId; return ownerId;
} }
public void setOwner(GenshinPlayer player) { public void setOwner(Player player) {
this.owner = player; this.owner = player;
this.ownerId = player.getUid(); this.ownerId = player.getUid();
this.guid = player.getNextGenshinGuid(); this.guid = player.getNextGameGuid();
} }
public int getSatiation() { public int getSatiation() {
@ -229,19 +229,19 @@ public class GenshinAvatar {
this.promoteLevel = promoteLevel; this.promoteLevel = promoteLevel;
} }
public Int2ObjectMap<GenshinItem> getEquips() { public Int2ObjectMap<GameItem> getEquips() {
return equips; return equips;
} }
public GenshinItem getEquipBySlot(EquipType slot) { public GameItem getEquipBySlot(EquipType slot) {
return this.getEquips().get(slot.getValue()); return this.getEquips().get(slot.getValue());
} }
private GenshinItem getEquipBySlot(int slotId) { private GameItem getEquipBySlot(int slotId) {
return this.getEquips().get(slotId); return this.getEquips().get(slotId);
} }
public GenshinItem getWeapon() { public GameItem getWeapon() {
return this.getEquipBySlot(EquipType.EQUIP_WEAPON); return this.getEquipBySlot(EquipType.EQUIP_WEAPON);
} }
@ -270,7 +270,7 @@ public class GenshinAvatar {
} }
if (openData.getNeedAvatarPromoteLevel() <= this.getPromoteLevel()) { if (openData.getNeedAvatarPromoteLevel() <= this.getPromoteLevel()) {
int proudSkillId = (openData.getProudSkillGroupId() * 100) + 1; int proudSkillId = (openData.getProudSkillGroupId() * 100) + 1;
if (GenshinData.getProudSkillDataMap().containsKey(proudSkillId)) { if (GameData.getProudSkillDataMap().containsKey(proudSkillId)) {
this.getProudSkillList().add(proudSkillId); this.getProudSkillList().add(proudSkillId);
} }
} }
@ -385,7 +385,7 @@ public class GenshinAvatar {
return bornTime; return bornTime;
} }
public boolean equipItem(GenshinItem item, boolean shouldRecalc) { public boolean equipItem(GameItem item, boolean shouldRecalc) {
EquipType itemEquipType = item.getItemData().getEquipType(); EquipType itemEquipType = item.getItemData().getEquipType();
if (itemEquipType == EquipType.EQUIP_NONE) { if (itemEquipType == EquipType.EQUIP_NONE) {
return false; return false;
@ -416,7 +416,7 @@ public class GenshinAvatar {
} }
public boolean unequipItem(EquipType slot) { public boolean unequipItem(EquipType slot) {
GenshinItem item = getEquips().remove(slot.getValue()); GameItem item = getEquips().remove(slot.getValue());
if (item != null) { if (item != null) {
item.setEquipCharacter(0); item.setEquipCharacter(0);
@ -434,7 +434,7 @@ public class GenshinAvatar {
public void recalcStats(boolean forceSendAbilityChange) { public void recalcStats(boolean forceSendAbilityChange) {
// Setup // Setup
AvatarData data = this.getAvatarData(); AvatarData data = this.getAvatarData();
AvatarPromoteData promoteData = GenshinData.getAvatarPromoteData(data.getAvatarPromoteId(), this.getPromoteLevel()); AvatarPromoteData promoteData = GameData.getAvatarPromoteData(data.getAvatarPromoteId(), this.getPromoteLevel());
Int2IntOpenHashMap setMap = new Int2IntOpenHashMap(); Int2IntOpenHashMap setMap = new Int2IntOpenHashMap();
// Extra ability embryos // Extra ability embryos
@ -476,21 +476,21 @@ public class GenshinAvatar {
// Artifacts // Artifacts
for (int slotId = 1; slotId <= 5; slotId++) { for (int slotId = 1; slotId <= 5; slotId++) {
// Get artifact // Get artifact
GenshinItem equip = this.getEquipBySlot(slotId); GameItem equip = this.getEquipBySlot(slotId);
if (equip == null) { if (equip == null) {
continue; continue;
} }
// Artifact main stat // Artifact main stat
ReliquaryMainPropData mainPropData = GenshinData.getReliquaryMainPropDataMap().get(equip.getMainPropId()); ReliquaryMainPropData mainPropData = GameData.getReliquaryMainPropDataMap().get(equip.getMainPropId());
if (mainPropData != null) { if (mainPropData != null) {
ReliquaryLevelData levelData = GenshinData.getRelicLevelData(equip.getItemData().getRankLevel(), equip.getLevel()); ReliquaryLevelData levelData = GameData.getRelicLevelData(equip.getItemData().getRankLevel(), equip.getLevel());
if (levelData != null) { if (levelData != null) {
this.addFightProperty(mainPropData.getFightProp(), levelData.getPropValue(mainPropData.getFightProp())); this.addFightProperty(mainPropData.getFightProp(), levelData.getPropValue(mainPropData.getFightProp()));
} }
} }
// Artifact sub stats // Artifact sub stats
for (int appendPropId : equip.getAppendPropIdList()) { for (int appendPropId : equip.getAppendPropIdList()) {
ReliquaryAffixData affixData = GenshinData.getReliquaryAffixDataMap().get(appendPropId); ReliquaryAffixData affixData = GameData.getReliquaryAffixDataMap().get(appendPropId);
if (affixData != null) { if (affixData != null) {
this.addFightProperty(affixData.getFightProp(), affixData.getPropValue()); this.addFightProperty(affixData.getFightProp(), affixData.getPropValue());
} }
@ -503,7 +503,7 @@ public class GenshinAvatar {
// Set stuff // Set stuff
for (Int2IntOpenHashMap.Entry e : setMap.int2IntEntrySet()) { for (Int2IntOpenHashMap.Entry e : setMap.int2IntEntrySet()) {
ReliquarySetData setData = GenshinData.getReliquarySetDataMap().get(e.getIntKey()); ReliquarySetData setData = GameData.getReliquarySetDataMap().get(e.getIntKey());
if (setData == null) { if (setData == null) {
continue; continue;
} }
@ -516,7 +516,7 @@ public class GenshinAvatar {
if (amount >= setData.getSetNeedNum()[setIndex]) { if (amount >= setData.getSetNeedNum()[setIndex]) {
int affixId = (setData.getEquipAffixId() * 10) + setIndex; int affixId = (setData.getEquipAffixId() * 10) + setIndex;
EquipAffixData affix = GenshinData.getEquipAffixDataMap().get(affixId); EquipAffixData affix = GameData.getEquipAffixDataMap().get(affixId);
if (affix == null) { if (affix == null) {
continue; continue;
} }
@ -535,17 +535,17 @@ public class GenshinAvatar {
} }
// Weapon // Weapon
GenshinItem weapon = this.getWeapon(); GameItem weapon = this.getWeapon();
if (weapon != null) { if (weapon != null) {
// Add stats // Add stats
WeaponCurveData curveData = GenshinData.getWeaponCurveDataMap().get(weapon.getLevel()); WeaponCurveData curveData = GameData.getWeaponCurveDataMap().get(weapon.getLevel());
if (curveData != null) { if (curveData != null) {
for (WeaponProperty weaponProperty : weapon.getItemData().getWeaponProperties()) { for (WeaponProperty weaponProperty : weapon.getItemData().getWeaponProperties()) {
this.addFightProperty(weaponProperty.getFightProp(), weaponProperty.getInitValue() * curveData.getMultByProp(weaponProperty.getType())); this.addFightProperty(weaponProperty.getFightProp(), weaponProperty.getInitValue() * curveData.getMultByProp(weaponProperty.getType()));
} }
} }
// Weapon promotion stats // Weapon promotion stats
WeaponPromoteData wepPromoteData = GenshinData.getWeaponPromoteData(weapon.getItemData().getWeaponPromoteId(), weapon.getPromoteLevel()); WeaponPromoteData wepPromoteData = GameData.getWeaponPromoteData(weapon.getItemData().getWeaponPromoteId(), weapon.getPromoteLevel());
if (wepPromoteData != null) { if (wepPromoteData != null) {
for (FightPropData prop : wepPromoteData.getAddProps()) { for (FightPropData prop : wepPromoteData.getAddProps()) {
if (prop.getValue() == 0f || prop.getProp() == null) { if (prop.getValue() == 0f || prop.getProp() == null) {
@ -563,7 +563,7 @@ public class GenshinAvatar {
} }
// Calculate affix id // Calculate affix id
int affixId = (af * 10) + weapon.getRefinement(); int affixId = (af * 10) + weapon.getRefinement();
EquipAffixData affix = GenshinData.getEquipAffixDataMap().get(affixId); EquipAffixData affix = GameData.getEquipAffixDataMap().get(affixId);
if (affix == null) { if (affix == null) {
continue; continue;
} }
@ -580,7 +580,7 @@ public class GenshinAvatar {
} }
// Add proud skills and unlock them if needed // Add proud skills and unlock them if needed
AvatarSkillDepotData skillDepot = GenshinData.getAvatarSkillDepotDataMap().get(this.getSkillDepotId()); AvatarSkillDepotData skillDepot = GameData.getAvatarSkillDepotDataMap().get(this.getSkillDepotId());
this.getProudSkillList().clear(); this.getProudSkillList().clear();
for (InherentProudSkillOpens openData : skillDepot.getInherentProudSkillOpens()) { for (InherentProudSkillOpens openData : skillDepot.getInherentProudSkillOpens()) {
if (openData.getProudSkillGroupId() == 0) { if (openData.getProudSkillGroupId() == 0) {
@ -588,7 +588,7 @@ public class GenshinAvatar {
} }
if (openData.getNeedAvatarPromoteLevel() <= this.getPromoteLevel()) { if (openData.getNeedAvatarPromoteLevel() <= this.getPromoteLevel()) {
int proudSkillId = (openData.getProudSkillGroupId() * 100) + 1; int proudSkillId = (openData.getProudSkillGroupId() * 100) + 1;
if (GenshinData.getProudSkillDataMap().containsKey(proudSkillId)) { if (GameData.getProudSkillDataMap().containsKey(proudSkillId)) {
this.getProudSkillList().add(proudSkillId); this.getProudSkillList().add(proudSkillId);
} }
} }
@ -596,7 +596,7 @@ public class GenshinAvatar {
// Proud skills // Proud skills
for (int proudSkillId : this.getProudSkillList()) { for (int proudSkillId : this.getProudSkillList()) {
ProudSkillData proudSkillData = GenshinData.getProudSkillDataMap().get(proudSkillId); ProudSkillData proudSkillData = GameData.getProudSkillDataMap().get(proudSkillId);
if (proudSkillData == null) { if (proudSkillData == null) {
continue; continue;
} }
@ -613,7 +613,7 @@ public class GenshinAvatar {
// Constellations // Constellations
if (this.getTalentIdList().size() > 0) { if (this.getTalentIdList().size() > 0) {
for (int talentId : this.getTalentIdList()) { for (int talentId : this.getTalentIdList()) {
AvatarTalentData avatarTalentData = GenshinData.getAvatarTalentDataMap().get(talentId); AvatarTalentData avatarTalentData = GameData.getAvatarTalentDataMap().get(talentId);
if (avatarTalentData == null) { if (avatarTalentData == null) {
return; return;
} }
@ -657,7 +657,7 @@ public class GenshinAvatar {
return; return;
} }
OpenConfigEntry entry = GenshinData.getOpenConfigEntries().get(openConfig); OpenConfigEntry entry = GameData.getOpenConfigEntries().get(openConfig);
if (entry == null) { if (entry == null) {
if (forceAdd) { if (forceAdd) {
// Add config string to ability skill list anyways // Add config string to ability skill list anyways
@ -684,14 +684,14 @@ public class GenshinAvatar {
if (this.getTalentIdList().size() > 0) { if (this.getTalentIdList().size() > 0) {
for (int talentId : this.getTalentIdList()) { for (int talentId : this.getTalentIdList()) {
AvatarTalentData avatarTalentData = GenshinData.getAvatarTalentDataMap().get(talentId); AvatarTalentData avatarTalentData = GameData.getAvatarTalentDataMap().get(talentId);
if (avatarTalentData == null || avatarTalentData.getOpenConfig() == null || avatarTalentData.getOpenConfig().length() == 0) { if (avatarTalentData == null || avatarTalentData.getOpenConfig() == null || avatarTalentData.getOpenConfig().length() == 0) {
continue; continue;
} }
// Get open config to find which skill should be boosted // Get open config to find which skill should be boosted
OpenConfigEntry entry = GenshinData.getOpenConfigEntries().get(avatarTalentData.getOpenConfig()); OpenConfigEntry entry = GameData.getOpenConfigEntries().get(avatarTalentData.getOpenConfig());
if (entry == null) { if (entry == null) {
continue; continue;
} }
@ -712,7 +712,7 @@ public class GenshinAvatar {
} }
// Get proud skill group id // Get proud skill group id
AvatarSkillData skillData = GenshinData.getAvatarSkillDataMap().get(skillId); AvatarSkillData skillData = GameData.getAvatarSkillDataMap().get(skillId);
if (skillData == null) { if (skillData == null) {
continue; continue;
@ -785,7 +785,7 @@ public class GenshinAvatar {
.setWearingFlycloakId(this.getFlyCloak()) .setWearingFlycloakId(this.getFlyCloak())
.setCostumeId(this.getCostume()); .setCostumeId(this.getCostume());
for (GenshinItem item : this.getEquips().values()) { for (GameItem item : this.getEquips().values()) {
avatarInfo.addEquipGuidList(item.getGuid()); avatarInfo.addEquipGuidList(item.getGuid());
} }

View File

@ -7,7 +7,7 @@ public class AvatarProfileData {
private int avatarId; private int avatarId;
private int level; private int level;
public AvatarProfileData(GenshinAvatar avatar) { public AvatarProfileData(Avatar avatar) {
this.update(avatar); this.update(avatar);
} }
@ -19,7 +19,7 @@ public class AvatarProfileData {
return level; return level;
} }
public void update(GenshinAvatar avatar) { public void update(Avatar avatar) {
this.avatarId = avatar.getAvatarId(); this.avatarId = avatar.getAvatarId();
this.level = avatar.getLevel(); this.level = avatar.getLevel();
} }

View File

@ -3,12 +3,12 @@ package emu.grasscutter.game.avatar;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import emu.grasscutter.data.GenshinData; import emu.grasscutter.data.GameData;
import emu.grasscutter.data.def.AvatarData; import emu.grasscutter.data.def.AvatarData;
import emu.grasscutter.database.DatabaseHelper; import emu.grasscutter.database.DatabaseHelper;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import emu.grasscutter.game.entity.EntityAvatar; import emu.grasscutter.game.entity.EntityAvatar;
import emu.grasscutter.game.inventory.GenshinItem; import emu.grasscutter.game.inventory.GameItem;
import emu.grasscutter.server.packet.send.PacketAvatarChangeCostumeNotify; import emu.grasscutter.server.packet.send.PacketAvatarChangeCostumeNotify;
import emu.grasscutter.server.packet.send.PacketAvatarFlycloakChangeNotify; import emu.grasscutter.server.packet.send.PacketAvatarFlycloakChangeNotify;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
@ -16,22 +16,22 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
public class AvatarStorage implements Iterable<GenshinAvatar> { public class AvatarStorage implements Iterable<Avatar> {
private final GenshinPlayer player; private final Player player;
private final Int2ObjectMap<GenshinAvatar> avatars; private final Int2ObjectMap<Avatar> avatars;
private final Long2ObjectMap<GenshinAvatar> avatarsGuid; private final Long2ObjectMap<Avatar> avatarsGuid;
public AvatarStorage(GenshinPlayer player) { public AvatarStorage(Player player) {
this.player = player; this.player = player;
this.avatars = new Int2ObjectOpenHashMap<>(); this.avatars = new Int2ObjectOpenHashMap<>();
this.avatarsGuid = new Long2ObjectOpenHashMap<>(); this.avatarsGuid = new Long2ObjectOpenHashMap<>();
} }
public GenshinPlayer getPlayer() { public Player getPlayer() {
return player; return player;
} }
public Int2ObjectMap<GenshinAvatar> getAvatars() { public Int2ObjectMap<Avatar> getAvatars() {
return avatars; return avatars;
} }
@ -39,11 +39,11 @@ public class AvatarStorage implements Iterable<GenshinAvatar> {
return this.avatars.size(); return this.avatars.size();
} }
public GenshinAvatar getAvatarById(int id) { public Avatar getAvatarById(int id) {
return getAvatars().get(id); return getAvatars().get(id);
} }
public GenshinAvatar getAvatarByGuid(long id) { public Avatar getAvatarByGuid(long id) {
return avatarsGuid.get(id); return avatarsGuid.get(id);
} }
@ -51,7 +51,7 @@ public class AvatarStorage implements Iterable<GenshinAvatar> {
return getAvatars().containsKey(id); return getAvatars().containsKey(id);
} }
public boolean addAvatar(GenshinAvatar avatar) { public boolean addAvatar(Avatar avatar) {
if (avatar.getAvatarData() == null || this.hasAvatar(avatar.getAvatarId())) { if (avatar.getAvatarData() == null || this.hasAvatar(avatar.getAvatarId())) {
return false; return false;
} }
@ -68,14 +68,14 @@ public class AvatarStorage implements Iterable<GenshinAvatar> {
return true; return true;
} }
public void addStartingWeapon(GenshinAvatar avatar) { public void addStartingWeapon(Avatar avatar) {
// Make sure avatar owner is this player // Make sure avatar owner is this player
if (avatar.getPlayer() != this.getPlayer()) { if (avatar.getPlayer() != this.getPlayer()) {
return; return;
} }
// Create weapon // Create weapon
GenshinItem weapon = new GenshinItem(avatar.getAvatarData().getInitialWeapon()); GameItem weapon = new GameItem(avatar.getAvatarData().getInitialWeapon());
if (weapon.getItemData() != null) { if (weapon.getItemData() != null) {
this.getPlayer().getInventory().addItem(weapon); this.getPlayer().getInventory().addItem(weapon);
@ -85,7 +85,7 @@ public class AvatarStorage implements Iterable<GenshinAvatar> {
} }
public boolean wearFlycloak(long avatarGuid, int flycloakId) { public boolean wearFlycloak(long avatarGuid, int flycloakId) {
GenshinAvatar avatar = this.getAvatarByGuid(avatarGuid); Avatar avatar = this.getAvatarByGuid(avatarGuid);
if (avatar == null || !getPlayer().getFlyCloakList().contains(flycloakId)) { if (avatar == null || !getPlayer().getFlyCloakList().contains(flycloakId)) {
return false; return false;
@ -101,7 +101,7 @@ public class AvatarStorage implements Iterable<GenshinAvatar> {
} }
public boolean changeCostume(long avatarGuid, int costumeId) { public boolean changeCostume(long avatarGuid, int costumeId) {
GenshinAvatar avatar = this.getAvatarByGuid(avatarGuid); Avatar avatar = this.getAvatarByGuid(avatarGuid);
if (avatar == null) { if (avatar == null) {
return false; return false;
@ -130,15 +130,15 @@ public class AvatarStorage implements Iterable<GenshinAvatar> {
} }
public void loadFromDatabase() { public void loadFromDatabase() {
List<GenshinAvatar> avatars = DatabaseHelper.getAvatars(getPlayer()); List<Avatar> avatars = DatabaseHelper.getAvatars(getPlayer());
for (GenshinAvatar avatar : avatars) { for (Avatar avatar : avatars) {
// Should never happen // Should never happen
if (avatar.getObjectId() == null) { if (avatar.getObjectId() == null) {
continue; continue;
} }
AvatarData avatarData = GenshinData.getAvatarDataMap().get(avatar.getAvatarId()); AvatarData avatarData = GameData.getAvatarDataMap().get(avatar.getAvatarId());
if (avatarData == null) { if (avatarData == null) {
continue; continue;
} }
@ -157,7 +157,7 @@ public class AvatarStorage implements Iterable<GenshinAvatar> {
} }
public void postLoad() { public void postLoad() {
for (GenshinAvatar avatar : this) { for (Avatar avatar : this) {
// Weapon check // Weapon check
if (avatar.getWeapon() == null) { if (avatar.getWeapon() == null) {
this.addStartingWeapon(avatar); this.addStartingWeapon(avatar);
@ -168,7 +168,7 @@ public class AvatarStorage implements Iterable<GenshinAvatar> {
} }
@Override @Override
public Iterator<GenshinAvatar> iterator() { public Iterator<Avatar> iterator() {
return getAvatars().values().iterator(); return getAvatars().values().iterator();
} }
} }

View File

@ -1,15 +1,15 @@
package emu.grasscutter.game.entity; package emu.grasscutter.game.entity;
import emu.grasscutter.GenshinConstants; import emu.grasscutter.GameConstants;
import emu.grasscutter.data.GenshinData; import emu.grasscutter.data.GameData;
import emu.grasscutter.data.def.AvatarData; import emu.grasscutter.data.def.AvatarData;
import emu.grasscutter.data.def.AvatarSkillDepotData; import emu.grasscutter.data.def.AvatarSkillDepotData;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import emu.grasscutter.game.GenshinScene; import emu.grasscutter.game.Scene;
import emu.grasscutter.game.World; import emu.grasscutter.game.World;
import emu.grasscutter.game.avatar.GenshinAvatar; import emu.grasscutter.game.avatar.Avatar;
import emu.grasscutter.game.inventory.EquipType; import emu.grasscutter.game.inventory.EquipType;
import emu.grasscutter.game.inventory.GenshinItem; import emu.grasscutter.game.inventory.GameItem;
import emu.grasscutter.game.props.EntityIdType; import emu.grasscutter.game.props.EntityIdType;
import emu.grasscutter.game.props.FightProperty; import emu.grasscutter.game.props.FightProperty;
import emu.grasscutter.game.props.PlayerProperty; import emu.grasscutter.game.props.PlayerProperty;
@ -34,29 +34,29 @@ import emu.grasscutter.utils.Utils;
import it.unimi.dsi.fastutil.ints.Int2FloatMap; import it.unimi.dsi.fastutil.ints.Int2FloatMap;
import it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap; import it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap;
public class EntityAvatar extends GenshinEntity { public class EntityAvatar extends GameEntity {
private final GenshinAvatar avatar; private final Avatar avatar;
private PlayerDieType killedType; private PlayerDieType killedType;
private int killedBy; private int killedBy;
public EntityAvatar(GenshinScene scene, GenshinAvatar avatar) { public EntityAvatar(Scene scene, Avatar avatar) {
super(scene); super(scene);
this.avatar = avatar; this.avatar = avatar;
this.id = getScene().getWorld().getNextEntityId(EntityIdType.AVATAR); this.id = getScene().getWorld().getNextEntityId(EntityIdType.AVATAR);
GenshinItem weapon = this.getAvatar().getWeapon(); GameItem weapon = this.getAvatar().getWeapon();
if (weapon != null) { if (weapon != null) {
weapon.setWeaponEntityId(getScene().getWorld().getNextEntityId(EntityIdType.WEAPON)); weapon.setWeaponEntityId(getScene().getWorld().getNextEntityId(EntityIdType.WEAPON));
} }
} }
public EntityAvatar(GenshinAvatar avatar) { public EntityAvatar(Avatar avatar) {
super(null); super(null);
this.avatar = avatar; this.avatar = avatar;
} }
public GenshinPlayer getPlayer() { public Player getPlayer() {
return avatar.getPlayer(); return avatar.getPlayer();
} }
@ -70,7 +70,7 @@ public class EntityAvatar extends GenshinEntity {
return getPlayer().getRotation(); return getPlayer().getRotation();
} }
public GenshinAvatar getAvatar() { public Avatar getAvatar() {
return avatar; return avatar;
} }
@ -122,7 +122,7 @@ public class EntityAvatar extends GenshinEntity {
.setCostumeId(this.getAvatar().getCostume()) .setCostumeId(this.getAvatar().getCostume())
.setBornTime(this.getAvatar().getBornTime()); .setBornTime(this.getAvatar().getBornTime());
for (GenshinItem item : avatar.getEquips().values()) { for (GameItem item : avatar.getEquips().values()) {
if (item.getItemData().getEquipType() == EquipType.EQUIP_WEAPON) { if (item.getItemData().getEquipType() == EquipType.EQUIP_WEAPON) {
avatarInfo.setWeapon(item.createSceneWeaponInfo()); avatarInfo.setWeapon(item.createSceneWeaponInfo());
} else { } else {
@ -187,17 +187,17 @@ public class EntityAvatar extends GenshinEntity {
AbilityEmbryo emb = AbilityEmbryo.newBuilder() AbilityEmbryo emb = AbilityEmbryo.newBuilder()
.setAbilityId(++embryoId) .setAbilityId(++embryoId)
.setAbilityNameHash(id) .setAbilityNameHash(id)
.setAbilityOverrideNameHash(GenshinConstants.DEFAULT_ABILITY_NAME) .setAbilityOverrideNameHash(GameConstants.DEFAULT_ABILITY_NAME)
.build(); .build();
abilityControlBlock.addAbilityEmbryoList(emb); abilityControlBlock.addAbilityEmbryoList(emb);
} }
} }
// Add default abilities // Add default abilities
for (int id : GenshinConstants.DEFAULT_ABILITY_HASHES) { for (int id : GameConstants.DEFAULT_ABILITY_HASHES) {
AbilityEmbryo emb = AbilityEmbryo.newBuilder() AbilityEmbryo emb = AbilityEmbryo.newBuilder()
.setAbilityId(++embryoId) .setAbilityId(++embryoId)
.setAbilityNameHash(id) .setAbilityNameHash(id)
.setAbilityOverrideNameHash(GenshinConstants.DEFAULT_ABILITY_NAME) .setAbilityOverrideNameHash(GameConstants.DEFAULT_ABILITY_NAME)
.build(); .build();
abilityControlBlock.addAbilityEmbryoList(emb); abilityControlBlock.addAbilityEmbryoList(emb);
} }
@ -206,18 +206,18 @@ public class EntityAvatar extends GenshinEntity {
AbilityEmbryo emb = AbilityEmbryo.newBuilder() AbilityEmbryo emb = AbilityEmbryo.newBuilder()
.setAbilityId(++embryoId) .setAbilityId(++embryoId)
.setAbilityNameHash(id) .setAbilityNameHash(id)
.setAbilityOverrideNameHash(GenshinConstants.DEFAULT_ABILITY_NAME) .setAbilityOverrideNameHash(GameConstants.DEFAULT_ABILITY_NAME)
.build(); .build();
abilityControlBlock.addAbilityEmbryoList(emb); abilityControlBlock.addAbilityEmbryoList(emb);
} }
// Add skill depot abilities // Add skill depot abilities
AvatarSkillDepotData skillDepot = GenshinData.getAvatarSkillDepotDataMap().get(this.getAvatar().getSkillDepotId()); AvatarSkillDepotData skillDepot = GameData.getAvatarSkillDepotDataMap().get(this.getAvatar().getSkillDepotId());
if (skillDepot != null && skillDepot.getAbilities() != null) { if (skillDepot != null && skillDepot.getAbilities() != null) {
for (int id : skillDepot.getAbilities()) { for (int id : skillDepot.getAbilities()) {
AbilityEmbryo emb = AbilityEmbryo.newBuilder() AbilityEmbryo emb = AbilityEmbryo.newBuilder()
.setAbilityId(++embryoId) .setAbilityId(++embryoId)
.setAbilityNameHash(id) .setAbilityNameHash(id)
.setAbilityOverrideNameHash(GenshinConstants.DEFAULT_ABILITY_NAME) .setAbilityOverrideNameHash(GameConstants.DEFAULT_ABILITY_NAME)
.build(); .build();
abilityControlBlock.addAbilityEmbryoList(emb); abilityControlBlock.addAbilityEmbryoList(emb);
} }
@ -228,7 +228,7 @@ public class EntityAvatar extends GenshinEntity {
AbilityEmbryo emb = AbilityEmbryo.newBuilder() AbilityEmbryo emb = AbilityEmbryo.newBuilder()
.setAbilityId(++embryoId) .setAbilityId(++embryoId)
.setAbilityNameHash(Utils.abilityHash(skill)) .setAbilityNameHash(Utils.abilityHash(skill))
.setAbilityOverrideNameHash(GenshinConstants.DEFAULT_ABILITY_NAME) .setAbilityOverrideNameHash(GameConstants.DEFAULT_ABILITY_NAME)
.build(); .build();
abilityControlBlock.addAbilityEmbryoList(emb); abilityControlBlock.addAbilityEmbryoList(emb);
} }

View File

@ -1,7 +1,7 @@
package emu.grasscutter.game.entity; package emu.grasscutter.game.entity;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import emu.grasscutter.game.GenshinScene; import emu.grasscutter.game.Scene;
import emu.grasscutter.game.World; import emu.grasscutter.game.World;
import emu.grasscutter.game.props.PlayerProperty; import emu.grasscutter.game.props.PlayerProperty;
import emu.grasscutter.net.proto.AbilitySyncStateInfoOuterClass.AbilitySyncStateInfo; import emu.grasscutter.net.proto.AbilitySyncStateInfoOuterClass.AbilitySyncStateInfo;
@ -24,7 +24,7 @@ import emu.grasscutter.utils.ProtoHelper;
import it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap; import it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap;
public class EntityClientGadget extends EntityGadget { public class EntityClientGadget extends EntityGadget {
private final GenshinPlayer owner; private final Player owner;
private final Position pos; private final Position pos;
private final Position rot; private final Position rot;
@ -36,7 +36,7 @@ public class EntityClientGadget extends EntityGadget {
private int targetEntityId; private int targetEntityId;
private boolean asyncLoad; private boolean asyncLoad;
public EntityClientGadget(GenshinScene scene, GenshinPlayer player, EvtCreateGadgetNotify notify) { public EntityClientGadget(Scene scene, Player player, EvtCreateGadgetNotify notify) {
super(scene); super(scene);
this.owner = player; this.owner = player;
this.id = notify.getEntityId(); this.id = notify.getEntityId();
@ -55,7 +55,7 @@ public class EntityClientGadget extends EntityGadget {
return configId; return configId;
} }
public GenshinPlayer getOwner() { public Player getOwner() {
return owner; return owner;
} }

View File

@ -1,11 +1,11 @@
package emu.grasscutter.game.entity; package emu.grasscutter.game.entity;
import emu.grasscutter.game.GenshinScene; import emu.grasscutter.game.Scene;
import emu.grasscutter.game.World; import emu.grasscutter.game.World;
public abstract class EntityGadget extends GenshinEntity { public abstract class EntityGadget extends GameEntity {
public EntityGadget(GenshinScene scene) { public EntityGadget(Scene scene) {
super(scene); super(scene);
} }

View File

@ -1,10 +1,10 @@
package emu.grasscutter.game.entity; package emu.grasscutter.game.entity;
import emu.grasscutter.data.def.ItemData; import emu.grasscutter.data.def.ItemData;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import emu.grasscutter.game.GenshinScene; import emu.grasscutter.game.Scene;
import emu.grasscutter.game.World; import emu.grasscutter.game.World;
import emu.grasscutter.game.inventory.GenshinItem; import emu.grasscutter.game.inventory.GameItem;
import emu.grasscutter.game.props.EntityIdType; import emu.grasscutter.game.props.EntityIdType;
import emu.grasscutter.game.props.PlayerProperty; import emu.grasscutter.game.props.PlayerProperty;
import emu.grasscutter.net.proto.AbilitySyncStateInfoOuterClass.AbilitySyncStateInfo; import emu.grasscutter.net.proto.AbilitySyncStateInfoOuterClass.AbilitySyncStateInfo;
@ -28,16 +28,16 @@ public class EntityItem extends EntityGadget {
private final Position pos; private final Position pos;
private final Position rot; private final Position rot;
private final GenshinItem item; private final GameItem item;
private final long guid; private final long guid;
public EntityItem(GenshinScene scene, GenshinPlayer player, ItemData itemData, Position pos, int count) { public EntityItem(Scene scene, Player player, ItemData itemData, Position pos, int count) {
super(scene); super(scene);
this.id = getScene().getWorld().getNextEntityId(EntityIdType.GADGET); this.id = getScene().getWorld().getNextEntityId(EntityIdType.GADGET);
this.pos = new Position(pos); this.pos = new Position(pos);
this.rot = new Position(); this.rot = new Position();
this.guid = player.getNextGenshinGuid(); this.guid = player.getNextGameGuid();
this.item = new GenshinItem(itemData, count); this.item = new GameItem(itemData, count);
} }
@Override @Override
@ -45,7 +45,7 @@ public class EntityItem extends EntityGadget {
return this.id; return this.id;
} }
private GenshinItem getItem() { private GameItem getItem() {
return this.item; return this.item;
} }

View File

@ -1,10 +1,10 @@
package emu.grasscutter.game.entity; package emu.grasscutter.game.entity;
import emu.grasscutter.data.GenshinData; import emu.grasscutter.data.GameData;
import emu.grasscutter.data.common.PropGrowCurve; import emu.grasscutter.data.common.PropGrowCurve;
import emu.grasscutter.data.def.MonsterCurveData; import emu.grasscutter.data.def.MonsterCurveData;
import emu.grasscutter.data.def.MonsterData; import emu.grasscutter.data.def.MonsterData;
import emu.grasscutter.game.GenshinScene; import emu.grasscutter.game.Scene;
import emu.grasscutter.game.World; import emu.grasscutter.game.World;
import emu.grasscutter.game.props.EntityIdType; import emu.grasscutter.game.props.EntityIdType;
import emu.grasscutter.game.props.FightProperty; import emu.grasscutter.game.props.FightProperty;
@ -27,7 +27,7 @@ import emu.grasscutter.utils.ProtoHelper;
import it.unimi.dsi.fastutil.ints.Int2FloatMap; import it.unimi.dsi.fastutil.ints.Int2FloatMap;
import it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap; import it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap;
public class EntityMonster extends GenshinEntity { public class EntityMonster extends GameEntity {
private final MonsterData monsterData; private final MonsterData monsterData;
private final Int2FloatOpenHashMap fightProp; private final Int2FloatOpenHashMap fightProp;
@ -41,7 +41,7 @@ public class EntityMonster extends GenshinEntity {
private int configId; private int configId;
private int poseId; private int poseId;
public EntityMonster(GenshinScene scene, MonsterData monsterData, Position pos, int level) { public EntityMonster(Scene scene, MonsterData monsterData, Position pos, int level) {
super(scene); super(scene);
this.id = getWorld().getNextEntityId(EntityIdType.MONSTER); this.id = getWorld().getNextEntityId(EntityIdType.MONSTER);
this.monsterData = monsterData; this.monsterData = monsterData;
@ -160,7 +160,7 @@ public class EntityMonster extends GenshinEntity {
this.setFightProperty(FightProperty.FIGHT_PROP_ICE_SUB_HURT, data.getIceSubHurt()); this.setFightProperty(FightProperty.FIGHT_PROP_ICE_SUB_HURT, data.getIceSubHurt());
// Level curve // Level curve
MonsterCurveData curve = GenshinData.getMonsterCurveDataMap().get(this.getLevel()); MonsterCurveData curve = GameData.getMonsterCurveDataMap().get(this.getLevel());
if (curve != null) { if (curve != null) {
for (PropGrowCurve growCurve : data.getPropGrowCurves()) { for (PropGrowCurve growCurve : data.getPropGrowCurves()) {
FightProperty prop = FightProperty.getPropByName(growCurve.getType()); FightProperty prop = FightProperty.getPropByName(growCurve.getType());

View File

@ -1,6 +1,6 @@
package emu.grasscutter.game.entity; package emu.grasscutter.game.entity;
import emu.grasscutter.game.GenshinScene; import emu.grasscutter.game.Scene;
import emu.grasscutter.game.World; import emu.grasscutter.game.World;
import emu.grasscutter.game.props.FightProperty; import emu.grasscutter.game.props.FightProperty;
import emu.grasscutter.game.props.LifeState; import emu.grasscutter.game.props.LifeState;
@ -12,16 +12,16 @@ import emu.grasscutter.net.proto.VectorOuterClass.Vector;
import emu.grasscutter.utils.Position; import emu.grasscutter.utils.Position;
import it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap; import it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap;
public abstract class GenshinEntity { public abstract class GameEntity {
protected int id; protected int id;
private final GenshinScene scene; private final Scene scene;
private SpawnDataEntry spawnEntry; private SpawnDataEntry spawnEntry;
private MotionState moveState; private MotionState moveState;
private int lastMoveSceneTimeMs; private int lastMoveSceneTimeMs;
private int lastMoveReliableSeq; private int lastMoveReliableSeq;
public GenshinEntity(GenshinScene scene) { public GameEntity(Scene scene) {
this.scene = scene; this.scene = scene;
this.moveState = MotionState.MOTION_NONE; this.moveState = MotionState.MOTION_NONE;
} }
@ -34,7 +34,7 @@ public abstract class GenshinEntity {
return this.getScene().getWorld(); return this.getScene().getWorld();
} }
public GenshinScene getScene() { public Scene getScene() {
return this.scene; return this.scene;
} }

View File

@ -3,7 +3,7 @@ package emu.grasscutter.game.friends;
import java.util.List; import java.util.List;
import emu.grasscutter.database.DatabaseHelper; import emu.grasscutter.database.DatabaseHelper;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import emu.grasscutter.net.proto.DealAddFriendResultTypeOuterClass.DealAddFriendResultType; import emu.grasscutter.net.proto.DealAddFriendResultTypeOuterClass.DealAddFriendResultType;
import emu.grasscutter.server.packet.send.PacketAskAddFriendNotify; import emu.grasscutter.server.packet.send.PacketAskAddFriendNotify;
import emu.grasscutter.server.packet.send.PacketAskAddFriendRsp; import emu.grasscutter.server.packet.send.PacketAskAddFriendRsp;
@ -14,20 +14,20 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
public class FriendsList { public class FriendsList {
private final GenshinPlayer player; private final Player player;
private final Int2ObjectMap<Friendship> friends; private final Int2ObjectMap<Friendship> friends;
private final Int2ObjectMap<Friendship> pendingFriends; private final Int2ObjectMap<Friendship> pendingFriends;
private boolean loaded = false; private boolean loaded = false;
public FriendsList(GenshinPlayer player) { public FriendsList(Player player) {
this.player = player; this.player = player;
this.friends = new Int2ObjectOpenHashMap<Friendship>(); this.friends = new Int2ObjectOpenHashMap<Friendship>();
this.pendingFriends = new Int2ObjectOpenHashMap<Friendship>(); this.pendingFriends = new Int2ObjectOpenHashMap<Friendship>();
} }
public GenshinPlayer getPlayer() { public Player getPlayer() {
return player; return player;
} }
@ -83,7 +83,7 @@ public class FriendsList {
return; return;
} }
GenshinPlayer target = getPlayer().getSession().getServer().getPlayerByUid(targetUid, true); Player target = getPlayer().getSession().getServer().getPlayerByUid(targetUid, true);
if (target == null) { if (target == null) {
return; // Should never happen return; // Should never happen
} }
@ -143,7 +143,7 @@ public class FriendsList {
myFriendship.delete(); myFriendship.delete();
Friendship theirFriendship = null; Friendship theirFriendship = null;
GenshinPlayer friend = myFriendship.getFriendProfile().getPlayer(); Player friend = myFriendship.getFriendProfile().getPlayer();
if (friend != null) { if (friend != null) {
// Friend online // Friend online
theirFriendship = friend.getFriendsList().getFriendById(this.getPlayer().getUid()); theirFriendship = friend.getFriendsList().getFriendById(this.getPlayer().getUid());
@ -165,7 +165,7 @@ public class FriendsList {
} }
public synchronized void sendFriendRequest(int targetUid) { public synchronized void sendFriendRequest(int targetUid) {
GenshinPlayer target = getPlayer().getSession().getServer().getPlayerByUid(targetUid, true); Player target = getPlayer().getSession().getServer().getPlayerByUid(targetUid, true);
if (target == null || target == this.getPlayer()) { if (target == null || target == this.getPlayer()) {
return; return;
@ -220,7 +220,7 @@ public class FriendsList {
friendship.setOwner(getPlayer()); friendship.setOwner(getPlayer());
// Check if friend is online // Check if friend is online
GenshinPlayer friend = getPlayer().getSession().getServer().getPlayerByUid(friendship.getFriendProfile().getUid()); Player friend = getPlayer().getSession().getServer().getPlayerByUid(friendship.getFriendProfile().getUid());
if (friend != null) { if (friend != null) {
// Set friend to online mode // Set friend to online mode
friendship.setFriendProfile(friend); friendship.setFriendProfile(friend);

View File

@ -5,7 +5,7 @@ import org.bson.types.ObjectId;
import dev.morphia.annotations.*; import dev.morphia.annotations.*;
import emu.grasscutter.database.DatabaseHelper; import emu.grasscutter.database.DatabaseHelper;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import emu.grasscutter.net.proto.FriendBriefOuterClass.FriendBrief; import emu.grasscutter.net.proto.FriendBriefOuterClass.FriendBrief;
import emu.grasscutter.net.proto.FriendOnlineStateOuterClass.FriendOnlineState; import emu.grasscutter.net.proto.FriendOnlineStateOuterClass.FriendOnlineState;
import emu.grasscutter.net.proto.HeadImageOuterClass.HeadImage; import emu.grasscutter.net.proto.HeadImageOuterClass.HeadImage;
@ -14,7 +14,7 @@ import emu.grasscutter.net.proto.HeadImageOuterClass.HeadImage;
public class Friendship { public class Friendship {
@Id private ObjectId id; @Id private ObjectId id;
@Transient private GenshinPlayer owner; @Transient private Player owner;
@Indexed private int ownerId; @Indexed private int ownerId;
@Indexed private int friendId; @Indexed private int friendId;
@ -26,7 +26,7 @@ public class Friendship {
@Deprecated // Morphia use only @Deprecated // Morphia use only
public Friendship() { } public Friendship() { }
public Friendship(GenshinPlayer owner, GenshinPlayer friend, GenshinPlayer asker) { public Friendship(Player owner, Player friend, Player asker) {
this.setOwner(owner); this.setOwner(owner);
this.ownerId = owner.getUid(); this.ownerId = owner.getUid();
this.friendId = friend.getUid(); this.friendId = friend.getUid();
@ -34,11 +34,11 @@ public class Friendship {
this.askerId = asker.getUid(); this.askerId = asker.getUid();
} }
public GenshinPlayer getOwner() { public Player getOwner() {
return owner; return owner;
} }
public void setOwner(GenshinPlayer owner) { public void setOwner(Player owner) {
this.owner = owner; this.owner = owner;
} }
@ -70,7 +70,7 @@ public class Friendship {
return profile; return profile;
} }
public void setFriendProfile(GenshinPlayer character) { public void setFriendProfile(Player character) {
if (character == null || this.friendId != character.getUid()) return; if (character == null || this.friendId != character.getUid()) return;
this.profile = character.getProfile(); this.profile = character.getProfile();
} }

View File

@ -1,12 +1,12 @@
package emu.grasscutter.game.friends; package emu.grasscutter.game.friends;
import dev.morphia.annotations.*; import dev.morphia.annotations.*;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import emu.grasscutter.utils.Utils; import emu.grasscutter.utils.Utils;
@Entity @Entity
public class PlayerProfile { public class PlayerProfile {
@Transient private GenshinPlayer player; @Transient private Player player;
@AlsoLoad("id") private int uid; @AlsoLoad("id") private int uid;
private int nameCard; private int nameCard;
@ -22,7 +22,7 @@ public class PlayerProfile {
@Deprecated // Morphia only @Deprecated // Morphia only
public PlayerProfile() { } public PlayerProfile() { }
public PlayerProfile(GenshinPlayer player) { public PlayerProfile(Player player) {
this.uid = player.getUid(); this.uid = player.getUid();
this.syncWithCharacter(player); this.syncWithCharacter(player);
} }
@ -31,11 +31,11 @@ public class PlayerProfile {
return uid; return uid;
} }
public GenshinPlayer getPlayer() { public Player getPlayer() {
return player; return player;
} }
public synchronized void setPlayer(GenshinPlayer player) { public synchronized void setPlayer(Player player) {
this.player = player; this.player = player;
} }
@ -83,7 +83,7 @@ public class PlayerProfile {
return this.getPlayer() != null; return this.getPlayer() != null;
} }
public void syncWithCharacter(GenshinPlayer player) { public void syncWithCharacter(Player player) {
if (player == null) { if (player == null) {
return; return;
} }

View File

@ -12,11 +12,11 @@ import com.google.gson.reflect.TypeToken;
import com.sun.nio.file.SensitivityWatchEventModifier; import com.sun.nio.file.SensitivityWatchEventModifier;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
import emu.grasscutter.data.GenshinData; import emu.grasscutter.data.GameData;
import emu.grasscutter.data.def.ItemData; import emu.grasscutter.data.def.ItemData;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import emu.grasscutter.game.avatar.GenshinAvatar; import emu.grasscutter.game.avatar.Avatar;
import emu.grasscutter.game.inventory.GenshinItem; import emu.grasscutter.game.inventory.GameItem;
import emu.grasscutter.game.inventory.ItemType; import emu.grasscutter.game.inventory.ItemType;
import emu.grasscutter.game.inventory.MaterialType; import emu.grasscutter.game.inventory.MaterialType;
import emu.grasscutter.net.proto.GachaItemOuterClass.GachaItem; import emu.grasscutter.net.proto.GachaItemOuterClass.GachaItem;
@ -89,7 +89,7 @@ public class GachaManager {
} }
} }
public synchronized void doPulls(GenshinPlayer player, int gachaType, int times) { public synchronized void doPulls(Player player, int gachaType, int times) {
// Sanity check // Sanity check
if (times != 10 && times != 1) { if (times != 10 && times != 1) {
return; return;
@ -108,7 +108,7 @@ public class GachaManager {
// Spend currency // Spend currency
if (banner.getCostItem() > 0) { if (banner.getCostItem() > 0) {
GenshinItem costItem = player.getInventory().getInventoryTab(ItemType.ITEM_MATERIAL).getItemById(banner.getCostItem()); GameItem costItem = player.getInventory().getInventoryTab(ItemType.ITEM_MATERIAL).getItemById(banner.getCostItem());
if (costItem == null || costItem.getCount() < times) { if (costItem == null || costItem.getCount() < times) {
return; return;
} }
@ -191,7 +191,7 @@ public class GachaManager {
int stardust = 0, starglitter = 0; int stardust = 0, starglitter = 0;
for (int itemId : wonItems) { for (int itemId : wonItems) {
ItemData itemData = GenshinData.getItemDataMap().get(itemId); ItemData itemData = GameData.getItemDataMap().get(itemId);
if (itemData == null) { if (itemData == null) {
continue; continue;
} }
@ -204,11 +204,11 @@ public class GachaManager {
// Const check // Const check
if (itemData.getMaterialType() == MaterialType.MATERIAL_AVATAR) { if (itemData.getMaterialType() == MaterialType.MATERIAL_AVATAR) {
int avatarId = (itemData.getId() % 1000) + 10000000; int avatarId = (itemData.getId() % 1000) + 10000000;
GenshinAvatar avatar = player.getAvatars().getAvatarById(avatarId); Avatar avatar = player.getAvatars().getAvatarById(avatarId);
if (avatar != null) { if (avatar != null) {
int constLevel = avatar.getCoreProudSkillLevel(); int constLevel = avatar.getCoreProudSkillLevel();
int constItemId = itemData.getId() + 100; int constItemId = itemData.getId() + 100;
GenshinItem constItem = player.getInventory().getInventoryTab(ItemType.ITEM_MATERIAL).getItemById(constItemId); GameItem constItem = player.getInventory().getInventoryTab(ItemType.ITEM_MATERIAL).getItemById(constItemId);
if (constItem != null) { if (constItem != null) {
constLevel += constItem.getCount(); constLevel += constItem.getCount();
} }
@ -249,7 +249,7 @@ public class GachaManager {
} }
// Create item // Create item
GenshinItem item = new GenshinItem(itemData); GameItem item = new GameItem(itemData);
gachaItem.setGachaItem(item.toItemParam()); gachaItem.setGachaItem(item.toItemParam());
player.getInventory().addItem(item); player.getInventory().addItem(item);

View File

@ -4,26 +4,26 @@ import java.util.HashSet;
import java.util.Set; import java.util.Set;
public class EquipInventoryTab implements InventoryTab { public class EquipInventoryTab implements InventoryTab {
private final Set<GenshinItem> items; private final Set<GameItem> items;
private final int maxCapacity; private final int maxCapacity;
public EquipInventoryTab(int maxCapacity) { public EquipInventoryTab(int maxCapacity) {
this.items = new HashSet<GenshinItem>(); this.items = new HashSet<GameItem>();
this.maxCapacity = maxCapacity; this.maxCapacity = maxCapacity;
} }
@Override @Override
public GenshinItem getItemById(int id) { public GameItem getItemById(int id) {
return null; return null;
} }
@Override @Override
public void onAddItem(GenshinItem item) { public void onAddItem(GameItem item) {
this.items.add(item); this.items.add(item);
} }
@Override @Override
public void onRemoveItem(GenshinItem item) { public void onRemoveItem(GameItem item) {
this.items.remove(item); this.items.remove(item);
} }

View File

@ -13,13 +13,13 @@ import dev.morphia.annotations.Indexed;
import dev.morphia.annotations.PostLoad; import dev.morphia.annotations.PostLoad;
import dev.morphia.annotations.Transient; import dev.morphia.annotations.Transient;
import emu.grasscutter.data.GenshinData; import emu.grasscutter.data.GameData;
import emu.grasscutter.data.GenshinDepot; import emu.grasscutter.data.GameDepot;
import emu.grasscutter.data.def.ItemData; import emu.grasscutter.data.def.ItemData;
import emu.grasscutter.data.def.ReliquaryAffixData; import emu.grasscutter.data.def.ReliquaryAffixData;
import emu.grasscutter.data.def.ReliquaryMainPropData; import emu.grasscutter.data.def.ReliquaryMainPropData;
import emu.grasscutter.database.DatabaseHelper; import emu.grasscutter.database.DatabaseHelper;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import emu.grasscutter.game.props.FightProperty; import emu.grasscutter.game.props.FightProperty;
import emu.grasscutter.net.proto.AbilitySyncStateInfoOuterClass.AbilitySyncStateInfo; import emu.grasscutter.net.proto.AbilitySyncStateInfoOuterClass.AbilitySyncStateInfo;
import emu.grasscutter.net.proto.EquipOuterClass.Equip; import emu.grasscutter.net.proto.EquipOuterClass.Equip;
@ -35,7 +35,7 @@ import emu.grasscutter.net.proto.WeaponOuterClass.Weapon;
import emu.grasscutter.utils.WeightedList; import emu.grasscutter.utils.WeightedList;
@Entity(value = "items", useDiscriminator = false) @Entity(value = "items", useDiscriminator = false)
public class GenshinItem { public class GameItem {
@Id private ObjectId id; @Id private ObjectId id;
@Indexed private int ownerId; @Indexed private int ownerId;
private int itemId; private int itemId;
@ -62,23 +62,23 @@ public class GenshinItem {
private int equipCharacter; private int equipCharacter;
@Transient private int weaponEntityId; @Transient private int weaponEntityId;
public GenshinItem() { public GameItem() {
// Morphia only // Morphia only
} }
public GenshinItem(int itemId) { public GameItem(int itemId) {
this(GenshinData.getItemDataMap().get(itemId)); this(GameData.getItemDataMap().get(itemId));
} }
public GenshinItem(int itemId, int count) { public GameItem(int itemId, int count) {
this(GenshinData.getItemDataMap().get(itemId), count); this(GameData.getItemDataMap().get(itemId), count);
} }
public GenshinItem(ItemData data) { public GameItem(ItemData data) {
this(data, 1); this(data, 1);
} }
public GenshinItem(ItemData data, int count) { public GameItem(ItemData data, int count) {
this.itemId = data.getId(); this.itemId = data.getId();
this.itemData = data; this.itemData = data;
@ -103,7 +103,7 @@ public class GenshinItem {
this.level = 1; this.level = 1;
this.appendPropIdList = new ArrayList<>(); this.appendPropIdList = new ArrayList<>();
// Create main property // Create main property
ReliquaryMainPropData mainPropData = GenshinDepot.getRandomRelicMainProp(getItemData().getMainPropDepotId()); ReliquaryMainPropData mainPropData = GameDepot.getRandomRelicMainProp(getItemData().getMainPropDepotId());
if (mainPropData != null) { if (mainPropData != null) {
this.mainPropId = mainPropData.getId(); this.mainPropId = mainPropData.getId();
} }
@ -124,9 +124,9 @@ public class GenshinItem {
return ownerId; return ownerId;
} }
public void setOwner(GenshinPlayer player) { public void setOwner(Player player) {
this.ownerId = player.getUid(); this.ownerId = player.getUid();
this.guid = player.getNextGenshinGuid(); this.guid = player.getNextGameGuid();
} }
public int getItemId() { public int getItemId() {
return itemId; return itemId;
@ -261,7 +261,7 @@ public class GenshinItem {
} }
private void addNewAppendProp() { private void addNewAppendProp() {
List<ReliquaryAffixData> affixList = GenshinDepot.getRandomRelicAffixList(getItemData().getAppendPropDepotId()); List<ReliquaryAffixData> affixList = GameDepot.getRandomRelicAffixList(getItemData().getAppendPropDepotId());
if (affixList == null) { if (affixList == null) {
return; return;
@ -269,13 +269,13 @@ public class GenshinItem {
// Build blacklist - Dont add same stat as main/sub stat // Build blacklist - Dont add same stat as main/sub stat
Set<FightProperty> blacklist = new HashSet<>(); Set<FightProperty> blacklist = new HashSet<>();
ReliquaryMainPropData mainPropData = GenshinData.getReliquaryMainPropDataMap().get(this.getMainPropId()); ReliquaryMainPropData mainPropData = GameData.getReliquaryMainPropDataMap().get(this.getMainPropId());
if (mainPropData != null) { if (mainPropData != null) {
blacklist.add(mainPropData.getFightProp()); blacklist.add(mainPropData.getFightProp());
} }
int len = Math.min(4, this.getAppendPropIdList().size()); int len = Math.min(4, this.getAppendPropIdList().size());
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
ReliquaryAffixData affixData = GenshinData.getReliquaryAffixDataMap().get((int) this.getAppendPropIdList().get(i)); ReliquaryAffixData affixData = GameData.getReliquaryAffixDataMap().get((int) this.getAppendPropIdList().get(i));
if (affixData != null) { if (affixData != null) {
blacklist.add(affixData.getFightProp()); blacklist.add(affixData.getFightProp());
} }
@ -299,7 +299,7 @@ public class GenshinItem {
} }
private void upgradeRandomAppendProp() { private void upgradeRandomAppendProp() {
List<ReliquaryAffixData> affixList = GenshinDepot.getRandomRelicAffixList(getItemData().getAppendPropDepotId()); List<ReliquaryAffixData> affixList = GameDepot.getRandomRelicAffixList(getItemData().getAppendPropDepotId());
if (affixList == null) { if (affixList == null) {
return; return;
@ -309,7 +309,7 @@ public class GenshinItem {
Set<FightProperty> whitelist = new HashSet<>(); Set<FightProperty> whitelist = new HashSet<>();
int len = Math.min(4, this.getAppendPropIdList().size()); int len = Math.min(4, this.getAppendPropIdList().size());
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
ReliquaryAffixData affixData = GenshinData.getReliquaryAffixDataMap().get((int) this.getAppendPropIdList().get(i)); ReliquaryAffixData affixData = GameData.getReliquaryAffixDataMap().get((int) this.getAppendPropIdList().get(i));
if (affixData != null) { if (affixData != null) {
whitelist.add(affixData.getFightProp()); whitelist.add(affixData.getFightProp());
} }
@ -331,7 +331,7 @@ public class GenshinItem {
@PostLoad @PostLoad
public void onLoad() { public void onLoad() {
if (this.itemData == null) { if (this.itemData == null) {
this.itemData = GenshinData.getItemDataMap().get(getItemId()); this.itemData = GameData.getItemDataMap().get(getItemId());
} }
} }

View File

@ -5,17 +5,17 @@ import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import emu.grasscutter.GenshinConstants; import emu.grasscutter.GameConstants;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
import emu.grasscutter.data.GenshinData; import emu.grasscutter.data.GameData;
import emu.grasscutter.data.def.AvatarCostumeData; import emu.grasscutter.data.def.AvatarCostumeData;
import emu.grasscutter.data.def.AvatarData; import emu.grasscutter.data.def.AvatarData;
import emu.grasscutter.data.def.AvatarFlycloakData; import emu.grasscutter.data.def.AvatarFlycloakData;
import emu.grasscutter.data.def.ItemData; import emu.grasscutter.data.def.ItemData;
import emu.grasscutter.database.DatabaseHelper; import emu.grasscutter.database.DatabaseHelper;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import emu.grasscutter.game.avatar.AvatarStorage; import emu.grasscutter.game.avatar.AvatarStorage;
import emu.grasscutter.game.avatar.GenshinAvatar; import emu.grasscutter.game.avatar.Avatar;
import emu.grasscutter.game.entity.EntityAvatar; import emu.grasscutter.game.entity.EntityAvatar;
import emu.grasscutter.game.props.ActionReason; import emu.grasscutter.game.props.ActionReason;
import emu.grasscutter.net.proto.ItemParamOuterClass.ItemParam; import emu.grasscutter.net.proto.ItemParamOuterClass.ItemParam;
@ -28,13 +28,13 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
public class Inventory implements Iterable<GenshinItem> { public class Inventory implements Iterable<GameItem> {
private final GenshinPlayer player; private final Player player;
private final Long2ObjectMap<GenshinItem> store; private final Long2ObjectMap<GameItem> store;
private final Int2ObjectMap<InventoryTab> inventoryTypes; private final Int2ObjectMap<InventoryTab> inventoryTypes;
public Inventory(GenshinPlayer player) { public Inventory(Player player) {
this.player = player; this.player = player;
this.store = new Long2ObjectOpenHashMap<>(); this.store = new Long2ObjectOpenHashMap<>();
this.inventoryTypes = new Int2ObjectOpenHashMap<>(); this.inventoryTypes = new Int2ObjectOpenHashMap<>();
@ -45,7 +45,7 @@ public class Inventory implements Iterable<GenshinItem> {
this.createInventoryTab(ItemType.ITEM_FURNITURE, new MaterialInventoryTab(Grasscutter.getConfig().getGameServerOptions().InventoryLimitFurniture)); this.createInventoryTab(ItemType.ITEM_FURNITURE, new MaterialInventoryTab(Grasscutter.getConfig().getGameServerOptions().InventoryLimitFurniture));
} }
public GenshinPlayer getPlayer() { public Player getPlayer() {
return player; return player;
} }
@ -53,7 +53,7 @@ public class Inventory implements Iterable<GenshinItem> {
return this.getPlayer().getAvatars(); return this.getPlayer().getAvatars();
} }
public Long2ObjectMap<GenshinItem> getItems() { public Long2ObjectMap<GameItem> getItems() {
return store; return store;
} }
@ -69,7 +69,7 @@ public class Inventory implements Iterable<GenshinItem> {
this.getInventoryTypes().put(type.getValue(), tab); this.getInventoryTypes().put(type.getValue(), tab);
} }
public GenshinItem getItemByGuid(long id) { public GameItem getItemByGuid(long id) {
return this.getItems().get(id); return this.getItems().get(id);
} }
@ -78,19 +78,19 @@ public class Inventory implements Iterable<GenshinItem> {
} }
public boolean addItem(int itemId, int count) { public boolean addItem(int itemId, int count) {
ItemData itemData = GenshinData.getItemDataMap().get(itemId); ItemData itemData = GameData.getItemDataMap().get(itemId);
if (itemData == null) { if (itemData == null) {
return false; return false;
} }
GenshinItem item = new GenshinItem(itemData, count); GameItem item = new GameItem(itemData, count);
return addItem(item); return addItem(item);
} }
public boolean addItem(GenshinItem item) { public boolean addItem(GameItem item) {
GenshinItem result = putItem(item); GameItem result = putItem(item);
if (result != null) { if (result != null) {
getPlayer().sendPacket(new PacketStoreItemChangeNotify(result)); getPlayer().sendPacket(new PacketStoreItemChangeNotify(result));
@ -100,7 +100,7 @@ public class Inventory implements Iterable<GenshinItem> {
return false; return false;
} }
public boolean addItem(GenshinItem item, ActionReason reason) { public boolean addItem(GameItem item, ActionReason reason) {
boolean result = addItem(item); boolean result = addItem(item);
if (result && reason != null) { if (result && reason != null) {
@ -110,15 +110,15 @@ public class Inventory implements Iterable<GenshinItem> {
return result; return result;
} }
public void addItems(Collection<GenshinItem> items) { public void addItems(Collection<GameItem> items) {
this.addItems(items, null); this.addItems(items, null);
} }
public void addItems(Collection<GenshinItem> items, ActionReason reason) { public void addItems(Collection<GameItem> items, ActionReason reason) {
List<GenshinItem> changedItems = new LinkedList<>(); List<GameItem> changedItems = new LinkedList<>();
for (GenshinItem item : items) { for (GameItem item : items) {
GenshinItem result = putItem(item); GameItem result = putItem(item);
if (result != null) { if (result != null) {
changedItems.add(result); changedItems.add(result);
} }
@ -136,10 +136,10 @@ public class Inventory implements Iterable<GenshinItem> {
} }
public void addItemParams(Collection<ItemParam> items) { public void addItemParams(Collection<ItemParam> items) {
addItems(items.stream().map(param -> new GenshinItem(param.getItemId(), param.getCount())).toList(), null); addItems(items.stream().map(param -> new GameItem(param.getItemId(), param.getCount())).toList(), null);
} }
private synchronized GenshinItem putItem(GenshinItem item) { private synchronized GameItem putItem(GameItem item) {
// Dont add items that dont have a valid item definition. // Dont add items that dont have a valid item definition.
if (item.getItemData() == null) { if (item.getItemData() == null) {
return null; return null;
@ -163,23 +163,23 @@ public class Inventory implements Iterable<GenshinItem> {
// Get avatar id // Get avatar id
int avatarId = (item.getItemId() % 1000) + 10000000; int avatarId = (item.getItemId() % 1000) + 10000000;
// Dont let people give themselves extra main characters // Dont let people give themselves extra main characters
if (avatarId == GenshinConstants.MAIN_CHARACTER_MALE || avatarId == GenshinConstants.MAIN_CHARACTER_FEMALE) { if (avatarId == GameConstants.MAIN_CHARACTER_MALE || avatarId == GameConstants.MAIN_CHARACTER_FEMALE) {
return null; return null;
} }
// Add avatar // Add avatar
AvatarData avatarData = GenshinData.getAvatarDataMap().get(avatarId); AvatarData avatarData = GameData.getAvatarDataMap().get(avatarId);
if (avatarData != null && !player.getAvatars().hasAvatar(avatarId)) { if (avatarData != null && !player.getAvatars().hasAvatar(avatarId)) {
this.getPlayer().addAvatar(new GenshinAvatar(avatarData)); this.getPlayer().addAvatar(new Avatar(avatarData));
} }
return null; return null;
} else if (item.getItemData().getMaterialType() == MaterialType.MATERIAL_FLYCLOAK) { } else if (item.getItemData().getMaterialType() == MaterialType.MATERIAL_FLYCLOAK) {
AvatarFlycloakData flycloakData = GenshinData.getAvatarFlycloakDataMap().get(item.getItemId()); AvatarFlycloakData flycloakData = GameData.getAvatarFlycloakDataMap().get(item.getItemId());
if (flycloakData != null && !player.getFlyCloakList().contains(item.getItemId())) { if (flycloakData != null && !player.getFlyCloakList().contains(item.getItemId())) {
getPlayer().addFlycloak(item.getItemId()); getPlayer().addFlycloak(item.getItemId());
} }
return null; return null;
} else if (item.getItemData().getMaterialType() == MaterialType.MATERIAL_COSTUME) { } else if (item.getItemData().getMaterialType() == MaterialType.MATERIAL_COSTUME) {
AvatarCostumeData costumeData = GenshinData.getAvatarCostumeDataItemIdMap().get(item.getItemId()); AvatarCostumeData costumeData = GameData.getAvatarCostumeDataItemIdMap().get(item.getItemId());
if (costumeData != null && !player.getCostumeList().contains(costumeData.getId())) { if (costumeData != null && !player.getCostumeList().contains(costumeData.getId())) {
getPlayer().addCostume(costumeData.getId()); getPlayer().addCostume(costumeData.getId());
} }
@ -190,7 +190,7 @@ public class Inventory implements Iterable<GenshinItem> {
} }
return null; return null;
} else if (tab != null) { } else if (tab != null) {
GenshinItem existingItem = tab.getItemById(item.getItemId()); GameItem existingItem = tab.getItemById(item.getItemId());
if (existingItem == null) { if (existingItem == null) {
// Item type didnt exist before, we will add it to main inventory map if there is enough space // Item type didnt exist before, we will add it to main inventory map if there is enough space
if (tab.getSize() >= tab.getMaxCapacity()) { if (tab.getSize() >= tab.getMaxCapacity()) {
@ -213,7 +213,7 @@ public class Inventory implements Iterable<GenshinItem> {
return item; return item;
} }
private synchronized void putItem(GenshinItem item, InventoryTab tab) { private synchronized void putItem(GameItem item, InventoryTab tab) {
// Set owner and guid FIRST! // Set owner and guid FIRST!
item.setOwner(getPlayer()); item.setOwner(getPlayer());
// Put in item store // Put in item store
@ -242,9 +242,9 @@ public class Inventory implements Iterable<GenshinItem> {
} }
} }
public void removeItems(List<GenshinItem> items) { public void removeItems(List<GameItem> items) {
// TODO Bulk delete // TODO Bulk delete
for (GenshinItem item : items) { for (GameItem item : items) {
this.removeItem(item, item.getCount()); this.removeItem(item, item.getCount());
} }
} }
@ -254,7 +254,7 @@ public class Inventory implements Iterable<GenshinItem> {
} }
public synchronized boolean removeItem(long guid, int count) { public synchronized boolean removeItem(long guid, int count) {
GenshinItem item = this.getItemByGuid(guid); GameItem item = this.getItemByGuid(guid);
if (item == null) { if (item == null) {
return false; return false;
@ -263,11 +263,11 @@ public class Inventory implements Iterable<GenshinItem> {
return removeItem(item, count); return removeItem(item, count);
} }
public synchronized boolean removeItem(GenshinItem item) { public synchronized boolean removeItem(GameItem item) {
return removeItem(item, item.getCount()); return removeItem(item, item.getCount());
} }
public synchronized boolean removeItem(GenshinItem item, int count) { public synchronized boolean removeItem(GameItem item, int count) {
// Sanity check // Sanity check
if (count <= 0 || item == null) { if (count <= 0 || item == null) {
return false; return false;
@ -296,7 +296,7 @@ public class Inventory implements Iterable<GenshinItem> {
return true; return true;
} }
private void deleteItem(GenshinItem item, InventoryTab tab) { private void deleteItem(GameItem item, InventoryTab tab) {
getItems().remove(item.getGuid()); getItems().remove(item.getGuid());
if (tab != null) { if (tab != null) {
tab.onRemoveItem(item); tab.onRemoveItem(item);
@ -304,8 +304,8 @@ public class Inventory implements Iterable<GenshinItem> {
} }
public boolean equipItem(long avatarGuid, long equipGuid) { public boolean equipItem(long avatarGuid, long equipGuid) {
GenshinAvatar avatar = getPlayer().getAvatars().getAvatarByGuid(avatarGuid); Avatar avatar = getPlayer().getAvatars().getAvatarByGuid(avatarGuid);
GenshinItem item = this.getItemByGuid(equipGuid); GameItem item = this.getItemByGuid(equipGuid);
if (avatar != null && item != null) { if (avatar != null && item != null) {
return avatar.equipItem(item, true); return avatar.equipItem(item, true);
@ -315,7 +315,7 @@ public class Inventory implements Iterable<GenshinItem> {
} }
public boolean unequipItem(long avatarGuid, int slot) { public boolean unequipItem(long avatarGuid, int slot) {
GenshinAvatar avatar = getPlayer().getAvatars().getAvatarByGuid(avatarGuid); Avatar avatar = getPlayer().getAvatars().getAvatarByGuid(avatarGuid);
EquipType equipType = EquipType.getTypeByValue(slot); EquipType equipType = EquipType.getTypeByValue(slot);
if (avatar != null && equipType != EquipType.EQUIP_WEAPON) { if (avatar != null && equipType != EquipType.EQUIP_WEAPON) {
@ -330,15 +330,15 @@ public class Inventory implements Iterable<GenshinItem> {
} }
public void loadFromDatabase() { public void loadFromDatabase() {
List<GenshinItem> items = DatabaseHelper.getInventoryItems(getPlayer()); List<GameItem> items = DatabaseHelper.getInventoryItems(getPlayer());
for (GenshinItem item : items) { for (GameItem item : items) {
// Should never happen // Should never happen
if (item.getObjectId() == null) { if (item.getObjectId() == null) {
continue; continue;
} }
ItemData itemData = GenshinData.getItemDataMap().get(item.getItemId()); ItemData itemData = GameData.getItemDataMap().get(item.getItemId());
if (itemData == null) { if (itemData == null) {
continue; continue;
} }
@ -354,7 +354,7 @@ public class Inventory implements Iterable<GenshinItem> {
// Equip to a character if possible // Equip to a character if possible
if (item.isEquipped()) { if (item.isEquipped()) {
GenshinAvatar avatar = getPlayer().getAvatars().getAvatarById(item.getEquipCharacter()); Avatar avatar = getPlayer().getAvatars().getAvatarById(item.getEquipCharacter());
boolean hasEquipped = false; boolean hasEquipped = false;
if (avatar != null) { if (avatar != null) {
@ -370,7 +370,7 @@ public class Inventory implements Iterable<GenshinItem> {
} }
@Override @Override
public Iterator<GenshinItem> iterator() { public Iterator<GameItem> iterator() {
return this.getItems().values().iterator(); return this.getItems().values().iterator();
} }
} }

View File

@ -1,11 +1,11 @@
package emu.grasscutter.game.inventory; package emu.grasscutter.game.inventory;
public interface InventoryTab { public interface InventoryTab {
public GenshinItem getItemById(int id); public GameItem getItemById(int id);
public void onAddItem(GenshinItem item); public void onAddItem(GameItem item);
public void onRemoveItem(GenshinItem item); public void onRemoveItem(GameItem item);
public int getSize(); public int getSize();

View File

@ -4,7 +4,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
public class MaterialInventoryTab implements InventoryTab { public class MaterialInventoryTab implements InventoryTab {
private final Int2ObjectMap<GenshinItem> items; private final Int2ObjectMap<GameItem> items;
private final int maxCapacity; private final int maxCapacity;
public MaterialInventoryTab(int maxCapacity) { public MaterialInventoryTab(int maxCapacity) {
@ -13,17 +13,17 @@ public class MaterialInventoryTab implements InventoryTab {
} }
@Override @Override
public GenshinItem getItemById(int id) { public GameItem getItemById(int id) {
return this.items.get(id); return this.items.get(id);
} }
@Override @Override
public void onAddItem(GenshinItem item) { public void onAddItem(GameItem item) {
this.items.put(item.getItemId(), item); this.items.put(item.getItemId(), item);
} }
@Override @Override
public void onRemoveItem(GenshinItem item) { public void onRemoveItem(GameItem item) {
this.items.remove(item.getItemId()); this.items.remove(item.getItemId());
} }

View File

@ -1,8 +1,8 @@
package emu.grasscutter.game.managers; package emu.grasscutter.game.managers;
import emu.grasscutter.command.CommandMap; import emu.grasscutter.command.CommandMap;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.server.game.GameServer; import emu.grasscutter.server.game.GameServer;
import emu.grasscutter.server.packet.send.PacketPlayerChatNotify; import emu.grasscutter.server.packet.send.PacketPlayerChatNotify;
import emu.grasscutter.server.packet.send.PacketPrivateChatNotify; import emu.grasscutter.server.packet.send.PacketPrivateChatNotify;
@ -23,7 +23,7 @@ public class ChatManager {
return server; return server;
} }
public void sendPrivateMessage(GenshinPlayer player, int targetUid, String message) { public void sendPrivateMessage(Player player, int targetUid, String message) {
// Sanity checks // Sanity checks
if (message == null || message.length() == 0) { if (message == null || message.length() == 0) {
return; return;
@ -36,35 +36,35 @@ public class ChatManager {
} }
// Get target // Get target
GenshinPlayer target = getServer().getPlayerByUid(targetUid); Player target = getServer().getPlayerByUid(targetUid);
if (target == null) { if (target == null) {
return; return;
} }
// Create chat packet // Create chat packet
GenshinPacket packet = new PacketPrivateChatNotify(player.getUid(), target.getUid(), message); BasePacket packet = new PacketPrivateChatNotify(player.getUid(), target.getUid(), message);
player.sendPacket(packet); player.sendPacket(packet);
target.sendPacket(packet); target.sendPacket(packet);
} }
public void sendPrivateMessage(GenshinPlayer player, int targetUid, int emote) { public void sendPrivateMessage(Player player, int targetUid, int emote) {
// Get target // Get target
GenshinPlayer target = getServer().getPlayerByUid(targetUid); Player target = getServer().getPlayerByUid(targetUid);
if (target == null) { if (target == null) {
return; return;
} }
// Create chat packet // Create chat packet
GenshinPacket packet = new PacketPrivateChatNotify(player.getUid(), target.getUid(), emote); BasePacket packet = new PacketPrivateChatNotify(player.getUid(), target.getUid(), emote);
player.sendPacket(packet); player.sendPacket(packet);
target.sendPacket(packet); target.sendPacket(packet);
} }
public void sendTeamMessage(GenshinPlayer player, int channel, String message) { public void sendTeamMessage(Player player, int channel, String message) {
// Sanity checks // Sanity checks
if (message == null || message.length() == 0) { if (message == null || message.length() == 0) {
return; return;
@ -80,7 +80,7 @@ public class ChatManager {
player.getWorld().broadcastPacket(new PacketPlayerChatNotify(player, channel, message)); player.getWorld().broadcastPacket(new PacketPlayerChatNotify(player, channel, message));
} }
public void sendTeamMessage(GenshinPlayer player, int channel, int icon) { public void sendTeamMessage(Player player, int channel, int icon) {
// Create and send chat packet // Create and send chat packet
player.getWorld().broadcastPacket(new PacketPlayerChatNotify(player, channel, icon)); player.getWorld().broadcastPacket(new PacketPlayerChatNotify(player, channel, icon));
} }

View File

@ -5,7 +5,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import emu.grasscutter.data.GenshinData; import emu.grasscutter.data.GameData;
import emu.grasscutter.data.common.ItemParamData; import emu.grasscutter.data.common.ItemParamData;
import emu.grasscutter.data.custom.OpenConfigEntry; import emu.grasscutter.data.custom.OpenConfigEntry;
import emu.grasscutter.data.def.AvatarPromoteData; import emu.grasscutter.data.def.AvatarPromoteData;
@ -15,9 +15,9 @@ import emu.grasscutter.data.def.WeaponPromoteData;
import emu.grasscutter.data.def.AvatarSkillDepotData.InherentProudSkillOpens; import emu.grasscutter.data.def.AvatarSkillDepotData.InherentProudSkillOpens;
import emu.grasscutter.data.def.AvatarTalentData; import emu.grasscutter.data.def.AvatarTalentData;
import emu.grasscutter.data.def.ProudSkillData; import emu.grasscutter.data.def.ProudSkillData;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import emu.grasscutter.game.avatar.GenshinAvatar; import emu.grasscutter.game.avatar.Avatar;
import emu.grasscutter.game.inventory.GenshinItem; import emu.grasscutter.game.inventory.GameItem;
import emu.grasscutter.game.inventory.ItemType; import emu.grasscutter.game.inventory.ItemType;
import emu.grasscutter.game.inventory.MaterialType; import emu.grasscutter.game.inventory.MaterialType;
import emu.grasscutter.net.proto.ItemParamOuterClass.ItemParam; import emu.grasscutter.net.proto.ItemParamOuterClass.ItemParam;
@ -72,8 +72,8 @@ public class InventoryManager {
return server; return server;
} }
public void lockEquip(GenshinPlayer player, long targetEquipGuid, boolean isLocked) { public void lockEquip(Player player, long targetEquipGuid, boolean isLocked) {
GenshinItem equip = player.getInventory().getItemByGuid(targetEquipGuid); GameItem equip = player.getInventory().getItemByGuid(targetEquipGuid);
if (equip == null || !equip.getItemData().isEquip()) { if (equip == null || !equip.getItemData().isEquip()) {
return; return;
@ -86,8 +86,8 @@ public class InventoryManager {
player.sendPacket(new PacketSetEquipLockStateRsp(equip)); player.sendPacket(new PacketSetEquipLockStateRsp(equip));
} }
public void upgradeRelic(GenshinPlayer player, long targetGuid, List<Long> foodRelicList, List<ItemParam> list) { public void upgradeRelic(Player player, long targetGuid, List<Long> foodRelicList, List<ItemParam> list) {
GenshinItem relic = player.getInventory().getItemByGuid(targetGuid); GameItem relic = player.getInventory().getItemByGuid(targetGuid);
if (relic == null || relic.getItemType() != ItemType.ITEM_RELIQUARY) { if (relic == null || relic.getItemType() != ItemType.ITEM_RELIQUARY) {
return; return;
@ -98,7 +98,7 @@ public class InventoryManager {
for (long guid : foodRelicList) { for (long guid : foodRelicList) {
// Add to delete queue // Add to delete queue
GenshinItem food = player.getInventory().getItemByGuid(guid); GameItem food = player.getInventory().getItemByGuid(guid);
if (food == null || !food.isDestroyable()) { if (food == null || !food.isDestroyable()) {
continue; continue;
} }
@ -111,7 +111,7 @@ public class InventoryManager {
} }
} }
for (ItemParam itemParam : list) { for (ItemParam itemParam : list) {
GenshinItem food = player.getInventory().getInventoryTab(ItemType.ITEM_MATERIAL).getItemById(itemParam.getItemId()); GameItem food = player.getInventory().getInventoryTab(ItemType.ITEM_MATERIAL).getItemById(itemParam.getItemId());
if (food == null || food.getItemData().getMaterialType() != MaterialType.MATERIAL_RELIQUARY_MATERIAL) { if (food == null || food.getItemData().getMaterialType() != MaterialType.MATERIAL_RELIQUARY_MATERIAL) {
continue; continue;
} }
@ -139,14 +139,14 @@ public class InventoryManager {
// Consume food items // Consume food items
for (long guid : foodRelicList) { for (long guid : foodRelicList) {
GenshinItem food = player.getInventory().getItemByGuid(guid); GameItem food = player.getInventory().getItemByGuid(guid);
if (food == null || !food.isDestroyable()) { if (food == null || !food.isDestroyable()) {
continue; continue;
} }
player.getInventory().removeItem(food); player.getInventory().removeItem(food);
} }
for (ItemParam itemParam : list) { for (ItemParam itemParam : list) {
GenshinItem food = player.getInventory().getInventoryTab(ItemType.ITEM_MATERIAL).getItemById(itemParam.getItemId()); GameItem food = player.getInventory().getInventoryTab(ItemType.ITEM_MATERIAL).getItemById(itemParam.getItemId());
if (food == null || food.getItemData().getMaterialType() != MaterialType.MATERIAL_RELIQUARY_MATERIAL) { if (food == null || food.getItemData().getMaterialType() != MaterialType.MATERIAL_RELIQUARY_MATERIAL) {
continue; continue;
} }
@ -169,7 +169,7 @@ public class InventoryManager {
int oldLevel = level; int oldLevel = level;
int exp = relic.getExp(); int exp = relic.getExp();
int totalExp = relic.getTotalExp(); int totalExp = relic.getTotalExp();
int reqExp = GenshinData.getRelicExpRequired(relic.getItemData().getRankLevel(), level); int reqExp = GameData.getRelicExpRequired(relic.getItemData().getRankLevel(), level);
int upgrades = 0; int upgrades = 0;
List<Integer> oldAppendPropIdList = relic.getAppendPropIdList(); List<Integer> oldAppendPropIdList = relic.getAppendPropIdList();
@ -189,7 +189,7 @@ public class InventoryManager {
upgrades += 1; upgrades += 1;
} }
// Set req exp // Set req exp
reqExp = GenshinData.getRelicExpRequired(relic.getItemData().getRankLevel(), level); reqExp = GameData.getRelicExpRequired(relic.getItemData().getRankLevel(), level);
} }
} }
@ -209,7 +209,7 @@ public class InventoryManager {
// Avatar // Avatar
if (oldLevel != level) { if (oldLevel != level) {
GenshinAvatar avatar = relic.getEquipCharacter() > 0 ? player.getAvatars().getAvatarById(relic.getEquipCharacter()) : null; Avatar avatar = relic.getEquipCharacter() > 0 ? player.getAvatars().getAvatarById(relic.getEquipCharacter()) : null;
if (avatar != null) { if (avatar != null) {
avatar.recalcStats(); avatar.recalcStats();
} }
@ -220,15 +220,15 @@ public class InventoryManager {
player.sendPacket(new PacketReliquaryUpgradeRsp(relic, rate, oldLevel, oldAppendPropIdList)); player.sendPacket(new PacketReliquaryUpgradeRsp(relic, rate, oldLevel, oldAppendPropIdList));
} }
public List<ItemParam> calcWeaponUpgradeReturnItems(GenshinPlayer player, long targetGuid, List<Long> foodWeaponGuidList, List<ItemParam> itemParamList) { public List<ItemParam> calcWeaponUpgradeReturnItems(Player player, long targetGuid, List<Long> foodWeaponGuidList, List<ItemParam> itemParamList) {
GenshinItem weapon = player.getInventory().getItemByGuid(targetGuid); GameItem weapon = player.getInventory().getItemByGuid(targetGuid);
// Sanity checks // Sanity checks
if (weapon == null || weapon.getItemType() != ItemType.ITEM_WEAPON) { if (weapon == null || weapon.getItemType() != ItemType.ITEM_WEAPON) {
return null; return null;
} }
WeaponPromoteData promoteData = GenshinData.getWeaponPromoteData(weapon.getItemData().getWeaponPromoteId(), weapon.getPromoteLevel()); WeaponPromoteData promoteData = GameData.getWeaponPromoteData(weapon.getItemData().getWeaponPromoteId(), weapon.getPromoteLevel());
if (promoteData == null) { if (promoteData == null) {
return null; return null;
} }
@ -236,7 +236,7 @@ public class InventoryManager {
// Get exp gain // Get exp gain
int expGain = 0; int expGain = 0;
for (long guid : foodWeaponGuidList) { for (long guid : foodWeaponGuidList) {
GenshinItem food = player.getInventory().getItemByGuid(guid); GameItem food = player.getInventory().getItemByGuid(guid);
if (food == null) { if (food == null) {
continue; continue;
} }
@ -246,7 +246,7 @@ public class InventoryManager {
} }
} }
for (ItemParam param : itemParamList) { for (ItemParam param : itemParamList) {
GenshinItem food = player.getInventory().getInventoryTab(ItemType.ITEM_MATERIAL).getItemById(param.getItemId()); GameItem food = player.getInventory().getInventoryTab(ItemType.ITEM_MATERIAL).getItemById(param.getItemId());
if (food == null || food.getItemData().getMaterialType() != MaterialType.MATERIAL_WEAPON_EXP_STONE) { if (food == null || food.getItemData().getMaterialType() != MaterialType.MATERIAL_WEAPON_EXP_STONE) {
continue; continue;
} }
@ -264,7 +264,7 @@ public class InventoryManager {
int maxLevel = promoteData.getUnlockMaxLevel(); int maxLevel = promoteData.getUnlockMaxLevel();
int level = weapon.getLevel(); int level = weapon.getLevel();
int exp = weapon.getExp(); int exp = weapon.getExp();
int reqExp = GenshinData.getWeaponExpRequired(weapon.getItemData().getRankLevel(), level); int reqExp = GameData.getWeaponExpRequired(weapon.getItemData().getRankLevel(), level);
while (expGain > 0 && reqExp > 0 && level < maxLevel) { while (expGain > 0 && reqExp > 0 && level < maxLevel) {
// Do calculations // Do calculations
@ -277,7 +277,7 @@ public class InventoryManager {
exp = 0; exp = 0;
level += 1; level += 1;
// Set req exp // Set req exp
reqExp = GenshinData.getWeaponExpRequired(weapon.getItemData().getRankLevel(), level); reqExp = GameData.getWeaponExpRequired(weapon.getItemData().getRankLevel(), level);
} }
} }
@ -285,15 +285,15 @@ public class InventoryManager {
} }
public void upgradeWeapon(GenshinPlayer player, long targetGuid, List<Long> foodWeaponGuidList, List<ItemParam> itemParamList) { public void upgradeWeapon(Player player, long targetGuid, List<Long> foodWeaponGuidList, List<ItemParam> itemParamList) {
GenshinItem weapon = player.getInventory().getItemByGuid(targetGuid); GameItem weapon = player.getInventory().getItemByGuid(targetGuid);
// Sanity checks // Sanity checks
if (weapon == null || weapon.getItemType() != ItemType.ITEM_WEAPON) { if (weapon == null || weapon.getItemType() != ItemType.ITEM_WEAPON) {
return; return;
} }
WeaponPromoteData promoteData = GenshinData.getWeaponPromoteData(weapon.getItemData().getWeaponPromoteId(), weapon.getPromoteLevel()); WeaponPromoteData promoteData = GameData.getWeaponPromoteData(weapon.getItemData().getWeaponPromoteId(), weapon.getPromoteLevel());
if (promoteData == null) { if (promoteData == null) {
return; return;
} }
@ -302,7 +302,7 @@ public class InventoryManager {
int expGain = 0, moraCost = 0; int expGain = 0, moraCost = 0;
for (long guid : foodWeaponGuidList) { for (long guid : foodWeaponGuidList) {
GenshinItem food = player.getInventory().getItemByGuid(guid); GameItem food = player.getInventory().getItemByGuid(guid);
if (food == null || !food.isDestroyable()) { if (food == null || !food.isDestroyable()) {
continue; continue;
} }
@ -313,7 +313,7 @@ public class InventoryManager {
} }
} }
for (ItemParam param : itemParamList) { for (ItemParam param : itemParamList) {
GenshinItem food = player.getInventory().getInventoryTab(ItemType.ITEM_MATERIAL).getItemById(param.getItemId()); GameItem food = player.getInventory().getInventoryTab(ItemType.ITEM_MATERIAL).getItemById(param.getItemId());
if (food == null || food.getItemData().getMaterialType() != MaterialType.MATERIAL_WEAPON_EXP_STONE) { if (food == null || food.getItemData().getMaterialType() != MaterialType.MATERIAL_WEAPON_EXP_STONE) {
continue; continue;
} }
@ -344,14 +344,14 @@ public class InventoryManager {
// Consume weapon/items used to feed // Consume weapon/items used to feed
for (long guid : foodWeaponGuidList) { for (long guid : foodWeaponGuidList) {
GenshinItem food = player.getInventory().getItemByGuid(guid); GameItem food = player.getInventory().getItemByGuid(guid);
if (food == null || !food.isDestroyable()) { if (food == null || !food.isDestroyable()) {
continue; continue;
} }
player.getInventory().removeItem(food); player.getInventory().removeItem(food);
} }
for (ItemParam param : itemParamList) { for (ItemParam param : itemParamList) {
GenshinItem food = player.getInventory().getInventoryTab(ItemType.ITEM_MATERIAL).getItemById(param.getItemId()); GameItem food = player.getInventory().getInventoryTab(ItemType.ITEM_MATERIAL).getItemById(param.getItemId());
if (food == null || food.getItemData().getMaterialType() != MaterialType.MATERIAL_WEAPON_EXP_STONE) { if (food == null || food.getItemData().getMaterialType() != MaterialType.MATERIAL_WEAPON_EXP_STONE) {
continue; continue;
} }
@ -365,7 +365,7 @@ public class InventoryManager {
int oldLevel = level; int oldLevel = level;
int exp = weapon.getExp(); int exp = weapon.getExp();
int totalExp = weapon.getTotalExp(); int totalExp = weapon.getTotalExp();
int reqExp = GenshinData.getWeaponExpRequired(weapon.getItemData().getRankLevel(), level); int reqExp = GameData.getWeaponExpRequired(weapon.getItemData().getRankLevel(), level);
while (expGain > 0 && reqExp > 0 && level < maxLevel) { while (expGain > 0 && reqExp > 0 && level < maxLevel) {
// Do calculations // Do calculations
@ -379,7 +379,7 @@ public class InventoryManager {
exp = 0; exp = 0;
level += 1; level += 1;
// Set req exp // Set req exp
reqExp = GenshinData.getWeaponExpRequired(weapon.getItemData().getRankLevel(), level); reqExp = GameData.getWeaponExpRequired(weapon.getItemData().getRankLevel(), level);
} }
} }
@ -393,7 +393,7 @@ public class InventoryManager {
// Avatar // Avatar
if (oldLevel != level) { if (oldLevel != level) {
GenshinAvatar avatar = weapon.getEquipCharacter() > 0 ? player.getAvatars().getAvatarById(weapon.getEquipCharacter()) : null; Avatar avatar = weapon.getEquipCharacter() > 0 ? player.getAvatars().getAvatarById(weapon.getEquipCharacter()) : null;
if (avatar != null) { if (avatar != null) {
avatar.recalcStats(); avatar.recalcStats();
} }
@ -429,9 +429,9 @@ public class InventoryManager {
return leftoverOreList; return leftoverOreList;
} }
public void refineWeapon(GenshinPlayer player, long targetGuid, long feedGuid) { public void refineWeapon(Player player, long targetGuid, long feedGuid) {
GenshinItem weapon = player.getInventory().getItemByGuid(targetGuid); GameItem weapon = player.getInventory().getItemByGuid(targetGuid);
GenshinItem feed = player.getInventory().getItemByGuid(feedGuid); GameItem feed = player.getInventory().getItemByGuid(feedGuid);
// Sanity checks // Sanity checks
if (weapon == null || feed == null || !feed.isDestroyable()) { if (weapon == null || feed == null || !feed.isDestroyable()) {
@ -478,7 +478,7 @@ public class InventoryManager {
weapon.save(); weapon.save();
// Avatar // Avatar
GenshinAvatar avatar = weapon.getEquipCharacter() > 0 ? player.getAvatars().getAvatarById(weapon.getEquipCharacter()) : null; Avatar avatar = weapon.getEquipCharacter() > 0 ? player.getAvatars().getAvatarById(weapon.getEquipCharacter()) : null;
if (avatar != null) { if (avatar != null) {
avatar.recalcStats(); avatar.recalcStats();
} }
@ -488,16 +488,16 @@ public class InventoryManager {
player.sendPacket(new PacketWeaponAwakenRsp(avatar, weapon, feed, oldRefineLevel)); player.sendPacket(new PacketWeaponAwakenRsp(avatar, weapon, feed, oldRefineLevel));
} }
public void promoteWeapon(GenshinPlayer player, long targetGuid) { public void promoteWeapon(Player player, long targetGuid) {
GenshinItem weapon = player.getInventory().getItemByGuid(targetGuid); GameItem weapon = player.getInventory().getItemByGuid(targetGuid);
if (weapon == null || weapon.getItemType() != ItemType.ITEM_WEAPON) { if (weapon == null || weapon.getItemType() != ItemType.ITEM_WEAPON) {
return; return;
} }
int nextPromoteLevel = weapon.getPromoteLevel() + 1; int nextPromoteLevel = weapon.getPromoteLevel() + 1;
WeaponPromoteData currentPromoteData = GenshinData.getWeaponPromoteData(weapon.getItemData().getWeaponPromoteId(), weapon.getPromoteLevel()); WeaponPromoteData currentPromoteData = GameData.getWeaponPromoteData(weapon.getItemData().getWeaponPromoteId(), weapon.getPromoteLevel());
WeaponPromoteData nextPromoteData = GenshinData.getWeaponPromoteData(weapon.getItemData().getWeaponPromoteId(), nextPromoteLevel); WeaponPromoteData nextPromoteData = GameData.getWeaponPromoteData(weapon.getItemData().getWeaponPromoteId(), nextPromoteLevel);
if (currentPromoteData == null || nextPromoteData == null) { if (currentPromoteData == null || nextPromoteData == null) {
return; return;
} }
@ -509,7 +509,7 @@ public class InventoryManager {
// Make sure player has promote items // Make sure player has promote items
for (ItemParamData cost : nextPromoteData.getCostItems()) { for (ItemParamData cost : nextPromoteData.getCostItems()) {
GenshinItem feedItem = player.getInventory().getInventoryTab(ItemType.ITEM_MATERIAL).getItemById(cost.getId()); GameItem feedItem = player.getInventory().getInventoryTab(ItemType.ITEM_MATERIAL).getItemById(cost.getId());
if (feedItem == null || feedItem.getCount() < cost.getCount()) { if (feedItem == null || feedItem.getCount() < cost.getCount()) {
return; return;
} }
@ -524,7 +524,7 @@ public class InventoryManager {
// Consume promote filler items // Consume promote filler items
for (ItemParamData cost : nextPromoteData.getCostItems()) { for (ItemParamData cost : nextPromoteData.getCostItems()) {
GenshinItem feedItem = player.getInventory().getInventoryTab(ItemType.ITEM_MATERIAL).getItemById(cost.getId()); GameItem feedItem = player.getInventory().getInventoryTab(ItemType.ITEM_MATERIAL).getItemById(cost.getId());
player.getInventory().removeItem(feedItem, cost.getCount()); player.getInventory().removeItem(feedItem, cost.getCount());
} }
@ -533,7 +533,7 @@ public class InventoryManager {
weapon.save(); weapon.save();
// Avatar // Avatar
GenshinAvatar avatar = weapon.getEquipCharacter() > 0 ? player.getAvatars().getAvatarById(weapon.getEquipCharacter()) : null; Avatar avatar = weapon.getEquipCharacter() > 0 ? player.getAvatars().getAvatarById(weapon.getEquipCharacter()) : null;
if (avatar != null) { if (avatar != null) {
avatar.recalcStats(); avatar.recalcStats();
} }
@ -543,8 +543,8 @@ public class InventoryManager {
player.sendPacket(new PacketWeaponPromoteRsp(weapon, oldPromoteLevel)); player.sendPacket(new PacketWeaponPromoteRsp(weapon, oldPromoteLevel));
} }
public void promoteAvatar(GenshinPlayer player, long guid) { public void promoteAvatar(Player player, long guid) {
GenshinAvatar avatar = player.getAvatars().getAvatarByGuid(guid); Avatar avatar = player.getAvatars().getAvatarByGuid(guid);
// Sanity checks // Sanity checks
if (avatar == null) { if (avatar == null) {
@ -552,8 +552,8 @@ public class InventoryManager {
} }
int nextPromoteLevel = avatar.getPromoteLevel() + 1; int nextPromoteLevel = avatar.getPromoteLevel() + 1;
AvatarPromoteData currentPromoteData = GenshinData.getAvatarPromoteData(avatar.getAvatarData().getAvatarPromoteId(), avatar.getPromoteLevel()); AvatarPromoteData currentPromoteData = GameData.getAvatarPromoteData(avatar.getAvatarData().getAvatarPromoteId(), avatar.getPromoteLevel());
AvatarPromoteData nextPromoteData = GenshinData.getAvatarPromoteData(avatar.getAvatarData().getAvatarPromoteId(), nextPromoteLevel); AvatarPromoteData nextPromoteData = GameData.getAvatarPromoteData(avatar.getAvatarData().getAvatarPromoteId(), nextPromoteLevel);
if (currentPromoteData == null || nextPromoteData == null) { if (currentPromoteData == null || nextPromoteData == null) {
return; return;
} }
@ -565,7 +565,7 @@ public class InventoryManager {
// Make sure player has cost items // Make sure player has cost items
for (ItemParamData cost : nextPromoteData.getCostItems()) { for (ItemParamData cost : nextPromoteData.getCostItems()) {
GenshinItem feedItem = player.getInventory().getInventoryTab(ItemType.ITEM_MATERIAL).getItemById(cost.getId()); GameItem feedItem = player.getInventory().getInventoryTab(ItemType.ITEM_MATERIAL).getItemById(cost.getId());
if (feedItem == null || feedItem.getCount() < cost.getCount()) { if (feedItem == null || feedItem.getCount() < cost.getCount()) {
return; return;
} }
@ -580,7 +580,7 @@ public class InventoryManager {
// Consume promote filler items // Consume promote filler items
for (ItemParamData cost : nextPromoteData.getCostItems()) { for (ItemParamData cost : nextPromoteData.getCostItems()) {
GenshinItem feedItem = player.getInventory().getInventoryTab(ItemType.ITEM_MATERIAL).getItemById(cost.getId()); GameItem feedItem = player.getInventory().getInventoryTab(ItemType.ITEM_MATERIAL).getItemById(cost.getId());
player.getInventory().removeItem(feedItem, cost.getCount()); player.getInventory().removeItem(feedItem, cost.getCount());
} }
@ -588,7 +588,7 @@ public class InventoryManager {
avatar.setPromoteLevel(nextPromoteLevel); avatar.setPromoteLevel(nextPromoteLevel);
// Update proud skills // Update proud skills
AvatarSkillDepotData skillDepot = GenshinData.getAvatarSkillDepotDataMap().get(avatar.getSkillDepotId()); AvatarSkillDepotData skillDepot = GameData.getAvatarSkillDepotDataMap().get(avatar.getSkillDepotId());
if (skillDepot != null && skillDepot.getInherentProudSkillOpens() != null) { if (skillDepot != null && skillDepot.getInherentProudSkillOpens() != null) {
for (InherentProudSkillOpens openData : skillDepot.getInherentProudSkillOpens()) { for (InherentProudSkillOpens openData : skillDepot.getInherentProudSkillOpens()) {
@ -597,7 +597,7 @@ public class InventoryManager {
} }
if (openData.getNeedAvatarPromoteLevel() == avatar.getPromoteLevel()) { if (openData.getNeedAvatarPromoteLevel() == avatar.getPromoteLevel()) {
int proudSkillId = (openData.getProudSkillGroupId() * 100) + 1; int proudSkillId = (openData.getProudSkillGroupId() * 100) + 1;
if (GenshinData.getProudSkillDataMap().containsKey(proudSkillId)) { if (GameData.getProudSkillDataMap().containsKey(proudSkillId)) {
avatar.getProudSkillList().add(proudSkillId); avatar.getProudSkillList().add(proudSkillId);
player.sendPacket(new PacketProudSkillChangeNotify(avatar)); player.sendPacket(new PacketProudSkillChangeNotify(avatar));
} }
@ -614,20 +614,20 @@ public class InventoryManager {
avatar.save(); avatar.save();
} }
public void upgradeAvatar(GenshinPlayer player, long guid, int itemId, int count) { public void upgradeAvatar(Player player, long guid, int itemId, int count) {
GenshinAvatar avatar = player.getAvatars().getAvatarByGuid(guid); Avatar avatar = player.getAvatars().getAvatarByGuid(guid);
// Sanity checks // Sanity checks
if (avatar == null) { if (avatar == null) {
return; return;
} }
AvatarPromoteData promoteData = GenshinData.getAvatarPromoteData(avatar.getAvatarData().getAvatarPromoteId(), avatar.getPromoteLevel()); AvatarPromoteData promoteData = GameData.getAvatarPromoteData(avatar.getAvatarData().getAvatarPromoteId(), avatar.getPromoteLevel());
if (promoteData == null) { if (promoteData == null) {
return; return;
} }
GenshinItem feedItem = player.getInventory().getInventoryTab(ItemType.ITEM_MATERIAL).getItemById(itemId); GameItem feedItem = player.getInventory().getInventoryTab(ItemType.ITEM_MATERIAL).getItemById(itemId);
if (feedItem == null || feedItem.getItemData().getMaterialType() != MaterialType.MATERIAL_EXP_FRUIT || feedItem.getCount() < count) { if (feedItem == null || feedItem.getItemData().getMaterialType() != MaterialType.MATERIAL_EXP_FRUIT || feedItem.getCount() < count) {
return; return;
@ -660,8 +660,8 @@ public class InventoryManager {
upgradeAvatar(player, avatar, promoteData, expGain); upgradeAvatar(player, avatar, promoteData, expGain);
} }
public void upgradeAvatar(GenshinPlayer player, GenshinAvatar avatar, int expGain) { public void upgradeAvatar(Player player, Avatar avatar, int expGain) {
AvatarPromoteData promoteData = GenshinData.getAvatarPromoteData(avatar.getAvatarData().getAvatarPromoteId(), avatar.getPromoteLevel()); AvatarPromoteData promoteData = GameData.getAvatarPromoteData(avatar.getAvatarData().getAvatarPromoteId(), avatar.getPromoteLevel());
if (promoteData == null) { if (promoteData == null) {
return; return;
} }
@ -669,12 +669,12 @@ public class InventoryManager {
upgradeAvatar(player, avatar, promoteData, expGain); upgradeAvatar(player, avatar, promoteData, expGain);
} }
public void upgradeAvatar(GenshinPlayer player, GenshinAvatar avatar, AvatarPromoteData promoteData, int expGain) { public void upgradeAvatar(Player player, Avatar avatar, AvatarPromoteData promoteData, int expGain) {
int maxLevel = promoteData.getUnlockMaxLevel(); int maxLevel = promoteData.getUnlockMaxLevel();
int level = avatar.getLevel(); int level = avatar.getLevel();
int oldLevel = level; int oldLevel = level;
int exp = avatar.getExp(); int exp = avatar.getExp();
int reqExp = GenshinData.getAvatarLevelExpRequired(level); int reqExp = GameData.getAvatarLevelExpRequired(level);
while (expGain > 0 && reqExp > 0 && level < maxLevel) { while (expGain > 0 && reqExp > 0 && level < maxLevel) {
// Do calculations // Do calculations
@ -687,7 +687,7 @@ public class InventoryManager {
exp = 0; exp = 0;
level += 1; level += 1;
// Set req exp // Set req exp
reqExp = GenshinData.getAvatarLevelExpRequired(level); reqExp = GameData.getAvatarLevelExpRequired(level);
} }
} }
@ -711,12 +711,12 @@ public class InventoryManager {
player.sendPacket(new PacketAvatarUpgradeRsp(avatar, oldLevel, oldPropMap)); player.sendPacket(new PacketAvatarUpgradeRsp(avatar, oldLevel, oldPropMap));
} }
public void upgradeAvatarFetterLevel(GenshinPlayer player, GenshinAvatar avatar, int expGain) { public void upgradeAvatarFetterLevel(Player player, Avatar avatar, int expGain) {
// May work. Not test. // May work. Not test.
int maxLevel = 10; // Keep it until I think of a more "elegant" way int maxLevel = 10; // Keep it until I think of a more "elegant" way
int level = avatar.getFetterLevel(); int level = avatar.getFetterLevel();
int exp = avatar.getFetterExp(); int exp = avatar.getFetterExp();
int reqExp = GenshinData.getAvatarFetterLevelExpRequired(level); int reqExp = GameData.getAvatarFetterLevelExpRequired(level);
while (expGain > 0 && reqExp > 0 && level < maxLevel) { while (expGain > 0 && reqExp > 0 && level < maxLevel) {
int toGain = Math.min(expGain, reqExp - exp); int toGain = Math.min(expGain, reqExp - exp);
@ -725,7 +725,7 @@ public class InventoryManager {
if (exp >= reqExp) { if (exp >= reqExp) {
exp = 0; exp = 0;
level += 1; level += 1;
reqExp = GenshinData.getAvatarFetterLevelExpRequired(level); reqExp = GameData.getAvatarFetterLevelExpRequired(level);
} }
} }
@ -736,9 +736,9 @@ public class InventoryManager {
player.sendPacket(new PacketAvatarPropNotify(avatar)); player.sendPacket(new PacketAvatarPropNotify(avatar));
} }
public void upgradeAvatarSkill(GenshinPlayer player, long guid, int skillId) { public void upgradeAvatarSkill(Player player, long guid, int skillId) {
// Sanity checks // Sanity checks
GenshinAvatar avatar = player.getAvatars().getAvatarByGuid(guid); Avatar avatar = player.getAvatars().getAvatarByGuid(guid);
if (avatar == null) { if (avatar == null) {
return; return;
} }
@ -748,7 +748,7 @@ public class InventoryManager {
return; return;
} }
AvatarSkillData skillData = GenshinData.getAvatarSkillDataMap().get(skillId); AvatarSkillData skillData = GameData.getAvatarSkillDataMap().get(skillId);
if (skillData == null) { if (skillData == null) {
return; return;
} }
@ -764,7 +764,7 @@ public class InventoryManager {
} }
// Proud skill data // Proud skill data
ProudSkillData proudSkill = GenshinData.getProudSkillDataMap().get(proudSkillId); ProudSkillData proudSkill = GameData.getProudSkillDataMap().get(proudSkillId);
if (proudSkill == null) { if (proudSkill == null) {
return; return;
} }
@ -779,7 +779,7 @@ public class InventoryManager {
if (cost.getId() == 0) { if (cost.getId() == 0) {
continue; continue;
} }
GenshinItem feedItem = player.getInventory().getInventoryTab(ItemType.ITEM_MATERIAL).getItemById(cost.getId()); GameItem feedItem = player.getInventory().getInventoryTab(ItemType.ITEM_MATERIAL).getItemById(cost.getId());
if (feedItem == null || feedItem.getCount() < cost.getCount()) { if (feedItem == null || feedItem.getCount() < cost.getCount()) {
return; return;
} }
@ -797,7 +797,7 @@ public class InventoryManager {
if (cost.getId() == 0) { if (cost.getId() == 0) {
continue; continue;
} }
GenshinItem feedItem = player.getInventory().getInventoryTab(ItemType.ITEM_MATERIAL).getItemById(cost.getId()); GameItem feedItem = player.getInventory().getInventoryTab(ItemType.ITEM_MATERIAL).getItemById(cost.getId());
player.getInventory().removeItem(feedItem, cost.getCount()); player.getInventory().removeItem(feedItem, cost.getCount());
} }
@ -810,9 +810,9 @@ public class InventoryManager {
player.sendPacket(new PacketAvatarSkillUpgradeRsp(avatar, skillId, currentLevel, nextLevel)); player.sendPacket(new PacketAvatarSkillUpgradeRsp(avatar, skillId, currentLevel, nextLevel));
} }
public void unlockAvatarConstellation(GenshinPlayer player, long guid) { public void unlockAvatarConstellation(Player player, long guid) {
// Sanity checks // Sanity checks
GenshinAvatar avatar = player.getAvatars().getAvatarByGuid(guid); Avatar avatar = player.getAvatars().getAvatarByGuid(guid);
if (avatar == null) { if (avatar == null) {
return; return;
} }
@ -826,13 +826,13 @@ public class InventoryManager {
nextTalentId = 40 + currentTalentLevel + 1; nextTalentId = 40 + currentTalentLevel + 1;
} }
AvatarTalentData talentData = GenshinData.getAvatarTalentDataMap().get(nextTalentId); AvatarTalentData talentData = GameData.getAvatarTalentDataMap().get(nextTalentId);
if (talentData == null) { if (talentData == null) {
return; return;
} }
GenshinItem costItem = player.getInventory().getInventoryTab(ItemType.ITEM_MATERIAL).getItemById(talentData.getMainCostItemId()); GameItem costItem = player.getInventory().getInventoryTab(ItemType.ITEM_MATERIAL).getItemById(talentData.getMainCostItemId());
if (costItem == null || costItem.getCount() < talentData.getMainCostItemCount()) { if (costItem == null || costItem.getCount() < talentData.getMainCostItemCount()) {
return; return;
} }
@ -849,7 +849,7 @@ public class InventoryManager {
player.sendPacket(new PacketUnlockAvatarTalentRsp(avatar, nextTalentId)); player.sendPacket(new PacketUnlockAvatarTalentRsp(avatar, nextTalentId));
// Proud skill bonus map (Extra skills) // Proud skill bonus map (Extra skills)
OpenConfigEntry entry = GenshinData.getOpenConfigEntries().get(talentData.getOpenConfig()); OpenConfigEntry entry = GameData.getOpenConfigEntries().get(talentData.getOpenConfig());
if (entry != null && entry.getExtraTalentIndex() > 0) { if (entry != null && entry.getExtraTalentIndex() > 0) {
avatar.recalcProudSkillBonusMap(); avatar.recalcProudSkillBonusMap();
player.sendPacket(new PacketProudSkillExtraLevelNotify(avatar, entry.getExtraTalentIndex())); player.sendPacket(new PacketProudSkillExtraLevelNotify(avatar, entry.getExtraTalentIndex()));
@ -860,7 +860,7 @@ public class InventoryManager {
avatar.save(); avatar.save();
} }
public void destroyMaterial(GenshinPlayer player, List<MaterialInfo> list) { public void destroyMaterial(Player player, List<MaterialInfo> list) {
// Return materials // Return materials
Int2IntOpenHashMap returnMaterialMap = new Int2IntOpenHashMap(); Int2IntOpenHashMap returnMaterialMap = new Int2IntOpenHashMap();
@ -870,7 +870,7 @@ public class InventoryManager {
continue; continue;
} }
GenshinItem item = player.getInventory().getItemByGuid(info.getGuid()); GameItem item = player.getInventory().getItemByGuid(info.getGuid());
if (item == null || !item.isDestroyable()) { if (item == null || !item.isDestroyable()) {
continue; continue;
} }
@ -890,7 +890,7 @@ public class InventoryManager {
// Give back items // Give back items
if (returnMaterialMap.size() > 0) { if (returnMaterialMap.size() > 0) {
for (Int2IntMap.Entry e : returnMaterialMap.int2IntEntrySet()) { for (Int2IntMap.Entry e : returnMaterialMap.int2IntEntrySet()) {
player.getInventory().addItem(new GenshinItem(e.getIntKey(), e.getIntValue())); player.getInventory().addItem(new GameItem(e.getIntKey(), e.getIntValue()));
} }
} }
@ -898,9 +898,9 @@ public class InventoryManager {
player.sendPacket(new PacketDestroyMaterialRsp(returnMaterialMap)); player.sendPacket(new PacketDestroyMaterialRsp(returnMaterialMap));
} }
public GenshinItem useItem(GenshinPlayer player, long targetGuid, long itemGuid, int count) { public GameItem useItem(Player player, long targetGuid, long itemGuid, int count) {
GenshinAvatar target = player.getAvatars().getAvatarByGuid(targetGuid); Avatar target = player.getAvatars().getAvatarByGuid(targetGuid);
GenshinItem useItem = player.getInventory().getItemByGuid(itemGuid); GameItem useItem = player.getInventory().getItemByGuid(itemGuid);
if (useItem == null) { if (useItem == null) {
return null; return null;

View File

@ -1,8 +1,8 @@
package emu.grasscutter.game.managers; package emu.grasscutter.game.managers;
import emu.grasscutter.game.CoopRequest; import emu.grasscutter.game.CoopRequest;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.Player;
import emu.grasscutter.game.GenshinPlayer.SceneLoadState; import emu.grasscutter.game.Player.SceneLoadState;
import emu.grasscutter.game.props.EnterReason; import emu.grasscutter.game.props.EnterReason;
import emu.grasscutter.net.proto.EnterTypeOuterClass.EnterType; import emu.grasscutter.net.proto.EnterTypeOuterClass.EnterType;
import emu.grasscutter.net.proto.PlayerApplyEnterMpReasonOuterClass.PlayerApplyEnterMpReason; import emu.grasscutter.net.proto.PlayerApplyEnterMpReasonOuterClass.PlayerApplyEnterMpReason;
@ -24,8 +24,8 @@ public class MultiplayerManager {
return server; return server;
} }
public void applyEnterMp(GenshinPlayer player, int targetUid) { public void applyEnterMp(Player player, int targetUid) {
GenshinPlayer target = getServer().getPlayerByUid(targetUid); Player target = getServer().getPlayerByUid(targetUid);
if (target == null) { if (target == null) {
player.sendPacket(new PacketPlayerApplyEnterMpResultNotify(targetUid, "", false, PlayerApplyEnterMpResultNotifyOuterClass.PlayerApplyEnterMpResultNotify.Reason.PLAYER_CANNOT_ENTER_MP)); player.sendPacket(new PacketPlayerApplyEnterMpResultNotify(targetUid, "", false, PlayerApplyEnterMpResultNotifyOuterClass.PlayerApplyEnterMpResultNotify.Reason.PLAYER_CANNOT_ENTER_MP));
return; return;
@ -59,7 +59,7 @@ public class MultiplayerManager {
target.sendPacket(new PacketPlayerApplyEnterMpNotify(player)); target.sendPacket(new PacketPlayerApplyEnterMpNotify(player));
} }
public void applyEnterMpReply(GenshinPlayer hostPlayer, int applyUid, boolean isAgreed) { public void applyEnterMpReply(Player hostPlayer, int applyUid, boolean isAgreed) {
// Checks // Checks
CoopRequest request = hostPlayer.getCoopRequests().get(applyUid); CoopRequest request = hostPlayer.getCoopRequests().get(applyUid);
if (request == null || request.isExpired()) { if (request == null || request.isExpired()) {
@ -67,7 +67,7 @@ public class MultiplayerManager {
} }
// Remove now that we are handling it // Remove now that we are handling it
GenshinPlayer requester = request.getRequester(); Player requester = request.getRequester();
hostPlayer.getCoopRequests().remove(applyUid); hostPlayer.getCoopRequests().remove(applyUid);
// Sanity checks - Dont let the requesting player join if they are already in multiplayer // Sanity checks - Dont let the requesting player join if they are already in multiplayer
@ -108,14 +108,14 @@ public class MultiplayerManager {
requester.sendPacket(new PacketPlayerEnterSceneNotify(requester, hostPlayer, EnterType.ENTER_OTHER, EnterReason.TeamJoin, hostPlayer.getScene().getId(), hostPlayer.getPos())); requester.sendPacket(new PacketPlayerEnterSceneNotify(requester, hostPlayer, EnterType.ENTER_OTHER, EnterReason.TeamJoin, hostPlayer.getScene().getId(), hostPlayer.getPos()));
} }
public boolean leaveCoop(GenshinPlayer player) { public boolean leaveCoop(Player player) {
// Make sure player's world is multiplayer // Make sure player's world is multiplayer
if (!player.getWorld().isMultiplayer()) { if (!player.getWorld().isMultiplayer()) {
return false; return false;
} }
// Make sure everyone's scene is loaded // Make sure everyone's scene is loaded
for (GenshinPlayer p : player.getWorld().getPlayers()) { for (Player p : player.getWorld().getPlayers()) {
if (p.getSceneLoadState() != SceneLoadState.LOADED) { if (p.getSceneLoadState() != SceneLoadState.LOADED) {
return false; return false;
} }
@ -131,14 +131,14 @@ public class MultiplayerManager {
return true; return true;
} }
public boolean kickPlayer(GenshinPlayer player, int targetUid) { public boolean kickPlayer(Player player, int targetUid) {
// Make sure player's world is multiplayer and that player is owner // Make sure player's world is multiplayer and that player is owner
if (!player.getWorld().isMultiplayer() || player.getWorld().getHost() != player) { if (!player.getWorld().isMultiplayer() || player.getWorld().getHost() != player) {
return false; return false;
} }
// Get victim and sanity checks // Get victim and sanity checks
GenshinPlayer victim = player.getServer().getPlayerByUid(targetUid); Player victim = player.getServer().getPlayerByUid(targetUid);
if (victim == null || victim == player) { if (victim == null || victim == player) {
return false; return false;

View File

@ -7,7 +7,7 @@ import com.google.protobuf.GeneratedMessageV3;
import emu.grasscutter.net.proto.PacketHeadOuterClass.PacketHead; import emu.grasscutter.net.proto.PacketHeadOuterClass.PacketHead;
import emu.grasscutter.utils.Crypto; import emu.grasscutter.utils.Crypto;
public class GenshinPacket { public class BasePacket {
private static final int const1 = 17767; // 0x4567 private static final int const1 = 17767; // 0x4567
private static final int const2 = -30293; // 0x89ab private static final int const2 = -30293; // 0x89ab
@ -21,16 +21,16 @@ public class GenshinPacket {
private boolean useDispatchKey; private boolean useDispatchKey;
public boolean shouldEncrypt = true; public boolean shouldEncrypt = true;
public GenshinPacket(int opcode) { public BasePacket(int opcode) {
this.opcode = opcode; this.opcode = opcode;
} }
public GenshinPacket(int opcode, int clientSequence) { public BasePacket(int opcode, int clientSequence) {
this.opcode = opcode; this.opcode = opcode;
this.buildHeader(clientSequence); this.buildHeader(clientSequence);
} }
public GenshinPacket(int opcode, boolean buildHeader) { public BasePacket(int opcode, boolean buildHeader) {
this.opcode = opcode; this.opcode = opcode;
this.shouldBuildHeader = buildHeader; this.shouldBuildHeader = buildHeader;
} }
@ -80,7 +80,7 @@ public class GenshinPacket {
this.data = proto.build().toByteArray(); this.data = proto.build().toByteArray();
} }
public GenshinPacket buildHeader(int clientSequence) { public BasePacket buildHeader(int clientSequence) {
if (this.getHeader() != null && clientSequence == 0) { if (this.getHeader() != null && clientSequence == 0) {
return this; return this;
} }

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