1
mirror of https://github.com/CarmJos/UserPrefix.git synced 2024-09-19 20:15:47 +00:00

2.1.0版本更新 支持聊天前缀

This commit is contained in:
carm 2021-09-27 01:32:17 +08:00
parent 9a620d7324
commit e14901ac86
10 changed files with 91 additions and 67 deletions

View File

@ -144,8 +144,15 @@ functions:
OnNamePrefix: true
# Automatic prefix select.
# When the player does not choose a prefix by himself,
# the prefix with the highest weight will be used automatically
# the prefix with the highest weight will be used~~~~ automatically
autoUsePrefix: true
chat:
# Chat Function
# - I recommend using other chat plugins instead of using this plugin,
# - this plugin only provides very basic chat format placeholders.
# - Notice that: format must has “%1$s” and “%2$s” for PlayerName and Message (Bukkit Chat Event)
enable: false
format: "<%UserPrefix_prefix%%1$s> %2$s"
Sounds:
# Format is [SOUND_NAME:Volume:Pitch] or [SOUND_NAME:Volume] or [SOUND_NAME]

View File

@ -105,6 +105,14 @@ debug: false #debug输出开发者用的
functions:
OnNamePrefix: true # 是否给头顶上添加前缀,该方法用到了头顶的那个计分板,如有冲突请关掉哦~
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| 列表"

View File

@ -6,7 +6,7 @@
<groupId>cc.carm.plugin</groupId>
<artifactId>UserPrefix</artifactId>
<version>2.0.0</version>
<version>2.1.0</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>

View File

