Daily Mission changes.

Contributed by kamikadzz.
This commit is contained in:
MobiusDevelopment
2022-10-08 22:49:25 +00:00
parent 18718b4148
commit 6201cf9303
170 changed files with 3483 additions and 2329 deletions

View File

@@ -0,0 +1,28 @@
/*
* This file is part of the L2J Mobius project.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.l2jmobius.gameserver.enums;
/**
* @author kamikadzz
*/
public enum MissionResetType
{
DAY,
WEEK,
MONTH,
WEEKEND
}

View File

@@ -16,11 +16,13 @@
*/
package org.l2jmobius.gameserver.model;
import java.util.Calendar;
import java.util.List;
import java.util.function.Function;
import org.l2jmobius.gameserver.enums.ClassId;
import org.l2jmobius.gameserver.enums.DailyMissionStatus;
import org.l2jmobius.gameserver.enums.MissionResetType;
import org.l2jmobius.gameserver.handler.AbstractDailyMissionHandler;
import org.l2jmobius.gameserver.handler.DailyMissionHandler;
import org.l2jmobius.gameserver.model.actor.Player;
@@ -42,6 +44,7 @@ public class DailyMissionDataHolder
private final boolean _isDualClassOnly;
private final boolean _isDisplayedWhenNotAvailable;
private final AbstractDailyMissionHandler _handler;
private final MissionResetType _missionResetSlot;
public DailyMissionDataHolder(StatSet set)
{
@@ -57,6 +60,7 @@ public class DailyMissionDataHolder
_isDualClassOnly = set.getBoolean("isDualClassOnly", false);
_isDisplayedWhenNotAvailable = set.getBoolean("isDisplayedWhenNotAvailable", true);
_handler = handler != null ? handler.apply(this) : null;
_missionResetSlot = set.getObject("duration", MissionResetType.class, MissionResetType.DAY);
}
public int getId()
@@ -171,7 +175,22 @@ public class DailyMissionDataHolder
{
if (_handler != null)
{
_handler.reset();
if ((_missionResetSlot == MissionResetType.WEEK) && (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY))
{
_handler.reset();
}
else if ((_missionResetSlot == MissionResetType.MONTH) && (Calendar.getInstance().get(Calendar.DAY_OF_MONTH) == 1))
{
_handler.reset();
}
else if ((_missionResetSlot == MissionResetType.WEEKEND) && (Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY))
{
_handler.reset();
}
else if (_dailyReset)
{
_handler.reset();
}
}
}
}