1
0
mirror of https://e.coding.net/circlecloud/QuickShop.git synced 2024-11-22 01:58:54 +00:00

修复不必要的获取离线玩家导致创建大量getProfile线程导致服务端崩溃的问题

[16:32:33] [Paper Watchdog Thread/ERROR]: Current Thread: Craft Scheduler Thread - 14395
[16:32:33] [Paper Watchdog Thread/ERROR]: 	PID: 18215 | Suspended: false | Native: false | State: BLOCKED
[16:32:33] [Paper Watchdog Thread/ERROR]: 	Stack:
[16:32:33] [Paper Watchdog Thread/ERROR]: 		net.minecraft.server.v1_12_R1.UserCache.getProfile(UserCache.java:142)
[16:32:33] [Paper Watchdog Thread/ERROR]: 		org.bukkit.craftbukkit.v1_12_R1.CraftServer.getOfflinePlayer(CraftServer.java:1352)
[16:32:33] [Paper Watchdog Thread/ERROR]: 		org.bukkit.Bukkit.getOfflinePlayer(Bukkit.java:730)
[16:32:33] [Paper Watchdog Thread/ERROR]: 		org.maxgamer.QuickShop.Util.MsgUtil.lambda$3(MsgUtil.java:170)
[16:32:33] [Paper Watchdog Thread/ERROR]: 		org.maxgamer.QuickShop.Util.MsgUtil$$Lambda$448/1914437489.run(Unknown Source)
[16:32:33] [Paper Watchdog Thread/ERROR]: 		org.bukkit.craftbukkit.v1_12_R1.scheduler.CraftTask.run(CraftTask.java:58)
[16:32:33] [Paper Watchdog Thread/ERROR]: 		org.bukkit.craftbukkit.v1_12_R1.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:52)
[16:32:33] [Paper Watchdog Thread/ERROR]: 		com.destroystokyo.paper.ServerSchedulerReportingWrapper.run(ServerSchedulerReportingWrapper.java:22)
[16:32:33] [Paper Watchdog Thread/ERROR]: 		java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[16:32:33] [Paper Watchdog Thread/ERROR]: 		java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[16:32:33] [Paper Watchdog Thread/ERROR]: 		java.lang.Thread.run(Thread.java:748)
[16:32:33] [Paper Watchdog Thread/ERROR]: ------------------------------
This commit is contained in:
17jiong 2018-01-31 18:43:23 +08:00
parent d768f93c6c
commit 4a18053026

View File

@ -106,7 +106,7 @@ public class MsgUtil {
*/ */
public static void send(final String player, final String message) { public static void send(final String player, final String message) {
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
final OfflinePlayer p = Bukkit.getOfflinePlayer(player); final Player p = Bukkit.getPlayerExact(player);
if (p == null || !p.isOnline()) { if (p == null || !p.isOnline()) {
LinkedList<String> msgs = player_messages.computeIfAbsent(player, k -> new LinkedList<>()); LinkedList<String> msgs = player_messages.computeIfAbsent(player, k -> new LinkedList<>());
msgs.add(message); msgs.add(message);
@ -166,8 +166,7 @@ public class MsgUtil {
p.sendMessage(""); p.sendMessage("");
p.sendMessage(ChatColor.DARK_PURPLE + "+---------------------------------------------------+"); p.sendMessage(ChatColor.DARK_PURPLE + "+---------------------------------------------------+");
p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.shop-information")); p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.shop-information"));
p.sendMessage(ChatColor.DARK_PURPLE + "| " p.sendMessage(ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.owner", shop.getOwner() == null ? (shop.isUnlimited() ? "系统商店" : "未知") : shop.getOwner()));
+ MsgUtil.p("menu.owner", Bukkit.getOfflinePlayer(shop.getOwner()).getName() == null ? (shop.isUnlimited() ? "系统商店" : "未知") : Bukkit.getOfflinePlayer(shop.getOwner()).getName()));
final String msg = ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.item", shop.getDataName()); final String msg = ChatColor.DARK_PURPLE + "| " + MsgUtil.p("menu.item", shop.getDataName());
sendItemMessage(p, shop.getItem(), msg); sendItemMessage(p, shop.getItem(), msg);
if (Util.isTool(item.getType())) { if (Util.isTool(item.getType())) {