Reduced queries for storing clan values.
This commit is contained in:
@@ -75,7 +75,7 @@ public class Ballista extends AbstractNpcAI
|
||||
{
|
||||
if (npc.getFort().getSiege().isInProgress() && (caster.getClan() != null) && (caster.getClan().getLevel() >= MIN_CLAN_LV))
|
||||
{
|
||||
caster.getClan().addReputationScore(Config.BALLISTA_POINTS, true);
|
||||
caster.getClan().addReputationScore(Config.BALLISTA_POINTS);
|
||||
caster.sendPacket(SystemMessageId.THE_BALLISTA_HAS_BEEN_SUCCESSFULLY_DESTROYED_THE_CLAN_S_REPUTATION_WILL_BE_INCREASED);
|
||||
}
|
||||
npc.doDie(caster);
|
||||
|
@@ -57,7 +57,7 @@ public class ClanTrader extends AbstractNpcAI
|
||||
if (getQuestItemsCount(player, itemId) >= itemCount)
|
||||
{
|
||||
takeItems(player, itemId, itemCount);
|
||||
player.getClan().addReputationScore(count, true);
|
||||
player.getClan().addReputationScore(count);
|
||||
|
||||
final SystemMessage sm = new SystemMessage(SystemMessageId.YOUR_CLAN_HAS_ADDED_1S_POINTS_TO_ITS_CLAN_REPUTATION_SCORE);
|
||||
sm.addInt(count);
|
||||
|
@@ -94,7 +94,7 @@ public class FameManager extends AbstractNpcAI
|
||||
if ((player.getFame() >= REPUTATION_COST) && (player.getLevel() >= MIN_LEVEL) && (player.getClassId().level() >= CLASS_LEVEL))
|
||||
{
|
||||
player.setFame(player.getFame() - REPUTATION_COST);
|
||||
player.getClan().addReputationScore(50, true);
|
||||
player.getClan().addReputationScore(50);
|
||||
player.sendPacket(new UserInfo(player));
|
||||
player.sendPacket(SystemMessageId.YOU_HAVE_ACQUIRED_50_CLAN_FAME_POINTS);
|
||||
htmltext = npc.getId() + "-04.html";
|
||||
|
@@ -147,7 +147,7 @@ public class AdminPledge implements IAdminCommandHandler
|
||||
showMainPage(activeChar);
|
||||
return false;
|
||||
}
|
||||
clan.addReputationScore(points, true);
|
||||
clan.addReputationScore(points);
|
||||
BuilderUtil.sendSysMessage(activeChar, "You " + (points > 0 ? "add " : "remove ") + Math.abs(points) + " points " + (points > 0 ? "to " : "from ") + clan.getName() + "'s reputation. Their current score is " + clan.getReputationScore());
|
||||
}
|
||||
catch (Exception e)
|
||||
|
@@ -198,7 +198,7 @@ public class Q00508_AClansReputation extends Quest
|
||||
playSound(player, QuestSound.ITEMSOUND_QUEST_FANFARE_1);
|
||||
takeItems(player, REWARD_POINTS.get(raid).get(1), -1);
|
||||
final int rep = REWARD_POINTS.get(raid).get(2);
|
||||
clan.addReputationScore(rep, true);
|
||||
clan.addReputationScore(rep);
|
||||
player.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_SUCCESSFULLY_COMPLETED_A_CLAN_QUEST_S1_POINTS_HAVE_BEEN_ADDED_TO_YOUR_CLAN_S_REPUTATION_SCORE).addInt(rep));
|
||||
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
||||
}
|
||||
|
@@ -181,7 +181,7 @@ public class Q00509_AClansFame extends Quest
|
||||
playSound(player, QuestSound.ITEMSOUND_QUEST_FANFARE_1);
|
||||
takeItems(player, REWARD_POINTS.get(raid).get(1), -1);
|
||||
final int rep = REWARD_POINTS.get(raid).get(2);
|
||||
clan.addReputationScore(rep, true);
|
||||
clan.addReputationScore(rep);
|
||||
player.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_SUCCESSFULLY_COMPLETED_A_CLAN_QUEST_S1_POINTS_HAVE_BEEN_ADDED_TO_YOUR_CLAN_S_REPUTATION_SCORE).addInt(rep));
|
||||
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
||||
}
|
||||
|
@@ -140,7 +140,7 @@ public class Q00510_AClansPrestige extends Quest
|
||||
final int reward = (count < 10) ? (30 * count) : (59 + (30 * count));
|
||||
playSound(player, QuestSound.ITEMSOUND_QUEST_FANFARE_1);
|
||||
takeItems(player, TYRANNOSAURUS_CLAW, -1);
|
||||
clan.addReputationScore(reward, true);
|
||||
clan.addReputationScore(reward);
|
||||
player.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_SUCCESSFULLY_COMPLETED_A_CLAN_QUEST_S1_POINTS_HAVE_BEEN_ADDED_TO_YOUR_CLAN_S_REPUTATION_SCORE).addInt(reward));
|
||||
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
|
||||
htmltext = "31331-7.html";
|
||||
|
@@ -535,7 +535,7 @@ public class ClanTable
|
||||
{
|
||||
for (Clan clan : _clans.values())
|
||||
{
|
||||
clan.updateInDB();
|
||||
clan.updateClanInDB();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -317,7 +317,7 @@ public class MultisellData implements IXmlReader
|
||||
{
|
||||
case CLAN_REPUTATION:
|
||||
{
|
||||
player.getClan().takeReputationScore((int) amount, true);
|
||||
player.getClan().takeReputationScore((int) amount);
|
||||
final SystemMessage smsg = new SystemMessage(SystemMessageId.S1_POINTS_HAVE_BEEN_DEDUCTED_FROM_THE_CLAN_S_REPUTATION_SCORE);
|
||||
smsg.addLong(amount);
|
||||
player.sendPacket(smsg);
|
||||
@@ -340,7 +340,7 @@ public class MultisellData implements IXmlReader
|
||||
{
|
||||
case CLAN_REPUTATION:
|
||||
{
|
||||
player.getClan().addReputationScore((int) amount, true);
|
||||
player.getClan().addReputationScore((int) amount);
|
||||
break;
|
||||
}
|
||||
case FAME:
|
||||
|
@@ -2391,15 +2391,15 @@ public class Player extends Playable
|
||||
{
|
||||
if (_lvlJoinedAcademy <= 16)
|
||||
{
|
||||
_clan.addReputationScore(Config.JOIN_ACADEMY_MAX_REP_SCORE, true);
|
||||
_clan.addReputationScore(Config.JOIN_ACADEMY_MAX_REP_SCORE);
|
||||
}
|
||||
else if (_lvlJoinedAcademy >= 39)
|
||||
{
|
||||
_clan.addReputationScore(Config.JOIN_ACADEMY_MIN_REP_SCORE, true);
|
||||
_clan.addReputationScore(Config.JOIN_ACADEMY_MIN_REP_SCORE);
|
||||
}
|
||||
else
|
||||
{
|
||||
_clan.addReputationScore(Config.JOIN_ACADEMY_MAX_REP_SCORE - ((_lvlJoinedAcademy - 16) * 20), true);
|
||||
_clan.addReputationScore(Config.JOIN_ACADEMY_MAX_REP_SCORE - ((_lvlJoinedAcademy - 16) * 20));
|
||||
}
|
||||
setLvlJoinedAcademy(0);
|
||||
// oust pledge member from the academy, cuz he has finished his 2nd class transfer
|
||||
@@ -5265,12 +5265,12 @@ public class Player extends Playable
|
||||
// when your reputation score is 0 or below, the other clan cannot acquire any reputation points
|
||||
if (_clan.getReputationScore() > 0)
|
||||
{
|
||||
pk.getClan().addReputationScore(Config.REPUTATION_SCORE_PER_KILL, false);
|
||||
pk.getClan().addReputationScore(Config.REPUTATION_SCORE_PER_KILL);
|
||||
}
|
||||
// when the opposing sides reputation score is 0 or below, your clans reputation score does not decrease
|
||||
if (pk.getClan().getReputationScore() > 0)
|
||||
{
|
||||
_clan.takeReputationScore(Config.REPUTATION_SCORE_PER_KILL, false);
|
||||
_clan.takeReputationScore(Config.REPUTATION_SCORE_PER_KILL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -929,24 +929,6 @@ public class Clan implements IIdentifiable, INamable
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store in database current clan's reputation.
|
||||
*/
|
||||
public void updateInDB()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE clan_data SET reputation_score=? WHERE clan_id=?"))
|
||||
{
|
||||
ps.setInt(1, _reputationScore);
|
||||
ps.setInt(2, _clanId);
|
||||
ps.execute();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, "Exception on updateClanScoreInDb(): " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates in database clan information:
|
||||
* <ul>
|
||||
@@ -1090,7 +1072,7 @@ public class Clan implements IIdentifiable, INamable
|
||||
setCrestLargeId(clanData.getInt("crest_large_id"));
|
||||
setAllyCrestId(clanData.getInt("ally_crest_id"));
|
||||
|
||||
setReputationScore(clanData.getInt("reputation_score"), false);
|
||||
setReputationScore(clanData.getInt("reputation_score"));
|
||||
setAuctionBiddedAt(clanData.getInt("auction_bid_at"), false);
|
||||
setNewLeaderId(clanData.getInt("new_leader_id"), false);
|
||||
|
||||
@@ -1890,11 +1872,11 @@ public class Clan implements IIdentifiable, INamable
|
||||
// Order of Knights 10000 points per each
|
||||
if (pledgeType < SUBUNIT_KNIGHT1)
|
||||
{
|
||||
setReputationScore(_reputationScore - Config.ROYAL_GUARD_COST, true);
|
||||
setReputationScore(_reputationScore - Config.ROYAL_GUARD_COST);
|
||||
}
|
||||
else
|
||||
{
|
||||
setReputationScore(_reputationScore - Config.KNIGHT_UNIT_COST, true);
|
||||
setReputationScore(_reputationScore - Config.KNIGHT_UNIT_COST);
|
||||
// TODO: clan lvl9 or more can reinforce knights cheaper if first knight unit already created, use Config.KNIGHT_REINFORCE_COST
|
||||
}
|
||||
}
|
||||
@@ -2089,17 +2071,17 @@ public class Clan implements IIdentifiable, INamable
|
||||
return id;
|
||||
}
|
||||
|
||||
public synchronized void addReputationScore(int value, boolean save)
|
||||
public synchronized void addReputationScore(int value)
|
||||
{
|
||||
setReputationScore(_reputationScore + value, save);
|
||||
setReputationScore(_reputationScore + value);
|
||||
}
|
||||
|
||||
public synchronized void takeReputationScore(int value, boolean save)
|
||||
public synchronized void takeReputationScore(int value)
|
||||
{
|
||||
setReputationScore(_reputationScore - value, save);
|
||||
setReputationScore(_reputationScore - value);
|
||||
}
|
||||
|
||||
private void setReputationScore(int value, boolean save)
|
||||
private void setReputationScore(int value)
|
||||
{
|
||||
if ((_reputationScore >= 0) && (value < 0))
|
||||
{
|
||||
@@ -2133,11 +2115,8 @@ public class Clan implements IIdentifiable, INamable
|
||||
{
|
||||
_reputationScore = -100000000;
|
||||
}
|
||||
|
||||
broadcastToOnlineMembers(new PledgeShowInfoUpdate(this));
|
||||
if (save)
|
||||
{
|
||||
updateInDB();
|
||||
}
|
||||
}
|
||||
|
||||
public int getReputationScore()
|
||||
@@ -2570,7 +2549,7 @@ public class Clan implements IIdentifiable, INamable
|
||||
// Upgrade to 6
|
||||
if ((_reputationScore >= Config.CLAN_LEVEL_6_COST) && (_members.size() >= Config.CLAN_LEVEL_6_REQUIREMENT))
|
||||
{
|
||||
setReputationScore(_reputationScore - Config.CLAN_LEVEL_6_COST, true);
|
||||
setReputationScore(_reputationScore - Config.CLAN_LEVEL_6_COST);
|
||||
final SystemMessage cr = new SystemMessage(SystemMessageId.S1_POINTS_HAVE_BEEN_DEDUCTED_FROM_THE_CLAN_S_REPUTATION_SCORE);
|
||||
cr.addInt(Config.CLAN_LEVEL_6_COST);
|
||||
player.sendPacket(cr);
|
||||
@@ -2583,7 +2562,7 @@ public class Clan implements IIdentifiable, INamable
|
||||
// Upgrade to 7
|
||||
if ((_reputationScore >= Config.CLAN_LEVEL_7_COST) && (_members.size() >= Config.CLAN_LEVEL_7_REQUIREMENT))
|
||||
{
|
||||
setReputationScore(_reputationScore - Config.CLAN_LEVEL_7_COST, true);
|
||||
setReputationScore(_reputationScore - Config.CLAN_LEVEL_7_COST);
|
||||
final SystemMessage cr = new SystemMessage(SystemMessageId.S1_POINTS_HAVE_BEEN_DEDUCTED_FROM_THE_CLAN_S_REPUTATION_SCORE);
|
||||
cr.addInt(Config.CLAN_LEVEL_7_COST);
|
||||
player.sendPacket(cr);
|
||||
@@ -2596,7 +2575,7 @@ public class Clan implements IIdentifiable, INamable
|
||||
// Upgrade to 8
|
||||
if ((_reputationScore >= Config.CLAN_LEVEL_8_COST) && (_members.size() >= Config.CLAN_LEVEL_8_REQUIREMENT))
|
||||
{
|
||||
setReputationScore(_reputationScore - Config.CLAN_LEVEL_8_COST, true);
|
||||
setReputationScore(_reputationScore - Config.CLAN_LEVEL_8_COST);
|
||||
final SystemMessage cr = new SystemMessage(SystemMessageId.S1_POINTS_HAVE_BEEN_DEDUCTED_FROM_THE_CLAN_S_REPUTATION_SCORE);
|
||||
cr.addInt(Config.CLAN_LEVEL_8_COST);
|
||||
player.sendPacket(cr);
|
||||
@@ -2609,7 +2588,7 @@ public class Clan implements IIdentifiable, INamable
|
||||
// Upgrade to 9 (itemId 9910 = Blood Oath)
|
||||
if ((_reputationScore >= Config.CLAN_LEVEL_9_COST) && (player.getInventory().getItemByItemId(9910) != null) && (_members.size() >= Config.CLAN_LEVEL_9_REQUIREMENT) && player.destroyItemByItemId("ClanLvl", 9910, 150, player.getTarget(), false))
|
||||
{
|
||||
setReputationScore(_reputationScore - Config.CLAN_LEVEL_9_COST, true);
|
||||
setReputationScore(_reputationScore - Config.CLAN_LEVEL_9_COST);
|
||||
final SystemMessage cr = new SystemMessage(SystemMessageId.S1_POINTS_HAVE_BEEN_DEDUCTED_FROM_THE_CLAN_S_REPUTATION_SCORE);
|
||||
cr.addInt(Config.CLAN_LEVEL_9_COST);
|
||||
player.sendPacket(cr);
|
||||
@@ -2629,7 +2608,7 @@ public class Clan implements IIdentifiable, INamable
|
||||
// itemId 9911 == Blood Alliance
|
||||
if (player.destroyItemByItemId("ClanLvl", 9911, 5, player.getTarget(), false))
|
||||
{
|
||||
setReputationScore(_reputationScore - Config.CLAN_LEVEL_10_COST, true);
|
||||
setReputationScore(_reputationScore - Config.CLAN_LEVEL_10_COST);
|
||||
final SystemMessage cr = new SystemMessage(SystemMessageId.S1_POINTS_HAVE_BEEN_DEDUCTED_FROM_THE_CLAN_S_REPUTATION_SCORE);
|
||||
cr.addInt(Config.CLAN_LEVEL_10_COST);
|
||||
player.sendPacket(cr);
|
||||
@@ -2656,7 +2635,7 @@ public class Clan implements IIdentifiable, INamable
|
||||
}
|
||||
if (hasTerritory && (_reputationScore >= Config.CLAN_LEVEL_11_COST) && (_members.size() >= Config.CLAN_LEVEL_11_REQUIREMENT))
|
||||
{
|
||||
setReputationScore(_reputationScore - Config.CLAN_LEVEL_11_COST, true);
|
||||
setReputationScore(_reputationScore - Config.CLAN_LEVEL_11_COST);
|
||||
final SystemMessage cr = new SystemMessage(SystemMessageId.S1_POINTS_HAVE_BEEN_DEDUCTED_FROM_THE_CLAN_S_REPUTATION_SCORE);
|
||||
cr.addInt(Config.CLAN_LEVEL_11_COST);
|
||||
player.sendPacket(cr);
|
||||
|
@@ -905,7 +905,7 @@ public class Hero
|
||||
final Clan clan = player.getClan();
|
||||
if ((clan != null) && (clan.getLevel() >= 5))
|
||||
{
|
||||
clan.addReputationScore(Config.HERO_POINTS, true);
|
||||
clan.addReputationScore(Config.HERO_POINTS);
|
||||
final SystemMessage sm = new SystemMessage(SystemMessageId.CLAN_MEMBER_C1_WAS_NAMED_A_HERO_S2_POINTS_HAVE_BEEN_ADDED_TO_YOUR_CLAN_S_REPUTATION_SCORE);
|
||||
sm.addString(CharNameTable.getInstance().getNameById(player.getObjectId()));
|
||||
sm.addInt(Config.HERO_POINTS);
|
||||
|
@@ -1102,7 +1102,7 @@ public class SevenSignsFestival implements SpawnListener
|
||||
{
|
||||
if (player.getClan() != null)
|
||||
{
|
||||
player.getClan().addReputationScore(Config.FESTIVAL_WIN_POINTS, true);
|
||||
player.getClan().addReputationScore(Config.FESTIVAL_WIN_POINTS);
|
||||
final SystemMessage sm = new SystemMessage(SystemMessageId.CLAN_MEMBER_C1_WAS_AN_ACTIVE_MEMBER_OF_THE_HIGHEST_RANKED_PARTY_IN_THE_FESTIVAL_OF_DARKNESS_S2_POINTS_HAVE_BEEN_ADDED_TO_YOUR_CLAN_S_REPUTATION_SCORE);
|
||||
sm.addString(partyMemberName);
|
||||
sm.addInt(Config.FESTIVAL_WIN_POINTS);
|
||||
@@ -1125,7 +1125,7 @@ public class SevenSignsFestival implements SpawnListener
|
||||
final Clan clan = ClanTable.getInstance().getClanByName(clanName);
|
||||
if (clan != null)
|
||||
{
|
||||
clan.addReputationScore(Config.FESTIVAL_WIN_POINTS, true);
|
||||
clan.addReputationScore(Config.FESTIVAL_WIN_POINTS);
|
||||
final SystemMessage sm = new SystemMessage(SystemMessageId.CLAN_MEMBER_C1_WAS_AN_ACTIVE_MEMBER_OF_THE_HIGHEST_RANKED_PARTY_IN_THE_FESTIVAL_OF_DARKNESS_S2_POINTS_HAVE_BEEN_ADDED_TO_YOUR_CLAN_S_REPUTATION_SCORE);
|
||||
sm.addString(partyMemberName);
|
||||
sm.addInt(Config.FESTIVAL_WIN_POINTS);
|
||||
|
@@ -967,16 +967,16 @@ public class Castle extends AbstractResidence
|
||||
if (_formerOwner != ClanTable.getInstance().getClan(getOwnerId()))
|
||||
{
|
||||
final int maxreward = Math.max(0, _formerOwner.getReputationScore());
|
||||
_formerOwner.takeReputationScore(Config.LOOSE_CASTLE_POINTS, true);
|
||||
_formerOwner.takeReputationScore(Config.LOOSE_CASTLE_POINTS);
|
||||
final Clan owner = ClanTable.getInstance().getClan(getOwnerId());
|
||||
if (owner != null)
|
||||
{
|
||||
owner.addReputationScore(Math.min(Config.TAKE_CASTLE_POINTS, maxreward), true);
|
||||
owner.addReputationScore(Math.min(Config.TAKE_CASTLE_POINTS, maxreward));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_formerOwner.addReputationScore(Config.CASTLE_DEFENDED_POINTS, true);
|
||||
_formerOwner.addReputationScore(Config.CASTLE_DEFENDED_POINTS);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -984,7 +984,7 @@ public class Castle extends AbstractResidence
|
||||
final Clan owner = ClanTable.getInstance().getClan(getOwnerId());
|
||||
if (owner != null)
|
||||
{
|
||||
owner.addReputationScore(Config.TAKE_CASTLE_POINTS, true);
|
||||
owner.addReputationScore(Config.TAKE_CASTLE_POINTS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -932,11 +932,11 @@ public class Fort extends AbstractResidence
|
||||
{
|
||||
if (removePoints)
|
||||
{
|
||||
owner.takeReputationScore(Config.LOOSE_FORT_POINTS, true);
|
||||
owner.takeReputationScore(Config.LOOSE_FORT_POINTS);
|
||||
}
|
||||
else
|
||||
{
|
||||
owner.addReputationScore(Config.TAKE_FORT_POINTS, true);
|
||||
owner.addReputationScore(Config.TAKE_FORT_POINTS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -201,7 +201,7 @@ public class RequestAcquireSkill implements IClientIncomingPacket
|
||||
}
|
||||
}
|
||||
|
||||
clan.takeReputationScore(repCost, true);
|
||||
clan.takeReputationScore(repCost);
|
||||
|
||||
final SystemMessage cr = new SystemMessage(SystemMessageId.S1_POINTS_HAVE_BEEN_DEDUCTED_FROM_THE_CLAN_S_REPUTATION_SCORE);
|
||||
cr.addInt(repCost);
|
||||
@@ -264,7 +264,7 @@ public class RequestAcquireSkill implements IClientIncomingPacket
|
||||
|
||||
if (repCost > 0)
|
||||
{
|
||||
clan.takeReputationScore(repCost, true);
|
||||
clan.takeReputationScore(repCost);
|
||||
final SystemMessage cr = new SystemMessage(SystemMessageId.S1_POINTS_HAVE_BEEN_DEDUCTED_FROM_THE_CLAN_S_REPUTATION_SCORE);
|
||||
cr.addInt(repCost);
|
||||
player.sendPacket(cr);
|
||||
|
@@ -119,7 +119,7 @@ public class TaskRaidPointsReset extends Task
|
||||
break;
|
||||
}
|
||||
}
|
||||
c.addReputationScore(reputation, true);
|
||||
c.addReputationScore(reputation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user