mirror of
https://e.coding.net/circlecloud/MiaoChat.git
synced 2024-11-22 14:38:47 +00:00
feat: add item tip support
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
parent
45ec56bebe
commit
80f2a37fc1
15
pom.xml
15
pom.xml
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>MiaoChat</artifactId>
|
||||
<version>1.9.5</version>
|
||||
<version>2.0.0</version>
|
||||
|
||||
<parent>
|
||||
<groupId>pw.yumc</groupId>
|
||||
@ -13,16 +13,17 @@
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<update.description>§a正式版本 §bv1.9.5 §b兼容 1.15 版本</update.description>
|
||||
<update.description>§a正式版本 §bv2.0.0 §b全新版本(号) 配合龙核食用</update.description>
|
||||
<update.changes>
|
||||
§621-06-20 §a增强: 兼容 1.18 版本 兼容新版PAPI;
|
||||
§621-06-20 §a增强: 兼容 1.17 版本;
|
||||
§621-12-18 §a增强: 全新版本(号) 新增 itemTip 配合龙核 实现神奇功能;
|
||||
§621-12-06 §a增强: 兼容 1.18 版本 兼容新版PAPI;
|
||||
§621-06-20 §a增强: 兼容 1.17 版本
|
||||
</update.changes>
|
||||
<update.changelog>
|
||||
§620-10-10 §c修复: 1.16.3聊天包格式调整的问题;
|
||||
§620-04-10 §c修复: L10N 本地化组件报错的问题;
|
||||
§620-04-09 §c修复: 1.13-1.15.2新增物品不兼容的问题;
|
||||
§620-02-15 §c修复: 跨服分组分配异常的问题
|
||||
</update.changes>
|
||||
<update.changelog>
|
||||
§620-02-15 §c修复: 跨服分组分配异常的问题;
|
||||
§619-05-31 §a增强: 跨服聊天压缩数据 增加可传输内容大小;
|
||||
§619-05-29 §c修复: 1.7.10不兼容的问题;
|
||||
§619-02-23 §c修复: BungeeCord 兼容性问题;
|
||||
|
@ -1,59 +1,62 @@
|
||||
package pw.yumc.MiaoChat.config;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import pw.yumc.YumCore.config.annotation.ConfigNode;
|
||||
import pw.yumc.YumCore.config.annotation.Nullable;
|
||||
import pw.yumc.YumCore.config.inject.InjectConfigurationSection;
|
||||
import pw.yumc.YumCore.tellraw.Tellraw;
|
||||
|
||||
public class ChatMessagePart extends InjectConfigurationSection {
|
||||
private String text;
|
||||
@Nullable
|
||||
private List<String> tip;
|
||||
@Nullable
|
||||
@ConfigNode("click.type")
|
||||
private String typestring;
|
||||
@Nullable
|
||||
@ConfigNode("click.command")
|
||||
private String command;
|
||||
private transient CLICKTYPE type = CLICKTYPE.SUGGEST;
|
||||
|
||||
public ChatMessagePart(ConfigurationSection config) {
|
||||
super(config);
|
||||
if (typestring != null) {
|
||||
type = CLICKTYPE.valueOf(typestring);
|
||||
}
|
||||
}
|
||||
|
||||
public Tellraw then(Tellraw tr, Player p) {
|
||||
tr.then(f(p, text));
|
||||
if (tip != null && !tip.isEmpty()) {
|
||||
tr.tip(f(p, tip));
|
||||
}
|
||||
if (command != null && !command.isEmpty()) {
|
||||
String tc = f(p, command);
|
||||
switch (type) {
|
||||
case COMMAND:
|
||||
return tr.command(tc);
|
||||
case OPENURL:
|
||||
return tr.openurl(tc);
|
||||
case SUGGEST:
|
||||
return tr.suggest(tc);
|
||||
}
|
||||
}
|
||||
return tr;
|
||||
}
|
||||
|
||||
private List<String> f(Player player, List<String> text) {
|
||||
return PlaceholderAPI.setPlaceholders(player, text);
|
||||
}
|
||||
|
||||
private String f(Player player, String text) {
|
||||
return PlaceholderAPI.setPlaceholders(player, text);
|
||||
}
|
||||
}
|
||||
package pw.yumc.MiaoChat.config;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import pw.yumc.YumCore.config.annotation.ConfigNode;
|
||||
import pw.yumc.YumCore.config.annotation.Nullable;
|
||||
import pw.yumc.YumCore.config.inject.InjectConfigurationSection;
|
||||
import pw.yumc.YumCore.tellraw.Tellraw;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ChatMessagePart extends InjectConfigurationSection {
|
||||
private String text;
|
||||
@Nullable
|
||||
private List<String> tip;
|
||||
@Nullable
|
||||
private ItemTip item;
|
||||
@Nullable
|
||||
@ConfigNode("click.type")
|
||||
private String typestring;
|
||||
@Nullable
|
||||
@ConfigNode("click.command")
|
||||
private String command;
|
||||
private transient CLICKTYPE type = CLICKTYPE.SUGGEST;
|
||||
|
||||
public ChatMessagePart(ConfigurationSection config) {
|
||||
super(config);
|
||||
if (typestring != null) {
|
||||
type = CLICKTYPE.valueOf(typestring);
|
||||
}
|
||||
}
|
||||
|
||||
public Tellraw then(Tellraw tr, Player p) {
|
||||
tr.then(f(p, text));
|
||||
if (item != null) {
|
||||
tr.item(item.getItemStack(p, text, tip));
|
||||
} else if (tip != null && !tip.isEmpty()) {
|
||||
tr.tip(f(p, tip));
|
||||
}
|
||||
if (command != null && !command.isEmpty()) {
|
||||
String tc = f(p, command);
|
||||
switch (type) {
|
||||
case COMMAND:
|
||||
return tr.command(tc);
|
||||
case OPENURL:
|
||||
return tr.openurl(tc);
|
||||
case SUGGEST:
|
||||
return tr.suggest(tc);
|
||||
}
|
||||
}
|
||||
return tr;
|
||||
}
|
||||
|
||||
private List<String> f(Player player, List<String> text) {
|
||||
return PlaceholderAPI.setPlaceholders(player, text);
|
||||
}
|
||||
|
||||
private String f(Player player, String text) {
|
||||
return PlaceholderAPI.setPlaceholders(player, text);
|
||||
}
|
||||
}
|
||||
|
52
src/main/java/pw/yumc/MiaoChat/config/ItemTip.java
Normal file
52
src/main/java/pw/yumc/MiaoChat/config/ItemTip.java
Normal file
@ -0,0 +1,52 @@
|
||||
package pw.yumc.MiaoChat.config;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import pw.yumc.MiaoChat.bungee.Log;
|
||||
import pw.yumc.YumCore.config.annotation.Default;
|
||||
import pw.yumc.YumCore.config.annotation.Nullable;
|
||||
import pw.yumc.YumCore.config.inject.InjectConfigurationSection;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemTip extends InjectConfigurationSection {
|
||||
private String type;
|
||||
@Default("0")
|
||||
private Short damage;
|
||||
@Nullable
|
||||
private String name;
|
||||
|
||||
private transient ItemStack itemStack;
|
||||
private transient ItemMeta itemMeta;
|
||||
|
||||
public ItemTip(ConfigurationSection config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
super.init();
|
||||
try {
|
||||
Material material = Material.valueOf(type);
|
||||
this.itemStack = new ItemStack(material, 1, damage);
|
||||
this.itemMeta = Bukkit.getItemFactory().getItemMeta(material);
|
||||
} catch (Throwable ex) {
|
||||
this.itemStack = new ItemStack(Material.STONE, 1);
|
||||
Log.w("物品 %s 解析失败 将使用默认值 STONE...", type);
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack getItemStack(Player p, String name, List<String> tip) {
|
||||
ItemStack itemStack = this.itemStack.clone();
|
||||
ItemMeta itemMeta = this.itemMeta.clone();
|
||||
itemMeta.setDisplayName(PlaceholderAPI.setPlaceholders(p, this.name == null ? name : this.name));
|
||||
itemMeta.setLore(PlaceholderAPI.setPlaceholders(p, tip));
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
return itemStack;
|
||||
}
|
||||
}
|
@ -1,42 +1,50 @@
|
||||
#当前文件为定义格式的基础文件
|
||||
world:
|
||||
#文本 支持PAPI变量
|
||||
text: '&6[&a%player_world%&6]'
|
||||
#悬浮提示 支持PAPI
|
||||
tip:
|
||||
- '&6当前所在位置:'
|
||||
- '&6世界: &d%player_world%'
|
||||
- '&6坐标: &aX:%player_x% Y: %player_y% Z: %player_z%'
|
||||
- ''
|
||||
- '&c点击即可TP我!'
|
||||
#点击操作
|
||||
click:
|
||||
#操作类型: [COMMAND,SUGGEST,OPENURL]
|
||||
#COMMAND代表执行命令
|
||||
#SUGGEST代表命令补全
|
||||
#OPENURL代表打开网址
|
||||
type: 'COMMAND'
|
||||
#命令或网址 支持PAPI
|
||||
command: '/tpa %player_name%'
|
||||
player:
|
||||
text: '&b%player_name%'
|
||||
tip:
|
||||
- '&6玩家名称: &b%player_name%'
|
||||
- '&6玩家等级: &a%player_level%'
|
||||
- '&6玩家血量: &c%player_health%'
|
||||
- '&6玩家饥饿: &d%player_food_level%'
|
||||
- '&6游戏模式: &4%player_gamemode%'
|
||||
- ''
|
||||
- '&c点击与我聊天'
|
||||
click:
|
||||
type: 'SUGGEST'
|
||||
command: '/tell %player_name%'
|
||||
admin:
|
||||
text: '&6[&c管理员&6]'
|
||||
help:
|
||||
text: '&4[求助]'
|
||||
tip:
|
||||
- '点击求助OP'
|
||||
click:
|
||||
type: 'COMMAND'
|
||||
#当前文件为定义格式的基础文件
|
||||
world:
|
||||
#文本 支持PAPI变量
|
||||
text: '&6[&a%player_world%&6]'
|
||||
#悬浮提示 支持PAPI
|
||||
tip:
|
||||
- '&6当前所在位置:'
|
||||
- '&6世界: &d%player_world%'
|
||||
- '&6坐标: &aX:%player_x% Y: %player_y% Z: %player_z%'
|
||||
- ''
|
||||
- '&c点击即可TP我!'
|
||||
#点击操作
|
||||
click:
|
||||
#操作类型: [COMMAND,SUGGEST,OPENURL]
|
||||
#COMMAND代表执行命令
|
||||
#SUGGEST代表命令补全
|
||||
#OPENURL代表打开网址
|
||||
type: 'COMMAND'
|
||||
#命令或网址 支持PAPI
|
||||
command: '/tpa %player_name%'
|
||||
player:
|
||||
text: '&b%player_name%'
|
||||
# 物品化Tip 可配合龙核/萌芽做ItemTip
|
||||
item:
|
||||
# 物品枚举
|
||||
type: STONE
|
||||
# 物品子ID
|
||||
damage: 0
|
||||
# 物品名称(用于萌芽/龙核匹配) 为空则使用 text
|
||||
name: '§s§v§i§p'
|
||||
tip:
|
||||
- '&6玩家名称: &b%player_name%'
|
||||
- '&6玩家等级: &a%player_level%'
|
||||
- '&6玩家血量: &c%player_health%'
|
||||
- '&6玩家饥饿: &d%player_food_level%'
|
||||
- '&6游戏模式: &4%player_gamemode%'
|
||||
- ''
|
||||
- '&c点击与我聊天'
|
||||
click:
|
||||
type: 'SUGGEST'
|
||||
command: '/tell %player_name%'
|
||||
admin:
|
||||
text: '&6[&c管理员&6]'
|
||||
help:
|
||||
text: '&4[求助]'
|
||||
tip:
|
||||
- '点击求助OP'
|
||||
click:
|
||||
type: 'COMMAND'
|
||||
command: '管理员@%player_name% 我需要你的帮助!'
|
@ -25,7 +25,7 @@ permissions:
|
||||
default: true
|
||||
${project.artifactId}.color:
|
||||
description: 彩字聊天权限!
|
||||
default: true
|
||||
default: op
|
||||
${project.artifactId}.admin:
|
||||
description: 管理员格式权限!
|
||||
default: op
|
||||
|
Loading…
Reference in New Issue
Block a user