Помогите Создание GUI с конфига

  • Автор темы Автор темы SaMEC
  • Дата начала Дата начала

SaMEC

Старожил
Пользователь
Баллы
173
Имя в Minecraft
Nick
Либо я дурак, либо лыжи не едут.
Код:
      public void onInventory(Player p, String section){
          Inventory i = Bukkit.createInventory(null, this.getConfig().getInt("gui."+section+".size"),
                                                        this.getConfig().getString("gui."+section+".name"));
           for (String path : this.getConfig().getConfigurationSection("gui."+section+".items").getKeys(false)){
               int a;
              for(a=0; a<i.getSize();a++){
                  if(path.equalsIgnoreCase(a+"")){
                     i.setItem(a, onItem(this.getConfig().getInt("gui."+section+".items."+a+".item"),
                                         this.getConfig().getString("gui."+section+".items."+a+".name"),
                                         this.getConfig().getStringList("gui."+section+".items."+a+".lore")));
                  }
              }
           }
          p.openInventory(i);
      }
Что может быть не так, или почему не работает getConfigurationSection
 
if(path.equalsIgnoreCase(a+""))
Так и не понял, зачем это нужно...
Вот, держи:
Код:
    public void onInventory(Player p, String guiId) {
        ConfigurationSection guiSection = this.getConfig().getConfigurationSection("gui." + guiId);
        if (guiSection == null) throw new IllegalArgumentException("Could not found gui with id " + guiId);
        Inventory i = Bukkit.createInventory(null,
                guiSection.getInt("size"),
                guiSection.getString("name"));
        for (String slot : guiSection.getConfigurationSection("items").getKeys(false)) {
            ConfigurationSection itemSection = guiSection.getConfigurationSection(slot);
            i.setItem(Integer.parseInt(slot), onItem(
                    itemSection.getInt("item"),
                    itemSection.getString("name"),
                    itemSection.getStringList("lore")));
        }
        p.openInventory(i);
    }
 
Так и не понял, зачем это нужно...
Вот, держи:
Код:
    public void onInventory(Player p, String guiId) {
        ConfigurationSection guiSection = this.getConfig().getConfigurationSection("gui." + guiId);
        if (guiSection == null) throw new IllegalArgumentException("Could not found gui with id " + guiId);
        Inventory i = Bukkit.createInventory(null,
                guiSection.getInt("size"),
                guiSection.getString("name"));
        for (String slot : guiSection.getConfigurationSection("items").getKeys(false)) {
            ConfigurationSection itemSection = guiSection.getConfigurationSection(slot);
            i.setItem(Integer.parseInt(slot), onItem(
                    itemSection.getInt("item"),
                    itemSection.getString("name"),
                    itemSection.getStringList("lore")));
        }
        p.openInventory(i);
    }
просто выкидывает в null на создании инвентаря
 
Назад
Верх