1
mirror of https://github.com/CarmJos/UserPrefix.git synced 2026-06-05 09:01:39 +08:00

Compare commits

..

18 Commits

Author SHA1 Message Date
carm 2e5250dd36 更新帖子 2021-10-25 08:10:54 +08:00
carm 88730c98f2 更新帖子 2021-10-25 07:58:43 +08:00
carm e003a543f5 支持由控制台为其他玩家打开GUI 2021-10-24 21:22:08 +08:00
Carm 07edaeb401 Merge pull request #5 from Yurinann/master
添加控制台尝试打开称号菜单时的反馈
2021-10-24 21:17:10 +08:00
carm 2357699324 自动提交默认值 2021-10-24 21:14:29 +08:00
“Yurinan” c2fa1a1e95 添加控制台尝试打开称号菜单时的反馈 2021-10-24 14:29:57 +08:00
carm 3b03ec4616 修改readme 2021-10-24 07:22:23 +08:00
carm 1a2644210b 2.1.7 提供自定义配置文件存储位置的功能 2021-10-24 07:12:47 +08:00
carm 83b9ced6f5 2.1.6 补充介绍,优化部署密钥配置。 2021-10-21 21:46:01 +08:00
carm dd96c6d6da 修改源地址 2021-10-19 10:49:35 +08:00
carm ba7d4b90c3 修改源地址 2021-10-19 10:47:55 +08:00
carm ab984acc73 修改源地址 2021-10-19 10:41:18 +08:00
carm 32df1de83d 2.1.5
1. 修复示例config中yaml格式错误的问题
2. 更改构建方式,分开构建与部署的工作流。
2021-10-19 10:40:02 +08:00
carm dfe447393e 2.1.5
1. 修复示例config中yaml格式错误的问题
2. 更改构建方式,分开构建与部署的工作流。
2021-10-19 10:37:41 +08:00
Carm 26ce6d7e66 Merge pull request #3 from OskyEdz/patch-1
YAML formatting
2021-10-19 10:16:04 +08:00
OskyEdz 2e4d1122d9 YAML formatting
Fixed mapping values are not allowed in this context error.
2021-10-19 02:15:38 +02:00
carm b5a2199e1e Update .gitignore 2021-10-19 00:37:07 +08:00
carm 3678a201c7 2.1.4 修改tag机制与测试部署 2021-10-07 23:04:00 +08:00
16 changed files with 258 additions and 78 deletions
+33
View File
@@ -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}}
+7 -11
View File
@@ -1,14 +1,12 @@
# 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: Maven
name: Build
on:
# 支持手动触发构建
workflow_dispatch:
release:
# 创建release的时候触发
types: [ published ]
push:
jobs:
build:
@@ -24,19 +22,17 @@ jobs:
distribution: 'adopt'
cache: maven
server-id: github
# Nexus用户名环境变量
server-username: MAVEN_USERNAME
# Nexus密码环境变量
server-password: MAVEN_TOKEN
- name: "Package & Deploy"
run: mvn -B deploy --file pom.xml
- 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: "Stage"
- name: "Target Stage"
run: mkdir staging && cp target/*.jar staging
- name: "Upload artifact"
uses: actions/upload-artifact@v2
with:
name: artifact
name: Artifact
path: staging
+1
View File
@@ -1,3 +1,4 @@
/.idea/
/target/
./*.iml
*.iml
+7
View File
@@ -114,6 +114,13 @@ version: ${project.version} # DO NOT EDIT IT
debug: false #DEBUG OUT PUT
custom-storage:
# Custom storage location
# default location is "./prefixes"
# Support absolute file path , such as "/etc/minecraft/configurations/prefixes/"
enable: false
path: "prefixes/" # Must be a folder!
GUI:
title: "&f&lMy Prefixes List" # Title of the GUI
items:
+8
View File
@@ -104,6 +104,14 @@ version: 1.0.0-SNAPSHOT # 配置文件版本,一般不会动。
debug: false #debug输出,开发者用的
custom-storage:
# 自定义存储位置
# 默认存储位置为 “插件文件夹”/prefixes
# 可以规定到远程文件夹中去寻找前缀相关的设定
# 支持绝对文件路径,如 "/etc/minecraft/configurations/prefixes/"
enable: false # 是否启用
path: "prefixes/" # 一定要指向一个文件夹!
functions:
OnNamePrefix: true # 是否给头顶上添加前缀,该方法用到了头顶的那个计分板,如有冲突请关掉哦~
autoUsePrefix: true # 自动前缀显示 当玩家没有自己选择一个前缀的时候,会自动使用所拥有的的前缀中权重最高的那一个
+15 -15
View File
@@ -6,20 +6,20 @@
<groupId>cc.carm.plugin</groupId>
<artifactId>userprefix</artifactId>
<version>2.1.3</version>
<version>2.1.7</version>
<name>用户前缀系统</name>
<name>UserPrefix</name>
<description>轻便、高效、实时的用户前缀系统。</description>
<url>https://github.com/CarmJos/UserPrefix</url>
<issueManagement>
<system>GitHub Issues</system>
<url>https://github.com/CarmJos/UserPrefix/issues</url>
<url>${project.url}/issues</url>
</issueManagement>
<ciManagement>
<system>GitHub Actions</system>
<url>https://github.com/CarmJos/UserPrefix/actions/workflows/maven.yml</url>
<url>${project.url}/actions/workflows/maven.yml</url>
</ciManagement>
<developers>
@@ -27,13 +27,18 @@
<id>CarmJos</id>
<name>Carm Jos</name>
<email>carm@carm.cc</email>
<url>https://work.carm.cc</url>
<roles>
<role>Main Developer</role>
</roles>
<url>https://work.carm.cc</url>
</developer>
</developers>
<organization>
<name>YourCraft你的世界</name>
<url>https://www.ycraft.cn/</url>
</organization>
<licenses>
<license>
<name>GNU General Public License v3.0</name>
@@ -51,8 +56,8 @@
<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/public/</url>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
@@ -60,11 +65,6 @@
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
<repository>
<id>lss233-repo</id>
<url>https://lss233.littleservice.cn/repositories/minecraft</url>
</repository>
<repository>
<id>oss-repo</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
@@ -83,7 +83,7 @@
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/CarmJos/UserPrefix</url>
<url>https://maven.pkg.github.com/CarmJos/${project.name}</url>
</repository>
</repositories>
@@ -91,7 +91,7 @@
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/CarmJos/UserPrefix</url>
<url>https://maven.pkg.github.com/CarmJos/${project.name}</url>
</repository>
</distributionManagement>
@@ -100,7 +100,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<artifactId>spigot-api</artifactId>
<version>1.17-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
@@ -1,6 +1,7 @@
package cc.carm.plugin.userprefix.command;
import cc.carm.plugin.userprefix.ui.PrefixSelectGUI;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@@ -14,6 +15,15 @@ public class UserPrefixCommand implements CommandExecutor {
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) {
if (sender instanceof Player) {
PrefixSelectGUI.open((Player) sender);
} else {
if (strings.length != 1) {
sender.sendMessage("输入 /prefix <ID> 为玩家打开前缀GUI。");
} else {
Player player = Bukkit.getPlayer(strings[0]);
if (player != null) {
PrefixSelectGUI.open(player);
}
}
}
return true;
}
@@ -11,6 +11,14 @@ public class PrefixConfig {
public static ConfigValue<Boolean> DEBUG = new ConfigValue<>("debug", Boolean.class, false);
public static class CustomStorage {
public static ConfigValue<Boolean> ENABLE = new ConfigValue<>("custom-storage.enable", Boolean.class, false);
public static ConfigValue<String> PATH = new ConfigValue<>("custom-storage.path", String.class, "prefixes/");
}
public static class Functions {
public static ConfigValue<Boolean> NAME_PREFIX = new ConfigValue<>("functions.OnNamePrefix", Boolean.class, true);
@@ -32,8 +32,13 @@ public class ConfigValue<V> {
}
public V get() {
Object val = getConfiguration().get(this.configSection, this.defaultValue);
return this.clazz.isInstance(val) ? this.clazz.cast(val) : this.defaultValue;
if (getConfiguration().contains(this.configSection)) {
Object val = getConfiguration().get(this.configSection, this.defaultValue);
return this.clazz.isInstance(val) ? this.clazz.cast(val) : this.defaultValue;
} else {
// 如果没有默认值,就把配置写进去,便于配置
return setDefault();
}
}
public void set(V value) {
@@ -45,4 +50,9 @@ public class ConfigValue<V> {
this.source.save();
}
public V setDefault() {
set(this.defaultValue);
return this.defaultValue;
}
}
@@ -1,6 +1,7 @@
package cc.carm.plugin.userprefix.manager;
import cc.carm.plugin.userprefix.Main;
import cc.carm.plugin.userprefix.configuration.PrefixConfig;
import cc.carm.plugin.userprefix.model.ConfiguredPrefix;
import cc.carm.plugin.userprefix.util.ItemStackFactory;
import org.bukkit.Material;
@@ -37,17 +38,19 @@ public class PrefixManager {
public static void loadConfiguredPrefixes() {
File prefixDataFolder = new File(Main.getInstance().getDataFolder() + File.separator + FOLDER_NAME);
File prefixDataFolder = getStorageFolder();
if (!prefixDataFolder.isDirectory() || !prefixDataFolder.exists()) {
prefixDataFolder.mkdir();
}
String[] filesList = prefixDataFolder.list();
if (filesList == null || filesList.length < 1) {
Main.log("配置文件中暂无任何前缀配置,请检查。");
Main.log("配置文件中暂无任何前缀配置,请检查。");
Main.log("There's no configured prefix.");
Main.log("Path: " + prefixDataFolder.getAbsolutePath());
return;
}
List<File> files = Arrays.stream(filesList)
.map(s -> new File(prefixDataFolder, s))
.filter(File::isFile)
@@ -74,7 +77,8 @@ public class PrefixManager {
public static void loadDefaultPrefix() {
PrefixManager.defaultPrefix = null;
ConfigurationSection defaultPrefixSection = ConfigManager.getPluginConfig().getConfig().getConfigurationSection("defaultPrefix");
ConfigurationSection defaultPrefixSection = ConfigManager.getPluginConfig()
.getConfig().getConfigurationSection("defaultPrefix");
if (defaultPrefixSection != null) {
try {
String name = defaultPrefixSection.getString("name", "默认前缀");
@@ -150,5 +154,13 @@ public class PrefixManager {
}
}
private static File getStorageFolder() {
if (PrefixConfig.CustomStorage.ENABLE.get()) {
return new File(PrefixConfig.CustomStorage.PATH.get());
} else {
return new File(Main.getInstance().getDataFolder() + File.separator + FOLDER_NAME);
}
}
}
+9 -1
View File
@@ -1,7 +1,15 @@
version: ${project.version}
version: ${project.version} #配置文件版本,若与插件版本不同请记得检查配置文件内容
debug: false
custom-storage:
# 自定义存储位置
# 默认存储位置为 “插件文件夹”/prefixes
# 可以规定到远程文件夹中去寻找前缀相关的设定
# 支持绝对文件路径,如 "/etc/minecraft/configurations/prefixes/"
enable: false # 是否启用
path: "prefixes/" # 一定要指向一个文件夹!
functions:
OnNamePrefix: true # 是否给头顶上添加前缀,该方法用到了头顶的那个计分板,如有冲突请关掉哦~
autoUsePrefix: true # 自动前缀显示 当玩家没有自己选择一个前缀的时候,会自动使用所拥有的的前缀中权重最高的那一个
+7
View File
@@ -2,6 +2,13 @@ version: ${project.version} # DO NOT EDIT IT
debug: false #DEBUG OUT PUT
custom-storage:
# Custom storage location
# default location is "./prefixes"
# Support absolute file path , such as "/etc/minecraft/configurations/prefixes/"
enable: false
path: "prefixes/" # Must be a folder!
GUI:
title: "&f&lMy Prefixes List" # Title of the GUI
items:
+25 -28
View File
@@ -29,43 +29,40 @@ itemHasPermission:
==: org.bukkit.inventory.ItemStack
type: DIAMOND
meta:
==: org.bukkit.inventory.ItemStack
type: DIAMOND
meta:
==: ItemMeta
meta-type: UNSPECIFIC
display-name: "§b§lVIP Prefix"
lore:
- ""
- "§a➥ Click to use"
==: ItemMeta
meta-type: UNSPECIFIC
display-name: "§b§lVIP Prefix"
lore:
- ""
- "§a➥ Click to use"
# itemUsing [Unnecessary]
# This Item will be displayed when the prefix is selected.
# If there is no such configuration, it will automatically display "itemHasPermission".
itemUsing:
==: org.bukkit.inventory.ItemStack
type: DIAMOND
meta:
==: ItemMeta
meta-type: UNSPECIFIC
display-name: "§b§lVIP Prefix"
enchants:
PROTECTION_ENVIRONMENTAL: 1 #Add an enchantment so it looks like its selected
lore:
- ""
- "§a✔ Selected"
type: DIAMOND
meta:
==: ItemMeta
meta-type: UNSPECIFIC
display-name: "§b§lVIP Prefix"
enchants:
PROTECTION_ENVIRONMENTAL: 1 #Add an enchantment so it looks like its selected
lore:
- ""
- "§a✔ Selected"
# itemNoPermission [Unnecessary]
# If player doesn't have the permission,this item will be displayed.
# If this item is not configured, it will not be displayed in the GUI when the player does not have permission to use it.
itemNoPermission:
==: org.bukkit.inventory.ItemStack
type: INK_SACK
damage: 8
meta:
==: ItemMeta
meta-type: UNSPECIFIC
display-name: "§b§lVIP §c(Buy it!)"
lore:
- ""
- "§e✯ Buy the VIP to use it!"
type: INK_SACK
damage: 8
meta:
==: ItemMeta
meta-type: UNSPECIFIC
display-name: "§b§lVIP §c(Buy it!)"
lore:
- ""
- "§e✯ Buy the VIP to use it!"
+5 -3
View File
@@ -1,11 +1,13 @@
main: cc.carm.plugin.userprefix.Main
name: UserPrefix
name: ${project.name}
version: ${project.version}
authors:
- Carm
- YourCraft
- ${project.organization.name}
- SakuraGame
website: "https://github.com/CarmJos/UserPrefix"
website: ${project.url}
description: ${project.description}
depend:
- LuckPerms
softdepend:
+87 -13
View File
@@ -67,13 +67,89 @@
[hr]
[size=4][b]基础配置文件 [/b][/size][color=#24292f][font=Tahoma][size=4](config.yml)[/size][/font][/color]
[spoiler]
[code] version: 1.0.0-SNAPSHOT # 配置文件版本,一般不会动。
[code]
version: ${project.version} #配置文件版本,若与插件版本不同请记得检查配置文件内容
debug: false #debug输出,开发者用的
debug: false
custom-storage:
# 自定义存储位置
# 默认存储位置为 “插件文件夹”/prefixes
# 可以规定到远程文件夹中去寻找前缀相关的设定
# 支持绝对文件路径,如 "/etc/minecraft/configurations/prefixes/"
enable: false # 是否启用
path: "prefixes/" # 一定要指向一个文件夹!
functions:
OnNamePrefix: true # 是否给头顶上添加前缀,该方法用到了头顶的那个计分板,如有冲突请关掉哦~
autoUsePrefix: true # 自动前缀显示 当玩家没有自己选择一个前缀的时候,会自动使用所拥有的的前缀中权重最高的那一个[/code][/spoiler]
autoUsePrefix: true # 自动前缀显示 当玩家没有自己选择一个前缀的时候,会自动使用所拥有的的前缀中权重最高的那一个
chat:
# 聊天功能
# - 我不推荐使用本插件的聊天功能,而是建议使用其他的聊天插件。
# - 本插件仅仅提供了**最基本**的格式变量支持,不包含其他任何功能。
# - 注意聊天格式需要遵守Bukkit原格式,即不得缺失 “%1$s” 和 “%2$s” 。
# - 本插件的聊天功能不影响其他插件对聊天事件的操作。
enable: false # 是否启用
format: "<%UserPrefix_prefix%%1$s> %2$s" #聊天的格式,注意 “%1$s” 和 “%2$s” 不可缺少,分别代表 玩家名 与 消息内容 。
GUI:
title: "&f&l我的前缀 &8| 列表"
items:
# 【必须】 GUI中可能存在的其他物品
next-page: # 下一页物品,如果没有下一页则不显示
==: org.bukkit.inventory.ItemStack
type: ARROW
meta:
==: ItemMeta
meta-type: UNSPECIFIC
display-name: "§f下一页"
lore:
- ""
- "§f右键可前往最后一页哦~"
previous-page: # 上一页物品,如果没有上一页则不显示
==: org.bukkit.inventory.ItemStack
type: ARROW
meta:
==: ItemMeta
meta-type: UNSPECIFIC
display-name: "§f上一页"
lore:
- ""
- "§f右键可前往第一页哦~"
Sounds: #相关的声音,注释掉则不播放声音 格式为 【声音名:音量:音调】 或 【声音名:音量】 或 【声音名】
openGUI: "BLOCK_NOTE_BLOCK_PLING:1:1"
guiClick: "UI_BUTTON_CLICK"
prefixChange: "ENTITY_VILLAGER_YES"
prefixExpired: "ENTITY_VILLAGER_NO"
# 默认前缀的配置
# 默认前缀的权重为0哦
defaultPrefix:
name: "默认前缀"
content: "&b"
itemNotUsing:
==: org.bukkit.inventory.ItemStack
type: NAME_TAG
meta:
==: ItemMeta
meta-type: UNSPECIFIC
display-name: "§f默认玩家前缀 §f(点击切换)"
lore:
- ""
- "§a➥ 点击切换到该前缀"
itemUsing:
==: org.bukkit.inventory.ItemStack
type: NAME_TAG
meta:
==: ItemMeta
meta-type: UNSPECIFIC
display-name: "§f默认玩家前缀"
lore:
- ""
- "§a✔ 您正在使用该前缀"
[/code]
[/spoiler]
[b][size=4][backcolor=transparent]消息配置文件[/backcolor][/size] [/b][size=4](messages.yml)[/size]
[spoiler][code]selected:
@@ -96,7 +172,7 @@ list-value:
- "&8- &7显示名 &r%(name) &7权限 &r%(permission)"
- "&8- &7内容示例&r %(content) %(sender_name)"[/code][/spoiler]
[size=4][backcolor=transparent][b]前缀配置文件[/b][/backcolor] (prefixes/*.yml)[/size]
[size=4][backcolor=transparent][b]前缀配置文件[/b][/backcolor] (prefixes/*.yml) [自2.1.7可自定义目录][/size]
[align=left][font=-apple-system, BlinkMacSystemFont, &quot;][size=3][color=#000000]所有前缀均为单独的配置文件,存放于 [u]插件配置目录/prefixes[/u] 下,便于管理。[/color][/size][/font][/align][align=left][font=-apple-system, BlinkMacSystemFont, &quot;][size=3][color=#000000]文件名理论上可以随便取,推荐使用英文,部分符号可能会影响正常读取,请避免使用。[/color][/size][/font][/align][align=left][spoiler][/align][code]# 唯一标识 [必须]
# 将用于记录玩家所选的前缀,以及用于数据的缓存。
# 必须 必须 必须 保持唯一!
@@ -177,11 +253,14 @@ itemNoPermission:
[size=5][b]下载地址[/b][/size]
[hr]
[size=3][b]最新版本 2.1.0 [/b][/size][attach]1909962[/attach][quote][b][size=3]更新内容[/size][/b]
[size=3][b]最新版本 [/b][/size][size=3][b]2.1.7 [/b][/size][attach]1919669[/attach][quote][b][size=3]更新内容[/size][/b]
1. 提供自定义配置文件存储位置的功能,便于多子服共享配置。(custome-storage)
2. 添加控制台打开玩家菜单时的反馈(来自 @Yuri南城 )。
3. 支持由控制台为其他玩家打开GUI。
4. 若出现新配置文件条目,将自动写入默认值,便于配置。[/quote][spoiler][size=3][b]2.1.2 [/b][/size][attach]1912028[/attach][quote][b][size=3]更新内容[/size][/b]
1. 修复不开启插件自带的头顶前缀功能时出现的报错。[/quote]
[size=3][b]2.1.0 [/b][/size][attach]1909962[/attach][quote][b][size=3]更新内容[/size][/b]
1. 添加聊天相关设定,支持聊天前缀。(但不推荐使用哦~)[/quote]
[spoiler]
[size=3][b] 2.0.0 [/b][/size][attach]1905700[/attach]
[quote][b][size=3]更新内容[/size][/b]
1. 修复低版本可能无法读取物品的bug。
@@ -233,8 +312,3 @@ itemNoPermission:
+8 -1
View File
@@ -90,10 +90,17 @@ After installed the [URL='https://github.com/PlaceholderAPI/PlaceholderAPI']Plac
Notice: The default configuration is based on Chinese. You can find the English Version [URL='https://github.com/CarmJos/UserPrefix/blob/master/src/main/resources/en_US/config.yml']here[/URL].
[code=YAML]
version: ${project.version} # DO NOT EDIT IT
version: ${project.version}
debug: false #DEBUG OUT PUT
custom-storage:
# Custom storage location
# default location is "./prefixes"
# Support absolute file path , such as "/etc/minecraft/configurations/prefixes/"
enable: false
path: "prefixes/" # Must be a folder!
GUI:
title: "&f&lMy Prefixes List" # Title of the GUI
items: