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
dd8d1752
Commit
dd8d1752
authored
Apr 18, 2022
by
Melledy
Browse files
Deregister empty scenes if a player leaves them
parent
c65443f4
Changes
2
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/GenshinScene.java
View file @
dd8d1752
...
@@ -117,6 +117,7 @@ public class GenshinScene {
...
@@ -117,6 +117,7 @@ public class GenshinScene {
}
}
public
void
removePlayer
(
GenshinPlayer
player
)
{
public
void
removePlayer
(
GenshinPlayer
player
)
{
// Remove player from scene
getPlayers
().
remove
(
player
);
getPlayers
().
remove
(
player
);
player
.
setScene
(
null
);
player
.
setScene
(
null
);
...
@@ -127,6 +128,11 @@ public class GenshinScene {
...
@@ -127,6 +128,11 @@ public class GenshinScene {
for
(
EntityGadget
gadget
:
player
.
getTeamManager
().
getGadgets
())
{
for
(
EntityGadget
gadget
:
player
.
getTeamManager
().
getGadgets
())
{
this
.
removeEntity
(
gadget
);
this
.
removeEntity
(
gadget
);
}
}
// Deregister scene if not in use
if
(
this
.
getEntities
().
size
()
<=
0
)
{
this
.
getWorld
().
deregisterScene
(
this
);
}
}
}
private
void
setupPlayerAvatars
(
GenshinPlayer
player
)
{
private
void
setupPlayerAvatars
(
GenshinPlayer
player
)
{
...
...
src/main/java/emu/grasscutter/game/World.java
View file @
dd8d1752
...
@@ -111,7 +111,7 @@ public class World implements Iterable<GenshinPlayer> {
...
@@ -111,7 +111,7 @@ public class World implements Iterable<GenshinPlayer> {
SceneData
sceneData
=
GenshinData
.
getSceneDataMap
().
get
(
sceneId
);
SceneData
sceneData
=
GenshinData
.
getSceneDataMap
().
get
(
sceneId
);
if
(
sceneData
!=
null
)
{
if
(
sceneData
!=
null
)
{
scene
=
new
GenshinScene
(
this
,
sceneData
);
scene
=
new
GenshinScene
(
this
,
sceneData
);
this
.
getScenes
().
put
(
sceneId
,
scene
);
this
.
registerScene
(
scene
);
return
scene
;
return
scene
;
}
}
...
@@ -198,6 +198,14 @@ public class World implements Iterable<GenshinPlayer> {
...
@@ -198,6 +198,14 @@ public class World implements Iterable<GenshinPlayer> {
}
}
}
}
public
void
registerScene
(
GenshinScene
scene
)
{
this
.
getScenes
().
put
(
scene
.
getId
(),
scene
);
}
public
void
deregisterScene
(
GenshinScene
scene
)
{
this
.
getScenes
().
remove
(
scene
.
getId
());
}
public
boolean
transferPlayerToScene
(
GenshinPlayer
player
,
int
sceneId
,
Position
pos
)
{
public
boolean
transferPlayerToScene
(
GenshinPlayer
player
,
int
sceneId
,
Position
pos
)
{
if
(
player
.
getScene
().
getId
()
==
sceneId
||
GenshinData
.
getSceneDataMap
().
get
(
sceneId
)
==
null
)
{
if
(
player
.
getScene
().
getId
()
==
sceneId
||
GenshinData
.
getSceneDataMap
().
get
(
sceneId
)
==
null
)
{
return
false
;
return
false
;
...
...
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