Addition of clan contribution info.

This commit is contained in:
MobiusDevelopment 2021-11-11 23:23:48 +00:00
parent 59367c14db
commit e49081fdb2
98 changed files with 3472 additions and 28 deletions

View File

@ -200,6 +200,22 @@ CreateKnightUnitCost = 10000
ReinforceKnightUnitCost = 5000
# ---------------------------------------------------------------------------
# Clan Contribution Points
# ---------------------------------------------------------------------------
# Contribution points gained for killing raidbosses.
ClanContributionRewardForRaid = 1
# Contribution points gained for killing enemy clan members.
ClanContributionRewardForEnemy = 1
# Contribution points required to get the reward.
ClanContributionRequired = 100
# Fame rewarded when required points are gathered.
ClanContributionFameReward = 300
# ---------------------------------------------------------------------------
# Other
# ---------------------------------------------------------------------------

View File

@ -390,6 +390,10 @@ public class Config
public static int ROYAL_GUARD_COST;
public static int KNIGHT_UNIT_COST;
public static int KNIGHT_REINFORCE_COST;
public static int CLAN_CONTRIBUTION_REWARD_FOR_RAID;
public static int CLAN_CONTRIBUTION_REWARD_FOR_ENEMY;
public static int CLAN_CONTRIBUTION_REQUIRED;
public static int CLAN_CONTRIBUTION_FAME_REWARD;
public static int BALLISTA_POINTS;
public static int BLOODALLIANCE_POINTS;
public static int BLOODOATH_POINTS;
@ -1555,6 +1559,10 @@ public class Config
ROYAL_GUARD_COST = featureConfig.getInt("CreateRoyalGuardCost", 5000);
KNIGHT_UNIT_COST = featureConfig.getInt("CreateKnightUnitCost", 10000);
KNIGHT_REINFORCE_COST = featureConfig.getInt("ReinforceKnightUnitCost", 5000);
CLAN_CONTRIBUTION_REWARD_FOR_RAID = featureConfig.getInt("ClanContributionRewardForRaid", 1);
CLAN_CONTRIBUTION_REWARD_FOR_ENEMY = featureConfig.getInt("ClanContributionRewardForEnemy", 1);
CLAN_CONTRIBUTION_REQUIRED = featureConfig.getInt("ClanContributionRequired", 100);
CLAN_CONTRIBUTION_FAME_REWARD = featureConfig.getInt("ClanContributionFameReward", 300);
BALLISTA_POINTS = featureConfig.getInt("KillBallistaPoints", 500);
BLOODALLIANCE_POINTS = featureConfig.getInt("BloodAlliancePoints", 500);
BLOODOATH_POINTS = featureConfig.getInt("BloodOathPoints", 200);

View File

@ -79,6 +79,7 @@ public class DailyTaskManager
{
clanLeaderApply();
resetVitalityWeekly();
resetClanContribution();
}
else
{
@ -314,6 +315,41 @@ public class DailyTaskManager
DailyMissionData.getInstance().getDailyMissionData().forEach(DailyMissionDataHolder::reset);
}
private void resetClanContribution()
{
// Update data for offline players.
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM character_variables WHERE var=?"))
{
ps.setString(1, PlayerVariables.CLAN_CONTRIBUTION);
ps.executeUpdate();
}
catch (Exception e)
{
LOGGER.log(Level.SEVERE, "Could not reset Clan contributions: ", e);
}
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM character_variables WHERE var=?"))
{
ps.setString(1, PlayerVariables.CLAN_CONTRIBUTION_REWARDED);
ps.executeUpdate();
}
catch (Exception e)
{
LOGGER.log(Level.SEVERE, "Could not reset Clan contributions: ", e);
}
// Update data for online players.
for (PlayerInstance player : World.getInstance().getPlayers())
{
player.getVariables().remove(PlayerVariables.CLAN_CONTRIBUTION);
player.getVariables().remove(PlayerVariables.CLAN_CONTRIBUTION_REWARDED);
player.getVariables().storeMe();
}
LOGGER.info("Clan contributions has been resetted.");
}
public void resetAttendanceRewards()
{
if (Config.ATTENDANCE_REWARDS_SHARE_ACCOUNT)

View File

@ -484,6 +484,7 @@ public class Attackable extends Npc
final int points = (int) (Math.max(raidbossPoints / members.size(), 1) * p.getStat().getValue(Stat.BONUS_RAID_POINTS, 1));
p.increaseRaidbossPoints(points);
p.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_EARNED_S1_RAID_POINT_S).addInt(points));
p.increaseClanContribution(Config.CLAN_CONTRIBUTION_REWARD_FOR_RAID);
if (p.getNobleLevel() > 0)
{
Hero.getInstance().setRBkilled(p.getObjectId(), getId());
@ -495,6 +496,7 @@ public class Attackable extends Npc
final int points = (int) (Math.max(raidbossPoints, 1) * player.getStat().getValue(Stat.BONUS_RAID_POINTS, 1));
player.increaseRaidbossPoints(points);
player.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_EARNED_S1_RAID_POINT_S).addInt(points));
player.increaseClanContribution(Config.CLAN_CONTRIBUTION_REWARD_FOR_RAID);
if (player.getNobleLevel() > 0)
{
Hero.getInstance().setRBkilled(player.getObjectId(), getId());

View File

@ -2384,6 +2384,39 @@ public class PlayerInstance extends Playable
setRaidbossPoints(_raidbossPoints + increasePoints);
}
/**
* @return the Clan Contribution points of this PlayerInstance
*/
public int getClanContribution()
{
return getVariables().getInt(PlayerVariables.CLAN_CONTRIBUTION, 0);
}
/**
* @return the Clan Contribution total points of this PlayerInstance
*/
public int getClanContributionTotal()
{
return getVariables().getInt(PlayerVariables.CLAN_CONTRIBUTION_TOTAL, 0);
}
/**
* Increase the ClanContribution points of this PlayerInstance (max 100)
* @param amount
*/
public void increaseClanContribution(int amount)
{
if ((amount <= 0) || (getClanContribution() >= Config.CLAN_CONTRIBUTION_REQUIRED))
{
return;
}
getVariables().set(PlayerVariables.CLAN_CONTRIBUTION, Math.min(Config.CLAN_CONTRIBUTION_REQUIRED, getClanContribution() + amount));
getVariables().set(PlayerVariables.CLAN_CONTRIBUTION_TOTAL, Math.min(100000000, getClanContributionTotal() + amount));
sendPacket(new SystemMessage(SystemMessageId.YOUR_CONTRIBUTION_SCORE_HAS_INCREASED_BY_S1).addInt(amount));
}
/**
* @return the ClassId object of the PlayerInstance contained in PlayerTemplate.
*/
@ -4943,6 +4976,7 @@ public class PlayerInstance extends Playable
final ClanWar clanWar = _clan.getWarWith(pkClan.getId());
if ((clanWar != null) && AntiFeedManager.getInstance().check(killer, this))
{
increaseClanContribution(Config.CLAN_CONTRIBUTION_REWARD_FOR_ENEMY);
clanWar.onKill(pk, this);
}
}
@ -10974,6 +11008,8 @@ public class PlayerInstance extends Playable
final ClanMember clanMember = _clan.getClanMember(getObjectId());
if (clanMember != null)
{
clanMember.setClanContribution(getClanContribution());
clanMember.setClanContributionTotal(getClanContributionTotal());
clanMember.setPlayerInstance(null);
}
}

View File

@ -66,6 +66,7 @@ import org.l2jmobius.gameserver.model.itemcontainer.ItemContainer;
import org.l2jmobius.gameserver.model.skills.CommonSkill;
import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.variables.ClanVariables;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
@ -504,6 +505,9 @@ public class Clan implements IIdentifiable, INamable
player.setApprentice(0);
player.setSponsor(0);
player.getVariables().remove(PlayerVariables.CLAN_CONTRIBUTION);
player.getVariables().remove(PlayerVariables.CLAN_CONTRIBUTION_TOTAL);
if (player.isClanLeader())
{
SiegeManager.getInstance().removeSiegeSkills(player);
@ -966,7 +970,9 @@ public class Clan implements IIdentifiable, INamable
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps1 = con.prepareStatement("UPDATE characters SET clanid=0, title=?, clan_join_expiry_time=?, clan_create_expiry_time=?, clan_privs=0, wantspeace=0, subpledge=0, lvl_joined_academy=0, apprentice=0, sponsor=0 WHERE charId=?");
PreparedStatement ps2 = con.prepareStatement("UPDATE characters SET apprentice=0 WHERE apprentice=?");
PreparedStatement ps3 = con.prepareStatement("UPDATE characters SET sponsor=0 WHERE sponsor=?"))
PreparedStatement ps3 = con.prepareStatement("UPDATE characters SET sponsor=0 WHERE sponsor=?");
PreparedStatement ps4 = con.prepareStatement("DELETE FROM character_variables WHERE var=?");
PreparedStatement ps5 = con.prepareStatement("DELETE FROM character_variables WHERE var=?"))
{
ps1.setString(1, "");
ps1.setLong(2, clanJoinExpiryTime);
@ -979,6 +985,11 @@ public class Clan implements IIdentifiable, INamable
// Remove sponsor.
ps3.setInt(1, member.getObjectId());
ps3.execute();
// Clan contribution.
ps4.setString(1, PlayerVariables.CLAN_CONTRIBUTION);
ps4.execute();
ps5.setString(1, PlayerVariables.CLAN_CONTRIBUTION_TOTAL);
ps5.execute();
}
catch (Exception e)
{

View File

@ -26,6 +26,7 @@ import java.util.logging.Logger;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.instancemanager.SiegeManager;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
/**
* This class holds the clan members data.
@ -47,6 +48,8 @@ public class ClanMember
private int _pledgeType;
private int _apprentice;
private int _sponsor;
private int _clanContribution = -1;
private int _clanContributionTotal = -1;
/**
* Used to restore a clan member from the database.
@ -813,4 +816,78 @@ public class ClanMember
LOGGER.log(Level.WARNING, "Could not save apprentice/sponsor: " + e.getMessage(), e);
}
}
public void setClanContribution(int value)
{
_clanContribution = value;
}
public int getClanContribution()
{
if (_clanContribution == -1)
{
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM character_variables WHERE charId=? AND var=?"))
{
ps.setInt(1, _objectId);
ps.setString(2, PlayerVariables.CLAN_CONTRIBUTION);
try (ResultSet result = ps.executeQuery())
{
if (result.next())
{
_clanContribution = result.getInt("val");
}
}
}
catch (SQLException e)
{
LOGGER.log(Level.WARNING, "Could not load Clan Contribution: " + e.getMessage(), e);
}
// Avoid further queries.
if (_clanContribution == -1)
{
_clanContribution = 0;
}
}
return _clanContribution;
}
public void setClanContributionTotal(int value)
{
_clanContributionTotal = value;
}
public int getClanContributionTotal()
{
if (_clanContributionTotal == -1)
{
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM character_variables WHERE charId=? AND var=?"))
{
ps.setInt(1, _objectId);
ps.setString(2, PlayerVariables.CLAN_CONTRIBUTION_TOTAL);
try (ResultSet result = ps.executeQuery())
{
if (result.next())
{
_clanContributionTotal = result.getInt("val");
}
}
}
catch (SQLException e)
{
LOGGER.log(Level.WARNING, "Could not load Clan Contribution total: " + e.getMessage(), e);
}
// Avoid further queries.
if (_clanContributionTotal == -1)
{
_clanContributionTotal = 0;
}
}
return _clanContributionTotal;
}
}

View File

@ -65,6 +65,9 @@ public class PlayerVariables extends AbstractVariables
public static final String FORTUNE_TELLING_VARIABLE = "FortuneTelling";
public static final String FORTUNE_TELLING_BLACK_CAT_VARIABLE = "FortuneTellingBlackCat";
public static final String DELUSION_RETURN = "DELUSION_RETURN";
public static final String CLAN_CONTRIBUTION = "CLAN_CONTRIBUTION";
public static final String CLAN_CONTRIBUTION_TOTAL = "CLAN_CONTRIBUTION_TOTAL";
public static final String CLAN_CONTRIBUTION_REWARDED = "CLAN_CONTRIBUTION_REWARDED";
private final int _objectId;

View File

@ -83,6 +83,9 @@ import org.l2jmobius.gameserver.network.clientpackets.monsterbook.RequestMonster
import org.l2jmobius.gameserver.network.clientpackets.monsterbook.RequestMonsterBookOpen;
import org.l2jmobius.gameserver.network.clientpackets.monsterbook.RequestMonsterBookReward;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeAnnounce;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeContributionInfo;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeContributionRank;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeContributionReward;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeItemBuy;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeItemList;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeLevelUp;
@ -423,9 +426,9 @@ public enum ExIncomingPackets implements IIncomingPackets<GameClient>
EX_ARENA_RANK_ALL(0x13B, null, ConnectionState.IN_GAME),
EX_ARENA_MYRANK(0x13C, null, ConnectionState.IN_GAME),
EX_SWAP_AGATHION_SLOT_ITEMS(0x13D, null, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_RANK(0x13E, null, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_INFO(0x13F, null, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_REWARD(0x140, null, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_RANK(0x13E, RequestExPledgeContributionRank::new, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_INFO(0x13F, RequestExPledgeContributionInfo::new, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_REWARD(0x140, RequestExPledgeContributionReward::new, ConnectionState.IN_GAME),
EX_PLEDGE_LEVEL_UP(0x141, RequestExPledgeLevelUp::new, ConnectionState.IN_GAME),
EX_PLEDGE_MISSION_INFO(0x142, RequestExPledgeMissionInfo::new, ConnectionState.IN_GAME),
EX_PLEDGE_MISSION_REWARD(0x143, RequestExPledgeMissionReward::new, ConnectionState.IN_GAME),

View File

@ -0,0 +1,47 @@
/*
* 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.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.pledgeV2.ExPledgeContributionInfo;
/**
* @author Mobius
*/
public class RequestExPledgeContributionInfo implements IClientIncomingPacket
{
@Override
public boolean read(GameClient client, PacketReader packet)
{
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if ((player == null) || (player.getClan() == null))
{
return;
}
client.sendPacket(new ExPledgeContributionInfo(player));
}
}

View File

@ -0,0 +1,57 @@
/*
* 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.ExPledgeContributionRank;
/**
* @author Mobius
*/
public class RequestExPledgeContributionRank implements IClientIncomingPacket
{
private int _cycle;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_cycle = packet.readC();
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;
}
client.sendPacket(new ExPledgeContributionRank(clan, _cycle));
}
}

View File

@ -0,0 +1,66 @@
/*
* 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.Config;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
/**
* @author Mobius
*/
public class RequestExPledgeContributionReward implements IClientIncomingPacket
{
@Override
public boolean read(GameClient client, PacketReader packet)
{
return true;
}
@Override
public void run(GameClient client)
{
if (!client.getFloodProtectors().canPerformTransaction())
{
return;
}
final PlayerInstance player = client.getPlayer();
if ((player == null) || (player.getClan() == null))
{
return;
}
if (player.getClanContribution() < Config.CLAN_CONTRIBUTION_REQUIRED)
{
return;
}
if (player.getVariables().getBoolean(PlayerVariables.CLAN_CONTRIBUTION_REWARDED, false))
{
player.sendMessage("You have already been rewarded for this cycle.");
return;
}
player.getVariables().set(PlayerVariables.CLAN_CONTRIBUTION_REWARDED, true);
player.setFame(player.getFame() + Config.CLAN_CONTRIBUTION_FAME_REWARD);
player.sendMessage("You have been rewarded with " + Config.CLAN_CONTRIBUTION_FAME_REWARD + " fame points.");
}
}

