Resource Modify an offline player's attributes easily

Discussion in 'Spigot Plugin Development' started by minion325, Jun 1, 2018.

  1. This is my first resource here on the forums and basically its really simple. You can do stuff such as modify a players inventory, enderchest, or even location.

    Its as simple as

    Code (Java):
    AdvancedOfflinePlayer aop = AdvancedOfflinePlayer.getAdvancedOfflinePlayer(Bukkit.getOfflinePlayer(uuid));

    PlayerInventory playerInventory = aop.getInventory();
    //EDIT Inventory
    aop.setPlayerInventory(Inventory);
    aop.saveData();
    This was tested on versions 1.8 and 1.10

    If you find any errors please post below

    SOURCE CODE: https://github.com/minion325/MCUtil...325/mcutils/player/AdvancedOfflinePlayer.java

    ps im new to github
     
    #1 minion325, Jun 1, 2018
    Last edited: Jun 2, 2018
    • Useful Useful x 1
  2. Interesting. But why bother making this a sub implementation to OfflinePlayer when all you want to achieve is editing a specific inventory?
    Why not just introduce something like "OfflineInventory" instead? Seems more straight forward to me :)
     
  3. Omnivion

    Patron

    If you look at the code, it provides a way for you to modify other player attributes, like location or health.
     
  4. Just took a small peek - if that's so, then it makes sense I guess ^^
    He just wrote "inventory" in the title ... so he should change that to "attributes" then probably?
     
  5. Will do :)

    Also if anyone has any suggestions as to what i should also add feel free to state below
     
  6. Just as a heads up in your example, you made a small typo. Line 1, you have AdvancedOfllinePlayer, but this should obviously be AdvancedOfflinePlayer.
     
    • Like Like x 1