parent
be66b3b9a0
commit
11fb155a37
12
pom.xml
12
pom.xml
|
@ -3,7 +3,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<artifactId>MiaoChat</artifactId>
|
<artifactId>MiaoChat</artifactId>
|
||||||
<version>2.0.0</version>
|
<version>2.1.1</version>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>pw.yumc</groupId>
|
<groupId>pw.yumc</groupId>
|
||||||
|
@ -13,13 +13,15 @@
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<update.description>§a正式版本 §bv2.0.0 §b全新版本(号) 配合龙核食用</update.description>
|
<update.description>§a正式版本 §bv2.1.1 §b兼容 1.18.2</update.description>
|
||||||
<update.changes>
|
<update.changes>
|
||||||
§621-12-18 §a增强: 全新版本(号) 新增 itemTip 配合龙核 实现神奇功能;
|
§622-04-12 §a增强: 兼容 1.18.2 修复 PAPI 注销报错;
|
||||||
§621-12-06 §a增强: 兼容 1.18 版本 兼容新版PAPI;
|
§622-02-25 §a增强: 新增 %a-z 自定义解析 实现神奇功能 兼容 1.18.1#133+;
|
||||||
§621-06-20 §a增强: 兼容 1.17 版本
|
§621-12-18 §a增强: 全新版本(号) 新增 itemTip 配合龙核 实现神奇功能
|
||||||
</update.changes>
|
</update.changes>
|
||||||
<update.changelog>
|
<update.changelog>
|
||||||
|
§621-12-06 §a增强: 兼容 1.18 版本 兼容新版PAPI;
|
||||||
|
§621-06-20 §a增强: 兼容 1.17 版本;
|
||||||
§620-10-10 §c修复: 1.16.3聊天包格式调整的问题;
|
§620-10-10 §c修复: 1.16.3聊天包格式调整的问题;
|
||||||
§620-04-10 §c修复: L10N 本地化组件报错的问题;
|
§620-04-10 §c修复: L10N 本地化组件报错的问题;
|
||||||
§620-04-09 §c修复: 1.13-1.15.2新增物品不兼容的问题;
|
§620-04-09 §c修复: 1.13-1.15.2新增物品不兼容的问题;
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class MiaoChat extends JavaPlugin implements Executor, PluginMessageListe
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
this.expansion.unregister();
|
try {this.expansion.unregister();} catch (Exception ignored) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableBungeeCord() {
|
private void enableBungeeCord() {
|
||||||
|
|
|
@ -1,62 +1,62 @@
|
||||||
package pw.yumc.MiaoChat.config;
|
package pw.yumc.MiaoChat.config;
|
||||||
|
|
||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import pw.yumc.YumCore.config.annotation.ConfigNode;
|
import pw.yumc.YumCore.config.annotation.ConfigNode;
|
||||||
import pw.yumc.YumCore.config.annotation.Nullable;
|
import pw.yumc.YumCore.config.annotation.Nullable;
|
||||||
import pw.yumc.YumCore.config.inject.InjectConfigurationSection;
|
import pw.yumc.YumCore.config.inject.InjectConfigurationSection;
|
||||||
import pw.yumc.YumCore.tellraw.Tellraw;
|
import pw.yumc.YumCore.tellraw.Tellraw;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ChatMessagePart extends InjectConfigurationSection {
|
public class ChatMessagePart extends InjectConfigurationSection {
|
||||||
private String text;
|
private String text;
|
||||||
@Nullable
|
@Nullable
|
||||||
private List<String> tip;
|
private List<String> tip;
|
||||||
@Nullable
|
@Nullable
|
||||||
private ItemTip item;
|
private ItemTip item;
|
||||||
@Nullable
|
@Nullable
|
||||||
@ConfigNode("click.type")
|
@ConfigNode("click.type")
|
||||||
private String typestring;
|
private String typestring;
|
||||||
@Nullable
|
@Nullable
|
||||||
@ConfigNode("click.command")
|
@ConfigNode("click.command")
|
||||||
private String command;
|
private String command;
|
||||||
private transient CLICKTYPE type = CLICKTYPE.SUGGEST;
|
private transient CLICKTYPE type = CLICKTYPE.SUGGEST;
|
||||||
|
|
||||||
public ChatMessagePart(ConfigurationSection config) {
|
public ChatMessagePart(ConfigurationSection config) {
|
||||||
super(config);
|
super(config);
|
||||||
if (typestring != null) {
|
if (typestring != null) {
|
||||||
type = CLICKTYPE.valueOf(typestring);
|
type = CLICKTYPE.valueOf(typestring);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Tellraw then(Tellraw tr, Player p) {
|
public Tellraw then(Tellraw tr, Player p) {
|
||||||
tr.then(f(p, text));
|
tr.then(f(p, text));
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
tr.item(item.getItemStack(p, text, tip));
|
tr.item(item.getItemStack(p, text, tip));
|
||||||
} else if (tip != null && !tip.isEmpty()) {
|
} else if (tip != null && !tip.isEmpty()) {
|
||||||
tr.tip(f(p, tip));
|
tr.tip(f(p, tip));
|
||||||
}
|
}
|
||||||
if (command != null && !command.isEmpty()) {
|
if (command != null && !command.isEmpty()) {
|
||||||
String tc = f(p, command);
|
String tc = f(p, command);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case COMMAND:
|
case COMMAND:
|
||||||
return tr.command(tc);
|
return tr.command(tc);
|
||||||
case OPENURL:
|
case OPENURL:
|
||||||
return tr.openurl(tc);
|
return tr.openurl(tc);
|
||||||
case SUGGEST:
|
case SUGGEST:
|
||||||
return tr.suggest(tc);
|
return tr.suggest(tc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tr;
|
return tr;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> f(Player player, List<String> text) {
|
private List<String> f(Player player, List<String> text) {
|
||||||
return PlaceholderAPI.setPlaceholders(player, text);
|
return PlaceholderAPI.setPlaceholders(player, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String f(Player player, String text) {
|
private String f(Player player, String text) {
|
||||||
return PlaceholderAPI.setPlaceholders(player, text);
|
return PlaceholderAPI.setPlaceholders(player, text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,5 @@
|
||||||
package pw.yumc.MiaoChat.listeners;
|
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.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
@ -16,7 +9,6 @@ import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import pw.yumc.MiaoChat.MiaoChat;
|
import pw.yumc.MiaoChat.MiaoChat;
|
||||||
import pw.yumc.MiaoChat.MiaoMessage;
|
import pw.yumc.MiaoChat.MiaoMessage;
|
||||||
import pw.yumc.MiaoChat.config.ChatConfig;
|
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.tellraw.Tellraw;
|
||||||
import pw.yumc.YumCore.update.SubscribeTask;
|
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
|
* @author MiaoWoo
|
||||||
*/
|
*/
|
||||||
public class ChatListener implements Listener {
|
public class ChatListener implements Listener {
|
||||||
public static Set<Player> offList = new HashSet<>();
|
public static Set<Player> offList = new HashSet<>();
|
||||||
private static Pattern ITEM_PATTERN = Pattern.compile("%([i1-9]?)");
|
private static Pattern PATTERN = Pattern.compile("%([a-z1-9]?)");
|
||||||
|
|
||||||
private final Queue<String> queue = new LinkedList<>();
|
|
||||||
|
|
||||||
private MiaoChat plugin = P.getPlugin();
|
private MiaoChat plugin = P.getPlugin();
|
||||||
private ChatConfig cc = plugin.getChatConfig();
|
private ChatConfig cc = plugin.getChatConfig();
|
||||||
|
@ -85,7 +81,7 @@ public class ChatListener implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private LinkedList<String> handlePattern(String message) {
|
private LinkedList<String> handlePattern(String message) {
|
||||||
Matcher m = ITEM_PATTERN.matcher(message);
|
Matcher m = PATTERN.matcher(message);
|
||||||
Set<String> temp = new HashSet<>();
|
Set<String> temp = new HashSet<>();
|
||||||
LinkedList<String> ilist = new LinkedList<>();
|
LinkedList<String> ilist = new LinkedList<>();
|
||||||
// Log.d("处理聊天物品信息...");
|
// Log.d("处理聊天物品信息...");
|
||||||
|
@ -126,7 +122,7 @@ public class ChatListener implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Tellraw handleTellraw(Player player, Tellraw tr, ChatRule cr, String message) {
|
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")) {
|
if (player.hasPermission("MiaoChat.color")) {
|
||||||
message = ChatColor.translateAlternateColorCodes('&', message);
|
message = ChatColor.translateAlternateColorCodes('&', message);
|
||||||
}
|
}
|
||||||
|
@ -151,6 +147,17 @@ public class ChatListener implements Listener {
|
||||||
// Log.d("处理物品: %s", mm);
|
// Log.d("处理物品: %s", mm);
|
||||||
tr.then(String.format(ChatColor.translateAlternateColorCodes('&', cr.getItemformat()), L10N.getName(is)));
|
tr.then(String.format(ChatColor.translateAlternateColorCodes('&', cr.getItemformat()), L10N.getName(is)));
|
||||||
tr.item(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 {
|
} else {
|
||||||
// Log.d("追加聊天: %s", mm);
|
// Log.d("追加聊天: %s", mm);
|
||||||
|
|
|
@ -1,50 +1,71 @@
|
||||||
#当前文件为定义格式的基础文件
|
#当前文件为定义格式的基础文件
|
||||||
world:
|
world:
|
||||||
#文本 支持PAPI变量
|
#文本 支持PAPI变量
|
||||||
text: '&6[&a%player_world%&6]'
|
text: '&6[&a%player_world%&6]'
|
||||||
#悬浮提示 支持PAPI
|
#悬浮提示 支持PAPI
|
||||||
tip:
|
tip:
|
||||||
- '&6当前所在位置:'
|
- '&6当前所在位置:'
|
||||||
- '&6世界: &d%player_world%'
|
- '&6世界: &d%player_world%'
|
||||||
- '&6坐标: &aX:%player_x% Y: %player_y% Z: %player_z%'
|
- '&6坐标: &aX:%player_x% Y: %player_y% Z: %player_z%'
|
||||||
- ''
|
- ''
|
||||||
- '&c点击即可TP我!'
|
- '&c点击即可TP我!'
|
||||||
#点击操作
|
#点击操作
|
||||||
click:
|
click:
|
||||||
#操作类型: [COMMAND,SUGGEST,OPENURL]
|
#操作类型: [COMMAND,SUGGEST,OPENURL]
|
||||||
#COMMAND代表执行命令
|
#COMMAND代表执行命令
|
||||||
#SUGGEST代表命令补全
|
#SUGGEST代表命令补全
|
||||||
#OPENURL代表打开网址
|
#OPENURL代表打开网址
|
||||||
type: 'COMMAND'
|
type: 'COMMAND'
|
||||||
#命令或网址 支持PAPI
|
#命令或网址 支持PAPI
|
||||||
command: '/tpa %player_name%'
|
command: '/tpa %player_name%'
|
||||||
player:
|
player:
|
||||||
text: '&b%player_name%'
|
text: '&b%player_name%'
|
||||||
# 物品化Tip 可配合龙核/萌芽做ItemTip
|
# 物品化Tip 可配合龙核/萌芽做ItemTip
|
||||||
#item:
|
#item:
|
||||||
# # 物品枚举
|
# # 物品枚举
|
||||||
# type: STONE
|
# type: STONE
|
||||||
# # 物品子ID
|
# # 物品子ID
|
||||||
# damage: 0
|
# damage: 0
|
||||||
# # 物品名称(用于萌芽/龙核匹配) 为空则使用 text
|
# # 物品名称(用于萌芽/龙核匹配) 为空则使用 text
|
||||||
# name: '§s§v§i§p'
|
# name: '§s§v§i§p'
|
||||||
tip:
|
tip:
|
||||||
- '&6玩家名称: &b%player_name%'
|
- '&6玩家名称: &b%player_name%'
|
||||||
- '&6玩家等级: &a%player_level%'
|
- '&6玩家等级: &a%player_level%'
|
||||||
- '&6玩家血量: &c%player_health%'
|
- '&6玩家血量: &c%player_health%'
|
||||||
- '&6玩家饥饿: &d%player_food_level%'
|
- '&6玩家饥饿: &d%player_food_level%'
|
||||||
- '&6游戏模式: &4%player_gamemode%'
|
- '&6游戏模式: &4%player_gamemode%'
|
||||||
- ''
|
- ''
|
||||||
- '&c点击与我聊天'
|
- '&c点击与我聊天'
|
||||||
click:
|
click:
|
||||||
type: 'SUGGEST'
|
type: 'SUGGEST'
|
||||||
command: '/tell %player_name%'
|
command: '/tell %player_name%'
|
||||||
admin:
|
admin:
|
||||||
text: '&6[&c管理员&6]'
|
text: '&6[&c管理员&6]'
|
||||||
help:
|
help:
|
||||||
text: '&4[求助]'
|
text: '&4[求助]'
|
||||||
tip:
|
tip:
|
||||||
- '点击求助OP'
|
- '点击求助OP'
|
||||||
click:
|
click:
|
||||||
type: 'COMMAND'
|
type: 'COMMAND'
|
||||||
command: '管理员@%player_name% 我需要你的帮助!'
|
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%'
|
|
@ -1,7 +1,7 @@
|
||||||
name: ${project.artifactId}
|
name: ${project.artifactId}
|
||||||
description: ${project.description}
|
description: ${project.description}
|
||||||
main: ${project.groupId}.${project.artifactId}.${project.artifactId}
|
main: ${project.groupId}.${project.artifactId}.${project.artifactId}
|
||||||
version: ${project.version}-git-${env.GIT_COMMIT}
|
version: ${project.version}
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
author: MiaoWoo
|
author: MiaoWoo
|
||||||
website: ${ciManagement.url}
|
website: ${ciManagement.url}
|
||||||
|
|
Loading…
Reference in New Issue