mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-10 04:12:54 +08:00
Refactor out some EntrySets
This commit is contained in:
parent
b5f356ce4f
commit
85f44ebdf3
@ -467,20 +467,17 @@ public class Avatar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set stuff
|
// Set stuff
|
||||||
for (Int2IntOpenHashMap.Entry e : setMap.int2IntEntrySet()) {
|
setMap.forEach((setId, amount) -> {
|
||||||
ReliquarySetData setData = GameData.getReliquarySetDataMap().get(e.getIntKey());
|
ReliquarySetData setData = GameData.getReliquarySetDataMap().get((int) setId);
|
||||||
if (setData == null) {
|
if (setData == null) return;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calculate how many items are from the set
|
// Calculate how many items are from the set
|
||||||
int amount = e.getIntValue();
|
|
||||||
|
|
||||||
// Add affix data from set bonus
|
// Add affix data from set bonus
|
||||||
for (int setIndex = 0; setIndex < setData.getSetNeedNum().length; setIndex++) {
|
val setNeedNum = setData.getSetNeedNum();
|
||||||
if (amount >= setData.getSetNeedNum()[setIndex]) {
|
for (int setIndex = 0; setIndex < setNeedNum.length; setIndex++) {
|
||||||
int affixId = (setData.getEquipAffixId() * 10) + setIndex;
|
if (amount < setNeedNum[setIndex]) break;
|
||||||
|
|
||||||
|
int affixId = (setData.getEquipAffixId() * 10) + setIndex;
|
||||||
EquipAffixData affix = GameData.getEquipAffixDataMap().get(affixId);
|
EquipAffixData affix = GameData.getEquipAffixDataMap().get(affixId);
|
||||||
if (affix == null) {
|
if (affix == null) {
|
||||||
continue;
|
continue;
|
||||||
@ -493,11 +490,8 @@ public class Avatar {
|
|||||||
|
|
||||||
// Add any skill strings from this affix
|
// Add any skill strings from this affix
|
||||||
this.addToExtraAbilityEmbryos(affix.getOpenConfig(), true);
|
this.addToExtraAbilityEmbryos(affix.getOpenConfig(), true);
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Weapon
|
// Weapon
|
||||||
GameItem weapon = this.getWeapon();
|
GameItem weapon = this.getWeapon();
|
||||||
|
@ -247,13 +247,7 @@ public class EntityAvatar extends GameEntity {
|
|||||||
entityInfo.setMotionInfo(this.getMotionInfo());
|
entityInfo.setMotionInfo(this.getMotionInfo());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Int2FloatMap.Entry entry : getFightProperties().int2FloatEntrySet()) {
|
this.addAllFightPropsToEntityInfo(entityInfo);
|
||||||
if (entry.getIntKey() == 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
FightPropPair fightProp = FightPropPair.newBuilder().setPropType(entry.getIntKey()).setPropValue(entry.getFloatValue()).build();
|
|
||||||
entityInfo.addFightPropList(fightProp);
|
|
||||||
}
|
|
||||||
|
|
||||||
PropPair pair = PropPair.newBuilder()
|
PropPair pair = PropPair.newBuilder()
|
||||||
.setType(PlayerProperty.PROP_LEVEL.getId())
|
.setType(PlayerProperty.PROP_LEVEL.getId())
|
||||||
|
@ -217,7 +217,7 @@ public class EntityGadget extends EntityBaseGadget {
|
|||||||
|
|
||||||
// We do not use the getter to null check because the getter will create a fight prop map if it is null
|
// We do not use the getter to null check because the getter will create a fight prop map if it is null
|
||||||
if (this.fightProp != null) {
|
if (this.fightProp != null) {
|
||||||
this.addAllFightPropsToEntityInfo(entityInfo);
|
addAllFightPropsToEntityInfo(entityInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneGadgetInfo.Builder gadgetInfo = SceneGadgetInfo.newBuilder()
|
SceneGadgetInfo.Builder gadgetInfo = SceneGadgetInfo.newBuilder()
|
||||||
|
@ -255,13 +255,7 @@ public class EntityMonster extends GameEntity {
|
|||||||
.setEntityAuthorityInfo(authority)
|
.setEntityAuthorityInfo(authority)
|
||||||
.setLifeState(this.getLifeState().getValue());
|
.setLifeState(this.getLifeState().getValue());
|
||||||
|
|
||||||
for (Int2FloatMap.Entry entry : getFightProperties().int2FloatEntrySet()) {
|
this.addAllFightPropsToEntityInfo(entityInfo);
|
||||||
if (entry.getIntKey() == 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
FightPropPair fightProp = FightPropPair.newBuilder().setPropType(entry.getIntKey()).setPropValue(entry.getFloatValue()).build();
|
|
||||||
entityInfo.addFightPropList(fightProp);
|
|
||||||
}
|
|
||||||
|
|
||||||
PropPair pair = PropPair.newBuilder()
|
PropPair pair = PropPair.newBuilder()
|
||||||
.setType(PlayerProperty.PROP_LEVEL.getId())
|
.setType(PlayerProperty.PROP_LEVEL.getId())
|
||||||
|
@ -122,14 +122,7 @@ public class EntityVehicle extends EntityBaseGadget {
|
|||||||
.setPropValue(ProtoHelper.newPropValue(PlayerProperty.PROP_LEVEL, 47))
|
.setPropValue(ProtoHelper.newPropValue(PlayerProperty.PROP_LEVEL, 47))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
for (Int2FloatMap.Entry entry : getFightProperties().int2FloatEntrySet()) {
|
this.addAllFightPropsToEntityInfo(entityInfo);
|
||||||
if (entry.getIntKey() == 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
FightPropPair fightProp = FightPropPair.newBuilder().setPropType(entry.getIntKey()).setPropValue(entry.getFloatValue()).build();
|
|
||||||
entityInfo.addFightPropList(fightProp);
|
|
||||||
}
|
|
||||||
|
|
||||||
entityInfo.addPropList(pair);
|
entityInfo.addPropList(pair);
|
||||||
|
|
||||||
return entityInfo.build();
|
return entityInfo.build();
|
||||||
|
@ -113,13 +113,10 @@ public abstract class GameEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addAllFightPropsToEntityInfo(SceneEntityInfo.Builder entityInfo) {
|
public void addAllFightPropsToEntityInfo(SceneEntityInfo.Builder entityInfo) {
|
||||||
for (Int2FloatMap.Entry entry : this.getFightProperties().int2FloatEntrySet()) {
|
this.getFightProperties().forEach((key, value) -> {
|
||||||
if (entry.getIntKey() == 0) {
|
if (key == 0) return;
|
||||||
continue;
|
entityInfo.addFightPropList(FightPropPair.newBuilder().setPropType(key).setPropValue(value).build());
|
||||||
}
|
});
|
||||||
FightPropPair fightProp = FightPropPair.newBuilder().setPropType(entry.getIntKey()).setPropValue(entry.getFloatValue()).build();
|
|
||||||
entityInfo.addFightPropList(fightProp);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected MotionInfo getMotionInfo() {
|
protected MotionInfo getMotionInfo() {
|
||||||
|
@ -93,14 +93,7 @@ public class EntityPlatform extends EntityBaseGadget {
|
|||||||
.setGadget(gadgetInfo)
|
.setGadget(gadgetInfo)
|
||||||
.setLifeState(1);
|
.setLifeState(1);
|
||||||
|
|
||||||
for (Int2FloatMap.Entry entry : getFightProperties().int2FloatEntrySet()) {
|
this.addAllFightPropsToEntityInfo(entityInfo);
|
||||||
if (entry.getIntKey() == 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
FightPropPairOuterClass.FightPropPair fightProp = FightPropPairOuterClass.FightPropPair.newBuilder().setPropType(entry.getIntKey()).setPropValue(entry.getFloatValue()).build();
|
|
||||||
entityInfo.addFightPropList(fightProp);
|
|
||||||
}
|
|
||||||
|
|
||||||
return entityInfo.build();
|
return entityInfo.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,16 +89,7 @@ public class EntitySolarIsotomaElevatorPlatform extends EntityPlatform {
|
|||||||
Grasscutter.getLogger().warn("Why gadget owner doesn't exist?");
|
Grasscutter.getLogger().warn("Why gadget owner doesn't exist?");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var entry : getFightProperties().int2FloatEntrySet()) {
|
this.addAllFightPropsToEntityInfo(info);
|
||||||
if (entry.getIntKey() == 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
var fightProp = FightPropPairOuterClass.FightPropPair.newBuilder()
|
|
||||||
.setPropType(entry.getIntKey())
|
|
||||||
.setPropValue(entry.getFloatValue())
|
|
||||||
.build();
|
|
||||||
info.addFightPropList(fightProp);
|
|
||||||
}
|
|
||||||
|
|
||||||
info.setLifeState(1)
|
info.setLifeState(1)
|
||||||
.setGadget(gadget)
|
.setGadget(gadget)
|
||||||
|
@ -172,16 +172,11 @@ public class CookingManager extends BasePlayerManager {
|
|||||||
|
|
||||||
// Construct CookRecipeData protos.
|
// Construct CookRecipeData protos.
|
||||||
List<CookRecipeDataOuterClass.CookRecipeData> data = new ArrayList<>();
|
List<CookRecipeDataOuterClass.CookRecipeData> data = new ArrayList<>();
|
||||||
for (var recipe : unlockedRecipes.entrySet()) {
|
unlockedRecipes.forEach((recipeId, proficiency) ->
|
||||||
int recipeId = recipe.getKey();
|
data.add(CookRecipeDataOuterClass.CookRecipeData.newBuilder()
|
||||||
int proficiency = recipe.getValue();
|
|
||||||
|
|
||||||
CookRecipeDataOuterClass.CookRecipeData proto = CookRecipeDataOuterClass.CookRecipeData.newBuilder()
|
|
||||||
.setRecipeId(recipeId)
|
.setRecipeId(recipeId)
|
||||||
.setProficiency(proficiency)
|
.setProficiency(proficiency)
|
||||||
.build();
|
.build()));
|
||||||
data.add(proto);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send packet.
|
// Send packet.
|
||||||
this.player.sendPacket(new PacketCookDataNotify(data));
|
this.player.sendPacket(new PacketCookDataNotify(data));
|
||||||
|
@ -304,9 +304,8 @@ public class StaminaManager extends BasePlayerManager {
|
|||||||
session.send(new PacketVehicleStaminaNotify(vehicleId, ((float) newStamina) / 100));
|
session.send(new PacketVehicleStaminaNotify(vehicleId, ((float) newStamina) / 100));
|
||||||
}
|
}
|
||||||
// notify updated
|
// notify updated
|
||||||
for (Map.Entry<String, AfterUpdateStaminaListener> listener : afterUpdateStaminaListeners.entrySet()) {
|
int s = newStamina;
|
||||||
listener.getValue().onAfterUpdateStamina(reason, newStamina, isCharacterStamina);
|
afterUpdateStaminaListeners.forEach((k, v) -> v.onAfterUpdateStamina(reason, s, isCharacterStamina));
|
||||||
}
|
|
||||||
return newStamina;
|
return newStamina;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ import emu.grasscutter.server.game.BaseGameSystem;
|
|||||||
import emu.grasscutter.server.game.GameServer;
|
import emu.grasscutter.server.game.GameServer;
|
||||||
import emu.grasscutter.server.packet.send.*;
|
import emu.grasscutter.server.packet.send.*;
|
||||||
import emu.grasscutter.utils.Utils;
|
import emu.grasscutter.utils.Utils;
|
||||||
|
import it.unimi.dsi.fastutil.ints.Int2FloatArrayMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2IntArrayMap;
|
import it.unimi.dsi.fastutil.ints.Int2IntArrayMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||||
@ -634,7 +635,7 @@ public class InventorySystem extends BaseGameSystem {
|
|||||||
Map<Integer, Float> oldPropMap = avatar.getFightProperties();
|
Map<Integer, Float> oldPropMap = avatar.getFightProperties();
|
||||||
if (oldLevel != level) {
|
if (oldLevel != level) {
|
||||||
// Deep copy if level has changed
|
// Deep copy if level has changed
|
||||||
oldPropMap = avatar.getFightProperties().int2FloatEntrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
oldPropMap = new Int2FloatArrayMap(avatar.getFightProperties());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Done
|
// Done
|
||||||
@ -696,7 +697,8 @@ public class InventorySystem extends BaseGameSystem {
|
|||||||
|
|
||||||
public void destroyMaterial(Player player, List<MaterialInfo> list) {
|
public void destroyMaterial(Player player, List<MaterialInfo> list) {
|
||||||
// Return materials
|
// Return materials
|
||||||
Int2IntOpenHashMap returnMaterialMap = new Int2IntOpenHashMap();
|
val returnMaterialMap = new Int2IntOpenHashMap();
|
||||||
|
val inventory = player.getInventory();
|
||||||
|
|
||||||
for (MaterialInfo info : list) {
|
for (MaterialInfo info : list) {
|
||||||
// Sanity check
|
// Sanity check
|
||||||
@ -704,28 +706,27 @@ public class InventorySystem extends BaseGameSystem {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameItem item = player.getInventory().getItemByGuid(info.getGuid());
|
GameItem item = inventory.getItemByGuid(info.getGuid());
|
||||||
if (item == null || !item.isDestroyable()) {
|
if (item == null || !item.isDestroyable()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove
|
// Remove
|
||||||
int removeAmount = Math.min(info.getCount(), item.getCount());
|
int removeAmount = Math.min(info.getCount(), item.getCount());
|
||||||
player.getInventory().removeItem(item, removeAmount);
|
inventory.removeItem(item, removeAmount);
|
||||||
|
|
||||||
// Delete material return items
|
// Delete material return items
|
||||||
if (item.getItemData().getDestroyReturnMaterial().length > 0) {
|
val data = item.getItemData();
|
||||||
for (int i = 0; i < item.getItemData().getDestroyReturnMaterial().length; i++) {
|
if (data.getDestroyReturnMaterial().length > 0) {
|
||||||
returnMaterialMap.addTo(item.getItemData().getDestroyReturnMaterial()[i], item.getItemData().getDestroyReturnMaterialCount()[i]);
|
for (int i = 0; i < data.getDestroyReturnMaterial().length; i++) {
|
||||||
|
returnMaterialMap.addTo(data.getDestroyReturnMaterial()[i], data.getDestroyReturnMaterialCount()[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Give back items
|
// Give back items
|
||||||
if (returnMaterialMap.size() > 0) {
|
if (returnMaterialMap.size() > 0) {
|
||||||
for (Int2IntMap.Entry e : returnMaterialMap.int2IntEntrySet()) {
|
returnMaterialMap.forEach((id, count) -> inventory.addItem(new GameItem(id, count)));
|
||||||
player.getInventory().addItem(new GameItem(e.getIntKey(), e.getIntValue()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Packets
|
// Packets
|
||||||
|
@ -1,14 +1,10 @@
|
|||||||
package emu.grasscutter.server.packet.send;
|
package emu.grasscutter.server.packet.send;
|
||||||
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import emu.grasscutter.game.avatar.Avatar;
|
import emu.grasscutter.game.avatar.Avatar;
|
||||||
import emu.grasscutter.game.player.Player;
|
import emu.grasscutter.game.player.Player;
|
||||||
import emu.grasscutter.game.player.TeamInfo;
|
|
||||||
import emu.grasscutter.net.packet.BasePacket;
|
import emu.grasscutter.net.packet.BasePacket;
|
||||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||||
import emu.grasscutter.net.proto.AvatarDataNotifyOuterClass.AvatarDataNotify;
|
import emu.grasscutter.net.proto.AvatarDataNotifyOuterClass.AvatarDataNotify;
|
||||||
import emu.grasscutter.net.proto.AvatarTeamOuterClass.AvatarTeam;
|
|
||||||
|
|
||||||
public class PacketAvatarDataNotify extends BasePacket {
|
public class PacketAvatarDataNotify extends BasePacket {
|
||||||
|
|
||||||
@ -21,21 +17,14 @@ public class PacketAvatarDataNotify extends BasePacket {
|
|||||||
.addAllOwnedFlycloakList(player.getFlyCloakList())
|
.addAllOwnedFlycloakList(player.getFlyCloakList())
|
||||||
.addAllOwnedCostumeList(player.getCostumeList());
|
.addAllOwnedCostumeList(player.getCostumeList());
|
||||||
|
|
||||||
for (Avatar avatar : player.getAvatars()) {
|
player.getAvatars().forEach(avatar -> proto.addAvatarList(avatar.toProto()));
|
||||||
proto.addAvatarList(avatar.toProto());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add the id list for custom teams.
|
player.getTeamManager().getTeams().forEach((id, teamInfo) -> {
|
||||||
for (int id : player.getTeamManager().getTeams().keySet()) {
|
proto.putAvatarTeamMap(id, teamInfo.toProto(player));
|
||||||
if (id > 4) {
|
if (id > 4) { // Add the id list for custom teams.
|
||||||
proto.addCustomTeamIds(id);
|
proto.addCustomTeamIds(id);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
for (Entry<Integer, TeamInfo> entry : player.getTeamManager().getTeams().entrySet()) {
|
|
||||||
TeamInfo teamInfo = entry.getValue();
|
|
||||||
proto.putAvatarTeamMap(entry.getKey(), teamInfo.toProto(player));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set main character
|
// Set main character
|
||||||
Avatar mainCharacter = player.getAvatars().getAvatarById(player.getMainCharacterId());
|
Avatar mainCharacter = player.getAvatars().getAvatarById(player.getMainCharacterId());
|
||||||
|
@ -12,7 +12,7 @@ public class PacketAvatarExpeditionAllDataRsp extends BasePacket {
|
|||||||
public PacketAvatarExpeditionAllDataRsp(Map<Long, ExpeditionInfo> expeditionInfo, int expeditionCountLimit) {
|
public PacketAvatarExpeditionAllDataRsp(Map<Long, ExpeditionInfo> expeditionInfo, int expeditionCountLimit) {
|
||||||
super(PacketOpcodes.AvatarExpeditionAllDataRsp);
|
super(PacketOpcodes.AvatarExpeditionAllDataRsp);
|
||||||
|
|
||||||
List<Integer> openExpeditionList = new ArrayList<>(List.of(306,305,304,303,302,301,206,105,204,104,203,103,202,101,102,201,106,205,401,402,403,404,405,406));
|
var openExpeditionList = List.of(306,305,304,303,302,301,206,105,204,104,203,103,202,101,102,201,106,205,401,402,403,404,405,406);
|
||||||
|
|
||||||
this.setData(AvatarExpeditionAllDataRsp.newBuilder()
|
this.setData(AvatarExpeditionAllDataRsp.newBuilder()
|
||||||
.addAllOpenExpeditionList(openExpeditionList)
|
.addAllOpenExpeditionList(openExpeditionList)
|
||||||
|
@ -1,13 +1,8 @@
|
|||||||
package emu.grasscutter.server.packet.send;
|
package emu.grasscutter.server.packet.send;
|
||||||
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import emu.grasscutter.game.avatar.Avatar;
|
|
||||||
import emu.grasscutter.game.player.Player;
|
import emu.grasscutter.game.player.Player;
|
||||||
import emu.grasscutter.game.player.TeamInfo;
|
|
||||||
import emu.grasscutter.net.packet.BasePacket;
|
import emu.grasscutter.net.packet.BasePacket;
|
||||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||||
import emu.grasscutter.net.proto.AvatarTeamOuterClass.AvatarTeam;
|
|
||||||
import emu.grasscutter.net.proto.AvatarTeamUpdateNotifyOuterClass.AvatarTeamUpdateNotify;
|
import emu.grasscutter.net.proto.AvatarTeamUpdateNotifyOuterClass.AvatarTeamUpdateNotify;
|
||||||
|
|
||||||
public class PacketAvatarTeamUpdateNotify extends BasePacket {
|
public class PacketAvatarTeamUpdateNotify extends BasePacket {
|
||||||
@ -17,10 +12,7 @@ public class PacketAvatarTeamUpdateNotify extends BasePacket {
|
|||||||
|
|
||||||
AvatarTeamUpdateNotify.Builder proto = AvatarTeamUpdateNotify.newBuilder();
|
AvatarTeamUpdateNotify.Builder proto = AvatarTeamUpdateNotify.newBuilder();
|
||||||
|
|
||||||
for (Entry<Integer, TeamInfo> entry : player.getTeamManager().getTeams().entrySet()) {
|
player.getTeamManager().getTeams().forEach((id, teamInfo) -> proto.putAvatarTeamMap(id, teamInfo.toProto(player)));
|
||||||
TeamInfo teamInfo = entry.getValue();
|
|
||||||
proto.putAvatarTeamMap(entry.getKey(), teamInfo.toProto(player));
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setData(proto);
|
this.setData(proto);
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,8 @@
|
|||||||
package emu.grasscutter.server.packet.send;
|
package emu.grasscutter.server.packet.send;
|
||||||
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import emu.grasscutter.game.avatar.Avatar;
|
|
||||||
import emu.grasscutter.game.player.Player;
|
import emu.grasscutter.game.player.Player;
|
||||||
import emu.grasscutter.game.player.TeamInfo;
|
|
||||||
import emu.grasscutter.net.packet.BasePacket;
|
import emu.grasscutter.net.packet.BasePacket;
|
||||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||||
import emu.grasscutter.net.proto.AvatarTeamOuterClass.AvatarTeam;
|
|
||||||
import emu.grasscutter.net.proto.CustomTeamListNotifyOuterClass.CustomTeamListNotify;
|
import emu.grasscutter.net.proto.CustomTeamListNotifyOuterClass.CustomTeamListNotify;
|
||||||
|
|
||||||
public class PacketCustomTeamListNotify extends BasePacket {
|
public class PacketCustomTeamListNotify extends BasePacket {
|
||||||
@ -24,10 +19,7 @@ public class PacketCustomTeamListNotify extends BasePacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add the avatar lists for all the teams the player has.
|
// Add the avatar lists for all the teams the player has.
|
||||||
for (Entry<Integer, TeamInfo> entry : player.getTeamManager().getTeams().entrySet()) {
|
player.getTeamManager().getTeams().forEach((id, teamInfo) -> proto.putAvatarTeamMap(id, teamInfo.toProto(player)));
|
||||||
TeamInfo teamInfo = entry.getValue();
|
|
||||||
proto.putAvatarTeamMap(entry.getKey(), teamInfo.toProto(player));
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setData(proto);
|
this.setData(proto);
|
||||||
}
|
}
|
||||||
|
@ -4,19 +4,18 @@ import emu.grasscutter.net.packet.BasePacket;
|
|||||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||||
import emu.grasscutter.net.proto.DestroyMaterialRspOuterClass.DestroyMaterialRsp;
|
import emu.grasscutter.net.proto.DestroyMaterialRspOuterClass.DestroyMaterialRsp;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
|
||||||
|
|
||||||
public class PacketDestroyMaterialRsp extends BasePacket {
|
public class PacketDestroyMaterialRsp extends BasePacket {
|
||||||
|
|
||||||
public PacketDestroyMaterialRsp(Int2IntOpenHashMap returnMaterialMap) {
|
public PacketDestroyMaterialRsp(Int2IntMap returnMaterialMap) {
|
||||||
super(PacketOpcodes.DestroyMaterialRsp);
|
super(PacketOpcodes.DestroyMaterialRsp);
|
||||||
|
|
||||||
DestroyMaterialRsp.Builder proto = DestroyMaterialRsp.newBuilder();
|
var proto = DestroyMaterialRsp.newBuilder();
|
||||||
|
|
||||||
for (Int2IntMap.Entry e : returnMaterialMap.int2IntEntrySet()) {
|
returnMaterialMap.forEach((id, count) -> {
|
||||||
proto.addItemIdList(e.getIntKey());
|
proto.addItemIdList(id);
|
||||||
proto.addItemCountList(e.getIntValue());
|
proto.addItemCountList(count);
|
||||||
}
|
});
|
||||||
|
|
||||||
this.setData(proto);
|
this.setData(proto);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user