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

@ -2628,14 +2628,14 @@
<item id="35987" count="10" />
</items>
</reward>
<reward id="224" reward_id="604" name="Login All Weekend" isOneTime="false">
<reward id="224" reward_id="604" name="Login All Weekend" requiredCompletion="1" isOneTime="false" duration="WEEKEND">
<handler name="loginweekend" />
<items>
<item id="27593" count="4" />
<item id="27603" count="1" />
</items>
</reward>
<reward id="225" reward_id="605" name="Login All Month" isOneTime="false">
<reward id="225" reward_id="605" name="Login All Month" requiredCompletion="1" isOneTime="false" duration="MONTH">
<handler name="loginmonth" />
<items>
<item id="27593" count="15" />

View File

@ -23,6 +23,7 @@ import org.l2jmobius.gameserver.handler.DailyMissionHandler;
import handlers.dailymissionhandlers.BossDailyMissionHandler;
import handlers.dailymissionhandlers.CeremonyOfChaosDailyMissionHandler;
import handlers.dailymissionhandlers.FishingDailyMissionHandler;
import handlers.dailymissionhandlers.JoinClanDailyMissionHandler;
import handlers.dailymissionhandlers.LevelDailyMissionHandler;
import handlers.dailymissionhandlers.LoginMonthDailyMissionHandler;
import handlers.dailymissionhandlers.LoginWeekendDailyMissionHandler;
@ -48,6 +49,7 @@ public class DailyMissionMasterHandler
DailyMissionHandler.getInstance().registerHandler("ceremonyofchaos", CeremonyOfChaosDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("boss", BossDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("fishing", FishingDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("joinclan", JoinClanDailyMissionHandler::new);
LOGGER.info(DailyMissionMasterHandler.class.getSimpleName() + ": Loaded " + DailyMissionHandler.getInstance().size() + " handlers.");
}
}

View File

@ -0,0 +1,81 @@
/*
* 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 handlers.dailymissionhandlers;
import java.util.function.Consumer;
import org.l2jmobius.gameserver.enums.DailyMissionStatus;
import org.l2jmobius.gameserver.handler.AbstractDailyMissionHandler;
import org.l2jmobius.gameserver.model.DailyMissionDataHolder;
import org.l2jmobius.gameserver.model.DailyMissionPlayerEntry;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.events.Containers;
import org.l2jmobius.gameserver.model.events.EventType;
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanCreate;
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanJoin;
import org.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener;
/**
* @author kamikadzz
*/
public class JoinClanDailyMissionHandler extends AbstractDailyMissionHandler
{
public JoinClanDailyMissionHandler(DailyMissionDataHolder holder)
{
super(holder);
}
@Override
public boolean isAvailable(Player player)
{
final DailyMissionPlayerEntry entry = getPlayerEntry(player.getObjectId(), false);
return (entry != null) && (entry.getStatus() == DailyMissionStatus.AVAILABLE);
}
@Override
public void init()
{
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_CLAN_JOIN, (Consumer<OnPlayerClanJoin>) this::onPlayerClanJoin, this));
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_CLAN_CREATE, (Consumer<OnPlayerClanCreate>) this::onPlayerClanCreate, this));
}
private void onPlayerClanJoin(OnPlayerClanJoin event)
{
final DailyMissionPlayerEntry missionData = getPlayerEntry(event.getClanMember().getPlayer().getObjectId(), true);
processMission(missionData);
}
private void onPlayerClanCreate(OnPlayerClanCreate event)
{
final DailyMissionPlayerEntry missionData = getPlayerEntry(event.getPlayer().getObjectId(), true);
processMission(missionData);
}
private void processMission(DailyMissionPlayerEntry missionData)
{
if (missionData.getProgress() == 1)
{
missionData.setStatus(DailyMissionStatus.COMPLETED);
}
else
{
missionData.setProgress(1);
missionData.setStatus(DailyMissionStatus.AVAILABLE);
}
storePlayerEntry(missionData);
}
}

View File

@ -49,30 +49,14 @@ public class LoginMonthDailyMissionHandler extends AbstractDailyMissionHandler
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_LOGIN, (OnPlayerLogin event) -> onPlayerLogin(event), this));
}
@Override
public void reset()
{
// Monthly rewards do not reset daily.
}
private void onPlayerLogin(OnPlayerLogin event)
{
final DailyMissionPlayerEntry entry = getPlayerEntry(event.getPlayer().getObjectId(), true);
final long lastCompleted = entry.getLastCompleted();
if (lastCompleted == 0) // Initial entry.
{
entry.setLastCompleted(System.currentTimeMillis());
}
else if ((System.currentTimeMillis() - lastCompleted) > 2506000000L) // 2506000000L (29 day) delay.
if (entry.getStatus() != DailyMissionStatus.COMPLETED)
{
entry.setProgress(1);
entry.setStatus(DailyMissionStatus.AVAILABLE);
}
else
{
entry.setProgress(0);
entry.setStatus(DailyMissionStatus.NOT_AVAILABLE);
}
storePlayerEntry(entry);
}
}

View File

@ -51,27 +51,18 @@ public class LoginWeekendDailyMissionHandler extends AbstractDailyMissionHandler
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_LOGIN, (OnPlayerLogin event) -> onPlayerLogin(event), this));
}
@Override
public void reset()
{
// Weekend rewards do not reset daily.
}
private void onPlayerLogin(OnPlayerLogin event)
{
final DailyMissionPlayerEntry entry = getPlayerEntry(event.getPlayer().getObjectId(), true);
final int currentDay = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
final long lastCompleted = entry.getLastCompleted();
if (((currentDay == Calendar.SATURDAY) || (currentDay == Calendar.SUNDAY)) // Reward only on weekend.
&& ((lastCompleted == 0) || ((System.currentTimeMillis() - lastCompleted) > 172800000))) // Initial entry or 172800000 (2 day) delay.
if (entry.getStatus() != DailyMissionStatus.COMPLETED)
{
entry.setProgress(1);
entry.setStatus(DailyMissionStatus.AVAILABLE);
}
else if (entry.getStatus() != DailyMissionStatus.AVAILABLE) // Not waiting to be rewarded.
{
entry.setProgress(0);
entry.setStatus(DailyMissionStatus.NOT_AVAILABLE);
final int currentDay = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
if (((currentDay == Calendar.SATURDAY) || (currentDay == Calendar.SUNDAY) || (currentDay == Calendar.MONDAY)) //
&& (Calendar.getInstance().get(Calendar.HOUR_OF_DAY) < 6) && (Calendar.getInstance().get(Calendar.MINUTE) < 30))
{
entry.setProgress(1);
entry.setStatus(DailyMissionStatus.AVAILABLE);
}
}
storePlayerEntry(entry);
}

View File

@ -39,6 +39,7 @@
<xs:attribute type="xs:int" name="requiredCompletion" />
<xs:attribute type="xs:boolean" name="dailyReset" />
<xs:attribute type="xs:boolean" name="isOneTime" />
<xs:attribute type="xs:string" name="duration" />
</xs:complexType>
<xs:complexType name="listType">
<xs:sequence>

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;
@ -39,6 +41,7 @@ public class DailyMissionDataHolder
private final boolean _dailyReset;
private final boolean _isOneTime;
private final AbstractDailyMissionHandler _handler;
private final MissionResetType _missionResetSlot;
public DailyMissionDataHolder(StatSet set)
{
@ -51,6 +54,7 @@ public class DailyMissionDataHolder
_dailyReset = set.getBoolean("dailyReset", true);
_isOneTime = set.getBoolean("isOneTime", true);
_handler = handler != null ? handler.apply(this) : null;
_missionResetSlot = set.getObject("duration", MissionResetType.class, MissionResetType.DAY);
}
public int getId()
@ -115,7 +119,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();
}
}
}
}

View File

@ -2613,14 +2613,14 @@
<item id="35987" count="10" />
</items>
</reward>
<reward id="224" reward_id="604" name="Login All Weekend" isOneTime="false">
<reward id="224" reward_id="604" name="Login All Weekend" requiredCompletion="1" isOneTime="false" duration="WEEKEND">
<handler name="loginweekend" />
<items>
<item id="27593" count="4" />
<item id="27603" count="1" />
</items>
</reward>
<reward id="225" reward_id="605" name="Login All Month" isOneTime="false">
<reward id="225" reward_id="605" name="Login All Month" requiredCompletion="1" isOneTime="false" duration="MONTH">
<handler name="loginmonth" />
<items>
<item id="27593" count="15" />

View File

@ -23,6 +23,7 @@ import org.l2jmobius.gameserver.handler.DailyMissionHandler;
import handlers.dailymissionhandlers.BossDailyMissionHandler;
import handlers.dailymissionhandlers.CeremonyOfChaosDailyMissionHandler;
import handlers.dailymissionhandlers.FishingDailyMissionHandler;
import handlers.dailymissionhandlers.JoinClanDailyMissionHandler;
import handlers.dailymissionhandlers.LevelDailyMissionHandler;
import handlers.dailymissionhandlers.LoginMonthDailyMissionHandler;
import handlers.dailymissionhandlers.LoginWeekendDailyMissionHandler;
@ -48,6 +49,7 @@ public class DailyMissionMasterHandler
DailyMissionHandler.getInstance().registerHandler("ceremonyofchaos", CeremonyOfChaosDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("boss", BossDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("fishing", FishingDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("joinclan", JoinClanDailyMissionHandler::new);
LOGGER.info(DailyMissionMasterHandler.class.getSimpleName() + ": Loaded " + DailyMissionHandler.getInstance().size() + " handlers.");
}
}

View File

@ -0,0 +1,81 @@
/*
* 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 handlers.dailymissionhandlers;
import java.util.function.Consumer;
import org.l2jmobius.gameserver.enums.DailyMissionStatus;
import org.l2jmobius.gameserver.handler.AbstractDailyMissionHandler;
import org.l2jmobius.gameserver.model.DailyMissionDataHolder;
import org.l2jmobius.gameserver.model.DailyMissionPlayerEntry;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.events.Containers;
import org.l2jmobius.gameserver.model.events.EventType;
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanCreate;
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanJoin;
import org.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener;
/**
* @author kamikadzz
*/
public class JoinClanDailyMissionHandler extends AbstractDailyMissionHandler
{
public JoinClanDailyMissionHandler(DailyMissionDataHolder holder)
{
super(holder);
}
@Override
public boolean isAvailable(Player player)
{
final DailyMissionPlayerEntry entry = getPlayerEntry(player.getObjectId(), false);
return (entry != null) && (entry.getStatus() == DailyMissionStatus.AVAILABLE);
}
@Override
public void init()
{
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_CLAN_JOIN, (Consumer<OnPlayerClanJoin>) this::onPlayerClanJoin, this));
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_CLAN_CREATE, (Consumer<OnPlayerClanCreate>) this::onPlayerClanCreate, this));
}
private void onPlayerClanJoin(OnPlayerClanJoin event)
{
final DailyMissionPlayerEntry missionData = getPlayerEntry(event.getClanMember().getPlayer().getObjectId(), true);
processMission(missionData);
}
private void onPlayerClanCreate(OnPlayerClanCreate event)
{
final DailyMissionPlayerEntry missionData = getPlayerEntry(event.getPlayer().getObjectId(), true);
processMission(missionData);
}
private void processMission(DailyMissionPlayerEntry missionData)
{
if (missionData.getProgress() == 1)
{
missionData.setStatus(DailyMissionStatus.COMPLETED);
}
else
{
missionData.setProgress(1);
missionData.setStatus(DailyMissionStatus.AVAILABLE);
}
storePlayerEntry(missionData);
}
}

View File

