New pledge related implementations.

Contributed by iDesy.
This commit is contained in:
MobiusDevelopment 2021-05-23 00:50:22 +00:00
parent a76f2abd78
commit a846368daf
30 changed files with 1282 additions and 13 deletions

View File

@ -0,0 +1,6 @@
DROP TABLE IF EXISTS `character_pledge_donation`;
CREATE TABLE IF NOT EXISTS `character_pledge_donation` (
`charId` int(10) unsigned NOT NULL DEFAULT 0,
`points` int(10) UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (`charId`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;

View File

@ -76,6 +76,7 @@ public class DailyTaskManager extends AbstractEventManager<AbstractEvent<?>>
resetTrainingCamp(); resetTrainingCamp();
resetVitality(); resetVitality();
resetVip(); resetVip();
resetClanDonationPoints();
} }
@ScheduleTarget @ScheduleTarget
@ -174,6 +175,15 @@ public class DailyTaskManager extends AbstractEventManager<AbstractEvent<?>>
LOGGER.info("Clan leaders has been updated."); LOGGER.info("Clan leaders has been updated.");
} }
@ScheduleTarget
private void onWeeklyResetContributionList()
{
for (Clan clan : ClanTable.getInstance().getClans())
{
clan.getVariables().deleteWeeklyContribution();
}
}
@ScheduleTarget @ScheduleTarget
private void onVitalityReset() private void onVitalityReset()
{ {
@ -239,6 +249,27 @@ public class DailyTaskManager extends AbstractEventManager<AbstractEvent<?>>
LOGGER.info("Daily skill reuse cleaned."); LOGGER.info("Daily skill reuse cleaned.");
} }
private void resetClanDonationPoints()
{
try (Connection con = DatabaseFactory.getConnection())
{
try (PreparedStatement ps = con.prepareStatement("DELETE FROM character_pledge_donation WHERE points < ?"))
{
ps.setInt(1, 4);
ps.execute();
}
World.getInstance().getPlayers().forEach(player ->
{
player.setClanDonationPoints(3);
});
}
catch (Exception e)
{
LOGGER.log(Level.SEVERE, "Could not reset clan donation points: ", e);
}
LOGGER.info("Weekly caln contributions cleaned.");
}
private void resetWorldChatPoints() private void resetWorldChatPoints()
{ {
if (!Config.ENABLE_WORLD_CHAT) if (!Config.ENABLE_WORLD_CHAT)

View File

@ -300,6 +300,11 @@ public class Attackable extends Npc
if ((killer != null) && (killer.getActingPlayer() != null)) if ((killer != null) && (killer.getActingPlayer() != null))
{ {
if ((killer.getClan() != null) && (Rnd.get(100) < 2))
{
killer.getClan().addExp(killer.getObjectId(), 1, true);
}
// Delayed notification // Delayed notification
EventDispatcher.getInstance().notifyEventAsync(new OnAttackableKill(killer.getActingPlayer(), this, killer.isSummon()), this); EventDispatcher.getInstance().notifyEventAsync(new OnAttackableKill(killer.getActingPlayer(), this, killer.isSummon()), this);
} }

View File

@ -455,6 +455,11 @@ public class PlayerInstance extends Playable
private static final String INSERT_SUBJUGATION = "REPLACE INTO character_purge (`charId`, `category`, `points`, `keys`) VALUES (?, ?, ?, ?)"; private static final String INSERT_SUBJUGATION = "REPLACE INTO character_purge (`charId`, `category`, `points`, `keys`) VALUES (?, ?, ?, ?)";
private static final String RESTORE_SUBJUGATION = "SELECT * FROM character_purge WHERE charId=?"; private static final String RESTORE_SUBJUGATION = "SELECT * FROM character_purge WHERE charId=?";
// Pledge donation:
private static final String DELETE_CLAN_DONATION = "DELETE FROM character_pledge_donation WHERE charId=?";
private static final String INSERT_CLAN_DONATION = "REPLACE INTO character_pledge_donation (`charId`, `points`) VALUES (?, ?)";
private static final String RESTORE_CLAN_DONATION = "SELECT * FROM character_pledge_donation WHERE charId=?";
// Elemental Spirits: // Elemental Spirits:
private static final String RESTORE_ELEMENTAL_SPIRITS = "SELECT * FROM character_spirits WHERE charId=?"; private static final String RESTORE_ELEMENTAL_SPIRITS = "SELECT * FROM character_spirits WHERE charId=?";
@ -934,6 +939,8 @@ public class PlayerInstance extends Playable
private final Map<Integer, PetEvolveHolder> _petEvolves = new HashMap<>(); private final Map<Integer, PetEvolveHolder> _petEvolves = new HashMap<>();
private int _clanDonationPoints = 3;
private final List<QuestTimer> _questTimers = new ArrayList<>(); private final List<QuestTimer> _questTimers = new ArrayList<>();
private final List<TimerHolder<?>> _timerHolders = new ArrayList<>(); private final List<TimerHolder<?>> _timerHolders = new ArrayList<>();
@ -2808,6 +2815,16 @@ public class PlayerInstance extends Playable
_clanJoinExpiryTime = time; _clanJoinExpiryTime = time;
} }
public long getClanJoinTime()
{
return getVariables().getLong(PlayerVariables.CLAN_JOIN_TIME, 0L);
}
public void setClanJoinTime(long time)
{
getVariables().set(PlayerVariables.CLAN_JOIN_TIME, time);
}
public long getClanCreateExpiryTime() public long getClanCreateExpiryTime()
{ {
return _clanCreateExpiryTime; return _clanCreateExpiryTime;
@ -6985,6 +7002,10 @@ public class PlayerInstance extends Playable
// Purge. // Purge.
restoreSubjugation(); restoreSubjugation();
// Clan donation.
restoreClanDonation();
// Load Premium Item List. // Load Premium Item List.
loadPremiumItemList(); loadPremiumItemList();
@ -7139,6 +7160,9 @@ public class PlayerInstance extends Playable
// Purge. // Purge.
storeSubjugation(); storeSubjugation();
// Pledge donation.
storePledgeDonation();
final PlayerVariables vars = getScript(PlayerVariables.class); final PlayerVariables vars = getScript(PlayerVariables.class);
if (vars != null) if (vars != null)
{ {
@ -14930,4 +14954,57 @@ public class PlayerInstance extends Playable
LOGGER.log(Level.SEVERE, "Could not restore subjugation data for playerId: " + getObjectId(), e); LOGGER.log(Level.SEVERE, "Could not restore subjugation data for playerId: " + getObjectId(), e);
} }
} }
public int getClanDonationPoints()
{
return _clanDonationPoints;
}
public void setClanDonationPoints(int points)
{
_clanDonationPoints = points;
}
public void storePledgeDonation()
{
try (Connection con = DatabaseFactory.getConnection())
{
try (PreparedStatement st = con.prepareStatement(DELETE_CLAN_DONATION))
{
st.setInt(1, getObjectId());
st.execute();
}
try (PreparedStatement st = con.prepareStatement(INSERT_CLAN_DONATION))
{
st.setInt(1, getObjectId());
st.setInt(2, getClanDonationPoints());
st.execute();
}
}
catch (Exception e)
{
LOGGER.log(Level.SEVERE, "Could not store clan donation points for playerId " + getObjectId() + ": ", e);
}
}
private void restoreClanDonation()
{
try (Connection con = DatabaseFactory.getConnection();
PreparedStatement statement = con.prepareStatement(RESTORE_CLAN_DONATION))
{
statement.setInt(1, getObjectId());
try (ResultSet rset = statement.executeQuery())
{
if (rset.next())
{
setClanDonationPoints(rset.getInt("points"));
}
}
}
catch (Exception e)
{
LOGGER.log(Level.SEVERE, "Could not restore clan donation points for playerId: " + getObjectId(), e);
}
}
} }

