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
45b45c4b
Commit
45b45c4b
authored
May 09, 2022
by
Akka
Browse files
Merge remote-tracking branch 'fork/tower' into tower
parents
722e710c
47ea4660
Changes
31
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/server/packet/recv/HandlerCombatInvocationsNotify.java
View file @
45b45c4b
...
...
@@ -74,14 +74,6 @@ public class HandlerCombatInvocationsNotify extends PacketHandler {
session
.
getPlayer
().
getCombatInvokeHandler
().
addEntry
(
entry
.
getForwardType
(),
entry
);
}
if
(
notif
.
getInvokeListList
().
size
()
>
0
)
{
session
.
getPlayer
().
getCombatInvokeHandler
().
update
(
session
.
getPlayer
());
}
// Handle attack results last
while
(!
session
.
getPlayer
().
getAttackResults
().
isEmpty
())
{
session
.
getPlayer
().
getScene
().
handleAttack
(
session
.
getPlayer
().
getAttackResults
().
poll
());
}
}
private
void
handleFallOnGround
(
GameSession
session
,
GameEntity
entity
,
MotionState
motionState
)
{
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerEvtCreateGadgetNotify.java
View file @
45b45c4b
...
...
@@ -14,11 +14,6 @@ public class HandlerEvtCreateGadgetNotify extends PacketHandler {
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
EvtCreateGadgetNotify
notify
=
EvtCreateGadgetNotify
.
parseFrom
(
payload
);
// Dont handle in singleplayer
if
(!
session
.
getPlayer
().
getWorld
().
isMultiplayer
())
{
return
;
}
// Sanity check - dont add duplicate entities
if
(
session
.
getPlayer
().
getScene
().
getEntityById
(
notify
.
getEntityId
())
!=
null
)
{
return
;
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerEvtDestroyGadgetNotify.java
View file @
45b45c4b
...
...
@@ -13,11 +13,6 @@ public class HandlerEvtDestroyGadgetNotify extends PacketHandler {
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
EvtDestroyGadgetNotify
notify
=
EvtDestroyGadgetNotify
.
parseFrom
(
payload
);
// Dont handle in singleplayer
if
(!
session
.
getPlayer
().
getWorld
().
isMultiplayer
())
{
return
;
}
session
.
getPlayer
().
getScene
().
onPlayerDestroyGadget
(
notify
.
getEntityId
());
}
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerSetEntityClientDataNotify.java
View file @
45b45c4b
...
...
@@ -23,7 +23,7 @@ public class HandlerSetEntityClientDataNotify extends PacketHandler {
BasePacket
packet
=
new
BasePacket
(
PacketOpcodes
.
SetEntityClientDataNotify
,
true
);
packet
.
setData
(
notif
);
session
.
getPlayer
().
getScene
().
broadcastPacket
ToOthers
(
session
.
getPlayer
(),
packet
);
session
.
getPlayer
().
getScene
().
broadcastPacket
(
packet
);
}
}
src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerBornDataReq.java
View file @
45b45c4b
...
...
@@ -62,7 +62,7 @@ public class HandlerSetPlayerBornDataReq extends PacketHandler {
// Create avatar
if
(
player
.
getAvatars
().
getAvatarCount
()
==
0
)
{
Avatar
mainCharacter
=
new
Avatar
(
avatarId
);
mainCharacter
.
setSkillDepot
(
GameData
.
getAvatarSkillDepotDataMap
().
get
(
startingSkillDepot
));
mainCharacter
.
setSkillDepot
Data
(
GameData
.
getAvatarSkillDepotDataMap
().
get
(
startingSkillDepot
));
player
.
addAvatar
(
mainCharacter
);
player
.
setMainCharacterId
(
avatarId
);
player
.
setHeadImage
(
avatarId
);
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerUnionCmdNotify.java
View file @
45b45c4b
...
...
@@ -15,5 +15,14 @@ public class HandlerUnionCmdNotify extends PacketHandler {
for
(
UnionCmd
cmd
:
req
.
getCmdListList
())
{
session
.
getServer
().
getPacketHandler
().
handle
(
session
,
cmd
.
getMessageId
(),
EMPTY_BYTE_ARRAY
,
cmd
.
getBody
().
toByteArray
());
}
// Update
session
.
getPlayer
().
getCombatInvokeHandler
().
update
(
session
.
getPlayer
());
session
.
getPlayer
().
getAbilityInvokeHandler
().
update
(
session
.
getPlayer
());
// Handle attack results last
while
(!
session
.
getPlayer
().
getAttackResults
().
isEmpty
())
{
session
.
getPlayer
().
getScene
().
handleAttack
(
session
.
getPlayer
().
getAttackResults
().
poll
());
}
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketEntityFightPropChangeReasonNotify.java
View file @
45b45c4b
...
...
@@ -11,21 +11,27 @@ import emu.grasscutter.net.proto.PropChangeReasonOuterClass.PropChangeReason;
import
java.util.List
;
public
class
PacketEntityFightPropChangeReasonNotify
extends
BasePacket
{
public
PacketEntityFightPropChangeReasonNotify
(
GameEntity
entity
,
FightProperty
prop
,
Float
value
,
List
<
Integer
>
param
,
PropChangeReason
reason
,
ChangeHpReason
changeHpReason
)
{
super
(
PacketOpcodes
.
EntityFightPropChangeReasonNotify
);
EntityFightPropChangeReasonNotify
.
Builder
proto
=
EntityFightPropChangeReasonNotify
.
newBuilder
()
.
setEntityId
(
entity
.
getId
())
.
setPropType
(
prop
.
getId
())
.
setPropDelta
(
value
)
.
setReason
(
reason
)
.
setChangeHpReason
(
changeHpReason
);
for
(
int
p:
param
){
for
(
int
p
:
param
){
proto
.
addParamList
(
p
);
}
this
.
setData
(
proto
);
}
public
PacketEntityFightPropChangeReasonNotify
(
GameEntity
entity
,
FightProperty
prop
,
Float
value
,
PropChangeReason
reason
,
ChangeHpReason
changeHpReason
)
{
super
(
PacketOpcodes
.
EntityFightPropChangeReasonNotify
);
EntityFightPropChangeReasonNotify
proto
=
EntityFightPropChangeReasonNotify
.
newBuilder
()
.
setEntityId
(
entity
.
getId
())
.
setPropType
(
prop
.
getId
())
...
...
@@ -33,6 +39,20 @@ public class PacketEntityFightPropChangeReasonNotify extends BasePacket {
.
setReason
(
reason
)
.
setChangeHpReason
(
changeHpReason
)
.
build
();
this
.
setData
(
proto
);
}
public
PacketEntityFightPropChangeReasonNotify
(
GameEntity
entity
,
FightProperty
prop
,
Float
value
,
PropChangeReason
reason
)
{
super
(
PacketOpcodes
.
EntityFightPropChangeReasonNotify
);
EntityFightPropChangeReasonNotify
proto
=
EntityFightPropChangeReasonNotify
.
newBuilder
()
.
setEntityId
(
entity
.
getId
())
.
setPropType
(
prop
.
getId
())
.
setPropDelta
(
value
)
.
setReason
(
reason
)
.
build
();
this
.
setData
(
proto
);
}
}
src/main/java/emu/grasscutter/task/Task.java
View file @
45b45c4b
package
emu.grasscutter.task
;
import
org.quartz.JobDataMap
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
...
...
src/main/java/emu/grasscutter/task/TaskMap.java
View file @
45b45c4b
...
...
@@ -67,6 +67,40 @@ public final class TaskMap {
return
this
;
}
public
boolean
pauseTask
(
String
taskName
)
{
try
{
Scheduler
scheduler
=
schedulerFactory
.
getScheduler
();
scheduler
.
pauseJob
(
new
JobKey
(
taskName
));
}
catch
(
SchedulerException
e
)
{
e
.
printStackTrace
();
return
false
;
}
return
true
;
}
public
boolean
resumeTask
(
String
taskName
)
{
try
{
Scheduler
scheduler
=
schedulerFactory
.
getScheduler
();
scheduler
.
resumeJob
(
new
JobKey
(
taskName
));
}
catch
(
SchedulerException
e
)
{
e
.
printStackTrace
();
return
false
;
}
return
true
;
}
public
boolean
cancelTask
(
String
taskName
)
{
Task
task
=
this
.
annotations
.
get
(
taskName
);
if
(
task
==
null
)
return
false
;
try
{
this
.
unregisterTask
(
this
.
tasks
.
get
(
taskName
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
false
;
}
return
true
;
}
public
TaskMap
registerTask
(
String
taskName
,
TaskHandler
task
)
{
Task
annotation
=
task
.
getClass
().
getAnnotation
(
Task
.
class
);
this
.
annotations
.
put
(
taskName
,
annotation
);
...
...
@@ -116,7 +150,7 @@ public final class TaskMap {
classes
.
forEach
(
annotated
->
{
try
{
Task
taskData
=
annotated
.
getAnnotation
(
Task
.
class
);
Object
object
=
annotated
.
newInstance
();
Object
object
=
annotated
.
getDeclaredConstructor
().
newInstance
();
if
(
object
instanceof
TaskHandler
)
{
this
.
registerTask
(
taskData
.
taskName
(),
(
TaskHandler
)
object
);
if
(
taskData
.
executeImmediatelyAfterReset
())
{
...
...
src/main/java/emu/grasscutter/utils/Language.java
View file @
45b45c4b
...
...
@@ -19,7 +19,7 @@ public final class Language {
* @return A language instance.
*/
public
static
Language
getLanguage
(
String
langCode
)
{
return
new
Language
(
langCode
+
".json"
,
Grasscutter
.
getConfig
().
DefaultLanguage
.
toLanguageTag
());
return
new
Language
(
langCode
+
".json"
,
Grasscutter
.
getConfig
().
DefaultLanguage
.
toLanguageTag
()
+
".json"
);
}
/**
...
...
@@ -46,15 +46,20 @@ public final class Language {
private
Language
(
String
fileName
,
String
fallback
)
{
@Nullable
JsonObject
languageData
=
null
;
try
{
InputStream
file
=
Grasscutter
.
class
.
getResourceAsStream
(
"/languages/"
+
fileName
);
String
translationContents
=
Utils
.
readFromInputStream
(
file
);
if
(
translationContents
.
equals
(
"empty"
))
{
if
(
file
==
null
)
{
// Provided fallback language.
file
=
Grasscutter
.
class
.
getResourceAsStream
(
"/languages/"
+
fallback
);
translationContents
=
Utils
.
readFromInputStream
(
file
);
Grasscutter
.
getLogger
().
warn
(
"Failed to load language file: "
+
fileName
+
", falling back to: "
+
fallback
);
}
if
(
file
==
null
)
{
// Fallback the fallback language.
file
=
Grasscutter
.
class
.
getResourceAsStream
(
"/languages/en-US.json"
);
Grasscutter
.
getLogger
().
warn
(
"Failed to load language file: "
+
fallback
+
", falling back to: en-US.json"
);
}
if
(
file
==
null
)
throw
new
RuntimeException
(
"Unable to load the primary, fallback, and 'en-US' language files."
);
languageData
=
Grasscutter
.
getGsonFactory
().
fromJson
(
translationContents
,
JsonObject
.
class
);
try
{
languageData
=
Grasscutter
.
getGsonFactory
().
fromJson
(
Utils
.
readFromInputStream
(
file
),
JsonObject
.
class
);
}
catch
(
Exception
exception
)
{
Grasscutter
.
getLogger
().
warn
(
"Failed to load language file: "
+
fileName
,
exception
);
}
...
...
src/main/resources/languages/zh-CN.json
View file @
45b45c4b
...
...
@@ -36,7 +36,7 @@
}
},
"status"
:
{
"free_software"
:
"Grasscutter 是免费开源软件,遵循A
pache-2
.0 license。如果您是付费购买的,那您已经被骗了。项目地址:Github:https://github.com/Grasscutters/Grasscutter"
,
"free_software"
:
"Grasscutter 是免费开源软件,遵循A
GPL-3
.0 license。如果您是付费购买的,那您已经被骗了。项目地址:Github:https://github.com/Grasscutters/Grasscutter"
,
"starting"
:
"正在启动 Grasscutter..."
,
"shutdown"
:
"正在关闭..."
,
"done"
:
"加载完成!输入
\"
help
\"
查看命令列表"
,
...
...
Prev
1
2
Next
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