Clan donation improvements.

Contributed by nasseka.
This commit is contained in:
MobiusDevelopment
2022-07-15 10:29:31 +00:00
parent 267cc8c60e
commit 48889ed549
18 changed files with 96 additions and 318 deletions

View File

@@ -1,6 +0,0 @@
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

@@ -360,23 +360,28 @@ public class DailyTaskManager
private void resetClanDonationPoints()
{
// Update data for offline players.
try (Connection con = DatabaseFactory.getConnection())
{
try (PreparedStatement ps = con.prepareStatement("DELETE FROM character_pledge_donation WHERE points < ?"))
try (PreparedStatement ps = con.prepareStatement("DELETE FROM character_variables WHERE points var = ?"))
{
ps.setInt(1, 4);
ps.setString(1, PlayerVariables.CLAN_DONATION_POINTS);
ps.execute();
}
for (Player player : World.getInstance().getPlayers())
{
player.setClanDonationPoints(3);
}
}
catch (Exception e)
{
LOGGER.log(Level.SEVERE, "Could not reset clan donation points: ", e);
}
LOGGER.info("Weekly caln contributions cleaned.");
// Update data for online players.
for (Player player : World.getInstance().getPlayers())
{
player.getVariables().remove(PlayerVariables.CLAN_DONATION_POINTS);
player.getVariables().storeMe();
}
LOGGER.info("Daily clan donation points have been reset.");
}
private void resetWorldChatPoints()

View File

@@ -460,11 +460,6 @@ public class Player extends Playable
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=?";
// 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:
private static final String RESTORE_ELEMENTAL_SPIRITS = "SELECT * FROM character_spirits WHERE charId=?";
@@ -946,8 +941,6 @@ public class Player extends Playable
private final Map<Integer, PetEvolveHolder> _petEvolves = new HashMap<>();
private int _clanDonationPoints = 3;
private final List<QuestTimer> _questTimers = new ArrayList<>();
private final List<TimerHolder<?>> _timerHolders = new ArrayList<>();
@@ -7084,9 +7077,6 @@ public class Player extends Playable
// Purge.
restoreSubjugation();
// Clan donation.
restoreClanDonation();
// Load Premium Item List.
loadPremiumItemList();
@@ -7241,9 +7231,6 @@ public class Player extends Playable
// Purge.
storeSubjugation();
// Pledge donation.
storePledgeDonation();
final PlayerVariables vars = getScript(PlayerVariables.class);
if (vars != null)
{
@@ -15351,54 +15338,6 @@ public class Player extends Playable
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);
}
return getVariables().getInt(PlayerVariables.CLAN_DONATION_POINTS, 3);
}
}

View File

@@ -39,6 +39,8 @@ public class ClanVariables extends AbstractVariables
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 DELETE_WEAKLY_QUERY = "DELETE FROM clan_variables WHERE var LIKE 'CONTRIBUTION_WEEKLY_%' AND clanId = ?";
// Public variable names.
public static final String CONTRIBUTION = "CONTRIBUTION_";
public static final String CONTRIBUTION_WEEKLY = "CONTRIBUTION_WEEKLY_";

View File

@@ -38,7 +38,7 @@ public class PlayerVariables extends AbstractVariables
private static final String DELETE_QUERY = "DELETE FROM character_variables WHERE charId = ?";
private static final String INSERT_QUERY = "INSERT INTO character_variables (charId, var, val) VALUES (?, ?, ?)";
// Public variable names
// Public variable names.
public static final String INSTANCE_ORIGIN = "INSTANCE_ORIGIN";
public static final String HAIR_ACCESSORY_VARIABLE_NAME = "HAIR_ACCESSORY_ENABLED";
public static final String WORLD_CHAT_VARIABLE_NAME = "WORLD_CHAT_USED";
@@ -81,6 +81,7 @@ public class PlayerVariables extends AbstractVariables
public static final String STAT_MEN = "STAT_MEN";
public static final String RESURRECT_BY_PAYMENT_COUNT = "RESURRECT_BY_PAYMENT_COUNT";
public static final String CLAN_JOIN_TIME = "CLAN_JOIN_TIME";
public static final String CLAN_DONATION_POINTS = "CLAN_DONATION_POINTS";
private final int _objectId;

View File