View File

@ -0,0 +1,54 @@
/*
* 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.Config;
import org.l2jmobius.commons.network.PacketWriter;
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 ExPledgeContributionInfo implements IClientOutgoingPacket
{
private final PlayerInstance _player;
public ExPledgeContributionInfo(PlayerInstance player)
{
_player = player;
}
@Override
public boolean write(PacketWriter packet)
{
if (_player.getClan() == null)
{
return false;
}
OutgoingPackets.EX_PLEDGE_CONTRIBUTION_INFO.writeId(packet);
packet.writeD(_player.getClanContribution());
packet.writeD(_player.getClanContribution());
packet.writeD(Config.CLAN_CONTRIBUTION_REQUIRED);
packet.writeD(-1);
packet.writeD(0);
packet.writeD(Config.CLAN_CONTRIBUTION_FAME_REWARD);
return true;
}
}

View File

@ -0,0 +1,76 @@
/*
* 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.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.clan.Clan;
import org.l2jmobius.gameserver.model.clan.ClanMember;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class ExPledgeContributionRank implements IClientOutgoingPacket
{
private final Clan _clan;
private final int _cycle;
public ExPledgeContributionRank(Clan clan, int cycle)
{
_clan = clan;
_cycle = cycle;
}
@Override
public boolean write(PacketWriter packet)
{
if (_clan == null)
{
return false;
}
OutgoingPackets.EX_PLEDGE_CONTRIBUTION_RANK.writeId(packet);
packet.writeC(_cycle);
packet.writeD(_clan.getMembersCount());
int order = 1;
for (ClanMember member : _clan.getMembers())
{
if (member.isOnline())
{
final PlayerInstance player = member.getPlayerInstance();
packet.writeD(order++); // Order?
packet.writeS(String.format("%1$-" + 24 + "s", player.getName()));
packet.writeD(player.getPledgeType());
packet.writeD(player.getClanContribution());
packet.writeD(player.getClanContributionTotal());
}
else
{
packet.writeD(order++); // Order?
packet.writeS(String.format("%1$-" + 24 + "s", member.getName()));
packet.writeD(member.getPledgeType());
packet.writeD(member.getClanContribution());
packet.writeD(member.getClanContributionTotal());
}
}
return true;
}
}

View File

@ -200,6 +200,22 @@ CreateKnightUnitCost = 10000
ReinforceKnightUnitCost = 5000
# ---------------------------------------------------------------------------
# Clan Contribution Points
# ---------------------------------------------------------------------------
# Contribution points gained for killing raidbosses.
ClanContributionRewardForRaid = 1
# Contribution points gained for killing enemy clan members.
ClanContributionRewardForEnemy = 1
# Contribution points required to get the reward.
ClanContributionRequired = 100
# Fame rewarded when required points are gathered.
ClanContributionFameReward = 300
# ---------------------------------------------------------------------------
# Other
# ---------------------------------------------------------------------------

View File

@ -390,6 +390,10 @@ public class Config
public static int ROYAL_GUARD_COST;
public static int KNIGHT_UNIT_COST;
public static int KNIGHT_REINFORCE_COST;
public static int CLAN_CONTRIBUTION_REWARD_FOR_RAID;
public static int CLAN_CONTRIBUTION_REWARD_FOR_ENEMY;
public static int CLAN_CONTRIBUTION_REQUIRED;
public static int CLAN_CONTRIBUTION_FAME_REWARD;
public static int BALLISTA_POINTS;
public static int BLOODALLIANCE_POINTS;
public static int BLOODOATH_POINTS;
@ -1562,6 +1566,10 @@ public class Config
ROYAL_GUARD_COST = featureConfig.getInt("CreateRoyalGuardCost", 5000);
KNIGHT_UNIT_COST = featureConfig.getInt("CreateKnightUnitCost", 10000);
KNIGHT_REINFORCE_COST = featureConfig.getInt("ReinforceKnightUnitCost", 5000);
CLAN_CONTRIBUTION_REWARD_FOR_RAID = featureConfig.getInt("ClanContributionRewardForRaid", 1);
CLAN_CONTRIBUTION_REWARD_FOR_ENEMY = featureConfig.getInt("ClanContributionRewardForEnemy", 1);
CLAN_CONTRIBUTION_REQUIRED = featureConfig.getInt("ClanContributionRequired", 100);
CLAN_CONTRIBUTION_FAME_REWARD = featureConfig.getInt("ClanContributionFameReward", 300);
BALLISTA_POINTS = featureConfig.getInt("KillBallistaPoints", 500);
BLOODALLIANCE_POINTS = featureConfig.getInt("BloodAlliancePoints", 500);
BLOODOATH_POINTS = featureConfig.getInt("BloodOathPoints", 200);

View File

@ -79,6 +79,7 @@ public class DailyTaskManager
{
clanLeaderApply();
resetVitalityWeekly();
resetClanContribution();
}
else
{
@ -314,6 +315,41 @@ public class DailyTaskManager
DailyMissionData.getInstance().getDailyMissionData().forEach(DailyMissionDataHolder::reset);
}
private void resetClanContribution()
{
// Update data for offline players.
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM character_variables WHERE var=?"))
{
ps.setString(1, PlayerVariables.CLAN_CONTRIBUTION);
ps.executeUpdate();
}
catch (Exception e)
{
LOGGER.log(Level.SEVERE, "Could not reset Clan contributions: ", e);
}
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM character_variables WHERE var=?"))
{
ps.setString(1, PlayerVariables.CLAN_CONTRIBUTION_REWARDED);
ps.executeUpdate();
}
catch (Exception e)
{
LOGGER.log(Level.SEVERE, "Could not reset Clan contributions: ", e);
}
// Update data for online players.
for (PlayerInstance player : World.getInstance().getPlayers())
{
player.getVariables().remove(PlayerVariables.CLAN_CONTRIBUTION);
player.getVariables().remove(PlayerVariables.CLAN_CONTRIBUTION_REWARDED);
player.getVariables().storeMe();
}
LOGGER.info("Clan contributions has been resetted.");
}
public void resetAttendanceRewards()
{
if (Config.ATTENDANCE_REWARDS_SHARE_ACCOUNT)

View File

@ -484,6 +484,7 @@ public class Attackable extends Npc
final int points = (int) (Math.max(raidbossPoints / members.size(), 1) * p.getStat().getValue(Stat.BONUS_RAID_POINTS, 1));
p.increaseRaidbossPoints(points);
p.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_EARNED_S1_RAID_POINT_S).addInt(points));
p.increaseClanContribution(Config.CLAN_CONTRIBUTION_REWARD_FOR_RAID);
if (p.getNobleLevel() > 0)
{
Hero.getInstance().setRBkilled(p.getObjectId(), getId());
@ -495,6 +496,7 @@ public class Attackable extends Npc
final int points = (int) (Math.max(raidbossPoints, 1) * player.getStat().getValue(Stat.BONUS_RAID_POINTS, 1));
player.increaseRaidbossPoints(points);
player.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_EARNED_S1_RAID_POINT_S).addInt(points));
player.increaseClanContribution(Config.CLAN_CONTRIBUTION_REWARD_FOR_RAID);
if (player.getNobleLevel() > 0)
{
Hero.getInstance().setRBkilled(player.getObjectId(), getId());

View File

@ -2384,6 +2384,39 @@ public class PlayerInstance extends Playable
setRaidbossPoints(_raidbossPoints + increasePoints);
}
/**
* @return the Clan Contribution points of this PlayerInstance
*/
public int getClanContribution()
{
return getVariables().getInt(PlayerVariables.CLAN_CONTRIBUTION, 0);
}
/**
* @return the Clan Contribution total points of this PlayerInstance
*/
public int getClanContributionTotal()
{
return getVariables().getInt(PlayerVariables.CLAN_CONTRIBUTION_TOTAL, 0);
}
/**
* Increase the ClanContribution points of this PlayerInstance (max 100)
* @param amount
*/
public void increaseClanContribution(int amount)
{
if ((amount <= 0) || (getClanContribution() >= Config.CLAN_CONTRIBUTION_REQUIRED))
{
return;
}
getVariables().set(PlayerVariables.CLAN_CONTRIBUTION, Math.min(Config.CLAN_CONTRIBUTION_REQUIRED, getClanContribution() + amount));
getVariables().set(PlayerVariables.CLAN_CONTRIBUTION_TOTAL, Math.min(100000000, getClanContributionTotal() + amount));
sendPacket(new SystemMessage(SystemMessageId.YOUR_CONTRIBUTION_SCORE_HAS_INCREASED_BY_S1).addInt(amount));
}
/**
* @return the ClassId object of the PlayerInstance contained in PlayerTemplate.
*/
@ -4943,6 +4976,7 @@ public class PlayerInstance extends Playable
final ClanWar clanWar = _clan.getWarWith(pkClan.getId());
if ((clanWar != null) && AntiFeedManager.getInstance().check(killer, this))
{
increaseClanContribution(Config.CLAN_CONTRIBUTION_REWARD_FOR_ENEMY);
clanWar.onKill(pk, this);
}
}
@ -10977,6 +11011,8 @@ public class PlayerInstance extends Playable
final ClanMember clanMember = _clan.getClanMember(getObjectId());
if (clanMember != null)
{
clanMember.setClanContribution(getClanContribution());
clanMember.setClanContributionTotal(getClanContributionTotal());
clanMember.setPlayerInstance(null);
}
}

View File

@ -66,6 +66,7 @@ import org.l2jmobius.gameserver.model.itemcontainer.ItemContainer;
import org.l2jmobius.gameserver.model.skills.CommonSkill;
import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.variables.ClanVariables;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
@ -504,6 +505,9 @@ public class Clan implements IIdentifiable, INamable
player.setApprentice(0);
player.setSponsor(0);
player.getVariables().remove(PlayerVariables.CLAN_CONTRIBUTION);
player.getVariables().remove(PlayerVariables.CLAN_CONTRIBUTION_TOTAL);
if (player.isClanLeader())
{
SiegeManager.getInstance().removeSiegeSkills(player);
@ -966,7 +970,9 @@ public class Clan implements IIdentifiable, INamable
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps1 = con.prepareStatement("UPDATE characters SET clanid=0, title=?, clan_join_expiry_time=?, clan_create_expiry_time=?, clan_privs=0, wantspeace=0, subpledge=0, lvl_joined_academy=0, apprentice=0, sponsor=0 WHERE charId=?");
PreparedStatement ps2 = con.prepareStatement("UPDATE characters SET apprentice=0 WHERE apprentice=?");
PreparedStatement ps3 = con.prepareStatement("UPDATE characters SET sponsor=0 WHERE sponsor=?"))
PreparedStatement ps3 = con.prepareStatement("UPDATE characters SET sponsor=0 WHERE sponsor=?");
PreparedStatement ps4 = con.prepareStatement("DELETE FROM character_variables WHERE var=?");
PreparedStatement ps5 = con.prepareStatement("DELETE FROM character_variables WHERE var=?"))
{
ps1.setString(1, "");
ps1.setLong(2, clanJoinExpiryTime);
@ -979,6 +985,11 @@ public class Clan implements IIdentifiable, INamable
// Remove sponsor.
ps3.setInt(1, member.getObjectId());
ps3.execute();
// Clan contribution.
ps4.setString(1, PlayerVariables.CLAN_CONTRIBUTION);
ps4.execute();
ps5.setString(1, PlayerVariables.CLAN_CONTRIBUTION_TOTAL);
ps5.execute();
}
catch (Exception e)
{

View File

@ -26,6 +26,7 @@ import java.util.logging.Logger;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.instancemanager.SiegeManager;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
/**
* This class holds the clan members data.
@ -47,6 +48,8 @@ public class ClanMember
private int _pledgeType;
private int _apprentice;
private int _sponsor;
private int _clanContribution = -1;
private int _clanContributionTotal = -1;
/**
* Used to restore a clan member from the database.
@ -813,4 +816,78 @@ public class ClanMember
LOGGER.log(Level.WARNING, "Could not save apprentice/sponsor: " + e.getMessage(), e);
}
}
public void setClanContribution(int value)
{
_clanContribution = value;
}
public int getClanContribution()
{
if (_clanContribution == -1)
{
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM character_variables WHERE charId=? AND var=?"))
{
ps.setInt(1, _objectId);
ps.setString(2, PlayerVariables.CLAN_CONTRIBUTION);
try (ResultSet result = ps.executeQuery())
{
if (result.next())
{
_clanContribution = result.getInt("val");
}
}
}
catch (SQLException e)
{
LOGGER.log(Level.WARNING, "Could not load Clan Contribution: " + e.getMessage(), e);
}
// Avoid further queries.
if (_clanContribution == -1)
{
_clanContribution = 0;
}
}
return _clanContribution;
}
public void setClanContributionTotal(int value)
{
_clanContributionTotal = value;
}
public int getClanContributionTotal()
{
if (_clanContributionTotal == -1)
{
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM character_variables WHERE charId=? AND var=?"))
{
ps.setInt(1, _objectId);
ps.setString(2, PlayerVariables.CLAN_CONTRIBUTION_TOTAL);
try (ResultSet result = ps.executeQuery())
{
if (result.next())
{
_clanContributionTotal = result.getInt("val");
}
}
}
catch (SQLException e)
{
LOGGER.log(Level.WARNING, "Could not load Clan Contribution total: " + e.getMessage(), e);
}
// Avoid further queries.
if (_clanContributionTotal == -1)
{
_clanContributionTotal = 0;
}
}
return _clanContributionTotal;
}
}

View File

@ -65,6 +65,9 @@ public class PlayerVariables extends AbstractVariables
public static final String FORTUNE_TELLING_VARIABLE = "FortuneTelling";
public static final String FORTUNE_TELLING_BLACK_CAT_VARIABLE = "FortuneTellingBlackCat";
public static final String DELUSION_RETURN = "DELUSION_RETURN";
public static final String CLAN_CONTRIBUTION = "CLAN_CONTRIBUTION";
public static final String CLAN_CONTRIBUTION_TOTAL = "CLAN_CONTRIBUTION_TOTAL";
public static final String CLAN_CONTRIBUTION_REWARDED = "CLAN_CONTRIBUTION_REWARDED";
private final int _objectId;

View File

@ -83,6 +83,9 @@ import org.l2jmobius.gameserver.network.clientpackets.monsterbook.RequestMonster
import org.l2jmobius.gameserver.network.clientpackets.monsterbook.RequestMonsterBookOpen;
import org.l2jmobius.gameserver.network.clientpackets.monsterbook.RequestMonsterBookReward;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeAnnounce;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeContributionInfo;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeContributionRank;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeContributionReward;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeItemBuy;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeItemList;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeLevelUp;
@ -423,9 +426,9 @@ public enum ExIncomingPackets implements IIncomingPackets<GameClient>
EX_ARENA_RANK_ALL(0x13B, null, ConnectionState.IN_GAME),
EX_ARENA_MYRANK(0x13C, null, ConnectionState.IN_GAME),
EX_SWAP_AGATHION_SLOT_ITEMS(0x13D, null, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_RANK(0x13E, null, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_INFO(0x13F, null, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_REWARD(0x140, null, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_RANK(0x13E, RequestExPledgeContributionRank::new, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_INFO(0x13F, RequestExPledgeContributionInfo::new, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_REWARD(0x140, RequestExPledgeContributionReward::new, ConnectionState.IN_GAME),
EX_PLEDGE_LEVEL_UP(0x141, RequestExPledgeLevelUp::new, ConnectionState.IN_GAME),
EX_PLEDGE_MISSION_INFO(0x142, RequestExPledgeMissionInfo::new, ConnectionState.IN_GAME),
EX_PLEDGE_MISSION_REWARD(0x143, RequestExPledgeMissionReward::new, ConnectionState.IN_GAME),

View File

@ -0,0 +1,47 @@
/*
* 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.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.pledgeV2.ExPledgeContributionInfo;
/**
* @author Mobius
*/
public class RequestExPledgeContributionInfo implements IClientIncomingPacket
{
@Override
public boolean read(GameClient client, PacketReader packet)
{
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if ((player == null) || (player.getClan() == null))
{
return;
}
client.sendPacket(new ExPledgeContributionInfo(player));
}
}

View File

@ -0,0 +1,57 @@
/*
* 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.ExPledgeContributionRank;
/**
* @author Mobius
*/
public class RequestExPledgeContributionRank implements IClientIncomingPacket
{
private int _cycle;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_cycle = packet.readC();
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;
}
client.sendPacket(new ExPledgeContributionRank(clan, _cycle));
}
}

View File

@ -0,0 +1,66 @@
/*
* 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.Config;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
/**
* @author Mobius
*/
public class RequestExPledgeContributionReward implements IClientIncomingPacket
{
@Override
public boolean read(GameClient client, PacketReader packet)
{
return true;
}
@Override
public void run(GameClient client)
{
if (!client.getFloodProtectors().canPerformTransaction())
{
return;
}
final PlayerInstance player = client.getPlayer();
if ((player == null) || (player.getClan() == null))
{
return;
}
if (player.getClanContribution() < Config.CLAN_CONTRIBUTION_REQUIRED)
{
return;
}
if (player.getVariables().getBoolean(PlayerVariables.CLAN_CONTRIBUTION_REWARDED, false))
{
player.sendMessage("You have already been rewarded for this cycle.");
return;
}
player.getVariables().set(PlayerVariables.CLAN_CONTRIBUTION_REWARDED, true);
player.setFame(player.getFame() + Config.CLAN_CONTRIBUTION_FAME_REWARD);
player.sendMessage("You have been rewarded with " + Config.CLAN_CONTRIBUTION_FAME_REWARD + " fame points.");
}
}

View File

@ -0,0 +1,54 @@
/*
* 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.Config;
import org.l2jmobius.commons.network.PacketWriter;
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 ExPledgeContributionInfo implements IClientOutgoingPacket
{
private final PlayerInstance _player;
public ExPledgeContributionInfo(PlayerInstance player)
{
_player = player;
}
@Override
public boolean write(PacketWriter packet)
{
if (_player.getClan() == null)
{
return false;
}
OutgoingPackets.EX_PLEDGE_CONTRIBUTION_INFO.writeId(packet);
packet.writeD(_player.getClanContribution());
packet.writeD(_player.getClanContribution());
packet.writeD(Config.CLAN_CONTRIBUTION_REQUIRED);
packet.writeD(-1);
packet.writeD(0);
packet.writeD(Config.CLAN_CONTRIBUTION_FAME_REWARD);
return true;
}
}

View File

@ -0,0 +1,76 @@
/*
* 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.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.clan.Clan;
import org.l2jmobius.gameserver.model.clan.ClanMember;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class ExPledgeContributionRank implements IClientOutgoingPacket
{
private final Clan _clan;
private final int _cycle;
public ExPledgeContributionRank(Clan clan, int cycle)
{
_clan = clan;
_cycle = cycle;
}
@Override
public boolean write(PacketWriter packet)
{
if (_clan == null)
{
return false;
}
OutgoingPackets.EX_PLEDGE_CONTRIBUTION_RANK.writeId(packet);
packet.writeC(_cycle);
packet.writeD(_clan.getMembersCount());
int order = 1;
for (ClanMember member : _clan.getMembers())
{
if (member.isOnline())
{
final PlayerInstance player = member.getPlayerInstance();
packet.writeD(order++); // Order?
packet.writeS(String.format("%1$-" + 24 + "s", player.getName()));
packet.writeD(player.getPledgeType());
packet.writeD(player.getClanContribution());
packet.writeD(player.getClanContributionTotal());
}
else
{
packet.writeD(order++); // Order?
packet.writeS(String.format("%1$-" + 24 + "s", member.getName()));
packet.writeD(member.getPledgeType());
packet.writeD(member.getClanContribution());
packet.writeD(member.getClanContributionTotal());
}
}
return true;
}
}

View File

@ -200,6 +200,22 @@ CreateKnightUnitCost = 10000
ReinforceKnightUnitCost = 5000
# ---------------------------------------------------------------------------
# Clan Contribution Points
# ---------------------------------------------------------------------------
# Contribution points gained for killing raidbosses.
ClanContributionRewardForRaid = 1
# Contribution points gained for killing enemy clan members.
ClanContributionRewardForEnemy = 1
# Contribution points required to get the reward.
ClanContributionRequired = 100
# Fame rewarded when required points are gathered.
ClanContributionFameReward = 300
# ---------------------------------------------------------------------------
# Other
# ---------------------------------------------------------------------------

View File

@ -391,6 +391,10 @@ public class Config
public static int ROYAL_GUARD_COST;
public static int KNIGHT_UNIT_COST;
public static int KNIGHT_REINFORCE_COST;
public static int CLAN_CONTRIBUTION_REWARD_FOR_RAID;
public static int CLAN_CONTRIBUTION_REWARD_FOR_ENEMY;
public static int CLAN_CONTRIBUTION_REQUIRED;
public static int CLAN_CONTRIBUTION_FAME_REWARD;
public static int BALLISTA_POINTS;
public static int BLOODALLIANCE_POINTS;
public static int BLOODOATH_POINTS;
@ -1584,6 +1588,10 @@ public class Config
ROYAL_GUARD_COST = featureConfig.getInt("CreateRoyalGuardCost", 5000);
KNIGHT_UNIT_COST = featureConfig.getInt("CreateKnightUnitCost", 10000);
KNIGHT_REINFORCE_COST = featureConfig.getInt("ReinforceKnightUnitCost", 5000);
CLAN_CONTRIBUTION_REWARD_FOR_RAID = featureConfig.getInt("ClanContributionRewardForRaid", 1);
CLAN_CONTRIBUTION_REWARD_FOR_ENEMY = featureConfig.getInt("ClanContributionRewardForEnemy", 1);
CLAN_CONTRIBUTION_REQUIRED = featureConfig.getInt("ClanContributionRequired", 100);
CLAN_CONTRIBUTION_FAME_REWARD = featureConfig.getInt("ClanContributionFameReward", 300);
BALLISTA_POINTS = featureConfig.getInt("KillBallistaPoints", 500);
BLOODALLIANCE_POINTS = featureConfig.getInt("BloodAlliancePoints", 500);
BLOODOATH_POINTS = featureConfig.getInt("BloodOathPoints", 200);

View File

@ -79,6 +79,7 @@ public class DailyTaskManager
{
clanLeaderApply();
resetVitalityWeekly();
resetClanContribution();
}
else
{
@ -314,6 +315,41 @@ public class DailyTaskManager
DailyMissionData.getInstance().getDailyMissionData().forEach(DailyMissionDataHolder::reset);
}
private void resetClanContribution()
{
// Update data for offline players.
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM character_variables WHERE var=?"))
{
ps.setString(1, PlayerVariables.CLAN_CONTRIBUTION);
ps.executeUpdate();
}
catch (Exception e)
{
LOGGER.log(Level.SEVERE, "Could not reset Clan contributions: ", e);
}
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM character_variables WHERE var=?"))
{
ps.setString(1, PlayerVariables.CLAN_CONTRIBUTION_REWARDED);
ps.executeUpdate();
}
catch (Exception e)
{
LOGGER.log(Level.SEVERE, "Could not reset Clan contributions: ", e);
}
// Update data for online players.
for (PlayerInstance player : World.getInstance().getPlayers())
{
player.getVariables().remove(PlayerVariables.CLAN_CONTRIBUTION);
player.getVariables().remove(PlayerVariables.CLAN_CONTRIBUTION_REWARDED);
player.getVariables().storeMe();
}
LOGGER.info("Clan contributions has been resetted.");
}
public void resetAttendanceRewards()
{
if (Config.ATTENDANCE_REWARDS_SHARE_ACCOUNT)

View File

@ -484,6 +484,7 @@ public class Attackable extends Npc
final int points = (int) (Math.max(raidbossPoints / members.size(), 1) * p.getStat().getValue(Stat.BONUS_RAID_POINTS, 1));
p.increaseRaidbossPoints(points);
p.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_EARNED_S1_RAID_POINT_S).addInt(points));
p.increaseClanContribution(Config.CLAN_CONTRIBUTION_REWARD_FOR_RAID);
if (p.getNobleLevel() > 0)
{
Hero.getInstance().setRBkilled(p.getObjectId(), getId());
@ -495,6 +496,7 @@ public class Attackable extends Npc
final int points = (int) (Math.max(raidbossPoints, 1) * player.getStat().getValue(Stat.BONUS_RAID_POINTS, 1));
player.increaseRaidbossPoints(points);
player.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_EARNED_S1_RAID_POINT_S).addInt(points));
player.increaseClanContribution(Config.CLAN_CONTRIBUTION_REWARD_FOR_RAID);
if (player.getNobleLevel() > 0)
{
Hero.getInstance().setRBkilled(player.getObjectId(), getId());

View File

@ -2384,6 +2384,39 @@ public class PlayerInstance extends Playable
setRaidbossPoints(_raidbossPoints + increasePoints);
}
/**
* @return the Clan Contribution points of this PlayerInstance
*/
public int getClanContribution()
{
return getVariables().getInt(PlayerVariables.CLAN_CONTRIBUTION, 0);
}
/**
* @return the Clan Contribution total points of this PlayerInstance
*/
public int getClanContributionTotal()
{
return getVariables().getInt(PlayerVariables.CLAN_CONTRIBUTION_TOTAL, 0);
}
/**
* Increase the ClanContribution points of this PlayerInstance (max 100)
* @param amount
*/
public void increaseClanContribution(int amount)
{
if ((amount <= 0) || (getClanContribution() >= Config.CLAN_CONTRIBUTION_REQUIRED))
{
return;
}
getVariables().set(PlayerVariables.CLAN_CONTRIBUTION, Math.min(Config.CLAN_CONTRIBUTION_REQUIRED, getClanContribution() + amount));
getVariables().set(PlayerVariables.CLAN_CONTRIBUTION_TOTAL, Math.min(100000000, getClanContributionTotal() + amount));
sendPacket(new SystemMessage(SystemMessageId.YOUR_CONTRIBUTION_SCORE_HAS_INCREASED_BY_S1).addInt(amount));
}
/**
* @return the ClassId object of the PlayerInstance contained in PlayerTemplate.
*/
@ -4944,6 +4977,7 @@ public class PlayerInstance extends Playable
final ClanWar clanWar = _clan.getWarWith(pkClan.getId());
if ((clanWar != null) && AntiFeedManager.getInstance().check(killer, this))
{
increaseClanContribution(Config.CLAN_CONTRIBUTION_REWARD_FOR_ENEMY);
clanWar.onKill(pk, this);
}
}
@ -10983,6 +11017,8 @@ public class PlayerInstance extends Playable
final ClanMember clanMember = _clan.getClanMember(getObjectId());
if (clanMember != null)
{
clanMember.setClanContribution(getClanContribution());
clanMember.setClanContributionTotal(getClanContributionTotal());
clanMember.setPlayerInstance(null);
}
}

View File

@ -66,6 +66,7 @@ import org.l2jmobius.gameserver.model.itemcontainer.ItemContainer;
import org.l2jmobius.gameserver.model.skills.CommonSkill;
import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.variables.ClanVariables;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
@ -504,6 +505,9 @@ public class Clan implements IIdentifiable, INamable
player.setApprentice(0);
player.setSponsor(0);
player.getVariables().remove(PlayerVariables.CLAN_CONTRIBUTION);
player.getVariables().remove(PlayerVariables.CLAN_CONTRIBUTION_TOTAL);
if (player.isClanLeader())
{
SiegeManager.getInstance().removeSiegeSkills(player);
@ -966,7 +970,9 @@ public class Clan implements IIdentifiable, INamable
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps1 = con.prepareStatement("UPDATE characters SET clanid=0, title=?, clan_join_expiry_time=?, clan_create_expiry_time=?, clan_privs=0, wantspeace=0, subpledge=0, lvl_joined_academy=0, apprentice=0, sponsor=0 WHERE charId=?");
PreparedStatement ps2 = con.prepareStatement("UPDATE characters SET apprentice=0 WHERE apprentice=?");
PreparedStatement ps3 = con.prepareStatement("UPDATE characters SET sponsor=0 WHERE sponsor=?"))
PreparedStatement ps3 = con.prepareStatement("UPDATE characters SET sponsor=0 WHERE sponsor=?");
PreparedStatement ps4 = con.prepareStatement("DELETE FROM character_variables WHERE var=?");
PreparedStatement ps5 = con.prepareStatement("DELETE FROM character_variables WHERE var=?"))
{
ps1.setString(1, "");
ps1.setLong(2, clanJoinExpiryTime);
@ -979,6 +985,11 @@ public class Clan implements IIdentifiable, INamable
// Remove sponsor.
ps3.setInt(1, member.getObjectId());
ps3.execute();
// Clan contribution.
ps4.setString(1, PlayerVariables.CLAN_CONTRIBUTION);
ps4.execute();
ps5.setString(1, PlayerVariables.CLAN_CONTRIBUTION_TOTAL);
ps5.execute();
}
catch (Exception e)
{

View File

@ -26,6 +26,7 @@ import java.util.logging.Logger;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.instancemanager.SiegeManager;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
/**
* This class holds the clan members data.
@ -47,6 +48,8 @@ public class ClanMember
private int _pledgeType;
private int _apprentice;
private int _sponsor;
private int _clanContribution = -1;
private int _clanContributionTotal = -1;
/**
* Used to restore a clan member from the database.
@ -813,4 +816,78 @@ public class ClanMember
LOGGER.log(Level.WARNING, "Could not save apprentice/sponsor: " + e.getMessage(), e);
}
}
public void setClanContribution(int value)
{
_clanContribution = value;
}
public int getClanContribution()
{
if (_clanContribution == -1)
{
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM character_variables WHERE charId=? AND var=?"))
{
ps.setInt(1, _objectId);
ps.setString(2, PlayerVariables.CLAN_CONTRIBUTION);
try (ResultSet result = ps.executeQuery())
{
if (result.next())
{
_clanContribution = result.getInt("val");
}
}
}
catch (SQLException e)
{
LOGGER.log(Level.WARNING, "Could not load Clan Contribution: " + e.getMessage(), e);
}
// Avoid further queries.
if (_clanContribution == -1)
{
_clanContribution = 0;
}
}
return _clanContribution;
}
public void setClanContributionTotal(int value)
{
_clanContributionTotal = value;
}
public int getClanContributionTotal()
{
if (_clanContributionTotal == -1)
{
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM character_variables WHERE charId=? AND var=?"))
{
ps.setInt(1, _objectId);
ps.setString(2, PlayerVariables.CLAN_CONTRIBUTION_TOTAL);
try (ResultSet result = ps.executeQuery())
{
if (result.next())
{
_clanContributionTotal = result.getInt("val");
}
}
}
catch (SQLException e)
{
LOGGER.log(Level.WARNING, "Could not load Clan Contribution total: " + e.getMessage(), e);
}
// Avoid further queries.
if (_clanContributionTotal == -1)
{
_clanContributionTotal = 0;
}
}
return _clanContributionTotal;
}
}

View File

@ -65,6 +65,9 @@ public class PlayerVariables extends AbstractVariables
public static final String FORTUNE_TELLING_VARIABLE = "FortuneTelling";
public static final String FORTUNE_TELLING_BLACK_CAT_VARIABLE = "FortuneTellingBlackCat";
public static final String DELUSION_RETURN = "DELUSION_RETURN";
public static final String CLAN_CONTRIBUTION = "CLAN_CONTRIBUTION";
public static final String CLAN_CONTRIBUTION_TOTAL = "CLAN_CONTRIBUTION_TOTAL";
public static final String CLAN_CONTRIBUTION_REWARDED = "CLAN_CONTRIBUTION_REWARDED";
private final int _objectId;

View File

@ -84,6 +84,9 @@ import org.l2jmobius.gameserver.network.clientpackets.monsterbook.RequestMonster
import org.l2jmobius.gameserver.network.clientpackets.monsterbook.RequestMonsterBookOpen;
import org.l2jmobius.gameserver.network.clientpackets.monsterbook.RequestMonsterBookReward;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeAnnounce;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeContributionInfo;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeContributionRank;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeContributionReward;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeItemBuy;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeItemList;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeLevelUp;
@ -424,9 +427,9 @@ public enum ExIncomingPackets implements IIncomingPackets<GameClient>
EX_ARENA_RANK_ALL(0x13B, null, ConnectionState.IN_GAME),
EX_ARENA_MYRANK(0x13C, null, ConnectionState.IN_GAME),
EX_SWAP_AGATHION_SLOT_ITEMS(0x13D, null, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_RANK(0x13E, null, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_INFO(0x13F, null, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_REWARD(0x140, null, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_RANK(0x13E, RequestExPledgeContributionRank::new, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_INFO(0x13F, RequestExPledgeContributionInfo::new, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_REWARD(0x140, RequestExPledgeContributionReward::new, ConnectionState.IN_GAME),
EX_PLEDGE_LEVEL_UP(0x141, RequestExPledgeLevelUp::new, ConnectionState.IN_GAME),
EX_PLEDGE_MISSION_INFO(0x142, RequestExPledgeMissionInfo::new, ConnectionState.IN_GAME),
EX_PLEDGE_MISSION_REWARD(0x143, RequestExPledgeMissionReward::new, ConnectionState.IN_GAME),

View File

@ -0,0 +1,47 @@
/*
* 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.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.pledgeV2.ExPledgeContributionInfo;
/**
* @author Mobius
*/
public class RequestExPledgeContributionInfo implements IClientIncomingPacket
{
@Override
public boolean read(GameClient client, PacketReader packet)
{
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if ((player == null) || (player.getClan() == null))
{
return;
}
client.sendPacket(new ExPledgeContributionInfo(player));
}
}

View File

@ -0,0 +1,57 @@
/*
* 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.ExPledgeContributionRank;
/**
* @author Mobius
*/
public class RequestExPledgeContributionRank implements IClientIncomingPacket
{
private int _cycle;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_cycle = packet.readC();
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;
}
client.sendPacket(new ExPledgeContributionRank(clan, _cycle));
}
}

