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
b9f7c657
Commit
b9f7c657
authored
Apr 27, 2022
by
Benjamin Elsdon
Browse files
Merge remote-tracking branch 'upstream/development' into dev-mail
parents
eb495807
782618cd
Changes
86
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/InvokeHandler.java
View file @
b9f7c657
...
...
@@ -20,18 +20,11 @@ public class InvokeHandler<T> {
public
synchronized
void
addEntry
(
ForwardType
forward
,
T
entry
)
{
switch
(
forward
)
{
case
ForwardToAll:
entryListForwardAll
.
add
(
entry
);
break
;
case
ForwardToAllExceptCur:
case
ForwardToAllExistExceptCur:
entryListForwardAllExceptCur
.
add
(
entry
);
break
;
case
ForwardToHost:
entryListForwardHost
.
add
(
entry
);
break
;
default
:
break
;
case
FORWARD_TO_ALL
->
entryListForwardAll
.
add
(
entry
);
case
FORWARD_TO_ALL_EXCEPT_CUR
,
FORWARD_TO_ALL_EXIST_EXCEPT_CUR
->
entryListForwardAllExceptCur
.
add
(
entry
);
case
FORWARD_TO_HOST
->
entryListForwardHost
.
add
(
entry
);
default
->
{
}
}
}
...
...
src/main/java/emu/grasscutter/game/TeamManager.java
View file @
b9f7c657
...
...
@@ -397,7 +397,7 @@ public class TeamManager {
this
.
setCurrentCharacterIndex
(
index
);
// Old entity motion state
oldEntity
.
setMotionState
(
MotionState
.
M
otionStandby
);
oldEntity
.
setMotionState
(
MotionState
.
M
OTION_STANDBY
);
// Remove and Add
getPlayer
().
getScene
().
replaceEntity
(
oldEntity
,
newEntity
);
...
...
@@ -476,7 +476,7 @@ public class TeamManager {
}
// Teleport player
getPlayer
().
sendPacket
(
new
PacketPlayerEnterSceneNotify
(
getPlayer
(),
EnterType
.
E
nterSelf
,
EnterReason
.
Revival
,
3
,
GenshinConstants
.
START_POSITION
));
getPlayer
().
sendPacket
(
new
PacketPlayerEnterSceneNotify
(
getPlayer
(),
EnterType
.
E
NTER_SELF
,
EnterReason
.
Revival
,
3
,
GenshinConstants
.
START_POSITION
));
// Set player position
player
.
setSceneId
(
3
);
...
...
src/main/java/emu/grasscutter/game/World.java
View file @
b9f7c657
...
...
@@ -64,7 +64,7 @@ public class World implements Iterable<GenshinPlayer> {
this
.
levelEntityId
=
getNextEntityId
(
EntityIdType
.
MPLEVEL
);
this
.
worldLevel
=
player
.
getWorldLevel
();
this
.
isMultiplayer
=
isMultiplayer
;
this
.
owner
.
getServer
().
registerWorld
(
this
);
}
...
...
@@ -197,7 +197,7 @@ public class World implements Iterable<GenshinPlayer> {
World
world
=
new
World
(
victim
);
world
.
addPlayer
(
victim
);
victim
.
sendPacket
(
new
PacketPlayerEnterSceneNotify
(
victim
,
EnterType
.
E
nterSelf
,
EnterReason
.
TeamKick
,
victim
.
getSceneId
(),
victim
.
getPos
()));
victim
.
sendPacket
(
new
PacketPlayerEnterSceneNotify
(
victim
,
EnterType
.
E
NTER_SELF
,
EnterReason
.
TeamKick
,
victim
.
getSceneId
(),
victim
.
getPos
()));
}
}
}
...
...
@@ -219,12 +219,12 @@ public class World implements Iterable<GenshinPlayer> {
if
(
player
.
getScene
()
!=
null
)
{
oldScene
=
player
.
getScene
();
// Dont deregister scenes if the player is going to tp back into them
if
(
oldScene
.
getId
()
==
sceneId
)
{
oldScene
.
setDontDestroyWhenEmpty
(
true
);
}
oldScene
.
removePlayer
(
player
);
}
...
...
@@ -235,12 +235,12 @@ public class World implements Iterable<GenshinPlayer> {
if
(
oldScene
!=
null
)
{
oldScene
.
setDontDestroyWhenEmpty
(
false
);
}
// Teleport packet
if
(
oldScene
==
newScene
)
{
player
.
sendPacket
(
new
PacketPlayerEnterSceneNotify
(
player
,
EnterType
.
E
nterGoto
,
EnterReason
.
TransPoint
,
sceneId
,
pos
));
player
.
sendPacket
(
new
PacketPlayerEnterSceneNotify
(
player
,
EnterType
.
E
NTER_GOTO
,
EnterReason
.
TransPoint
,
sceneId
,
pos
));
}
else
{
player
.
sendPacket
(
new
PacketPlayerEnterSceneNotify
(
player
,
EnterType
.
E
nterJump
,
EnterReason
.
TransPoint
,
sceneId
,
pos
));
player
.
sendPacket
(
new
PacketPlayerEnterSceneNotify
(
player
,
EnterType
.
E
NTER_JUMP
,
EnterReason
.
TransPoint
,
sceneId
,
pos
));
}
return
true
;
}
...
...
@@ -281,7 +281,7 @@ public class World implements Iterable<GenshinPlayer> {
scene
.
onTick
();
}
}
public
void
close
()
{
}
...
...
src/main/java/emu/grasscutter/game/avatar/GenshinAvatar.java
View file @
b9f7c657
...
...
@@ -778,7 +778,7 @@ public class GenshinAvatar {
.
setCoreProudSkillLevel
(
this
.
getCoreProudSkillLevel
())
.
putAllSkillLevelMap
(
this
.
getSkillLevelMap
())
.
addAllInherentProudSkillList
(
this
.
getProudSkillList
())
.
putAllProudSkillExtraLevel
(
getProudSkillBonusMap
())
.
putAllProudSkillExtraLevel
Map
(
getProudSkillBonusMap
())
.
setAvatarType
(
1
)
.
setBornTime
(
this
.
getBornTime
())
.
setFetterInfo
(
avatarFetter
)
...
...
src/main/java/emu/grasscutter/game/entity/EntityAvatar.java
View file @
b9f7c657
...
...
@@ -101,13 +101,13 @@ public class EntityAvatar extends GenshinEntity {
@Override
public
void
onDeath
(
int
killerId
)
{
this
.
killedType
=
PlayerDieType
.
P
layerDieKillByMonster
;
this
.
killedType
=
PlayerDieType
.
P
LAYER_DIE_KILL_BY_MONSTER
;
this
.
killedBy
=
killerId
;
}
public
SceneAvatarInfo
getSceneAvatarInfo
()
{
SceneAvatarInfo
.
Builder
avatarInfo
=
SceneAvatarInfo
.
newBuilder
()
.
set
PlayerI
d
(
this
.
getPlayer
().
getUid
())
.
set
Ui
d
(
this
.
getPlayer
().
getUid
())
.
setAvatarId
(
this
.
getAvatar
().
getAvatarId
())
.
setGuid
(
this
.
getAvatar
().
getGuid
())
.
setPeerId
(
this
.
getPlayer
().
getPeerId
())
...
...
@@ -145,7 +145,7 @@ public class EntityAvatar extends GenshinEntity {
SceneEntityInfo
.
Builder
entityInfo
=
SceneEntityInfo
.
newBuilder
()
.
setEntityId
(
getId
())
.
setEntityType
(
ProtEntityType
.
P
rotEntityAvatar
)
.
setEntityType
(
ProtEntityType
.
P
ROT_ENTITY_AVATAR
)
.
addAnimatorParaList
(
AnimatorParameterValueInfoPair
.
newBuilder
())
.
setEntityClientData
(
EntityClientData
.
newBuilder
())
.
setEntityAuthorityInfo
(
authority
)
...
...
@@ -161,7 +161,7 @@ public class EntityAvatar extends GenshinEntity {
if
(
entry
.
getIntKey
()
==
0
)
{
continue
;
}
FightPropPair
fightProp
=
FightPropPair
.
newBuilder
().
setType
(
entry
.
getIntKey
()).
setPropValue
(
entry
.
getFloatValue
()).
build
();
FightPropPair
fightProp
=
FightPropPair
.
newBuilder
().
set
Prop
Type
(
entry
.
getIntKey
()).
setPropValue
(
entry
.
getFloatValue
()).
build
();
entityInfo
.
addFightPropList
(
fightProp
);
}
...
...
src/main/java/emu/grasscutter/game/entity/EntityClientGadget.java
View file @
b9f7c657
...
...
@@ -6,6 +6,7 @@ import emu.grasscutter.game.World;
import
emu.grasscutter.game.props.PlayerProperty
;
import
emu.grasscutter.net.proto.AbilitySyncStateInfoOuterClass.AbilitySyncStateInfo
;
import
emu.grasscutter.net.proto.AnimatorParameterValueInfoPairOuterClass.AnimatorParameterValueInfoPair
;
import
emu.grasscutter.net.proto.ClientGadgetInfoOuterClass
;
import
emu.grasscutter.net.proto.EntityAuthorityInfoOuterClass.EntityAuthorityInfo
;
import
emu.grasscutter.net.proto.EntityClientDataOuterClass.EntityClientData
;
import
emu.grasscutter.net.proto.EntityRendererChangedInfoOuterClass.EntityRendererChangedInfo
;
...
...
@@ -112,7 +113,7 @@ public class EntityClientGadget extends EntityGadget {
SceneEntityInfo
.
Builder
entityInfo
=
SceneEntityInfo
.
newBuilder
()
.
setEntityId
(
getId
())
.
setEntityType
(
ProtEntityType
.
P
rotEntityGadget
)
.
setEntityType
(
ProtEntityType
.
P
ROT_ENTITY_GADGET
)
.
setMotionInfo
(
MotionInfo
.
newBuilder
().
setPos
(
getPosition
().
toProto
()).
setRot
(
getRotation
().
toProto
()).
setSpeed
(
Vector
.
newBuilder
()))
.
addAnimatorParaList
(
AnimatorParameterValueInfoPair
.
newBuilder
())
.
setEntityClientData
(
EntityClientData
.
newBuilder
())
...
...
@@ -125,7 +126,7 @@ public class EntityClientGadget extends EntityGadget {
.
build
();
entityInfo
.
addPropList
(
pair
);
GadgetClientParam
clientGadget
=
GadgetClientParam
.
newBuilder
()
ClientGadgetInfoOuterClass
.
ClientGadgetInfo
clientGadget
=
ClientGadgetInfoOuterClass
.
ClientGadgetInfo
.
newBuilder
()
.
setCampId
(
this
.
getCampId
())
.
setCampType
(
this
.
getCampType
())
.
setOwnerEntityId
(
this
.
getOwnerEntityId
())
...
...
src/main/java/emu/grasscutter/game/entity/EntityItem.java
View file @
b9f7c657
...
...
@@ -92,7 +92,7 @@ public class EntityItem extends EntityGadget {
SceneEntityInfo
.
Builder
entityInfo
=
SceneEntityInfo
.
newBuilder
()
.
setEntityId
(
getId
())
.
setEntityType
(
ProtEntityType
.
P
rotEntityGadget
)
.
setEntityType
(
ProtEntityType
.
P
ROT_ENTITY_GADGET
)
.
setMotionInfo
(
MotionInfo
.
newBuilder
().
setPos
(
getPosition
().
toProto
()).
setRot
(
getRotation
().
toProto
()).
setSpeed
(
Vector
.
newBuilder
()))
.
addAnimatorParaList
(
AnimatorParameterValueInfoPair
.
newBuilder
())
.
setEntityClientData
(
EntityClientData
.
newBuilder
())
...
...
@@ -108,7 +108,7 @@ public class EntityItem extends EntityGadget {
SceneGadgetInfo
.
Builder
gadgetInfo
=
SceneGadgetInfo
.
newBuilder
()
.
setGadgetId
(
this
.
getItemData
().
getGadgetId
())
.
setTrifleItem
(
this
.
getItem
().
toProto
())
.
setBornType
(
GadgetBornType
.
G
adgetBornInAir
)
.
setBornType
(
GadgetBornType
.
G
ADGET_BORN_IN_AIR
)
.
setAuthorityPeerId
(
this
.
getWorld
().
getHostPeerId
())
.
setIsEnableInteract
(
true
);
...
...
src/main/java/emu/grasscutter/game/entity/EntityMonster.java
View file @
b9f7c657
...
...
@@ -197,7 +197,7 @@ public class EntityMonster extends GenshinEntity {
SceneEntityInfo
.
Builder
entityInfo
=
SceneEntityInfo
.
newBuilder
()
.
setEntityId
(
getId
())
.
setEntityType
(
ProtEntityType
.
P
rotEntityMonster
)
.
setEntityType
(
ProtEntityType
.
P
ROT_ENTITY_MONSTER
)
.
setMotionInfo
(
this
.
getMotionInfo
())
.
addAnimatorParaList
(
AnimatorParameterValueInfoPair
.
newBuilder
())
.
setEntityClientData
(
EntityClientData
.
newBuilder
())
...
...
@@ -208,7 +208,7 @@ public class EntityMonster extends GenshinEntity {
if
(
entry
.
getIntKey
()
==
0
)
{
continue
;
}
FightPropPair
fightProp
=
FightPropPair
.
newBuilder
().
setType
(
entry
.
getIntKey
()).
setPropValue
(
entry
.
getFloatValue
()).
build
();
FightPropPair
fightProp
=
FightPropPair
.
newBuilder
().
set
Prop
Type
(
entry
.
getIntKey
()).
setPropValue
(
entry
.
getFloatValue
()).
build
();
entityInfo
.
addFightPropList
(
fightProp
);
}
...
...
@@ -226,7 +226,7 @@ public class EntityMonster extends GenshinEntity {
.
setAuthorityPeerId
(
getWorld
().
getHostPeerId
())
.
setPoseId
(
this
.
getPoseId
())
.
setBlockId
(
3001
)
.
setBornType
(
MonsterBornType
.
M
onsterBornDefault
)
.
setBornType
(
MonsterBornType
.
M
ONSTER_BORN_DEFAULT
)
.
setSpecialNameId
(
40
);
if
(
getMonsterData
().
getDescribeData
()
!=
null
)
{
...
...
@@ -240,7 +240,7 @@ public class EntityMonster extends GenshinEntity {
.
setAbilityInfo
(
AbilitySyncStateInfo
.
newBuilder
())
.
build
();
monsterInfo
.
set
WeaponList
(
weaponInfo
);
monsterInfo
.
add
WeaponList
(
weaponInfo
);
}
entityInfo
.
setMonster
(
monsterInfo
);
...
...
src/main/java/emu/grasscutter/game/entity/GenshinEntity.java
View file @
b9f7c657
...
...
@@ -23,7 +23,7 @@ public abstract class GenshinEntity {
public
GenshinEntity
(
GenshinScene
scene
)
{
this
.
scene
=
scene
;
this
.
moveState
=
MotionState
.
M
otionNone
;
this
.
moveState
=
MotionState
.
M
OTION_NONE
;
}
public
int
getId
()
{
...
...
src/main/java/emu/grasscutter/game/friends/FriendsList.java
View file @
b9f7c657
...
...
@@ -104,7 +104,7 @@ public class FriendsList {
}
// Handle
if
(
result
==
DealAddFriendResultType
.
D
ealAddFriendAccept
)
{
// Request accepted
if
(
result
==
DealAddFriendResultType
.
D
EAL_ADD_FRIEND_ACCEPT
)
{
// Request accepted
myFriendship
.
setIsFriend
(
true
);
theirFriendship
.
setIsFriend
(
true
);
...
...
src/main/java/emu/grasscutter/game/friends/Friendship.java
View file @
b9f7c657
package
emu.grasscutter.game.friends
;
import
emu.grasscutter.net.proto.PlatformTypeOuterClass
;
import
org.bson.types.ObjectId
;
import
dev.morphia.annotations.*
;
...
...
@@ -91,16 +92,16 @@ public class Friendship {
.
setUid
(
getFriendProfile
().
getUid
())
.
setNickname
(
getFriendProfile
().
getName
())
.
setLevel
(
getFriendProfile
().
getPlayerLevel
())
.
setAvatar
(
HeadImage
.
newBuilder
().
setAvatarId
(
getFriendProfile
().
getAvatarId
()))
.
setAvatar
Id
(
HeadImage
.
newBuilder
().
setAvatarId
(
getFriendProfile
().
getAvatarId
())
.
getAvatarId
()
)
.
setWorldLevel
(
getFriendProfile
().
getWorldLevel
())
.
setSignature
(
getFriendProfile
().
getSignature
())
.
setOnlineState
(
getFriendProfile
().
isOnline
()
?
FriendOnlineState
.
FRIEND_ONLINE
:
FriendOnlineState
.
FRIEND_DISCONNECT
)
.
setOnlineState
(
getFriendProfile
().
isOnline
()
?
FriendOnlineState
.
FRIEND_ONLINE
:
FriendOnlineState
.
FR
E
IEND_DISCONNECT
)
.
setIsMpModeAvailable
(
true
)
.
setLastActiveTime
(
getFriendProfile
().
getLastActiveTime
())
.
setNameCardId
(
getFriendProfile
().
getNameCard
())
.
setParam
(
getFriendProfile
().
getDaysSinceLogin
())
.
set
Unk1
(
1
)
.
set
Unk2
(
3
)
.
set
IsGameSource
(
true
)
.
set
PlatformType
(
PlatformTypeOuterClass
.
PlatformType
.
PC
)
.
build
();
return
proto
;
...
...
src/main/java/emu/grasscutter/game/gacha/GachaManager.java
View file @
b9f7c657
...
...
@@ -286,8 +286,6 @@ public class GachaManager {
this
.
watchService
=
FileSystems
.
getDefault
().
newWatchService
();
Path
path
=
new
File
(
Grasscutter
.
getConfig
().
DATA_FOLDER
).
toPath
();
path
.
register
(
watchService
,
new
WatchEvent
.
Kind
[]{
StandardWatchEventKinds
.
ENTRY_MODIFY
},
SensitivityWatchEventModifier
.
HIGH
);
server
.
OnGameServerTick
.
register
(
this
);
}
catch
(
Exception
e
)
{
Grasscutter
.
getLogger
().
error
(
"Unable to load the Gacha Manager Watch Service. If ServerOptions.watchGacha is true it will not auto-reload"
);
e
.
printStackTrace
();
...
...
src/main/java/emu/grasscutter/game/managers/MultiplayerManager.java
View file @
b9f7c657
...
...
@@ -7,6 +7,7 @@ import emu.grasscutter.game.props.EnterReason;
import
emu.grasscutter.net.proto.EnterTypeOuterClass.EnterType
;
import
emu.grasscutter.net.proto.PlayerApplyEnterMpReasonOuterClass.PlayerApplyEnterMpReason
;
import
emu.grasscutter.game.World
;
import
emu.grasscutter.net.proto.PlayerApplyEnterMpResultNotifyOuterClass
;
import
emu.grasscutter.server.game.GameServer
;
import
emu.grasscutter.server.packet.send.PacketPlayerApplyEnterMpNotify
;
import
emu.grasscutter.server.packet.send.PacketPlayerApplyEnterMpResultNotify
;
...
...
@@ -26,7 +27,7 @@ public class MultiplayerManager {
public
void
applyEnterMp
(
GenshinPlayer
player
,
int
targetUid
)
{
GenshinPlayer
target
=
getServer
().
getPlayerByUid
(
targetUid
);
if
(
target
==
null
)
{
player
.
sendPacket
(
new
PacketPlayerApplyEnterMpResultNotify
(
targetUid
,
""
,
false
,
PlayerApplyEnterMpRe
ason
.
Player
Cannot
EnterMp
));
player
.
sendPacket
(
new
PacketPlayerApplyEnterMpResultNotify
(
targetUid
,
""
,
false
,
PlayerApplyEnterMpRe
sultNotifyOuterClass
.
Player
Apply
EnterMp
ResultNotify
.
Reason
.
PLAYER_CANNOT_ENTER_MP
));
return
;
}
...
...
@@ -71,12 +72,12 @@ public class MultiplayerManager {
// Sanity checks - Dont let the requesting player join if they are already in multiplayer
if
(
requester
.
getWorld
().
isMultiplayer
())
{
request
.
getRequester
().
sendPacket
(
new
PacketPlayerApplyEnterMpResultNotify
(
hostPlayer
,
false
,
PlayerApplyEnterMpRe
ason
.
Player
Cannot
EnterMp
));
request
.
getRequester
().
sendPacket
(
new
PacketPlayerApplyEnterMpResultNotify
(
hostPlayer
,
false
,
PlayerApplyEnterMpRe
sultNotifyOuterClass
.
Player
Apply
EnterMp
ResultNotify
.
Reason
.
PLAYER_CANNOT_ENTER_MP
));
return
;
}
// Response packet
request
.
getRequester
().
sendPacket
(
new
PacketPlayerApplyEnterMpResultNotify
(
hostPlayer
,
isAgreed
,
PlayerApplyEnterMpRe
ason
.
PlayerJudge
));
request
.
getRequester
().
sendPacket
(
new
PacketPlayerApplyEnterMpResultNotify
(
hostPlayer
,
isAgreed
,
PlayerApplyEnterMpRe
sultNotifyOuterClass
.
PlayerApplyEnterMpResultNotify
.
Reason
.
PLAYER_JUDGE
));
// Declined
if
(!
isAgreed
)
{
...
...
@@ -92,7 +93,7 @@ public class MultiplayerManager {
world
.
addPlayer
(
hostPlayer
);
// Rejoin packet
hostPlayer
.
sendPacket
(
new
PacketPlayerEnterSceneNotify
(
hostPlayer
,
hostPlayer
,
EnterType
.
E
nterSelf
,
EnterReason
.
HostFromSingleToMp
,
hostPlayer
.
getScene
().
getId
(),
hostPlayer
.
getPos
()));
hostPlayer
.
sendPacket
(
new
PacketPlayerEnterSceneNotify
(
hostPlayer
,
hostPlayer
,
EnterType
.
E
NTER_SELF
,
EnterReason
.
HostFromSingleToMp
,
hostPlayer
.
getScene
().
getId
(),
hostPlayer
.
getPos
()));
}
// Set scene pos and id of requester to the host player's
...
...
@@ -104,7 +105,7 @@ public class MultiplayerManager {
hostPlayer
.
getWorld
().
addPlayer
(
requester
);
// Packet
requester
.
sendPacket
(
new
PacketPlayerEnterSceneNotify
(
requester
,
hostPlayer
,
EnterType
.
E
nterOther
,
EnterReason
.
TeamJoin
,
hostPlayer
.
getScene
().
getId
(),
hostPlayer
.
getPos
()));
requester
.
sendPacket
(
new
PacketPlayerEnterSceneNotify
(
requester
,
hostPlayer
,
EnterType
.
E
NTER_OTHER
,
EnterReason
.
TeamJoin
,
hostPlayer
.
getScene
().
getId
(),
hostPlayer
.
getPos
()));
}
public
boolean
leaveCoop
(
GenshinPlayer
player
)
{
...
...
@@ -125,7 +126,7 @@ public class MultiplayerManager {
world
.
addPlayer
(
player
);
// Packet
player
.
sendPacket
(
new
PacketPlayerEnterSceneNotify
(
player
,
EnterType
.
E
nterSelf
,
EnterReason
.
TeamBack
,
player
.
getScene
().
getId
(),
player
.
getPos
()));
player
.
sendPacket
(
new
PacketPlayerEnterSceneNotify
(
player
,
EnterType
.
E
NTER_SELF
,
EnterReason
.
TeamBack
,
player
.
getScene
().
getId
(),
player
.
getPos
()));
return
true
;
}
...
...
@@ -152,7 +153,7 @@ public class MultiplayerManager {
World
world
=
new
World
(
victim
);
world
.
addPlayer
(
victim
);
victim
.
sendPacket
(
new
PacketPlayerEnterSceneNotify
(
victim
,
EnterType
.
E
nterSelf
,
EnterReason
.
TeamKick
,
victim
.
getScene
().
getId
(),
victim
.
getPos
()));
victim
.
sendPacket
(
new
PacketPlayerEnterSceneNotify
(
victim
,
EnterType
.
E
NTER_SELF
,
EnterReason
.
TeamKick
,
victim
.
getScene
().
getId
(),
victim
.
getPos
()));
return
true
;
}
}
src/main/java/emu/grasscutter/net/packet/PacketOpcodes.java
View file @
b9f7c657
...
...
@@ -1009,6 +1009,7 @@ public class PacketOpcodes {
public
static
final
int
SetNameCardRsp
=
4009
;
public
static
final
int
SetOpenStateReq
=
162
;
public
static
final
int
SetOpenStateRsp
=
189
;
public
static
final
int
SetPlayerBirthdayReq
=
4097
;
public
static
final
int
SetPlayerBirthdayRsp
=
4088
;
public
static
final
int
SetPlayerBornDataReq
=
155
;
...
...
@@ -1034,8 +1035,6 @@ public class PacketOpcodes {
public
static
final
int
ShowTemplateReminderNotify
=
3164
;
public
static
final
int
SignInInfoReq
=
2510
;
public
static
final
int
SignInInfoRsp
=
2515
;
public
static
final
int
SitReq
=
354
;
public
static
final
int
SitRsp
=
335
;
public
static
final
int
SocialDataNotify
=
4063
;
public
static
final
int
SpringUseReq
=
1720
;
public
static
final
int
SpringUseRsp
=
1727
;
...
...
src/main/java/emu/grasscutter/net/packet/Retcode.java
deleted
100644 → 0
View file @
eb495807
package
emu.grasscutter.net.packet
;
public
class
Retcode
{
public
static
final
int
SUCCESS
=
0
;
public
static
final
int
FAIL
=
1
;
}
src/main/java/emu/grasscutter/plugin/PluginManager.java
View file @
b9f7c657
...
...
@@ -13,9 +13,11 @@ import java.lang.reflect.Method;
import
java.net.URL
;
import
java.net.URLClassLoader
;
import
java.util.*
;
import
java.util.jar.JarEntry
;
import
java.util.jar.JarFile
;
/**
* Manages the server's plugins
&
the event system.
* Manages the server's plugins
and
the event system.
*/
public
final
class
PluginManager
{
private
final
Map
<
String
,
Plugin
>
plugins
=
new
HashMap
<>();
...
...
@@ -52,13 +54,22 @@ public final class PluginManager {
try
(
URLClassLoader
loader
=
new
URLClassLoader
(
new
URL
[]{
url
}))
{
URL
configFile
=
loader
.
findResource
(
"plugin.json"
);
InputStreamReader
fileReader
=
new
InputStreamReader
(
configFile
.
openStream
());
PluginConfig
pluginConfig
=
Grasscutter
.
getGsonFactory
().
fromJson
(
fileReader
,
PluginConfig
.
class
);
if
(!
pluginConfig
.
validate
())
{
Utils
.
logObject
(
pluginConfig
);
Grasscutter
.
getLogger
().
warn
(
"Plugin "
+
plugin
.
getName
()
+
" has an invalid config file."
);
return
;
}
JarFile
jarFile
=
new
JarFile
(
plugin
);
Enumeration
<
JarEntry
>
entries
=
jarFile
.
entries
();
while
(
entries
.
hasMoreElements
())
{
JarEntry
entry
=
entries
.
nextElement
();
if
(
entry
.
isDirectory
()
||
!
entry
.
getName
().
endsWith
(
".class"
))
continue
;
String
className
=
entry
.
getName
().
replace
(
".class"
,
""
).
replace
(
"/"
,
"."
);
Class
<?>
clazz
=
loader
.
loadClass
(
className
);
}
Class
<?>
pluginClass
=
loader
.
loadClass
(
pluginConfig
.
mainClass
);
Plugin
pluginInstance
=
(
Plugin
)
pluginClass
.
getDeclaredConstructor
().
newInstance
();
...
...
src/main/java/emu/grasscutter/plugin/api/Item.java
0 → 100644
View file @
b9f7c657
package
emu.grasscutter.plugin.api
;
public
enum
Item
{
/* TODO: Use handbook to generate an Item enum. */
}
src/main/java/emu/grasscutter/plugin/api/PlayerHook.java
0 → 100644
View file @
b9f7c657
package
emu.grasscutter.plugin.api
;
import
emu.grasscutter.game.GenshinPlayer
;
import
emu.grasscutter.game.avatar.GenshinAvatar
;
import
emu.grasscutter.game.entity.EntityAvatar
;
import
emu.grasscutter.game.props.EnterReason
;
import
emu.grasscutter.game.props.FightProperty
;
import
emu.grasscutter.net.packet.GenshinPacket
;
import
emu.grasscutter.net.proto.EnterTypeOuterClass.EnterType
;
import
emu.grasscutter.server.packet.send.PacketAvatarFightPropUpdateNotify
;
import
emu.grasscutter.server.packet.send.PacketAvatarLifeStateChangeNotify
;
import
emu.grasscutter.server.packet.send.PacketPlayerEnterSceneNotify
;
import
emu.grasscutter.utils.Position
;
/**
* Hooks into the {@link GenshinPlayer} class, adding convenient ways to do certain things.
*/
public
final
class
PlayerHook
{
private
final
GenshinPlayer
player
;
/**
* Hooks into the player.
* @param player The player to hook into.
*/
public
PlayerHook
(
GenshinPlayer
player
)
{
this
.
player
=
player
;
}
/**
* Kicks a player from the server.
*/
public
void
kick
()
{
this
.
player
.
getSession
().
close
();
}
/**
* Sends a player to another scene.
* @param sceneId The scene to send the player to.
*/
public
void
changeScenes
(
int
sceneId
)
{
this
.
player
.
getWorld
().
transferPlayerToScene
(
this
.
player
,
sceneId
,
this
.
player
.
getPos
());
}
/**
* Broadcasts an avatar property notify to all world players.
* @param property The property that was updated.
*/
public
void
updateFightProperty
(
FightProperty
property
)
{
this
.
broadcastPacketToWorld
(
new
PacketAvatarFightPropUpdateNotify
(
this
.
getCurrentAvatar
(),
property
));
}
/**
* Broadcasts the packet sent to all world players.
* @param packet The packet to send.
*/
public
void
broadcastPacketToWorld
(
GenshinPacket
packet
)
{
this
.
player
.
getWorld
().
broadcastPacket
(
packet
);
}
/**
* Set the currently equipped avatar's health.
* @param health The health to set the avatar to.
*/
public
void
setHealth
(
float
health
)
{
this
.
getCurrentAvatarEntity
().
setFightProperty
(
FightProperty
.
FIGHT_PROP_CUR_HP
,
health
);
this
.
updateFightProperty
(
FightProperty
.
FIGHT_PROP_CUR_HP
);
}
/**
* Revives the specified avatar.
* @param avatar The avatar to revive.
*/
public
void
reviveAvatar
(
GenshinAvatar
avatar
)
{
this
.
broadcastPacketToWorld
(
new
PacketAvatarLifeStateChangeNotify
(
avatar
));
}
/**
* Teleports a player to a position.
* This will **not** transfer the player to another scene.
* @param position The position to teleport the player to.
*/
public
void
teleport
(
Position
position
)
{
this
.
player
.
getPos
().
set
(
position
);
this
.
player
.
sendPacket
(
new
PacketPlayerEnterSceneNotify
(
this
.
player
,
EnterType
.
ENTER_JUMP
,
EnterReason
.
TransPoint
,
this
.
player
.
getSceneId
(),
position
));
}
/**
* Gets the currently selected avatar's max health.
* @return The max health as a float.
*/
public
float
getMaxHealth
()
{
return
this
.
getCurrentAvatarEntity
().
getFightProperty
(
FightProperty
.
FIGHT_PROP_MAX_HP
);
}
/**
* Gets the currently selected avatar in entity form.
* @return The avatar as an {@link EntityAvatar}.
*/
public
EntityAvatar
getCurrentAvatarEntity
()
{
return
this
.
player
.
getTeamManager
().
getCurrentAvatarEntity
();
}
/**
* Gets the currently selected avatar.
* @return The avatar as an {@link GenshinAvatar}.
*/
public
GenshinAvatar
getCurrentAvatar
()
{
return
this
.
getCurrentAvatarEntity
().
getAvatar
();
}
}
\ No newline at end of file
src/main/java/emu/grasscutter/plugin/api/README.md
0 → 100644
View file @
b9f7c657
# Grasscutter Plugin API
**Warning!**
As of now, this is a work in progress and isn't completely documented.
\ No newline at end of file
src/main/java/emu/grasscutter/plugin/api/ServerHook.java
0 → 100644
View file @
b9f7c657
package
emu.grasscutter.plugin.api
;
import
emu.grasscutter.game.GenshinPlayer
;
import
emu.grasscutter.server.game.GameServer
;
import
java.util.LinkedList
;
import
java.util.List
;
/**
* Hooks into the {@link GameServer} class, adding convenient ways to do certain things.
*/
public
final
class
ServerHook
{
private
static
ServerHook
instance
;
private
final
GameServer
server
;
/**
* Gets the server hook instance.
* @return A {@link ServerHook} singleton.
*/
public
static
ServerHook
getInstance
()
{
return
instance
;
}
/**
* Hooks into a server.
* @param server The server to hook into.
*/
public
ServerHook
(
GameServer
server
)
{
this
.
server
=
server
;
instance
=
this
;
}
/**
* Gets all online players.
* @return Players connected to the server.
*/
public
List
<
GenshinPlayer
>
getOnlinePlayers
()
{
return
new
LinkedList
<>(
this
.
server
.
getPlayers
().
values
());
}
}
\ No newline at end of file
Prev
1
2
3
4
5
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