From f82160d7d3c3dfab4f5c81de865dfa6130415931 Mon Sep 17 00:00:00 2001 From: Len <40720638+destro174@users.noreply.github.com> Date: Sat, 25 Jul 2026 10:43:58 -0500 Subject: [PATCH] Refactor to PaperPlugin --- build.gradle.kts | 80 +++++++++++++++---- .../afkdectector/AFKDetectorBootstrap.java | 13 +++ src/main/resources/changelog.txt | 0 src/main/resources/plugin.yml | 66 --------------- 4 files changed, 77 insertions(+), 82 deletions(-) create mode 100644 src/main/java/com/alttd/afkdectector/AFKDetectorBootstrap.java delete mode 100755 src/main/resources/changelog.txt delete mode 100755 src/main/resources/plugin.yml diff --git a/build.gradle.kts b/build.gradle.kts index 8fe465e..a0ee973 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,7 +1,9 @@ -import java.io.ByteArrayOutputStream +import net.minecrell.pluginyml.bukkit.BukkitPluginDescription +import net.minecrell.pluginyml.paper.PaperPluginDescription plugins { id("java") + id("de.eldoria.plugin-yml.paper") version "0.9.0" } group = "com.alttd" @@ -27,14 +29,6 @@ tasks { jar { archiveFileName.set("${rootProject.name}.jar") } - - processResources { - filteringCharset = Charsets.UTF_8.name() - duplicatesStrategy = DuplicatesStrategy.INCLUDE - filesMatching("plugin.yml") { - expand(Pair("projectVersion", project.version)) - } - } } dependencies { @@ -48,12 +42,66 @@ dependencies { } fun gitCommit(): String { -// val os = ByteArrayOutputStream() -// project.exec { -// isIgnoreExitValue = true -// commandLine = "git rev-parse --short HEAD".split(" ") -// standardOutput = os -// } -// return String(os.toByteArray()).trim() return "FIXME" } + +paper { + name = rootProject.name + main = "$group.${rootProject.name}" + description = rootProject.description + bootstrapper = "$group.${rootProject.name}Bootstrap" + version = "${rootProject.version}" + apiVersion = "26.2" + authors = listOf("destro174") + serverDependencies { + register("MyPet") { + required = false + load = PaperPluginDescription.RelativeLoadOrder.BEFORE + } + } + permissions { + register("afkdetector.admin") { + description = "Admin permission for the ${rootProject.name} plugin." + default = BukkitPluginDescription.Permission.Default.FALSE + children = listOf( + "afkdetector.bypass", + "afkdetector.afklist", + "afkdetector.afkcheck", + "afkdetector.notify", + "afkdetector.reload" + ) + } + register("afkdetector.bypass") { + description = "Bypass permission for the ${rootProject.name} plugin." + default = BukkitPluginDescription.Permission.Default.FALSE + children = listOf( + "afkdetector.kickexempt" + ) + } + register("afkdetector.reload") { + description = "Allows reloading the ${rootProject.name} plugin." + default = BukkitPluginDescription.Permission.Default.FALSE + } + register("afkdetector.kickexempt") { + description = "Bypass permission for being afk kicked." + default = BukkitPluginDescription.Permission.Default.FALSE + } + register("afkdetector.afktime") { + description = "Master permission for custom afk time in the ${rootProject.name} plugin." + default = BukkitPluginDescription.Permission.Default.FALSE + } + register("afkdetector.afkcheck") { + description = "Allows usage of the /afkcheck command." + default = BukkitPluginDescription.Permission.Default.FALSE + } + + register("afkdetector.afklist") { + description = "Allows usage of the /afklist command." + default = BukkitPluginDescription.Permission.Default.FALSE + } + register("afkdetector.notify") { + description = "Get notified when a player is afk." + default = BukkitPluginDescription.Permission.Default.FALSE + } + } +} \ No newline at end of file diff --git a/src/main/java/com/alttd/afkdectector/AFKDetectorBootstrap.java b/src/main/java/com/alttd/afkdectector/AFKDetectorBootstrap.java new file mode 100644 index 0000000..b9e8eeb --- /dev/null +++ b/src/main/java/com/alttd/afkdectector/AFKDetectorBootstrap.java @@ -0,0 +1,13 @@ +package com.alttd.afkdectector; + + +import io.papermc.paper.plugin.bootstrap.BootstrapContext; +import io.papermc.paper.plugin.bootstrap.PluginBootstrap; + +@SuppressWarnings("UnstableApiUsage") +public class AFKDetectorBootstrap implements PluginBootstrap { + + @Override + public void bootstrap(BootstrapContext context) {} + +} \ No newline at end of file diff --git a/src/main/resources/changelog.txt b/src/main/resources/changelog.txt deleted file mode 100755 index e69de29..0000000 diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml deleted file mode 100755 index da1bba8..0000000 --- a/src/main/resources/plugin.yml +++ /dev/null @@ -1,66 +0,0 @@ -main: com.alttd.afkdectector.AFKDetector -name: AFKDetector -version: ${projectVersion} -api-version: 1.21 -author: Destro174 -softdepend: - - MyPet - -description: Checks if a player is afk. - -commands: - afklist: - description: Gives a list of all afk players - permission: afkdetector.afklist - permission-message: You do not have permission! - usage: /afklist - afkcheck: - description: Sends and afkcheck message to the target - permission: afkdetector.afkcheck - permission-message: You do not have permission! - usage: /afkcheck - relogcheck: - description: Sends and relogcheck message to the target - permission: afkdetector.relogcheck - permission-message: You do not have permission! - usage: /relogcheck - reloadafkdetector: - description: Reloads the plugin config - permission: afkdetector.reload - permission-message: You do not have permission! - usage: /afkdetectorreload - -permissions: - afkdetector.admin: - default: op - description: Implies all permissions. - children: - afkdetector.bypass: true - afkdetector.afklist: true - afkdetector.afkcheck: true - afkdetector.notify: true - afkdetector.reload: true - afkdetector.bypass: - description: Bypass the AFKplugin. - default: op - children: - afkdetector.kickexempt: true - afkdetector.reload: - description: Allows reloading the afkdetector plugin config. - default: op - afkdetector.kickexempt: - description: Doesn't kick you automatically for AFK. - default: op - afkdetector.afktime: - description: Master permission for custom times. - default: false - afkdetector.afkcheck: - description: Allows the usage of /afkcheck command. - default: false - afkdetector.afklist: - description: Allows the usage of /afklist command. - default: false - afkdetector.notify: - description: Get output when a player goes afk. - default: false -