Delay unread mail message and also send it as a title message
This commit is contained in:
@@ -23,8 +23,10 @@ import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import net.kyori.adventure.title.Title;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class ProxyPlayerListener {
|
||||
|
||||
@@ -68,9 +70,17 @@ public class ProxyPlayerListener {
|
||||
List<Mail> unReadMail = chatUser.getUnReadMail();
|
||||
if (unReadMail.isEmpty())
|
||||
return;
|
||||
player.sendMessage(Utility.parseMiniMessage(Config.mailUnread,
|
||||
Placeholder.unparsed("amount", String.valueOf(unReadMail.size()))
|
||||
));
|
||||
VelocityChat plugin = VelocityChat.getPlugin();
|
||||
plugin.getProxy().getScheduler().buildTask(plugin, () -> {
|
||||
if (!player.isActive())
|
||||
return;
|
||||
|
||||
Component message = Utility.parseMiniMessage(Config.mailUnread,
|
||||
Placeholder.unparsed("amount", String.valueOf(unReadMail.size())));
|
||||
player.sendMessage(message);
|
||||
player.showTitle(Title.title(message, Component.empty()));
|
||||
}).delay(Config.mailDisplayDelay * 50L, TimeUnit.MILLISECONDS).schedule();
|
||||
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
||||
Reference in New Issue
Block a user