Support for time limited clan mastery skills.
This commit is contained in:
parent
62cba84978
commit
dbe104cbc2
@ -27,6 +27,8 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentSkipListMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@ -154,6 +156,8 @@ public class Clan implements IIdentifiable, INamable
|
||||
private ClanRewardBonus _lastMembersOnlineBonus = null;
|
||||
private ClanRewardBonus _lastHuntingBonus = null;
|
||||
|
||||
private final List<ScheduledFuture<?>> masterySkillTasks = new CopyOnWriteArrayList<>();
|
||||
|
||||
private volatile ClanVariables _vars;
|
||||
|
||||
/**
|
||||
@ -178,6 +182,52 @@ public class Clan implements IIdentifiable, INamable
|
||||
{
|
||||
_lastHuntingBonus = availableHuntingBonus;
|
||||
}
|
||||
|
||||
final int masteryTime19538 = getMasterySkillRemainingTime(19538);
|
||||
if (masteryTime19538 > 0)
|
||||
{
|
||||
final ScheduledFuture<?> task = ThreadPool.schedule(() ->
|
||||
{
|
||||
removeMasterySkill(19538);
|
||||
}, masteryTime19538);
|
||||
masterySkillTasks.add(task);
|
||||
}
|
||||
final int masteryTime19539 = getMasterySkillRemainingTime(19539);
|
||||
if (masteryTime19539 > 0)
|
||||
{
|
||||
final ScheduledFuture<?> task = ThreadPool.schedule(() ->
|
||||
{
|
||||
removeMasterySkill(19539);
|
||||
}, masteryTime19539);
|
||||
masterySkillTasks.add(task);
|
||||
}
|
||||
final int masteryTime19540 = getMasterySkillRemainingTime(19540);
|
||||
if (masteryTime19540 > 0)
|
||||
{
|
||||
final ScheduledFuture<?> task = ThreadPool.schedule(() ->
|
||||
{
|
||||
removeMasterySkill(19540);
|
||||
}, masteryTime19540);
|
||||
masterySkillTasks.add(task);
|
||||
}
|
||||
final int masteryTime19541 = getMasterySkillRemainingTime(19541);
|
||||
if (masteryTime19541 > 0)
|
||||
{
|
||||
final ScheduledFuture<?> task = ThreadPool.schedule(() ->
|
||||
{
|
||||
removeMasterySkill(19541);
|
||||
}, masteryTime19541);
|
||||
masterySkillTasks.add(task);
|
||||
}
|
||||
final int masteryTime19542 = getMasterySkillRemainingTime(19542);
|
||||
if (masteryTime19542 > 0)
|
||||
{
|
||||
final ScheduledFuture<?> task = ThreadPool.schedule(() ->
|
||||
{
|
||||
removeMasterySkill(19542);
|
||||
}, masteryTime19542);
|
||||
masterySkillTasks.add(task);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2803,6 +2853,46 @@ public class Clan implements IIdentifiable, INamable
|
||||
removeSkill(skill);
|
||||
}
|
||||
}
|
||||
for (ScheduledFuture<?> task : masterySkillTasks)
|
||||
{
|
||||
if ((task != null) && !task.isDone())
|
||||
{
|
||||
task.cancel(true);
|
||||
}
|
||||
}
|
||||
masterySkillTasks.clear();
|
||||
removeMasterySkill(19538);
|
||||
removeMasterySkill(19539);
|
||||
removeMasterySkill(19540);
|
||||
removeMasterySkill(19541);
|
||||
removeMasterySkill(19542);
|
||||
}
|
||||
|
||||
public void addMasterySkill(int id)
|
||||
{
|
||||
getVariables().set(ClanVariables.CLAN_MASTERY_SKILL_TIME + id, System.currentTimeMillis() + 1296000000);
|
||||
final ScheduledFuture<?> task = ThreadPool.schedule(() ->
|
||||
{
|
||||
removeMasterySkill(id);
|
||||
}, 1296000000); // 1296000000 = 15 days
|
||||
masterySkillTasks.add(task);
|
||||
addNewSkill(SkillData.getInstance().getSkill(id, 1));
|
||||
}
|
||||
|
||||
public void removeMasterySkill(int id)
|
||||
{
|
||||
getVariables().remove(ClanVariables.CLAN_MASTERY_SKILL_TIME + id);
|
||||
removeSkill(SkillData.getInstance().getSkill(id, 1));
|
||||
}
|
||||
|
||||
public int getMasterySkillRemainingTime(int id)
|
||||
{
|
||||
final long endTime = getVariables().getLong(ClanVariables.CLAN_MASTERY_SKILL_TIME + id, 0);
|
||||
if (endTime == 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return (int) (endTime - System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public void setDevelopmentPoints(int count)
|
||||
|
@ -41,6 +41,7 @@ public class ClanVariables extends AbstractVariables
|
||||
// Public variables.
|
||||
public static final String CLAN_DEVELOPMENT_POINTS = "CLAN_DEVELOPMENT_POINTS";
|
||||
public static final String CLAN_MASTERY = "CLAN_MASTERY_";
|
||||
public static final String CLAN_MASTERY_SKILL_TIME = "CLAN_MASTERY_SKILL_TIME_";
|
||||
|
||||
private final int _objectId;
|
||||
|
||||
|
@ -88,6 +88,7 @@ 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.RequestExPledgeSkillActivate;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeSkillInfo;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.pledgebonus.RequestPledgeBonusOpen;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.pledgebonus.RequestPledgeBonusReward;
|
||||
@ -432,7 +433,7 @@ public enum ExIncomingPackets implements IIncomingPackets<GameClient>
|
||||
EX_PLEDGE_MASTERY_SET(0x145, RequestExPledgeMasterySet::new, ConnectionState.IN_GAME),
|
||||
EX_PLEDGE_MASTERY_RESET(0x146, RequestExPledgeMasteryReset::new, ConnectionState.IN_GAME),
|
||||
EX_PLEDGE_SKILL_INFO(0x147, RequestExPledgeSkillInfo::new, ConnectionState.IN_GAME),
|
||||
EX_PLEDGE_SKILL_ACTIVATE(0x148, null, ConnectionState.IN_GAME),
|
||||
EX_PLEDGE_SKILL_ACTIVATE(0x148, RequestExPledgeSkillActivate::new, ConnectionState.IN_GAME),
|
||||
EX_PLEDGE_ITEM_LIST(0x149, RequestExPledgeItemList::new, ConnectionState.IN_GAME),
|
||||
EX_PLEDGE_ITEM_ACTIVATE(0x14A, null, ConnectionState.IN_GAME),
|
||||
EX_PLEDGE_ANNOUNCE(0x14B, RequestExPledgeAnnounce::new, ConnectionState.IN_GAME),
|
||||
|
@ -100,6 +100,7 @@ public class RequestExPledgeMasterySet implements IClientIncomingPacket
|
||||
}
|
||||
|
||||
// Learn.
|
||||
clan.takeReputationScore(mastery.getClanReputation(), true);
|
||||
clan.addMastery(mastery.getId());
|
||||
clan.setDevelopmentPoints(clan.getUsedDevelopmentPoints() + 1);
|
||||
for (Skill skill : mastery.getSkills())
|
||||
|
@ -0,0 +1,118 @@
|
||||
/*
|
||||
* 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 org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.pledgeV2.ExPledgeSkillInfo;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class RequestExPledgeSkillActivate implements IClientIncomingPacket
|
||||
{
|
||||
private int _skillId;
|
||||
|
||||
@Override
|
||||
public boolean read(GameClient client, PacketReader packet)
|
||||
{
|
||||
_skillId = packet.readD();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(GameClient client)
|
||||
{
|
||||
final PlayerInstance player = client.getPlayer();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
final Clan clan = player.getClan();
|
||||
if (clan == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (player.getObjectId() != clan.getLeaderId())
|
||||
{
|
||||
player.sendMessage("You do not have enough privileges to take this action.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if already enabled.
|
||||
if (clan.getMasterySkillRemainingTime(_skillId) > 0)
|
||||
{
|
||||
clan.removeMasterySkill(_skillId);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if it can be learned.
|
||||
int previous = 0;
|
||||
int cost = 0;
|
||||
switch (_skillId)
|
||||
{
|
||||
case 19538:
|
||||
{
|
||||
previous = 4;
|
||||
cost = 40000;
|
||||
break;
|
||||
}
|
||||
case 19539:
|
||||
{
|
||||
previous = 9;
|
||||
cost = 30000;
|
||||
break;
|
||||
}
|
||||
case 19540:
|
||||
{
|
||||
previous = 11;
|
||||
cost = 50000;
|
||||
break;
|
||||
}
|
||||
case 19541:
|
||||
{
|
||||
previous = 14;
|
||||
cost = 30000;
|
||||
break;
|
||||
}
|
||||
case 19542:
|
||||
{
|
||||
previous = 16;
|
||||
cost = 50000;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (clan.getReputationScore() < cost)
|
||||
{
|
||||
player.sendMessage("Your clan reputation is lower than the requirement.");
|
||||
return;
|
||||
}
|
||||
if (!clan.hasMastery(previous))
|
||||
{
|
||||
player.sendMessage("You need to learn the previous mastery.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Learn.
|
||||
clan.takeReputationScore(cost, true);
|
||||
clan.addMasterySkill(_skillId);
|
||||
player.sendPacket(new ExPledgeSkillInfo(_skillId, 1, 1296000, 2));
|
||||
}
|
||||
}
|
@ -53,6 +53,47 @@ public class RequestExPledgeSkillInfo implements IClientIncomingPacket
|
||||
return;
|
||||
}
|
||||
|
||||
client.sendPacket(new ExPledgeSkillInfo(_skillId, _skillLevel, -1, 0));
|
||||
int previous = 0;
|
||||
switch (_skillId)
|
||||
{
|
||||
case 19538:
|
||||
{
|
||||
previous = 4;
|
||||
break;
|
||||
}
|
||||
case 19539:
|
||||
{
|
||||
previous = 9;
|
||||
break;
|
||||
}
|
||||
case 19540:
|
||||
{
|
||||
previous = 11;
|
||||
break;
|
||||
}
|
||||
case 19541:
|
||||
{
|
||||
previous = 14;
|
||||
break;
|
||||
}
|
||||
case 19542:
|
||||
{
|
||||
previous = 16;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int time = -1;
|
||||
int available = 0;
|
||||
final int remainingTime = clan.getMasterySkillRemainingTime(_skillId);
|
||||
if (remainingTime > 0)
|
||||
{
|
||||
time = remainingTime / 1000;
|
||||
available = 2;
|
||||
}
|
||||
else if (clan.hasMastery(previous))
|
||||
{
|
||||
available = 1;
|
||||
}
|
||||
client.sendPacket(new ExPledgeSkillInfo(_skillId, _skillLevel, time, available));
|
||||
}
|
||||
}
|
@ -27,6 +27,8 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentSkipListMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@ -154,6 +156,8 @@ public class Clan implements IIdentifiable, INamable
|
||||
private ClanRewardBonus _lastMembersOnlineBonus = null;
|
||||
private ClanRewardBonus _lastHuntingBonus = null;
|
||||
|
||||
private final List<ScheduledFuture<?>> masterySkillTasks = new CopyOnWriteArrayList<>();
|
||||
|
||||
private volatile ClanVariables _vars;
|
||||
|
||||
/**
|
||||
@ -178,6 +182,52 @@ public class Clan implements IIdentifiable, INamable
|
||||
{
|
||||
_lastHuntingBonus = availableHuntingBonus;
|
||||
}
|
||||
|
||||
final int masteryTime19538 = getMasterySkillRemainingTime(19538);
|
||||
if (masteryTime19538 > 0)
|
||||
{
|
||||
final ScheduledFuture<?> task = ThreadPool.schedule(() ->
|
||||
{
|
||||
removeMasterySkill(19538);
|
||||
}, masteryTime19538);
|
||||
masterySkillTasks.add(task);
|
||||
}
|
||||
final int masteryTime19539 = getMasterySkillRemainingTime(19539);
|
||||
if (masteryTime19539 > 0)
|
||||
{
|
||||
final ScheduledFuture<?> task = ThreadPool.schedule(() ->
|
||||
{
|
||||
removeMasterySkill(19539);
|
||||
}, masteryTime19539);
|
||||
masterySkillTasks.add(task);
|
||||
}
|
||||
final int masteryTime19540 = getMasterySkillRemainingTime(19540);
|
||||
if (masteryTime19540 > 0)
|
||||
{
|
||||
final ScheduledFuture<?> task = ThreadPool.schedule(() ->
|
||||
{
|
||||
removeMasterySkill(19540);
|
||||
}, masteryTime19540);
|
||||
masterySkillTasks.add(task);
|
||||
}
|
||||
final int masteryTime19541 = getMasterySkillRemainingTime(19541);
|
||||
if (masteryTime19541 > 0)
|
||||
{
|
||||
final ScheduledFuture<?> task = ThreadPool.schedule(() ->
|
||||
{
|
||||
removeMasterySkill(19541);
|
||||
}, masteryTime19541);
|
||||
masterySkillTasks.add(task);
|
||||
}
|
||||
final int masteryTime19542 = getMasterySkillRemainingTime(19542);
|
||||
if (masteryTime19542 > 0)
|
||||
{
|
||||
final ScheduledFuture<?> task = ThreadPool.schedule(() ->
|
||||
{
|
||||
removeMasterySkill(19542);
|
||||
}, masteryTime19542);
|
||||
masterySkillTasks.add(task);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2803,6 +2853,46 @@ public class Clan implements IIdentifiable, INamable
|
||||
removeSkill(skill);
|
||||
}
|
||||
}
|
||||
for (ScheduledFuture<?> task : masterySkillTasks)
|
||||
{
|
||||
if ((task != null) && !task.isDone())
|
||||
{
|
||||
task.cancel(true);
|
||||
}
|
||||
}
|
||||
masterySkillTasks.clear();
|
||||
removeMasterySkill(19538);
|
||||
removeMasterySkill(19539);
|
||||
removeMasterySkill(19540);
|
||||
removeMasterySkill(19541);
|
||||
removeMasterySkill(19542);
|
||||
}
|
||||
|
||||
public void addMasterySkill(int id)
|
||||
{
|
||||
getVariables().set(ClanVariables.CLAN_MASTERY_SKILL_TIME + id, System.currentTimeMillis() + 1296000000);
|
||||
final ScheduledFuture<?> task = ThreadPool.schedule(() ->
|
||||
{
|
||||
removeMasterySkill(id);
|
||||
}, 1296000000); // 1296000000 = 15 days
|
||||
masterySkillTasks.add(task);
|
||||
addNewSkill(SkillData.getInstance().getSkill(id, 1));
|
||||
}
|
||||
|
||||
public void removeMasterySkill(int id)
|
||||
{
|
||||
getVariables().remove(ClanVariables.CLAN_MASTERY_SKILL_TIME + id);
|
||||
removeSkill(SkillData.getInstance().getSkill(id, 1));
|
||||
}
|
||||
|
||||
public int getMasterySkillRemainingTime(int id)
|
||||
{
|
||||
final long endTime = getVariables().getLong(ClanVariables.CLAN_MASTERY_SKILL_TIME + id, 0);
|
||||
if (endTime == 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return (int) (endTime - System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public void setDevelopmentPoints(int count)
|
||||
|
@ -41,6 +41,7 @@ public class ClanVariables extends AbstractVariables
|
||||
// Public variables.
|
||||
public static final String CLAN_DEVELOPMENT_POINTS = "CLAN_DEVELOPMENT_POINTS";
|
||||
public static final String CLAN_MASTERY = "CLAN_MASTERY_";
|
||||
public static final String CLAN_MASTERY_SKILL_TIME = "CLAN_MASTERY_SKILL_TIME_";
|
||||
|
||||
private final int _objectId;
|
||||
|
||||
|
@ -88,6 +88,7 @@ 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.RequestExPledgeSkillActivate;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeSkillInfo;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.pledgebonus.RequestPledgeBonusOpen;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.pledgebonus.RequestPledgeBonusReward;
|
||||
@ -432,7 +433,7 @@ public enum ExIncomingPackets implements IIncomingPackets<GameClient>
|
||||
EX_PLEDGE_MASTERY_SET(0x145, RequestExPledgeMasterySet::new, ConnectionState.IN_GAME),
|
||||
EX_PLEDGE_MASTERY_RESET(0x146, RequestExPledgeMasteryReset::new, ConnectionState.IN_GAME),
|
||||
EX_PLEDGE_SKILL_INFO(0x147, RequestExPledgeSkillInfo::new, ConnectionState.IN_GAME),
|
||||
EX_PLEDGE_SKILL_ACTIVATE(0x148, null, ConnectionState.IN_GAME),
|
||||
EX_PLEDGE_SKILL_ACTIVATE(0x148, RequestExPledgeSkillActivate::new, ConnectionState.IN_GAME),
|
||||
EX_PLEDGE_ITEM_LIST(0x149, RequestExPledgeItemList::new, ConnectionState.IN_GAME),
|
||||
EX_PLEDGE_ITEM_ACTIVATE(0x14A, null, ConnectionState.IN_GAME),
|
||||
EX_PLEDGE_ANNOUNCE(0x14B, RequestExPledgeAnnounce::new, ConnectionState.IN_GAME),
|
||||
|
@ -100,6 +100,7 @@ public class RequestExPledgeMasterySet implements IClientIncomingPacket
|
||||
}
|
||||
|
||||
// Learn.
|
||||
clan.takeReputationScore(mastery.getClanReputation(), true);
|
||||
clan.addMastery(mastery.getId());
|
||||
clan.setDevelopmentPoints(clan.getUsedDevelopmentPoints() + 1);
|
||||
for (Skill skill : mastery.getSkills())
|
||||
|
@ -0,0 +1,118 @@
|
||||
/*
|
||||
* 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 org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.pledgeV2.ExPledgeSkillInfo;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class RequestExPledgeSkillActivate implements IClientIncomingPacket
|
||||
{
|
||||
private int _skillId;
|
||||
|
||||
@Override
|
||||
public boolean read(GameClient client, PacketReader packet)
|
||||
{
|
||||
_skillId = packet.readD();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(GameClient client)
|
||||
{
|
||||
final PlayerInstance player = client.getPlayer();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
final Clan clan = player.getClan();
|
||||
if (clan == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (player.getObjectId() != clan.getLeaderId())
|
||||
{
|
||||
player.sendMessage("You do not have enough privileges to take this action.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if already enabled.
|
||||
if (clan.getMasterySkillRemainingTime(_skillId) > 0)
|
||||
{
|
||||
clan.removeMasterySkill(_skillId);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if it can be learned.
|
||||
int previous = 0;
|
||||
int cost = 0;
|
||||
switch (_skillId)
|
||||
{
|
||||
case 19538:
|
||||
{
|
||||
previous = 4;
|
||||
cost = 40000;
|
||||
break;
|
||||
}
|
||||
case 19539:
|
||||
{
|
||||
previous = 9;
|
||||
cost = 30000;
|
||||
break;
|
||||
}
|
||||
case 19540:
|
||||
{
|
||||
previous = 11;
|
||||
cost = 50000;
|
||||
break;
|
||||
}
|
||||
case 19541:
|
||||
{
|
||||
previous = 14;
|
||||
cost = 30000;
|
||||
break;
|
||||
}
|
||||
case 19542:
|
||||
{
|
||||
previous = 16;
|
||||
cost = 50000;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (clan.getReputationScore() < cost)
|
||||
{
|
||||
player.sendMessage("Your clan reputation is lower than the requirement.");
|
||||
return;
|
||||
}
|
||||
if (!clan.hasMastery(previous))
|
||||
{
|
||||
player.sendMessage("You need to learn the previous mastery.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Learn.
|
||||
clan.takeReputationScore(cost, true);
|
||||
clan.addMasterySkill(_skillId);
|
||||
player.sendPacket(new ExPledgeSkillInfo(_skillId, 1, 1296000, 2));
|
||||
}
|
||||
}
|
@ -53,6 +53,47 @@ public class RequestExPledgeSkillInfo implements IClientIncomingPacket
|
||||
return;
|
||||
}
|
||||
|
||||
client.sendPacket(new ExPledgeSkillInfo(_skillId, _skillLevel, -1, 0));
|
||||
int previous = 0;
|
||||
switch (_skillId)
|
||||
{
|
||||
case 19538:
|
||||
{
|
||||
previous = 4;
|
||||
break;
|
||||
}
|
||||
case 19539:
|
||||
{
|
||||
previous = 9;
|
||||
break;
|
||||
}
|
||||
case 19540:
|
||||
{
|
||||
previous = 11;
|
||||
break;
|
||||
}
|
||||
case 19541:
|
||||
{
|
||||
previous = 14;
|
||||
break;
|
||||
}
|
||||
case 19542:
|
||||
{
|
||||
previous = 16;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int time = -1;
|
||||
int available = 0;
|
||||
final int remainingTime = clan.getMasterySkillRemainingTime(_skillId);
|
||||
if (remainingTime > 0)
|
||||
{
|
||||
time = remainingTime / 1000;
|
||||
available = 2;
|
||||
}
|
||||
else if (clan.hasMastery(previous))
|
||||
{
|
||||
available = 1;
|
||||
}
|
||||
client.sendPacket(new ExPledgeSkillInfo(_skillId, _skillLevel, time, available));
|
||||
}
|
||||
}
|
@ -27,6 +27,8 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentSkipListMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@ -154,6 +156,8 @@ public class Clan implements IIdentifiable, INamable
|
||||
private ClanRewardBonus _lastMembersOnlineBonus = null;
|
||||
private ClanRewardBonus _lastHuntingBonus = null;
|
||||
|
||||
private final List<ScheduledFuture<?>> masterySkillTasks = new CopyOnWriteArrayList<>();
|
||||
|
||||
private volatile ClanVariables _vars;
|
||||
|
||||
/**
|
||||
@ -178,6 +182,52 @@ public class Clan implements IIdentifiable, INamable
|
||||
{
|
||||
_lastHuntingBonus = availableHuntingBonus;
|
||||
}
|
||||
|
||||
final int masteryTime19538 = getMasterySkillRemainingTime(19538);
|
||||
if (masteryTime19538 > 0)
|
||||
{
|
||||
final ScheduledFuture<?> task = ThreadPool.schedule(() ->
|
||||
{
|
||||
removeMasterySkill(19538);
|
||||
}, masteryTime19538);
|
||||
masterySkillTasks.add(task);
|
||||
}
|
||||
final int masteryTime19539 = getMasterySkillRemainingTime(19539);
|
||||
if (masteryTime19539 > 0)
|
||||
{
|
||||
final ScheduledFuture<?> task = ThreadPool.schedule(() ->
|
||||
{
|
||||
removeMasterySkill(19539);
|
||||
}, masteryTime19539);
|
||||
masterySkillTasks.add(task);
|
||||
}
|
||||
final int masteryTime19540 = getMasterySkillRemainingTime(19540);
|
||||
if (masteryTime19540 > 0)
|
||||
{
|
||||
final ScheduledFuture<?> task = ThreadPool.schedule(() ->
|
||||
{
|
||||
removeMasterySkill(19540);
|
||||
}, masteryTime19540);
|
||||
masterySkillTasks.add(task);
|
||||
}
|
||||
final int masteryTime19541 = getMasterySkillRemainingTime(19541);
|
||||
if (masteryTime19541 > 0)
|
||||
{
|
||||
final ScheduledFuture<?> task = ThreadPool.schedule(() ->
|
||||
{
|
||||
removeMasterySkill(19541);
|
||||
}, masteryTime19541);
|
||||
masterySkillTasks.add(task);
|
||||
}
|
||||
final int masteryTime19542 = getMasterySkillRemainingTime(19542);
|
||||
if (masteryTime19542 > 0)
|
||||
{
|
||||
final ScheduledFuture<?> task = ThreadPool.schedule(() ->
|
||||
{
|
||||
removeMasterySkill(19542);
|
||||
}, masteryTime19542);
|
||||
masterySkillTasks.add(task);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2803,6 +2853,46 @@ public class Clan implements IIdentifiable, INamable
|
||||
removeSkill(skill);
|
||||
}
|
||||
}
|
||||
for (ScheduledFuture<?> task : masterySkillTasks)
|
||||
{
|
||||
if ((task != null) && !task.isDone())
|
||||
{
|
||||
task.cancel(true);
|
||||
}
|
||||
}
|
||||
masterySkillTasks.clear();
|
||||
removeMasterySkill(19538);
|
||||
removeMasterySkill(19539);
|
||||
removeMasterySkill(19540);
|
||||
removeMasterySkill(19541);
|
||||
removeMasterySkill(19542);
|
||||
}
|
||||
|
||||
public void addMasterySkill(int id)
|
||||
{
|
||||
getVariables().set(ClanVariables.CLAN_MASTERY_SKILL_TIME + id, System.currentTimeMillis() + 1296000000);
|
||||
final ScheduledFuture<?> task = ThreadPool.schedule(() ->
|
||||
{
|
||||
removeMasterySkill(id);
|
||||
}, 1296000000); // 1296000000 = 15 days
|
||||
masterySkillTasks.add(task);
|
||||
addNewSkill(SkillData.getInstance().getSkill(id, 1));
|
||||
}
|
||||
|
||||
public void removeMasterySkill(int id)
|
||||
{
|
||||
getVariables().remove(ClanVariables.CLAN_MASTERY_SKILL_TIME + id);
|
||||
removeSkill(SkillData.getInstance().getSkill(id, 1));
|
||||
}
|
||||
|
||||
public int getMasterySkillRemainingTime(int id)
|
||||
{
|
||||
final long endTime = getVariables().getLong(ClanVariables.CLAN_MASTERY_SKILL_TIME + id, 0);
|
||||
if (endTime == 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return (int) (endTime - System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public void setDevelopmentPoints(int count)
|
||||
|
@ -41,6 +41,7 @@ public class ClanVariables extends AbstractVariables
|
||||
// Public variables.
|
||||
public static final String CLAN_DEVELOPMENT_POINTS = "CLAN_DEVELOPMENT_POINTS";
|
||||
public static final String CLAN_MASTERY = "CLAN_MASTERY_";
|
||||
public static final String CLAN_MASTERY_SKILL_TIME = "CLAN_MASTERY_SKILL_TIME_";
|
||||
|
||||
private final int _objectId;
|
||||
|
||||
|
@ -88,6 +88,7 @@ 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.RequestExPledgeSkillActivate;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeSkillInfo;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.pledgebonus.RequestPledgeBonusOpen;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.pledgebonus.RequestPledgeBonusReward;
|
||||
@ -432,7 +433,7 @@ public enum ExIncomingPackets implements IIncomingPackets<GameClient>
|
||||
EX_PLEDGE_MASTERY_SET(0x145, RequestExPledgeMasterySet::new, ConnectionState.IN_GAME),
|
||||
EX_PLEDGE_MASTERY_RESET(0x146, RequestExPledgeMasteryReset::new, ConnectionState.IN_GAME),
|
||||
EX_PLEDGE_SKILL_INFO(0x147, RequestExPledgeSkillInfo::new, ConnectionState.IN_GAME),
|
||||
EX_PLEDGE_SKILL_ACTIVATE(0x148, null, ConnectionState.IN_GAME),
|
||||
EX_PLEDGE_SKILL_ACTIVATE(0x148, RequestExPledgeSkillActivate::new, ConnectionState.IN_GAME),
|
||||
EX_PLEDGE_ITEM_LIST(0x149, RequestExPledgeItemList::new, ConnectionState.IN_GAME),
|
||||
EX_PLEDGE_ITEM_ACTIVATE(0x14A, null, ConnectionState.IN_GAME),
|
||||
EX_PLEDGE_ANNOUNCE(0x14B, RequestExPledgeAnnounce::new, ConnectionState.IN_GAME),
|
||||
|
@ -100,6 +100,7 @@ public class RequestExPledgeMasterySet implements IClientIncomingPacket
|
||||
}
|
||||
|
||||
// Learn.
|
||||
clan.takeReputationScore(mastery.getClanReputation(), true);
|
||||
clan.addMastery(mastery.getId());
|
||||
clan.setDevelopmentPoints(clan.getUsedDevelopmentPoints() + 1);
|
||||
for (Skill skill : mastery.getSkills())
|
||||
|
@ -0,0 +1,118 @@
|
||||
/*
|
||||
* 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 org.l2jmobius.commons.network.PacketReader;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.clan.Clan;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.pledgeV2.ExPledgeSkillInfo;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class RequestExPledgeSkillActivate implements IClientIncomingPacket
|
||||
{
|
||||
private int _skillId;
|
||||
|
||||
@Override
|
||||
public boolean read(GameClient client, PacketReader packet)
|
||||
{
|
||||
_skillId = packet.readD();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(GameClient client)
|
||||
{
|
||||
final PlayerInstance player = client.getPlayer();
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
final Clan clan = player.getClan();
|
||||
if (clan == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (player.getObjectId() != clan.getLeaderId())
|
||||
{
|
||||
player.sendMessage("You do not have enough privileges to take this action.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if already enabled.
|
||||
if (clan.getMasterySkillRemainingTime(_skillId) > 0)
|
||||
{
|
||||
clan.removeMasterySkill(_skillId);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if it can be learned.
|
||||
int previous = 0;
|
||||
int cost = 0;
|
||||
switch (_skillId)
|
||||
{
|
||||
case 19538:
|
||||
{
|
||||
previous = 4;
|
||||
cost = 40000;
|
||||
break;
|
||||
}
|
||||
case 19539:
|
||||
{
|
||||
previous = 9;
|
||||
cost = 30000;
|
||||
break;
|
||||
}
|
||||
case 19540:
|
||||
{
|
||||
previous = 11;
|
||||
cost = 50000;
|
||||
break;
|
||||
}
|
||||
case 19541:
|
||||
{
|
||||
previous = 14;
|
||||
cost = 30000;
|
||||
break;
|
||||
}
|
||||
case 19542:
|
||||
{
|
||||
previous = 16;
|
||||
cost = 50000;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (clan.getReputationScore() < cost)
|
||||
{
|
||||
player.sendMessage("Your clan reputation is lower than the requirement.");
|
||||
return;
|
||||
}
|
||||
if (!clan.hasMastery(previous))
|
||||
{
|
||||
player.sendMessage("You need to learn the previous mastery.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Learn.
|
||||
clan.takeReputationScore(cost, true);
|
||||
clan.addMasterySkill(_skillId);
|
||||
player.sendPacket(new ExPledgeSkillInfo(_skillId, 1, 1296000, 2));
|
||||
}
|
||||
}
|
@ -53,6 +53,47 @@ public class RequestExPledgeSkillInfo implements IClientIncomingPacket
|
||||
return;
|
||||
}
|
||||
|
||||
client.sendPacket(new ExPledgeSkillInfo(_skillId, _skillLevel, -1, 0));
|
||||
int previous = 0;
|
||||
switch (_skillId)
|
||||
{
|
||||
case 19538:
|
||||
{
|
||||
previous = 4;
|
||||
break;
|
||||
}
|
||||
case 19539:
|
||||
{
|
||||
previous = 9;
|
||||
break;
|
||||
}
|
||||
case 19540:
|
||||
{
|
||||
previous = 11;
|
||||
break;
|
||||
}
|
||||
case 19541:
|
||||
{
|
||||
previous = 14;
|
||||
break;
|
||||
}
|
||||
case 19542:
|
||||
{
|
||||
previous = 16;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int time = -1;
|
||||
int available = 0;
|
||||
final int remainingTime = clan.getMasterySkillRemainingTime(_skillId);
|
||||
if (remainingTime > 0)
|
||||
{
|
||||
time = remainingTime / 1000;
|
||||
available = 2;
|
||||
}
|
||||
else if (clan.hasMastery(previous))
|
||||
{
|
||||
available = 1;
|
||||
}
|
||||
client.sendPacket(new ExPledgeSkillInfo(_skillId, _skillLevel, time, available));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user