@ -49,30 +49,14 @@ public class LoginMonthDailyMissionHandler extends AbstractDailyMissionHandler
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_LOGIN, (OnPlayerLogin event) -> onPlayerLogin(event), this));
}
@Override
public void reset()
{
// Monthly rewards do not reset daily.
}
private void onPlayerLogin(OnPlayerLogin event)
{
final DailyMissionPlayerEntry entry = getPlayerEntry(event.getPlayer().getObjectId(), true);
final long lastCompleted = entry.getLastCompleted();
if (lastCompleted == 0) // Initial entry.
{
entry.setLastCompleted(System.currentTimeMillis());
}
else if ((System.currentTimeMillis() - lastCompleted) > 2506000000L) // 2506000000L (29 day) delay.
if (entry.getStatus() != DailyMissionStatus.COMPLETED)
{
entry.setProgress(1);
entry.setStatus(DailyMissionStatus.AVAILABLE);
}
else
{
entry.setProgress(0);
entry.setStatus(DailyMissionStatus.NOT_AVAILABLE);
}
storePlayerEntry(entry);
}
}

View File

@ -51,27 +51,18 @@ public class LoginWeekendDailyMissionHandler extends AbstractDailyMissionHandler
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_LOGIN, (OnPlayerLogin event) -> onPlayerLogin(event), this));
}
@Override
public void reset()
{
// Weekend rewards do not reset daily.
}
private void onPlayerLogin(OnPlayerLogin event)
{
final DailyMissionPlayerEntry entry = getPlayerEntry(event.getPlayer().getObjectId(), true);
final int currentDay = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
final long lastCompleted = entry.getLastCompleted();
if (((currentDay == Calendar.SATURDAY) || (currentDay == Calendar.SUNDAY)) // Reward only on weekend.
&& ((lastCompleted == 0) || ((System.currentTimeMillis() - lastCompleted) > 172800000))) // Initial entry or 172800000 (2 day) delay.
if (entry.getStatus() != DailyMissionStatus.COMPLETED)
{
entry.setProgress(1);
entry.setStatus(DailyMissionStatus.AVAILABLE);
}
else if (entry.getStatus() != DailyMissionStatus.AVAILABLE) // Not waiting to be rewarded.
{
entry.setProgress(0);
entry.setStatus(DailyMissionStatus.NOT_AVAILABLE);
final int currentDay = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
if (((currentDay == Calendar.SATURDAY) || (currentDay == Calendar.SUNDAY) || (currentDay == Calendar.MONDAY)) //
&& (Calendar.getInstance().get(Calendar.HOUR_OF_DAY) < 6) && (Calendar.getInstance().get(Calendar.MINUTE) < 30))
{
entry.setProgress(1);
entry.setStatus(DailyMissionStatus.AVAILABLE);
}
}
storePlayerEntry(entry);
}

View File

@ -39,6 +39,7 @@
<xs:attribute type="xs:int" name="requiredCompletion" />
<xs:attribute type="xs:boolean" name="dailyReset" />
<xs:attribute type="xs:boolean" name="isOneTime" />
<xs:attribute type="xs:string" name="duration" />
</xs:complexType>
<xs:complexType name="listType">
<xs:sequence>

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;
@ -39,6 +41,7 @@ public class DailyMissionDataHolder
private final boolean _dailyReset;
private final boolean _isOneTime;
private final AbstractDailyMissionHandler _handler;
private final MissionResetType _missionResetSlot;
public DailyMissionDataHolder(StatSet set)
{
@ -51,6 +54,7 @@ public class DailyMissionDataHolder
_dailyReset = set.getBoolean("dailyReset", true);
_isOneTime = set.getBoolean("isOneTime", true);
_handler = handler != null ? handler.apply(this) : null;
_missionResetSlot = set.getObject("duration", MissionResetType.class, MissionResetType.DAY);
}
public int getId()
@ -115,7 +119,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();
}
}
}
}

View File

@ -2612,14 +2612,14 @@
<item id="35987" count="10" />
</items>
</reward>
<reward id="224" reward_id="604" name="Login Once During the Weekend" requiredCompletion="1" isMainClassOnly="false" isOneTime="false">
<reward id="224" reward_id="604" name="Login Once During the Weekend" isMainClassOnly="false" requiredCompletion="1" isOneTime="false" duration="WEEKEND">
<handler name="loginweekend" />
<items>
<item id="27593" count="4" />
<item id="27603" count="1" />
</items>
</reward>
<reward id="225" reward_id="605" name="Login Once During the Month" requiredCompletion="1" isMainClassOnly="false" isOneTime="false">
<reward id="225" reward_id="605" name="Login Once During the Month" isMainClassOnly="false" requiredCompletion="1" isOneTime="false" duration="MONTH">
<handler name="loginmonth" />
<items>
<item id="27593" count="15" />

View File

@ -23,6 +23,7 @@ import org.l2jmobius.gameserver.handler.DailyMissionHandler;
import handlers.dailymissionhandlers.BossDailyMissionHandler;
import handlers.dailymissionhandlers.CeremonyOfChaosDailyMissionHandler;
import handlers.dailymissionhandlers.FishingDailyMissionHandler;
import handlers.dailymissionhandlers.JoinClanDailyMissionHandler;
import handlers.dailymissionhandlers.LevelDailyMissionHandler;
import handlers.dailymissionhandlers.LoginMonthDailyMissionHandler;
import handlers.dailymissionhandlers.LoginWeekendDailyMissionHandler;
@ -48,6 +49,7 @@ public class DailyMissionMasterHandler
DailyMissionHandler.getInstance().registerHandler("ceremonyofchaos", CeremonyOfChaosDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("boss", BossDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("fishing", FishingDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("joinclan", JoinClanDailyMissionHandler::new);
LOGGER.info(DailyMissionMasterHandler.class.getSimpleName() + ": Loaded " + DailyMissionHandler.getInstance().size() + " handlers.");
}
}

View File

@ -0,0 +1,81 @@
/*
* 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 handlers.dailymissionhandlers;
import java.util.function.Consumer;
import org.l2jmobius.gameserver.enums.DailyMissionStatus;
import org.l2jmobius.gameserver.handler.AbstractDailyMissionHandler;
import org.l2jmobius.gameserver.model.DailyMissionDataHolder;
import org.l2jmobius.gameserver.model.DailyMissionPlayerEntry;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.events.Containers;
import org.l2jmobius.gameserver.model.events.EventType;
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanCreate;
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanJoin;
import org.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener;
/**
* @author kamikadzz
*/
public class JoinClanDailyMissionHandler extends AbstractDailyMissionHandler
{
public JoinClanDailyMissionHandler(DailyMissionDataHolder holder)
{
super(holder);
}
@Override
public boolean isAvailable(Player player)
{
final DailyMissionPlayerEntry entry = getPlayerEntry(player.getObjectId(), false);
return (entry != null) && (entry.getStatus() == DailyMissionStatus.AVAILABLE);
}
@Override
public void init()
{
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_CLAN_JOIN, (Consumer<OnPlayerClanJoin>) this::onPlayerClanJoin, this));
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_CLAN_CREATE, (Consumer<OnPlayerClanCreate>) this::onPlayerClanCreate, this));
}
private void onPlayerClanJoin(OnPlayerClanJoin event)
{
final DailyMissionPlayerEntry missionData = getPlayerEntry(event.getClanMember().getPlayer().getObjectId(), true);
processMission(missionData);
}
private void onPlayerClanCreate(OnPlayerClanCreate event)
{
final DailyMissionPlayerEntry missionData = getPlayerEntry(event.getPlayer().getObjectId(), true);
processMission(missionData);
}
private void processMission(DailyMissionPlayerEntry missionData)
{
if (missionData.getProgress() == 1)
{
missionData.setStatus(DailyMissionStatus.COMPLETED);
}
else
{
missionData.setProgress(1);
missionData.setStatus(DailyMissionStatus.AVAILABLE);
}
storePlayerEntry(missionData);
}
}

View File

@ -49,30 +49,14 @@ public class LoginMonthDailyMissionHandler extends AbstractDailyMissionHandler
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_LOGIN, (OnPlayerLogin event) -> onPlayerLogin(event), this));
}
@Override
public void reset()
{
// Monthly rewards do not reset daily.
}
private void onPlayerLogin(OnPlayerLogin event)
{
final DailyMissionPlayerEntry entry = getPlayerEntry(event.getPlayer().getObjectId(), true);
final long lastCompleted = entry.getLastCompleted();
if (lastCompleted == 0) // Initial entry.
{
entry.setLastCompleted(System.currentTimeMillis());
}
else if ((System.currentTimeMillis() - lastCompleted) > 2506000000L) // 2506000000L (29 day) delay.
if (entry.getStatus() != DailyMissionStatus.COMPLETED)
{
entry.setProgress(1);
entry.setStatus(DailyMissionStatus.AVAILABLE);
}
else
{
entry.setProgress(0);
entry.setStatus(DailyMissionStatus.NOT_AVAILABLE);
}
storePlayerEntry(entry);
}
}

View File

@ -51,27 +51,18 @@ public class LoginWeekendDailyMissionHandler extends AbstractDailyMissionHandler
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_LOGIN, (OnPlayerLogin event) -> onPlayerLogin(event), this));
}
@Override
public void reset()
{
// Weekend rewards do not reset daily.
}
private void onPlayerLogin(OnPlayerLogin event)
{
final DailyMissionPlayerEntry entry = getPlayerEntry(event.getPlayer().getObjectId(), true);
final int currentDay = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
final long lastCompleted = entry.getLastCompleted();
if (((currentDay == Calendar.SATURDAY) || (currentDay == Calendar.SUNDAY)) // Reward only on weekend.
&& ((lastCompleted == 0) || ((System.currentTimeMillis() - lastCompleted) > 172800000))) // Initial entry or 172800000 (2 day) delay.
if (entry.getStatus() != DailyMissionStatus.COMPLETED)
{
entry.setProgress(1);
entry.setStatus(DailyMissionStatus.AVAILABLE);
}
else if (entry.getStatus() != DailyMissionStatus.AVAILABLE) // Not waiting to be rewarded.
{
entry.setProgress(0);
entry.setStatus(DailyMissionStatus.NOT_AVAILABLE);
final int currentDay = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
if (((currentDay == Calendar.SATURDAY) || (currentDay == Calendar.SUNDAY) || (currentDay == Calendar.MONDAY)) //
&& (Calendar.getInstance().get(Calendar.HOUR_OF_DAY) < 6) && (Calendar.getInstance().get(Calendar.MINUTE) < 30))
{
entry.setProgress(1);
entry.setStatus(DailyMissionStatus.AVAILABLE);
}
}
storePlayerEntry(entry);
}

View File

@ -42,6 +42,7 @@
<xs:attribute type="xs:boolean" name="isMainClassOnly" />
<xs:attribute type="xs:boolean" name="isDualClassOnly" />
<xs:attribute type="xs:boolean" name="isDisplayedWhenNotAvailable" />
<xs:attribute type="xs:string" name="duration" />
</xs:complexType>
<xs:complexType name="listType">
<xs:sequence>

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()
@ -166,7 +170,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();
}
}
}
}

View File

