Skip to content

WasabiThumb/spiglue

Repository files navigation

SpiGlue

A library for Spigot/Paper plugins that allows applying Adventure Components from any ClassLoader to various Bukkit API objects. Notably, allows reading/writing Components to ItemMeta.

This is not necessary if your plugin only targets Paper, as Paper has the ability to do this in its API.

Example

Also see the example plugin.

SpiGlue sg = SpiGlue.spiGlue();

ItemStack is = new ItemStack(Material.TNT, 1);
ItemMeta im = is.getItemMeta();

sg.itemMeta(im)
    .displayName(Component.text("Golden TNT").color(NamedTextColor.GOLD));

is.setItemMeta(im);

Usage

Gradle

dependencies {
    implementation("io.github.wasabithumb:spiglue:0.1.0")
    
    // Adventure
    implementation("net.kyori:adventure-api:VERSION")
    implementation("net.kyori:adventure-platform-bukkit:VERSION")
    
    // Required to convert Components when using Paper
    implementation("net.kyori:adventure-text-serializer-gson:VERSION")
    
    // Required to read & write Components when not using Paper
    implementation("net.kyori:adventure-text-serializer-legacy:VERSION")

    // Not required unless desired
    // implementation("net.kyori:adventure-text-serializer-plain:VERSION")
    // implementation("net.kyori:adventure-text-minimessage:VERSION")
}

// HIGHLY SUGGESTED: Relocate SpiGlue and Adventure
tasks.shadowJar {
    relocate("net.kyori", "your.package.here.shadow.kyori")
    relocate("io.github.wasabithumb.spiglue", "your.package.here.shadow.spiglue")
}

Maven

<dependencies>
    <dependency>
        <groupId>io.github.wasabithumb</groupId>
        <artifactId>spiglue</artifactId>
        <version>0.1.0</version>
        <scope>compile</scope>
    </dependency>
    <!-- Adventure -->
    <dependency>
        <groupId>net.kyori</groupId>
        <artifactId>adventure-api</artifactId>
        <version>VERSION</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>net.kyori</groupId>
        <artifactId>adventure-platform-bukkit</artifactId>
        <version>VERSION</version>
        <scope>compile</scope>
    </dependency>
    <!-- Required to convert Components when using Paper -->
    <dependency>
        <groupId>net.kyori</groupId>
        <artifactId>adventure-text-serializer-gson</artifactId>
        <version>VERSION</version>
        <scope>compile</scope>
    </dependency>
    <!-- Required to read & write Components when not using Paper -->
    <dependency>
        <groupId>net.kyori</groupId>
        <artifactId>adventure-text-serializer-legacy</artifactId>
        <version>VERSION</version>
        <scope>compile</scope>
    </dependency>
    <!-- Not required unless desired -->
    <!--
    <dependency>
        <groupId>net.kyori</groupId>
        <artifactId>adventure-text-serializer-plain</artifactId>
        <version>VERSION</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>net.kyori</groupId>
        <artifactId>adventure-text-minimessage</artifactId>
        <version>VERSION</version>
        <scope>compile</scope>
    </dependency>
    -->
</dependencies>

<!-- HIGHLY SUGGESTED: Relocate SpiGlue and Adventure -->
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>VERSION</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                    <configuration>
                        <relocations>
                            <relocation>
                                <pattern>net.kyori</pattern>
                                <shadedPattern>your.package.here.shadow.kyori</shadedPattern>
                            </relocation>
                            <relocation>
                                <pattern>io.github.wasabithumb.spiglue</pattern>
                                <shadedPattern>your.package.here.shadow.spiglue</shadedPattern>
                            </relocation>
                        </relocations>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

License

   Copyright 2024 Wasabi Codes

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

About

Tools for applying Adventure components to Spigot API objects

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages