Addition of Clan Missions.

This commit is contained in:
MobiusDevelopment
2019-10-31 18:00:37 +00:00
parent 39f8ea0c4c
commit 89d48d9913
52 changed files with 3300 additions and 1178 deletions

View File

@ -27,10 +27,12 @@ import java.util.logging.Logger;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.enums.DailyMissionStatus;
import org.l2jmobius.gameserver.enums.SpecialItemType;
import org.l2jmobius.gameserver.model.DailyMissionDataHolder;
import org.l2jmobius.gameserver.model.DailyMissionPlayerEntry;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.events.ListenersContainer;
import org.l2jmobius.gameserver.model.holders.ItemHolder;
/**
* @author Sdw
@ -55,6 +57,11 @@ public abstract class AbstractDailyMissionHandler extends ListenersContainer
public abstract boolean isAvailable(PlayerInstance player);
public boolean isLevelUpMission()
{
return false;
}
public abstract void init();
public int getStatus(PlayerInstance player)
@ -96,7 +103,7 @@ public abstract class AbstractDailyMissionHandler extends ListenersContainer
public boolean requestReward(PlayerInstance player)
{
if (isAvailable(player))
if (isAvailable(player) || isLevelUpMission())
{
giveRewards(player);
@ -113,7 +120,22 @@ public abstract class AbstractDailyMissionHandler extends ListenersContainer
protected void giveRewards(PlayerInstance player)
{
_holder.getRewards().forEach(i -> player.addItem("One Day Reward", i, player, true));
for (ItemHolder reward : _holder.getRewards())
{
if (reward.getId() == SpecialItemType.CLAN_REPUTATION.getClientId())
{
player.getClan().addReputationScore((int) reward.getCount(), true);
}
else if (reward.getId() == SpecialItemType.FAME.getClientId())
{
player.setFame(player.getFame() + (int) reward.getCount());
player.broadcastUserInfo();
}
else
{
player.addItem("Daily Reward", reward, player, true);
}
}
}
protected void storePlayerEntry(DailyMissionPlayerEntry entry)

View File

@ -163,6 +163,11 @@ public class DailyMissionDataHolder
return (_handler != null) && _handler.getRecentlyCompleted(player);
}
public boolean isLevelUpMission()
{
return (_handler != null) && _handler.isLevelUpMission();
}
public void reset()
{
if (_handler != null)

View File

@ -88,6 +88,8 @@ import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeLe
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeMasteryInfo;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeMasteryReset;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeMasterySet;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeMissionInfo;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeMissionReward;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeSkillActivate;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeSkillInfo;
import org.l2jmobius.gameserver.network.clientpackets.primeshop.RequestBRBuyProduct;
@ -424,8 +426,8 @@ public enum ExIncomingPackets implements IIncomingPackets<GameClient>
EX_PLEDGE_CONTRIBUTION_INFO(0x13F, null, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_REWARD(0x140, null, ConnectionState.IN_GAME),
EX_PLEDGE_LEVEL_UP(0x141, RequestExPledgeLevelUp::new, ConnectionState.IN_GAME),
EX_PLEDGE_MISSION_INFO(0x142, null, ConnectionState.IN_GAME),
EX_PLEDGE_MISSION_REWARD(0x143, null, ConnectionState.IN_GAME),
EX_PLEDGE_MISSION_INFO(0x142, RequestExPledgeMissionInfo::new, ConnectionState.IN_GAME),
EX_PLEDGE_MISSION_REWARD(0x143, RequestExPledgeMissionReward::new, ConnectionState.IN_GAME),
EX_PLEDGE_MASTERY_INFO(0x144, RequestExPledgeMasteryInfo::new, ConnectionState.IN_GAME),
EX_PLEDGE_MASTERY_SET(0x145, RequestExPledgeMasterySet::new, ConnectionState.IN_GAME),
EX_PLEDGE_MASTERY_RESET(0x146, RequestExPledgeMasteryReset::new, ConnectionState.IN_GAME),

View File

@ -624,9 +624,6 @@ public class EnterWorld implements IClientIncomingPacket
{
player.sendPacket(new ExWorldChatCnt(player));
}
// Removed used by new Clan system.
// player.sendPacket(new ExConnectedTimeAndGettableReward(player));
// player.sendPacket(new ExOneDayReceiveRewardList(player, true));
// Handle soulshots, disable all on EnterWorld
player.sendPacket(new ExAutoSoulShot(0, true, 0));

View File

@ -1,71 +0,0 @@
/*
* 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.network.clientpackets.dailymission;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.dailymission.ExOneDayReceiveRewardList;
/**
* @author UnAfraid
*/
public class RequestTodoList implements IClientIncomingPacket
{
private int _tab;
@SuppressWarnings("unused")
private boolean _showAllLevels;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_tab = packet.readC(); // Daily Reward = 9, Event = 1, Instance Zone = 2
_showAllLevels = packet.readC() == 1; // Disabled = 0, Enabled = 1
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
switch (_tab)
{
// case 1:
// {
// player.sendPacket(new ExTodoListInzone());
// break;
// }
// case 2:
// {
// player.sendPacket(new ExTodoListInzone());
// break;
// }
case 9: // Daily Rewards
{
// Initial EW request should be false
player.sendPacket(new ExOneDayReceiveRewardList(player, true));
break;
}
}
}
}

