Skip to content

快速开始

huanmeng_qwq edited this page Dec 27, 2024 · 13 revisions

选择构建系统并引入依赖

目前主流的构建系统主要分为GradleMaven,其它构建系统需要自行了解如何执行

Gradle

build.gradlebuild.gradle.kts文件中添加:

plugins {
    // 添加shadow插件,来将依赖打包到最终产物中
    id("com.gradleup.shadow") version "8.3.0"
}

dependencies {
    implementation("com.huanmeng-qwq:bukkit-gui:2.3.5")
    // Kotlin DSL依赖
    implementation("com.huanmeng-qwq:bukkit-gui-kotlin-dsl:2.3.5")
}
// 除此之外,还需要对包名进行重定向,以避免不同插件见的版本冲突
shadowJar {
    // 替换 'com.yourpackage' 为你自己插件的包路径
    relocate("org.bstats","com.yourpackage.bstats") // 这是必须的,否则无法正常运行
    relocate 'me.huanmeng.opensource', 'com.yourpackage.huanmeng'
}

Maven

pom.xml文件中添加:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>3.2.3</version> <!-- 版本可能不是最新的 -->
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <relocations>
                    <relocation>
                        <pattern>me.huanmeng.opensource.bukkit.gui</pattern>
                        <!-- 替换 'com.yourpackage' 为你自己插件的包路径 -->
                        <shadedPattern>com.yourpackage.gui</shadedPattern>
                    </relocation>
                    <relocation>
                        <pattern>org.bstats</pattern>
                        <!-- 替换 'com.yourpackage' 为你自己插件的包路径 -->
                        <shadedPattern>com.yourpackage.bstats</shadedPattern>
                    </relocation>
                </relocations>
            </configuration>
        </plugin>
    </plugins>
</build>

<dependencies>
    <dependency>
        <groupId>com.huanmeng-qwq</groupId>
        <artifactId>bukkit-gui</artifactId>
        <version>2.3.5</version>
    </dependency>

    <!--Kotlin DSL-->

    <dependency>
        <groupId>com.huanmeng-qwq</groupId>
        <artifactId>bukkit-gui-kotlin-dsl</artifactId>
        <version>2.3.5</version>
    </dependency>
</dependencies>
Clone this wiki locally