View File

@ -0,0 +1,66 @@
/*
* 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.Config;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
/**
* @author Mobius
*/
public class RequestExPledgeContributionReward implements IClientIncomingPacket
{
@Override
public boolean read(GameClient client, PacketReader packet)
{
return true;
}
@Override
public void run(GameClient client)
{
if (!client.getFloodProtectors().canPerformTransaction())
{
return;
}
final PlayerInstance player = client.getPlayer();
if ((player == null) || (player.getClan() == null))
{
return;
}
if (player.getClanContribution() < Config.CLAN_CONTRIBUTION_REQUIRED)
{
return;
}
if (player.getVariables().getBoolean(PlayerVariables.CLAN_CONTRIBUTION_REWARDED, false))
{
player.sendMessage("You have already been rewarded for this cycle.");
return;
}
player.getVariables().set(PlayerVariables.CLAN_CONTRIBUTION_REWARDED, true);
player.setFame(player.getFame() + Config.CLAN_CONTRIBUTION_FAME_REWARD);
player.sendMessage("You have been rewarded with " + Config.CLAN_CONTRIBUTION_FAME_REWARD + " fame points.");
}
}

View File

@ -0,0 +1,54 @@
/*
* 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.Config;
import org.l2jmobius.commons.network.PacketWriter;
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 ExPledgeContributionInfo implements IClientOutgoingPacket
{
private final PlayerInstance _player;
public ExPledgeContributionInfo(PlayerInstance player)
{
_player = player;
}
@Override
public boolean write(PacketWriter packet)
{
if (_player.getClan() == null)
{
return false;
}
OutgoingPackets.EX_PLEDGE_CONTRIBUTION_INFO.writeId(packet);
packet.writeD(_player.getClanContribution());
packet.writeD(_player.getClanContribution());
packet.writeD(Config.CLAN_CONTRIBUTION_REQUIRED);
packet.writeD(-1);
packet.writeD(0);
packet.writeD(Config.CLAN_CONTRIBUTION_FAME_REWARD);
return true;
}
}

View File

@ -0,0 +1,76 @@
/*
* 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.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.clan.Clan;
import org.l2jmobius.gameserver.model.clan.ClanMember;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class ExPledgeContributionRank implements IClientOutgoingPacket
{
private final Clan _clan;
private final int _cycle;
public ExPledgeContributionRank(Clan clan, int cycle)
{
_clan = clan;
_cycle = cycle;
}
@Override
public boolean write(PacketWriter packet)
{
if (_clan == null)
{
return false;
}
OutgoingPackets.EX_PLEDGE_CONTRIBUTION_RANK.writeId(packet);
packet.writeC(_cycle);
packet.writeD(_clan.getMembersCount());
int order = 1;
for (ClanMember member : _clan.getMembers())
{
if (member.isOnline())
{
final PlayerInstance player = member.getPlayerInstance();
packet.writeD(order++); // Order?
packet.writeS(String.format("%1$-" + 24 + "s", player.getName()));
packet.writeD(player.getPledgeType());
packet.writeD(player.getClanContribution());
packet.writeD(player.getClanContributionTotal());
}
else
{
packet.writeD(order++); // Order?
packet.writeS(String.format("%1$-" + 24 + "s", member.getName()));
packet.writeD(member.getPledgeType());
packet.writeD(member.getClanContribution());
packet.writeD(member.getClanContributionTotal());
}
}
return true;
}
}

View File

@ -200,6 +200,22 @@ CreateKnightUnitCost = 10000
ReinforceKnightUnitCost = 5000
# ---------------------------------------------------------------------------
# Clan Contribution Points
# ---------------------------------------------------------------------------
# Contribution points gained for killing raidbosses.
ClanContributionRewardForRaid = 1
# Contribution points gained for killing enemy clan members.
ClanContributionRewardForEnemy = 1
# Contribution points required to get the reward.
ClanContributionRequired = 100
# Fame rewarded when required points are gathered.
ClanContributionFameReward = 300
# ---------------------------------------------------------------------------
# Other
# ---------------------------------------------------------------------------

View File

@ -391,6 +391,10 @@ public class Config
public static int ROYAL_GUARD_COST;
public static int KNIGHT_UNIT_COST;
public static int KNIGHT_REINFORCE_COST;
public static int CLAN_CONTRIBUTION_REWARD_FOR_RAID;
public static int CLAN_CONTRIBUTION_REWARD_FOR_ENEMY;
public static int CLAN_CONTRIBUTION_REQUIRED;
public static int CLAN_CONTRIBUTION_FAME_REWARD;
public static int BALLISTA_POINTS;
public static int BLOODALLIANCE_POINTS;
public static int BLOODOATH_POINTS;
@ -1592,6 +1596,10 @@ public class Config
ROYAL_GUARD_COST = featureConfig.getInt("CreateRoyalGuardCost", 5000);
KNIGHT_UNIT_COST = featureConfig.getInt("CreateKnightUnitCost", 10000);
KNIGHT_REINFORCE_COST = featureConfig.getInt("ReinforceKnightUnitCost", 5000);
CLAN_CONTRIBUTION_REWARD_FOR_RAID = featureConfig.getInt("ClanContributionRewardForRaid", 1);
CLAN_CONTRIBUTION_REWARD_FOR_ENEMY = featureConfig.getInt("ClanContributionRewardForEnemy", 1);
CLAN_CONTRIBUTION_REQUIRED = featureConfig.getInt("ClanContributionRequired", 100);
CLAN_CONTRIBUTION_FAME_REWARD = featureConfig.getInt("ClanContributionFameReward", 300);
BALLISTA_POINTS = featureConfig.getInt("KillBallistaPoints", 500);
BLOODALLIANCE_POINTS = featureConfig.getInt("BloodAlliancePoints", 500);
BLOODOATH_POINTS = featureConfig.getInt("BloodOathPoints", 200);

View File

@ -81,6 +81,7 @@ public class DailyTaskManager
{
clanLeaderApply();
resetVitalityWeekly();
resetClanContribution();
resetTimedHuntingZonesWeekly();
}
else
@ -318,6 +319,41 @@ public class DailyTaskManager
DailyMissionData.getInstance().getDailyMissionData().forEach(DailyMissionDataHolder::reset);
}
private void resetClanContribution()
{
// Update data for offline players.
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM character_variables WHERE var=?"))
{
ps.setString(1, PlayerVariables.CLAN_CONTRIBUTION);
ps.executeUpdate();
}
catch (Exception e)
{
LOGGER.log(Level.SEVERE, "Could not reset Clan contributions: ", e);
}
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM character_variables WHERE var=?"))
{
ps.setString(1, PlayerVariables.CLAN_CONTRIBUTION_REWARDED);
ps.executeUpdate();
}
catch (Exception e)
{
LOGGER.log(Level.SEVERE, "Could not reset Clan contributions: ", e);
}
// Update data for online players.
for (PlayerInstance player : World.getInstance().getPlayers())
{
player.getVariables().remove(PlayerVariables.CLAN_CONTRIBUTION);
player.getVariables().remove(PlayerVariables.CLAN_CONTRIBUTION_REWARDED);
player.getVariables().storeMe();
}
LOGGER.info("Clan contributions has been resetted.");
}
public void resetTimedHuntingZones()
{
for (TimedHuntingZoneHolder holder : TimedHuntingZoneData.getInstance().getAllHuntingZones())

View File

@ -484,6 +484,7 @@ public class Attackable extends Npc
final int points = (int) (Math.max(raidbossPoints / members.size(), 1) * p.getStat().getValue(Stat.BONUS_RAID_POINTS, 1));
p.increaseRaidbossPoints(points);
p.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_EARNED_S1_RAID_POINT_S).addInt(points));
p.increaseClanContribution(Config.CLAN_CONTRIBUTION_REWARD_FOR_RAID);
if (p.getNobleLevel() > 0)
{
Hero.getInstance().setRBkilled(p.getObjectId(), getId());
@ -495,6 +496,7 @@ public class Attackable extends Npc
final int points = (int) (Math.max(raidbossPoints, 1) * player.getStat().getValue(Stat.BONUS_RAID_POINTS, 1));
player.increaseRaidbossPoints(points);
player.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_EARNED_S1_RAID_POINT_S).addInt(points));
player.increaseClanContribution(Config.CLAN_CONTRIBUTION_REWARD_FOR_RAID);
if (player.getNobleLevel() > 0)
{
Hero.getInstance().setRBkilled(player.getObjectId(), getId());

View File

@ -2320,6 +2320,39 @@ public class PlayerInstance extends Playable
setRaidbossPoints(_raidbossPoints + increasePoints);
}
/**
* @return the Clan Contribution points of this PlayerInstance
*/
public int getClanContribution()
{
return getVariables().getInt(PlayerVariables.CLAN_CONTRIBUTION, 0);
}
/**
* @return the Clan Contribution total points of this PlayerInstance
*/
public int getClanContributionTotal()
{
return getVariables().getInt(PlayerVariables.CLAN_CONTRIBUTION_TOTAL, 0);
}
/**
* Increase the ClanContribution points of this PlayerInstance (max 100)
* @param amount
*/
public void increaseClanContribution(int amount)
{
if ((amount <= 0) || (getClanContribution() >= Config.CLAN_CONTRIBUTION_REQUIRED))
{
return;
}
getVariables().set(PlayerVariables.CLAN_CONTRIBUTION, Math.min(Config.CLAN_CONTRIBUTION_REQUIRED, getClanContribution() + amount));
getVariables().set(PlayerVariables.CLAN_CONTRIBUTION_TOTAL, Math.min(100000000, getClanContributionTotal() + amount));
sendPacket(new SystemMessage(SystemMessageId.YOUR_CONTRIBUTION_SCORE_HAS_INCREASED_BY_S1).addInt(amount));
}
/**
* @return the ClassId object of the PlayerInstance contained in PlayerTemplate.
*/
@ -4882,6 +4915,7 @@ public class PlayerInstance extends Playable
final ClanWar clanWar = _clan.getWarWith(pkClan.getId());
if ((clanWar != null) && AntiFeedManager.getInstance().check(killer, this))
{
increaseClanContribution(Config.CLAN_CONTRIBUTION_REWARD_FOR_ENEMY);
clanWar.onKill(pk, this);
}
}
@ -11011,6 +11045,8 @@ public class PlayerInstance extends Playable
final ClanMember clanMember = _clan.getClanMember(getObjectId());
if (clanMember != null)
{
clanMember.setClanContribution(getClanContribution());
clanMember.setClanContributionTotal(getClanContributionTotal());
clanMember.setPlayerInstance(null);
}
}

View File

