Don't send messages to command blocks async

This commit is contained in:
Luck 2017-06-13 17:30:01 +01:00
parent 0acefde805
commit c57947949c
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
2 changed files with 12 additions and 0 deletions

View File

@ -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<CommandSender> {
@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);
}

View File

@ -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<T> {
@Getter(AccessLevel.PROTECTED)
private final LuckPermsPlugin plugin;
protected abstract String getName(T t);