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
8db0500e
Commit
8db0500e
authored
Jun 04, 2022
by
ImmuState
Committed by
Melledy
Jun 08, 2022
Browse files
Add missing forging protos, add data for ongoing forges to player, handler for ForgeStartReq.
parent
3fc63c2c
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/managers/ForgingManager/ActiveForgeData.java
0 → 100644
View file @
8db0500e
package
emu.grasscutter.game.managers.ForgingManager
;
import
dev.morphia.annotations.Entity
;
@Entity
public
class
ActiveForgeData
{
private
int
queueId
;
private
int
forgeId
;
private
int
avatarId
;
private
int
startTime
;
private
int
forgeTime
;
// private int finishedCount;
// private int unfinishedCount;
// private int nextFinishTimestamp;
// private int totalFinishTimestamp;
public
int
getQueueId
()
{
return
this
.
queueId
;
}
public
void
setQueueId
(
int
value
)
{
this
.
queueId
=
value
;
}
public
int
getForgeId
()
{
return
this
.
forgeId
;
}
public
void
setForgeId
(
int
value
)
{
this
.
forgeId
=
value
;
}
public
int
getAvatarId
()
{
return
this
.
avatarId
;
}
public
void
setAvatarId
(
int
value
)
{
this
.
avatarId
=
value
;
}
public
int
getStartTime
()
{
return
this
.
startTime
;
}
public
void
setStartTime
(
int
value
)
{
this
.
startTime
=
value
;
}
public
int
getForgeTime
()
{
return
this
.
forgeTime
;
}
public
void
setForgeTime
(
int
value
)
{
this
.
forgeTime
=
value
;
}
}
src/main/java/emu/grasscutter/game/managers/ForgingManager/ForgingManager.java
View file @
8db0500e
package
emu.grasscutter.game.managers.ForgingManager
;
package
emu.grasscutter.game.managers.ForgingManager
;
import
java.util.HashMap
;
import
java.util.Map
;
import
emu.grasscutter.game.inventory.GameItem
;
import
emu.grasscutter.game.inventory.GameItem
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.net.proto.ForgeStartReqOuterClass
;
import
emu.grasscutter.net.proto.ForgeQueueDataOuterClass.ForgeQueueData
;
import
emu.grasscutter.net.proto.RetcodeOuterClass.Retcode
;
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.PacketForgeStartRsp
;
public
class
ForgingManager
{
public
class
ForgingManager
{
private
final
Player
player
;
private
final
Player
player
;
...
@@ -46,20 +52,49 @@ public class ForgingManager {
...
@@ -46,20 +52,49 @@ public class ForgingManager {
:
1
;
:
1
;
}
}
private
Map
<
Integer
,
ForgeQueueData
>
determineCurrentForgeQueueData
()
{
// Dummy for now.
ForgeQueueData
data
=
ForgeQueueData
.
newBuilder
()
.
setQueueId
(
1
)
.
setForgeId
(
11001
)
.
setFinishCount
(
2
)
.
setUnfinishCount
(
3
)
.
setNextFinishTimestamp
(
0
)
.
setNextFinishTimestamp
(
0
)
.
setAvatarId
(
0
)
.
build
();
Map
<
Integer
,
ForgeQueueData
>
res
=
new
HashMap
<>();
res
.
put
(
1
,
data
);
return
res
;
}
public
void
sendForgeDataNotify
()
{
public
void
sendForgeDataNotify
()
{
// Determine the number of queues and unlocked items.
// Determine the number of queues and unlocked items.
int
numQueues
=
this
.
determineNumberOfQueues
();
int
numQueues
=
this
.
determineNumberOfQueues
();
var
unlockedItems
=
this
.
player
.
getUnlockedForgingBlueprints
();
var
unlockedItems
=
this
.
player
.
getUnlockedForgingBlueprints
();
var
queueData
=
this
.
determineCurrentForgeQueueData
();
// Send notification.
// Send notification.
this
.
player
.
sendPacket
(
new
PacketForgeDataNotify
(
unlockedItems
,
numQueues
));
this
.
player
.
sendPacket
(
new
PacketForgeDataNotify
(
unlockedItems
,
numQueues
,
queueData
));
}
}
public
void
handleForgeGetQueueDataReq
()
{
public
void
handleForgeGetQueueDataReq
()
{
// Determine the number of queues.
// Determine the number of queues.
int
numQueues
=
this
.
determineNumberOfQueues
();
int
numQueues
=
this
.
determineNumberOfQueues
();
var
queueData
=
this
.
determineCurrentForgeQueueData
();
// Reply.
// Reply.
this
.
player
.
sendPacket
(
new
PacketForgeGetQueueDataRsp
(
Retcode
.
RET_SUCC
,
numQueues
));
this
.
player
.
sendPacket
(
new
PacketForgeGetQueueDataRsp
(
Retcode
.
RET_SUCC
,
numQueues
,
queueData
));
}
}
/**********
Initiate forging process.
**********/
public
void
startForging
(
ForgeStartReqOuterClass
.
ForgeStartReq
req
)
{
// Dummy for now.
this
.
player
.
sendPacket
(
new
PacketForgeStartRsp
(
Retcode
.
RET_SUCC
));
}
}
}
src/main/java/emu/grasscutter/game/player/Player.java
View file @
8db0500e
...
@@ -30,6 +30,7 @@ import emu.grasscutter.game.managers.InsectCaptureManager;
...
@@ -30,6 +30,7 @@ import emu.grasscutter.game.managers.InsectCaptureManager;
import
emu.grasscutter.game.managers.StaminaManager.StaminaManager
;
import
emu.grasscutter.game.managers.StaminaManager.StaminaManager
;
import
emu.grasscutter.game.managers.SotSManager
;
import
emu.grasscutter.game.managers.SotSManager
;
import
emu.grasscutter.game.managers.EnergyManager.EnergyManager
;
import
emu.grasscutter.game.managers.EnergyManager.EnergyManager
;
import
emu.grasscutter.game.managers.ForgingManager.ActiveForgeData
;
import
emu.grasscutter.game.managers.ForgingManager.ForgingManager
;
import
emu.grasscutter.game.managers.ForgingManager.ForgingManager
;
import
emu.grasscutter.game.props.ActionReason
;
import
emu.grasscutter.game.props.ActionReason
;
import
emu.grasscutter.game.props.EntityType
;
import
emu.grasscutter.game.props.EntityType
;
...
@@ -92,6 +93,7 @@ public class Player {
...
@@ -92,6 +93,7 @@ public class Player {
private
Set
<
Integer
>
flyCloakList
;
private
Set
<
Integer
>
flyCloakList
;
private
Set
<
Integer
>
costumeList
;
private
Set
<
Integer
>
costumeList
;
private
Set
<
Integer
>
unlockedForgingBlueprints
;
private
Set
<
Integer
>
unlockedForgingBlueprints
;
private
Map
<
Integer
,
ActiveForgeData
>
activeForges
;
private
Integer
widgetId
;
private
Integer
widgetId
;
...
@@ -188,6 +190,7 @@ public class Player {
...
@@ -188,6 +190,7 @@ public class Player {
this
.
flyCloakList
=
new
HashSet
<>();
this
.
flyCloakList
=
new
HashSet
<>();
this
.
costumeList
=
new
HashSet
<>();
this
.
costumeList
=
new
HashSet
<>();
this
.
unlockedForgingBlueprints
=
new
HashSet
<>();
this
.
unlockedForgingBlueprints
=
new
HashSet
<>();
this
.
activeForges
=
new
HashMap
<>();
this
.
setSceneId
(
3
);
this
.
setSceneId
(
3
);
this
.
setRegionId
(
1
);
this
.
setRegionId
(
1
);
...
@@ -523,7 +526,11 @@ public class Player {
...
@@ -523,7 +526,11 @@ public class Player {
}
}
public
Set
<
Integer
>
getUnlockedForgingBlueprints
()
{
public
Set
<
Integer
>
getUnlockedForgingBlueprints
()
{
return
unlockedForgingBlueprints
;
return
this
.
unlockedForgingBlueprints
;
}
public
Map
<
Integer
,
ActiveForgeData
>
getActiveForges
()
{
return
this
.
activeForges
;
}
}
public
MpSettingType
getMpSetting
()
{
public
MpSettingType
getMpSetting
()
{
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerForgeStartReq.java
0 → 100644
View file @
8db0500e
package
emu.grasscutter.server.packet.recv
;
import
java.lang.invoke.StringConcatFactory
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.ForgeStartReqOuterClass
;
import
emu.grasscutter.net.proto.DeleteFriendReqOuterClass
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.packet.send.PacketDelMailRsp
;
@Opcodes
(
PacketOpcodes
.
ForgeStartReq
)
public
class
HandlerForgeStartReq
extends
PacketHandler
{
@Override
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
ForgeStartReqOuterClass
.
ForgeStartReq
req
=
ForgeStartReqOuterClass
.
ForgeStartReq
.
parseFrom
(
payload
);
session
.
getPlayer
().
getForgingManager
().
startForging
(
req
);
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketForgeDataNotify.java
View file @
8db0500e
package
emu.grasscutter.server.packet.send
;
package
emu.grasscutter.server.packet.send
;
import
java.util.Map
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.player.Player
;
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.ForgeDataNotifyOuterClass.ForgeDataNotify
;
import
emu.grasscutter.net.proto.ForgeDataNotifyOuterClass.ForgeDataNotify
;
import
emu.grasscutter.net.proto.ForgeQueueDataOuterClass.ForgeQueueData
;
public
class
PacketForgeDataNotify
extends
BasePacket
{
public
class
PacketForgeDataNotify
extends
BasePacket
{
public
PacketForgeDataNotify
(
Iterable
<
Integer
>
unlockedItem
,
int
numQueues
)
{
public
PacketForgeDataNotify
(
Iterable
<
Integer
>
unlockedItem
,
int
numQueues
,
Map
<
Integer
,
ForgeQueueData
>
queueData
)
{
super
(
PacketOpcodes
.
ForgeDataNotify
);
super
(
PacketOpcodes
.
ForgeDataNotify
);
/*int adventureRank = player.getLevel();
ForgeDataNotify
.
Builder
builder
=
ForgeDataNotify
.
newBuilder
()
int numQueues =
(adventureRank >= 15) ? 4
: (adventureRank >= 10) ? 3
: (adventureRank >= 5) ? 2
: 1;*/
ForgeDataNotify
proto
=
ForgeDataNotify
.
newBuilder
()
.
addAllForgeIdList
(
unlockedItem
)
.
addAllForgeIdList
(
unlockedItem
)
.
setMaxQueueNum
(
numQueues
)
.
setMaxQueueNum
(
numQueues
);
.
build
();
// ToDo: Add the information for the actual forging queues
for
(
int
queueId
:
queueData
.
keySet
())
{
// and ongoing forges.
var
data
=
queueData
.
get
(
queueId
);
builder
.
putForgeQueueMap
(
queueId
,
data
);
}
this
.
setData
(
proto
);
this
.
setData
(
builder
.
build
()
);
}
}
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketForgeGetQueueDataRsp.java
View file @
8db0500e
package
emu.grasscutter.server.packet.send
;
package
emu.grasscutter.server.packet.send
;
import
java.util.Map
;
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.ForgeGetQueueDataRspOuterClass.ForgeGetQueueDataRsp
;
import
emu.grasscutter.net.proto.ForgeGetQueueDataRspOuterClass.ForgeGetQueueDataRsp
;
import
emu.grasscutter.net.proto.ForgeQueueDataOuterClass.ForgeQueueData
;
import
emu.grasscutter.net.proto.RetcodeOuterClass.Retcode
;
import
emu.grasscutter.net.proto.RetcodeOuterClass.Retcode
;
public
class
PacketForgeGetQueueDataRsp
extends
BasePacket
{
public
class
PacketForgeGetQueueDataRsp
extends
BasePacket
{
public
PacketForgeGetQueueDataRsp
(
Retcode
retcode
,
int
numQueues
)
{
public
PacketForgeGetQueueDataRsp
(
Retcode
retcode
,
int
numQueues
,
Map
<
Integer
,
ForgeQueueData
>
queueData
)
{
super
(
PacketOpcodes
.
ForgeGetQueueDataRsp
);
super
(
PacketOpcodes
.
ForgeGetQueueDataRsp
);
ForgeGetQueueDataRsp
proto
=
ForgeGetQueueDataRsp
.
newBuilder
()
ForgeGetQueueDataRsp
.
Builder
builder
=
ForgeGetQueueDataRsp
.
newBuilder
()
.
setRetcode
(
retcode
.
getNumber
())
.
setRetcode
(
retcode
.
getNumber
())
.
setMaxQueueNum
(
numQueues
)
.
setMaxQueueNum
(
numQueues
);
.
build
();
// ToDo: Add the information for the actual forging queues
for
(
int
queueId
:
queueData
.
keySet
())
{
// and ongoing forges.
var
data
=
queueData
.
get
(
queueId
);
builder
.
putForgeQueueMap
(
queueId
,
data
);
}
this
.
setData
(
proto
);
this
.
setData
(
builder
.
build
()
);
}
}
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketForgeStartRsp.java
0 → 100644
View file @
8db0500e
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.ForgeStartRspOuterClass.ForgeStartRsp
;
import
emu.grasscutter.net.proto.RetcodeOuterClass.Retcode
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
PacketForgeStartRsp
extends
BasePacket
{
public
PacketForgeStartRsp
(
Retcode
retcode
)
{
super
(
PacketOpcodes
.
ForgeStartRsp
);
ForgeStartRsp
proto
=
ForgeStartRsp
.
newBuilder
()
.
setRetcode
(
retcode
.
getNumber
())
.
build
();
this
.
setData
(
proto
);
}
}
\ No newline at end of file
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