commit 9ebb79c09b49f0aef2d87ba68827f5c5e1950d24 Author: CNLuminous Date: Fri Jul 25 04:00:23 2025 +0800 Submit diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml new file mode 100644 index 0000000..ac1517e --- /dev/null +++ b/.gitea/workflows/build.yaml @@ -0,0 +1,25 @@ +name: Java CI with Maven + +on: + push: + branches: + - master + +jobs: + build_and_test: + name: Build and Test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 8 + uses: actions/setup-java@v4 + with: + java-version: '8' + distribution: 'temurin' + cache: maven + - name: Set up Maven + uses: stCarolas/setup-maven@v5 + with: + maven-version: 3.9.5 + - name: Build with Maven + run: mvn test \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4788b4b --- /dev/null +++ b/.gitignore @@ -0,0 +1,113 @@ +# User-specific stuff +.idea/ + +*.iml +*.ipr +*.iws + +# IntelliJ +out/ + +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +target/ + +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next + +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties +.mvn/wrapper/maven-wrapper.jar +.flattened-pom.xml + +# Common working directory +run/ diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..6b12ea1 --- /dev/null +++ b/pom.xml @@ -0,0 +1,81 @@ + + + 4.0.0 + + com.blockfantasy + luckpermstimeformat + 1.0 + jar + + LuckPermsTimeFormat + + + 1.8 + UTF-8 + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + ${java.version} + ${java.version} + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.4 + + + package + + shade + + + + + + + + src/main/resources + true + + + + + + + spigotmc-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + sonatype + https://oss.sonatype.org/content/groups/public/ + + + placeholderapi + https://repo.extendedclip.com/content/repositories/placeholderapi/ + + + + + + org.spigotmc + spigot-api + 1.12-R0.1-SNAPSHOT + provided + + + me.clip + placeholderapi + 2.11.6 + provided + + + diff --git a/src/main/java/com/blockfantasy/luckpermstimeformat/LuckPermsTimeFormat.java b/src/main/java/com/blockfantasy/luckpermstimeformat/LuckPermsTimeFormat.java new file mode 100644 index 0000000..2d32a43 --- /dev/null +++ b/src/main/java/com/blockfantasy/luckpermstimeformat/LuckPermsTimeFormat.java @@ -0,0 +1,23 @@ +package com.blockfantasy.luckpermstimeformat; + +import org.bukkit.Bukkit; +import org.bukkit.plugin.java.JavaPlugin; + +public final class LuckPermsTimeFormat extends JavaPlugin { + + @Override + public void onEnable() { + if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) { + getLogger().info("[+]PPlaceholderAPI Hook成功"); + (new Papi()).register(); + } else { + getLogger().warning("没有找到PlaceholderAPI!这是必须的"); + Bukkit.getPluginManager().disablePlugin(this); + } + + } + + @Override + public void onDisable() { + } +} diff --git a/src/main/java/com/blockfantasy/luckpermstimeformat/Papi.java b/src/main/java/com/blockfantasy/luckpermstimeformat/Papi.java new file mode 100644 index 0000000..0373232 --- /dev/null +++ b/src/main/java/com/blockfantasy/luckpermstimeformat/Papi.java @@ -0,0 +1,52 @@ +package com.blockfantasy.luckpermstimeformat; + +import me.clip.placeholderapi.PlaceholderAPI; +import me.clip.placeholderapi.expansion.PlaceholderExpansion; +import org.bukkit.OfflinePlayer; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class Papi extends PlaceholderExpansion { + @Override + public @NotNull String getIdentifier() { + return "lptimeformat"; + } + + @Override + public @NotNull String getAuthor() { + return "CNLuminous"; + } + + @Override + public @NotNull String getVersion() { + return "1.0"; + } + + @Override + public @Nullable String onRequest(OfflinePlayer player, @NotNull String params) { + String str = getTime(player.getPlayer(), params); + + if (str.isEmpty()){ + if (PlaceholderAPI.setPlaceholders(player, "%luckperms_in_group_"+params+"%").equals("yes")){ + return "长期有效"; + } + return "未查询到有效日期"; + } + return str; + } + + public static String getTime(Player player, String placeholder){ + String str = PlaceholderAPI.setPlaceholders(player, "%luckperms_group_expiry_time_"+placeholder+"%"); + str = str.replaceAll(" ", ""); + str = str.replace("y", "年"); + str = str.replace("mo", "月"); + str = str.replace("w", "周"); + str = str.replace("d", "天"); + str = str.replace("h", "时"); + str = str.replace("m", "分"); + str = str.replace("s", "秒"); + return str; + + } +} diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml new file mode 100644 index 0000000..ad5db00 --- /dev/null +++ b/src/main/resources/plugin.yml @@ -0,0 +1,5 @@ +name: LuckPermsTimeFormat +version: '${project.version}' +main: com.blockfantasy.luckpermstimeformat.LuckPermsTimeFormat +softdepend: [ PlaceholderAPI ] +authors: [ CNLuminous ] \ No newline at end of file