forked from circlecloud/MiaoChat
		
	
							
								
								
									
										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,21 +1,22 @@
 | 
			
		||||
package pw.yumc.MiaoChat.config;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import me.clip.placeholderapi.PlaceholderAPI;
 | 
			
		||||
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;
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
@@ -32,7 +33,9 @@ public class ChatMessagePart extends InjectConfigurationSection {
 | 
			
		||||
 | 
			
		||||
    public Tellraw then(Tellraw tr, Player p) {
 | 
			
		||||
        tr.then(f(p, text));
 | 
			
		||||
        if (tip != null && !tip.isEmpty()) {
 | 
			
		||||
        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()) {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										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;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -20,6 +20,14 @@ world:
 | 
			
		||||
    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%'
 | 
			
		||||
 
 | 
			
		||||
@@ -25,7 +25,7 @@ permissions:
 | 
			
		||||
    default: true
 | 
			
		||||
  ${project.artifactId}.color:
 | 
			
		||||
    description: 彩字聊天权限!
 | 
			
		||||
    default: true
 | 
			
		||||
    default: op
 | 
			
		||||
  ${project.artifactId}.admin:
 | 
			
		||||
    description: 管理员格式权限!
 | 
			
		||||
    default: op
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user