View File

@ -31,6 +31,7 @@ import java.util.concurrent.ConcurrentSkipListMap;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.stream.Collectors;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.concurrent.ThreadPool;
@ -77,6 +78,8 @@ import org.l2jmobius.gameserver.network.serverpackets.PledgeShowMemberListDelete
import org.l2jmobius.gameserver.network.serverpackets.PledgeShowMemberListUpdate; import org.l2jmobius.gameserver.network.serverpackets.PledgeShowMemberListUpdate;
import org.l2jmobius.gameserver.network.serverpackets.PledgeSkillList; import org.l2jmobius.gameserver.network.serverpackets.PledgeSkillList;
import org.l2jmobius.gameserver.network.serverpackets.PledgeSkillList.SubPledgeSkill; import org.l2jmobius.gameserver.network.serverpackets.PledgeSkillList.SubPledgeSkill;
import org.l2jmobius.gameserver.network.serverpackets.pledgeV3.ExPledgeLevelUp;
import org.l2jmobius.gameserver.network.serverpackets.pledgeV3.ExPledgeV3Info;
import org.l2jmobius.gameserver.network.serverpackets.PledgeSkillListAdd; import org.l2jmobius.gameserver.network.serverpackets.PledgeSkillListAdd;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage; import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import org.l2jmobius.gameserver.network.serverpackets.UserInfo; import org.l2jmobius.gameserver.network.serverpackets.UserInfo;
@ -2233,8 +2236,9 @@ public class Clan implements IIdentifiable, INamable
} }
if (target.getClanJoinExpiryTime() > Chronos.currentTimeMillis()) if (target.getClanJoinExpiryTime() > Chronos.currentTimeMillis())
{ {
final SystemMessage sm = new SystemMessage(SystemMessageId.C1_WILL_BE_ABLE_TO_JOIN_YOUR_CLAN_IN_24_H_AFTER_LEAVING_THE_PREVIOUS_ONE); final SystemMessage sm = new SystemMessage(SystemMessageId.C1_WILL_BE_ABLE_TO_JOIN_YOUR_CLAN_IN_S2_MIN_AFTER_LEAVING_THE_PREVIOUS_ONE);
sm.addString(target.getName()); sm.addString(target.getName());
sm.addInt(Config.ALT_CLAN_JOIN_DAYS);
player.sendPacket(sm); player.sendPacket(sm);
return false; return false;
} }
@ -2486,6 +2490,7 @@ public class Clan implements IIdentifiable, INamable
updateClanInDB(); updateClanInDB();
} }
// Unused?
public boolean levelUpClan(PlayerInstance player) public boolean levelUpClan(PlayerInstance player)
{ {
if (!player.isClanLeader()) if (!player.isClanLeader())
@ -2635,6 +2640,7 @@ public class Clan implements IIdentifiable, INamable
} }
// notify all the members about it // notify all the members about it
broadcastToOnlineMembers(new ExPledgeLevelUp(level));
broadcastToOnlineMembers(new SystemMessage(SystemMessageId.YOUR_CLAN_S_LEVEL_HAS_INCREASED)); broadcastToOnlineMembers(new SystemMessage(SystemMessageId.YOUR_CLAN_S_LEVEL_HAS_INCREASED));
broadcastToOnlineMembers(new PledgeShowInfoUpdate(this)); broadcastToOnlineMembers(new PledgeShowInfoUpdate(this));
} }
@ -3064,14 +3070,40 @@ public class Clan implements IIdentifiable, INamable
} }
} }
public int getClanContribution(int objId)
{
return getVariables().getInt(ClanVariables.CONTRIBUTION + objId, 0);
}
public void setClanContribution(int objId, int exp)
{
getVariables().set(ClanVariables.CONTRIBUTION + objId, exp);
}
public int getClanContributionWeekly(int objId)
{
return getVariables().getInt(ClanVariables.CONTRIBUTION_WEEKLY + objId, 0);
}
public Collection<ClanMember> getContributionList()
{
return getMembers().stream().filter(it -> it.getClan().getClanContribution(it.getObjectId()) != 0).collect(Collectors.toList());
}
public void setClanContributionWeekly(int objId, int exp)
{
getVariables().set(ClanVariables.CONTRIBUTION_WEEKLY + objId, exp);
}
public int getExp() public int getExp()
{ {
return _exp; return _exp;
} }
public void addExp(int value, boolean save) public void addExp(int objId, int value, boolean save)
{ {
_exp += value; _exp += value;
broadcastToOnlineMembers(new ExPledgeV3Info(_exp, getRank(), getNotice(), isNoticeEnabled()));
if (EXP_TABLE[getLevel()] <= _exp) if (EXP_TABLE[getLevel()] <= _exp)
{ {
@ -3080,6 +3112,9 @@ public class Clan implements IIdentifiable, INamable
if (save) if (save)
{ {
final int contribution = getClanContribution(objId);
setClanContribution(objId, contribution + value);
setClanContributionWeekly(objId, contribution + value);
updateClanInDB(); updateClanInDB();
} }
} }

View File

@ -23,6 +23,7 @@ import java.sql.SQLException;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.stream.Collectors;
import org.l2jmobius.commons.database.DatabaseFactory; import org.l2jmobius.commons.database.DatabaseFactory;
@ -37,6 +38,9 @@ public class ClanVariables extends AbstractVariables
private static final String SELECT_QUERY = "SELECT * FROM clan_variables WHERE clanId = ?"; private static final String SELECT_QUERY = "SELECT * FROM clan_variables WHERE clanId = ?";
private static final String DELETE_QUERY = "DELETE FROM clan_variables WHERE clanId = ?"; private static final String DELETE_QUERY = "DELETE FROM clan_variables WHERE clanId = ?";
private static final String INSERT_QUERY = "INSERT INTO clan_variables (clanId, var, val) VALUES (?, ?, ?)"; private static final String INSERT_QUERY = "INSERT INTO clan_variables (clanId, var, val) VALUES (?, ?, ?)";
private static final String DELETE_WEAKLY_QUERY = "DELETE FROM clan_variables WHERE var LIKE 'CONTRIBUTION_WEEKLY_%' AND clanId = ?";
public static final String CONTRIBUTION = "CONTRIBUTION_";
public static final String CONTRIBUTION_WEEKLY = "CONTRIBUTION_WEEKLY_";
private final int _objectId; private final int _objectId;
@ -139,4 +143,26 @@ public class ClanVariables extends AbstractVariables
} }
return true; return true;
} }
public boolean deleteWeeklyContribution()
{
try (Connection con = DatabaseFactory.getConnection())
{
// Clear previous entries.
try (PreparedStatement st = con.prepareStatement(DELETE_WEAKLY_QUERY))
{
st.setInt(1, _objectId);
st.execute();
}
// Clear all entries
getSet().entrySet().stream().filter(it -> it.getKey().startsWith("CONTRIBUTION_WEEKLY_")).collect(Collectors.toList()).forEach(it -> getSet().remove(it.getKey()));
}
catch (Exception e)
{
LOGGER.log(Level.WARNING, getClass().getSimpleName() + ": Couldn't delete variables for: " + _objectId, e);
return false;
}
return true;
}
} }

