Virtual chest and enderchest linking help!

Discussion in 'Plugin Development' started by BlackFing, Apr 22, 2014.

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

    BlackFing

    Hello.
    How would I create a virtual chest that keeps the players items only to that player?
    Also how would I add more inventory space based on permission not command?
    One more thing. How would I link a enderchest to the virtual chest? So the /chest has 6 rows and it has 10 diamonds in it. Let's say I go to my enderchest, I need the enderchest to have 6 rows and 10 diamonds in it (Like the chest.)
    I would really appreciate it if you could give me all the code.
    I can't find any tutorials about this.
    Thanks.
     
  2. Offline

    tcvs

    BlackFing If you want someone else to do all the coding I recommend getting this post moved or creating a new post in Plugin requests...
     
  3. Offline

    stink123456

    Well how you would go ahead and do this is create an inventory for each person, save the contents to a config file, and about the enderChest just do an onPlayerInteract event and check if he right clicks an ender chest. Then cancel the event and open the custom inventory.
     
  4. Offline

    BlackFing

    No, I need help with the coding, not someone doing it for me. So I see no reason to move it.
     
  5. Offline

    tcvs

    BlackFing you are saying to code it all...

     
    Garris0n, KingFaris11 and tbrooks23 like this.
  6. Offline

    BlackFing

    Sorry, I must of mistyped. I will give you my code but can you fix it?
     
  7. Offline

    tcvs

    BlackFing post it and I'll see if I get time to review it.
     
  8. Offline

    BlackFing

    Ok I will once my Eclipse starts :p
     
  9. Offline

    GeorgeeeHD

    To this day, nobody will ever know if his Eclipse decided to open...
     
    Garris0n likes this.
  10. Offline

    tcvs

    GeorgeeeHD HAHA So true... must of been having issues.
     
  11. Offline

    BlackFing

  12. Offline

    tcvs

    BlackFing have you updated eclipse recently?
     
  13. Offline

    BlackFing

    Just yesterday I deleted everything of Eclipse except my workspaces, (Has my plugins in it) and it didn't do anything.
     
  14. Offline

    tcvs

    Hmm what happens if you create a new workspace? With nothing in it?
     
  15. Offline

    BlackFing

    It doesn't get that far. It shows the error right when I double click the .exe
     
  16. Offline

    tcvs

    BlackFing have you tried installing eclipse say on your desktop?
     
  17. Offline

    BlackFing

    I have a shortcut on my desktop. If that's what your asking.
     
  18. Offline

    tcvs

    BlackFing no I am saying install a fresh copy on the desktop/folder on desktop and see if that works
     
  19. Offline

    BlackFing

    Tried that and it didn't work.
     
  20. Offline

    tcvs

    BlackFing hmm OK I will think about it...
     
  21. Offline

    BlackFing

    I fixed it. Once I get everything figured out, then I will send you my chest code.

    Here's my code to make the chest

    Code:
     } else if ( command.getName().toLowerCase().equals("chest") ) {
                                 
                                    System.out.println("Check perm nodes");
                                    if (!has(sender, "adventurepack.chest")) {
                                         
                                            player.sendMessage(ChatColor.RED + "You do not have the right permission to perform this command!");
                                            return true;
                                    }
                                    buildVirtual(InventoryType.CHEST, player);
                                 
                                    return true;
    Here's other code in the same .java
    Code:
    } else  if (type.toString().equalsIgnoreCase(InventoryType.CHEST.toString())) {
                         
                      if(tracker == null) {
                        tracker = new HashMap<String, APTracker>();
                        APTracker ap = new APTracker();
                        ap.setName(player.getName());
                        tracker.put(player.getName(), ap);
                      }
                            APTracker AP = tracker.get(player.getName());
                            if(AP == null) {
                                    AP = new APTracker();
                                    AP.setName(player.getName());
                                    tracker.put(player.getName(), AP);
                            }
                            Inventory chest = Bukkit.createInventory(player, 54, player.getName()+"Chest");
                         
                            if(AP != null) {
                              System.out.println("Player tracker found.");
                                    if(AP.getChestItems() != null) {
                                            int stackSize = AP.getChestItems().size();
                                            for(int index = 0; index < stackSize; index++) {
                                                    chest.addItem(AP.getChestItems().get(index));
                                            }
                                         
                                         
                                    }
                            }
                            System.out.println("Setup chest for " + player.getName());
                            player.openInventory(chest);
                            AP.setChestName(player.getName()+"chest");
    Here the code in the Listener
    Code:
     @EventHandler(priority = EventPriority.HIGHEST)
            public void onInventoryClickEvent(InventoryClickEvent event) {
                    System.out.println("Listener fired");
                    String name = event.getWhoClicked().getName();
                    String isChest = event.getInventory().getTitle();
                    System.out.println("Player clicking item is " + name);
                    plugin.matchPlayerToChest(name, event.getCurrentItem());
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
Thread Status:
Not open for further replies.

Share This Page