mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-24 22:14:44 +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
@@ -14,6 +14,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.CustomNpcsPermissions;
|
||||
import noppes.npcs.roles.RoleTrader;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -63,7 +64,13 @@ public final class RoleSavePacket extends AbstractPacket {
|
||||
if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player))
|
||||
return;
|
||||
|
||||
npc.roleInterface.readFromNBT(ByteBufUtils.readNBT(in));
|
||||
NBTTagCompound roleCompound = ByteBufUtils.readNBT(in);
|
||||
if (npc.roleInterface instanceof RoleTrader) {
|
||||
// An admin edit wins over the linked market; the market is written from it afterwards.
|
||||
((RoleTrader) npc.roleInterface).readFromNBT(roleCompound, false);
|
||||
} else {
|
||||
npc.roleInterface.readFromNBT(roleCompound);
|
||||
}
|
||||
npc.updateClient = true;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user