Keep players inventory?

Discussion in 'Plugin Development' started by stantheman68, Apr 6, 2013.

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

    stantheman68

    Hey!

    I was wondering for a while, What's the code on how to keep a players inventory after they have died.

    Just can't really find it, It'd be great if some can post it down below.

    Thanks!
     
  2. Offline

    MrSparkzz

    You could either store the player's inventory, which I'm not gonna show. Or you could use gamerules
    Code:java
    1.  
    2. World world = ((Player) sender).getWorld();
    3.  
    4. world.setGameRuleValue("keepInventory", "on");
    5.  


    This hasn't been tested by me!

    stantheman68
    Or you could do this
    Code:java
    1.  
    2. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "gamerule keepInventory on");
    3.  


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

    Codisimus

    Why write a plugin for that?
     
  4. Offline

    MrSparkzz

    Well if you have a plugin that does something, say you want to enter a command that does something, but also changes the gamerules. You could just do this and be happy.

    stantheman68 I'm not so sure how GameRules work, but just look around and surely you'll find your answer.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  5. Offline

    Codisimus

    I just know that admins will be upset if they uninstall the plugin expecting it to change back and then cannot figure out how fix it.
     
Thread Status:
Not open for further replies.

Share This Page