View File

@ -14,32 +14,37 @@
* 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.network.clientpackets.dailymission;
package org.l2jmobius.gameserver.network.clientpackets.pledgeV2;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.pledgeV2.ExPledgeMissionInfo;
import org.l2jmobius.gameserver.network.serverpackets.pledgeV2.ExPledgeMissionRewardCount;
/**
* @author Mobius
*/
public class RequestTodoListHTML implements IClientIncomingPacket
* @author Bonux (bonuxq@gmail.com)
* @date 29.09.2019
**/
public class RequestExPledgeMissionInfo implements IClientIncomingPacket
{
@SuppressWarnings("unused")
private int _tab;
@SuppressWarnings("unused")
private String _linkName;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_tab = packet.readC();
_linkName = packet.readS();
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
client.sendPacket(new ExPledgeMissionRewardCount(player));
client.sendPacket(new ExPledgeMissionInfo(player));
}
}

View File

@ -1,62 +1,63 @@
/*
* 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.network.clientpackets.dailymission;
import java.util.Collection;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.data.xml.impl.DailyMissionData;
import org.l2jmobius.gameserver.model.DailyMissionDataHolder;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.dailymission.ExOneDayReceiveRewardList;
/**
* @author Sdw
*/
public class RequestOneDayRewardReceive implements IClientIncomingPacket
{
private int _id;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_id = packet.readH();
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
final Collection<DailyMissionDataHolder> reward = DailyMissionData.getInstance().getDailyMissionData(_id);
if ((reward == null) || reward.isEmpty())
{
return;
}
reward.stream().filter(o -> o.isDisplayable(player)).forEach(r -> r.requestReward(player));
// player.sendPacket(new ExConnectedTimeAndGettableReward(player));
player.sendPacket(new ExOneDayReceiveRewardList(player, true));
}
}
/*
* 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.network.clientpackets.pledgeV2;
import java.util.Collection;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.data.xml.impl.DailyMissionData;
import org.l2jmobius.gameserver.model.DailyMissionDataHolder;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.pledgeV2.ExPledgeMissionInfo;
import org.l2jmobius.gameserver.network.serverpackets.pledgeV2.ExPledgeMissionRewardCount;
/**
* @author Mobius
*/
public class RequestExPledgeMissionReward implements IClientIncomingPacket
{
private int _id;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_id = packet.readD();
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if ((player == null) || (player.getClan() == null))
{
return;
}
final Collection<DailyMissionDataHolder> reward = DailyMissionData.getInstance().getDailyMissionData(_id);
if ((reward == null) || reward.isEmpty())
{
return;
}
reward.stream().filter(o -> o.isDisplayable(player)).forEach(r -> r.requestReward(player));
client.sendPacket(new ExPledgeMissionRewardCount(player));
client.sendPacket(new ExPledgeMissionInfo(player));
}
}

View File

@ -1,81 +0,0 @@
/*
* 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.network.serverpackets.dailymission;
import java.time.LocalDate;
import java.util.Collection;
import java.util.Collections;
import java.util.function.Function;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.data.xml.impl.DailyMissionData;
import org.l2jmobius.gameserver.model.DailyMissionDataHolder;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
import org.l2jmobius.gameserver.util.cron4j.Predictor;
/**
* @author Sdw
*/
public class ExOneDayReceiveRewardList implements IClientOutgoingPacket
{
final PlayerInstance _player;
private final Collection<DailyMissionDataHolder> _rewards;
private static final Function<String, Long> _remainTime = pattern -> (new Predictor(pattern).nextMatchingTime() - System.currentTimeMillis()) / 1000;
private final long _dayRemainTime;
private final long _weekRemainTime;
private final long _monthRemainTime;
public ExOneDayReceiveRewardList(PlayerInstance player, boolean sendRewards)
{
_player = player;
_rewards = sendRewards ? DailyMissionData.getInstance().getDailyMissionData(player) : Collections.emptyList();
_dayRemainTime = _remainTime.apply("30 6 * * *");
_weekRemainTime = _remainTime.apply("30 6 * * 1");
_monthRemainTime = _remainTime.apply("30 6 1 * *");
}
@Override
public boolean write(PacketWriter packet)
{
if (!DailyMissionData.getInstance().isAvailable())
{
return true;
}
OutgoingPackets.EX_ONE_DAY_RECEIVE_REWARD_LIST.writeId(packet);
packet.writeD((int) _dayRemainTime);
packet.writeD((int) _weekRemainTime);
packet.writeD((int) _monthRemainTime);
packet.writeC(0x17);
packet.writeD(_player.getClassId().getId());
packet.writeD(LocalDate.now().getDayOfWeek().ordinal()); // Day of week
packet.writeD(_rewards.size());
for (DailyMissionDataHolder reward : _rewards)
{
packet.writeH(reward.getId());
packet.writeC(reward.getStatus(_player));
packet.writeC(reward.getRequiredCompletions() > 1 ? 0x01 : 0x00);
packet.writeD(Math.min(reward.getProgress(_player), _player.getLevel()));
packet.writeD(reward.getRequiredCompletions());
}
return true;
}
}