@ -65,6 +65,7 @@ import org.l2jmobius.gameserver.model.itemcontainer.ClanWarehouse;
import org.l2jmobius.gameserver.model.itemcontainer.ItemContainer;
import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.variables.ClanVariables;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
@ -503,6 +504,9 @@ public class Clan implements IIdentifiable, INamable
player.setApprentice(0);
player.setSponsor(0);
player.getVariables().remove(PlayerVariables.CLAN_CONTRIBUTION);
player.getVariables().remove(PlayerVariables.CLAN_CONTRIBUTION_TOTAL);
if (player.isClanLeader())
{
SiegeManager.getInstance().removeSiegeSkills(player);
@ -965,7 +969,9 @@ public class Clan implements IIdentifiable, INamable
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps1 = con.prepareStatement("UPDATE characters SET clanid=0, title=?, clan_join_expiry_time=?, clan_create_expiry_time=?, clan_privs=0, wantspeace=0, subpledge=0, lvl_joined_academy=0, apprentice=0, sponsor=0 WHERE charId=?");
PreparedStatement ps2 = con.prepareStatement("UPDATE characters SET apprentice=0 WHERE apprentice=?");
PreparedStatement ps3 = con.prepareStatement("UPDATE characters SET sponsor=0 WHERE sponsor=?"))
PreparedStatement ps3 = con.prepareStatement("UPDATE characters SET sponsor=0 WHERE sponsor=?");
PreparedStatement ps4 = con.prepareStatement("DELETE FROM character_variables WHERE var=?");
PreparedStatement ps5 = con.prepareStatement("DELETE FROM character_variables WHERE var=?"))
{
ps1.setString(1, "");
ps1.setLong(2, clanJoinExpiryTime);
@ -978,6 +984,11 @@ public class Clan implements IIdentifiable, INamable
// Remove sponsor.
ps3.setInt(1, member.getObjectId());
ps3.execute();
// Clan contribution.
ps4.setString(1, PlayerVariables.CLAN_CONTRIBUTION);
ps4.execute();
ps5.setString(1, PlayerVariables.CLAN_CONTRIBUTION_TOTAL);
ps5.execute();
}
catch (Exception e)
{

View File

@ -26,6 +26,7 @@ import java.util.logging.Logger;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.instancemanager.SiegeManager;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
/**
* This class holds the clan members data.
@ -47,6 +48,8 @@ public class ClanMember
private int _pledgeType;
private int _apprentice;
private int _sponsor;
private int _clanContribution = -1;
private int _clanContributionTotal = -1;
/**
* Used to restore a clan member from the database.
@ -813,4 +816,78 @@ public class ClanMember
LOGGER.log(Level.WARNING, "Could not save apprentice/sponsor: " + e.getMessage(), e);
}
}
public void setClanContribution(int value)
{
_clanContribution = value;
}
public int getClanContribution()
{
if (_clanContribution == -1)
{
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM character_variables WHERE charId=? AND var=?"))
{
ps.setInt(1, _objectId);
ps.setString(2, PlayerVariables.CLAN_CONTRIBUTION);
try (ResultSet result = ps.executeQuery())
{
if (result.next())
{
_clanContribution = result.getInt("val");
}
}
}
catch (SQLException e)
{
LOGGER.log(Level.WARNING, "Could not load Clan Contribution: " + e.getMessage(), e);
}
// Avoid further queries.
if (_clanContribution == -1)
{
_clanContribution = 0;
}
}
return _clanContribution;
}
public void setClanContributionTotal(int value)
{
_clanContributionTotal = value;
}
public int getClanContributionTotal()
{
if (_clanContributionTotal == -1)
{
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM character_variables WHERE charId=? AND var=?"))
{
ps.setInt(1, _objectId);
ps.setString(2, PlayerVariables.CLAN_CONTRIBUTION_TOTAL);
try (ResultSet result = ps.executeQuery())
{
if (result.next())
{
_clanContributionTotal = result.getInt("val");
}
}
}
catch (SQLException e)
{
LOGGER.log(Level.WARNING, "Could not load Clan Contribution total: " + e.getMessage(), e);
}
// Avoid further queries.
if (_clanContributionTotal == -1)
{
_clanContributionTotal = 0;
}
}
return _clanContributionTotal;
}
}

View File

@ -65,6 +65,9 @@ public class PlayerVariables extends AbstractVariables
public static final String FORTUNE_TELLING_VARIABLE = "FortuneTelling";
public static final String FORTUNE_TELLING_BLACK_CAT_VARIABLE = "FortuneTellingBlackCat";
public static final String DELUSION_RETURN = "DELUSION_RETURN";
public static final String CLAN_CONTRIBUTION = "CLAN_CONTRIBUTION";
public static final String CLAN_CONTRIBUTION_TOTAL = "CLAN_CONTRIBUTION_TOTAL";
public static final String CLAN_CONTRIBUTION_REWARDED = "CLAN_CONTRIBUTION_REWARDED";
public static final String AUTO_USE_SETTINGS = "AUTO_USE_SETTINGS";
public static final String AUTO_USE_SHORTCUTS = "AUTO_USE_SHORTCUTS";
public static final String HUNTING_ZONE_ENTRY = "HUNTING_ZONE_ENTRY_";

View File

@ -90,6 +90,9 @@ import org.l2jmobius.gameserver.network.clientpackets.monsterbook.RequestMonster
import org.l2jmobius.gameserver.network.clientpackets.monsterbook.RequestMonsterBookOpen;
import org.l2jmobius.gameserver.network.clientpackets.monsterbook.RequestMonsterBookReward;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeAnnounce;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeContributionInfo;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeContributionRank;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeContributionReward;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeItemBuy;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeItemList;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeLevelUp;
@ -442,9 +445,9 @@ public enum ExIncomingPackets implements IIncomingPackets<GameClient>
EX_ARENA_RANK_ALL(0x13A, null, ConnectionState.IN_GAME),
EX_ARENA_MYRANK(0x13B, null, ConnectionState.IN_GAME),
EX_SWAP_AGATHION_SLOT_ITEMS(0x13C, null, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_RANK(0x13D, null, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_INFO(0x13E, null, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_REWARD(0x13F, null, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_RANK(0x13D, RequestExPledgeContributionRank::new, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_INFO(0x13E, RequestExPledgeContributionInfo::new, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_REWARD(0x13F, RequestExPledgeContributionReward::new, ConnectionState.IN_GAME),
EX_PLEDGE_LEVEL_UP(0x140, RequestExPledgeLevelUp::new, ConnectionState.IN_GAME),
EX_PLEDGE_MISSION_INFO(0x141, RequestExPledgeMissionInfo::new, ConnectionState.IN_GAME),
EX_PLEDGE_MISSION_REWARD(0x142, RequestExPledgeMissionReward::new, ConnectionState.IN_GAME),

View File

@ -0,0 +1,47 @@
/*
* 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.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.pledgeV2.ExPledgeContributionInfo;
/**
* @author Mobius
*/
public class RequestExPledgeContributionInfo implements IClientIncomingPacket
{
@Override
public boolean read(GameClient client, PacketReader packet)
{
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if ((player == null) || (player.getClan() == null))
{
return;
}
client.sendPacket(new ExPledgeContributionInfo(player));
}
}

View File

@ -0,0 +1,57 @@
/*
* 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.ExPledgeContributionRank;
/**
* @author Mobius
*/
public class RequestExPledgeContributionRank implements IClientIncomingPacket
{
private int _cycle;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_cycle = packet.readC();
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;
}
client.sendPacket(new ExPledgeContributionRank(clan, _cycle));
}
}

View File

@ -0,0 +1,66 @@
/*
* 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.Config;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
/**
* @author Mobius
*/
public class RequestExPledgeContributionReward implements IClientIncomingPacket
{
@Override
public boolean read(GameClient client, PacketReader packet)
{
return true;
}
@Override
public void run(GameClient client)
{
if (!client.getFloodProtectors().canPerformTransaction())
{
return;
}
final PlayerInstance player = client.getPlayer();
if ((player == null) || (player.getClan() == null))
{
return;
}
if (player.getClanContribution() < Config.CLAN_CONTRIBUTION_REQUIRED)
{
return;
}
if (player.getVariables().getBoolean(PlayerVariables.CLAN_CONTRIBUTION_REWARDED, false))
{
player.sendMessage("You have already been rewarded for this cycle.");
return;
}
player.getVariables().set(PlayerVariables.CLAN_CONTRIBUTION_REWARDED, true);
player.setFame(player.getFame() + Config.CLAN_CONTRIBUTION_FAME_REWARD);
player.sendMessage("You have been rewarded with " + Config.CLAN_CONTRIBUTION_FAME_REWARD + " fame points.");
}
}

View File

@ -0,0 +1,54 @@
/*
* 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.Config;
import org.l2jmobius.commons.network.PacketWriter;
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 ExPledgeContributionInfo implements IClientOutgoingPacket
{
private final PlayerInstance _player;
public ExPledgeContributionInfo(PlayerInstance player)
{
_player = player;
}
@Override
public boolean write(PacketWriter packet)
{
if (_player.getClan() == null)
{
return false;
}
OutgoingPackets.EX_PLEDGE_CONTRIBUTION_INFO.writeId(packet);
packet.writeD(_player.getClanContribution());
packet.writeD(_player.getClanContribution());
packet.writeD(Config.CLAN_CONTRIBUTION_REQUIRED);
packet.writeD(-1);
packet.writeD(0);
packet.writeD(Config.CLAN_CONTRIBUTION_FAME_REWARD);
return true;
}
}

View File

@ -0,0 +1,76 @@
/*
* 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.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.clan.Clan;
import org.l2jmobius.gameserver.model.clan.ClanMember;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class ExPledgeContributionRank implements IClientOutgoingPacket
{
private final Clan _clan;
private final int _cycle;
public ExPledgeContributionRank(Clan clan, int cycle)
{
_clan = clan;
_cycle = cycle;
}
@Override
public boolean write(PacketWriter packet)
{
if (_clan == null)
{
return false;
}
OutgoingPackets.EX_PLEDGE_CONTRIBUTION_RANK.writeId(packet);
packet.writeC(_cycle);
packet.writeD(_clan.getMembersCount());
int order = 1;
for (ClanMember member : _clan.getMembers())
{
if (member.isOnline())
{
final PlayerInstance player = member.getPlayerInstance();
packet.writeD(order++); // Order?
packet.writeS(String.format("%1$-" + 24 + "s", player.getName()));
packet.writeD(player.getPledgeType());
packet.writeD(player.getClanContribution());
packet.writeD(player.getClanContributionTotal());
}
else
{
packet.writeD(order++); // Order?
packet.writeS(String.format("%1$-" + 24 + "s", member.getName()));
packet.writeD(member.getPledgeType());
packet.writeD(member.getClanContribution());
packet.writeD(member.getClanContributionTotal());
}
}
return true;
}
}

View File

@ -200,6 +200,22 @@ CreateKnightUnitCost = 10000
ReinforceKnightUnitCost = 5000
# ---------------------------------------------------------------------------
# Clan Contribution Points
# ---------------------------------------------------------------------------
# Contribution points gained for killing raidbosses.
ClanContributionRewardForRaid = 1
# Contribution points gained for killing enemy clan members.
ClanContributionRewardForEnemy = 1
# Contribution points required to get the reward.
ClanContributionRequired = 100
# Fame rewarded when required points are gathered.
ClanContributionFameReward = 300
# ---------------------------------------------------------------------------
# Other
# ---------------------------------------------------------------------------

View File

@ -391,6 +391,10 @@ public class Config
public static int ROYAL_GUARD_COST;
public static int KNIGHT_UNIT_COST;
public static int KNIGHT_REINFORCE_COST;
public static int CLAN_CONTRIBUTION_REWARD_FOR_RAID;
public static int CLAN_CONTRIBUTION_REWARD_FOR_ENEMY;
public static int CLAN_CONTRIBUTION_REQUIRED;
public static int CLAN_CONTRIBUTION_FAME_REWARD;
public static int BALLISTA_POINTS;
public static int BLOODALLIANCE_POINTS;
public static int BLOODOATH_POINTS;
@ -1590,6 +1594,10 @@ public class Config
ROYAL_GUARD_COST = featureConfig.getInt("CreateRoyalGuardCost", 5000);
KNIGHT_UNIT_COST = featureConfig.getInt("CreateKnightUnitCost", 10000);
KNIGHT_REINFORCE_COST = featureConfig.getInt("ReinforceKnightUnitCost", 5000);
CLAN_CONTRIBUTION_REWARD_FOR_RAID = featureConfig.getInt("ClanContributionRewardForRaid", 1);
CLAN_CONTRIBUTION_REWARD_FOR_ENEMY = featureConfig.getInt("ClanContributionRewardForEnemy", 1);
CLAN_CONTRIBUTION_REQUIRED = featureConfig.getInt("ClanContributionRequired", 100);
CLAN_CONTRIBUTION_FAME_REWARD = featureConfig.getInt("ClanContributionFameReward", 300);
BALLISTA_POINTS = featureConfig.getInt("KillBallistaPoints", 500);
BLOODALLIANCE_POINTS = featureConfig.getInt("BloodAlliancePoints", 500);
BLOODOATH_POINTS = featureConfig.getInt("BloodOathPoints", 200);

View File

@ -83,6 +83,7 @@ public class DailyTaskManager
{
clanLeaderApply();
resetVitalityWeekly();
resetClanContribution();
resetTimedHuntingZonesWeekly();
resetThroneOfHeroes();
}
@ -322,6 +323,41 @@ public class DailyTaskManager
DailyMissionData.getInstance().getDailyMissionData().forEach(DailyMissionDataHolder::reset);
}
private void resetClanContribution()
{
// Update data for offline players.
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM character_variables WHERE var=?"))
{
ps.setString(1, PlayerVariables.CLAN_CONTRIBUTION);
ps.executeUpdate();
}
catch (Exception e)
{
LOGGER.log(Level.SEVERE, "Could not reset Clan contributions: ", e);
}
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM character_variables WHERE var=?"))
{
ps.setString(1, PlayerVariables.CLAN_CONTRIBUTION_REWARDED);
ps.executeUpdate();
}
catch (Exception e)
{
LOGGER.log(Level.SEVERE, "Could not reset Clan contributions: ", e);
}
// Update data for online players.
for (PlayerInstance player : World.getInstance().getPlayers())
{
player.getVariables().remove(PlayerVariables.CLAN_CONTRIBUTION);
player.getVariables().remove(PlayerVariables.CLAN_CONTRIBUTION_REWARDED);
player.getVariables().storeMe();
}
LOGGER.info("Clan contributions has been resetted.");
}
public void resetThroneOfHeroes()
{
// Update data for offline players.

View File

@ -484,6 +484,7 @@ public class Attackable extends Npc
final int points = (int) (Math.max(raidbossPoints / members.size(), 1) * p.getStat().getValue(Stat.BONUS_RAID_POINTS, 1));
p.increaseRaidbossPoints(points);
p.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_EARNED_S1_RAID_POINT_S).addInt(points));
p.increaseClanContribution(Config.CLAN_CONTRIBUTION_REWARD_FOR_RAID);
if (p.getNobleLevel() > 0)
{
Hero.getInstance().setRBkilled(p.getObjectId(), getId());
@ -495,6 +496,7 @@ public class Attackable extends Npc
final int points = (int) (Math.max(raidbossPoints, 1) * player.getStat().getValue(Stat.BONUS_RAID_POINTS, 1));
player.increaseRaidbossPoints(points);
player.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_EARNED_S1_RAID_POINT_S).addInt(points));
player.increaseClanContribution(Config.CLAN_CONTRIBUTION_REWARD_FOR_RAID);
if (player.getNobleLevel() > 0)
{
Hero.getInstance().setRBkilled(player.getObjectId(), getId());

View File

@ -2350,6 +2350,39 @@ public class PlayerInstance extends Playable
setRaidbossPoints(_raidbossPoints + increasePoints);
}
/**
* @return the Clan Contribution points of this PlayerInstance
*/
public int getClanContribution()
{
return getVariables().getInt(PlayerVariables.CLAN_CONTRIBUTION, 0);
}
/**
* @return the Clan Contribution total points of this PlayerInstance
*/
public int getClanContributionTotal()
{
return getVariables().getInt(PlayerVariables.CLAN_CONTRIBUTION_TOTAL, 0);
}
/**
* Increase the ClanContribution points of this PlayerInstance (max 100)
* @param amount
*/
public void increaseClanContribution(int amount)
{
if ((amount <= 0) || (getClanContribution() >= Config.CLAN_CONTRIBUTION_REQUIRED))
{
return;
}
getVariables().set(PlayerVariables.CLAN_CONTRIBUTION, Math.min(Config.CLAN_CONTRIBUTION_REQUIRED, getClanContribution() + amount));
getVariables().set(PlayerVariables.CLAN_CONTRIBUTION_TOTAL, Math.min(100000000, getClanContributionTotal() + amount));
sendPacket(new SystemMessage(SystemMessageId.YOUR_CONTRIBUTION_SCORE_HAS_INCREASED_BY_S1).addInt(amount));
}
/**
* @return the ClassId object of the PlayerInstance contained in PlayerTemplate.
*/
@ -4902,6 +4935,7 @@ public class PlayerInstance extends Playable
final ClanWar clanWar = _clan.getWarWith(pkClan.getId());
if ((clanWar != null) && AntiFeedManager.getInstance().check(killer, this))
{
increaseClanContribution(Config.CLAN_CONTRIBUTION_REWARD_FOR_ENEMY);
clanWar.onKill(pk, this);
}
}
@ -11125,6 +11159,8 @@ public class PlayerInstance extends Playable
final ClanMember clanMember = _clan.getClanMember(getObjectId());
if (clanMember != null)
{
clanMember.setClanContribution(getClanContribution());
clanMember.setClanContributionTotal(getClanContributionTotal());
clanMember.setPlayerInstance(null);
}
}

View File

