当玩家请求传送时,使用聊天栏按钮代替指令进行响应
This commit is contained in:
@@ -2,6 +2,11 @@ package ling.coordinateRecorder.Service;
|
||||
|
||||
import ling.coordinateRecorder.Config;
|
||||
import ling.coordinateRecorder.data.TransmitData;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.chat.hover.content.Text;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -45,8 +50,25 @@ public final class TransmitService implements Service {
|
||||
")");
|
||||
} else {
|
||||
player.sendMessage("正在等待目标玩家响应...");
|
||||
data.getTargetPlayer().getPlayer().sendMessage("玩家 " + player.getName() + " 正在请求向你传送\n使用"
|
||||
+ ChatColor.YELLOW + "/zb yes" + ChatColor.WHITE + "同意该请求,使用" + ChatColor.YELLOW + "/zb no" + ChatColor.WHITE + "拒绝");
|
||||
BaseComponent message = new TextComponent("玩家 " + player.getName() + " 正在请求向你传送\n");
|
||||
|
||||
BaseComponent yes = new TextComponent("[同意]");
|
||||
yes.setColor(net.md_5.bungee.api.ChatColor.YELLOW);
|
||||
yes.setUnderlined(true);
|
||||
yes.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/zb yes"));
|
||||
yes.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("点击同意该请求")));
|
||||
|
||||
BaseComponent no = new TextComponent("[拒绝]");
|
||||
no.setColor(net.md_5.bungee.api.ChatColor.RED);
|
||||
no.setUnderlined(true);
|
||||
no.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/zb no"));
|
||||
no.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("点击拒绝该请求")));
|
||||
|
||||
message.addExtra(yes);
|
||||
message.addExtra(" ");
|
||||
message.addExtra(no);
|
||||
|
||||
data.getTargetPlayer().getPlayer().spigot().sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user