Skip to content

Commit

Permalink
Fix home nulls (#2355)
Browse files Browse the repository at this point in the history
* Add null checking

* Sanity check for moduleManager
  • Loading branch information
NotThorny authored Sep 12, 2023
1 parent 8de281d commit 5fd31ae
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/java/emu/grasscutter/game/home/HomeModuleManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,20 @@ public HomeModuleManager(HomeWorld homeWorld) {
}

public void tick() {
if (this.moduleId == 0) {
return;
}

this.outdoor.onTick();
this.indoor.onTick();
this.summonEvents.removeIf(HomeAvatarSummonEvent::isTimeOver);
}

public void refreshMainHouse() {
if (this.moduleId == 0) {
return;
}

this.indoor = this.homeWorld.getSceneById(this.homeWorld.getActiveIndoorSceneId());
}

Expand All @@ -67,6 +75,7 @@ private void fireAllAvatarRewardEvent() {
var suites =
allBlockItems.stream()
.map(HomeBlockItem::getSuiteList)
.filter(Objects::nonNull)
.flatMap(Collection::stream)
.distinct()
.toList();
Expand Down Expand Up @@ -210,6 +219,10 @@ public HomeSceneItem getIndoorSceneItem() {
}

public void onSetModule() {
if (this.moduleId == 0) {
return;
}

this.outdoor.addEntities(this.getOutdoorSceneItem().getAnimals(this.outdoor));
this.indoor.addEntities(this.getIndoorSceneItem().getAnimals(this.indoor));
this.fireAllAvatarRewardEvent();
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/emu/grasscutter/game/home/HomeWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public HomeWorld(GameServer server, Player owner) {

@Override
public boolean onTick() {
if (this.moduleManager == null) {
return false;
}
this.moduleManager.tick();

if (this.getTickCount() % 10 == 0) {
Expand Down

0 comments on commit 5fd31ae

Please sign in to comment.