@ -65,6 +65,7 @@ import org.l2jmobius.gameserver.model.itemcontainer.ClanWarehouse;
import org.l2jmobius.gameserver.model.itemcontainer.ItemContainer;
import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.variables.ClanVariables;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
@ -503,6 +504,9 @@ public class Clan implements IIdentifiable, INamable
player.setApprentice(0);
player.setSponsor(0);
player.getVariables().remove(PlayerVariables.CLAN_CONTRIBUTION);
player.getVariables().remove(PlayerVariables.CLAN_CONTRIBUTION_TOTAL);
if (player.isClanLeader())
{
SiegeManager.getInstance().removeSiegeSkills(player);
@ -965,7 +969,9 @@ public class Clan implements IIdentifiable, INamable
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps1 = con.prepareStatement("UPDATE characters SET clanid=0, title=?, clan_join_expiry_time=?, clan_create_expiry_time=?, clan_privs=0, wantspeace=0, subpledge=0, lvl_joined_academy=0, apprentice=0, sponsor=0 WHERE charId=?");
PreparedStatement ps2 = con.prepareStatement("UPDATE characters SET apprentice=0 WHERE apprentice=?");
PreparedStatement ps3 = con.prepareStatement("UPDATE characters SET sponsor=0 WHERE sponsor=?"))
PreparedStatement ps3 = con.prepareStatement("UPDATE characters SET sponsor=0 WHERE sponsor=?");
PreparedStatement ps4 = con.prepareStatement("DELETE FROM character_variables WHERE var=?");
PreparedStatement ps5 = con.prepareStatement("DELETE FROM character_variables WHERE var=?"))
{
ps1.setString(1, "");
ps1.setLong(2, clanJoinExpiryTime);
@ -978,6 +984,11 @@ public class Clan implements IIdentifiable, INamable
// Remove sponsor.
ps3.setInt(1, member.getObjectId());
ps3.execute();
// Clan contribution.
ps4.setString(1, PlayerVariables.CLAN_CONTRIBUTION);
ps4.execute();
ps5.setString(1, PlayerVariables.CLAN_CONTRIBUTION_TOTAL);
ps5.execute();
}
catch (Exception e)
{

View File

@ -26,6 +26,7 @@ import java.util.logging.Logger;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.instancemanager.SiegeManager;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
/**
* This class holds the clan members data.
@ -47,6 +48,8 @@ public class ClanMember
private int _pledgeType;
private int _apprentice;
private int _sponsor;
private int _clanContribution = -1;
private int _clanContributionTotal = -1;
/**
* Used to restore a clan member from the database.
@ -813,4 +816,78 @@ public class ClanMember
LOGGER.log(Level.WARNING, "Could not save apprentice/sponsor: " + e.getMessage(), e);
}
}
public void setClanContribution(int value)
{
_clanContribution = value;
}
public int getClanContribution()
{
if (_clanContribution == -1)
{
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM character_variables WHERE charId=? AND var=?"))
{
ps.setInt(1, _objectId);
ps.setString(2, PlayerVariables.CLAN_CONTRIBUTION);
try (ResultSet result = ps.executeQuery())
{
if (result.next())
{
_clanContribution = result.getInt("val");
}
}
}
catch (SQLException e)
{
LOGGER.log(Level.WARNING, "Could not load Clan Contribution: " + e.getMessage(), e);
}
// Avoid further queries.
if (_clanContribution == -1)
{
_clanContribution = 0;
}
}
return _clanContribution;
}
public void setClanContributionTotal(int value)
{
_clanContributionTotal = value;
}
public int getClanContributionTotal()
{
if (_clanContributionTotal == -1)
{
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM character_variables WHERE charId=? AND var=?"))
{
ps.setInt(1, _objectId);
ps.setString(2, PlayerVariables.CLAN_CONTRIBUTION_TOTAL);
try (ResultSet result = ps.executeQuery())
{
if (result.next())
{
_clanContributionTotal = result.getInt("val");
}
}
}
catch (SQLException e)
{
LOGGER.log(Level.WARNING, "Could not load Clan Contribution total: " + e.getMessage(), e);
}
// Avoid further queries.
if (_clanContributionTotal == -1)
{
_clanContributionTotal = 0;
}
}
return _clanContributionTotal;
}
}

View File

@ -65,6 +65,9 @@ public class PlayerVariables extends AbstractVariables
public static final String FORTUNE_TELLING_VARIABLE = "FortuneTelling";
public static final String FORTUNE_TELLING_BLACK_CAT_VARIABLE = "FortuneTellingBlackCat";
public static final String DELUSION_RETURN = "DELUSION_RETURN";
public static final String CLAN_CONTRIBUTION = "CLAN_CONTRIBUTION";
public static final String CLAN_CONTRIBUTION_TOTAL = "CLAN_CONTRIBUTION_TOTAL";
public static final String CLAN_CONTRIBUTION_REWARDED = "CLAN_CONTRIBUTION_REWARDED";
public static final String AUTO_USE_SETTINGS = "AUTO_USE_SETTINGS";
public static final String AUTO_USE_SHORTCUTS = "AUTO_USE_SHORTCUTS";
public static final String HUNTING_ZONE_ENTRY = "HUNTING_ZONE_ENTRY_";

View File

@ -100,6 +100,9 @@ import org.l2jmobius.gameserver.network.clientpackets.mentoring.RequestMentorLis
import org.l2jmobius.gameserver.network.clientpackets.pk.RequestExPkPenaltyList;
import org.l2jmobius.gameserver.network.clientpackets.pk.RequestExPkPenaltyListOnlyLoc;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeAnnounce;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeContributionInfo;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeContributionRank;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeContributionReward;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeItemBuy;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeItemList;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeLevelUp;
@ -458,9 +461,9 @@ public enum ExIncomingPackets implements IIncomingPackets<GameClient>
EX_ARENA_RANK_ALL(0x13A, null, ConnectionState.IN_GAME),
EX_ARENA_MYRANK(0x13B, null, ConnectionState.IN_GAME),
EX_SWAP_AGATHION_SLOT_ITEMS(0x13C, null, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_RANK(0x13D, null, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_INFO(0x13E, null, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_REWARD(0x13F, null, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_RANK(0x13D, RequestExPledgeContributionRank::new, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_INFO(0x13E, RequestExPledgeContributionInfo::new, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_REWARD(0x13F, RequestExPledgeContributionReward::new, ConnectionState.IN_GAME),
EX_PLEDGE_LEVEL_UP(0x140, RequestExPledgeLevelUp::new, ConnectionState.IN_GAME),
EX_PLEDGE_MISSION_INFO(0x141, RequestExPledgeMissionInfo::new, ConnectionState.IN_GAME),
EX_PLEDGE_MISSION_REWARD(0x142, RequestExPledgeMissionReward::new, ConnectionState.IN_GAME),

View File

@ -0,0 +1,47 @@
/*
* 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.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.pledgeV2.ExPledgeContributionInfo;
/**
* @author Mobius
*/
public class RequestExPledgeContributionInfo implements IClientIncomingPacket
{
@Override
public boolean read(GameClient client, PacketReader packet)
{
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if ((player == null) || (player.getClan() == null))
{
return;
}
client.sendPacket(new ExPledgeContributionInfo(player));
}
}

View File

@ -0,0 +1,57 @@
/*
* 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.ExPledgeContributionRank;
/**
* @author Mobius
*/
public class RequestExPledgeContributionRank implements IClientIncomingPacket
{
private int _cycle;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_cycle = packet.readC();
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;
}
client.sendPacket(new ExPledgeContributionRank(clan, _cycle));
}
}

View File

@ -0,0 +1,66 @@
/*
* 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.Config;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
/**
* @author Mobius
*/
public class RequestExPledgeContributionReward implements IClientIncomingPacket
{
@Override
public boolean read(GameClient client, PacketReader packet)
{
return true;
}
@Override
public void run(GameClient client)
{
if (!client.getFloodProtectors().canPerformTransaction())
{
return;
}
final PlayerInstance player = client.getPlayer();
if ((player == null) || (player.getClan() == null))
{
return;
}
if (player.getClanContribution() < Config.CLAN_CONTRIBUTION_REQUIRED)
{
return;
}
if (player.getVariables().getBoolean(PlayerVariables.CLAN_CONTRIBUTION_REWARDED, false))
{
player.sendMessage("You have already been rewarded for this cycle.");
return;
}
player.getVariables().set(PlayerVariables.CLAN_CONTRIBUTION_REWARDED, true);
player.setFame(player.getFame() + Config.CLAN_CONTRIBUTION_FAME_REWARD);
player.sendMessage("You have been rewarded with " + Config.CLAN_CONTRIBUTION_FAME_REWARD + " fame points.");
}
}

View File

@ -0,0 +1,54 @@
/*
* 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.Config;
import org.l2jmobius.commons.network.PacketWriter;
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 ExPledgeContributionInfo implements IClientOutgoingPacket
{
private final PlayerInstance _player;
public ExPledgeContributionInfo(PlayerInstance player)
{
_player = player;
}
@Override
public boolean write(PacketWriter packet)
{
if (_player.getClan() == null)
{
return false;
}
OutgoingPackets.EX_PLEDGE_CONTRIBUTION_INFO.writeId(packet);
packet.writeD(_player.getClanContribution());
packet.writeD(_player.getClanContribution());
packet.writeD(Config.CLAN_CONTRIBUTION_REQUIRED);
packet.writeD(-1);
packet.writeD(0);
packet.writeD(Config.CLAN_CONTRIBUTION_FAME_REWARD);
return true;
}
}

View File

@ -0,0 +1,76 @@
/*
* 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.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.clan.Clan;
import org.l2jmobius.gameserver.model.clan.ClanMember;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class ExPledgeContributionRank implements IClientOutgoingPacket
{
private final Clan _clan;
private final int _cycle;
public ExPledgeContributionRank(Clan clan, int cycle)
{
_clan = clan;
_cycle = cycle;
}
@Override
public boolean write(PacketWriter packet)
{
if (_clan == null)
{
return false;
}
OutgoingPackets.EX_PLEDGE_CONTRIBUTION_RANK.writeId(packet);
packet.writeC(_cycle);
packet.writeD(_clan.getMembersCount());
int order = 1;
for (ClanMember member : _clan.getMembers())
{
if (member.isOnline())
{
final PlayerInstance player = member.getPlayerInstance();
packet.writeD(order++); // Order?
packet.writeS(String.format("%1$-" + 24 + "s", player.getName()));
packet.writeD(player.getPledgeType());
packet.writeD(player.getClanContribution());
packet.writeD(player.getClanContributionTotal());
}
else
{
packet.writeD(order++); // Order?
packet.writeS(String.format("%1$-" + 24 + "s", member.getName()));
packet.writeD(member.getPledgeType());
packet.writeD(member.getClanContribution());
packet.writeD(member.getClanContributionTotal());
}
}
return true;
}
}

View File

@ -200,6 +200,22 @@ CreateKnightUnitCost = 10000
ReinforceKnightUnitCost = 5000
# ---------------------------------------------------------------------------
# Clan Contribution Points
# ---------------------------------------------------------------------------
# Contribution points gained for killing raidbosses.
ClanContributionRewardForRaid = 1
# Contribution points gained for killing enemy clan members.
ClanContributionRewardForEnemy = 1
# Contribution points required to get the reward.
ClanContributionRequired = 100
# Fame rewarded when required points are gathered.
ClanContributionFameReward = 300
# ---------------------------------------------------------------------------
# Other
# ---------------------------------------------------------------------------

View File

@ -391,6 +391,10 @@ public class Config
public static int ROYAL_GUARD_COST;
public static int KNIGHT_UNIT_COST;
public static int KNIGHT_REINFORCE_COST;
public static int CLAN_CONTRIBUTION_REWARD_FOR_RAID;
public static int CLAN_CONTRIBUTION_REWARD_FOR_ENEMY;
public static int CLAN_CONTRIBUTION_REQUIRED;
public static int CLAN_CONTRIBUTION_FAME_REWARD;
public static int BALLISTA_POINTS;
public static int BLOODALLIANCE_POINTS;
public static int BLOODOATH_POINTS;
@ -1592,6 +1596,10 @@ public class Config
ROYAL_GUARD_COST = featureConfig.getInt("CreateRoyalGuardCost", 5000);
KNIGHT_UNIT_COST = featureConfig.getInt("CreateKnightUnitCost", 10000);
KNIGHT_REINFORCE_COST = featureConfig.getInt("ReinforceKnightUnitCost", 5000);
CLAN_CONTRIBUTION_REWARD_FOR_RAID = featureConfig.getInt("ClanContributionRewardForRaid", 1);
CLAN_CONTRIBUTION_REWARD_FOR_ENEMY = featureConfig.getInt("ClanContributionRewardForEnemy", 1);
CLAN_CONTRIBUTION_REQUIRED = featureConfig.getInt("ClanContributionRequired", 100);
CLAN_CONTRIBUTION_FAME_REWARD = featureConfig.getInt("ClanContributionFameReward", 300);
BALLISTA_POINTS = featureConfig.getInt("KillBallistaPoints", 500);
BLOODALLIANCE_POINTS = featureConfig.getInt("BloodAlliancePoints", 500);
BLOODOATH_POINTS = featureConfig.getInt("BloodOathPoints", 200);

View File

@ -83,6 +83,7 @@ public class DailyTaskManager
{
clanLeaderApply();
resetVitalityWeekly();
resetClanContribution();
resetTimedHuntingZonesWeekly();
resetThroneOfHeroes();
}
@ -322,6 +323,41 @@ public class DailyTaskManager
DailyMissionData.getInstance().getDailyMissionData().forEach(DailyMissionDataHolder::reset);
}
private void resetClanContribution()
{
// Update data for offline players.
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM character_variables WHERE var=?"))
{
ps.setString(1, PlayerVariables.CLAN_CONTRIBUTION);
ps.executeUpdate();
}
catch (Exception e)
{
LOGGER.log(Level.SEVERE, "Could not reset Clan contributions: ", e);
}
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM character_variables WHERE var=?"))
{
ps.setString(1, PlayerVariables.CLAN_CONTRIBUTION_REWARDED);
ps.executeUpdate();
}
catch (Exception e)
{
LOGGER.log(Level.SEVERE, "Could not reset Clan contributions: ", e);
}
// Update data for online players.
for (PlayerInstance player : World.getInstance().getPlayers())
{
player.getVariables().remove(PlayerVariables.CLAN_CONTRIBUTION);
player.getVariables().remove(PlayerVariables.CLAN_CONTRIBUTION_REWARDED);
player.getVariables().storeMe();
}
LOGGER.info("Clan contributions has been resetted.");
}
public void resetThroneOfHeroes()
{
// Update data for offline players.

View File

@ -484,6 +484,7 @@ public class Attackable extends Npc
final int points = (int) (Math.max(raidbossPoints / members.size(), 1) * p.getStat().getValue(Stat.BONUS_RAID_POINTS, 1));
p.increaseRaidbossPoints(points);
p.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_EARNED_S1_RAID_POINT_S).addInt(points));
p.increaseClanContribution(Config.CLAN_CONTRIBUTION_REWARD_FOR_RAID);
if (p.getNobleLevel() > 0)
{
Hero.getInstance().setRBkilled(p.getObjectId(), getId());
@ -495,6 +496,7 @@ public class Attackable extends Npc
final int points = (int) (Math.max(raidbossPoints, 1) * player.getStat().getValue(Stat.BONUS_RAID_POINTS, 1));
player.increaseRaidbossPoints(points);
player.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_EARNED_S1_RAID_POINT_S).addInt(points));
player.increaseClanContribution(Config.CLAN_CONTRIBUTION_REWARD_FOR_RAID);
if (player.getNobleLevel() > 0)
{
Hero.getInstance().setRBkilled(player.getObjectId(), getId());

View File

@ -2367,6 +2367,39 @@ public class PlayerInstance extends Playable
setRaidbossPoints(_raidbossPoints + increasePoints);
}
/**
* @return the Clan Contribution points of this PlayerInstance
*/
public int getClanContribution()
{
return getVariables().getInt(PlayerVariables.CLAN_CONTRIBUTION, 0);
}
/**
* @return the Clan Contribution total points of this PlayerInstance
*/
public int getClanContributionTotal()
{
return getVariables().getInt(PlayerVariables.CLAN_CONTRIBUTION_TOTAL, 0);
}
/**
* Increase the ClanContribution points of this PlayerInstance (max 100)
* @param amount
*/
public void increaseClanContribution(int amount)
{
if ((amount <= 0) || (getClanContribution() >= Config.CLAN_CONTRIBUTION_REQUIRED))
{
return;
}
getVariables().set(PlayerVariables.CLAN_CONTRIBUTION, Math.min(Config.CLAN_CONTRIBUTION_REQUIRED, getClanContribution() + amount));
getVariables().set(PlayerVariables.CLAN_CONTRIBUTION_TOTAL, Math.min(100000000, getClanContributionTotal() + amount));
sendPacket(new SystemMessage(SystemMessageId.YOUR_CONTRIBUTION_SCORE_HAS_INCREASED_BY_S1).addInt(amount));
}
/**
* @return the ClassId object of the PlayerInstance contained in PlayerTemplate.
*/
@ -4919,6 +4952,7 @@ public class PlayerInstance extends Playable
final ClanWar clanWar = _clan.getWarWith(pkClan.getId());
if ((clanWar != null) && AntiFeedManager.getInstance().check(killer, this))
{
increaseClanContribution(Config.CLAN_CONTRIBUTION_REWARD_FOR_ENEMY);
clanWar.onKill(pk, this);
}
}
@ -11151,6 +11185,8 @@ public class PlayerInstance extends Playable
final ClanMember clanMember = _clan.getClanMember(getObjectId());
if (clanMember != null)
{
clanMember.setClanContribution(getClanContribution());
clanMember.setClanContributionTotal(getClanContributionTotal());
clanMember.setPlayerInstance(null);
}
}

