mirror of
https://github.com/Anime-Game-Servers/AGSLunarCore.git
synced 2024-11-23 04:19:48 +00:00
Dont save items to the db when their properties havent changed
This commit is contained in:
parent
b84f24e4a7
commit
d71a4b8529
@ -135,8 +135,13 @@ public class GameItem {
|
||||
return !this.isLocked() && !this.isEquipped();
|
||||
}
|
||||
|
||||
public void setCount(int count) {
|
||||
this.count = count;
|
||||
public boolean setCount(int count) {
|
||||
if (this.count != count) {
|
||||
this.count = count;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean setEquipAvatar(int newEquipAvatar) {
|
||||
|
@ -236,8 +236,9 @@ public class Inventory extends BasePlayerManager {
|
||||
} else {
|
||||
// Add count to item
|
||||
int amount = Utils.safeAdd(existingItem.getCount(), item.getCount(), item.getExcel().getPileLimit(), 0);
|
||||
existingItem.setCount(amount);
|
||||
existingItem.save();
|
||||
if (existingItem.setCount(amount)) {
|
||||
existingItem.save();
|
||||
}
|
||||
return existingItem;
|
||||
}
|
||||
}
|
||||
|
@ -389,23 +389,35 @@ public class Player {
|
||||
}
|
||||
|
||||
public void addSCoin(int amount) {
|
||||
this.scoin = Utils.safeAdd(this.scoin, amount);
|
||||
this.sendPacket(new PacketPlayerSyncScNotify(this));
|
||||
int newAmount = Utils.safeAdd(this.scoin, amount);
|
||||
if (this.scoin != newAmount) {
|
||||
this.scoin = newAmount;
|
||||
this.sendPacket(new PacketPlayerSyncScNotify(this));
|
||||
}
|
||||
}
|
||||
|
||||
public void addHCoin(int amount) {
|
||||
this.hcoin = Utils.safeAdd(this.hcoin, amount);
|
||||
this.sendPacket(new PacketPlayerSyncScNotify(this));
|
||||
int newAmount = Utils.safeAdd(this.hcoin, amount);
|
||||
if (this.hcoin != newAmount) {
|
||||
this.hcoin = newAmount;
|
||||
this.sendPacket(new PacketPlayerSyncScNotify(this));
|
||||
}
|
||||
}
|
||||
|
||||
public void addMCoin(int amount) {
|
||||
this.mcoin = Utils.safeAdd(this.mcoin, amount);
|
||||
this.sendPacket(new PacketPlayerSyncScNotify(this));
|
||||
int newAmount = Utils.safeAdd(this.mcoin, amount);
|
||||
if (this.mcoin != newAmount) {
|
||||
this.mcoin = newAmount;
|
||||
this.sendPacket(new PacketPlayerSyncScNotify(this));
|
||||
}
|
||||
}
|
||||
|
||||
public void addTalentPoints(int amount) {
|
||||
this.talentPoints = Utils.safeAdd(this.talentPoints, amount);
|
||||
this.sendPacket(new PacketSyncRogueVirtualItemInfoScNotify(this));
|
||||
int newAmount = Utils.safeAdd(this.talentPoints, amount);
|
||||
if (this.talentPoints != newAmount) {
|
||||
this.talentPoints = newAmount;
|
||||
this.sendPacket(new PacketSyncRogueVirtualItemInfoScNotify(this));
|
||||
}
|
||||
}
|
||||
|
||||
public void addExp(int amount) {
|
||||
@ -421,6 +433,7 @@ public class Player {
|
||||
reqExp = GameData.getPlayerExpRequired(this.level + 1);
|
||||
}
|
||||
|
||||
// Update level and change property
|
||||
this.onLevelChange(oldLevel, this.level);
|
||||
this.save();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user