@ -4,6 +4,7 @@ import cc.carm.plugin.userprefix.command.UserPrefixAdminCommand;
import cc.carm.plugin.userprefix.command.UserPrefixCommand;
import cc.carm.plugin.userprefix.configuration.PrefixConfig;
import cc.carm.plugin.userprefix.hooker.UserPrefixExpansion;
import cc.carm.plugin.userprefix.listener.ChatListener;
import cc.carm.plugin.userprefix.listener.UserListener;
import cc.carm.plugin.userprefix.listener.processor.UserNodeUpdateProcessor;
import cc.carm.plugin.userprefix.manager.ConfigManager;
@ -38,6 +39,7 @@ public class Main extends JavaPlugin {
log("注册监听器...");
regListener(new UserListener());
regListener(new ChatListener());
ServiceManager.getService().getEventBus().subscribe(this, UserDataRecalculateEvent.class, UserNodeUpdateProcessor::process);
if (MessageUtil.hasPlaceholderAPI()) {

View File

@ -16,6 +16,13 @@ public class PrefixConfig {
public static ConfigValue<Boolean> NAME_PREFIX = new ConfigValue<>("functions.OnNamePrefix", Boolean.class, true);
public static ConfigValue<Boolean> AUTO_USE = new ConfigValue<>("functions.autoUsePrefix", Boolean.class, true);
public static class Chat {
public static ConfigValue<Boolean> ENABLE = new ConfigValue<>("functions.chat.enable", Boolean.class, false);
public static ConfigValue<String> FORMAT = new ConfigValue<>("functions.chat.format", String.class, "<%1$s> %2$s");
}
}
public static class GUI {

View File

@ -0,0 +1,32 @@
package cc.carm.plugin.userprefix.listener;
import cc.carm.plugin.userprefix.Main;
import cc.carm.plugin.userprefix.configuration.PrefixConfig;
import cc.carm.plugin.userprefix.util.MessageUtil;
import me.clip.placeholderapi.PlaceholderAPI;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
public class ChatListener implements Listener {
@EventHandler
public void onChat(AsyncPlayerChatEvent event) {
if (!PrefixConfig.Functions.Chat.ENABLE.get()) return;
String format = PrefixConfig.Functions.Chat.FORMAT.get();
if (format == null || format.length() < 1) return;
if (!MessageUtil.hasPlaceholderAPI()) return;
try {
event.setFormat(PlaceholderAPI.setPlaceholders(event.getPlayer(), format));
} catch (Exception exception) {
Main.log("Please check the chat configuration.");
Main.log("请检查配置文件中聊天相关是否配置正确。");
exception.printStackTrace();
}
}
}

View File

@ -5,6 +5,14 @@ debug: false
functions:
OnNamePrefix: true # 是否给头顶上添加前缀,该方法用到了头顶的那个计分板,如有冲突请关掉哦~
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| 列表"

View File

@ -35,6 +35,13 @@ functions:
# When the player does not choose a prefix by himself,
# the prefix with the highest weight will be used automatically
autoUsePrefix: true
chat:
# Chat Function
# - I recommend using other chat plugins instead of using this plugin,
# - this plugin only provides very basic chat format placeholders.
# - Notice that: format must has “%1$s” and “%2$s” for PlayerName and Message (Bukkit Chat Event)
enable: false
format: "<%UserPrefix_prefix%%1$s> %2$s"

View File

@ -73,66 +73,7 @@ debug: false #debug输出开发者用的
functions:
OnNamePrefix: true # 是否给头顶上添加前缀,该方法用到了头顶的那个计分板,如有冲突请关掉哦~
autoUsePrefix: true # 自动前缀显示 当玩家没有自己选择一个前缀的时候,会自动使用所拥有的的前缀中权重最高的那一个
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<img src="file:///C:\Users\Karmu\AppData\Roaming\Tencent\QQ\Temp\FZ~{7VEC09VVKFU7J7X3CT8.png"> 您正在使用该前缀"
[/code][/spoiler]
autoUsePrefix: true # 自动前缀显示 当玩家没有自己选择一个前缀的时候,会自动使用所拥有的的前缀中权重最高的那一个[/code][/spoiler]
[b][size=4][backcolor=transparent]消息配置文件[/backcolor][/size] [/b][size=4](messages.yml)[/size]
[spoiler][code]selected:
@ -236,13 +177,17 @@ itemNoPermission:
[size=5][b]下载地址[/b][/size]
[hr]
[size=3][b]最新版本 [/b][/size][size=3][b] 2.0.0 [/b][/size][attach]1905700[/attach]
[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。
2. 分离配置文件消息配置文件改为messages.yml前缀配置文件改 prefixes/*.yml便于配置和管理。
3. 允许配置GUI中上一页和下一页的物品。
4. 补全帮助文档,在插件首次加载将提供一份英文版的配置,以便使用。[/quote]
[spoiler]
[size=3][b] 1.2.5 [/b][/size][attach]1905430[/attach][quote][size=3][b]更新内容[/b]
1. 支持指令的多语言配置。[/size][/quote]
[b][size=3]
@ -291,3 +236,5 @@ itemNoPermission:

View File

@ -59,9 +59,8 @@ Please turn of the [U]functions.OnNamePrefix[/U] in the configuration if there i
[SIZE=4][B]3. Item icon configuration problem[/B][/SIZE]
Items are read through the ItemStack serialization method provided by Bukkit. For related configuration methods, please refer to [URL='https://www.spigotmc.org/wiki/itemstack-serialization/']ItemStack Serialization[/URL].
[SIZE=5][B]Commands[/B][/SIZE]
This plugin's Commands are based on Chinese! May support multi-language in the future.
[SIZE=5][B]Commands[/B]
[/SIZE]
[code]
/UserPrefix or /prefix #Open prefix GUI
/UserPrefixAdmin # View Admin Command Help
@ -128,6 +127,13 @@ functions:
# When the player does not choose a prefix by himself,
# the prefix with the highest weight will be used automatically
autoUsePrefix: true
chat:
# Chat Function
# - I recommend using other chat plugins instead of using this plugin,
# - this plugin only provides very basic chat format placeholders.
# - Notice that: format must has “%1$s” and “%2$s” for PlayerName and Message (Bukkit Chat Event)
enable: false
format: "<%UserPrefix_prefix%%1$s> %2$s"
Sounds:
# Format is [SOUND_NAME:Volume:Pitch] or [SOUND_NAME:Volume] or [SOUND_NAME]