From 5d4aa73fd62605d6cce1619dd97a37cd403804a7 Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Mon, 5 Jun 2023 17:29:58 +0700 Subject: [PATCH] finally limit the mail total thingy thing thingy --- .../chomens_bot/commands/MailCommand.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/MailCommand.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/MailCommand.java index e735c060..acf1d54f 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/MailCommand.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/commands/MailCommand.java @@ -58,8 +58,18 @@ public class MailCommand implements Command { final MutablePlayerListEntry sender = context.sender(); + // kinda messy ngl + switch (args[0]) { case "send" -> { + int senderMailsSentTotal = 0; + for (Mail mail : MailPlugin.mails()) { + if (!mail.sentBy().equals(sender.profile().getName())) continue; + senderMailsSentTotal++; + } + + if (senderMailsSentTotal > 256) return Component.text("You are sending too much mails!").color(NamedTextColor.RED); + bot.mail().send( new Mail( sender.profile().getName(), @@ -73,6 +83,14 @@ public class MailCommand implements Command { return Component.text("Mail sent!").color(ColorUtilities.getColorByString(bot.config().colorPalette().defaultColor())); } case "sendselecteditem" -> { + int senderMailsSentTotal = 0; + for (Mail mail : MailPlugin.mails()) { + if (!mail.sentTo().equals(sender.profile().getName())) continue; + senderMailsSentTotal++; + } + + if (senderMailsSentTotal > 256) return Component.text("You are sending too much mails!").color(NamedTextColor.RED); + final CompletableFuture future = bot.core().runTracked( "minecraft:data get entity " + UUIDUtilities.selector(sender.profile().getId()) +