mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-25 07:22:56 +08:00
Fix NPEs when player leaves world
This commit is contained in:
parent
02653620d4
commit
5f4f220eab
@ -127,18 +127,18 @@ public class QuestManager extends BasePlayerManager {
|
|||||||
this.player.getActivityManager().triggerActivityConditions();
|
this.player.getActivityManager().triggerActivityConditions();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onTick(){
|
public void onTick() {
|
||||||
checkTimeVars();
|
var world = this.getPlayer().getWorld();
|
||||||
|
if (world == null) return;
|
||||||
|
|
||||||
|
checkTimeVars();
|
||||||
// trigger game time tick for quests
|
// trigger game time tick for quests
|
||||||
queueEvent(QuestContent.QUEST_CONTENT_GAME_TIME_TICK,
|
queueEvent(QuestContent.QUEST_CONTENT_GAME_TIME_TICK,
|
||||||
player.getWorld().getGameTimeHours() , // hours
|
world.getGameTimeHours() , // hours
|
||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkTimeVars() {
|
private void checkTimeVars() {
|
||||||
if (this.player.getWorld() == null) return;
|
|
||||||
|
|
||||||
val currentDays = player.getWorld().getTotalGameTimeDays();
|
val currentDays = player.getWorld().getTotalGameTimeDays();
|
||||||
val currentHours = player.getWorld().getTotalGameTimeHours();
|
val currentHours = player.getWorld().getTotalGameTimeHours();
|
||||||
boolean checkDays = currentDays != lastDayCheck;
|
boolean checkDays = currentDays != lastDayCheck;
|
||||||
@ -385,7 +385,7 @@ public class QuestManager extends BasePlayerManager {
|
|||||||
*/
|
*/
|
||||||
public void checkQuestAlreadyFullfilled(GameQuest quest){
|
public void checkQuestAlreadyFullfilled(GameQuest quest){
|
||||||
Grasscutter.getGameServer().getScheduler().scheduleDelayedTask(() -> {
|
Grasscutter.getGameServer().getScheduler().scheduleDelayedTask(() -> {
|
||||||
for(var condition : quest.getQuestData().getFinishCond()){
|
for (var condition : quest.getQuestData().getFinishCond()){
|
||||||
switch (condition.getType()) {
|
switch (condition.getType()) {
|
||||||
case QUEST_CONTENT_OBTAIN_ITEM, QUEST_CONTENT_ITEM_LESS_THAN -> {
|
case QUEST_CONTENT_OBTAIN_ITEM, QUEST_CONTENT_ITEM_LESS_THAN -> {
|
||||||
//check if we already own enough of the item
|
//check if we already own enough of the item
|
||||||
|
Loading…
Reference in New Issue
Block a user