View File

@ -78,6 +78,7 @@ public class PlayerVariables extends AbstractVariables
public static final String STAT_INT = "STAT_INT"; public static final String STAT_INT = "STAT_INT";
public static final String STAT_WIT = "STAT_WIT"; public static final String STAT_WIT = "STAT_WIT";
public static final String STAT_MEN = "STAT_MEN"; public static final String STAT_MEN = "STAT_MEN";
public static final String CLAN_JOIN_TIME = "CLAN_JOIN_TIME";
private final int _objectId; private final int _objectId;

View File

@ -104,9 +104,17 @@ import org.l2jmobius.gameserver.network.clientpackets.pet.ExEvolvePet;
import org.l2jmobius.gameserver.network.clientpackets.pet.ExPetEquipItem; import org.l2jmobius.gameserver.network.clientpackets.pet.ExPetEquipItem;
import org.l2jmobius.gameserver.network.clientpackets.pet.ExPetUnequipItem; import org.l2jmobius.gameserver.network.clientpackets.pet.ExPetUnequipItem;
import org.l2jmobius.gameserver.network.clientpackets.pet.RequestExAcquirePetSkill; import org.l2jmobius.gameserver.network.clientpackets.pet.RequestExAcquirePetSkill;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV3.RequestExPledgeEnemyDelete;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV3.RequestExPledgeEnemyInfoList;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV3.RequestExPledgeEnemyRegister;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV3.RequestExPledgeV3Info;
import org.l2jmobius.gameserver.network.clientpackets.pledgeV3.RequestExPledgeV3SetAnnounce;
import org.l2jmobius.gameserver.network.clientpackets.pledgebonus.RequestPledgeBonusOpen; import org.l2jmobius.gameserver.network.clientpackets.pledgebonus.RequestPledgeBonusOpen;
import org.l2jmobius.gameserver.network.clientpackets.pledgebonus.RequestPledgeBonusReward; import org.l2jmobius.gameserver.network.clientpackets.pledgebonus.RequestPledgeBonusReward;
import org.l2jmobius.gameserver.network.clientpackets.pledgebonus.RequestPledgeBonusRewardList; import org.l2jmobius.gameserver.network.clientpackets.pledgebonus.RequestPledgeBonusRewardList;
import org.l2jmobius.gameserver.network.clientpackets.pledgedonation.RequestExPledgeContributionList;
import org.l2jmobius.gameserver.network.clientpackets.pledgedonation.RequestExPledgeDonationInfo;
import org.l2jmobius.gameserver.network.clientpackets.pledgedonation.RequestExPledgeDonationRequest;
import org.l2jmobius.gameserver.network.clientpackets.primeshop.RequestBRBuyProduct; import org.l2jmobius.gameserver.network.clientpackets.primeshop.RequestBRBuyProduct;
import org.l2jmobius.gameserver.network.clientpackets.primeshop.RequestBRGamePoint; import org.l2jmobius.gameserver.network.clientpackets.primeshop.RequestBRGamePoint;
import org.l2jmobius.gameserver.network.clientpackets.primeshop.RequestBRPresentBuyProduct; import org.l2jmobius.gameserver.network.clientpackets.primeshop.RequestBRPresentBuyProduct;
@ -615,14 +623,14 @@ public enum ExIncomingPackets implements IIncomingPackets<GameClient>
EX_PVP_RANKING_MY_INFO(0x1C2, RequestPvpRankingMyInfo::new, ConnectionState.IN_GAME), EX_PVP_RANKING_MY_INFO(0x1C2, RequestPvpRankingMyInfo::new, ConnectionState.IN_GAME),
EX_PVP_RANKING_LIST(0x1C3, RequestPvpRankingList::new, ConnectionState.IN_GAME), EX_PVP_RANKING_LIST(0x1C3, RequestPvpRankingList::new, ConnectionState.IN_GAME),
EX_ACQUIRE_PET_SKILL(0x1C4, RequestExAcquirePetSkill::new, ConnectionState.IN_GAME), EX_ACQUIRE_PET_SKILL(0x1C4, RequestExAcquirePetSkill::new, ConnectionState.IN_GAME),
EX_PLEDGE_V3_INFO(0x1C5, null, ConnectionState.IN_GAME), EX_PLEDGE_V3_INFO(0x1C5, RequestExPledgeV3Info::new, ConnectionState.IN_GAME),
EX_PLEDGE_ENEMY_INFO_LIST(0x1C6, null, ConnectionState.IN_GAME), EX_PLEDGE_ENEMY_INFO_LIST(0x1C6, RequestExPledgeEnemyInfoList::new, ConnectionState.IN_GAME),
EX_PLEDGE_ENEMY_REGISTER(0x1C7, null, ConnectionState.IN_GAME), EX_PLEDGE_ENEMY_REGISTER(0x1C7, RequestExPledgeEnemyRegister::new, ConnectionState.IN_GAME),
EX_PLEDGE_ENEMY_DELETE(0x1C8, null, ConnectionState.IN_GAME), EX_PLEDGE_ENEMY_DELETE(0x1C8, RequestExPledgeEnemyDelete::new, ConnectionState.IN_GAME),
EX_PK_PENALTY_LIST(0x1C9, null, ConnectionState.IN_GAME), EX_PK_PENALTY_LIST(0x1C9, null, ConnectionState.IN_GAME),
EX_PK_PENALTY_LIST_ONLY_LOC(0x1CA, null, ConnectionState.IN_GAME), EX_PK_PENALTY_LIST_ONLY_LOC(0x1CA, null, ConnectionState.IN_GAME),
EX_TRY_PET_EXTRACT_SYSTEM(0x1CB, null, ConnectionState.IN_GAME), EX_TRY_PET_EXTRACT_SYSTEM(0x1CB, null, ConnectionState.IN_GAME),
EX_PLEDGE_V3_SET_ANNOUNCE(0x1CC, null, ConnectionState.IN_GAME), EX_PLEDGE_V3_SET_ANNOUNCE(0x1CC, RequestExPledgeV3SetAnnounce::new, ConnectionState.IN_GAME),
// 306 // 306
EX_RANKING_FESTIVAL_OPEN(0x1CD, null, ConnectionState.IN_GAME), EX_RANKING_FESTIVAL_OPEN(0x1CD, null, ConnectionState.IN_GAME),
EX_RANKING_FESTIVAL_BUY(0x1CE, null, ConnectionState.IN_GAME), EX_RANKING_FESTIVAL_BUY(0x1CE, null, ConnectionState.IN_GAME),
@ -661,9 +669,9 @@ public enum ExIncomingPackets implements IIncomingPackets<GameClient>
EX_SUBJUGATION_RANKING(0x1EF, RequestSubjugationRanking::new, ConnectionState.IN_GAME), EX_SUBJUGATION_RANKING(0x1EF, RequestSubjugationRanking::new, ConnectionState.IN_GAME),
EX_SUBJUGATION_GACHA_UI(0x1F0, RequestSubjugationGachaUI::new, ConnectionState.IN_GAME), EX_SUBJUGATION_GACHA_UI(0x1F0, RequestSubjugationGachaUI::new, ConnectionState.IN_GAME),
EX_SUBJUGATION_GACHA(0x1F1, RequestSubjugationGacha::new, ConnectionState.IN_GAME), EX_SUBJUGATION_GACHA(0x1F1, RequestSubjugationGacha::new, ConnectionState.IN_GAME),
EX_PLEDGE_DONATION_INFO(0x1F2, null, ConnectionState.IN_GAME), EX_PLEDGE_DONATION_INFO(0x1F2, RequestExPledgeDonationInfo::new, ConnectionState.IN_GAME),
EX_PLEDGE_DONATION_REQUEST(0x1F3, null, ConnectionState.IN_GAME), EX_PLEDGE_DONATION_REQUEST(0x1F3, RequestExPledgeDonationRequest::new, ConnectionState.IN_GAME),
EX_PLEDGE_CONTRIBUTION_LIST(0x1F4, null, ConnectionState.IN_GAME), EX_PLEDGE_CONTRIBUTION_LIST(0x1F4, RequestExPledgeContributionList::new, ConnectionState.IN_GAME),
EX_PLEDGE_RANKING_MY_INFO(0x1F5, RequestPledgeRankingMyInfo::new, ConnectionState.IN_GAME), EX_PLEDGE_RANKING_MY_INFO(0x1F5, RequestPledgeRankingMyInfo::new, ConnectionState.IN_GAME),
EX_PLEDGE_RANKING_LIST(0x1F6, RequestPledgeRankingList::new, ConnectionState.IN_GAME), EX_PLEDGE_RANKING_LIST(0x1F6, RequestPledgeRankingList::new, ConnectionState.IN_GAME),
EX_ITEM_RESTORE_LIST(0x1F7, null, ConnectionState.IN_GAME), EX_ITEM_RESTORE_LIST(0x1F7, null, ConnectionState.IN_GAME),

