IF Inventory Framework

repository·master·Indexed 19 days ago

https://github.com/stefvanschie/if

An inventory framework for Minecraft designed to manage GUIs using a pane-based architecture. IF supports GUI creation via code or XML and integrates with the Adventure library for modern text handling. Version 0.12.0 is available via Maven Central.

Tokens
1.5K
Snippets
4
Records
5
Agent score
18%

What's inside IF

  1. How IF's pane-based architecture works

    master

    IF is an inventory framework for managing Minecraft GUIs based on a pane principle.

    • A GUI is divided into different types of panes.
    • Each pane behaves differently and they can interact with each other.
    • GUIs can also be defined via XML files, allowing for easy creation with minimal code.
  2. Add IF as a Maven dependency

    master

    To use IF in your Maven project, add the following dependency to your pom.xml. The project is hosted in Maven Central, so no additional repository configuration is required.

    Note: IF does not support declaration via the libraries section in plugin.yml. You must use a build tool like Maven or Gradle.

    <dependency>
        <groupId>com.github.stefvanschie.inventoryframework</groupId>
        <artifactId>IF</artifactId>
        <version>0.12.0</version>
    </dependency>
  3. Add IF as a Gradle dependency

    master

    To use IF in a Gradle project, add the dependency to your dependencies block and ensure mavenCentral() is in your repositories block.

    You must use the shadowJar plugin to include IF in your final artifact. Relocate the classes to your own namespace to prevent conflicts.

    Paper Compatibility: If targeting Paper versions before 26.1, you must set the paperweight-mappings-namespace attribute to spigot within the shadowJar manifest configuration.

    // Dependencies
    dependencies {
        implementation 'com.github.stefvanschie.inventoryframework:IF:0.12.0'
    }
    
    // Repositories
    repositories {
        mavenCentral()
    }
    
    // Shadowing and Relocation
    plugins {
        id "com.gradleup.shadow" version "9.4.1"
    }
    
    shadowJar {
        relocate 'com.github.stefvanschie.inventoryframework', '[YOUR PACKAGE].inventoryframework'
    
        // Required for Paper plugins targeting versions < 26.1
        manifest {
            attributes 'paperweight-mappings-namespace': 'spigot'
        }
    }
  4. Shade and relocate IF in Maven

    master

    Since IF is a library, you should shade and relocate it into your plugin to avoid dependency conflicts. Use the maven-shade-plugin and replace [YOUR PACKAGE] with your project's top-level package.

    If your plugin targets a Paper version before 26.1, you must also set the paperweight-mappings-namespace to spigot in the META-INF/MANIFEST.MF using a transformer.

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>3.5.2</version>
        <configuration>
            <dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
            <relocations>
                <relocation>
                    <pattern>com.github.stefvanschie.inventoryframework</pattern>
                    <shadedPattern>[YOUR PACKAGE].inventoryframework</shadedPattern>
                </relocation>
            </relocations>
            <transformers>
                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                    <manifestEntries>
                        <paperweight-mappings-namespace>spigot</paperweight-mappings-namespace>
                    </manifestEntries>
                </transformer>
            </transformers>
        </configuration>
        <executions>
            <execution>
                <phase>package</phase>
                <goals>
                    <goal>shade</goal>
                </goals>
            </execution>
        </executions>
    </plugin>
  5. Use Adventure Components for text

    master

    IF supports the Adventure library for modern text handling. Using Adventure Components instead of legacy Strings is optional. If you don't use Adventure, you can ignore all TextHolder related methods.

    Implementation Requirements

    • Paper (Build 473+): Adventure is natively supported; no extra shading required.
    • Spigot or older Paper: You must shade and relocate adventure-api and adventure-platform-bukkit yourself.

    Usage Pattern

    Because IF avoids a hard dependency on Adventure, you must wrap components using ComponentHolder.of().

    Migration Example:

    • Legacy: namedGui.setTitle("My Title!");
    • Adventure: namedGui.setTitle(ComponentHolder.of(Component.text("My Title!")));
    import net.kyori.adventure.text.Component;
    
    // Use ComponentHolder.of to wrap Adventure components
    namedGui.setTitle(ComponentHolder.of(Component.text("My Title!")));