mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-16 15:24:44 +01:00
Dont save items to the db when their properties havent changed
This commit is contained in:
@@ -135,8 +135,13 @@ public class GameItem {
|
||||
return !this.isLocked() && !this.isEquipped();
|
||||
}
|
||||
|
||||
public void setCount(int 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);
|
||||
if (existingItem.setCount(amount)) {
|
||||
existingItem.save();
|
||||
}
|
||||
return existingItem;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -389,24 +389,36 @@ public class Player {
|
||||
}
|
||||
|
||||
public void addSCoin(int amount) {
|
||||
this.scoin = Utils.safeAdd(this.scoin, amount);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
int newAmount = Utils.safeAdd(this.talentPoints, amount);
|
||||
if (this.talentPoints != newAmount) {
|
||||
this.talentPoints = newAmount;
|
||||
this.sendPacket(new PacketSyncRogueVirtualItemInfoScNotify(this));
|
||||
}
|
||||
}
|
||||
|
||||
public void addExp(int amount) {
|
||||
// Setup
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user