Merge two separate inventories?

Discussion in 'Spigot Plugin Development' started by dave_, Jun 23, 2016.

  1. Hello. I have run into a problem with a certain plugin which adds a secondary layer of authentication by requiring the user to login with a password by using a command.

    This plugin hides the players inventory.

    I have Votifier enabled and when a player votes, he receives an item.

    Since the item is added AFTER the inventory is hidden, the item is not saved into this cached inventory, and therefore is lost once the user logs in.

    My question is, how can I take two inventories, and combine them? And how could I even do this safely?

    Would it be possible to drop an item only the player that earned it can see? I would want this, for example, if their inventory was full and couldn't hold another item, but I also don't want others to steal their item that they earned by voting.
  2. Why not disallow them to vote before logging in instead?
  3. Wrong section.
    • Funny Funny x 2
    • Optimistic Optimistic x 1
  4. I see, completely forgot they could vote offline. Here's an idea I had just now:

    Instead of directly giving them the item, you could keep it stored(enderchest, a configuration file maybe?) to be retrieved later on. You could make a command in order to retrieve it and make so they can only use it if they're fully logged in.
  5. Or you could listen to an event when the player spawns (from successfully logging in [onPlayerJoin / onCommand / onTeleport / etc) and get the player's inventory before it is restored - check to if it contains X rewards - re-add the items upon spawn.