overwrite inventory one way

Discussion in 'Plugin Development' started by sergetheurge, May 15, 2018.

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

    sergetheurge

    so i got world a, and world b
    when i go from world a to world b, i want to take my world a inventory and add it to my world b inventory, and if inventory is full, then drop the items under the player

    when going from world b to world a, do nothing.

    public void onPlayerTeleport(PlayerTeleportEvent event) {
    object stuff1 = player.getInventory().getContents();
    object stuff2 = player.getInventory().getArmorContents();
    if (p.getWorld() = "a") {return;}
    if (p.getWorld() = "b") {
    player.getInventory().setArmorContents(stuff2);
    player.getInventory().setContents(stuff1);
    }
    }

    ... soo..... sigh.
     
  2. Offline

    timtower Administrator Administrator Moderator

  3. Offline

    MightyOne

    Save the inventory the player has in world a. Start a bukkitrunnable. In the runnable make a boolean if the player has free space in their inventory. Then iterate over the inventory from world a. If your boolean is false drop the item, if it is true add it to the inventory and refresh the boolean. Finally run the runnable delayed.
     
Thread Status:
Not open for further replies.

Share This Page