Skip to content
Misat11 edited this page Dec 14, 2019 · 29 revisions

SimpleGuiFormat

What is SimpleGuiFormat?

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

For Server Owner

Variables:

Plugins using this library

  1. BedWars - since 0.1.0
  2. ZombieApocalypse - since 2.0.4 (now have deprecated version)

For Plugin Developers

  1. Import maven repository

    <repository>
      <id>mtorus-repo</id>
      <url>https://jenkins.mtorus.cz/plugin/repository/everything/</url>
    </repository>
  2. Include dependency

    <dependency>
      <groupId>misat11.lib.sgui</groupId>
      <artifactId>SimpleGuiFormat</artifactId>
      <version>SELECTED_VERSION</version> <!-- current version is: 0.0.10-snap5 -->
      <scope>compile</scope>
    </dependency>
  3. Use it

    ...
    
    Bukkit.getServer().getPluginManager().registerEvents(new InventoryListener(), plugin); // for all guis
    
    ...
    Options options = new Options();
    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
    
    SimpleGuiFormat format = new SimpleGuiFormat(options); # create new format with options
    format.load(plugin.getDataFolder(), "gui.yml"); // load yml 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
    
    ...
  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>misat11.lib</pattern>
                    <shadedPattern>${project.groupId}.lib</shadedPattern>
                  </relocation>
                </relocations>
              </configuration>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </build>
  5. Build your plugin and enjoy it

    mvn install

Clone this wiki locally