Delay unread mail message and also send it as a title message
This commit is contained in:
parent
9bd9e21321
commit
f5c0a0676c
|
|
@ -424,6 +424,7 @@ public final class Config {
|
||||||
public static String mailUnread = "<green><click:run_command:/mail list unread>You have <amount> unread mail, click to view it.</click></green>";
|
public static String mailUnread = "<green><click:run_command:/mail list unread>You have <amount> unread mail, click to view it.</click></green>";
|
||||||
public static String mailSent = "<green>Successfully send mail to <player_name></green>: <#2e8b57><message></#2e8b57>";
|
public static String mailSent = "<green>Successfully send mail to <player_name></green>: <#2e8b57><message></#2e8b57>";
|
||||||
public static List<String> mailCommandAlias = new ArrayList<>();
|
public static List<String> mailCommandAlias = new ArrayList<>();
|
||||||
|
public static int mailDisplayDelay = 5;
|
||||||
private static void mailSettings() {
|
private static void mailSettings() {
|
||||||
mailHeader = getString("settings.mail.header", mailHeader);
|
mailHeader = getString("settings.mail.header", mailHeader);
|
||||||
mailBody = getString("settings.mail.message", mailBody);
|
mailBody = getString("settings.mail.message", mailBody);
|
||||||
|
|
@ -432,6 +433,7 @@ public final class Config {
|
||||||
mailReceived = getString("settings.mail.mail-received", mailReceived);
|
mailReceived = getString("settings.mail.mail-received", mailReceived);
|
||||||
mailUnread = getString("settings.mail.mail-unread", mailUnread);
|
mailUnread = getString("settings.mail.mail-unread", mailUnread);
|
||||||
mailSent = getString("settings.mail.mail-sent", mailSent);
|
mailSent = getString("settings.mail.mail-sent", mailSent);
|
||||||
|
mailDisplayDelay = getInt("settings.mail.delay", mailDisplayDelay);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HashMap<String, Long> serverChannelId = new HashMap<>();
|
public static HashMap<String, Long> serverChannelId = new HashMap<>();
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,10 @@ import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
|
import net.kyori.adventure.title.Title;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class ProxyPlayerListener {
|
public class ProxyPlayerListener {
|
||||||
|
|
||||||
|
|
@ -68,9 +70,17 @@ public class ProxyPlayerListener {
|
||||||
List<Mail> unReadMail = chatUser.getUnReadMail();
|
List<Mail> unReadMail = chatUser.getUnReadMail();
|
||||||
if (unReadMail.isEmpty())
|
if (unReadMail.isEmpty())
|
||||||
return;
|
return;
|
||||||
player.sendMessage(Utility.parseMiniMessage(Config.mailUnread,
|
VelocityChat plugin = VelocityChat.getPlugin();
|
||||||
Placeholder.unparsed("amount", String.valueOf(unReadMail.size()))
|
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
|
@Subscribe
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user