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();
|
return !this.isLocked() && !this.isEquipped();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCount(int count) {
|
public boolean setCount(int count) {
|
||||||
this.count = count;
|
if (this.count != count) {
|
||||||
|
this.count = count;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setEquipAvatar(int newEquipAvatar) {
|
public boolean setEquipAvatar(int newEquipAvatar) {
|
||||||
|
|||||||
@@ -236,8 +236,9 @@ public class Inventory extends BasePlayerManager {
|
|||||||
} else {
|
} else {
|
||||||
// Add count to item
|
// Add count to item
|
||||||
int amount = Utils.safeAdd(existingItem.getCount(), item.getCount(), item.getExcel().getPileLimit(), 0);
|
int amount = Utils.safeAdd(existingItem.getCount(), item.getCount(), item.getExcel().getPileLimit(), 0);
|
||||||
existingItem.setCount(amount);
|
if (existingItem.setCount(amount)) {
|
||||||
existingItem.save();
|
existingItem.save();
|
||||||
|
}
|
||||||
return existingItem;
|
return existingItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -389,23 +389,35 @@ public class Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addSCoin(int amount) {
|
public void addSCoin(int amount) {
|
||||||
this.scoin = Utils.safeAdd(this.scoin, amount);
|
int newAmount = Utils.safeAdd(this.scoin, amount);
|
||||||
this.sendPacket(new PacketPlayerSyncScNotify(this));
|
if (this.scoin != newAmount) {
|
||||||
|
this.scoin = newAmount;
|
||||||
|
this.sendPacket(new PacketPlayerSyncScNotify(this));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addHCoin(int amount) {
|
public void addHCoin(int amount) {
|
||||||
this.hcoin = Utils.safeAdd(this.hcoin, amount);
|
int newAmount = Utils.safeAdd(this.hcoin, amount);
|
||||||
this.sendPacket(new PacketPlayerSyncScNotify(this));
|
if (this.hcoin != newAmount) {
|
||||||
|
this.hcoin = newAmount;
|
||||||
|
this.sendPacket(new PacketPlayerSyncScNotify(this));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addMCoin(int amount) {
|
public void addMCoin(int amount) {
|
||||||
this.mcoin = Utils.safeAdd(this.mcoin, amount);
|
int newAmount = Utils.safeAdd(this.mcoin, amount);
|
||||||
this.sendPacket(new PacketPlayerSyncScNotify(this));
|
if (this.mcoin != newAmount) {
|
||||||
|
this.mcoin = newAmount;
|
||||||
|
this.sendPacket(new PacketPlayerSyncScNotify(this));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addTalentPoints(int amount) {
|
public void addTalentPoints(int amount) {
|
||||||
this.talentPoints = Utils.safeAdd(this.talentPoints, amount);
|
int newAmount = Utils.safeAdd(this.talentPoints, amount);
|
||||||
this.sendPacket(new PacketSyncRogueVirtualItemInfoScNotify(this));
|
if (this.talentPoints != newAmount) {
|
||||||
|
this.talentPoints = newAmount;
|
||||||
|
this.sendPacket(new PacketSyncRogueVirtualItemInfoScNotify(this));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addExp(int amount) {
|
public void addExp(int amount) {
|
||||||
@@ -421,6 +433,7 @@ public class Player {
|
|||||||
reqExp = GameData.getPlayerExpRequired(this.level + 1);
|
reqExp = GameData.getPlayerExpRequired(this.level + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update level and change property
|
||||||
this.onLevelChange(oldLevel, this.level);
|
this.onLevelChange(oldLevel, this.level);
|
||||||
this.save();
|
this.save();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user