View File

@ -0,0 +1,94 @@
/*
* 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.network.serverpackets.pledgeV2;
import java.util.Collection;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.data.xml.impl.DailyMissionData;
import org.l2jmobius.gameserver.model.DailyMissionDataHolder;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class ExPledgeMissionInfo implements IClientOutgoingPacket
{
private final PlayerInstance _player;
private final Collection<DailyMissionDataHolder> _rewards;
public ExPledgeMissionInfo(PlayerInstance player)
{
_player = player;
_rewards = DailyMissionData.getInstance().getDailyMissionData(player);
}
@Override
public boolean write(PacketWriter packet)
{
if (!DailyMissionData.getInstance().isAvailable() || (_player.getClan() == null))
{
return true;
}
OutgoingPackets.EX_PLEDGE_MISSION_INFO.writeId(packet);
packet.writeD(_rewards.size());
for (DailyMissionDataHolder reward : _rewards)
{
int progress = reward.getProgress(_player);
int status = reward.getStatus(_player);
// TODO: Figure out this.
if (reward.isLevelUpMission())
{
progress = 1;
if (status == 2)
{
if (reward.getRequiredCompletions() <= _player.getLevel())
{
status = 3;
}
else
{
status = 1;
}
}
else
{
status = 0;
}
}
else if (status == 1)
{
status = 3;
}
else if (status == 3)
{
status = 2;
}
packet.writeD(reward.getId());
packet.writeD(progress);
packet.writeC(status);
}
return true;
}
}

View File

@ -1,60 +1,50 @@
/*
* 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.network.serverpackets.dailymission;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.data.xml.impl.DailyMissionData;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Sdw
*/
public class ExConnectedTimeAndGettableReward implements IClientOutgoingPacket
{
private final int _oneDayRewardAvailableCount;
public ExConnectedTimeAndGettableReward(PlayerInstance player)
{
_oneDayRewardAvailableCount = DailyMissionData.getInstance().getDailyMissionData(player).size();
}
@Override
public boolean write(PacketWriter packet)
{
if (!DailyMissionData.getInstance().isAvailable())
{
return true;
}
OutgoingPackets.EX_CONNECTED_TIME_AND_GETTABLE_REWARD.writeId(packet);
packet.writeD(0x00);
packet.writeD(_oneDayRewardAvailableCount);
packet.writeD(0x00);
packet.writeD(0x00);
packet.writeD(0x00);
packet.writeD(0x00);
packet.writeD(0x00);
packet.writeD(0x00);
packet.writeD(0x00);
packet.writeD(0x00);
packet.writeD(0x00);
packet.writeD(0x00);
return true;
}
}
/*
* 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.network.serverpackets.pledgeV2;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.data.xml.impl.DailyMissionData;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Bonux (bonuxq@gmail.com)
* @date 29.09.2019
**/
public class ExPledgeMissionRewardCount implements IClientOutgoingPacket
{
private final int _doneMissionsCount;
private final int _availableMissionsCount;
public ExPledgeMissionRewardCount(PlayerInstance player)
{
_doneMissionsCount = (int) DailyMissionData.getInstance().getDailyMissionData(player).stream().filter(d -> d.getRecentlyCompleted(player)).count();
_availableMissionsCount = DailyMissionData.getInstance().getDailyMissionData(player).size();
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_PLEDGE_MISSION_REWARD_COUNT.writeId(packet);
packet.writeD(Math.min(_availableMissionsCount, _doneMissionsCount)); // Received missions rewards.
packet.writeD(_availableMissionsCount); // Available missions rewards. 18 - for noble, 20 - for honnorable noble.
return true;
}
}