From e9036bdfad4200f41b086a4e3dc629c0c1c3c9e3 Mon Sep 17 00:00:00 2001 From: William Date: Fri, 5 Apr 2024 15:09:00 +0100 Subject: [PATCH] feat: run as Paper plugin on Paper --- bukkit/build.gradle | 10 ----- paper/build.gradle | 41 +++++++++++++++++++ .../william278/huskchat/PaperHuskChat.java | 24 +++++++++++ paper/src/main/resources/paper-plugin.yml | 22 ++++++++++ plugin/build.gradle | 1 + settings.gradle | 1 + 6 files changed, 89 insertions(+), 10 deletions(-) create mode 100644 paper/build.gradle create mode 100644 paper/src/main/java/net/william278/huskchat/PaperHuskChat.java create mode 100644 paper/src/main/resources/paper-plugin.yml diff --git a/bukkit/build.gradle b/bukkit/build.gradle index e5fb520..58f6d17 100644 --- a/bukkit/build.gradle +++ b/bukkit/build.gradle @@ -1,7 +1,3 @@ -plugins { - id 'xyz.jpenilla.run-paper' version '2.2.3' -} - dependencies { implementation project(path: ':common') @@ -40,10 +36,4 @@ shadowJar { } minimize() -} - -tasks { - runServer { - minecraftVersion('1.20.4') - } } \ No newline at end of file diff --git a/paper/build.gradle b/paper/build.gradle new file mode 100644 index 0000000..1d64ed7 --- /dev/null +++ b/paper/build.gradle @@ -0,0 +1,41 @@ +plugins { + id 'xyz.jpenilla.run-paper' version '2.2.3' +} + +dependencies { + implementation project(':bukkit') + compileOnly project(':common') + + compileOnly 'io.papermc.paper:paper-api:1.19.4-R0.1-SNAPSHOT' + compileOnly 'org.bstats:bstats-bukkit:3.0.2' + compileOnly 'org.jetbrains:annotations:24.1.0' +} + +shadowJar { + relocate 'net.william278.profanitycheckerapi', 'net.william278.huskchat.libraries.profanitycheckerapi' + relocate 'net.william278.desertwell', 'net.william278.huskchat.libraries.desertwell' + relocate 'de.themoep', 'net.william278.huskchat.libraries' + relocate 'dev.vankka', 'net.william278.huskchat.libraries' + relocate 'de.exlll', 'net.william278.huskchat.libraries' + relocate 'org.snakeyaml.engine', 'net.william278.huskchat.libraries.snakeyaml.engine' + relocate 'org.json', 'net.william278.huskchat.libraries.json' + + relocate 'org.apache', 'net.william278.huskchat.libraries' + relocate 'org.jetbrains', 'net.william278.huskchat.libraries' + relocate 'org.intellij', 'net.william278.huskchat.libraries' + relocate 'org.bstats', 'net.william278.huskchat.libraries.bstats' + relocate 'space.arim', 'net.william278.huskchat.libraries.morepaperlib' + + minimize() +} + +tasks { + runServer { + minecraftVersion('1.20.4') + + downloadPlugins { + url("https://download.luckperms.net/1526/bukkit/loader/LuckPerms-Bukkit-5.4.113.jar") + url("https://ci.lucko.me/job/spark/399/artifact/spark-bukkit/build/libs/spark-1.10.58-bukkit.jar") + } + } +} \ No newline at end of file diff --git a/paper/src/main/java/net/william278/huskchat/PaperHuskChat.java b/paper/src/main/java/net/william278/huskchat/PaperHuskChat.java new file mode 100644 index 0000000..87b477d --- /dev/null +++ b/paper/src/main/java/net/william278/huskchat/PaperHuskChat.java @@ -0,0 +1,24 @@ +package net.william278.huskchat; + +import net.kyori.adventure.audience.Audience; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +import java.util.UUID; + +public class PaperHuskChat extends BukkitHuskChat { + + @NotNull + @Override + public Audience getAudience(@NotNull UUID user) { + final Player player = getServer().getPlayer(user); + return player == null || !player.isOnline() ? Audience.empty() : player; + } + + @Override + @NotNull + public Audience getConsole() { + return getServer().getConsoleSender(); + } + +} diff --git a/paper/src/main/resources/paper-plugin.yml b/paper/src/main/resources/paper-plugin.yml new file mode 100644 index 0000000..298f65b --- /dev/null +++ b/paper/src/main/resources/paper-plugin.yml @@ -0,0 +1,22 @@ +name: 'HuskChat' +description: '${description}' +author: 'William278' +website: 'https://william278.net/' +main: 'net.william278.huskchat.PaperHuskChat' +version: '${version}' +api-version: '1.19' +folia-supported: true +dependencies: + server: + LuckPerms: + load: BEFORE + join-classpath: true + required: false + PlaceholderAPI: + load: BEFORE + join-classpath: true + required: false + Spicord: + load: BEFORE + join-classpath: true + required: false \ No newline at end of file diff --git a/plugin/build.gradle b/plugin/build.gradle index 92c3ff8..9740a72 100644 --- a/plugin/build.gradle +++ b/plugin/build.gradle @@ -2,4 +2,5 @@ dependencies { implementation project(path: ':bungee', configuration: 'shadow') implementation project(path: ':velocity', configuration: 'shadow') implementation project(path: ':bukkit', configuration: 'shadow') + implementation project(path: ':paper', configuration: 'shadow') } \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index d86f958..ffc0ad1 100644 --- a/settings.gradle +++ b/settings.gradle @@ -11,5 +11,6 @@ include( 'bungee', 'velocity', 'bukkit', + 'paper', 'plugin' ) \ No newline at end of file