@ -23,6 +23,7 @@ import org.l2jmobius.gameserver.handler.DailyMissionHandler;
import handlers.dailymissionhandlers.BossDailyMissionHandler;
import handlers.dailymissionhandlers.CeremonyOfChaosDailyMissionHandler;
import handlers.dailymissionhandlers.FishingDailyMissionHandler;
import handlers.dailymissionhandlers.JoinClanDailyMissionHandler;
import handlers.dailymissionhandlers.LevelDailyMissionHandler;
import handlers.dailymissionhandlers.LoginMonthDailyMissionHandler;
import handlers.dailymissionhandlers.LoginWeekendDailyMissionHandler;
@ -48,6 +49,7 @@ public class DailyMissionMasterHandler
DailyMissionHandler.getInstance().registerHandler("ceremonyofchaos", CeremonyOfChaosDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("boss", BossDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("fishing", FishingDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("joinclan", JoinClanDailyMissionHandler::new);
LOGGER.info(DailyMissionMasterHandler.class.getSimpleName() + ": Loaded " + DailyMissionHandler.getInstance().size() + " handlers.");
}
}

View File

@ -0,0 +1,81 @@
/*
* 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 handlers.dailymissionhandlers;
import java.util.function.Consumer;
import org.l2jmobius.gameserver.enums.DailyMissionStatus;
import org.l2jmobius.gameserver.handler.AbstractDailyMissionHandler;
import org.l2jmobius.gameserver.model.DailyMissionDataHolder;
import org.l2jmobius.gameserver.model.DailyMissionPlayerEntry;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.events.Containers;
import org.l2jmobius.gameserver.model.events.EventType;
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanCreate;
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanJoin;
import org.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener;
/**
* @author kamikadzz
*/
public class JoinClanDailyMissionHandler extends AbstractDailyMissionHandler
{
public JoinClanDailyMissionHandler(DailyMissionDataHolder holder)
{
super(holder);
}
@Override
public boolean isAvailable(Player player)
{
final DailyMissionPlayerEntry entry = getPlayerEntry(player.getObjectId(), false);
return (entry != null) && (entry.getStatus() == DailyMissionStatus.AVAILABLE);
}
@Override
public void init()
{
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_CLAN_JOIN, (Consumer<OnPlayerClanJoin>) this::onPlayerClanJoin, this));
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_CLAN_CREATE, (Consumer<OnPlayerClanCreate>) this::onPlayerClanCreate, this));
}
private void onPlayerClanJoin(OnPlayerClanJoin event)
{
final DailyMissionPlayerEntry missionData = getPlayerEntry(event.getClanMember().getPlayer().getObjectId(), true);
processMission(missionData);
}
private void onPlayerClanCreate(OnPlayerClanCreate event)
{
final DailyMissionPlayerEntry missionData = getPlayerEntry(event.getPlayer().getObjectId(), true);
processMission(missionData);
}
private void processMission(DailyMissionPlayerEntry missionData)
{
if (missionData.getProgress() == 1)
{
missionData.setStatus(DailyMissionStatus.COMPLETED);
}
else
{
missionData.setProgress(1);
missionData.setStatus(DailyMissionStatus.AVAILABLE);
}
storePlayerEntry(missionData);
}
}

View File

@ -49,30 +49,14 @@ public class LoginMonthDailyMissionHandler extends AbstractDailyMissionHandler
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_LOGIN, (OnPlayerLogin event) -> onPlayerLogin(event), this));
}
@Override
public void reset()
{
// Monthly rewards do not reset daily.
}
private void onPlayerLogin(OnPlayerLogin event)
{
final DailyMissionPlayerEntry entry = getPlayerEntry(event.getPlayer().getObjectId(), true);
final long lastCompleted = entry.getLastCompleted();
if (lastCompleted == 0) // Initial entry.
{
entry.setLastCompleted(System.currentTimeMillis());
}
else if ((System.currentTimeMillis() - lastCompleted) > 2506000000L) // 2506000000L (29 day) delay.
if (entry.getStatus() != DailyMissionStatus.COMPLETED)
{
entry.setProgress(1);
entry.setStatus(DailyMissionStatus.AVAILABLE);
}
else
{
entry.setProgress(0);
entry.setStatus(DailyMissionStatus.NOT_AVAILABLE);
}
storePlayerEntry(entry);
}
}

View File

@ -51,27 +51,18 @@ public class LoginWeekendDailyMissionHandler extends AbstractDailyMissionHandler
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_LOGIN, (OnPlayerLogin event) -> onPlayerLogin(event), this));
}
@Override
public void reset()
{
// Weekend rewards do not reset daily.
}
private void onPlayerLogin(OnPlayerLogin event)
{
final DailyMissionPlayerEntry entry = getPlayerEntry(event.getPlayer().getObjectId(), true);
final int currentDay = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
final long lastCompleted = entry.getLastCompleted();
if (((currentDay == Calendar.SATURDAY) || (currentDay == Calendar.SUNDAY)) // Reward only on weekend.
&& ((lastCompleted == 0) || ((System.currentTimeMillis() - lastCompleted) > 172800000))) // Initial entry or 172800000 (2 day) delay.
if (entry.getStatus() != DailyMissionStatus.COMPLETED)
{
entry.setProgress(1);
entry.setStatus(DailyMissionStatus.AVAILABLE);
}
else if (entry.getStatus() != DailyMissionStatus.AVAILABLE) // Not waiting to be rewarded.
{
entry.setProgress(0);
entry.setStatus(DailyMissionStatus.NOT_AVAILABLE);
final int currentDay = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
if (((currentDay == Calendar.SATURDAY) || (currentDay == Calendar.SUNDAY) || (currentDay == Calendar.MONDAY)) //
&& (Calendar.getInstance().get(Calendar.HOUR_OF_DAY) < 6) && (Calendar.getInstance().get(Calendar.MINUTE) < 30))
{
entry.setProgress(1);
entry.setStatus(DailyMissionStatus.AVAILABLE);
}
}
storePlayerEntry(entry);
}

View File

@ -42,6 +42,7 @@
<xs:attribute type="xs:boolean" name="isMainClassOnly" />
<xs:attribute type="xs:boolean" name="isDualClassOnly" />
<xs:attribute type="xs:boolean" name="isDisplayedWhenNotAvailable" />
<xs:attribute type="xs:string" name="duration" />
</xs:complexType>
<xs:complexType name="listType">
<xs:sequence>

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();
}
}
}
}

View File

@ -23,6 +23,7 @@ import org.l2jmobius.gameserver.handler.DailyMissionHandler;
import handlers.dailymissionhandlers.BossDailyMissionHandler;
import handlers.dailymissionhandlers.CeremonyOfChaosDailyMissionHandler;
import handlers.dailymissionhandlers.FishingDailyMissionHandler;
import handlers.dailymissionhandlers.JoinClanDailyMissionHandler;
import handlers.dailymissionhandlers.LevelDailyMissionHandler;
import handlers.dailymissionhandlers.LoginMonthDailyMissionHandler;
import handlers.dailymissionhandlers.LoginWeekendDailyMissionHandler;
@ -48,6 +49,7 @@ public class DailyMissionMasterHandler
DailyMissionHandler.getInstance().registerHandler("ceremonyofchaos", CeremonyOfChaosDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("boss", BossDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("fishing", FishingDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("joinclan", JoinClanDailyMissionHandler::new);
LOGGER.info(DailyMissionMasterHandler.class.getSimpleName() + ": Loaded " + DailyMissionHandler.getInstance().size() + " handlers.");
}
}

View File

@ -0,0 +1,81 @@
/*
* 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 handlers.dailymissionhandlers;
import java.util.function.Consumer;
import org.l2jmobius.gameserver.enums.DailyMissionStatus;
import org.l2jmobius.gameserver.handler.AbstractDailyMissionHandler;
import org.l2jmobius.gameserver.model.DailyMissionDataHolder;
import org.l2jmobius.gameserver.model.DailyMissionPlayerEntry;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.events.Containers;
import org.l2jmobius.gameserver.model.events.EventType;
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanCreate;
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanJoin;
import org.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener;
/**
* @author kamikadzz
*/
public class JoinClanDailyMissionHandler extends AbstractDailyMissionHandler
{
public JoinClanDailyMissionHandler(DailyMissionDataHolder holder)
{
super(holder);
}
@Override
public boolean isAvailable(Player player)
{
final DailyMissionPlayerEntry entry = getPlayerEntry(player.getObjectId(), false);
return (entry != null) && (entry.getStatus() == DailyMissionStatus.AVAILABLE);
}
@Override
public void init()
{
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_CLAN_JOIN, (Consumer<OnPlayerClanJoin>) this::onPlayerClanJoin, this));
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_CLAN_CREATE, (Consumer<OnPlayerClanCreate>) this::onPlayerClanCreate, this));
}
private void onPlayerClanJoin(OnPlayerClanJoin event)
{
final DailyMissionPlayerEntry missionData = getPlayerEntry(event.getClanMember().getPlayer().getObjectId(), true);
processMission(missionData);
}
private void onPlayerClanCreate(OnPlayerClanCreate event)
{
final DailyMissionPlayerEntry missionData = getPlayerEntry(event.getPlayer().getObjectId(), true);
processMission(missionData);
}
private void processMission(DailyMissionPlayerEntry missionData)
{
if (missionData.getProgress() == 1)
{
missionData.setStatus(DailyMissionStatus.COMPLETED);
}
else
{
missionData.setProgress(1);
missionData.setStatus(DailyMissionStatus.AVAILABLE);
}
storePlayerEntry(missionData);
}
}

View File

@ -49,30 +49,14 @@ public class LoginMonthDailyMissionHandler extends AbstractDailyMissionHandler
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_LOGIN, (OnPlayerLogin event) -> onPlayerLogin(event), this));
}
@Override
public void reset()
{
// Monthly rewards do not reset daily.
}
private void onPlayerLogin(OnPlayerLogin event)
{
final DailyMissionPlayerEntry entry = getPlayerEntry(event.getPlayer().getObjectId(), true);
final long lastCompleted = entry.getLastCompleted();
if (lastCompleted == 0) // Initial entry.
{
entry.setLastCompleted(System.currentTimeMillis());
}
else if ((System.currentTimeMillis() - lastCompleted) > 2506000000L) // 2506000000L (29 day) delay.
if (entry.getStatus() != DailyMissionStatus.COMPLETED)
{
entry.setProgress(1);
entry.setStatus(DailyMissionStatus.AVAILABLE);
}
else
{
entry.setProgress(0);
entry.setStatus(DailyMissionStatus.NOT_AVAILABLE);
}
storePlayerEntry(entry);
}
}

View File

@ -51,27 +51,18 @@ public class LoginWeekendDailyMissionHandler extends AbstractDailyMissionHandler
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_LOGIN, (OnPlayerLogin event) -> onPlayerLogin(event), this));
}
@Override
public void reset()
{
// Weekend rewards do not reset daily.
}
private void onPlayerLogin(OnPlayerLogin event)
{
final DailyMissionPlayerEntry entry = getPlayerEntry(event.getPlayer().getObjectId(), true);
final int currentDay = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
final long lastCompleted = entry.getLastCompleted();
if (((currentDay == Calendar.SATURDAY) || (currentDay == Calendar.SUNDAY)) // Reward only on weekend.
&& ((lastCompleted == 0) || ((System.currentTimeMillis() - lastCompleted) > 172800000))) // Initial entry or 172800000 (2 day) delay.
if (entry.getStatus() != DailyMissionStatus.COMPLETED)
{
entry.setProgress(1);
entry.setStatus(DailyMissionStatus.AVAILABLE);
}
else if (entry.getStatus() != DailyMissionStatus.AVAILABLE) // Not waiting to be rewarded.
{
entry.setProgress(0);
entry.setStatus(DailyMissionStatus.NOT_AVAILABLE);
final int currentDay = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
if (((currentDay == Calendar.SATURDAY) || (currentDay == Calendar.SUNDAY) || (currentDay == Calendar.MONDAY)) //
&& (Calendar.getInstance().get(Calendar.HOUR_OF_DAY) < 6) && (Calendar.getInstance().get(Calendar.MINUTE) < 30))
{
entry.setProgress(1);
entry.setStatus(DailyMissionStatus.AVAILABLE);
}
}
storePlayerEntry(entry);
}

View File

@ -42,6 +42,7 @@
<xs:attribute type="xs:boolean" name="isMainClassOnly" />
<xs:attribute type="xs:boolean" name="isDualClassOnly" />
<xs:attribute type="xs:boolean" name="isDisplayedWhenNotAvailable" />
<xs:attribute type="xs:string" name="duration" />
</xs:complexType>
<xs:complexType name="listType">
<xs:sequence>

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();
}
}
}
}

View File