View File

@ -65,6 +65,7 @@ import org.l2jmobius.gameserver.model.itemcontainer.ClanWarehouse;
import org.l2jmobius.gameserver.model.itemcontainer.ItemContainer;
import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.variables.ClanVariables;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
@ -503,6 +504,9 @@ public class Clan implements IIdentifiable, INamable
player.setApprentice(0);
player.setSponsor(0);
player.getVariables().remove(PlayerVariables.CLAN_CONTRIBUTION);
player.getVariables().remove(PlayerVariables.CLAN_CONTRIBUTION_TOTAL);
if (player.isClanLeader())
{
SiegeManager.getInstance().removeSiegeSkills(player);
@ -965,7 +969,9 @@ public class Clan implements IIdentifiable, INamable
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps1 = con.prepareStatement("UPDATE characters SET clanid=0, title=?, clan_join_expiry_time=?, clan_create_expiry_time=?, clan_privs=0, wantspeace=0, subpledge=0, lvl_joined_academy=0, apprentice=0, sponsor=0 WHERE charId=?");
PreparedStatement ps2 = con.prepareStatement("UPDATE characters SET apprentice=0 WHERE apprentice=?");
PreparedStatement ps3 = con.prepareStatement("UPDATE characters SET sponsor=0 WHERE sponsor=?"))
PreparedStatement ps3 = con.prepareStatement("UPDATE characters SET sponsor=0 WHERE sponsor=?");
PreparedStatement ps4 = con.prepareStatement("DELETE FROM character_variables WHERE var=?");
PreparedStatement ps5 = con.prepareStatement("DELETE FROM character_variables WHERE var=?"))
{
ps1.setString(1, "");
ps1.setLong(2, clanJoinExpiryTime);
@ -978,6 +984,11 @@ public class Clan implements IIdentifiable, INamable
// Remove sponsor.
ps3.setInt(1, member.getObjectId());
ps3.execute();
// Clan contribution.
ps4.setString(1, PlayerVariables.CLAN_CONTRIBUTION);
ps4.execute();
ps5.setString(1, PlayerVariables.CLAN_CONTRIBUTION_TOTAL);
ps5.execute();
}
catch (Exception e)
{

View File

@ -26,6 +26,7 @@ import java.util.logging.Logger;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.instancemanager.SiegeManager;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
/**
* This class holds the clan members data.
@ -47,6 +48,8 @@ public class ClanMember
private int _pledgeType;
private int _apprentice;
private int _sponsor;
private int _clanContribution = -1;
private int _clanContributionTotal = -1;
/**
* Used to restore a clan member from the database.
@ -813,4 +816,78 @@ public class ClanMember
LOGGER.log(Level.WARNING, "Could not save apprentice/sponsor: " + e.getMessage(), e);
}
}
public void setClanContribution(int value)
{
_clanContribution = value;
}
public int getClanContribution()
{
if (_clanContribution == -1)
{
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM character_variables WHERE charId=? AND var=?"))
{
ps.setInt(1, _objectId);
ps.setString(2, PlayerVariables.CLAN_CONTRIBUTION);
try (ResultSet result = ps.executeQuery())
{
if (result.next())
{
_clanContribution = result.getInt("val");
}
}
}
catch (SQLException e)
{
LOGGER.log(Level.WARNING, "Could not load Clan Contribution: " + e.getMessage(), e);
}
// Avoid further queries.
if (_clanContribution == -1)
{
_clanContribution = 0;
}
}
return _clanContribution;
}
public void setClanContributionTotal(int value)
{
_clanContributionTotal = value;
}
public int getClanContributionTotal()
{
if (_clanContributionTotal == -1)
{
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM character_variables WHERE charId=? AND var=?"))
{
ps.setInt(1, _objectId);
ps.setString(2, PlayerVariables.CLAN_CONTRIBUTION_TOTAL);
try (ResultSet result = ps.executeQuery())
{
if (result.next())
{
_clanContributionTotal = result.getInt("val");
}
}
}
catch (SQLException e)
{
LOGGER.log(Level.WARNING, "Could not load Clan Contribution total: " + e.getMessage(), e);
}
// Avoid further queries.
if (_clanContributionTotal == -1)
{
_clanContributionTotal = 0;
}
}
return _clanContributionTotal;
}
}

View File

@ -65,6 +65,9 @@ public class PlayerVariables extends AbstractVariables
public static final String FORTUNE_TELLING_VARIABLE = "FortuneTelling";
public static final String FORTUNE_TELLING_BLACK_CAT_VARIABLE = "FortuneTellingBlackCat";
public static final String DELUSION_RETURN = "DELUSION_RETURN";
public static final String CLAN_CONTRIBUTION = "CLAN_CONTRIBUTION";
public static final String CLAN_CONTRIBUTION_TOTAL = "CLAN_CONTRIBUTION_TOTAL";
public static final String CLAN_CONTRIBUTION_REWARDED = "CLAN_CONTRIBUTION_REWARDED";
public static final String AUTO_USE_SETTINGS = "AUTO_USE_SETTINGS";
public static final String AUTO_USE_SHORTCUTS = "AUTO_USE_SHORTCUTS";
public static final String HUNTING_ZONE_ENTRY = "HUNTING_ZONE_ENTRY_";

View File

@ -109,6 +109,9 @@ import org.l2jmobius.gameserver.network.clientpackets.mentoring.RequestMentorLis
import org.l2jmobius.gameserver.network.clientpackets.pk.RequestExPkPenaltyList;
import org.l2jmobius.gameserver.network.clientpackets.pk.RequestExPkPenaltyListOnlyLoc;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeAnnounce;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeContributionInfo;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeContributionRank;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeContributionReward;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeItemBuy;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeItemList;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeLevelUp;
@ -467,9 +470,9 @@ public enum ExIncomingPackets implements IIncomingPackets<GameClient>
EX_ARENA_RANK_ALL(0x13A, null, ConnectionState.IN_GAME),
EX_ARENA_MYRANK(0x13B, null, ConnectionState.IN_GAME),
EX_SWAP_AGATHION_SLOT_ITEMS(0x13C, null, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_RANK(0x13D, null, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_INFO(0x13E, null, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_REWARD(0x13F, null, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_RANK(0x13D, RequestExPledgeContributionRank::new, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_INFO(0x13E, RequestExPledgeContributionInfo::new, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_REWARD(0x13F, RequestExPledgeContributionReward::new, ConnectionState.IN_GAME),
EX_PLEDGE_LEVEL_UP(0x140, RequestExPledgeLevelUp::new, ConnectionState.IN_GAME),
EX_PLEDGE_MISSION_INFO(0x141, RequestExPledgeMissionInfo::new, ConnectionState.IN_GAME),
EX_PLEDGE_MISSION_REWARD(0x142, RequestExPledgeMissionReward::new, ConnectionState.IN_GAME),

View File

@ -0,0 +1,47 @@
/*
* 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.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.pledgeV2.ExPledgeContributionInfo;
/**
* @author Mobius
*/
public class RequestExPledgeContributionInfo implements IClientIncomingPacket
{
@Override
public boolean read(GameClient client, PacketReader packet)
{
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if ((player == null) || (player.getClan() == null))
{
return;
}
client.sendPacket(new ExPledgeContributionInfo(player));
}
}

View File

@ -0,0 +1,57 @@
/*
* 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.ExPledgeContributionRank;
/**
* @author Mobius
*/
public class RequestExPledgeContributionRank implements IClientIncomingPacket
{
private int _cycle;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_cycle = packet.readC();
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;
}
client.sendPacket(new ExPledgeContributionRank(clan, _cycle));
}
}

View File

@ -0,0 +1,66 @@
/*
* 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.Config;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
/**
* @author Mobius
*/
public class RequestExPledgeContributionReward implements IClientIncomingPacket
{
@Override
public boolean read(GameClient client, PacketReader packet)
{
return true;
}
@Override
public void run(GameClient client)
{
if (!client.getFloodProtectors().canPerformTransaction())
{
return;
}
final PlayerInstance player = client.getPlayer();
if ((player == null) || (player.getClan() == null))
{
return;
}
if (player.getClanContribution() < Config.CLAN_CONTRIBUTION_REQUIRED)
{
return;
}
if (player.getVariables().getBoolean(PlayerVariables.CLAN_CONTRIBUTION_REWARDED, false))
{
player.sendMessage("You have already been rewarded for this cycle.");
return;
}
player.getVariables().set(PlayerVariables.CLAN_CONTRIBUTION_REWARDED, true);
player.setFame(player.getFame() + Config.CLAN_CONTRIBUTION_FAME_REWARD);
player.sendMessage("You have been rewarded with " + Config.CLAN_CONTRIBUTION_FAME_REWARD + " fame points.");
}
}

View File

@ -0,0 +1,54 @@
/*
* 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.Config;
import org.l2jmobius.commons.network.PacketWriter;
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 ExPledgeContributionInfo implements IClientOutgoingPacket
{
private final PlayerInstance _player;
public ExPledgeContributionInfo(PlayerInstance player)
{
_player = player;
}
@Override
public boolean write(PacketWriter packet)
{
if (_player.getClan() == null)
{
return false;
}
OutgoingPackets.EX_PLEDGE_CONTRIBUTION_INFO.writeId(packet);
packet.writeD(_player.getClanContribution());
packet.writeD(_player.getClanContribution());
packet.writeD(Config.CLAN_CONTRIBUTION_REQUIRED);
packet.writeD(-1);
packet.writeD(0);
packet.writeD(Config.CLAN_CONTRIBUTION_FAME_REWARD);
return true;
}
}

View File

@ -0,0 +1,76 @@
/*
* 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.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.clan.Clan;
import org.l2jmobius.gameserver.model.clan.ClanMember;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class ExPledgeContributionRank implements IClientOutgoingPacket
{
private final Clan _clan;
private final int _cycle;
public ExPledgeContributionRank(Clan clan, int cycle)
{
_clan = clan;
_cycle = cycle;
}
@Override
public boolean write(PacketWriter packet)
{
if (_clan == null)
{
return false;
}
OutgoingPackets.EX_PLEDGE_CONTRIBUTION_RANK.writeId(packet);
packet.writeC(_cycle);
packet.writeD(_clan.getMembersCount());
int order = 1;
for (ClanMember member : _clan.getMembers())
{
if (member.isOnline())
{
final PlayerInstance player = member.getPlayerInstance();
packet.writeD(order++); // Order?
packet.writeS(String.format("%1$-" + 24 + "s", player.getName()));
packet.writeD(player.getPledgeType());
packet.writeD(player.getClanContribution());
packet.writeD(player.getClanContributionTotal());
}
else
{
packet.writeD(order++); // Order?
packet.writeS(String.format("%1$-" + 24 + "s", member.getName()));
packet.writeD(member.getPledgeType());
packet.writeD(member.getClanContribution());
packet.writeD(member.getClanContributionTotal());
}
}
return true;
}
}

View File

@ -200,6 +200,22 @@ CreateKnightUnitCost = 10000
ReinforceKnightUnitCost = 5000
# ---------------------------------------------------------------------------
# Clan Contribution Points
# ---------------------------------------------------------------------------
# Contribution points gained for killing raidbosses.
ClanContributionRewardForRaid = 1
# Contribution points gained for killing enemy clan members.
ClanContributionRewardForEnemy = 1
# Contribution points required to get the reward.
ClanContributionRequired = 100
# Fame rewarded when required points are gathered.
ClanContributionFameReward = 300
# ---------------------------------------------------------------------------
# Other
# ---------------------------------------------------------------------------

View File

@ -391,6 +391,10 @@ public class Config
public static int ROYAL_GUARD_COST;
public static int KNIGHT_UNIT_COST;
public static int KNIGHT_REINFORCE_COST;
public static int CLAN_CONTRIBUTION_REWARD_FOR_RAID;
public static int CLAN_CONTRIBUTION_REWARD_FOR_ENEMY;
public static int CLAN_CONTRIBUTION_REQUIRED;
public static int CLAN_CONTRIBUTION_FAME_REWARD;
public static int BALLISTA_POINTS;
public static int BLOODALLIANCE_POINTS;
public static int BLOODOATH_POINTS;
@ -1592,6 +1596,10 @@ public class Config
ROYAL_GUARD_COST = featureConfig.getInt("CreateRoyalGuardCost", 5000);
KNIGHT_UNIT_COST = featureConfig.getInt("CreateKnightUnitCost", 10000);
KNIGHT_REINFORCE_COST = featureConfig.getInt("ReinforceKnightUnitCost", 5000);
CLAN_CONTRIBUTION_REWARD_FOR_RAID = featureConfig.getInt("ClanContributionRewardForRaid", 1);
CLAN_CONTRIBUTION_REWARD_FOR_ENEMY = featureConfig.getInt("ClanContributionRewardForEnemy", 1);
CLAN_CONTRIBUTION_REQUIRED = featureConfig.getInt("ClanContributionRequired", 100);
CLAN_CONTRIBUTION_FAME_REWARD = featureConfig.getInt("ClanContributionFameReward", 300);
BALLISTA_POINTS = featureConfig.getInt("KillBallistaPoints", 500);
BLOODALLIANCE_POINTS = featureConfig.getInt("BloodAlliancePoints", 500);
BLOODOATH_POINTS = featureConfig.getInt("BloodOathPoints", 200);

View File

@ -83,6 +83,7 @@ public class DailyTaskManager
{
clanLeaderApply();
resetVitalityWeekly();
resetClanContribution();
resetTimedHuntingZonesWeekly();
resetThroneOfHeroes();
}
@ -322,6 +323,41 @@ public class DailyTaskManager
DailyMissionData.getInstance().getDailyMissionData().forEach(DailyMissionDataHolder::reset);
}
private void resetClanContribution()
{
// Update data for offline players.
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM character_variables WHERE var=?"))
{
ps.setString(1, PlayerVariables.CLAN_CONTRIBUTION);
ps.executeUpdate();
}
catch (Exception e)
{
LOGGER.log(Level.SEVERE, "Could not reset Clan contributions: ", e);
}
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM character_variables WHERE var=?"))
{
ps.setString(1, PlayerVariables.CLAN_CONTRIBUTION_REWARDED);
ps.executeUpdate();
}
catch (Exception e)
{
LOGGER.log(Level.SEVERE, "Could not reset Clan contributions: ", e);
}
// Update data for online players.
for (PlayerInstance player : World.getInstance().getPlayers())
{
player.getVariables().remove(PlayerVariables.CLAN_CONTRIBUTION);
player.getVariables().remove(PlayerVariables.CLAN_CONTRIBUTION_REWARDED);
player.getVariables().storeMe();
}
LOGGER.info("Clan contributions has been resetted.");
}
public void resetThroneOfHeroes()
{
// Update data for offline players.

View File

@ -484,6 +484,7 @@ public class Attackable extends Npc
final int points = (int) (Math.max(raidbossPoints / members.size(), 1) * p.getStat().getValue(Stat.BONUS_RAID_POINTS, 1));
p.increaseRaidbossPoints(points);
p.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_EARNED_S1_RAID_POINT_S).addInt(points));
p.increaseClanContribution(Config.CLAN_CONTRIBUTION_REWARD_FOR_RAID);
if (p.getNobleLevel() > 0)
{
Hero.getInstance().setRBkilled(p.getObjectId(), getId());
@ -495,6 +496,7 @@ public class Attackable extends Npc
final int points = (int) (Math.max(raidbossPoints, 1) * player.getStat().getValue(Stat.BONUS_RAID_POINTS, 1));
player.increaseRaidbossPoints(points);
player.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_EARNED_S1_RAID_POINT_S).addInt(points));
player.increaseClanContribution(Config.CLAN_CONTRIBUTION_REWARD_FOR_RAID);
if (player.getNobleLevel() > 0)
{
Hero.getInstance().setRBkilled(player.getObjectId(), getId());

View File

@ -2369,6 +2369,39 @@ public class PlayerInstance extends Playable
setRaidbossPoints(_raidbossPoints + increasePoints);
}
/**
* @return the Clan Contribution points of this PlayerInstance
*/
public int getClanContribution()
{
return getVariables().getInt(PlayerVariables.CLAN_CONTRIBUTION, 0);
}
/**
* @return the Clan Contribution total points of this PlayerInstance
*/
public int getClanContributionTotal()
{
return getVariables().getInt(PlayerVariables.CLAN_CONTRIBUTION_TOTAL, 0);
}
/**
* Increase the ClanContribution points of this PlayerInstance (max 100)
* @param amount
*/
public void increaseClanContribution(int amount)
{
if ((amount <= 0) || (getClanContribution() >= Config.CLAN_CONTRIBUTION_REQUIRED))
{
return;
}
getVariables().set(PlayerVariables.CLAN_CONTRIBUTION, Math.min(Config.CLAN_CONTRIBUTION_REQUIRED, getClanContribution() + amount));
getVariables().set(PlayerVariables.CLAN_CONTRIBUTION_TOTAL, Math.min(100000000, getClanContributionTotal() + amount));
sendPacket(new SystemMessage(SystemMessageId.YOUR_CONTRIBUTION_SCORE_HAS_INCREASED_BY_S1).addInt(amount));
}
/**
* @return the ClassId object of the PlayerInstance contained in PlayerTemplate.
*/
@ -4952,6 +4985,7 @@ public class PlayerInstance extends Playable
final ClanWar clanWar = _clan.getWarWith(pkClan.getId());
if ((clanWar != null) && AntiFeedManager.getInstance().check(killer, this))
{
increaseClanContribution(Config.CLAN_CONTRIBUTION_REWARD_FOR_ENEMY);
clanWar.onKill(pk, this);
}
}
@ -11201,6 +11235,8 @@ public class PlayerInstance extends Playable
final ClanMember clanMember = _clan.getClanMember(getObjectId());
if (clanMember != null)
{
clanMember.setClanContribution(getClanContribution());
clanMember.setClanContributionTotal(getClanContributionTotal());
clanMember.setPlayerInstance(null);
}
}

