BedWars - Teamboxes

Discussion in 'Plugin Development' started by MerryChrismas, Aug 18, 2018.

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

    MerryChrismas

    After a little testing of code, I now have a new problem: The inventory is only called when you click with an item on the end box. Another problem is that the items are still in the box after being taken out and have doubled. If someone can help me please write privately or write a suggestion here as a thread.
    Thank you!

    Information: The teams are ArrayLists

    Code:
    //Variables
    
        public static HashMap<String, List<ItemStack>> teamboxblau = new HashMap<>();
        public static HashMap<String, List<ItemStack>> teamboxgelb = new HashMap<>();
        public static HashMap<String, List<ItemStack>> teamboxgrün = new HashMap<>();
        public static HashMap<String, List<ItemStack>> teamboxrot = new HashMap<>();
    
        public static List<ItemStack> a = new ArrayList<ItemStack>();
    
    //InteractEvent
    
                        if(e.getClickedBlock() == null) {
                            return;
                        }
                        if(e.getClickedBlock().getType() != Material.ENDER_CHEST) return;
                      
                        e.setCancelled(true);
                      
                      
                        if(Main.teamblau.contains(p)) {
                          
                          
                            Inventory blau = Bukkit.createInventory(null, 27, "§5Teamchest");
                          
                            List<ItemStack> is = Main.teamboxblau.get("teamblau");
                          
                            if(is == null) {
                              
                                p.openInventory(blau);
                                return;
                              
                            }
                          
                            for(ItemStack i : is) {
                                if(i != null) {
                                    blau.addItem(i);
                                }
                            }
                          
                            p.openInventory(blau);
                          
                          
                        }
    
    //InventotyCloseEvent
    
                    if (Main.teamblau.contains(p)) {
    
                        ItemStack[] is = e.getInventory().getContents();
    
                        for (ItemStack i : is) {
                            Main.a.add(i);
                        }
    
                        Main.teamboxblau.put("teamblau", Main.a);
    
                    }
    
    //
    Are there serios mistakes in there?
     
Thread Status:
Not open for further replies.

Share This Page