mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-26 09:13:06 +00:00
Fix trader edits being lost on an existing linked market
Closing the setup GUI saved the market from the server''s stale role and then re-read that market over the edits it had just applied, so stock and currency cost changes never survived. The role now saves first and the market is written from it, and relinking to another market no longer pushes pre-link data over it.
This commit is contained in:
1 parent
17f61de57a
commit
68b5191db6
3 files changed
+29
-2
No files matched your search
@@ -94,6 +94,15 @@ public class RoleTrader extends RoleInterface {
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
readFromNBT(nbttagcompound, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param loadFromMarket pull the linked market's stored data over the compound just read.
|
||||
* False when the compound is an admin edit, which is authoritative and
|
||||
* would otherwise be overwritten by the market it is about to be saved to.
|
||||
*/
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound, boolean loadFromMarket) {
|
||||
String oldMarket = marketName;
|
||||
marketName = nbttagcompound.getString("TraderMarket");
|
||||
readNBT(nbttagcompound);
|
||||
@@ -101,6 +110,9 @@ public class RoleTrader extends RoleInterface {
|
||||
// Register with MarketRegistry for linked market sync
|
||||
MarketRegistry.updateTraderMarket(oldMarket, marketName, this);
|
||||
|
||||
if (!loadFromMarket)
|
||||
return;
|
||||
|
||||
try {
|
||||
Market.getMarket(this, marketName);
|
||||
} catch (Exception ex) {
|
||||
|
||||
Reference in new issue
Block a user