Commit e140284d authored by ImmuState's avatar ImmuState Committed by Melledy
Browse files

Persist unlocked blueprints to the database.

parent f243c101
......@@ -824,7 +824,6 @@ public class InventoryManager {
int used = 0;
// Use
Grasscutter.getLogger().info("Item: {}", useItem.getItemData().getId());
switch (useItem.getItemData().getMaterialType()) {
case MATERIAL_FOOD:
if (useItem.getItemData().getUseTarget().equals("ITEM_USE_TARGET_SPECIFY_DEAD_AVATAR")) {
......@@ -856,8 +855,9 @@ public class InventoryManager {
// Determine the forging item we should unlock.
int forgeId = Integer.parseInt(useItem.getItemData().getItemUse().get(0).getUseParam().get(0));
// Tell the client that this blueprint is now unlocked.
// Tell the client that this blueprint is now unlocked and add the unlocked item to the player.
player.sendPacket(new PacketForgeFormulaDataNotify(forgeId));
player.getUnlockedForgingBlueprints().add(forgeId);
// Use up the blueprint item.
used = 1;
......
......@@ -89,6 +89,7 @@ public class Player {
private Set<Integer> nameCardList;
private Set<Integer> flyCloakList;
private Set<Integer> costumeList;
private Set<Integer> unlockedForgingBlueprints;
private Integer widgetId;
......@@ -183,6 +184,7 @@ public class Player {
this.nameCardList = new HashSet<>();
this.flyCloakList = new HashSet<>();
this.costumeList = new HashSet<>();
this.unlockedForgingBlueprints = new HashSet<>();
this.setSceneId(3);
this.setRegionId(1);
......@@ -515,6 +517,10 @@ public class Player {
return this.nameCardList;
}
public Set<Integer> getUnlockedForgingBlueprints() {
return unlockedForgingBlueprints;
}
public MpSettingType getMpSetting() {
return MpSettingType.MP_SETTING_TYPE_ENTER_AFTER_APPLY; // TEMP
}
......
package emu.grasscutter.server.packet.send;
import java.util.List;
import dev.morphia.AdvancedDatastore;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.ForgeDataNotifyOuterClass.ForgeDataNotify;
import emu.grasscutter.net.proto.ForgeQueueDataOuterClass.ForgeQueueData;
public class PacketForgeDataNotify extends BasePacket {
......@@ -22,10 +18,13 @@ public class PacketForgeDataNotify extends BasePacket {
: 1;
ForgeDataNotify proto = ForgeDataNotify.newBuilder()
.addAllForgeIdList(List.of(14017, 14009, 14008))
.addAllForgeIdList(player.getUnlockedForgingBlueprints())
.setMaxQueueNum(numQueues)
.build();
// ToDo: Add the information for the actual forging queues
// and ongoing forges.
this.setData(proto);
}
}
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