View File

@ -114,6 +114,7 @@ import org.l2jmobius.gameserver.network.serverpackets.dailymission.ExOneDayRecei
import org.l2jmobius.gameserver.network.serverpackets.friend.L2FriendList; import org.l2jmobius.gameserver.network.serverpackets.friend.L2FriendList;
import org.l2jmobius.gameserver.network.serverpackets.limitshop.ExBloodyCoinCount; import org.l2jmobius.gameserver.network.serverpackets.limitshop.ExBloodyCoinCount;
import org.l2jmobius.gameserver.network.serverpackets.magiclamp.ExMagicLampExpInfoUI; import org.l2jmobius.gameserver.network.serverpackets.magiclamp.ExMagicLampExpInfoUI;
import org.l2jmobius.gameserver.network.serverpackets.pledgedonation.ExPledgeContributionList;
import org.l2jmobius.gameserver.network.serverpackets.randomcraft.ExCraftInfo; import org.l2jmobius.gameserver.network.serverpackets.randomcraft.ExCraftInfo;
import org.l2jmobius.gameserver.network.serverpackets.subjugation.ExSubjugationSidebar; import org.l2jmobius.gameserver.network.serverpackets.subjugation.ExSubjugationSidebar;
import org.l2jmobius.gameserver.util.BuilderUtil; import org.l2jmobius.gameserver.util.BuilderUtil;
@ -808,6 +809,8 @@ public class EnterWorld implements IClientIncomingPacket
msg.addString(player.getName()); msg.addString(player.getName());
clan.broadcastToOtherOnlineMembers(msg, player); clan.broadcastToOtherOnlineMembers(msg, player);
clan.broadcastToOtherOnlineMembers(new PledgeShowMemberListUpdate(player), player); clan.broadcastToOtherOnlineMembers(new PledgeShowMemberListUpdate(player), player);
player.sendPacket(new ExPledgeContributionList(clan.getMembers()));
} }
} }

View File

