Commit d9fc1595 authored by Melledy's avatar Melledy
Browse files

Refactor some commands and move inventory/team limits to the config

parent 7417a1b6
......@@ -123,7 +123,7 @@ public class GameSession extends MihoyoKcpChannel {
// Save
getPlayer().onLogout();
// Remove from gameserver
getServer().getPlayers().remove(getPlayer().getId());
getServer().getPlayers().remove(getPlayer().getUid());
}
}
......
......@@ -15,7 +15,7 @@ public class HandlerGetPlayerSocialDetailReq extends PacketHandler {
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
GetPlayerSocialDetailReq req = GetPlayerSocialDetailReq.parseFrom(payload);
SocialDetail.Builder detail = session.getServer().getSocialDetailById(req.getUid());
SocialDetail.Builder detail = session.getServer().getSocialDetailByUid(req.getUid());
if (detail != null) {
detail.setIsFriend(session.getPlayer().getFriendsList().isFriendsWith(req.getUid()));
......
......@@ -28,7 +28,7 @@ public class HandlerMarkMapReq extends PacketHandler {
session.getPlayer().getPos().setZ(req.getMark().getPos().getZ());
session.getPlayer().getPos().setY(300);
Grasscutter.getLogger().info("Player [" + session.getPlayer().getId() + ":" + session.getPlayer().getNickname() + "] tp to " + session.getPlayer().getPos() + " Scene id: " + req.getMark().getSceneId());
Grasscutter.getLogger().info("Player [" + session.getPlayer().getUid() + ":" + session.getPlayer().getNickname() + "] tp to " + session.getPlayer().getPos() + " Scene id: " + req.getMark().getSceneId());
if (req.getMark().getSceneId() != session.getPlayer().getSceneId()) {
session.getPlayer().getWorld().transferPlayerToScene(session.getPlayer(), req.getMark().getSceneId(), session.getPlayer().getPos());
......
......@@ -57,7 +57,7 @@ public class HandlerSetPlayerBornDataReq extends PacketHandler {
}
// Save account
session.getAccount().setPlayerId(player.getId());
session.getAccount().setPlayerId(player.getUid());
session.getAccount().save();
// Set character
......
......@@ -14,7 +14,7 @@ public class PacketGetPlayerAskFriendListRsp extends GenshinPacket {
GetPlayerAskFriendListRsp.Builder proto = GetPlayerAskFriendListRsp.newBuilder();
for (Friendship friendship : player.getFriendsList().getPendingFriends().values()) {
if (friendship.getAskerId() == player.getId()) {
if (friendship.getAskerId() == player.getUid()) {
continue;
}
proto.addAskFriendList(friendship.toProto());
......
......@@ -37,7 +37,7 @@ public class PacketGetPlayerFriendListRsp extends GenshinPacket {
proto.addFriendList(friendship.toProto());
}
for (Friendship friendship : player.getFriendsList().getPendingFriends().values()) {
if (friendship.getAskerId() == player.getId()) {
if (friendship.getAskerId() == player.getUid()) {
continue;
}
proto.addAskFriendList(friendship.toProto());
......
......@@ -11,7 +11,7 @@ public class PacketHostPlayerNotify extends GenshinPacket {
super(PacketOpcodes.HostPlayerNotify);
HostPlayerNotify proto = HostPlayerNotify.newBuilder()
.setHostUid(world.getHost().getId())
.setHostUid(world.getHost().getUid())
.setHostPeerId(world.getHost().getPeerId())
.build();
......
......@@ -12,7 +12,7 @@ public class PacketPlayerApplyEnterMpResultNotify extends GenshinPacket {
super(PacketOpcodes.PlayerApplyEnterMpResultNotify);
PlayerApplyEnterMpResultNotify proto = PlayerApplyEnterMpResultNotify.newBuilder()
.setTargetUid(target.getId())
.setTargetUid(target.getUid())
.setTargetNickname(target.getNickname())
.setIsAgreed(isAgreed)
.setReason(reason)
......
......@@ -14,7 +14,7 @@ public class PacketPlayerChatNotify extends GenshinPacket {
ChatInfo info = ChatInfo.newBuilder()
.setTime((int) (System.currentTimeMillis() / 1000))
.setUid(sender.getId())
.setUid(sender.getUid())
.setText(message)
.build();
......@@ -31,7 +31,7 @@ public class PacketPlayerChatNotify extends GenshinPacket {
ChatInfo info = ChatInfo.newBuilder()
.setTime((int) (System.currentTimeMillis() / 1000))
.setUid(sender.getId())
.setUid(sender.getUid())
.setIcon(emote)
.build();
......@@ -48,7 +48,7 @@ public class PacketPlayerChatNotify extends GenshinPacket {
ChatInfo info = ChatInfo.newBuilder()
.setTime((int) (System.currentTimeMillis() / 1000))
.setUid(sender.getId())
.setUid(sender.getUid())
.setSystemHint(systemHint)
.build();
......
......@@ -24,13 +24,13 @@ public class PacketPlayerEnterSceneNotify extends GenshinPacket {
.setPos(player.getPos().toProto())
.setSceneBeginTime(System.currentTimeMillis())
.setType(EnterType.EnterSelf)
.setTargetUid(player.getId())
.setTargetUid(player.getUid())
.setEnterSceneToken(player.getEnterSceneToken())
.setWorldLevel(player.getWorldLevel())
.setEnterReason(EnterReason.Login.getValue())
.setIsFirstLoginEnterScene(player.isFirstLoginEnterScene())
.setUnk1(1)
.setUnk2("3-" + player.getId() + "-" + (int) (System.currentTimeMillis() / 1000) + "-" + 18402)
.setUnk2("3-" + player.getUid() + "-" + (int) (System.currentTimeMillis() / 1000) + "-" + 18402)
.build();
this.setData(proto);
......@@ -53,7 +53,7 @@ public class PacketPlayerEnterSceneNotify extends GenshinPacket {
.setPos(newPos.toProto())
.setSceneBeginTime(System.currentTimeMillis())
.setType(EnterType.EnterSelf)
.setTargetUid(target.getId())
.setTargetUid(target.getUid())
.setEnterSceneToken(player.getEnterSceneToken())
.setWorldLevel(target.getWorld().getWorldLevel())
.setEnterReason(reason.getValue())
......@@ -62,7 +62,7 @@ public class PacketPlayerEnterSceneNotify extends GenshinPacket {
.addSceneTagIdList(113)
.addSceneTagIdList(117)
.setUnk1(1)
.setUnk2(newScene + "-" + target.getId() + "-" + (int) (System.currentTimeMillis() / 1000) + "-" + 18402)
.setUnk2(newScene + "-" + target.getUid() + "-" + (int) (System.currentTimeMillis() / 1000) + "-" + 18402)
.build();
this.setData(proto);
......
......@@ -13,7 +13,7 @@ public class PacketPlayerGameTimeNotify extends GenshinPacket {
PlayerGameTimeNotify proto = PlayerGameTimeNotify.newBuilder()
.setGameTime(player.getScene().getTime())
.setUid(player.getId())
.setUid(player.getUid())
.build();
this.setData(proto);
......
package emu.grasscutter.server.packet.send;
import emu.grasscutter.GenshinConstants;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.game.GenshinPlayer;
import emu.grasscutter.game.inventory.GenshinItem;
import emu.grasscutter.net.packet.GenshinPacket;
......@@ -18,7 +19,7 @@ public class PacketPlayerStoreNotify extends GenshinPacket {
PlayerStoreNotify.Builder p = PlayerStoreNotify.newBuilder()
.setStoreType(StoreType.StorePack)
.setWeightLimit(GenshinConstants.LIMIT_ALL);
.setWeightLimit(Grasscutter.getConfig().getServerOptions().InventoryLimitAll);
for (GenshinItem item : player.getInventory()) {
Item itemProto = item.toProto();
......
......@@ -21,7 +21,7 @@ public class PacketPullRecentChatRsp extends GenshinPacket {
ChatInfo welcomeEmote = ChatInfo.newBuilder()
.setTime((int) (System.currentTimeMillis() / 1000))
.setUid(GenshinConstants.SERVER_CONSOLE_UID)
.setToUid(player.getId())
.setToUid(player.getUid())
.setIcon(serverOptions.WelcomeEmotes[Utils.randomRange(0, serverOptions.WelcomeEmotes.length - 1)])
.build();
......@@ -32,7 +32,7 @@ public class PacketPullRecentChatRsp extends GenshinPacket {
ChatInfo welcomeMotd = ChatInfo.newBuilder()
.setTime((int) (System.currentTimeMillis() / 1000))
.setUid(GenshinConstants.SERVER_CONSOLE_UID)
.setToUid(player.getId())
.setToUid(player.getUid())
.setText(Grasscutter.getConfig().getServerOptions().WelcomeMotd)
.build();
......
......@@ -18,7 +18,7 @@ public class PacketScenePlayerInfoNotify extends GenshinPacket {
GenshinPlayer p = world.getPlayers().get(i);
ScenePlayerInfo pInfo = ScenePlayerInfo.newBuilder()
.setUid(p.getId())
.setUid(p.getUid())
.setPeerId(p.getPeerId())
.setName(p.getNickname())
.setSceneId(p.getSceneId())
......
......@@ -19,7 +19,7 @@ public class PacketSceneTeamUpdateNotify extends GenshinPacket {
for (GenshinPlayer p : player.getWorld().getPlayers()) {
for (EntityAvatar entityAvatar : p.getTeamManager().getActiveTeam()) {
SceneTeamAvatar.Builder avatarProto = SceneTeamAvatar.newBuilder()
.setPlayerId(p.getId())
.setPlayerId(p.getUid())
.setAvatarGuid(entityAvatar.getAvatar().getGuid())
.setSceneId(p.getSceneId())
.setEntityId(entityAvatar.getId())
......
package emu.grasscutter.server.packet.send;
import emu.grasscutter.GenshinConstants;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.StoreTypeOuterClass.StoreType;
......@@ -13,11 +13,11 @@ public class PacketStoreWeightLimitNotify extends GenshinPacket {
StoreWeightLimitNotify p = StoreWeightLimitNotify.newBuilder()
.setStoreType(StoreType.StorePack)
.setWeightLimit(GenshinConstants.LIMIT_ALL)
.setWeaponCountLimit(GenshinConstants.LIMIT_WEAPON)
.setReliquaryCountLimit(GenshinConstants.LIMIT_RELIC)
.setMaterialCountLimit(GenshinConstants.LIMIT_MATERIAL)
.setFurnitureCountLimit(GenshinConstants.LIMIT_FURNITURE)
.setWeightLimit(Grasscutter.getConfig().getServerOptions().InventoryLimitAll)
.setWeaponCountLimit(Grasscutter.getConfig().getServerOptions().InventoryLimitWeapon)
.setReliquaryCountLimit(Grasscutter.getConfig().getServerOptions().InventoryLimitRelic)
.setMaterialCountLimit(Grasscutter.getConfig().getServerOptions().InventoryLimitMaterial)
.setFurnitureCountLimit(Grasscutter.getConfig().getServerOptions().InventoryLimitFurniture)
.build();
this.setData(p);
......
......@@ -17,7 +17,7 @@ public class PacketWorldPlayerInfoNotify extends GenshinPacket {
GenshinPlayer p = world.getPlayers().get(i);
proto.addPlayerInfoList(p.getOnlinePlayerInfo());
proto.addPlayerUidList(p.getId());
proto.addPlayerUidList(p.getUid());
}
this.setData(proto.build());
......
......@@ -17,7 +17,7 @@ public class PacketWorldPlayerRTTNotify extends GenshinPacket {
for (GenshinPlayer player : world.getPlayers()) {
proto.addPlayerRttList(
PlayerRTTInfo.newBuilder()
.setUid(player.getId())
.setUid(player.getUid())
.setRtt(10) // TODO - put player ping here
);
}
......
......@@ -165,8 +165,6 @@ public final class Utils {
// Check for game data.
if(!fileExists(dataFolder))
createFolder(dataFolder);
if(!fileExists(dataFolder + "AbilityEmbryos.json"))
copyFromResources("data/AbilityEmbryos.json", dataFolder);
if(exit) System.exit(1);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment