Fix home nulls (#2355)

* Add null checking

* Sanity check for moduleManager
This commit is contained in:
Thoronium 2023-09-11 23:07:17 -06:00 committed by GitHub
parent 8de281d4da
commit 5fd31aece8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View File

@ -41,12 +41,20 @@ public class HomeModuleManager {
} }
public void tick() { public void tick() {
if (this.moduleId == 0) {
return;
}
this.outdoor.onTick(); this.outdoor.onTick();
this.indoor.onTick(); this.indoor.onTick();
this.summonEvents.removeIf(HomeAvatarSummonEvent::isTimeOver); this.summonEvents.removeIf(HomeAvatarSummonEvent::isTimeOver);
} }
public void refreshMainHouse() { public void refreshMainHouse() {
if (this.moduleId == 0) {
return;
}
this.indoor = this.homeWorld.getSceneById(this.homeWorld.getActiveIndoorSceneId()); this.indoor = this.homeWorld.getSceneById(this.homeWorld.getActiveIndoorSceneId());
} }
@ -67,6 +75,7 @@ public class HomeModuleManager {
var suites = var suites =
allBlockItems.stream() allBlockItems.stream()
.map(HomeBlockItem::getSuiteList) .map(HomeBlockItem::getSuiteList)
.filter(Objects::nonNull)
.flatMap(Collection::stream) .flatMap(Collection::stream)
.distinct() .distinct()
.toList(); .toList();
@ -210,6 +219,10 @@ public class HomeModuleManager {
} }
public void onSetModule() { public void onSetModule() {
if (this.moduleId == 0) {
return;
}
this.outdoor.addEntities(this.getOutdoorSceneItem().getAnimals(this.outdoor)); this.outdoor.addEntities(this.getOutdoorSceneItem().getAnimals(this.outdoor));
this.indoor.addEntities(this.getIndoorSceneItem().getAnimals(this.indoor)); this.indoor.addEntities(this.getIndoorSceneItem().getAnimals(this.indoor));
this.fireAllAvatarRewardEvent(); this.fireAllAvatarRewardEvent();

View File

@ -29,6 +29,9 @@ public class HomeWorld extends World {
@Override @Override
public boolean onTick() { public boolean onTick() {
if (this.moduleManager == null) {
return false;
}
this.moduleManager.tick(); this.moduleManager.tick();
if (this.getTickCount() % 10 == 0) { if (this.getTickCount() % 10 == 0) {