@ -16,6 +16,7 @@
*/ */
package org.l2jmobius.gameserver.network.clientpackets; package org.l2jmobius.gameserver.network.clientpackets;
import org.l2jmobius.Config;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.commons.util.Chronos; import org.l2jmobius.commons.util.Chronos;
import org.l2jmobius.gameserver.instancemanager.CastleManager; import org.l2jmobius.gameserver.instancemanager.CastleManager;
@ -70,8 +71,9 @@ public class RequestPledgeSignInForOpenJoiningMethod implements IClientIncomingP
} }
if (player.getClanJoinExpiryTime() > Chronos.currentTimeMillis()) if (player.getClanJoinExpiryTime() > Chronos.currentTimeMillis())
{ {
final SystemMessage sm = new SystemMessage(SystemMessageId.C1_WILL_BE_ABLE_TO_JOIN_YOUR_CLAN_IN_24_H_AFTER_LEAVING_THE_PREVIOUS_ONE); final SystemMessage sm = new SystemMessage(SystemMessageId.C1_WILL_BE_ABLE_TO_JOIN_YOUR_CLAN_IN_S2_MIN_AFTER_LEAVING_THE_PREVIOUS_ONE);
sm.addString(player.getName()); sm.addString(player.getName());
sm.addInt(Config.ALT_CLAN_JOIN_DAYS);
player.sendPacket(sm); player.sendPacket(sm);
return; return;
} }
@ -112,6 +114,7 @@ public class RequestPledgeSignInForOpenJoiningMethod implements IClientIncomingP
// This activates the clan tab on the new member. // This activates the clan tab on the new member.
PledgeShowMemberListAll.sendAllTo(player); PledgeShowMemberListAll.sendAllTo(player);
player.setClanJoinExpiryTime(0); player.setClanJoinExpiryTime(0);
player.setClanJoinTime(Chronos.currentTimeMillis());
player.broadcastUserInfo(); player.broadcastUserInfo();
ClanEntryManager.getInstance().removePlayerApplication(_clanId, player.getObjectId()); ClanEntryManager.getInstance().removePlayerApplication(_clanId, player.getObjectId());

View File

@ -17,6 +17,7 @@
package org.l2jmobius.gameserver.network.clientpackets; package org.l2jmobius.gameserver.network.clientpackets;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.commons.util.Chronos;
import org.l2jmobius.gameserver.instancemanager.CastleManager; import org.l2jmobius.gameserver.instancemanager.CastleManager;
import org.l2jmobius.gameserver.instancemanager.ClanEntryManager; import org.l2jmobius.gameserver.instancemanager.ClanEntryManager;
import org.l2jmobius.gameserver.instancemanager.FortManager; import org.l2jmobius.gameserver.instancemanager.FortManager;
@ -94,6 +95,7 @@ public class RequestPledgeWaitingUserAccept implements IClientIncomingPacket
// This activates the clan tab on the new member. // This activates the clan tab on the new member.
PledgeShowMemberListAll.sendAllTo(target); PledgeShowMemberListAll.sendAllTo(target);
target.setClanJoinExpiryTime(0); target.setClanJoinExpiryTime(0);
player.setClanJoinTime(Chronos.currentTimeMillis());
target.broadcastUserInfo(); target.broadcastUserInfo();
ClanEntryManager.getInstance().removePlayerApplication(_clanId, _playerId); ClanEntryManager.getInstance().removePlayerApplication(_clanId, _playerId);

View File

@ -0,0 +1,105 @@
/*
* 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.pledgeV3;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.data.sql.ClanTable;
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.model.clan.ClanPrivilege;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
import org.l2jmobius.gameserver.taskmanager.AttackStanceTaskManager;
public class RequestExPledgeEnemyDelete implements IClientIncomingPacket
{
private String _pledgeName;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_pledgeName = packet.readS();
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
final Clan playerClan = player.getClan();
if (playerClan == null)
{
return;
}
final Clan clan = ClanTable.getInstance().getClanByName(_pledgeName);
if (clan == null)
{
player.sendMessage("No such clan.");
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
if (!playerClan.isAtWarWith(clan.getId()))
{
player.sendMessage("You aren't at war with this clan.");
player.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
// Check if player who does the request has the correct rights to do it
if (!player.hasClanPrivilege(ClanPrivilege.CL_PLEDGE_WAR))
{
player.sendPacket(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT);
return;
}
for (ClanMember member : playerClan.getMembers())
{
if ((member == null) || (member.getPlayerInstance() == null))
{
continue;
}
if (AttackStanceTaskManager.getInstance().hasAttackStanceTask(member.getPlayerInstance()))
{
player.sendPacket(SystemMessageId.THE_CLAN_WAR_CANNOT_BE_STOPPED_BECAUSE_SOMEONE_FROM_YOUR_CLAN_IS_STILL_ENGAGED_IN_BATTLE);
return;
}
}
// Reduce reputation.
playerClan.takeReputationScore(500, true);
ClanTable.getInstance().deleteClanWars(playerClan.getId(), clan.getId());
for (PlayerInstance member : playerClan.getOnlineMembers(0))
{
member.broadcastUserInfo();
}
for (PlayerInstance member : clan.getOnlineMembers(0))
{
member.broadcastUserInfo();
}
}
}

View File

@ -0,0 +1,56 @@
/*
* 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.pledgeV3;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.data.sql.ClanTable;
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.pledgeV3.ExPledgeEnemyInfoList;
/**
* Written by Berezkin Nikolay, on 04.05.2021
*/
public class RequestExPledgeEnemyInfoList implements IClientIncomingPacket
{
private int _playerClan;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_playerClan = packet.readD();
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
final Clan clan = ClanTable.getInstance().getClan(_playerClan);
if ((clan != null) && (clan.getClanMember(player.getObjectId()) != null))
{
player.sendPacket(new ExPledgeEnemyInfoList(clan));
}
}
}

View File

