[INACTIVE] [MECH/DEV] SpoutBackpack v2.3.6_3 - Give your players a Backpack [1317]

Discussion in 'Inactive/Unsupported Plugins' started by NeatMonster, Aug 10, 2011.

  1. Offline

    NeatMonster

    Please now use BukkitInventoryTools which contains SpoutBackpack.
    This thread is now useless, please don't post any longer on it.
    -----------------------​
    You can find the Bukkit Dev' thread HERE.
    Please use it, this thread will no longer be updated.

    ------------------------​
    SpoutBackpack v2.0.1
    Give your players a Backpack w/ Spout.

    Because pictures / video are always better than thousand words:
    [​IMG]
    [​IMG]
    (Unofficial video by IAMWIN but outdated: v1.9.5)​

    Features:
    • Pressing a key to open your backpack ;
    • Economy widget if you want it ;
    • Not just backpack, workbench too ;
    • Drop on death (configurable) ;
    • Permissions and economy plugins support ;
    • Allow your players to expand their Backpack ;
    • Restictions of upgrades & commands ;
    • Multiworld support with different Backpacks ;
    • Hooks into WorldGuard, MobArena and Jail ;
    • Key and name can be customized ;
    • API for developers ;
    • Backpacks are saved on server ;
    • Works even on reload.
    Requirements:
    • Spout and Spoutcraft - Required to launch and use the plugin.
      Tested with RB #1.0.5.227 of Spout and RB #1.0.5.256 of Spoutcraft.
    • (OPTIONAL) Permissions - Required if you want to customize the size or upgrade.
    • (OPTIONAL) PermissionsBukkit - Required if you want to customize the size or upgrade.
    • (OPTIONAL) PermissionsEx - Required if you want to customize the size or upgrade.
    • (OPTIONAL) GroupManager - Required if you want to customize the size or upgrade.
    • (OPTIONAL) iConomy - Required if you want to upgrade.
    • (OPTIONAL) BOSEconomy - Required if you want to upgrade.
    • (OPTIONAL) Essentials Economy - Required if you want to upgrade.
    • (OPTIONAL) MultiCurrency - Required if you want to upgrade.
    • (OPTIONAL) WorldGuard - Not required but compatible.
    • (OPTIONAL) MobArena - Not required but compatible.
    • (OPTIONAL) Jail - Not required but compatible.
    Configuration:
    Code:
    Widget:
        PositionY: 5
        PositionX: 3
        Enabled?: true
    Permissions:
        UseGroupManager?: false
        UsePermissions?: true
        UsePermissionsBukkit?: false
        UsePermissionsEx?: false
    Backpack:
        Name: Backpack
        Key: B
        Price:
            '45': 40.0
            '36': 30.0
            '18': 10.0
            '54': 50.0
            '27': 20.0
        RegionWhereBackpacksAreDisabled:
        - region1
        - region2
        world:
            Administrators:
                UpgradeSize: 54
                Size: 54
            Players:
                UpgradeSize: 27
                Size: 9
            Guests:
                UpgradeSize: 0
                Size: 0
            InventoriesShare?: true
            Moderators:
                UpgradeSize: 45
                Size: 27
            Joueurs:
                UpgradeSize: 36
                Size: 18
    Workbench:
        Enabled?: true
        Key: W
        NeededInInventory?: false
    Saves:
        Log?: false
        Interval(InMinutes): 5
    
    For PermissionsBukkit and PermissionsEx, you need to add permissions backpack.worldname.groupname. You also need to order your groups in the configuration file (eg. Admins, then Mods, then Players and then Guests). I'm sorry of this but those two plugins doesn't have the methods I need.

    Permissions:
    • backpack.workbench : Allow the player to open a virtual workbench.
    • backpack.nodrop : No drop of the items in the Backpack on death.
    • backpack.clear : Allow the player to clear his own Backpack.
    • backpack.clear.other : Allow the player to clear others inventories.
    • backpack.info.other: Allow the player to show info about others.
    • backpack.upgrade.other: Allow the player to upgrade others' Backpack.
    • backpack.open.other : Open other players' Backpack.
    • backpack.reload : Allow the use of the /backpack reload command.
    • NOTE: If you use OP system, size for not-Op players will be 9 and 54 for OP players.
    Commands:
    • /backpack clear (Player) : Clear your / player's inventory.
    • /backpack info (Player): Show information about your / player's Backpack.
    • /backpack open [Player] : Open player's Backpack.
    • /backpack upgrade [Player]: Upgrade your /player's Backpack.
    • /backpack reload : Reload Backpack's configuration.
    • NOTE: /backpack's alias is /bp.
    Downloads:
    Highly recommended:
    Credits:
    • The portage from BukkitContrib to Spout of this plugin was made by kazimir!
    • All credits go to captainawesome7 for his awesome BCBackpack plugin!
    TO-DO:
    • Permissions support ; DONE IN 1.3
    • Configuration of the key ; DONE IN 1.3
    • Multiple chest sizes ; DONE IN 1.4
    • iConomy integration ; DONE IN 1.6
    • MobArena hook ; DONE IN 1.6.1
    • BOSEconomy support ; DONE IN 1.6.2
    • PermissionsBukkit support ; DONE IN 1.6.3
    • Multiworld support ; DONE IN 1.7
    • Separate inventories ; DONE IN 1.7
    • WorldGuard regions support ; DONE IN 1.7.1
    • GroupManager support ; DONE IN 1.7.2
    • Workbench ; DONE IN 1.8
    • Jail support ; DONE IN 1.8.1
    • Add an option to disable workbench ; DONE IN 1.8.2
    • Restriction on Workbench ; DONE IN 1.8.4
    • Support of Essentials economy ; DONE IN 1.8.5
    • Economy widget ; DONE IN 1.9
    • Command to clear Backpack ; DONE IN 1.9
    • Restrictions on upgrades ; DONE IN 1.9
    • API ; DONE IN 1.9
    • Setting for the widget position ; DONE IN 1.9.2
    • Lookup in others' Backpack ; DONE IN 1.9.2
    • Support for PermissionsEx ; DONE IN 2.0
    • Handle deaths without Spout client ; DONE IN 2.0
    • Upgrade other players' Backpack ; DONE IN 2.0
    • Furnaces.
    Notes:
    • If you put something in your Backpack and close Minecraft by clicking the "X" without closing your backpack, all items you put in since opening your Backpack are lost. That's not a bug - It's a feature to prevent duping.
    API:
    You want to hook into SpoutBackpack? Fine, I have what you need.
    1. Import SpoutBackpack.jar as a library in your project ;
    2. Import me.neatmonster.spoutbackpack.SBHandler ;
    3. In your main class, add this object creation :
      Code:
          public SBHandler spoutBackpackHandler;
    4. Somewhere on your onEnable, add this line :
      Code:
              setupSpoutBackpack();
    5. So, this is the setupSpoutBackpack function :
      Code:
          private void setupSpoutBackpack() {
                                                      if (spoutBackpackHandler != null) {
                                                          return;
                                                      }
                                                      Plugin spoutBackpackPlugin = this.getServer().getPluginManager().getPlugin("SpoutBackpack");
                                                      if (spoutBackpackPlugin == null) {
                                                          return;
                                                      }
                                                      spoutBackpackHandler = new SBHandler();
                                                      return;
                                                      }
    6. To check somewhere in your code if SpoutBackpack is enabled, use :
      Code:
              if (spoutBackpackHandler != null) {
                                            return;
                                     }
    7. And finally to use a method of SpoutBackpack :
      Code:
              spoutBackpackHandler.theMethodYouWant();
      You can find all the methods HERE.
    8. If you need more methods, or if I made a mistake, do not hesitate to contact me.
    Changelog:
    Version 2.0.1
    • PermissionsBukkit & PermissionsEx fix.
    Version 2.0
    • Improved Backpacks' save system ;
    • PermissionsBukkit full support ;
    • PermissionsEx full support ;
    • Bug fix when client doesn't use Spoutcraft ;
    • Upgrade other players' Backpack.
    Other versions (open)
    Version 1.9.5
    Other versions (open)

    • Added methods for the API.
    Version 1.9.4
    • Fixed API.
    Version 1.9.3
    • Removed debug messages.
    Version 1.9.2
    • Setting for the position of the widget ;
    • Command to open other players' Backpack.
    Version 1.9.1
    • New method added to the API.
    Version 1.9
    • Economy widget when you opens your Backpack ;
    • Commands to clear Backpack(s) ;
    • Restrictions on updates ;
    • Creation of an API ;
    • Bug fixes with economy.
    Version 1.8.5
    • Support of Essentials Economy ;
    • Support of MultiCurrency.
    Version 1.8.4
    • Option to only use workbench if you have one in inventory.
    Version 1.8.3
    • No more saves when nobody is online ;
    • Fixed bug on upgrade.
    Version 1.8.2
    • Workbench toggle in the config.
    Version 1.8.1
    • Jail support.
    Version 1.8
    • Now with you can give your players a virtual workbench ;
    • You can close the workbench with the same key ;
    • Now the workbench will not appear when typing in the chat.
    Version 1.7.3
    • GroupManager full support.
    Version 1.7.2
    • GroupManager support ;
    • Permission for drop on death.
    Version 1.7.1
    • You can specify WorldGuard region where Backpacks will be disabled ;
    • More, more, more and more keys.
    Version 1.7
    • New multiworld support ;
    • Separate inventories ;
    • Common inventories ;
    • Reload command ;
    • Smart detection of plugins you've installed ;
    • Some code rewrite = more proper code.
    Version 1.6.3
    • Added PermissionsBukkit support with configuration options.
    Version 1.6.2
    • Support for BOSEconomy, no configuration needed ;
    • More anti-cheat messages and information for users.
    Version 1.6.1
    • Hooks in MobArena : when a player is inside an arena, I can't open his BackPack ;
    • For more security, it checks if iConomy is installed.
    Version 1.6
    • Added iConomy support & /backpack commands, which allow your players to expand their Backpack by paying some iConomy money (configurable in config.yml) ;
    • Minor bug fixes & code cleanup.
    Version 1.5
    • Added support for multiword (see in config.yml).
    • More and more help in the config.yml.
    Version 1.4
    • New permissions for different sizes.
    Version 1.3
    • Closing you backpack will now saves his content.
    • Permissions support.
    • You can now change the key used to open the backpack in the configuration.
    Version 1.2
    • Original version.



    [​IMG]
     
  2. Offline

    NeatMonster

    I'll add this to my TO-DO list.

    Edit:
    I tried over the GUI and it's impossible. But adding a setting in the configuration file is possible. I'll add this to my TO-DO too.
     
  3. Offline

    Gabriel333

    Hmm... I does not work :-(

    I call my sort method when the Backpack is open and I use these 3 methods to move the itemstacks around.

    inventory.setItem(slotnumer, itemstack); // this one should put the itemstack into slutnumber
    inventory.getItem(slotnumer); // this one returns the itemstack in slotnumber.
    inventory.clear(slotnumber); this one clears slutnumber.

    I need to go to bed now, but thanks for being so fast!!!!
     
  4. Offline

    NeatMonster

    I'll release a new version tomorrow. Need to go to bed too...
     
  5. Offline

    atlem

    do the money go under the backpack gui? if so wy not use a transparent money window ?
    [​IMG]
    Then agien im the onlyone who see this unless gui changes in spout essential texture change
     
  6. Offline

    bularax

    When i use the spoutcraft client and i press B, nothing happens. Do you know what this is?
     
  7. Offline

    atlem

    change premissions in config folder
     
  8. Offline

    Beatkidz

    I love this plug-in but found one conflict. When i install SpoutEssentials over this i can no longer see the economy Widget. i think it has something to do with the text on screen help in SpoutEssentials. if you could make these 2 compatible it would be great
     
  9. Offline

    Havoxx

    You update faster than the auto update check!!!
     
  10. Offline

    gameswereus

    You should rename the plugin pendparmhkabw
     
  11. Offline

    NeatMonster

    Yep, it goes under. In next version you will have the setting you want (position).

    Hum... Have you set the permissions? Configured the plugin? etc.

    Yep, in the next version I'll add a setting for the position of the widget.

    :p

    Enjoy! :cool:

    @Gabriel333
    I changed the code of the method. Tell me if it works now, please.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 18, 2016
    atlem likes this.
  12. Offline

    atlem

    Working for me :) Tanks alot :)
    [​IMG]
     
  13. Offline

    NeatMonster

    Great. When I asked if it was working, I was talking about the API. :rolleyes:
     
  14. Offline

    atlem

    :p
    ok then :p
     
  15. Offline

    Gabriel333

    Hi. I does not work yet.

    This is my test
    1) open Backpack by pressing "B"
    2) Sort the backpack by pressing "S"
    The class uses these three Methods to sort the backpackinventory.
    inventory.setItem(slotnumer, itemstack); // this one should put the itemstack into slutnumber
    inventory.getItem(slotnumer); // this one returns the itemstack in slotnumber.
    inventory.clear(slotnumber); this one clears slutnumber.
    Normally you would see the items move right away, but not when I do it on SpoutBackpack. But I can see that we are close, because I noticed the following. If I press "S" to sort and and without closing the spoutbackpack. Stops the server from the console, with the "stop" command. and then start the server again and open the spoutbackpack, then the items are sorted as they should be???? :eek:

    It is like if the screen is not updated, but the stored data is right???
     
  16. Offline

    NeatMonster

    Hum... I think it's normal you can't the modifications in "live", because you're working with a copy of the inventory of the inventory, and after this copy will be re-implanted into the original inventory. I'm trying to find a solution to this problem, but I think it's really difficult.
     
  17. Offline

    Gabriel333

    Hmm... It works perfectly on the normal playerinventory, a singlechest and a doublechest.... Difficult? I think it is fun... like a puzzle ;-)
     
  18. Offline

    NeatMonster

    It's not the same as normal player/chest inventory.
    This is the code executed when you use the getSpoutBackpack:
    Code:
        public Inventory getInventory(Player player) {
            CustomInventory customInventory = new CustomInventory(
                    inventoriesSize.get(player.getName()), inventoryName);
            if (inventories.containsKey(player.getName())) {
                customInventory.setContents(inventories.get(player.getName()));
            }
            Inventory inventory = ((Inventory) customInventory);
            return inventory;
        }
    And the setSpoutBackpack now:
    Code:
        public boolean setInventory(Player player, Inventory inventory) {
            CustomInventory customInventory = new CustomInventory(
                    inventoriesSize.get(player.getName()), inventoryName);
            if (inventories.containsKey(player.getName())) {
                customInventory.setContents(inventory.getContents());
                inventories.put(player.getName(), customInventory.getContents());
                return true;
            } else {
                return false;
            }
        }
    Do you understand now? You're working with a copy, so changes are not visible on the screen.

    If you press B, load Backpack with getSpoutBackpack, press S to sort items, save Backpack with setSpoutBackpack, press B to close it, and then press B to reopen it, are the items sorted?
     
  19. Offline

    bularax

    Yes i did...
     
  20. Offline

    NeatMonster

    Okay, download SpoutcraftTest.jar (source included), put it into your plugins folder and start the server. Connect and press some keys. If don't get any message like that in console, it's a Spoutcraft issue:
    Code:
    [INFO] [SpoutcraftTest] Key pressed: KEY_A.
    Edit:
    @Gabriel333 : So?
     
  21. Offline

    Gabriel333

    If I do what you suggest, the items are not sorted, when i reopen the backpack.
    I have tried to save the inventory - when i'm finish sorting the items, i write them back with setSpoutBackpack as you said, but it does not work...

    Show Spoiler
    Code:
    if (SortInventory.spoutbackpack) {
                inventory = SortInventory.spoutBackpackHandler
                        .getSpoutBackpack(sPlayer);
                // sPlayer.sendMessage("inv="+inventory);
                // sPlayer.sendMessage("Size="+inventory.getSize());
                i = 0;
                j = 0;
                for (i = 0; i < inventory.getSize(); i++) {
                    ItemStack item1 = inventory.getItem(i);
                    if (item1.getAmount() == 64) {
                        continue;
                    } else {
                        for (j = i + 1; j < inventory.getSize(); j++) {
                            SortInventoryCommand.moveitem(sPlayer, j, i, inventory,
                                    inventory);
                        }
                    }
                }
    
                SortInventory.spoutBackpackHandler.setSpoutBackpack(sPlayer,inventory);
    
            }
    Show Spoiler

    Im sorry for the late answer. I have been looking for at way to configure and SORTITEMSLIST = {"STONE","DIRT","WHOOL"} in the config.yml so that the admin can chose the sequence of the items after the sort/stacking. I have tried config.getList but i cant make it work...
     
  22. Offline

    NeatMonster

    Don't worry.

    I made my own plugin who hooks into SpoutBackpack. :p
    I made some progress so expect an update in the evening.

    Edit:
    Here we go!
    @Gabriel333
    It was really stupid error. Just check the instructions in the OP, now you only need to get inventory and you can do what you want with it. Enjoooooy! :cool:

    Re-Edit: But please make sure the player's Backpack is opened before sorting it. Check this file at lines ~31-32.

    Re-Re-Edit: Hum... Now I need to add methods to get inventory when it's closed, I think.

    Re-Re-Re-Edit: Okay, I added two methods to get and set the inventory of a player when he has his Backpack closed.
     
  23. Offline

    Kane

    @NeatMonster
    I assume you made it so it only saves when the bag is closed. Why not make it instant save while in the memory then write to the file after to prevent the duping?

    You are one the very few of many to come of the spout inventory uses and really should try provide a better more safer but also more stable solution to anti duping.

    Your a leader =)
     
  24. Offline

    Gabriel333

    You made an error in 5) it must be != to work ;)
    Code:
        private void setupSpoutBackpack() {
                           if (spoutBackpackHandler != null) {
                               return;
                           }
     
  25. Offline

    meizme

    NeatM. this might be an easy fix .. or not we'll see, but if i use the widget with the latest dev release of spout and spoutcraft the font is like 37 or bigger its like an 3/4 inch tall, is there a setting somewhere that effects this or a hack or trick you might know?
     
  26. Offline

    Gabriel333



    But after this little bug, IT WORKS!!!!! :cool: I release v1.2.0 in a moment!
     
  27. Offline

    NeatMonster

    It's already working like that!


    No, I corrected the error. If spoutBackpackHandler == null, it means the plugin isn't detected so we return.
    So, is your plugin working with SpoutBackpack now?

    Hum... I really don't know because I'm only using recommended builds. If you want me to do something, post a screenshot here.

    Edit:
    I never make mistakes! (I'm joking.) :p
    I'm really happy your plugin support mine now, I'll add it to the OP soon.
     
    Kane likes this.
  28. Offline

    Gabriel333

    @NeatMonstaer: YES it works. I have released SortInventory, with support for SpouBackpack :)

    BUT Im' right you made an error in OP.


    Code:
     private void setupSpoutBackpack() {
                              if (spoutBackpackHandler == null) {   OBS: this is ALLWAYS null OBS
                                  return;
                              }
                              Plugin spoutBackpackPlugin = this.getServer().getPluginManager().getPlugin("SpoutBackpack");
                              if (spoutBackpackPlugin == null) {
                                  return;
                              }
                              spoutBackpackHandler = new SBHandler();
                              return;
                              }
     
  29. Offline

    NeatMonster

    Hum... fail. You've right, this code is for checking if it has already initialized. Sorry about that, I corrected an error, but it wasn't an error. I'll edit the OP as soon as possible.
     
  30. Offline

    Ranzear

    If I give my players the backpack.sizexx permissions it automatically upgrades them to that backpack size, but if I give the size9 and upgrade18 permissions and they do /bp upgrade it takes their money but they still have only the size 9 backpack. Explain? Bug?

    Do I give them both the size and upgrade permissions for a given backpack size and take faith that I don't have to purge the backpacks again when it just gives them that size for free?
     
  31. Offline

    NeatMonster

    Have you switched to Permissions or are you still using SuperPermsBridge?
    If you're using SuperPermsBridge, upgrade is not supported.
     

Share This Page