@ -23,6 +23,7 @@ import org.l2jmobius.gameserver.handler.DailyMissionHandler;
import handlers.dailymissionhandlers.BossDailyMissionHandler;
import handlers.dailymissionhandlers.CeremonyOfChaosDailyMissionHandler;
import handlers.dailymissionhandlers.FishingDailyMissionHandler;
import handlers.dailymissionhandlers.JoinClanDailyMissionHandler;
import handlers.dailymissionhandlers.LevelDailyMissionHandler;
import handlers.dailymissionhandlers.LoginMonthDailyMissionHandler;
import handlers.dailymissionhandlers.LoginWeekendDailyMissionHandler;
@ -50,6 +51,7 @@ public class DailyMissionMasterHandler
DailyMissionHandler.getInstance().registerHandler("boss", BossDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("monster", MonsterDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("fishing", FishingDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("joinclan", JoinClanDailyMissionHandler::new);
LOGGER.info(DailyMissionMasterHandler.class.getSimpleName() + ": Loaded " + DailyMissionHandler.getInstance().size() + " handlers.");
}
}

View File

@ -0,0 +1,81 @@
/*
* 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 handlers.dailymissionhandlers;
import java.util.function.Consumer;
import org.l2jmobius.gameserver.enums.DailyMissionStatus;
import org.l2jmobius.gameserver.handler.AbstractDailyMissionHandler;
import org.l2jmobius.gameserver.model.DailyMissionDataHolder;
import org.l2jmobius.gameserver.model.DailyMissionPlayerEntry;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.events.Containers;
import org.l2jmobius.gameserver.model.events.EventType;
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanCreate;
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanJoin;
import org.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener;
/**
* @author kamikadzz
*/
public class JoinClanDailyMissionHandler extends AbstractDailyMissionHandler
{
public JoinClanDailyMissionHandler(DailyMissionDataHolder holder)
{
super(holder);
}
@Override
public boolean isAvailable(Player player)
{
final DailyMissionPlayerEntry entry = getPlayerEntry(player.getObjectId(), false);
return (entry != null) && (entry.getStatus() == DailyMissionStatus.AVAILABLE);
}
@Override
public void init()
{
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_CLAN_JOIN, (Consumer<OnPlayerClanJoin>) this::onPlayerClanJoin, this));
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_CLAN_CREATE, (Consumer<OnPlayerClanCreate>) this::onPlayerClanCreate, this));
}
private void onPlayerClanJoin(OnPlayerClanJoin event)
{
final DailyMissionPlayerEntry missionData = getPlayerEntry(event.getClanMember().getPlayer().getObjectId(), true);
processMission(missionData);
}
private void onPlayerClanCreate(OnPlayerClanCreate event)
{
final DailyMissionPlayerEntry missionData = getPlayerEntry(event.getPlayer().getObjectId(), true);
processMission(missionData);
}
private void processMission(DailyMissionPlayerEntry missionData)
{
if (missionData.getProgress() == 1)
{
missionData.setStatus(DailyMissionStatus.COMPLETED);
}
else
{
missionData.setProgress(1);
missionData.setStatus(DailyMissionStatus.AVAILABLE);
}
storePlayerEntry(missionData);
}
}

View File

@ -49,30 +49,14 @@ public class LoginMonthDailyMissionHandler extends AbstractDailyMissionHandler
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_LOGIN, (OnPlayerLogin event) -> onPlayerLogin(event), this));
}
@Override
public void reset()
{
// Monthly rewards do not reset daily.
}
private void onPlayerLogin(OnPlayerLogin event)
{
final DailyMissionPlayerEntry entry = getPlayerEntry(event.getPlayer().getObjectId(), true);
final long lastCompleted = entry.getLastCompleted();
if (lastCompleted == 0) // Initial entry.
{
entry.setLastCompleted(System.currentTimeMillis());
}
else if ((System.currentTimeMillis() - lastCompleted) > 2506000000L) // 2506000000L (29 day) delay.
if (entry.getStatus() != DailyMissionStatus.COMPLETED)
{
entry.setProgress(1);
entry.setStatus(DailyMissionStatus.AVAILABLE);
}
else
{
entry.setProgress(0);
entry.setStatus(DailyMissionStatus.NOT_AVAILABLE);
}
storePlayerEntry(entry);
}
}

View File

@ -51,27 +51,18 @@ public class LoginWeekendDailyMissionHandler extends AbstractDailyMissionHandler
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_LOGIN, (OnPlayerLogin event) -> onPlayerLogin(event), this));
}
@Override
public void reset()
{
// Weekend rewards do not reset daily.
}
private void onPlayerLogin(OnPlayerLogin event)
{
final DailyMissionPlayerEntry entry = getPlayerEntry(event.getPlayer().getObjectId(), true);
final int currentDay = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
final long lastCompleted = entry.getLastCompleted();
if (((currentDay == Calendar.SATURDAY) || (currentDay == Calendar.SUNDAY)) // Reward only on weekend.
&& ((lastCompleted == 0) || ((System.currentTimeMillis() - lastCompleted) > 172800000))) // Initial entry or 172800000 (2 day) delay.
if (entry.getStatus() != DailyMissionStatus.COMPLETED)
{
entry.setProgress(1);
entry.setStatus(DailyMissionStatus.AVAILABLE);
}
else if (entry.getStatus() != DailyMissionStatus.AVAILABLE) // Not waiting to be rewarded.
{
entry.setProgress(0);
entry.setStatus(DailyMissionStatus.NOT_AVAILABLE);
final int currentDay = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
if (((currentDay == Calendar.SATURDAY) || (currentDay == Calendar.SUNDAY) || (currentDay == Calendar.MONDAY)) //
&& (Calendar.getInstance().get(Calendar.HOUR_OF_DAY) < 6) && (Calendar.getInstance().get(Calendar.MINUTE) < 30))
{
entry.setProgress(1);
entry.setStatus(DailyMissionStatus.AVAILABLE);
}
}
storePlayerEntry(entry);
}

View File

@ -106,12 +106,9 @@ public class MonsterDailyMissionHandler extends AbstractDailyMissionHandler
final Player player = event.getAttacker();
final int monsterLevel = monster.getLevel();
if (_minLevel > 0)
if ((_minLevel > 0) && ((monsterLevel < _minLevel) || (monsterLevel > _maxLevel) || ((player.getLevel() - monsterLevel) > 5)))
{
if ((monsterLevel < _minLevel) || (monsterLevel > _maxLevel) || ((player.getLevel() - monsterLevel) > 5))
{
return;
}
return;
}
final Party party = player.getParty();

View File

@ -42,6 +42,7 @@
<xs:attribute type="xs:boolean" name="isMainClassOnly" />
<xs:attribute type="xs:boolean" name="isDualClassOnly" />
<xs:attribute type="xs:boolean" name="isDisplayedWhenNotAvailable" />
<xs:attribute type="xs:string" name="duration" />
</xs:complexType>
<xs:complexType name="listType">
<xs:sequence>

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();
}
}
}
}

View File

@ -23,6 +23,7 @@ import org.l2jmobius.gameserver.handler.DailyMissionHandler;
import handlers.dailymissionhandlers.BossDailyMissionHandler;
import handlers.dailymissionhandlers.CeremonyOfChaosDailyMissionHandler;
import handlers.dailymissionhandlers.FishingDailyMissionHandler;
import handlers.dailymissionhandlers.JoinClanDailyMissionHandler;
import handlers.dailymissionhandlers.LevelDailyMissionHandler;
import handlers.dailymissionhandlers.LoginMonthDailyMissionHandler;
import handlers.dailymissionhandlers.LoginWeekendDailyMissionHandler;
@ -50,6 +51,7 @@ public class DailyMissionMasterHandler
DailyMissionHandler.getInstance().registerHandler("boss", BossDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("monster", MonsterDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("fishing", FishingDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("joinclan", JoinClanDailyMissionHandler::new);
LOGGER.info(DailyMissionMasterHandler.class.getSimpleName() + ": Loaded " + DailyMissionHandler.getInstance().size() + " handlers.");
}
}

View File

@ -0,0 +1,81 @@
/*
* 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 handlers.dailymissionhandlers;
import java.util.function.Consumer;
import org.l2jmobius.gameserver.enums.DailyMissionStatus;
import org.l2jmobius.gameserver.handler.AbstractDailyMissionHandler;
import org.l2jmobius.gameserver.model.DailyMissionDataHolder;
import org.l2jmobius.gameserver.model.DailyMissionPlayerEntry;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.events.Containers;
import org.l2jmobius.gameserver.model.events.EventType;
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanCreate;
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanJoin;
import org.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener;
/**
* @author kamikadzz
*/
public class JoinClanDailyMissionHandler extends AbstractDailyMissionHandler
{
public JoinClanDailyMissionHandler(DailyMissionDataHolder holder)
{
super(holder);
}
@Override
public boolean isAvailable(Player player)
{
final DailyMissionPlayerEntry entry = getPlayerEntry(player.getObjectId(), false);
return (entry != null) && (entry.getStatus() == DailyMissionStatus.AVAILABLE);
}
@Override
public void init()
{
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_CLAN_JOIN, (Consumer<OnPlayerClanJoin>) this::onPlayerClanJoin, this));
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_CLAN_CREATE, (Consumer<OnPlayerClanCreate>) this::onPlayerClanCreate, this));
}
private void onPlayerClanJoin(OnPlayerClanJoin event)
{
final DailyMissionPlayerEntry missionData = getPlayerEntry(event.getClanMember().getPlayer().getObjectId(), true);
processMission(missionData);
}
private void onPlayerClanCreate(OnPlayerClanCreate event)
{
final DailyMissionPlayerEntry missionData = getPlayerEntry(event.getPlayer().getObjectId(), true);
processMission(missionData);
}
private void processMission(DailyMissionPlayerEntry missionData)
{
if (missionData.getProgress() == 1)
{
missionData.setStatus(DailyMissionStatus.COMPLETED);
}
else
{
missionData.setProgress(1);
missionData.setStatus(DailyMissionStatus.AVAILABLE);
}
storePlayerEntry(missionData);
}
}

View File

@ -49,30 +49,14 @@ public class LoginMonthDailyMissionHandler extends AbstractDailyMissionHandler
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_LOGIN, (OnPlayerLogin event) -> onPlayerLogin(event), this));
}
@Override
public void reset()
{
// Monthly rewards do not reset daily.
}
private void onPlayerLogin(OnPlayerLogin event)
{
final DailyMissionPlayerEntry entry = getPlayerEntry(event.getPlayer().getObjectId(), true);
final long lastCompleted = entry.getLastCompleted();
if (lastCompleted == 0) // Initial entry.
{
entry.setLastCompleted(System.currentTimeMillis());
}
else if ((System.currentTimeMillis() - lastCompleted) > 2506000000L) // 2506000000L (29 day) delay.
if (entry.getStatus() != DailyMissionStatus.COMPLETED)
{
entry.setProgress(1);
entry.setStatus(DailyMissionStatus.AVAILABLE);
}
else
{
entry.setProgress(0);
entry.setStatus(DailyMissionStatus.NOT_AVAILABLE);
}
storePlayerEntry(entry);
}
}

View File

@ -51,27 +51,18 @@ public class LoginWeekendDailyMissionHandler extends AbstractDailyMissionHandler
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_LOGIN, (OnPlayerLogin event) -> onPlayerLogin(event), this));
}
@Override
public void reset()
{
// Weekend rewards do not reset daily.
}
private void onPlayerLogin(OnPlayerLogin event)
{
final DailyMissionPlayerEntry entry = getPlayerEntry(event.getPlayer().getObjectId(), true);
final int currentDay = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
final long lastCompleted = entry.getLastCompleted();
if (((currentDay == Calendar.SATURDAY) || (currentDay == Calendar.SUNDAY)) // Reward only on weekend.
&& ((lastCompleted == 0) || ((System.currentTimeMillis() - lastCompleted) > 172800000))) // Initial entry or 172800000 (2 day) delay.
if (entry.getStatus() != DailyMissionStatus.COMPLETED)
{
entry.setProgress(1);
entry.setStatus(DailyMissionStatus.AVAILABLE);
}
else if (entry.getStatus() != DailyMissionStatus.AVAILABLE) // Not waiting to be rewarded.
{
entry.setProgress(0);
entry.setStatus(DailyMissionStatus.NOT_AVAILABLE);
final int currentDay = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
if (((currentDay == Calendar.SATURDAY) || (currentDay == Calendar.SUNDAY) || (currentDay == Calendar.MONDAY)) //
&& (Calendar.getInstance().get(Calendar.HOUR_OF_DAY) < 6) && (Calendar.getInstance().get(Calendar.MINUTE) < 30))
{
entry.setProgress(1);
entry.setStatus(DailyMissionStatus.AVAILABLE);
}
}
storePlayerEntry(entry);
}