@ -0,0 +1,137 @@
/*
* 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.pledgeV3;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.commons.util.Chronos;
import org.l2jmobius.gameserver.data.sql.ClanTable;
import org.l2jmobius.gameserver.enums.ClanWarState;
import org.l2jmobius.gameserver.enums.UserInfoType;
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.model.clan.ClanPrivilege;
import org.l2jmobius.gameserver.model.clan.ClanWar;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
public class RequestExPledgeEnemyRegister implements IClientIncomingPacket
{
private String _pledgeName;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_pledgeName = packet.readString();
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
final Clan clanDeclaringWar = player.getClan();
if (clanDeclaringWar == null)
{
return;
}
if (!player.hasClanPrivilege(ClanPrivilege.CL_PLEDGE_WAR))
{
client.sendPacket(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT);
client.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
else if (clanDeclaringWar.getWarCount() >= 30)
{
client.sendPacket(SystemMessageId.A_DECLARATION_OF_WAR_AGAINST_MORE_THAN_30_CLANS_CAN_T_BE_MADE_AT_THE_SAME_TIME);
client.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
final Clan clanDeclaredWar = ClanTable.getInstance().getClanByName(_pledgeName);
if (clanDeclaredWar == null)
{
client.sendPacket(new SystemMessage(SystemMessageId.A_CLAN_WAR_CANNOT_BE_DECLARED_AGAINST_A_CLAN_THAT_DOES_NOT_EXIST));
client.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
else if (clanDeclaredWar == clanDeclaringWar)
{
client.sendPacket(new SystemMessage(SystemMessageId.FOOL_YOU_CANNOT_DECLARE_WAR_AGAINST_YOUR_OWN_CLAN));
client.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
else if ((clanDeclaringWar.getAllyId() == clanDeclaredWar.getAllyId()) && (clanDeclaringWar.getAllyId() != 0))
{
client.sendPacket(new SystemMessage(SystemMessageId.A_DECLARATION_OF_CLAN_WAR_AGAINST_AN_ALLIED_CLAN_CAN_T_BE_MADE));
client.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
else if (clanDeclaredWar.getDissolvingExpiryTime() > Chronos.currentTimeMillis())
{
client.sendPacket(new SystemMessage(SystemMessageId.A_CLAN_WAR_CAN_NOT_BE_DECLARED_AGAINST_A_CLAN_THAT_IS_BEING_DISSOLVED));
client.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
final ClanWar clanWar = clanDeclaringWar.getWarWith(clanDeclaredWar.getId());
if (clanWar != null)
{
if (clanWar.getClanWarState(clanDeclaringWar) == ClanWarState.WIN)
{
final SystemMessage sm = new SystemMessage(SystemMessageId.YOU_CAN_T_DECLARE_A_WAR_BECAUSE_THE_21_DAY_PERIOD_HASN_T_PASSED_AFTER_A_DEFEAT_DECLARATION_WITH_THE_S1_CLAN);
sm.addString(clanDeclaredWar.getName());
client.sendPacket(sm);
client.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
final SystemMessage sm = new SystemMessage(SystemMessageId.YOU_HAVE_ALREADY_BEEN_AT_WAR_WITH_THE_S1_CLAN_5_DAYS_MUST_PASS_BEFORE_YOU_CAN_DECLARE_WAR_AGAIN);
sm.addString(clanDeclaredWar.getName());
client.sendPacket(sm);
client.sendPacket(ActionFailed.STATIC_PACKET);
return;
}
final ClanWar newClanWar = new ClanWar(clanDeclaringWar, clanDeclaredWar);
ClanTable.getInstance().storeClanWars(newClanWar);
for (ClanMember member : clanDeclaringWar.getMembers())
{
if ((member != null) && member.isOnline())
{
member.getPlayerInstance().broadcastUserInfo(UserInfoType.CLAN);
}
}
for (ClanMember member : clanDeclaredWar.getMembers())
{
if ((member != null) && member.isOnline())
{
member.getPlayerInstance().broadcastUserInfo(UserInfoType.CLAN);
}
}
}
}

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.pledgeV3;
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.PledgeReceiveWarList;
import org.l2jmobius.gameserver.network.serverpackets.pledgeV3.ExPledgeV3Info;
/**
* Written by Berezkin Nikolay, on 04.05.2021
*/
public class RequestExPledgeV3Info implements IClientIncomingPacket
{
private int _page;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_page = packet.readC();
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance player = client.getPlayer();
if (player == null)
{
return;
}
if (player.getClan() == null)
{
return;
}
player.sendPacket(new ExPledgeV3Info(player.getClan().getExp(), player.getClan().getRank(), player.getClan().getNotice(), player.getClan().isNoticeEnabled()));
player.sendPacket(new PledgeReceiveWarList(player.getClan(), _page));
}
}

View File

@ -0,0 +1,61 @@
/*
* 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.pledgeV3;
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.pledgeV3.ExPledgeV3Info;
/**
* Written by Berezkin Nikolay, on 04.05.2021
*/
public class RequestExPledgeV3SetAnnounce implements IClientIncomingPacket
{
private String _announce;
private boolean _enterWorldShow;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_announce = packet.readString();
_enterWorldShow = packet.readC() == 1;
return true;
}
@Override
public void run(GameClient client)
{
final PlayerInstance activeChar = client.getPlayer();
if (activeChar == null)
{
return;
}
final Clan clan = activeChar.getClan();
if (clan == null)
{
return;
}
clan.setNotice(_announce);
clan.setNoticeEnabled(_enterWorldShow);
clan.broadcastToOnlineMembers(new ExPledgeV3Info(clan.getExp(), clan.getRank(), clan.getNotice(), clan.isNoticeEnabled()));
}
}

View File

@ -16,11 +16,14 @@
*/ */
package org.l2jmobius.gameserver.network.clientpackets.pledgebonus; package org.l2jmobius.gameserver.network.clientpackets.pledgebonus;
import org.l2jmobius.Config;
import org.l2jmobius.commons.network.PacketReader; import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.GameClient; import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket; import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.pledgeV3.ExPledgeClassicRaidInfo;
import org.l2jmobius.gameserver.network.serverpackets.pledgebonus.ExPledgeBonusOpen; import org.l2jmobius.gameserver.network.serverpackets.pledgebonus.ExPledgeBonusOpen;
import org.l2jmobius.gameserver.network.serverpackets.pledgedonation.ExPledgeDonationInfo;
/** /**
* @author UnAfraid * @author UnAfraid
@ -43,5 +46,8 @@ public class RequestPledgeBonusOpen implements IClientIncomingPacket
} }
player.sendPacket(new ExPledgeBonusOpen(player)); player.sendPacket(new ExPledgeBonusOpen(player));
player.sendPacket(new ExPledgeClassicRaidInfo());
final long joinedTime = (player.getClanJoinExpiryTime() - (Config.ALT_CLAN_JOIN_DAYS * 60000));
player.sendPacket(new ExPledgeDonationInfo(player.getClanDonationPoints(), (joinedTime + 86400000) < System.currentTimeMillis()));
} }
} }

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.clientpackets.pledgedonation;
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.pledgedonation.ExPledgeContributionList;
/**
* Written by Berezkin Nikolay, on 09.05.2021
*/
public class RequestExPledgeContributionList 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)
{
return;
}
final Clan clan = player.getClan();
if (clan == null)
{
return;
}
player.sendPacket(new ExPledgeContributionList(clan.getContributionList()));
}
}

