diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 0000000..1845360 --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,31 @@ +name: PR Check + +on: + pull_request: + +jobs: + test: + permissions: + contents: write + discussions: write + + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: true + + - name: Setup jdk 17 + uses: actions/setup-java@v4 + with: + distribution: 'zulu' + java-version: '17' + + - uses: gradle/wrapper-validation-action@v2 + + - name: Fix Gradle permission + run: chmod +x gradlew + + - name: Test with Gradle + run: ./gradlew buildArtifacts test --stacktrace --no-daemon diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index e69de29..0000000 diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml new file mode 100644 index 0000000..8704887 --- /dev/null +++ b/.github/workflows/push.yml @@ -0,0 +1,64 @@ +name: Push Build + +on: + push: + workflow_dispatch: + +jobs: + build: + if: ${{ !startsWith(github.ref.name, 'refs/tags/') && contains(github.event.head_commit.message, '[build skip]') == false }} + permissions: + contents: write + + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: true + + - name: Setup jdk 17 + uses: actions/setup-java@v4 + with: + distribution: 'zulu' + java-version: '17' + + - uses: gradle/wrapper-validation-action@v2 + + - name: Fix Gradle permission + run: chmod +x gradlew + + - name: Build with Gradle + run: ./gradlew buildArtifacts --stacktrace --no-daemon + + - name: Get short SHA + run: echo "SHORT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV + + - name: Read Properties info + id: prop_info + uses: christian-draeger/read-properties@1.1.1 + with: + path: gradle.properties + properties: "release_version" + + - name: Upload Artifacts + uses: actions/upload-artifact@v4 + with: + name: TubeNekoPlugin-${{ env.SHORT_SHA }} + path: | + build/libs/*.jar + + - name: Create GitHub Release + if: ${{ contains(github.event.head_commit.message, '[publish skip]') == false && contains(github.event.head_commit.message, 'release:') }} + uses: softprops/action-gh-release@v2 + with: + files: | + build/libs/*.jar + !build/libs/*-dev.jar + !build/libs/*-dev-source.jar + name: ${{ steps.prop_info.outputs.release_version }} + tag_name: ${{ steps.prop_info.outputs.release_version }}-${{ env.SHORT_SHA }} + make_latest: "true" + target_commitish: ${{ github.event.ref }} + generate_release_notes: true + token: ${{ secrets.RELEASE_TOKEN }} diff --git a/build.gradle b/build.gradle index f48ae87..f309314 100644 --- a/build.gradle +++ b/build.gradle @@ -7,9 +7,9 @@ plugins { allprojects { apply plugin: "java" - group = 'xyz.tcbuildmc.minecraft' - version = '1.0.0-SNAPSHOT' - base.archivesName = "HorizontalNekoPlugin-" + project.name + group = rootProject.maven_group + version = rootProject.release_version + base.archivesName = "${rootProject.archives_base_name}-${project.name}" repositories { mavenLocal() @@ -63,10 +63,14 @@ allprojects { compileJava.dependsOn(clean) jar { + archiveClassifier.set "dev" + zip64 true } sourcesJar { + archiveClassifier.set "dev-source" + duplicatesStrategy DuplicatesStrategy.EXCLUDE } } @@ -81,20 +85,24 @@ subprojects { annotationProcessor 'org.projectlombok:lombok:1.18.32' compileOnly 'org.projectlombok:lombok:1.18.32' - implementation "com.electronwill.night-config:toml:3.6.7" + annotationProcessor(testImplementation("org.projectlombok:lombok:1.18.30")) + testImplementation platform('org.junit:junit-bom:5.10.2') + testImplementation 'org.junit.jupiter:junit-jupiter' } - shadowJar { - dependencies { - include dependency("com.electronwill.night-config:core:3.6.7") - include dependency("com.electronwill.night-config:toml:3.6.7") - } + test { + useJUnitPlatform() - def reloc = { String from, String dest -> - relocate from, dest + ignoreFailures true + + testLogging { + exceptionFormat = 'full' + events "passed", "skipped", "failed" } + } - reloc "com.electronwill.nightconfig", "xyz.tcbuildmc.minecraft.hnp.nightconfig" + shadowJar { + archiveClassifier.set null zip64 true } @@ -114,20 +122,19 @@ subprojects { } tasks.register("buildArtifacts") { - logger.lifecycle(":step1 build subprojects") - subprojects { dependsOn project.tasks.named("build").get() dependsOn project.tasks.named("shadowJar").get() } doFirst { - logger.lifecycle(":step2 clean buildLibs of rootProject") + logger.lifecycle(":executing 2 steps to build artifacts") + logger.lifecycle(":step1 clean buildLibs of rootProject") delete fileTree(rootProject.buildDir.toPath().resolve("libs")) { include '*' } - logger.lifecycle(":step3 copy buildLibs from subprojects") + logger.lifecycle(":step2 copy buildLibs from subprojects") subprojects { copy { from(project.buildDir.toPath().resolve("libs")) { diff --git a/bukkit/build.gradle b/bukkit/build.gradle index 772fa8c..08f4ad0 100644 --- a/bukkit/build.gradle +++ b/bukkit/build.gradle @@ -1,4 +1,6 @@ dependencies { + implementation project(path: ":common", configuration: "shadow") + compileOnly "org.spigotmc:spigot-api:1.20.4-R0.1-SNAPSHOT" compileOnly "me.clip:placeholderapi:2.11.5" implementation "dev.jorel:commandapi-bukkit-shade:9.3.0" @@ -15,6 +17,7 @@ processResources { shadowJar { dependencies { + include project(":common") include dependency("dev.jorel:commandapi-bukkit-shade:9.3.0") } @@ -22,7 +25,7 @@ shadowJar { relocate from, dest } - reloc "dev.jorel.commandapi", "xyz.tcbuildmc.minecraft.hnp.commandapi" + reloc "dev.jorel.commandapi", "xyz.tcbuildmc.minecraft.hnp.bukkit.commandapi" zip64 true } diff --git a/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/HorizontalNekoPlugin.java b/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/HorizontalNekoPlugin.java deleted file mode 100644 index ff0eed1..0000000 --- a/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/HorizontalNekoPlugin.java +++ /dev/null @@ -1,30 +0,0 @@ -package xyz.tcbuildmc.minecraft.hnp; - -import dev.jorel.commandapi.CommandAPI; -import dev.jorel.commandapi.CommandAPIBukkitConfig; -import org.bukkit.plugin.java.JavaPlugin; -import xyz.tcbuildmc.minecraft.hnp.command.HorizontalNekoCommands; - -public final class HorizontalNekoPlugin extends JavaPlugin { - @Override - public void onLoad() { - // CommandAPI Initialize - CommandAPI.onLoad(new CommandAPIBukkitConfig(this).verboseOutput(true)); - - HorizontalNekoCommands.register(); - } - - @Override - public void onEnable() { - CommandAPI.onEnable(); - - saveDefaultConfig(); - } - - @Override - public void onDisable() { - CommandAPI.onDisable(); - - saveConfig(); - } -} diff --git a/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/bukkit/HorizontalNekoPlugin.java b/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/bukkit/HorizontalNekoPlugin.java new file mode 100644 index 0000000..ce15df7 --- /dev/null +++ b/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/bukkit/HorizontalNekoPlugin.java @@ -0,0 +1,41 @@ +package xyz.tcbuildmc.minecraft.hnp.bukkit; + +import dev.jorel.commandapi.CommandAPI; +import dev.jorel.commandapi.CommandAPIBukkitConfig; +import lombok.Getter; +import org.bukkit.plugin.java.JavaPlugin; +import xyz.tcbuildmc.minecraft.hnp.bukkit.command.HorizontalNekoCommands; +import xyz.tcbuildmc.minecraft.hnp.common.HorizontalNekoPluginConfigHelper; + +@Getter +public final class HorizontalNekoPlugin extends JavaPlugin { + private static HorizontalNekoPlugin instance; + private static HorizontalNekoPluginConfigHelper config; + + public HorizontalNekoPlugin() { + HorizontalNekoPlugin.instance = this; + HorizontalNekoPlugin.config = new HorizontalNekoPluginConfigHelper(HorizontalNekoPlugin.class); + } + + @Override + public void onLoad() { + // CommandAPI Initialize + CommandAPI.onLoad(new CommandAPIBukkitConfig(this).verboseOutput(true)); + + HorizontalNekoCommands.register(); + } + + @Override + public void onEnable() { + CommandAPI.onEnable(); + + config.load(); + } + + @Override + public void onDisable() { + config.close(); + + CommandAPI.onDisable(); + } +} diff --git a/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/command/HorizontalNekoCommands.java b/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/bukkit/command/HorizontalNekoCommands.java similarity index 64% rename from bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/command/HorizontalNekoCommands.java rename to bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/bukkit/command/HorizontalNekoCommands.java index 6c6f75b..6e20090 100644 --- a/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/command/HorizontalNekoCommands.java +++ b/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/bukkit/command/HorizontalNekoCommands.java @@ -1,8 +1,8 @@ -package xyz.tcbuildmc.minecraft.hnp.command; +package xyz.tcbuildmc.minecraft.hnp.bukkit.command; import org.bukkit.ChatColor; -import xyz.tcbuildmc.minecraft.hnp.util.CommandUtils; -import xyz.tcbuildmc.minecraft.hnp.util.TextUtils; +import xyz.tcbuildmc.minecraft.hnp.bukkit.util.BukkitHolderString; +import xyz.tcbuildmc.minecraft.hnp.bukkit.util.CommandUtils; import java.util.Random; @@ -12,7 +12,7 @@ public static void register() { .executes((sender, args) -> { Random random = new Random(); - sender.sendMessage(TextUtils.formatted("Your lucky number is: %number%") + sender.sendMessage(new BukkitHolderString("Your lucky number is: %number%") .appendColor(ChatColor.AQUA) .replaceHolder("%number%", random.nextInt(100)) .toString()); diff --git a/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/bukkit/command/LuckyCommand.java b/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/bukkit/command/LuckyCommand.java new file mode 100644 index 0000000..438a628 --- /dev/null +++ b/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/bukkit/command/LuckyCommand.java @@ -0,0 +1,4 @@ +package xyz.tcbuildmc.minecraft.hnp.bukkit.command; + +public final class LuckyCommand { +} diff --git a/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/bukkit/hook/papi/PlaceholderAPIHook.java b/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/bukkit/hook/papi/PlaceholderAPIHook.java new file mode 100644 index 0000000..ae86b52 --- /dev/null +++ b/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/bukkit/hook/papi/PlaceholderAPIHook.java @@ -0,0 +1,4 @@ +package xyz.tcbuildmc.minecraft.hnp.bukkit.hook.papi; + +public class PlaceholderAPIHook { +} diff --git a/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/bukkit/util/BukkitHolderString.java b/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/bukkit/util/BukkitHolderString.java new file mode 100644 index 0000000..501cc7f --- /dev/null +++ b/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/bukkit/util/BukkitHolderString.java @@ -0,0 +1,18 @@ +package xyz.tcbuildmc.minecraft.hnp.bukkit.util; + +import org.bukkit.ChatColor; +import xyz.tcbuildmc.common.util.HolderString; + +public class BukkitHolderString extends HolderString { + public BukkitHolderString(String string) { + super(string); + } + + public BukkitHolderString() { + } + + public BukkitHolderString appendColor(ChatColor color) { + this.setString(color + this.getString()); + return this; + } +} diff --git a/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/util/CommandUtils.java b/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/bukkit/util/CommandUtils.java similarity index 97% rename from bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/util/CommandUtils.java rename to bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/bukkit/util/CommandUtils.java index 2934026..f51709c 100644 --- a/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/util/CommandUtils.java +++ b/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/bukkit/util/CommandUtils.java @@ -1,4 +1,4 @@ -package xyz.tcbuildmc.minecraft.hnp.util; +package xyz.tcbuildmc.minecraft.hnp.bukkit.util; import dev.jorel.commandapi.CommandAPICommand; import dev.jorel.commandapi.CommandPermission; @@ -10,7 +10,7 @@ import org.bukkit.command.ProxiedCommandSender; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; -import xyz.tcbuildmc.minecraft.hnp.annotations.Testing; +import xyz.tcbuildmc.common.annotations.Testing; import java.util.List; import java.util.function.Predicate; diff --git a/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/util/ExecutorSupplier.java b/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/bukkit/util/ExecutorSupplier.java similarity index 64% rename from bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/util/ExecutorSupplier.java rename to bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/bukkit/util/ExecutorSupplier.java index de35818..9724e7c 100644 --- a/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/util/ExecutorSupplier.java +++ b/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/bukkit/util/ExecutorSupplier.java @@ -1,7 +1,7 @@ -package xyz.tcbuildmc.minecraft.hnp.util; +package xyz.tcbuildmc.minecraft.hnp.bukkit.util; import dev.jorel.commandapi.executors.CommandArguments; -import xyz.tcbuildmc.minecraft.hnp.annotations.Testing; +import xyz.tcbuildmc.common.annotations.Testing; @Testing @FunctionalInterface diff --git a/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/command/LuckyCommand.java b/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/command/LuckyCommand.java deleted file mode 100644 index 0a6c3f8..0000000 --- a/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/command/LuckyCommand.java +++ /dev/null @@ -1,4 +0,0 @@ -package xyz.tcbuildmc.minecraft.hnp.command; - -public final class LuckyCommand { -} diff --git a/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/hook/papi/PlaceholderAPIHook.java b/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/hook/papi/PlaceholderAPIHook.java deleted file mode 100644 index d5fa073..0000000 --- a/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/hook/papi/PlaceholderAPIHook.java +++ /dev/null @@ -1,4 +0,0 @@ -package xyz.tcbuildmc.minecraft.hnp.hook.papi; - -public class PlaceholderAPIHook { -} diff --git a/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/throwable/HorizontalNekoException.java b/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/throwable/HorizontalNekoException.java deleted file mode 100644 index 13e4a8a..0000000 --- a/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/throwable/HorizontalNekoException.java +++ /dev/null @@ -1,4 +0,0 @@ -package xyz.tcbuildmc.minecraft.hnp.throwable; - -public class HorizontalNekoException extends Exception { -} diff --git a/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/util/Constants.java b/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/util/Constants.java deleted file mode 100644 index 85dae8f..0000000 --- a/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/util/Constants.java +++ /dev/null @@ -1,4 +0,0 @@ -package xyz.tcbuildmc.minecraft.hnp.util; - -public final class Constants { -} diff --git a/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/util/TextUtils.java b/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/util/TextUtils.java deleted file mode 100644 index 41d29f7..0000000 --- a/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/util/TextUtils.java +++ /dev/null @@ -1,66 +0,0 @@ -package xyz.tcbuildmc.minecraft.hnp.util; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.bukkit.ChatColor; - -import java.util.List; -import java.util.Map; - -public final class TextUtils { - public static String format(final ChatColor color, final String string, final Object... args) { - String message = color + string; - - for (Object o : args) { - message = message.replaceFirst("%*%", o.toString()); - } - - return message; - } - - public static TextUtils.FormattedString formatted(String s) { - return new TextUtils.FormattedString(s); - } - - @Data - @AllArgsConstructor - @NoArgsConstructor - public static class FormattedString { - private String string; - - public TextUtils.FormattedString appendColor(ChatColor color) { - this.string = color + this.string; - return this; - } - - public TextUtils.FormattedString replaceHolder(String holder, Object value) { - String regex = "%" + holder + "%"; - this.string = this.string.replaceFirst(regex, value.toString()); - return this; - } - - public TextUtils.FormattedString replaceAllHolder(String holder, Object value) { - String regex = "%" + holder + "%"; - this.string = this.string.replaceAll(regex, value.toString()); - return this; - } - - public TextUtils.FormattedString replaceHolders(Map map) { - map.forEach((str, o) -> { - String regex = "%" + str + "%"; - - if (o instanceof List list) { - list.forEach(o1 -> this.string = this.string.replaceFirst(regex, o1.toString())); - } - this.string = this.string.replaceFirst(regex, o.toString()); - }); - return this; - } - - @Override - public String toString() { - return this.string; - } - } -} diff --git a/bukkit/src/main/resources/config.yml b/bukkit/src/main/resources/config.yml deleted file mode 100644 index e69de29..0000000 diff --git a/bukkit/src/main/resources/plugin.yml b/bukkit/src/main/resources/plugin.yml index 680ac1d..bd7baa8 100644 --- a/bukkit/src/main/resources/plugin.yml +++ b/bukkit/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: HorizontalNekoPlugin version: '${version}' -main: xyz.tcbuildmc.minecraft.hnp.HorizontalNekoPlugin +main: xyz.tcbuildmc.minecraft.hnp.bukkit.HorizontalNekoPlugin api-version: '1.20' prefix: HorizontalNekoPlugin softdepend: diff --git a/bungeecord/build.gradle b/bungeecord/build.gradle index ed92648..2b73ade 100644 --- a/bungeecord/build.gradle +++ b/bungeecord/build.gradle @@ -1,4 +1,6 @@ dependencies { + implementation project(path: ":common", configuration: "shadow") + compileOnly "net.md-5:bungeecord-api:1.20-R0.3-SNAPSHOT" compileOnly "me.clip:placeholderapi:2.11.5" } @@ -11,3 +13,13 @@ processResources { expand props } } + +shadowJar { + dependencies { + include project(":common") + } + + def reloc = { String from, String dest -> + relocate from, dest + } +} diff --git a/bungeecord/src/main/java/xyz/tcbuildmc/minecraft/hnp/HorizontalNekoPlugin.java b/bungeecord/src/main/java/xyz/tcbuildmc/minecraft/hnp/HorizontalNekoPlugin.java deleted file mode 100644 index 17600fa..0000000 --- a/bungeecord/src/main/java/xyz/tcbuildmc/minecraft/hnp/HorizontalNekoPlugin.java +++ /dev/null @@ -1,13 +0,0 @@ -package xyz.tcbuildmc.minecraft.hnp; - -import net.md_5.bungee.api.plugin.Plugin; - -public final class HorizontalNekoPlugin extends Plugin { - @Override - public void onEnable() { - } - - @Override - public void onDisable() { - } -} diff --git a/bungeecord/src/main/java/xyz/tcbuildmc/minecraft/hnp/bungeecord/HorizontalNekoPlugin.java b/bungeecord/src/main/java/xyz/tcbuildmc/minecraft/hnp/bungeecord/HorizontalNekoPlugin.java new file mode 100644 index 0000000..a61ae87 --- /dev/null +++ b/bungeecord/src/main/java/xyz/tcbuildmc/minecraft/hnp/bungeecord/HorizontalNekoPlugin.java @@ -0,0 +1,26 @@ +package xyz.tcbuildmc.minecraft.hnp.bungeecord; + +import lombok.Getter; +import net.md_5.bungee.api.plugin.Plugin; +import xyz.tcbuildmc.minecraft.hnp.common.HorizontalNekoPluginConfigHelper; + +@Getter +public final class HorizontalNekoPlugin extends Plugin { + private static HorizontalNekoPlugin instance; + private static HorizontalNekoPluginConfigHelper config; + + public HorizontalNekoPlugin() { + HorizontalNekoPlugin.instance = this; + HorizontalNekoPlugin.config = new HorizontalNekoPluginConfigHelper(HorizontalNekoPlugin.class); + } + + @Override + public void onEnable() { + config.load(); + } + + @Override + public void onDisable() { + config.close(); + } +} diff --git a/bungeecord/src/main/java/xyz/tcbuildmc/minecraft/hnp/bungeecord/network/PluginMessage.java b/bungeecord/src/main/java/xyz/tcbuildmc/minecraft/hnp/bungeecord/network/PluginMessage.java new file mode 100644 index 0000000..ad0b377 --- /dev/null +++ b/bungeecord/src/main/java/xyz/tcbuildmc/minecraft/hnp/bungeecord/network/PluginMessage.java @@ -0,0 +1,4 @@ +package xyz.tcbuildmc.minecraft.hnp.bungeecord.network; + +public class PluginMessage { +} diff --git a/bungeecord/src/main/java/xyz/tcbuildmc/minecraft/hnp/network/PluginMessage.java b/bungeecord/src/main/java/xyz/tcbuildmc/minecraft/hnp/network/PluginMessage.java deleted file mode 100644 index 864a76e..0000000 --- a/bungeecord/src/main/java/xyz/tcbuildmc/minecraft/hnp/network/PluginMessage.java +++ /dev/null @@ -1,4 +0,0 @@ -package xyz.tcbuildmc.minecraft.hnp.network; - -public class PluginMessage { -} diff --git a/bungeecord/src/main/resources/config.yml b/bungeecord/src/main/resources/config.yml deleted file mode 100644 index 8b13789..0000000 --- a/bungeecord/src/main/resources/config.yml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/bungeecord/src/main/resources/plugin.yml b/bungeecord/src/main/resources/plugin.yml index 0ac5a71..1ed45d0 100644 --- a/bungeecord/src/main/resources/plugin.yml +++ b/bungeecord/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: HorizontalNekoPlugin version: '${version}' -main: xyz.tcbuildmc.minecraft.hnp.HorizontalNekoPlugin +main: xyz.tcbuildmc.minecraft.hnp.bungeecord.HorizontalNekoPlugin prefix: HorizontalNekoPlugin #softdepend: # - PlaceholderAPI diff --git a/common/build.gradle b/common/build.gradle new file mode 100644 index 0000000..7abfbc2 --- /dev/null +++ b/common/build.gradle @@ -0,0 +1,16 @@ +dependencies { + implementation "com.electronwill.night-config:toml:3.6.7" +} + +shadowJar { + dependencies { + include dependency("com.electronwill.night-config:core:3.6.7") + include dependency("com.electronwill.night-config:toml:3.6.7") + } + + def reloc = { String from, String dest -> + relocate from, dest + } + + reloc "com.electronwill.nightconfig", "xyz.tcbuildmc.common.nightconfig" +} diff --git a/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/annotations/Testing.java b/common/src/main/java/xyz/tcbuildmc/common/annotations/Testing.java similarity index 56% rename from bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/annotations/Testing.java rename to common/src/main/java/xyz/tcbuildmc/common/annotations/Testing.java index a83cf79..a77013d 100644 --- a/bukkit/src/main/java/xyz/tcbuildmc/minecraft/hnp/annotations/Testing.java +++ b/common/src/main/java/xyz/tcbuildmc/common/annotations/Testing.java @@ -1,4 +1,4 @@ -package xyz.tcbuildmc.minecraft.hnp.annotations; +package xyz.tcbuildmc.common.annotations; public @interface Testing { String before() default ""; diff --git a/common/src/main/java/xyz/tcbuildmc/common/config/ConfigHelper.java b/common/src/main/java/xyz/tcbuildmc/common/config/ConfigHelper.java new file mode 100644 index 0000000..11c858c --- /dev/null +++ b/common/src/main/java/xyz/tcbuildmc/common/config/ConfigHelper.java @@ -0,0 +1,87 @@ +package xyz.tcbuildmc.common.config; + +import com.electronwill.nightconfig.core.file.CommentedFileConfig; +import lombok.Getter; + +import java.io.File; +import java.net.URL; +import java.nio.file.Path; +import java.util.Map; + +@Getter +public abstract class ConfigHelper { + private final CommentedFileConfig config; + + public ConfigHelper(Path path, URL defaultConfig) { + this.config = CommentedFileConfig.builder(path) + .defaultData(defaultConfig) + .autosave() + .build(); + } + + public ConfigHelper(Path path, ClassLoader loader, String defaultConfigName) { + this(path, loader.getResource(defaultConfigName)); + } + + public ConfigHelper(Path path, Class clazz, String defaultConfigName) { + this(path, clazz.getClassLoader(), defaultConfigName); + } + + public T getContent(String path) { + return this.config.get(path); + } + + public void setContent(String path, Object object) { + this.config.set(path, object); + } + + public void addContent(String path, Object object) { + this.config.add(path, object); + } + + public void removeContent(String path) { + this.config.remove(path); + } + + public void setComment(String path, String comment) { + this.config.setComment(path, comment); + } + + public void removeComment(String path) { + this.config.removeComment(path); + } + + public Map getContentMap() { + return this.config.valueMap(); + } + + public Map getCommentMap() { + return this.config.commentMap(); + } + + public File getConfigFile() { + return this.config.getFile(); + } + + public Path getConfigPath() { + return this.config.getNioPath(); + } + + public void load() { + this.config.load(); + } + + @Deprecated(forRemoval = true) + public void reload() { + this.load(); + } + + @Deprecated(forRemoval = true) + public void save() { + this.config.save(); + } + + public void close() { + this.config.close(); + } +} diff --git a/common/src/main/java/xyz/tcbuildmc/common/util/HolderString.java b/common/src/main/java/xyz/tcbuildmc/common/util/HolderString.java new file mode 100644 index 0000000..c8800f1 --- /dev/null +++ b/common/src/main/java/xyz/tcbuildmc/common/util/HolderString.java @@ -0,0 +1,44 @@ +package xyz.tcbuildmc.common.util; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; +import java.util.Map; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class HolderString { + private String string; + + public HolderString replaceHolder(String holder, Object value) { + String regex = "%" + holder + "%"; + this.string = this.string.replaceFirst(regex, value.toString()); + return this; + } + + public HolderString replaceAllHolder(String holder, Object value) { + String regex = "%" + holder + "%"; + this.string = this.string.replaceAll(regex, value.toString()); + return this; + } + + public HolderString replaceHolders(Map map) { + map.forEach((str, o) -> { + String regex = "%" + str + "%"; + + if (o instanceof List list) { + list.forEach(o1 -> this.string = this.string.replaceFirst(regex, o1.toString())); + } + this.string = this.string.replaceFirst(regex, o.toString()); + }); + return this; + } + + @Override + public String toString() { + return this.string; + } +} diff --git a/common/src/main/java/xyz/tcbuildmc/common/util/TextUtils.java b/common/src/main/java/xyz/tcbuildmc/common/util/TextUtils.java new file mode 100644 index 0000000..6d2c8e5 --- /dev/null +++ b/common/src/main/java/xyz/tcbuildmc/common/util/TextUtils.java @@ -0,0 +1,13 @@ +package xyz.tcbuildmc.common.util; + +public final class TextUtils { + public static String format(final String string, final Object... args) { + String message = string; + + for (Object o : args) { + message = message.replaceFirst("%*%", o.toString()); + } + + return message; + } +} diff --git a/common/src/main/java/xyz/tcbuildmc/minecraft/hnp/common/ConfigContent.java b/common/src/main/java/xyz/tcbuildmc/minecraft/hnp/common/ConfigContent.java new file mode 100644 index 0000000..a581108 --- /dev/null +++ b/common/src/main/java/xyz/tcbuildmc/minecraft/hnp/common/ConfigContent.java @@ -0,0 +1,4 @@ +package xyz.tcbuildmc.minecraft.hnp.common; + +public interface ConfigContent { +} diff --git a/common/src/main/java/xyz/tcbuildmc/minecraft/hnp/common/Extension.java b/common/src/main/java/xyz/tcbuildmc/minecraft/hnp/common/Extension.java new file mode 100644 index 0000000..f862766 --- /dev/null +++ b/common/src/main/java/xyz/tcbuildmc/minecraft/hnp/common/Extension.java @@ -0,0 +1,4 @@ +package xyz.tcbuildmc.minecraft.hnp.common; + +public abstract class Extension { +} diff --git a/common/src/main/java/xyz/tcbuildmc/minecraft/hnp/common/HorizontalNekoPluginConfigHelper.java b/common/src/main/java/xyz/tcbuildmc/minecraft/hnp/common/HorizontalNekoPluginConfigHelper.java new file mode 100644 index 0000000..1f7910f --- /dev/null +++ b/common/src/main/java/xyz/tcbuildmc/minecraft/hnp/common/HorizontalNekoPluginConfigHelper.java @@ -0,0 +1,13 @@ +package xyz.tcbuildmc.minecraft.hnp.common; + +import xyz.tcbuildmc.common.config.ConfigHelper; + +import java.nio.file.Paths; + +public final class HorizontalNekoPluginConfigHelper extends ConfigHelper { + public HorizontalNekoPluginConfigHelper(Class clazz) { + super(Paths.get("./plugins/HorizontalNekoPlugin/config.toml"), + clazz, + "config.toml"); + } +} diff --git a/common/src/main/java/xyz/tcbuildmc/minecraft/hnp/common/util/Constants.java b/common/src/main/java/xyz/tcbuildmc/minecraft/hnp/common/util/Constants.java new file mode 100644 index 0000000..87c310a --- /dev/null +++ b/common/src/main/java/xyz/tcbuildmc/minecraft/hnp/common/util/Constants.java @@ -0,0 +1,4 @@ +package xyz.tcbuildmc.minecraft.hnp.common.util; + +public final class Constants { +} diff --git a/velocity/src/main/resources/config.toml b/common/src/main/resources/config.toml similarity index 100% rename from velocity/src/main/resources/config.toml rename to common/src/main/resources/config.toml diff --git a/gradle.properties b/gradle.properties index e69de29..e825350 100644 --- a/gradle.properties +++ b/gradle.properties @@ -0,0 +1,6 @@ +org.gradle.daemon=false +org.gradle.jvmargs=-Xmx1G + +release_version=1.0.0-alpha.1 +maven_group=xyz.tcbuildmc.minecraft +archives_base_name=HorizontalNekoPlugin diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..e644113 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e096528..b82aa23 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..1aa94a4 --- /dev/null +++ b/gradlew @@ -0,0 +1,249 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# 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 +# +# https://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. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..25da30d --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/jitpack.yml b/jitpack.yml new file mode 100644 index 0000000..d42b19f --- /dev/null +++ b/jitpack.yml @@ -0,0 +1,3 @@ +before_install: + - sdk install java 17.0.8.1-tem + - sdk use java 17.0.8.1-tem diff --git a/settings.gradle b/settings.gradle index b8dface..f31a54e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,4 +1,5 @@ def modules = [ + "common", "bukkit", "bungeecord", "velocity" diff --git a/velocity/build.gradle b/velocity/build.gradle index 45f18ec..7b7dc26 100644 --- a/velocity/build.gradle +++ b/velocity/build.gradle @@ -1,6 +1,18 @@ dependencies { + implementation project(path: ":common", configuration: "shadow") + compileOnly "com.velocitypowered:velocity-api:3.3.0-SNAPSHOT" annotationProcessor "com.velocitypowered:velocity-api:3.3.0-SNAPSHOT" implementation 'net.william278:papiproxybridge:1.5' } + +shadowJar { + dependencies { + include project(":common") + } + + def reloc = { String from, String dest -> + relocate from, dest + } +} diff --git a/velocity/src/main/java/xyz/tcbuildmc/minecraft/hnp/network/PluginMessage.java b/velocity/src/main/java/xyz/tcbuildmc/minecraft/hnp/network/PluginMessage.java deleted file mode 100644 index 864a76e..0000000 --- a/velocity/src/main/java/xyz/tcbuildmc/minecraft/hnp/network/PluginMessage.java +++ /dev/null @@ -1,4 +0,0 @@ -package xyz.tcbuildmc.minecraft.hnp.network; - -public class PluginMessage { -} diff --git a/velocity/src/main/java/xyz/tcbuildmc/minecraft/hnp/HorizontalNekoPlugin.java b/velocity/src/main/java/xyz/tcbuildmc/minecraft/hnp/velocity/HorizontalNekoPlugin.java similarity index 60% rename from velocity/src/main/java/xyz/tcbuildmc/minecraft/hnp/HorizontalNekoPlugin.java rename to velocity/src/main/java/xyz/tcbuildmc/minecraft/hnp/velocity/HorizontalNekoPlugin.java index 4accba4..982ff96 100644 --- a/velocity/src/main/java/xyz/tcbuildmc/minecraft/hnp/HorizontalNekoPlugin.java +++ b/velocity/src/main/java/xyz/tcbuildmc/minecraft/hnp/velocity/HorizontalNekoPlugin.java @@ -1,13 +1,17 @@ -package xyz.tcbuildmc.minecraft.hnp; +package xyz.tcbuildmc.minecraft.hnp.velocity; import com.google.inject.Inject; import com.velocitypowered.api.event.Subscribe; import com.velocitypowered.api.event.proxy.ProxyInitializeEvent; +import com.velocitypowered.api.event.proxy.ProxyReloadEvent; +import com.velocitypowered.api.event.proxy.ProxyShutdownEvent; import com.velocitypowered.api.plugin.Plugin; import com.velocitypowered.api.proxy.ProxyServer; +import lombok.Getter; import org.slf4j.Logger; +import xyz.tcbuildmc.minecraft.hnp.common.HorizontalNekoPluginConfigHelper; - +@Getter @Plugin(id = "horizontalnekoplugin", name = "HorizontalNekoPlugin", version = "1.0.0-SNAPSHOT", @@ -22,15 +26,28 @@ public final class HorizontalNekoPlugin { private final ProxyServer server; private final Logger logger; + private static HorizontalNekoPluginConfigHelper config; @Inject public HorizontalNekoPlugin(ProxyServer server, Logger logger) { this.server = server; this.logger = logger; + HorizontalNekoPlugin.config = new HorizontalNekoPluginConfigHelper(HorizontalNekoPlugin.class); } @Subscribe public void onProxyInit(ProxyInitializeEvent e) { + config.load(); + } + + @Subscribe + public void onProxyShutdown(ProxyShutdownEvent e) { + config.close(); + } + @Subscribe + public void onProxyReload(ProxyReloadEvent e) { + config.close(); + config.load(); } } diff --git a/velocity/src/main/java/xyz/tcbuildmc/minecraft/hnp/velocity/network/PluginMessage.java b/velocity/src/main/java/xyz/tcbuildmc/minecraft/hnp/velocity/network/PluginMessage.java new file mode 100644 index 0000000..3ddce0e --- /dev/null +++ b/velocity/src/main/java/xyz/tcbuildmc/minecraft/hnp/velocity/network/PluginMessage.java @@ -0,0 +1,4 @@ +package xyz.tcbuildmc.minecraft.hnp.velocity.network; + +public class PluginMessage { +}