[UnSolved] Changing a player's page in a merchant inventory

Discussion in 'Plugin Development' started by Jogy34, Jul 12, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Jogy34

    I was wondering if anyone knew how to change the page a player is on in a merchant inventory. I am currently using custom merchants and merchant inventories in one of my plugins through the use of NMS/Craftbukkit code so if it has to use that or reflection it's fine.

    Anyone?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 3, 2016
  2. Offline

    Cybermaxke

    I don't think this is possible.
     
  3. Offline

    soulofw0lf

    i'm pretty sure cyber is correct and that is handled client side, you'd need to do a mod to effect it.
     
  4. Offline

    Eats_Rainbows

    It is possible, I just don't know how to either...
     
  5. Offline

    Jogy34

    soulofw0lf Cybermaxke I don't know if that part is strictly client side as the server has to tell your client what the trades are for the page that you are currently on and I'm pretty sure that the server does keep track of what page you are on.
     
  6. Offline

    soulofw0lf

    If i understand how it works correctly the server sends the whole "trade inventory" to the player, the client handles which page of it your on, and sends the item clicked back to the server. I could be wrong, but i've looked into it before and couldn't figure out a way to do it and from what i read the actual page display is client side.. but like i said i could be wrong.
     
  7. Offline

    Cybermaxke

    Found it ;)
    Code:
    MerchantInventory inventory = ...;
    InventoryMerchant handle = ((CraftInventoryMerchant) inventory).getInventory();
     
    Field field = InventoryMerchant.getDeclaredField("e");
    field.setAccessible(true);
     
    int index = (Integer) field.get(handle);
     
  8. Offline

    Jogy34

    That will get me the current index that the player is on. I think I've already tried that before and, unless I did something wrong, it isn't as easy as just setting that.
     
  9. Offline

    Cybermaxke

    The index of the current offer, that is the only thing what the client sends about merchants.
     
  10. Offline

    Jogy34


    So there's no way to tell it to use a different offer?
     
  11. Offline

    Cybermaxke

    No, I tried it and it isn't working.
     
Thread Status:
Not open for further replies.

Share This Page