View File

@ -0,0 +1,55 @@
/*
* 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.pledgedonation;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.commons.util.Chronos;
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.pledgedonation.ExPledgeDonationInfo;
/**
* Written by Berezkin Nikolay, on 08.05.2021
*/
public class RequestExPledgeDonationInfo 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)
{
return;
}
final Clan clan = player.getClan();
if (clan == null)
{
return;
}
player.sendPacket(new ExPledgeDonationInfo(player.getClanDonationPoints(), (player.getClanJoinTime() + 86400000) < Chronos.currentTimeMillis()));
}
}

View File

@ -0,0 +1,157 @@
/*
* 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.pledgedonation;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.commons.util.Rnd;
import org.l2jmobius.gameserver.enums.MailType;
import org.l2jmobius.gameserver.instancemanager.MailManager;
import org.l2jmobius.gameserver.model.Message;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.clan.Clan;
import org.l2jmobius.gameserver.model.itemcontainer.Inventory;
import org.l2jmobius.gameserver.model.itemcontainer.Mail;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.clientpackets.IClientIncomingPacket;
import org.l2jmobius.gameserver.network.serverpackets.limitshop.ExBloodyCoinCount;
import org.l2jmobius.gameserver.network.serverpackets.pledgedonation.ExPledgeDonationRequest;
/**
* Written by Berezkin Nikolay, on 08.05.2021
*/
public class RequestExPledgeDonationRequest implements IClientIncomingPacket
{
private int _type;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_type = 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;
}
switch (_type)
{
case 0:
{
if (player.reduceAdena("pledge donation", 10000, null, true))
{
clan.addExp(player.getObjectId(), 3, true);
}
else
{
player.sendPacket(new ExPledgeDonationRequest(false, _type, 2));
}
break;
}
case 1:
{
if (player.getInventory().getInventoryItemCount(Inventory.LCOIN_ID, -1) >= 100)
{
if (player.getInventory().destroyItemByItemId("pledge donation", Inventory.LCOIN_ID, 100, player, null) != null)
{
clan.addExp(player.getObjectId(), 10, true);
player.addItem("pledge donation", 95570, 100, null, true);
}
else
{
player.sendPacket(new ExPledgeDonationRequest(false, _type, 2));
}
}
else
{
player.sendPacket(new ExPledgeDonationRequest(false, _type, 2));
}
break;
}
case 2:
{
if (player.getInventory().getInventoryItemCount(Inventory.LCOIN_ID, -1) >= 500)
{
if (player.getInventory().destroyItemByItemId("pledge donation", Inventory.LCOIN_ID, 500, player, null) != null)
{
clan.addExp(player.getObjectId(), 50, true);
player.addItem("pledge donation", 95570, 500, null, true);
}
else
{
player.sendPacket(new ExPledgeDonationRequest(false, _type, 2));
}
}
else
{
player.sendPacket(new ExPledgeDonationRequest(false, _type, 2));
}
break;
}
}
player.setClanDonationPoints(Math.max(player.getClanDonationPoints() - 1, 0));
criticalSuccess(player, clan, _type);
player.sendPacket(new ExBloodyCoinCount(player));
player.sendItemList();
player.sendPacket(new ExPledgeDonationRequest(true, _type, player.getClanDonationPoints()));
}
private void criticalSuccess(PlayerInstance player, Clan clan, int type)
{
if (type == 1)
{
if (Rnd.get(100) < 10)
{
player.addItem("pledge critical success: type" + type, 95570, 200, null, true);
clan.getMembers().forEach(clanMember ->
{
sendMail(clanMember.getObjectId(), 1, player.getName());
});
}
}
else if (type == 2)
{
if (Rnd.get(100) < 5)
{
player.addItem("pledge critical success: type" + type, 95570, 1000, null, true);
clan.getMembers().forEach(clanMember ->
{
sendMail(clanMember.getObjectId(), 5, player.getName());
});
}
}
}
private void sendMail(int charId, int amount, String donator)
{
final Message msg = new Message(charId, "Clan Rewards for " + donator + " Donation", "The entire clan receives rewards for " + donator + " donation.", MailType.PLEDGE_DONATION_CRITICAL_SUCCESS);
final Mail attachment = msg.createAttachments();
attachment.addItem("Pledge reward", 95672, amount, null, null);
MailManager.getInstance().sendMessage(msg);
}
}

View File

@ -0,0 +1,46 @@
/*
* 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.pledgeV3;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* Written by Berezkin Nikolay, on 22.04.2021
*/
public class ExPledgeClassicRaidInfo implements IClientOutgoingPacket
{
public ExPledgeClassicRaidInfo()
{
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_PLEDGE_CLASSIC_RAID_INFO.writeId(packet);
packet.writeD(0); // clan arena stage
packet.writeD(5);
for (int i = 1; i <= 5; i++)
{
packet.writeD(1867);
packet.writeD(i);
}
return true;
}
}

View File

@ -0,0 +1,36 @@
/*
* 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.pledgeV3;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* Written by Berezkin Nikolay, on 22.04.2021
*/
public class ExPledgeDonationInfo implements IClientOutgoingPacket
{
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_PLEDGE_DONATION_INFO.writeId(packet);
packet.writeD(0);
packet.writeC(1);
return true;
}
}

View File

@ -0,0 +1,58 @@
/*
* 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.pledgeV3;
import java.util.List;
import java.util.stream.Collectors;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.enums.ClanWarState;
import org.l2jmobius.gameserver.model.clan.Clan;
import org.l2jmobius.gameserver.model.clan.ClanWar;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* Written by Berezkin Nikolay, on 04.05.2021
*/
public class ExPledgeEnemyInfoList implements IClientOutgoingPacket
{
private final Clan _playerClan;
private final List<ClanWar> _warList;
public ExPledgeEnemyInfoList(Clan playerClan)
{
_playerClan = playerClan;
_warList = playerClan.getWarList().values().stream().filter(it -> (it.getClanWarState(playerClan) == ClanWarState.MUTUAL) || (it.getAttackerClanId() == playerClan.getId())).collect(Collectors.toList());
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_PLEDGE_ENEMY_INFO_LIST.writeId(packet);
packet.writeD(_warList.size());
for (ClanWar war : _warList)
{
final Clan clan = war.getOpposingClan(_playerClan);
packet.writeD(clan.getRank());
packet.writeD(clan.getId());
packet.writeString(clan.getName());
packet.writeString(clan.getLeaderName());
}
return true;
}
}