View File

@ -106,12 +106,9 @@ public class MonsterDailyMissionHandler extends AbstractDailyMissionHandler
final Player player = event.getAttacker();
final int monsterLevel = monster.getLevel();
if (_minLevel > 0)
if ((_minLevel > 0) && ((monsterLevel < _minLevel) || (monsterLevel > _maxLevel) || ((player.getLevel() - monsterLevel) > 5)))
{
if ((monsterLevel < _minLevel) || (monsterLevel > _maxLevel) || ((player.getLevel() - monsterLevel) > 5))
{
return;
}
return;
}
final Party party = player.getParty();

View File

@ -42,6 +42,7 @@
<xs:attribute type="xs:boolean" name="isMainClassOnly" />
<xs:attribute type="xs:boolean" name="isDualClassOnly" />
<xs:attribute type="xs:boolean" name="isDisplayedWhenNotAvailable" />
<xs:attribute type="xs:string" name="duration" />
</xs:complexType>
<xs:complexType name="listType">
<xs:sequence>

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();
}
}
}
}

View File

@ -23,6 +23,7 @@ import org.l2jmobius.gameserver.handler.DailyMissionHandler;
import handlers.dailymissionhandlers.BossDailyMissionHandler;
import handlers.dailymissionhandlers.CeremonyOfChaosDailyMissionHandler;
import handlers.dailymissionhandlers.FishingDailyMissionHandler;
import handlers.dailymissionhandlers.JoinClanDailyMissionHandler;
import handlers.dailymissionhandlers.LevelDailyMissionHandler;
import handlers.dailymissionhandlers.LoginMonthDailyMissionHandler;
import handlers.dailymissionhandlers.LoginWeekendDailyMissionHandler;
@ -50,6 +51,7 @@ public class DailyMissionMasterHandler
DailyMissionHandler.getInstance().registerHandler("boss", BossDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("monster", MonsterDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("fishing", FishingDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("joinclan", JoinClanDailyMissionHandler::new);
LOGGER.info(DailyMissionMasterHandler.class.getSimpleName() + ": Loaded " + DailyMissionHandler.getInstance().size() + " handlers.");
}
}

View File

@ -0,0 +1,81 @@
/*
* 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 handlers.dailymissionhandlers;
import java.util.function.Consumer;
import org.l2jmobius.gameserver.enums.DailyMissionStatus;
import org.l2jmobius.gameserver.handler.AbstractDailyMissionHandler;
import org.l2jmobius.gameserver.model.DailyMissionDataHolder;
import org.l2jmobius.gameserver.model.DailyMissionPlayerEntry;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.events.Containers;
import org.l2jmobius.gameserver.model.events.EventType;
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanCreate;
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanJoin;
import org.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener;
/**
* @author kamikadzz
*/
public class JoinClanDailyMissionHandler extends AbstractDailyMissionHandler
{
public JoinClanDailyMissionHandler(DailyMissionDataHolder holder)
{
super(holder);
}
@Override
public boolean isAvailable(Player player)
{
final DailyMissionPlayerEntry entry = getPlayerEntry(player.getObjectId(), false);
return (entry != null) && (entry.getStatus() == DailyMissionStatus.AVAILABLE);
}
@Override
public void init()
{
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_CLAN_JOIN, (Consumer<OnPlayerClanJoin>) this::onPlayerClanJoin, this));
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_CLAN_CREATE, (Consumer<OnPlayerClanCreate>) this::onPlayerClanCreate, this));
}
private void onPlayerClanJoin(OnPlayerClanJoin event)
{
final DailyMissionPlayerEntry missionData = getPlayerEntry(event.getClanMember().getPlayer().getObjectId(), true);
processMission(missionData);
}
private void onPlayerClanCreate(OnPlayerClanCreate event)
{
final DailyMissionPlayerEntry missionData = getPlayerEntry(event.getPlayer().getObjectId(), true);
processMission(missionData);
}
private void processMission(DailyMissionPlayerEntry missionData)
{
if (missionData.getProgress() == 1)
{
missionData.setStatus(DailyMissionStatus.COMPLETED);
}
else
{
missionData.setProgress(1);
missionData.setStatus(DailyMissionStatus.AVAILABLE);
}
storePlayerEntry(missionData);
}
}

View File

@ -49,30 +49,14 @@ public class LoginMonthDailyMissionHandler extends AbstractDailyMissionHandler
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_LOGIN, (OnPlayerLogin event) -> onPlayerLogin(event), this));
}
@Override
public void reset()
{
// Monthly rewards do not reset daily.
}
private void onPlayerLogin(OnPlayerLogin event)
{
final DailyMissionPlayerEntry entry = getPlayerEntry(event.getPlayer().getObjectId(), true);
final long lastCompleted = entry.getLastCompleted();
if (lastCompleted == 0) // Initial entry.
{
entry.setLastCompleted(System.currentTimeMillis());
}
else if ((System.currentTimeMillis() - lastCompleted) > 2506000000L) // 2506000000L (29 day) delay.
if (entry.getStatus() != DailyMissionStatus.COMPLETED)
{
entry.setProgress(1);
entry.setStatus(DailyMissionStatus.AVAILABLE);
}
else
{
entry.setProgress(0);
entry.setStatus(DailyMissionStatus.NOT_AVAILABLE);
}
storePlayerEntry(entry);
}
}

View File

@ -51,27 +51,18 @@ public class LoginWeekendDailyMissionHandler extends AbstractDailyMissionHandler
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_LOGIN, (OnPlayerLogin event) -> onPlayerLogin(event), this));
}
@Override
public void reset()
{
// Weekend rewards do not reset daily.
}
private void onPlayerLogin(OnPlayerLogin event)
{
final DailyMissionPlayerEntry entry = getPlayerEntry(event.getPlayer().getObjectId(), true);
final int currentDay = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
final long lastCompleted = entry.getLastCompleted();
if (((currentDay == Calendar.SATURDAY) || (currentDay == Calendar.SUNDAY)) // Reward only on weekend.
&& ((lastCompleted == 0) || ((System.currentTimeMillis() - lastCompleted) > 172800000))) // Initial entry or 172800000 (2 day) delay.
if (entry.getStatus() != DailyMissionStatus.COMPLETED)
{
entry.setProgress(1);
entry.setStatus(DailyMissionStatus.AVAILABLE);
}
else if (entry.getStatus() != DailyMissionStatus.AVAILABLE) // Not waiting to be rewarded.
{
entry.setProgress(0);
entry.setStatus(DailyMissionStatus.NOT_AVAILABLE);
final int currentDay = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
if (((currentDay == Calendar.SATURDAY) || (currentDay == Calendar.SUNDAY) || (currentDay == Calendar.MONDAY)) //
&& (Calendar.getInstance().get(Calendar.HOUR_OF_DAY) < 6) && (Calendar.getInstance().get(Calendar.MINUTE) < 30))
{
entry.setProgress(1);
entry.setStatus(DailyMissionStatus.AVAILABLE);
}
}
storePlayerEntry(entry);
}

View File

@ -105,13 +105,10 @@ public class MonsterDailyMissionHandler extends AbstractDailyMissionHandler
}
final Player player = event.getAttacker();
if (_minLevel > 0)
final int monsterLevel = monster.getLevel();
if ((_minLevel > 0) && ((monsterLevel < _minLevel) || (monsterLevel > _maxLevel) || ((player.getLevel() - monsterLevel) > 5)))
{
final int monsterLevel = monster.getLevel();
if ((monsterLevel < _minLevel) || (monsterLevel > _maxLevel) || ((player.getLevel() - monsterLevel) > 5))
{
return;
}
return;
}
final Party party = player.getParty();
@ -119,7 +116,13 @@ public class MonsterDailyMissionHandler extends AbstractDailyMissionHandler
{
final CommandChannel channel = party.getCommandChannel();
final List<Player> members = channel != null ? channel.getMembers() : party.getMembers();
members.stream().filter(member -> member.calculateDistance3D(monster) <= Config.ALT_PARTY_RANGE).forEach(this::processPlayerProgress);
for (Player member : members)
{
if ((member.getLevel() >= (monsterLevel - 5)) && (member.calculateDistance3D(monster) <= Config.ALT_PARTY_RANGE))
{
processPlayerProgress(member);
}
}
}
else
{

View File

@ -42,6 +42,7 @@
<xs:attribute type="xs:boolean" name="isMainClassOnly" />
<xs:attribute type="xs:boolean" name="isDualClassOnly" />
<xs:attribute type="xs:boolean" name="isDisplayedWhenNotAvailable" />
<xs:attribute type="xs:string" name="duration" />
</xs:complexType>
<xs:complexType name="listType">
<xs:sequence>

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();
}
}
}
}

View File

@ -23,6 +23,7 @@ import org.l2jmobius.gameserver.handler.DailyMissionHandler;
import handlers.dailymissionhandlers.BossDailyMissionHandler;
import handlers.dailymissionhandlers.CeremonyOfChaosDailyMissionHandler;
import handlers.dailymissionhandlers.FishingDailyMissionHandler;
import handlers.dailymissionhandlers.JoinClanDailyMissionHandler;
import handlers.dailymissionhandlers.LevelDailyMissionHandler;
import handlers.dailymissionhandlers.LoginMonthDailyMissionHandler;
import handlers.dailymissionhandlers.LoginWeekendDailyMissionHandler;
@ -50,6 +51,7 @@ public class DailyMissionMasterHandler
DailyMissionHandler.getInstance().registerHandler("boss", BossDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("monster", MonsterDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("fishing", FishingDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("joinclan", JoinClanDailyMissionHandler::new);
LOGGER.info(DailyMissionMasterHandler.class.getSimpleName() + ": Loaded " + DailyMissionHandler.getInstance().size() + " handlers.");
}
}

View File

@ -0,0 +1,81 @@
/*
* 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 handlers.dailymissionhandlers;
import java.util.function.Consumer;
import org.l2jmobius.gameserver.enums.DailyMissionStatus;
import org.l2jmobius.gameserver.handler.AbstractDailyMissionHandler;
import org.l2jmobius.gameserver.model.DailyMissionDataHolder;
import org.l2jmobius.gameserver.model.DailyMissionPlayerEntry;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.events.Containers;
import org.l2jmobius.gameserver.model.events.EventType;
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanCreate;
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanJoin;
import org.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener;
/**
* @author kamikadzz
*/
public class JoinClanDailyMissionHandler extends AbstractDailyMissionHandler
{
public JoinClanDailyMissionHandler(DailyMissionDataHolder holder)
{
super(holder);
}
@Override
public boolean isAvailable(Player player)
{
final DailyMissionPlayerEntry entry = getPlayerEntry(player.getObjectId(), false);
return (entry != null) && (entry.getStatus() == DailyMissionStatus.AVAILABLE);
}
@Override
public void init()
{
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_CLAN_JOIN, (Consumer<OnPlayerClanJoin>) this::onPlayerClanJoin, this));
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_CLAN_CREATE, (Consumer<OnPlayerClanCreate>) this::onPlayerClanCreate, this));
}
private void onPlayerClanJoin(OnPlayerClanJoin event)
{
final DailyMissionPlayerEntry missionData = getPlayerEntry(event.getClanMember().getPlayer().getObjectId(), true);
processMission(missionData);
}
private void onPlayerClanCreate(OnPlayerClanCreate event)
{
final DailyMissionPlayerEntry missionData = getPlayerEntry(event.getPlayer().getObjectId(), true);
processMission(missionData);
}
private void processMission(DailyMissionPlayerEntry missionData)
{
if (missionData.getProgress() == 1)
{
missionData.setStatus(DailyMissionStatus.COMPLETED);
}
else
{
missionData.setProgress(1);
missionData.setStatus(DailyMissionStatus.AVAILABLE);
}
storePlayerEntry(missionData);
}
}

