Skip to content
Misat11 edited this page May 29, 2020 · 29 revisions

SimpleInventories

What is SimpleInventories?

SimpleInventories is library for generating gui menu in spigot plugin, example for shops, but it could be used for anything!

For Server Owner

Example format

Variables:

Plugins using this library

  1. BedWars - since 0.1.0
  2. ZombieApocalypse - since 2.0.4 (now have deprecated version)
  3. SimpleInventories of course

For Plugin Developers

  1. Import maven repository

    <repository>
      <id>screaming-repo</id>
      <url>https://repo.screamingsandals.org</url>
    </repository>
  2. Include dependency

    <dependency>
      <groupId>org.screamingsandals.simpleinventories</groupId>
      <artifactId>SimpleInventories-Core</artifactId>
      <version>LATEST_VERSION_HERE</version>
      <scope>compile</scope>
    </dependency>
  3. Use it

    ...
    
    InventoryListener.init(this); // for all guis
    
    ...
    Options options = new Options(this);
    options.setPrefix("My gui");
    options.setBackItem(backItem);
    options.setPageBackItem(pageBackItem);
    options.setForwardItem(pageForwardItem);
    options.setCosmeticItem(cosmeticItem);
    
    // and more and more options you can set here
    
    SimpleInventories format = new SimpleInventories(options); // create new format with options
    format.loadFromDataFolder(plugin.getDataFolder(), "gui.yml"); // load yml/groovy file
    
    // here you can modify 
    
    Bukkit.getServer().getPluginManager().registerEvents(new MyGuiListener(format), plugin); // create your listener for one inventory or for more inventories, it depends on you
    
    format.generateData(); // generate data after all listeners are registered and format is completely set
    
    // here you cannot modify format
    
    ...
    // somewhere in code you will need a way how to open it
    format.openForPlayer(player);
    ...
  4. Relocate package

    <build>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-shade-plugin</artifactId>
          <executions>
            <execution>
              <phase>package</phase>
              <goals>
                <goal>shade</goal>
              </goals>
              <configuration>
                <relocations>
                  <relocation>
                    <pattern>org.screamingsandals.simpleinventories</pattern>
                    <shadedPattern>${project.groupId}.si</shadedPattern>
                  </relocation>
                </relocations>
              </configuration>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </build>
  5. Build your plugin and enjoy it

    mvn install

Clone this wiki locally