mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-27 02:43:15 +00:00
Add ForgeQueueDataNotify, unwhack UI.
This commit is contained in:
parent
e193781f0c
commit
36e7e028f7
14
proto/ForgeQueueDataNotify.proto
Normal file
14
proto/ForgeQueueDataNotify.proto
Normal file
@ -0,0 +1,14 @@
|
||||
syntax = "proto3";
|
||||
|
||||
option java_package = "emu.grasscutter.net.proto";
|
||||
|
||||
import "ForgeQueueData.proto";
|
||||
|
||||
// CmdId: 633
|
||||
// EnetChannelId: 0
|
||||
// EnetIsReliable: true
|
||||
// IsAllowClient: true
|
||||
message ForgeQueueDataNotify {
|
||||
map<uint32, ForgeQueueData> forge_queue_map = 14;
|
||||
repeated uint32 removed_forge_queue_list = 8;
|
||||
}
|
@ -22,6 +22,7 @@ import emu.grasscutter.net.proto.RetcodeOuterClass.Retcode;
|
||||
import emu.grasscutter.server.packet.send.PacketForgeDataNotify;
|
||||
import emu.grasscutter.server.packet.send.PacketForgeFormulaDataNotify;
|
||||
import emu.grasscutter.server.packet.send.PacketForgeGetQueueDataRsp;
|
||||
import emu.grasscutter.server.packet.send.PacketForgeQueueDataNotify;
|
||||
import emu.grasscutter.server.packet.send.PacketForgeQueueManipulateRsp;
|
||||
import emu.grasscutter.server.packet.send.PacketForgeStartRsp;
|
||||
import emu.grasscutter.utils.Utils;
|
||||
@ -111,6 +112,15 @@ public class ForgingManager {
|
||||
/**********
|
||||
Initiate forging process.
|
||||
**********/
|
||||
private void sendForgeQueueDataNotify() {
|
||||
var queueData = this.determineCurrentForgeQueueData();
|
||||
this.player.sendPacket(new PacketForgeQueueDataNotify(queueData, List.of()));
|
||||
}
|
||||
private void sendForgeQueueDataNotify(int removed) {
|
||||
var queueData = this.determineCurrentForgeQueueData();
|
||||
this.player.sendPacket(new PacketForgeQueueDataNotify(queueData, List.of(removed)));
|
||||
}
|
||||
|
||||
public void handleForgeStartReq(ForgeStartReq req) {
|
||||
// Refuse if all queues are already full.
|
||||
if (this.player.getActiveForges().size() >= this.determineNumberOfQueues()) {
|
||||
@ -169,8 +179,8 @@ public class ForgingManager {
|
||||
this.player.getActiveForges().add(activeForge);
|
||||
|
||||
// Done.
|
||||
this.sendForgeQueueDataNotify();
|
||||
this.player.sendPacket(new PacketForgeStartRsp(Retcode.RET_SUCC));
|
||||
this.sendForgeDataNotify();
|
||||
}
|
||||
|
||||
/**********
|
||||
@ -210,15 +220,16 @@ public class ForgingManager {
|
||||
remainingForge.setStartTime(currentTime);
|
||||
|
||||
this.player.getActiveForges().set(queueId - 1, remainingForge);
|
||||
this.sendForgeQueueDataNotify();
|
||||
}
|
||||
// Otherwise, completely remove it.
|
||||
else {
|
||||
this.player.getActiveForges().remove(queueId - 1);
|
||||
this.sendForgeQueueDataNotify(queueId);
|
||||
}
|
||||
|
||||
// Send response.
|
||||
this.player.sendPacket(new PacketForgeQueueManipulateRsp(Retcode.RET_SUCC, ForgeQueueManipulateType.FORGE_QUEUE_MANIPULATE_TYPE_RECEIVE_OUTPUT, List.of(addItem), List.of(), List.of()));
|
||||
this.sendForgeDataNotify();
|
||||
}
|
||||
|
||||
private void cancelForge(int queueId) {
|
||||
@ -253,9 +264,12 @@ public class ForgingManager {
|
||||
GameItem returnMora = new GameItem(moraItem, data.getScoinCost() * forge.getCount());
|
||||
returnItems.add(returnMora);
|
||||
|
||||
// Remove the forge queue.
|
||||
this.player.getActiveForges().remove(queueId - 1);
|
||||
this.sendForgeQueueDataNotify(queueId);
|
||||
|
||||
// Send response.
|
||||
this.player.sendPacket(new PacketForgeQueueManipulateRsp(Retcode.RET_SUCC, ForgeQueueManipulateType.FORGE_QUEUE_MANIPULATE_TYPE_STOP_FORGE, List.of(), returnItems, List.of()));
|
||||
this.sendForgeDataNotify();
|
||||
}
|
||||
|
||||
public void handleForgeQueueManipulateReq(ForgeQueueManipulateReq req) {
|
||||
|
@ -0,0 +1,26 @@
|
||||
package emu.grasscutter.server.packet.send;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import emu.grasscutter.net.packet.BasePacket;
|
||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||
import emu.grasscutter.net.proto.ForgeQueueDataNotifyOuterClass.ForgeQueueDataNotify;
|
||||
import emu.grasscutter.net.proto.ForgeQueueDataOuterClass.ForgeQueueData;
|
||||
|
||||
public class PacketForgeQueueDataNotify extends BasePacket {
|
||||
|
||||
public PacketForgeQueueDataNotify(Map<Integer, ForgeQueueData> queueData, List<Integer> removedQueues) {
|
||||
super(PacketOpcodes.ForgeQueueDataNotify);
|
||||
|
||||
ForgeQueueDataNotify.Builder builder = ForgeQueueDataNotify.newBuilder()
|
||||
.addAllRemovedForgeQueueList(removedQueues);
|
||||
|
||||
for (int queueId : queueData.keySet()) {
|
||||
var data = queueData.get(queueId);
|
||||
builder.putForgeQueueMap(queueId, data);
|
||||
}
|
||||
|
||||
this.setData(builder.build());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user