View File

@ -65,6 +65,7 @@ import org.l2jmobius.gameserver.model.itemcontainer.ClanWarehouse;
import org.l2jmobius.gameserver.model.itemcontainer.ItemContainer;
import org.l2jmobius.gameserver.model.skills.Skill;
import org.l2jmobius.gameserver.model.variables.ClanVariables;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
@ -503,6 +504,9 @@ public class Clan implements IIdentifiable, INamable
player.setApprentice(0);
player.setSponsor(0);
player.getVariables().remove(PlayerVariables.CLAN_CONTRIBUTION);
player.getVariables().remove(PlayerVariables.CLAN_CONTRIBUTION_TOTAL);
if (player.isClanLeader())
{
SiegeManager.getInstance().removeSiegeSkills(player);
@ -965,7 +969,9 @@ public class Clan implements IIdentifiable, INamable
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps1 = con.prepareStatement("UPDATE characters SET clanid=0, title=?, clan_join_expiry_time=?, clan_create_expiry_time=?, clan_privs=0, wantspeace=0, subpledge=0, lvl_joined_academy=0, apprentice=0, sponsor=0 WHERE charId=?");
PreparedStatement ps2 = con.prepareStatement("UPDATE characters SET apprentice=0 WHERE apprentice=?");
PreparedStatement ps3 = con.prepareStatement("UPDATE characters SET sponsor=0 WHERE sponsor=?"))
PreparedStatement ps3 = con.prepareStatement("UPDATE characters SET sponsor=0 WHERE sponsor=?");
PreparedStatement ps4 = con.prepareStatement("DELETE FROM character_variables WHERE var=?");
PreparedStatement ps5 = con.prepareStatement("DELETE FROM character_variables WHERE var=?"))
{
ps1.setString(1, "");
ps1.setLong(2, clanJoinExpiryTime);
@ -978,6 +984,11 @@ public class Clan implements IIdentifiable, INamable
// Remove sponsor.
ps3.setInt(1, member.getObjectId());
ps3.execute();
// Clan contribution.
ps4.setString(1, PlayerVariables.CLAN_CONTRIBUTION);
ps4.execute();
ps5.setString(1, PlayerVariables.CLAN_CONTRIBUTION_TOTAL);
ps5.execute();
}
catch (Exception e)
{

View File

@ -26,6 +26,7 @@ import java.util.logging.Logger;
import org.l2jmobius.commons.database.DatabaseFactory;
import org.l2jmobius.gameserver.instancemanager.SiegeManager;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
/**
* This class holds the clan members data.
@ -47,6 +48,8 @@ public class ClanMember
private int _pledgeType;
private int _apprentice;
private int _sponsor;
private int _clanContribution = -1;
private int _clanContributionTotal = -1;
/**
* Used to restore a clan member from the database.
@ -813,4 +816,78 @@ public class ClanMember
LOGGER.log(Level.WARNING, "Could not save apprentice/sponsor: " + e.getMessage(), e);
}
}
public void setClanContribution(int value)
{
_clanContribution = value;
}
public int getClanContribution()
{
if (_clanContribution == -1)
{
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM character_variables WHERE charId=? AND var=?"))
{
ps.setInt(1, _objectId);
ps.setString(2, PlayerVariables.CLAN_CONTRIBUTION);
try (ResultSet result = ps.executeQuery())
{
if (result.next())
{
_clanContribution = result.getInt("val");
}
}
}
catch (SQLException e)
{
LOGGER.log(Level.WARNING, "Could not load Clan Contribution: " + e.getMessage(), e);
}
// Avoid further queries.
if (_clanContribution == -1)
{
_clanContribution = 0;
}
}
return _clanContribution;
}
public void setClanContributionTotal(int value)
{
_clanContributionTotal = value;
}
public int getClanContributionTotal()
{
if (_clanContributionTotal == -1)
{
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement ps = con.prepareStatement("SELECT * FROM character_variables WHERE charId=? AND var=?"))
{
ps.setInt(1, _objectId);
ps.setString(2, PlayerVariables.CLAN_CONTRIBUTION_TOTAL);
try (ResultSet result = ps.executeQuery())
{
if (result.next())
{
_clanContributionTotal = result.getInt("val");
}
}
}
catch (SQLException e)
{
LOGGER.log(Level.WARNING, "Could not load Clan Contribution total: " + e.getMessage(), e);
}
// Avoid further queries.
if (_clanContributionTotal == -1)
{
_clanContributionTotal = 0;
}
}
return _clanContributionTotal;
}
}

View File

@ -65,6 +65,9 @@ public class PlayerVariables extends AbstractVariables
public static final String FORTUNE_TELLING_VARIABLE = "FortuneTelling";
public static final String FORTUNE_TELLING_BLACK_CAT_VARIABLE = "FortuneTellingBlackCat";
public static final String DELUSION_RETURN = "DELUSION_RETURN";
public static final String CLAN_CONTRIBUTION = "CLAN_CONTRIBUTION";
public static final String CLAN_CONTRIBUTION_TOTAL = "CLAN_CONTRIBUTION_TOTAL";
public static final String CLAN_CONTRIBUTION_REWARDED = "CLAN_CONTRIBUTION_REWARDED";
public static final String AUTO_USE_SETTINGS = "AUTO_USE_SETTINGS";
public static final String AUTO_USE_SHORTCUTS = "AUTO_USE_SHORTCUTS";
public static final String HUNTING_ZONE_ENTRY = "HUNTING_ZONE_ENTRY_";

View File

@ -111,6 +111,9 @@ import org.l2jmobius.gameserver.network.clientpackets.mentoring.RequestMentorLis
import org.l2jmobius.gameserver.network.clientpackets.pk.RequestExPkPenaltyList;
import org.l2jmobius.gameserver.network.clientpackets.pk.RequestExPkPenaltyListOnlyLoc;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeAnnounce;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeContributionInfo;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeContributionRank;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeContributionReward;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeItemBuy;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeItemList;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV2.RequestExPledgeLevelUp;
@ -469,9 +472,9 @@ public enum ExIncomingPackets implements IIncomingPackets<GameClient>
EX_ARENA_RANK_ALL(0x13A, null, ConnectionState.IN_GAME),
EX_ARENA_MYRANK(0x13B, null, ConnectionState.IN_GAME),
EX_SWAP_AGATHION_SLOT_ITEMS(0x13C, null, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_RANK(0x13D, null, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_INFO(0x13E, null, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_REWARD(0x13F, null, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_RANK(0x13D, RequestExPledgeContributionRank::new, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_INFO(0x13E, RequestExPledgeContributionInfo::new, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_REWARD(0x13F, RequestExPledgeContributionReward::new, ConnectionState.IN_GAME),
EX_PLEDGE_LEVEL_UP(0x140, RequestExPledgeLevelUp::new, ConnectionState.IN_GAME),
EX_PLEDGE_MISSION_INFO(0x141, RequestExPledgeMissionInfo::new, ConnectionState.IN_GAME),
EX_PLEDGE_MISSION_REWARD(0x142, RequestExPledgeMissionReward::new, ConnectionState.IN_GAME),

View File

@ -0,0 +1,47 @@
/*
* 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.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.pledgeV2.ExPledgeContributionInfo;
/**
* @author Mobius
*/
public class RequestExPledgeContributionInfo implements IClientIncomingPacket
{
@Override
public boolean read(GameClient client, PacketReader packet)
{
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if ((player == null) || (player.getClan() == null))
{
return;
}
client.sendPacket(new ExPledgeContributionInfo(player));
}
}

View File

@ -0,0 +1,57 @@
/*
* 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.ExPledgeContributionRank;
/**
* @author Mobius
*/
public class RequestExPledgeContributionRank implements IClientIncomingPacket
{
private int _cycle;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_cycle = packet.readC();
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;
}
client.sendPacket(new ExPledgeContributionRank(clan, _cycle));
}
}

View File

@ -0,0 +1,66 @@
/*
* 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.Config;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.variables.PlayerVariables;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
/**
* @author Mobius
*/
public class RequestExPledgeContributionReward implements IClientIncomingPacket
{
@Override
public boolean read(GameClient client, PacketReader packet)
{
return true;
}
@Override
public void run(GameClient client)
{
if (!client.getFloodProtectors().canPerformTransaction())
{
return;
}
final PlayerInstance player = client.getPlayer();
if ((player == null) || (player.getClan() == null))
{
return;
}
if (player.getClanContribution() < Config.CLAN_CONTRIBUTION_REQUIRED)
{
return;
}
if (player.getVariables().getBoolean(PlayerVariables.CLAN_CONTRIBUTION_REWARDED, false))
{
player.sendMessage("You have already been rewarded for this cycle.");
return;
}
player.getVariables().set(PlayerVariables.CLAN_CONTRIBUTION_REWARDED, true);
player.setFame(player.getFame() + Config.CLAN_CONTRIBUTION_FAME_REWARD);
player.sendMessage("You have been rewarded with " + Config.CLAN_CONTRIBUTION_FAME_REWARD + " fame points.");
}
}

View File

@ -0,0 +1,54 @@
/*
* 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.Config;
import org.l2jmobius.commons.network.PacketWriter;
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 ExPledgeContributionInfo implements IClientOutgoingPacket
{
private final PlayerInstance _player;
public ExPledgeContributionInfo(PlayerInstance player)
{
_player = player;
}
@Override
public boolean write(PacketWriter packet)
{
if (_player.getClan() == null)
{
return false;
}
OutgoingPackets.EX_PLEDGE_CONTRIBUTION_INFO.writeId(packet);
packet.writeD(_player.getClanContribution());
packet.writeD(_player.getClanContribution());
packet.writeD(Config.CLAN_CONTRIBUTION_REQUIRED);
packet.writeD(-1);
packet.writeD(0);
packet.writeD(Config.CLAN_CONTRIBUTION_FAME_REWARD);
return true;
}
}

View File

@ -0,0 +1,76 @@
/*
* 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.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.clan.Clan;
import org.l2jmobius.gameserver.model.clan.ClanMember;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* @author Mobius
*/
public class ExPledgeContributionRank implements IClientOutgoingPacket
{
private final Clan _clan;
private final int _cycle;
public ExPledgeContributionRank(Clan clan, int cycle)
{
_clan = clan;
_cycle = cycle;
}
@Override
public boolean write(PacketWriter packet)
{
if (_clan == null)
{
return false;
}
OutgoingPackets.EX_PLEDGE_CONTRIBUTION_RANK.writeId(packet);
packet.writeC(_cycle);
packet.writeD(_clan.getMembersCount());
int order = 1;
for (ClanMember member : _clan.getMembers())
{
if (member.isOnline())
{
final PlayerInstance player = member.getPlayerInstance();
packet.writeD(order++); // Order?
packet.writeS(String.format("%1$-" + 24 + "s", player.getName()));
packet.writeD(player.getPledgeType());
packet.writeD(player.getClanContribution());
packet.writeD(player.getClanContributionTotal());
}
else
{
packet.writeD(order++); // Order?
packet.writeS(String.format("%1$-" + 24 + "s", member.getName()));
packet.writeD(member.getPledgeType());
packet.writeD(member.getClanContribution());
packet.writeD(member.getClanContributionTotal());
}
}
return true;
}
}