View File

@ -49,30 +49,14 @@ public class LoginMonthDailyMissionHandler extends AbstractDailyMissionHandler
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_LOGIN, (OnPlayerLogin event) -> onPlayerLogin(event), this));
}
@Override
public void reset()
{
// Monthly rewards do not reset daily.
}
private void onPlayerLogin(OnPlayerLogin event)
{
final DailyMissionPlayerEntry entry = getPlayerEntry(event.getPlayer().getObjectId(), true);
final long lastCompleted = entry.getLastCompleted();
if (lastCompleted == 0) // Initial entry.
{
entry.setLastCompleted(System.currentTimeMillis());
}
else if ((System.currentTimeMillis() - lastCompleted) > 2506000000L) // 2506000000L (29 day) delay.
if (entry.getStatus() != DailyMissionStatus.COMPLETED)
{
entry.setProgress(1);
entry.setStatus(DailyMissionStatus.AVAILABLE);
}
else
{
entry.setProgress(0);
entry.setStatus(DailyMissionStatus.NOT_AVAILABLE);
}
storePlayerEntry(entry);
}
}

View File

@ -51,27 +51,18 @@ public class LoginWeekendDailyMissionHandler extends AbstractDailyMissionHandler
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_LOGIN, (OnPlayerLogin event) -> onPlayerLogin(event), this));
}
@Override
public void reset()
{
// Weekend rewards do not reset daily.
}
private void onPlayerLogin(OnPlayerLogin event)
{
final DailyMissionPlayerEntry entry = getPlayerEntry(event.getPlayer().getObjectId(), true);
final int currentDay = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
final long lastCompleted = entry.getLastCompleted();
if (((currentDay == Calendar.SATURDAY) || (currentDay == Calendar.SUNDAY)) // Reward only on weekend.
&& ((lastCompleted == 0) || ((System.currentTimeMillis() - lastCompleted) > 172800000))) // Initial entry or 172800000 (2 day) delay.
if (entry.getStatus() != DailyMissionStatus.COMPLETED)
{
entry.setProgress(1);
entry.setStatus(DailyMissionStatus.AVAILABLE);
}
else if (entry.getStatus() != DailyMissionStatus.AVAILABLE) // Not waiting to be rewarded.
{
entry.setProgress(0);
entry.setStatus(DailyMissionStatus.NOT_AVAILABLE);
final int currentDay = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
if (((currentDay == Calendar.SATURDAY) || (currentDay == Calendar.SUNDAY) || (currentDay == Calendar.MONDAY)) //
&& (Calendar.getInstance().get(Calendar.HOUR_OF_DAY) < 6) && (Calendar.getInstance().get(Calendar.MINUTE) < 30))
{
entry.setProgress(1);
entry.setStatus(DailyMissionStatus.AVAILABLE);
}
}
storePlayerEntry(entry);
}

View File

@ -105,13 +105,10 @@ public class MonsterDailyMissionHandler extends AbstractDailyMissionHandler
}
final Player player = event.getAttacker();
if (_minLevel > 0)
final int monsterLevel = monster.getLevel();
if ((_minLevel > 0) && ((monsterLevel < _minLevel) || (monsterLevel > _maxLevel) || ((player.getLevel() - monsterLevel) > 5)))
{
final int monsterLevel = monster.getLevel();
if ((monsterLevel < _minLevel) || (monsterLevel > _maxLevel) || ((player.getLevel() - monsterLevel) > 5))
{
return;
}
return;
}
final Party party = player.getParty();
@ -119,7 +116,13 @@ public class MonsterDailyMissionHandler extends AbstractDailyMissionHandler
{
final CommandChannel channel = party.getCommandChannel();
final List<Player> members = channel != null ? channel.getMembers() : party.getMembers();
members.stream().filter(member -> member.calculateDistance3D(monster) <= Config.ALT_PARTY_RANGE).forEach(this::processPlayerProgress);
for (Player member : members)
{
if ((member.getLevel() >= (monsterLevel - 5)) && (member.calculateDistance3D(monster) <= Config.ALT_PARTY_RANGE))
{
processPlayerProgress(member);
}
}
}
else
{

View File

@ -42,6 +42,7 @@
<xs:attribute type="xs:boolean" name="isMainClassOnly" />
<xs:attribute type="xs:boolean" name="isDualClassOnly" />
<xs:attribute type="xs:boolean" name="isDisplayedWhenNotAvailable" />
<xs:attribute type="xs:string" name="duration" />
</xs:complexType>
<xs:complexType name="listType">
<xs:sequence>

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();
}
}
}
}

View File

@ -23,6 +23,7 @@ import org.l2jmobius.gameserver.handler.DailyMissionHandler;
import handlers.dailymissionhandlers.BossDailyMissionHandler;
import handlers.dailymissionhandlers.CeremonyOfChaosDailyMissionHandler;
import handlers.dailymissionhandlers.FishingDailyMissionHandler;
import handlers.dailymissionhandlers.JoinClanDailyMissionHandler;
import handlers.dailymissionhandlers.LevelDailyMissionHandler;
import handlers.dailymissionhandlers.LoginMonthDailyMissionHandler;
import handlers.dailymissionhandlers.LoginWeekendDailyMissionHandler;
@ -50,6 +51,7 @@ public class DailyMissionMasterHandler
DailyMissionHandler.getInstance().registerHandler("boss", BossDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("monster", MonsterDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("fishing", FishingDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("joinclan", JoinClanDailyMissionHandler::new);
LOGGER.info(DailyMissionMasterHandler.class.getSimpleName() + ": Loaded " + DailyMissionHandler.getInstance().size() + " handlers.");
}
}

View File

@ -0,0 +1,81 @@
/*
* 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 handlers.dailymissionhandlers;
import java.util.function.Consumer;
import org.l2jmobius.gameserver.enums.DailyMissionStatus;
import org.l2jmobius.gameserver.handler.AbstractDailyMissionHandler;
import org.l2jmobius.gameserver.model.DailyMissionDataHolder;
import org.l2jmobius.gameserver.model.DailyMissionPlayerEntry;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.events.Containers;
import org.l2jmobius.gameserver.model.events.EventType;
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanCreate;
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanJoin;
import org.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener;
/**
* @author kamikadzz
*/
public class JoinClanDailyMissionHandler extends AbstractDailyMissionHandler
{
public JoinClanDailyMissionHandler(DailyMissionDataHolder holder)
{
super(holder);
}
@Override
public boolean isAvailable(Player player)
{
final DailyMissionPlayerEntry entry = getPlayerEntry(player.getObjectId(), false);
return (entry != null) && (entry.getStatus() == DailyMissionStatus.AVAILABLE);
}
@Override
public void init()
{
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_CLAN_JOIN, (Consumer<OnPlayerClanJoin>) this::onPlayerClanJoin, this));
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_CLAN_CREATE, (Consumer<OnPlayerClanCreate>) this::onPlayerClanCreate, this));
}
private void onPlayerClanJoin(OnPlayerClanJoin event)
{
final DailyMissionPlayerEntry missionData = getPlayerEntry(event.getClanMember().getPlayer().getObjectId(), true);
processMission(missionData);
}
private void onPlayerClanCreate(OnPlayerClanCreate event)
{
final DailyMissionPlayerEntry missionData = getPlayerEntry(event.getPlayer().getObjectId(), true);
processMission(missionData);
}
private void processMission(DailyMissionPlayerEntry missionData)
{
if (missionData.getProgress() == 1)
{
missionData.setStatus(DailyMissionStatus.COMPLETED);
}
else
{
missionData.setProgress(1);
missionData.setStatus(DailyMissionStatus.AVAILABLE);
}
storePlayerEntry(missionData);
}
}

View File

@ -49,30 +49,14 @@ public class LoginMonthDailyMissionHandler extends AbstractDailyMissionHandler
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_LOGIN, (OnPlayerLogin event) -> onPlayerLogin(event), this));
}
@Override
public void reset()
{
// Monthly rewards do not reset daily.
}
private void onPlayerLogin(OnPlayerLogin event)
{
final DailyMissionPlayerEntry entry = getPlayerEntry(event.getPlayer().getObjectId(), true);
final long lastCompleted = entry.getLastCompleted();
if (lastCompleted == 0) // Initial entry.
{
entry.setLastCompleted(System.currentTimeMillis());
}
else if ((System.currentTimeMillis() - lastCompleted) > 2506000000L) // 2506000000L (29 day) delay.
if (entry.getStatus() != DailyMissionStatus.COMPLETED)
{
entry.setProgress(1);
entry.setStatus(DailyMissionStatus.AVAILABLE);
}
else
{
entry.setProgress(0);
entry.setStatus(DailyMissionStatus.NOT_AVAILABLE);
}
storePlayerEntry(entry);
}
}

View File

@ -51,27 +51,18 @@ public class LoginWeekendDailyMissionHandler extends AbstractDailyMissionHandler
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_LOGIN, (OnPlayerLogin event) -> onPlayerLogin(event), this));
}
@Override
public void reset()
{
// Weekend rewards do not reset daily.
}
private void onPlayerLogin(OnPlayerLogin event)
{
final DailyMissionPlayerEntry entry = getPlayerEntry(event.getPlayer().getObjectId(), true);
final int currentDay = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
final long lastCompleted = entry.getLastCompleted();
if (((currentDay == Calendar.SATURDAY) || (currentDay == Calendar.SUNDAY)) // Reward only on weekend.
&& ((lastCompleted == 0) || ((System.currentTimeMillis() - lastCompleted) > 172800000))) // Initial entry or 172800000 (2 day) delay.
if (entry.getStatus() != DailyMissionStatus.COMPLETED)
{
entry.setProgress(1);
entry.setStatus(DailyMissionStatus.AVAILABLE);
}
else if (entry.getStatus() != DailyMissionStatus.AVAILABLE) // Not waiting to be rewarded.
{
entry.setProgress(0);
entry.setStatus(DailyMissionStatus.NOT_AVAILABLE);
final int currentDay = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
if (((currentDay == Calendar.SATURDAY) || (currentDay == Calendar.SUNDAY) || (currentDay == Calendar.MONDAY)) //
&& (Calendar.getInstance().get(Calendar.HOUR_OF_DAY) < 6) && (Calendar.getInstance().get(Calendar.MINUTE) < 30))
{
entry.setProgress(1);
entry.setStatus(DailyMissionStatus.AVAILABLE);
}
}
storePlayerEntry(entry);
}

View File

@ -105,13 +105,10 @@ public class MonsterDailyMissionHandler extends AbstractDailyMissionHandler
}
final Player player = event.getAttacker();
if (_minLevel > 0)
final int monsterLevel = monster.getLevel();
if ((_minLevel > 0) && ((monsterLevel < _minLevel) || (monsterLevel > _maxLevel) || ((player.getLevel() - monsterLevel) > 5)))
{
final int monsterLevel = monster.getLevel();
if ((monsterLevel < _minLevel) || (monsterLevel > _maxLevel) || ((player.getLevel() - monsterLevel) > 5))
{
return;
}
return;
}
final Party party = player.getParty();
@ -119,7 +116,13 @@ public class MonsterDailyMissionHandler extends AbstractDailyMissionHandler
{
final CommandChannel channel = party.getCommandChannel();
final List<Player> members = channel != null ? channel.getMembers() : party.getMembers();
members.stream().filter(member -> member.calculateDistance3D(monster) <= Config.ALT_PARTY_RANGE).forEach(this::processPlayerProgress);
for (Player member : members)
{
if ((member.getLevel() >= (monsterLevel - 5)) && (member.calculateDistance3D(monster) <= Config.ALT_PARTY_RANGE))
{
processPlayerProgress(member);
}
}
}
else
{

View File

@ -42,6 +42,7 @@
<xs:attribute type="xs:boolean" name="isMainClassOnly" />
<xs:attribute type="xs:boolean" name="isDualClassOnly" />
<xs:attribute type="xs:boolean" name="isDisplayedWhenNotAvailable" />
<xs:attribute type="xs:string" name="duration" />
</xs:complexType>
<xs:complexType name="listType">
<xs:sequence>

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();
}
}
}
}

