-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. 添加变量 %PlayerPrefix% 2. 添加部署配置
- Loading branch information
carm
committed
Oct 21, 2021
1 parent
126772f
commit 8d3e4f2
Showing
5 changed files
with
118 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven | ||
|
||
name: Deploy | ||
|
||
on: | ||
# 支持手动触发构建 | ||
workflow_dispatch: | ||
release: | ||
# 创建release的时候触发 | ||
types: [ published ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: "Set up JDK" | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: '11' | ||
distribution: 'adopt' | ||
cache: maven | ||
server-id: github | ||
server-username: MAVEN_USERNAME | ||
server-password: MAVEN_TOKEN | ||
- name: "Deploy" | ||
run: mvn -B deploy --file pom.xml | ||
env: | ||
MAVEN_USERNAME: ${{ github.repository_owner }} | ||
MAVEN_TOKEN: ${{secrets.GITHUB_TOKEN}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/main/java/cc/carm/plugin/playerprefix/hooker/PlayerPrefixExpansion.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package cc.carm.plugin.playerprefix.hooker; | ||
|
||
import cc.carm.plugin.playerprefix.managers.UserPrefixManager; | ||
import cc.carm.plugin.playerprefix.models.UserPrefixCache; | ||
import me.clip.placeholderapi.expansion.PlaceholderExpansion; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class PlayerPrefixExpansion extends PlaceholderExpansion { | ||
|
||
JavaPlugin plugin; | ||
|
||
public PlayerPrefixExpansion(JavaPlugin plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
@Override | ||
public @NotNull List<String> getPlaceholders() { | ||
List<String> placeholders = new ArrayList<>(); | ||
placeholders.add("%PlayerPrefix%"); | ||
return placeholders; | ||
} | ||
|
||
@Override | ||
public boolean canRegister() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public @NotNull String getAuthor() { | ||
return plugin.getDescription().getAuthors().toString(); | ||
} | ||
|
||
@Override | ||
public @NotNull String getIdentifier() { | ||
return plugin.getDescription().getName(); | ||
} | ||
|
||
@Override | ||
public @NotNull String getVersion() { | ||
return plugin.getDescription().getVersion(); | ||
} | ||
|
||
@Override | ||
public String onPlaceholderRequest(Player player, @NotNull String identifier) { | ||
if (player == null) return "加载中..."; | ||
|
||
UserPrefixCache cache = UserPrefixManager.getData(player.getUniqueId()); | ||
|
||
return cache.getUsingPrefix(); | ||
} | ||
|
||
} |