View File

@ -0,0 +1,42 @@
/*
* 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.pledgeV3;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* Written by Berezkin Nikolay, on 08.05.2021
*/
public class ExPledgeLevelUp implements IClientOutgoingPacket
{
private final int _level;
public ExPledgeLevelUp(int level)
{
_level = level;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_PLEDGE_LEVEL_UP.writeId(packet);
packet.writeD(_level);
return true;
}
}

View File

@ -0,0 +1,51 @@
/*
* 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.pledgeV3;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* Written by Berezkin Nikolay, on 04.05.2021 22 C0 00 00 00 00 00 00 00 00 00
*/
public class ExPledgeV3Info implements IClientOutgoingPacket
{
private final int _points;
private final int _rank;
private final String _announce;
private final boolean _isShowOnEnter;
public ExPledgeV3Info(int points, int rank, String announce, boolean isShowOnEnter)
{
_points = points;
_rank = rank;
_announce = announce;
_isShowOnEnter = isShowOnEnter;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_PLEDGE_V3_INFO.writeId(packet);
packet.writeD(_points);
packet.writeD(_rank);
packet.writeString(_announce);
packet.writeC(_isShowOnEnter ? 1 : 0);
return true;
}
}

View File

@ -82,7 +82,7 @@ public class ExPledgeBonusOpen implements IClientOutgoingPacket
// Members online bonus // Members online bonus
packet.writeD(highestMembersOnlineBonus.getRequiredAmount()); packet.writeD(highestMembersOnlineBonus.getRequiredAmount());
packet.writeD(clan.getMaxOnlineMembers()); packet.writeD(clan.getMaxOnlineMembers());
packet.writeC(0x00); // 140 packet.writeC(0x02); // 140
packet.writeD(membersOnlineBonus != null ? highestMembersOnlineBonus.getSkillReward().getSkillId() : 0x00); packet.writeD(membersOnlineBonus != null ? highestMembersOnlineBonus.getSkillReward().getSkillId() : 0x00);
packet.writeC(membersOnlineBonus != null ? membersOnlineBonus.getLevel() : 0x00); packet.writeC(membersOnlineBonus != null ? membersOnlineBonus.getLevel() : 0x00);
packet.writeC(membersOnlineBonus != null ? 0x01 : 0x00); packet.writeC(membersOnlineBonus != null ? 0x01 : 0x00);
@ -90,7 +90,7 @@ public class ExPledgeBonusOpen implements IClientOutgoingPacket
// Hunting bonus // Hunting bonus
packet.writeD(highestHuntingBonus.getRequiredAmount()); packet.writeD(highestHuntingBonus.getRequiredAmount());
packet.writeD(clan.getHuntingPoints()); packet.writeD(clan.getHuntingPoints());
packet.writeC(0x00); // 140 packet.writeC(0x01); // 140
packet.writeD(huntingBonus != null ? highestHuntingBonus.getItemReward().getId() : 0x00); packet.writeD(huntingBonus != null ? highestHuntingBonus.getItemReward().getId() : 0x00);
packet.writeC(huntingBonus != null ? huntingBonus.getLevel() : 0x00); packet.writeC(huntingBonus != null ? huntingBonus.getLevel() : 0x00);
packet.writeC(huntingBonus != null ? 0x01 : 0x00); packet.writeC(huntingBonus != null ? 0x01 : 0x00);

View File

@ -0,0 +1,52 @@
/*
* 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.pledgedonation;
import java.util.Collection;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.model.clan.ClanMember;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* Written by Berezkin Nikolay, on 09.05.2021
*/
public class ExPledgeContributionList implements IClientOutgoingPacket
{
private final Collection<ClanMember> _contributors;
public ExPledgeContributionList(Collection<ClanMember> contributors)
{
_contributors = contributors;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_PLEDGE_CONTRIBUTION_LIST.writeId(packet);
packet.writeD(_contributors.size());
for (ClanMember contributor : _contributors)
{
packet.writeString(contributor.getName());
packet.writeD(contributor.getClan().getClanContributionWeekly(contributor.getObjectId()));
packet.writeD(contributor.getClan().getClanContribution(contributor.getObjectId()));
}
return true;
}
}

View File

@ -0,0 +1,45 @@
/*
* 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.pledgedonation;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* Written by Berezkin Nikolay, on 08.05.2021 00 01 00 00 00 00 00 03 00 00 00 0E 00 00 00 00 00 00 00 00 00 00 00 00 00 02 00 00 00
*/
public class ExPledgeDonationInfo implements IClientOutgoingPacket
{
private final int _curPoints;
private final boolean _accepted;
public ExPledgeDonationInfo(int curPoints, boolean accepted)
{
_curPoints = curPoints;
_accepted = accepted;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_PLEDGE_DONATION_INFO.writeId(packet);
packet.writeD(_curPoints);
packet.writeC(_accepted ? 0 : 1);
return true;
}
}

View File

@ -0,0 +1,53 @@
/*
* 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.pledgedonation;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.network.OutgoingPackets;
import org.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
/**
* Written by Berezkin Nikolay, on 08.05.2021 00 01 00 00 00 00 00 03 00 00 00 0E 00 00 00 00 00 00 00 00 00 00 00 00 00 02 00 00 00 00 01 00 00 00 00 00 03 00 00 00 0E 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00
*/
public class ExPledgeDonationRequest implements IClientOutgoingPacket
{
private final boolean _success;
private final int _type;
private final int _curPoints;
public ExPledgeDonationRequest(boolean success, int type, int curPoints)
{
_success = success;
_type = type;
_curPoints = curPoints;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_PLEDGE_DONATION_REQUEST.writeId(packet);
packet.writeC(_type);
packet.writeD(_success ? 1 : 0);
packet.writeH(0);
packet.writeD(3);
packet.writeD(14);
packet.writeQ(0);
packet.writeH(0);
packet.writeD(_curPoints);
return true;
}
}

View File

@ -126,6 +126,7 @@ Sylph: https://eu.4game.com/patchnotes/lineage2essence/281/
-Sylph creation support -Sylph creation support
-Collection system -Collection system
-Purge system -Purge system
-Pledge donation system
Customs: Customs:
-Newbie Helper NPC location info -Newbie Helper NPC location info