From c57947949cefc5cb388f36444032c709fc6cf486 Mon Sep 17 00:00:00 2001 From: Luck Date: Tue, 13 Jun 2017 17:30:01 +0100 Subject: [PATCH] Don't send messages to command blocks async --- .../me/lucko/luckperms/bukkit/BukkitSenderFactory.java | 8 ++++++++ .../luckperms/common/commands/sender/SenderFactory.java | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitSenderFactory.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitSenderFactory.java index c3fe2ee86..73e2d4600 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitSenderFactory.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitSenderFactory.java @@ -32,6 +32,7 @@ import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import net.kyori.text.Component; +import org.bukkit.command.BlockCommandSender; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -63,6 +64,13 @@ public class BukkitSenderFactory extends SenderFactory { @Override protected void sendMessage(CommandSender sender, String s) { + + // send sync if command block + if (sender instanceof BlockCommandSender) { + getPlugin().getScheduler().doSync(() -> sender.sendMessage(s)); + return; + } + sender.sendMessage(s); } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/sender/SenderFactory.java b/common/src/main/java/me/lucko/luckperms/common/commands/sender/SenderFactory.java index 89a873189..d6be834c3 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/sender/SenderFactory.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/sender/SenderFactory.java @@ -25,6 +25,8 @@ package me.lucko.luckperms.common.commands.sender; +import lombok.AccessLevel; +import lombok.Getter; import lombok.RequiredArgsConstructor; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; @@ -40,6 +42,8 @@ import java.util.UUID; */ @RequiredArgsConstructor public abstract class SenderFactory { + + @Getter(AccessLevel.PROTECTED) private final LuckPermsPlugin plugin; protected abstract String getName(T t);