View File

@ -1174,13 +1174,13 @@
<item id="49509" count="1" />
</items>
</reward>
<reward id="224" reward_id="604" name="Login All Weekend" isOneTime="false">
<reward id="224" reward_id="604" name="Login All Weekend" requiredCompletion="1" isOneTime="false" duration="WEEKEND">
<handler name="loginweekend" />
<items>
<item id="29648" count="2" />
</items>
</reward>
<reward id="225" reward_id="605" name="Login All Month" isOneTime="false">
<reward id="225" reward_id="605" name="Login All Month" requiredCompletion="1" isOneTime="false" duration="MONTH">
<handler name="loginmonth" />
<items>
<item id="29648" count="4" />
@ -1198,14 +1198,12 @@
<item id="29648" count="1" />
</items>
</reward>
<!--
<reward id="232" reward_id="612" name="Have you joined a clan?" requiredCompletion="1" isOneTime="true">
<handler name="siege" />
<handler name="joinclan" />
<items>
<item id="29654" count="1" />
</items>
</reward>
-->
<reward id="233" reward_id="613" name="Olympiad Warrior" requiredCompletion="1" isOneTime="false">
<handler name="olympiad" />
<items>

View File

@ -22,6 +22,7 @@ import org.l2jmobius.gameserver.handler.DailyMissionHandler;
import handlers.dailymissionhandlers.BossDailyMissionHandler;
import handlers.dailymissionhandlers.FishingDailyMissionHandler;
import handlers.dailymissionhandlers.JoinClanDailyMissionHandler;
import handlers.dailymissionhandlers.LevelDailyMissionHandler;
import handlers.dailymissionhandlers.LoginMonthDailyMissionHandler;
import handlers.dailymissionhandlers.LoginWeekendDailyMissionHandler;
@ -46,6 +47,7 @@ public class DailyMissionMasterHandler
DailyMissionHandler.getInstance().registerHandler("siege", SiegeDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("boss", BossDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("fishing", FishingDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("joinclan", JoinClanDailyMissionHandler::new);
LOGGER.info(DailyMissionMasterHandler.class.getSimpleName() + ": Loaded " + DailyMissionHandler.getInstance().size() + " handlers.");
}
}

View File

@ -0,0 +1,81 @@
/*
* 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 handlers.dailymissionhandlers;
import java.util.function.Consumer;
import org.l2jmobius.gameserver.enums.DailyMissionStatus;
import org.l2jmobius.gameserver.handler.AbstractDailyMissionHandler;
import org.l2jmobius.gameserver.model.DailyMissionDataHolder;
import org.l2jmobius.gameserver.model.DailyMissionPlayerEntry;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.events.Containers;
import org.l2jmobius.gameserver.model.events.EventType;
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanCreate;
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanJoin;
import org.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener;
/**
* @author kamikadzz
*/
public class JoinClanDailyMissionHandler extends AbstractDailyMissionHandler
{
public JoinClanDailyMissionHandler(DailyMissionDataHolder holder)
{
super(holder);
}
@Override
public boolean isAvailable(Player player)
{
final DailyMissionPlayerEntry entry = getPlayerEntry(player.getObjectId(), false);
return (entry != null) && (entry.getStatus() == DailyMissionStatus.AVAILABLE);
}
@Override
public void init()
{
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_CLAN_JOIN, (Consumer<OnPlayerClanJoin>) this::onPlayerClanJoin, this));
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_CLAN_CREATE, (Consumer<OnPlayerClanCreate>) this::onPlayerClanCreate, this));
}
private void onPlayerClanJoin(OnPlayerClanJoin event)
{
final DailyMissionPlayerEntry missionData = getPlayerEntry(event.getClanMember().getPlayer().getObjectId(), true);
processMission(missionData);
}
private void onPlayerClanCreate(OnPlayerClanCreate event)
{
final DailyMissionPlayerEntry missionData = getPlayerEntry(event.getPlayer().getObjectId(), true);
processMission(missionData);
}
private void processMission(DailyMissionPlayerEntry missionData)
{
if (missionData.getProgress() == 1)
{
missionData.setStatus(DailyMissionStatus.COMPLETED);
}
else
{
missionData.setProgress(1);
missionData.setStatus(DailyMissionStatus.AVAILABLE);
}
storePlayerEntry(missionData);
}
}

View File

@ -49,30 +49,14 @@ public class LoginMonthDailyMissionHandler extends AbstractDailyMissionHandler
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_LOGIN, (OnPlayerLogin event) -> onPlayerLogin(event), this));
}
@Override
public void reset()
{
// Monthly rewards do not reset daily.
}
private void onPlayerLogin(OnPlayerLogin event)
{
final DailyMissionPlayerEntry entry = getPlayerEntry(event.getPlayer().getObjectId(), true);
final long lastCompleted = entry.getLastCompleted();
if (lastCompleted == 0) // Initial entry.
{
entry.setLastCompleted(System.currentTimeMillis());
}
else if ((System.currentTimeMillis() - lastCompleted) > 2506000000L) // 2506000000L (29 day) delay.
if (entry.getStatus() != DailyMissionStatus.COMPLETED)
{
entry.setProgress(1);
entry.setStatus(DailyMissionStatus.AVAILABLE);
}
else
{
entry.setProgress(0);
entry.setStatus(DailyMissionStatus.NOT_AVAILABLE);
}
storePlayerEntry(entry);
}
}

View File

@ -51,27 +51,18 @@ public class LoginWeekendDailyMissionHandler extends AbstractDailyMissionHandler
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_LOGIN, (OnPlayerLogin event) -> onPlayerLogin(event), this));
}
@Override
public void reset()
{
// Weekend rewards do not reset daily.
}
private void onPlayerLogin(OnPlayerLogin event)
{
final DailyMissionPlayerEntry entry = getPlayerEntry(event.getPlayer().getObjectId(), true);
final int currentDay = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
final long lastCompleted = entry.getLastCompleted();
if (((currentDay == Calendar.SATURDAY) || (currentDay == Calendar.SUNDAY)) // Reward only on weekend.
&& ((lastCompleted == 0) || ((System.currentTimeMillis() - lastCompleted) > 172800000))) // Initial entry or 172800000 (2 day) delay.
if (entry.getStatus() != DailyMissionStatus.COMPLETED)
{
entry.setProgress(1);
entry.setStatus(DailyMissionStatus.AVAILABLE);
}
else if (entry.getStatus() != DailyMissionStatus.AVAILABLE) // Not waiting to be rewarded.
{
entry.setProgress(0);
entry.setStatus(DailyMissionStatus.NOT_AVAILABLE);
final int currentDay = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
if (((currentDay == Calendar.SATURDAY) || (currentDay == Calendar.SUNDAY) || (currentDay == Calendar.MONDAY)) //
&& (Calendar.getInstance().get(Calendar.HOUR_OF_DAY) < 6) && (Calendar.getInstance().get(Calendar.MINUTE) < 30))
{
entry.setProgress(1);
entry.setStatus(DailyMissionStatus.AVAILABLE);
}
}
storePlayerEntry(entry);
}

View File

@ -39,6 +39,7 @@
<xs:attribute type="xs:int" name="requiredCompletion" />
<xs:attribute type="xs:boolean" name="dailyReset" />
<xs:attribute type="xs:boolean" name="isOneTime" />
<xs:attribute type="xs:string" name="duration" />
</xs:complexType>
<xs:complexType name="listType">
<xs:sequence>

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;
@ -39,6 +41,7 @@ public class DailyMissionDataHolder
private final boolean _dailyReset;
private final boolean _isOneTime;
private final AbstractDailyMissionHandler _handler;
private final MissionResetType _missionResetSlot;
public DailyMissionDataHolder(StatSet set)
{
@ -51,6 +54,7 @@ public class DailyMissionDataHolder
_dailyReset = set.getBoolean("dailyReset", true);
_isOneTime = set.getBoolean("isOneTime", true);
_handler = handler != null ? handler.apply(this) : null;
_missionResetSlot = set.getObject("duration", MissionResetType.class, MissionResetType.DAY);
}
public int getId()
@ -115,7 +119,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();
}
}
}
}

View File

@ -1633,20 +1633,18 @@
<item id="70777" count="1" />
</items>
</reward>
<!--
<reward id="224" reward_id="604" name="Login All Weekend" isMainClassOnly="false" isOneTime="false">
<reward id="224" reward_id="604" name="Login All Weekend" isMainClassOnly="false" requiredCompletion="1" isOneTime="false" duration="WEEKEND">
<handler name="loginweekend" />
<items>
<item id="29648" count="2" />
</items>
</reward>
<reward id="225" reward_id="605" name="Login All Month" isMainClassOnly="false" isOneTime="false">
<reward id="225" reward_id="605" name="Login All Month" isMainClassOnly="false" requiredCompletion="1" isOneTime="false" duration="MONTH">
<handler name="loginmonth" />
<items>
<item id="29648" count="4" />
</items>
</reward>
-->
<reward id="226" reward_id="606" name="Quest Mania" isMainClassOnly="false" requiredCompletion="2" isOneTime="false">
<handler name="quest" />
<items>
@ -1659,14 +1657,12 @@
<item id="29648" count="1" />
</items>
</reward>
<!--
<reward id="232" reward_id="612" name="Have you joined a clan?" isMainClassOnly="false" requiredCompletion="1" isOneTime="true">
<handler name="siege" />
<handler name="joinclan" />
<items>
<item id="29654" count="1" />
</items>
</reward>
-->
<reward id="233" reward_id="613" name="Olympiad Warrior" isMainClassOnly="false" requiredCompletion="1" isOneTime="false">
<handler name="olympiad" />
<items>

View File

@ -22,6 +22,7 @@ import org.l2jmobius.gameserver.handler.DailyMissionHandler;
import handlers.dailymissionhandlers.BossDailyMissionHandler;
import handlers.dailymissionhandlers.FishingDailyMissionHandler;
import handlers.dailymissionhandlers.JoinClanDailyMissionHandler;
import handlers.dailymissionhandlers.LevelDailyMissionHandler;
import handlers.dailymissionhandlers.LoginMonthDailyMissionHandler;
import handlers.dailymissionhandlers.LoginWeekendDailyMissionHandler;
@ -46,6 +47,7 @@ public class DailyMissionMasterHandler
DailyMissionHandler.getInstance().registerHandler("siege", SiegeDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("boss", BossDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("fishing", FishingDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("joinclan", JoinClanDailyMissionHandler::new);
LOGGER.info(DailyMissionMasterHandler.class.getSimpleName() + ": Loaded " + DailyMissionHandler.getInstance().size() + " handlers.");
}
}

View File

@ -0,0 +1,81 @@
/*
* 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 handlers.dailymissionhandlers;
import java.util.function.Consumer;
import org.l2jmobius.gameserver.enums.DailyMissionStatus;
import org.l2jmobius.gameserver.handler.AbstractDailyMissionHandler;
import org.l2jmobius.gameserver.model.DailyMissionDataHolder;
import org.l2jmobius.gameserver.model.DailyMissionPlayerEntry;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.events.Containers;
import org.l2jmobius.gameserver.model.events.EventType;
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanCreate;
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanJoin;
import org.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener;
/**
* @author kamikadzz
*/
public class JoinClanDailyMissionHandler extends AbstractDailyMissionHandler
{
public JoinClanDailyMissionHandler(DailyMissionDataHolder holder)
{
super(holder);
}
@Override
public boolean isAvailable(Player player)
{
final DailyMissionPlayerEntry entry = getPlayerEntry(player.getObjectId(), false);
return (entry != null) && (entry.getStatus() == DailyMissionStatus.AVAILABLE);
}
@Override
public void init()
{
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_CLAN_JOIN, (Consumer<OnPlayerClanJoin>) this::onPlayerClanJoin, this));
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_CLAN_CREATE, (Consumer<OnPlayerClanCreate>) this::onPlayerClanCreate, this));
}
private void onPlayerClanJoin(OnPlayerClanJoin event)
{
final DailyMissionPlayerEntry missionData = getPlayerEntry(event.getClanMember().getPlayer().getObjectId(), true);
processMission(missionData);
}
private void onPlayerClanCreate(OnPlayerClanCreate event)
{
final DailyMissionPlayerEntry missionData = getPlayerEntry(event.getPlayer().getObjectId(), true);
processMission(missionData);
}
private void processMission(DailyMissionPlayerEntry missionData)
{
if (missionData.getProgress() == 1)
{
missionData.setStatus(DailyMissionStatus.COMPLETED);
}
else
{
missionData.setProgress(1);
missionData.setStatus(DailyMissionStatus.AVAILABLE);
}
storePlayerEntry(missionData);
}
}

