Skip to content
Misat11 edited this page Jun 7, 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

Example format

Variables:

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.4 -->
      <scope>compile</scope>
    </dependency>
  3. Use it

    ...
    
    Bukkit.getServer().getPluginManager().registerEvents(new InventoryListener(), plugin); // for all guis
    
    ...
    
    SimpleGuiFormat format = new SimpleGuiFormat("My gui", backItem, pageBackItem, pageForwardItem, cosmeticItem);
    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

Plugins using this library

  1. BedWars - since 0.1.0
  2. ZombieApocalypse - since 2.0.4
Clone this wiki locally