Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
ziqian zhang
Grasscutter
Commits
4b77e84e
Commit
4b77e84e
authored
Jun 06, 2022
by
ImmuState
Committed by
Melledy
Jun 08, 2022
Browse files
Add ForgeQueueDataNotify, unwhack UI.
parent
0e1c8dc5
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/managers/ForgingManager/ForgingManager.java
View file @
4b77e84e
...
@@ -22,6 +22,7 @@ import emu.grasscutter.net.proto.RetcodeOuterClass.Retcode;
...
@@ -22,6 +22,7 @@ import emu.grasscutter.net.proto.RetcodeOuterClass.Retcode;
import
emu.grasscutter.server.packet.send.PacketForgeDataNotify
;
import
emu.grasscutter.server.packet.send.PacketForgeDataNotify
;
import
emu.grasscutter.server.packet.send.PacketForgeFormulaDataNotify
;
import
emu.grasscutter.server.packet.send.PacketForgeFormulaDataNotify
;
import
emu.grasscutter.server.packet.send.PacketForgeGetQueueDataRsp
;
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.PacketForgeQueueManipulateRsp
;
import
emu.grasscutter.server.packet.send.PacketForgeStartRsp
;
import
emu.grasscutter.server.packet.send.PacketForgeStartRsp
;
import
emu.grasscutter.utils.Utils
;
import
emu.grasscutter.utils.Utils
;
...
@@ -111,6 +112,15 @@ public class ForgingManager {
...
@@ -111,6 +112,15 @@ public class ForgingManager {
/**********
/**********
Initiate forging process.
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
)
{
public
void
handleForgeStartReq
(
ForgeStartReq
req
)
{
// Refuse if all queues are already full.
// Refuse if all queues are already full.
if
(
this
.
player
.
getActiveForges
().
size
()
>=
this
.
determineNumberOfQueues
())
{
if
(
this
.
player
.
getActiveForges
().
size
()
>=
this
.
determineNumberOfQueues
())
{
...
@@ -169,8 +179,8 @@ public class ForgingManager {
...
@@ -169,8 +179,8 @@ public class ForgingManager {
this
.
player
.
getActiveForges
().
add
(
activeForge
);
this
.
player
.
getActiveForges
().
add
(
activeForge
);
// Done.
// Done.
this
.
sendForgeQueueDataNotify
();
this
.
player
.
sendPacket
(
new
PacketForgeStartRsp
(
Retcode
.
RET_SUCC
));
this
.
player
.
sendPacket
(
new
PacketForgeStartRsp
(
Retcode
.
RET_SUCC
));
this
.
sendForgeDataNotify
();
}
}
/**********
/**********
...
@@ -210,15 +220,16 @@ public class ForgingManager {
...
@@ -210,15 +220,16 @@ public class ForgingManager {
remainingForge
.
setStartTime
(
currentTime
);
remainingForge
.
setStartTime
(
currentTime
);
this
.
player
.
getActiveForges
().
set
(
queueId
-
1
,
remainingForge
);
this
.
player
.
getActiveForges
().
set
(
queueId
-
1
,
remainingForge
);
this
.
sendForgeQueueDataNotify
();
}
}
// Otherwise, completely remove it.
// Otherwise, completely remove it.
else
{
else
{
this
.
player
.
getActiveForges
().
remove
(
queueId
-
1
);
this
.
player
.
getActiveForges
().
remove
(
queueId
-
1
);
this
.
sendForgeQueueDataNotify
(
queueId
);
}
}
// Send response.
// 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
.
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
)
{
private
void
cancelForge
(
int
queueId
)
{
...
@@ -253,9 +264,12 @@ public class ForgingManager {
...
@@ -253,9 +264,12 @@ public class ForgingManager {
GameItem
returnMora
=
new
GameItem
(
moraItem
,
data
.
getScoinCost
()
*
forge
.
getCount
());
GameItem
returnMora
=
new
GameItem
(
moraItem
,
data
.
getScoinCost
()
*
forge
.
getCount
());
returnItems
.
add
(
returnMora
);
returnItems
.
add
(
returnMora
);
// Remove the forge queue.
this
.
player
.
getActiveForges
().
remove
(
queueId
-
1
);
this
.
sendForgeQueueDataNotify
(
queueId
);
// Send response.
// Send response.
this
.
player
.
sendPacket
(
new
PacketForgeQueueManipulateRsp
(
Retcode
.
RET_SUCC
,
ForgeQueueManipulateType
.
FORGE_QUEUE_MANIPULATE_TYPE_STOP_FORGE
,
List
.
of
(),
returnItems
,
List
.
of
()));
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
)
{
public
void
handleForgeQueueManipulateReq
(
ForgeQueueManipulateReq
req
)
{
...
...
src/main/java/emu/grasscutter/server/packet/send/PacketForgeQueueDataNotify.java
0 → 100644
View file @
4b77e84e
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
());
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment