mirror of
https://github.com/CarmJos/PlayerPrefix.git
synced 2026-06-04 09:59:31 +08:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ff40d921e7 | |||
| ff0255f72a | |||
| 8d3e4f2853 |
@@ -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}}
|
||||
@@ -27,7 +27,7 @@ jobs:
|
||||
- name: "Package"
|
||||
run: mvn -B package --file pom.xml
|
||||
env:
|
||||
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
|
||||
MAVEN_USERNAME: ${{ github.repository_owner }}
|
||||
MAVEN_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
||||
- name: "Target Stage"
|
||||
run: mkdir staging && cp target/*.jar staging
|
||||
|
||||
@@ -52,6 +52,13 @@
|
||||
- 设置目标玩家的前缀列表为源玩家的前缀列表
|
||||
```
|
||||
|
||||
## 变量
|
||||
|
||||
```text
|
||||
# %PlayerPrefix%
|
||||
- 获取玩家当前的前缀内容。
|
||||
```
|
||||
|
||||
## [玩家数据文件](https://github.com/CarmJos/PlayerPrefix/blob/master/example/userdata.yml) 示例
|
||||
|
||||
```yaml
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.harmoland</groupId>
|
||||
<artifactId>PlayerPrefix</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<groupId>cc.carm.plugin</groupId>
|
||||
<artifactId>playerprefix</artifactId>
|
||||
<version>1.1.1</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
@@ -15,18 +15,18 @@
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<name>玩家前缀系统</name>
|
||||
<name>PlayerPrefix</name>
|
||||
<description>指令操作的轻量玩家前缀管理插件。</description>
|
||||
<url>https://github.com/CarmJos/PlayerPrefix</url>
|
||||
|
||||
<issueManagement>
|
||||
<system>GitHub Issues</system>
|
||||
<url>https://github.com/CarmJos/PlayerPrefix/issues</url>
|
||||
<url>${project.url}/issues</url>
|
||||
</issueManagement>
|
||||
|
||||
<ciManagement>
|
||||
<system>GitHub Actions</system>
|
||||
<url>https://github.com/CarmJos/PlayerPrefix/actions/workflows/maven.yml</url>
|
||||
<url>${project.url}/actions/workflows/maven.yml</url>
|
||||
</ciManagement>
|
||||
|
||||
<developers>
|
||||
@@ -43,8 +43,8 @@
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>GNU General Public License v3.0</name>
|
||||
<url>https://opensource.org/licenses/GPL-3.0</url>
|
||||
<name>The MIT License</name>
|
||||
<url>https://opensource.org/licenses/mit-license.php</url>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
@@ -78,10 +78,18 @@
|
||||
<repository>
|
||||
<id>github</id>
|
||||
<name>GitHub Packages</name>
|
||||
<url>https://maven.pkg.github.com/CarmJos/PlayerPrefix</url>
|
||||
<url>https://maven.pkg.github.com/CarmJos/${project.artifactId}</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>github</id>
|
||||
<name>GitHub Packages</name>
|
||||
<url>https://maven.pkg.github.com/CarmJos/${project.artifactId}</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
@@ -95,6 +103,7 @@
|
||||
<groupId>com.github.azbh111</groupId>
|
||||
<artifactId>craftbukkit-1.12.2</artifactId>
|
||||
<version>R</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package cc.carm.plugin.playerprefix;
|
||||
|
||||
import cc.carm.plugin.playerprefix.commands.PlayerPrefixCommand;
|
||||
import cc.carm.plugin.playerprefix.hooker.PlayerPrefixExpansion;
|
||||
import cc.carm.plugin.playerprefix.listeners.PrefixListener;
|
||||
import cc.carm.plugin.playerprefix.managers.UserPrefixManager;
|
||||
import cc.carm.plugin.playerprefix.utils.MessageParser;
|
||||
@@ -33,6 +34,14 @@ public class Main extends JavaPlugin {
|
||||
log("注册监听器...");
|
||||
Bukkit.getPluginManager().registerEvents(new PrefixListener(), this);
|
||||
|
||||
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||
log("注册变量...");
|
||||
new PlayerPrefixExpansion(getInstance()).register();
|
||||
} else {
|
||||
log("未安装 PlaceholderAPI 不进行变量注册...");
|
||||
log("若您想使用变量进行前缀的显示,请安装PlaceholderAPI!");
|
||||
}
|
||||
|
||||
log("加载完成 ,共耗时 " + (System.currentTimeMillis() - startTime) + " ms 。");
|
||||
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +1,19 @@
|
||||
name: PlayerPrefix
|
||||
main: cc.carm.plugin.playerprefix.Main
|
||||
version: ${project}
|
||||
|
||||
name: ${project.name}
|
||||
version: ${project.version}
|
||||
description: ${project.description}
|
||||
author: CarmJos
|
||||
depend: [ ProtocolLib ]
|
||||
website: "https://github.com/CarmJos/PlayerPrefix"
|
||||
website: ${project.url}
|
||||
|
||||
depend:
|
||||
- ProtocolLib
|
||||
softdepend:
|
||||
- PlaceholderAPI
|
||||
|
||||
commands:
|
||||
PlayerPrefix:
|
||||
aliases:
|
||||
- prefix
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user