View File

@ -49,30 +49,14 @@ public class LoginMonthDailyMissionHandler extends AbstractDailyMissionHandler
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_LOGIN, (OnPlayerLogin event) -> onPlayerLogin(event), this));
}
@Override
public void reset()
{
// Monthly rewards do not reset daily.
}
private void onPlayerLogin(OnPlayerLogin event)
{
final DailyMissionPlayerEntry entry = getPlayerEntry(event.getPlayer().getObjectId(), true);
final long lastCompleted = entry.getLastCompleted();
if (lastCompleted == 0) // Initial entry.
{
entry.setLastCompleted(System.currentTimeMillis());
}
else if ((System.currentTimeMillis() - lastCompleted) > 2506000000L) // 2506000000L (29 day) delay.
if (entry.getStatus() != DailyMissionStatus.COMPLETED)
{
entry.setProgress(1);
entry.setStatus(DailyMissionStatus.AVAILABLE);
}
else
{
entry.setProgress(0);
entry.setStatus(DailyMissionStatus.NOT_AVAILABLE);
}
storePlayerEntry(entry);
}
}

View File

@ -51,27 +51,18 @@ public class LoginWeekendDailyMissionHandler extends AbstractDailyMissionHandler
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_LOGIN, (OnPlayerLogin event) -> onPlayerLogin(event), this));
}
@Override
public void reset()
{
// Weekend rewards do not reset daily.
}
private void onPlayerLogin(OnPlayerLogin event)
{
final DailyMissionPlayerEntry entry = getPlayerEntry(event.getPlayer().getObjectId(), true);
final int currentDay = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
final long lastCompleted = entry.getLastCompleted();
if (((currentDay == Calendar.SATURDAY) || (currentDay == Calendar.SUNDAY)) // Reward only on weekend.
&& ((lastCompleted == 0) || ((System.currentTimeMillis() - lastCompleted) > 172800000))) // Initial entry or 172800000 (2 day) delay.
if (entry.getStatus() != DailyMissionStatus.COMPLETED)
{
entry.setProgress(1);
entry.setStatus(DailyMissionStatus.AVAILABLE);
}
else if (entry.getStatus() != DailyMissionStatus.AVAILABLE) // Not waiting to be rewarded.
{
entry.setProgress(0);
entry.setStatus(DailyMissionStatus.NOT_AVAILABLE);
final int currentDay = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
if (((currentDay == Calendar.SATURDAY) || (currentDay == Calendar.SUNDAY) || (currentDay == Calendar.MONDAY)) //
&& (Calendar.getInstance().get(Calendar.HOUR_OF_DAY) < 6) && (Calendar.getInstance().get(Calendar.MINUTE) < 30))
{
entry.setProgress(1);
entry.setStatus(DailyMissionStatus.AVAILABLE);
}
}
storePlayerEntry(entry);
}

View File

@ -42,6 +42,7 @@
<xs:attribute type="xs:boolean" name="isMainClassOnly" />
<xs:attribute type="xs:boolean" name="isDualClassOnly" />
<xs:attribute type="xs:boolean" name="isDisplayedWhenNotAvailable" />
<xs:attribute type="xs:string" name="duration" />
</xs:complexType>
<xs:complexType name="listType">
<xs:sequence>

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()
@ -166,7 +170,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();
}
}
}
}

View File

@ -1632,13 +1632,13 @@
<item id="70777" count="1" />
</items>
</reward>
<reward id="224" reward_id="604" name="Login All Weekend" isMainClassOnly="false" isOneTime="false">
<reward id="224" reward_id="604" name="Login All Weekend" isMainClassOnly="false" requiredCompletion="1" isOneTime="false" duration="WEEKEND">
<handler name="loginweekend" />
<items>
<item id="29648" count="2" />
</items>
</reward>
<reward id="225" reward_id="605" name="Login All Month" isMainClassOnly="false" isOneTime="false">
<reward id="225" reward_id="605" name="Login All Month" isMainClassOnly="false" requiredCompletion="1" isOneTime="false" duration="MONTH">
<handler name="loginmonth" />
<items>
<item id="29648" count="4" />
@ -1656,14 +1656,12 @@
<item id="29648" count="1" />
</items>
</reward>
<!--
<reward id="232" reward_id="612" name="Have you joined a clan?" isMainClassOnly="false" requiredCompletion="1" isOneTime="true">
<handler name="siege" />
<handler name="joinclan" />
<items>
<item id="29654" count="1" />
</items>
</reward>
-->
<reward id="233" reward_id="613" name="Olympiad Warrior" isMainClassOnly="false" requiredCompletion="1" isOneTime="false">
<handler name="olympiad" />
<items>

View File

@ -22,6 +22,7 @@ import org.l2jmobius.gameserver.handler.DailyMissionHandler;
import handlers.dailymissionhandlers.BossDailyMissionHandler;
import handlers.dailymissionhandlers.FishingDailyMissionHandler;
import handlers.dailymissionhandlers.JoinClanDailyMissionHandler;
import handlers.dailymissionhandlers.LevelDailyMissionHandler;
import handlers.dailymissionhandlers.LoginMonthDailyMissionHandler;
import handlers.dailymissionhandlers.LoginWeekendDailyMissionHandler;
@ -46,6 +47,7 @@ public class DailyMissionMasterHandler
DailyMissionHandler.getInstance().registerHandler("siege", SiegeDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("boss", BossDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("fishing", FishingDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("joinclan", JoinClanDailyMissionHandler::new);
LOGGER.info(DailyMissionMasterHandler.class.getSimpleName() + ": Loaded " + DailyMissionHandler.getInstance().size() + " handlers.");
}
}

View File

@ -0,0 +1,81 @@
/*
* 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 handlers.dailymissionhandlers;
import java.util.function.Consumer;
import org.l2jmobius.gameserver.enums.DailyMissionStatus;
import org.l2jmobius.gameserver.handler.AbstractDailyMissionHandler;
import org.l2jmobius.gameserver.model.DailyMissionDataHolder;
import org.l2jmobius.gameserver.model.DailyMissionPlayerEntry;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.events.Containers;
import org.l2jmobius.gameserver.model.events.EventType;
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanCreate;
import org.l2jmobius.gameserver.model.events.impl.creature.player.OnPlayerClanJoin;
import org.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener;
/**
* @author kamikadzz
*/
public class JoinClanDailyMissionHandler extends AbstractDailyMissionHandler
{
public JoinClanDailyMissionHandler(DailyMissionDataHolder holder)
{
super(holder);
}
@Override
public boolean isAvailable(Player player)
{
final DailyMissionPlayerEntry entry = getPlayerEntry(player.getObjectId(), false);
return (entry != null) && (entry.getStatus() == DailyMissionStatus.AVAILABLE);
}
@Override
public void init()
{
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_CLAN_JOIN, (Consumer<OnPlayerClanJoin>) this::onPlayerClanJoin, this));
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_CLAN_CREATE, (Consumer<OnPlayerClanCreate>) this::onPlayerClanCreate, this));
}
private void onPlayerClanJoin(OnPlayerClanJoin event)
{
final DailyMissionPlayerEntry missionData = getPlayerEntry(event.getClanMember().getPlayer().getObjectId(), true);
processMission(missionData);
}
private void onPlayerClanCreate(OnPlayerClanCreate event)
{
final DailyMissionPlayerEntry missionData = getPlayerEntry(event.getPlayer().getObjectId(), true);
processMission(missionData);
}
private void processMission(DailyMissionPlayerEntry missionData)
{
if (missionData.getProgress() == 1)
{
missionData.setStatus(DailyMissionStatus.COMPLETED);
}
else
{
missionData.setProgress(1);
missionData.setStatus(DailyMissionStatus.AVAILABLE);
}
storePlayerEntry(missionData);
}
}

View File

@ -49,30 +49,14 @@ public class LoginMonthDailyMissionHandler extends AbstractDailyMissionHandler
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_LOGIN, (OnPlayerLogin event) -> onPlayerLogin(event), this));
}
@Override
public void reset()
{
// Monthly rewards do not reset daily.
}
private void onPlayerLogin(OnPlayerLogin event)
{
final DailyMissionPlayerEntry entry = getPlayerEntry(event.getPlayer().getObjectId(), true);
final long lastCompleted = entry.getLastCompleted();
if (lastCompleted == 0) // Initial entry.
{
entry.setLastCompleted(System.currentTimeMillis());
}
else if ((System.currentTimeMillis() - lastCompleted) > 2506000000L) // 2506000000L (29 day) delay.
if (entry.getStatus() != DailyMissionStatus.COMPLETED)
{
entry.setProgress(1);
entry.setStatus(DailyMissionStatus.AVAILABLE);
}
else
{
entry.setProgress(0);
entry.setStatus(DailyMissionStatus.NOT_AVAILABLE);
}
storePlayerEntry(entry);
}
}

View File

@ -51,27 +51,18 @@ public class LoginWeekendDailyMissionHandler extends AbstractDailyMissionHandler
Containers.Global().addListener(new ConsumerEventListener(this, EventType.ON_PLAYER_LOGIN, (OnPlayerLogin event) -> onPlayerLogin(event), this));
}
@Override
public void reset()
{
// Weekend rewards do not reset daily.
}
private void onPlayerLogin(OnPlayerLogin event)
{
final DailyMissionPlayerEntry entry = getPlayerEntry(event.getPlayer().getObjectId(), true);
final int currentDay = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
final long lastCompleted = entry.getLastCompleted();
if (((currentDay == Calendar.SATURDAY) || (currentDay == Calendar.SUNDAY)) // Reward only on weekend.
&& ((lastCompleted == 0) || ((System.currentTimeMillis() - lastCompleted) > 172800000))) // Initial entry or 172800000 (2 day) delay.
if (entry.getStatus() != DailyMissionStatus.COMPLETED)
{
entry.setProgress(1);
entry.setStatus(DailyMissionStatus.AVAILABLE);
}
else if (entry.getStatus() != DailyMissionStatus.AVAILABLE) // Not waiting to be rewarded.
{
entry.setProgress(0);
entry.setStatus(DailyMissionStatus.NOT_AVAILABLE);
final int currentDay = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
if (((currentDay == Calendar.SATURDAY) || (currentDay == Calendar.SUNDAY) || (currentDay == Calendar.MONDAY)) //
&& (Calendar.getInstance().get(Calendar.HOUR_OF_DAY) < 6) && (Calendar.getInstance().get(Calendar.MINUTE) < 30))
{
entry.setProgress(1);
entry.setStatus(DailyMissionStatus.AVAILABLE);
}
}
storePlayerEntry(entry);
}

View File

@ -42,6 +42,7 @@
<xs:attribute type="xs:boolean" name="isMainClassOnly" />
<xs:attribute type="xs:boolean" name="isDualClassOnly" />
<xs:attribute type="xs:boolean" name="isDisplayedWhenNotAvailable" />
<xs:attribute type="xs:string" name="duration" />
</xs:complexType>
<xs:complexType name="listType">
<xs:sequence>

Some files were not shown because too many files have changed in this diff Show More