@@ -25,9 +25,11 @@ import org.l2jmobius.gameserver.model.actor.Player;
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.model.variables.PlayerVariables;
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.ExPledgeDonationInfo;
import org.l2jmobius.gameserver.network.serverpackets.pledgedonation.ExPledgeDonationRequest;
/**
@@ -63,7 +65,7 @@ public class RequestExPledgeDonationRequest implements IClientIncomingPacket
{
case 0:
{
if (player.reduceAdena("pledge donation", 10000, null, true))
if (player.reduceAdena("Pledge donation", 10000, null, true))
{
clan.addExp(player.getObjectId(), 9);
}
@@ -77,15 +79,9 @@ public class RequestExPledgeDonationRequest implements IClientIncomingPacket
{
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(), 30);
player.setHonorCoins(player.getHonorCoins() + 100);
}
else
{
player.sendPacket(new ExPledgeDonationRequest(false, _type, 2));
}
player.destroyItemByItemId("Pledge donation", Inventory.LCOIN_ID, 100, player, true);
clan.addExp(player.getObjectId(), 30);
player.setHonorCoins(player.getHonorCoins() + 100);
}
else
{
@@ -97,15 +93,9 @@ public class RequestExPledgeDonationRequest implements IClientIncomingPacket
{
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(), 150);
player.setHonorCoins(player.getHonorCoins() + 500);
}
else
{
player.sendPacket(new ExPledgeDonationRequest(false, _type, 2));
}
player.destroyItemByItemId("Pledge donation", Inventory.LCOIN_ID, 500, player, true);
clan.addExp(player.getObjectId(), 150);
player.setHonorCoins(player.getHonorCoins() + 500);
}
else
{
@@ -114,24 +104,22 @@ public class RequestExPledgeDonationRequest implements IClientIncomingPacket
break;
}
}
player.setClanDonationPoints(Math.max(player.getClanDonationPoints() - 1, 0));
player.getVariables().set(PlayerVariables.CLAN_DONATION_POINTS, 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()));
player.sendPacket(new ExPledgeDonationInfo(player.getClanDonationPoints(), true));
}
private void criticalSuccess(Player player, Clan clan, int type)
{
if (type == 1)
{
if (Rnd.get(100) < 10)
if (Rnd.get(100) < 5)
{
player.setHonorCoins(player.getHonorCoins() + 200);
clan.getMembers().forEach(clanMember ->
{
sendMail(clanMember.getObjectId(), 1, player.getName());
});
clan.getMembers().forEach(clanMember -> sendMail(clanMember.getObjectId(), 1, player.getName()));
}
}
else if (type == 2)
@@ -139,10 +127,7 @@ public class RequestExPledgeDonationRequest implements IClientIncomingPacket
if (Rnd.get(100) < 5)
{
player.setHonorCoins(player.getHonorCoins() + 1000);
clan.getMembers().forEach(clanMember ->
{
sendMail(clanMember.getObjectId(), 5, player.getName());
});
clan.getMembers().forEach(clanMember -> sendMail(clanMember.getObjectId(), 5, player.getName()));
}
}
}
@@ -151,7 +136,7 @@ public class RequestExPledgeDonationRequest implements IClientIncomingPacket
{
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);
attachment.addItem("Pledge reward", 95672, amount, null, donator); // Honor Coin Pouch
MailManager.getInstance().sendMessage(msg);
}
}

View File

@@ -1,6 +0,0 @@
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

@@ -361,23 +361,28 @@ public class DailyTaskManager
private void resetClanDonationPoints()
{
// Update data for offline players.
try (Connection con = DatabaseFactory.getConnection())
{
try (PreparedStatement ps = con.prepareStatement("DELETE FROM character_pledge_donation WHERE points < ?"))
try (PreparedStatement ps = con.prepareStatement("DELETE FROM character_variables WHERE points var = ?"))
{
ps.setInt(1, 4);
ps.setString(1, PlayerVariables.CLAN_DONATION_POINTS);
ps.execute();
}
for (Player player : World.getInstance().getPlayers())
{
player.setClanDonationPoints(3);
}
}
catch (Exception e)
{
LOGGER.log(Level.SEVERE, "Could not reset clan donation points: ", e);
}
LOGGER.info("Weekly caln contributions cleaned.");
// Update data for online players.
for (Player player : World.getInstance().getPlayers())
{
player.getVariables().remove(PlayerVariables.CLAN_DONATION_POINTS);
player.getVariables().storeMe();
}
LOGGER.info("Daily clan donation points have been reset.");
}
private void resetWorldChatPoints()

View File

@@ -464,11 +464,6 @@ public class Player extends Playable
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=?";
// 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:
private static final String RESTORE_ELEMENTAL_SPIRITS = "SELECT * FROM character_spirits WHERE charId=?";
@@ -954,8 +949,6 @@ public class Player extends Playable
private final Map<Integer, PetEvolveHolder> _petEvolves = new HashMap<>();
private int _clanDonationPoints = 3;
private final List<QuestTimer> _questTimers = new ArrayList<>();
private final List<TimerHolder<?>> _timerHolders = new ArrayList<>();
@@ -7099,9 +7092,6 @@ public class Player extends Playable
// Purge.
restoreSubjugation();
// Clan donation.
restoreClanDonation();
// Load Premium Item List.
loadPremiumItemList();
@@ -7258,9 +7248,6 @@ public class Player extends Playable
// Purge.
storeSubjugation();
// Pledge donation.
storePledgeDonation();
final PlayerVariables vars = getScript(PlayerVariables.class);
if (vars != null)
{
@@ -15531,54 +15518,6 @@ public class Player extends Playable
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);
}
return getVariables().getInt(PlayerVariables.CLAN_DONATION_POINTS, 3);
}
}

View File

@@ -39,6 +39,8 @@ public class ClanVariables extends AbstractVariables
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 DELETE_WEAKLY_QUERY = "DELETE FROM clan_variables WHERE var LIKE 'CONTRIBUTION_WEEKLY_%' AND clanId = ?";
// Public variable names.
public static final String CONTRIBUTION = "CONTRIBUTION_";
public static final String CONTRIBUTION_WEEKLY = "CONTRIBUTION_WEEKLY_";

View File

@@ -38,7 +38,7 @@ public class PlayerVariables extends AbstractVariables
private static final String DELETE_QUERY = "DELETE FROM character_variables WHERE charId = ?";
private static final String INSERT_QUERY = "INSERT INTO character_variables (charId, var, val) VALUES (?, ?, ?)";
// Public variable names
// Public variable names.
public static final String INSTANCE_ORIGIN = "INSTANCE_ORIGIN";
public static final String HAIR_ACCESSORY_VARIABLE_NAME = "HAIR_ACCESSORY_ENABLED";
public static final String WORLD_CHAT_VARIABLE_NAME = "WORLD_CHAT_USED";
@@ -81,6 +81,7 @@ public class PlayerVariables extends AbstractVariables
public static final String STAT_MEN = "STAT_MEN";
public static final String RESURRECT_BY_PAYMENT_COUNT = "RESURRECT_BY_PAYMENT_COUNT";
public static final String CLAN_JOIN_TIME = "CLAN_JOIN_TIME";
public static final String CLAN_DONATION_POINTS = "CLAN_DONATION_POINTS";
public static final String HENNA1_DURATION = "HENNA1_DURATION";
public static final String HENNA2_DURATION = "HENNA2_DURATION";
public static final String HENNA3_DURATION = "HENNA3_DURATION";

View File

@@ -25,9 +25,11 @@ import org.l2jmobius.gameserver.model.actor.Player;
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.model.variables.PlayerVariables;
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.ExPledgeDonationInfo;
import org.l2jmobius.gameserver.network.serverpackets.pledgedonation.ExPledgeDonationRequest;
/**
@@ -63,7 +65,7 @@ public class RequestExPledgeDonationRequest implements IClientIncomingPacket
{
case 0:
{
if (player.reduceAdena("pledge donation", 10000, null, true))
if (player.reduceAdena("Pledge donation", 10000, null, true))
{
clan.addExp(player.getObjectId(), 9);
}
@@ -77,15 +79,9 @@ public class RequestExPledgeDonationRequest implements IClientIncomingPacket
{
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(), 30);
player.setHonorCoins(player.getHonorCoins() + 100);
}
else
{
player.sendPacket(new ExPledgeDonationRequest(false, _type, 2));
}
player.destroyItemByItemId("Pledge donation", Inventory.LCOIN_ID, 100, player, true);
clan.addExp(player.getObjectId(), 30);
player.setHonorCoins(player.getHonorCoins() + 100);
}
else
{
@@ -97,15 +93,9 @@ public class RequestExPledgeDonationRequest implements IClientIncomingPacket
{
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(), 150);
player.setHonorCoins(player.getHonorCoins() + 500);
}
else
{
player.sendPacket(new ExPledgeDonationRequest(false, _type, 2));
}
player.destroyItemByItemId("Pledge donation", Inventory.LCOIN_ID, 500, player, true);
clan.addExp(player.getObjectId(), 150);
player.setHonorCoins(player.getHonorCoins() + 500);
}
else
{
@@ -114,24 +104,22 @@ public class RequestExPledgeDonationRequest implements IClientIncomingPacket
break;
}
}
player.setClanDonationPoints(Math.max(player.getClanDonationPoints() - 1, 0));
player.getVariables().set(PlayerVariables.CLAN_DONATION_POINTS, 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()));
player.sendPacket(new ExPledgeDonationInfo(player.getClanDonationPoints(), true));
}
private void criticalSuccess(Player player, Clan clan, int type)
{
if (type == 1)
{
if (Rnd.get(100) < 10)
if (Rnd.get(100) < 5)
{
player.setHonorCoins(player.getHonorCoins() + 200);
clan.getMembers().forEach(clanMember ->
{
sendMail(clanMember.getObjectId(), 1, player.getName());
});
clan.getMembers().forEach(clanMember -> sendMail(clanMember.getObjectId(), 1, player.getName()));
}
}
else if (type == 2)
@@ -139,10 +127,7 @@ public class RequestExPledgeDonationRequest implements IClientIncomingPacket
if (Rnd.get(100) < 5)
{
player.setHonorCoins(player.getHonorCoins() + 1000);
clan.getMembers().forEach(clanMember ->
{
sendMail(clanMember.getObjectId(), 5, player.getName());
});
clan.getMembers().forEach(clanMember -> sendMail(clanMember.getObjectId(), 5, player.getName()));
}
}
}
@@ -151,7 +136,7 @@ public class RequestExPledgeDonationRequest implements IClientIncomingPacket
{
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);
attachment.addItem("Pledge reward", 95672, amount, null, donator); // Honor Coin Pouch
MailManager.getInstance().sendMessage(msg);
}
}

View File

@@ -1,6 +0,0 @@
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

@@ -361,23 +361,28 @@ public class DailyTaskManager
private void resetClanDonationPoints()
{
// Update data for offline players.
try (Connection con = DatabaseFactory.getConnection())
{
try (PreparedStatement ps = con.prepareStatement("DELETE FROM character_pledge_donation WHERE points < ?"))
try (PreparedStatement ps = con.prepareStatement("DELETE FROM character_variables WHERE points var = ?"))
{
ps.setInt(1, 4);
ps.setString(1, PlayerVariables.CLAN_DONATION_POINTS);
ps.execute();
}
for (Player player : World.getInstance().getPlayers())
{
player.setClanDonationPoints(3);
}
}
catch (Exception e)
{
LOGGER.log(Level.SEVERE, "Could not reset clan donation points: ", e);
}
LOGGER.info("Weekly caln contributions cleaned.");
// Update data for online players.
for (Player player : World.getInstance().getPlayers())
{
player.getVariables().remove(PlayerVariables.CLAN_DONATION_POINTS);
player.getVariables().storeMe();
}
LOGGER.info("Daily clan donation points have been reset.");
}
private void resetWorldChatPoints()

View File

@@ -466,11 +466,6 @@ public class Player extends Playable
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=?";
// 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:
private static final String RESTORE_ELEMENTAL_SPIRITS = "SELECT * FROM character_spirits WHERE charId=?";
@@ -961,8 +956,6 @@ public class Player extends Playable
private final Map<Integer, PetEvolveHolder> _petEvolves = new HashMap<>();
private int _clanDonationPoints = 3;
private MissionLevelPlayerDataHolder _missionLevelProgress = null;
private final List<QuestTimer> _questTimers = new ArrayList<>();
@@ -7140,9 +7133,6 @@ public class Player extends Playable
// Purge.
restoreSubjugation();
// Clan donation.
restoreClanDonation();
// Load Premium Item List.
loadPremiumItemList();
@@ -7299,9 +7289,6 @@ public class Player extends Playable
// Purge.
storeSubjugation();
// Pledge donation.
storePledgeDonation();
final PlayerVariables vars = getScript(PlayerVariables.class);
if (vars != null)
{
@@ -15620,55 +15607,7 @@ public class Player extends Playable
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);
}
return getVariables().getInt(PlayerVariables.CLAN_DONATION_POINTS, 3);
}
public MissionLevelPlayerDataHolder getMissionLevelProgress()

View File

@@ -39,6 +39,8 @@ public class ClanVariables extends AbstractVariables
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 DELETE_WEAKLY_QUERY = "DELETE FROM clan_variables WHERE var LIKE 'CONTRIBUTION_WEEKLY_%' AND clanId = ?";
// Public variable names.
public static final String CONTRIBUTION = "CONTRIBUTION_";
public static final String CONTRIBUTION_WEEKLY = "CONTRIBUTION_WEEKLY_";

View File

@@ -38,7 +38,7 @@ public class PlayerVariables extends AbstractVariables
private static final String DELETE_QUERY = "DELETE FROM character_variables WHERE charId = ?";
private static final String INSERT_QUERY = "INSERT INTO character_variables (charId, var, val) VALUES (?, ?, ?)";
// Public variable names
// Public variable names.
public static final String INSTANCE_ORIGIN = "INSTANCE_ORIGIN";
public static final String HAIR_ACCESSORY_VARIABLE_NAME = "HAIR_ACCESSORY_ENABLED";
public static final String WORLD_CHAT_VARIABLE_NAME = "WORLD_CHAT_USED";
@@ -82,6 +82,7 @@ public class PlayerVariables extends AbstractVariables
public static final String STAT_MEN = "STAT_MEN";
public static final String RESURRECT_BY_PAYMENT_COUNT = "RESURRECT_BY_PAYMENT_COUNT";
public static final String CLAN_JOIN_TIME = "CLAN_JOIN_TIME";
public static final String CLAN_DONATION_POINTS = "CLAN_DONATION_POINTS";
public static final String HENNA1_DURATION = "HENNA1_DURATION";
public static final String HENNA2_DURATION = "HENNA2_DURATION";
public static final String HENNA3_DURATION = "HENNA3_DURATION";

View File

@@ -25,9 +25,11 @@ import org.l2jmobius.gameserver.model.actor.Player;
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.model.variables.PlayerVariables;
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.ExPledgeDonationInfo;
import org.l2jmobius.gameserver.network.serverpackets.pledgedonation.ExPledgeDonationRequest;
/**
@@ -63,7 +65,7 @@ public class RequestExPledgeDonationRequest implements IClientIncomingPacket
{
case 0:
{
if (player.reduceAdena("pledge donation", 10000, null, true))
if (player.reduceAdena("Pledge donation", 100000, null, true))
{
clan.addExp(player.getObjectId(), 9);
}
@@ -77,15 +79,9 @@ public class RequestExPledgeDonationRequest implements IClientIncomingPacket
{
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(), 30);
player.setHonorCoins(player.getHonorCoins() + 100);
}
else
{
player.sendPacket(new ExPledgeDonationRequest(false, _type, 2));
}
player.destroyItemByItemId("Pledge donation", Inventory.LCOIN_ID, 100, player, true);
clan.addExp(player.getObjectId(), 30);
player.setHonorCoins(player.getHonorCoins() + 100);
}
else
{
@@ -97,15 +93,9 @@ public class RequestExPledgeDonationRequest implements IClientIncomingPacket
{
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(), 150);
player.setHonorCoins(player.getHonorCoins() + 500);
}
else
{
player.sendPacket(new ExPledgeDonationRequest(false, _type, 2));
}
player.destroyItemByItemId("Pledge donation", Inventory.LCOIN_ID, 500, player, true);
clan.addExp(player.getObjectId(), 150);
player.setHonorCoins(player.getHonorCoins() + 500);
}
else
{
@@ -114,24 +104,22 @@ public class RequestExPledgeDonationRequest implements IClientIncomingPacket
break;
}
}
player.setClanDonationPoints(Math.max(player.getClanDonationPoints() - 1, 0));
player.getVariables().set(PlayerVariables.CLAN_DONATION_POINTS, 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()));
player.sendPacket(new ExPledgeDonationInfo(player.getClanDonationPoints(), true));
}
private void criticalSuccess(Player player, Clan clan, int type)
{
if (type == 1)
{
if (Rnd.get(100) < 10)
if (Rnd.get(100) < 5)
{
player.setHonorCoins(player.getHonorCoins() + 200);
clan.getMembers().forEach(clanMember ->
{
sendMail(clanMember.getObjectId(), 1, player.getName());
});
clan.getMembers().forEach(clanMember -> sendMail(clanMember.getObjectId(), 1, player.getName()));
}
}
else if (type == 2)
@@ -139,10 +127,7 @@ public class RequestExPledgeDonationRequest implements IClientIncomingPacket
if (Rnd.get(100) < 5)
{
player.setHonorCoins(player.getHonorCoins() + 1000);
clan.getMembers().forEach(clanMember ->
{
sendMail(clanMember.getObjectId(), 5, player.getName());
});
clan.getMembers().forEach(clanMember -> sendMail(clanMember.getObjectId(), 5, player.getName()));
}
}
}
@@ -151,7 +136,7 @@ public class RequestExPledgeDonationRequest implements IClientIncomingPacket
{
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);
attachment.addItem("Pledge reward", 95672, amount, null, donator); // Honor Coin Pouch
MailManager.getInstance().sendMessage(msg);
}
}