4
1
mirror of https://e.coding.net/circlecloud/MiaoChat.git synced 2024-11-22 14:38:47 +00:00

feat: 公开发布兼容1.18.2版本

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
MiaoWoo 2022-04-13 14:34:04 +08:00
parent be66b3b9a0
commit 11fb155a37
6 changed files with 162 additions and 132 deletions

12
pom.xml
View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>MiaoChat</artifactId>
<version>2.0.0</version>
<version>2.1.1</version>
<parent>
<groupId>pw.yumc</groupId>
@ -13,13 +13,15 @@
</parent>
<properties>
<update.description>§a正式版本 §bv2.0.0 §b全新版本(号) 配合龙核食用</update.description>
<update.description>§a正式版本 §bv2.1.1 §b兼容 1.18.2</update.description>
<update.changes>
§621-12-18 §a增强: 全新版本(号) 新增 itemTip 配合龙核 实现神奇功能;
§621-12-06 §a增强: 兼容 1.18 版本 兼容新版PAPI;
§621-06-20 §a增强: 兼容 1.17 版本
§622-04-12 §a增强: 兼容 1.18.2 修复 PAPI 注销报错;
§622-02-25 §a增强: 新增 %a-z 自定义解析 实现神奇功能 兼容 1.18.1#133+;
§621-12-18 §a增强: 全新版本(号) 新增 itemTip 配合龙核 实现神奇功能
</update.changes>
<update.changelog>
§621-12-06 §a增强: 兼容 1.18 版本 兼容新版PAPI;
§621-06-20 §a增强: 兼容 1.17 版本;
§620-10-10 §c修复: 1.16.3聊天包格式调整的问题;
§620-04-10 §c修复: L10N 本地化组件报错的问题;
§620-04-09 §c修复: 1.13-1.15.2新增物品不兼容的问题;

View File

@ -67,7 +67,7 @@ public class MiaoChat extends JavaPlugin implements Executor, PluginMessageListe
@Override
public void onDisable() {
this.expansion.unregister();
try {this.expansion.unregister();} catch (Exception ignored) {}
}
private void enableBungeeCord() {

View File

@ -1,62 +1,62 @@
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);
}
}
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);
}
}

View File

@ -1,12 +1,5 @@
package pw.yumc.MiaoChat.listeners;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@ -16,7 +9,6 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.inventory.ItemStack;
import pw.yumc.MiaoChat.MiaoChat;
import pw.yumc.MiaoChat.MiaoMessage;
import pw.yumc.MiaoChat.config.ChatConfig;
@ -28,14 +20,18 @@ import pw.yumc.YumCore.statistic.Statistics;
import pw.yumc.YumCore.tellraw.Tellraw;
import pw.yumc.YumCore.update.SubscribeTask;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @author MiaoWoo
*/
public class ChatListener implements Listener {
public static Set<Player> offList = new HashSet<>();
private static Pattern ITEM_PATTERN = Pattern.compile("%([i1-9]?)");
private final Queue<String> queue = new LinkedList<>();
private static Pattern PATTERN = Pattern.compile("%([a-z1-9]?)");
private MiaoChat plugin = P.getPlugin();
private ChatConfig cc = plugin.getChatConfig();
@ -85,7 +81,7 @@ public class ChatListener implements Listener {
}
private LinkedList<String> handlePattern(String message) {
Matcher m = ITEM_PATTERN.matcher(message);
Matcher m = PATTERN.matcher(message);
Set<String> temp = new HashSet<>();
LinkedList<String> ilist = new LinkedList<>();
// Log.d("处理聊天物品信息...");
@ -126,7 +122,7 @@ public class ChatListener implements Listener {
}
private Tellraw handleTellraw(Player player, Tellraw tr, ChatRule cr, String message) {
if (message.isEmpty()) { return tr; }
if (message.isEmpty()) {return tr;}
if (player.hasPermission("MiaoChat.color")) {
message = ChatColor.translateAlternateColorCodes('&', message);
}
@ -151,6 +147,17 @@ public class ChatListener implements Listener {
// Log.d("处理物品: %s", mm);
tr.then(String.format(ChatColor.translateAlternateColorCodes('&', cr.getItemformat()), L10N.getName(is)));
tr.item(is);
} else {
String key = String.valueOf(k);
if (plugin.getChatConfig().getFormats().containsKey(key)) {
if (!player.hasPermission("MiaoChat.format.*") && player.hasPermission("MiaoChat.format." + k)) {
Log.sender(player, "§c你没有使用 " + mm + " 的权限!");
continue;
}
plugin.getChatConfig().getFormats().get(key).then(tr, player);
} else {
tr.then(cr.getLastColor() + mm);
}
}
} else {
// Log.d("追加聊天: %s", mm);

View File

@ -1,50 +1,71 @@
#当前文件为定义格式的基础文件
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% 我需要你的帮助!'
#当前文件为定义格式的基础文件
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% 我需要你的帮助!'
l:
text: '&6[&b点击看我仓库]&6'
# item:
# # 物品枚举
# type: STONE
# # 物品子ID
# damage: 0
# # 物品名称(用于萌芽/龙核匹配) 为空则使用 text
# name: '§g§s§p'
tip:
- '&a点击查看 &b%player_name% &a的仓库'
click:
type: 'COMMAND'
command: '/mgs look %player_name% local 1'
t:
text: '&6[&b点击和我交易&6]&r'
tip:
- '&a点击和 &b%player_name% &a发起交易'
click:
type: 'COMMAND'
command: '/trade %player_name%'

View File

@ -1,7 +1,7 @@
name: ${project.artifactId}
description: ${project.description}
main: ${project.groupId}.${project.artifactId}.${project.artifactId}
version: ${project.version}-git-${env.GIT_COMMIT}
version: ${project.version}
api-version: 1.13
author: MiaoWoo
website: ${ciManagement.url}