Fixed 'silent' param in /mi give

This commit is contained in:
Indyuce 2022-12-02 17:49:04 +01:00
parent 4a4227fe97
commit de7eb81ddf

View File

@ -5,7 +5,6 @@ import io.lumine.mythic.lib.command.api.CommandTreeNode;
import io.lumine.mythic.lib.command.api.Parameter;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
@ -14,6 +13,7 @@ import net.Indyuce.mmoitems.api.util.RandomAmount;
import net.Indyuce.mmoitems.api.util.message.Message;
import net.Indyuce.mmoitems.command.MMOItemsCommandTreeRoot;
import net.Indyuce.mmoitems.stat.data.SoulboundData;
import net.Indyuce.mmoitems.util.MMOUtils;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -60,7 +60,7 @@ public class GiveCommandTreeNode extends CommandTreeNode {
double unidentify = args.length > 5 ? Double.parseDouble(args[5]) / 100 : 0;
double drop = args.length > 6 ? Double.parseDouble(args[6]) / 100 : 1;
double soulbound = args.length > 7 ? Double.parseDouble(args[7]) / 100 : 0;
boolean silent = args.length > 8 ? args[8].equalsIgnoreCase("silent") || args[8].equalsIgnoreCase("s") : false;
boolean silent = args.length > 8 && (args[8].equalsIgnoreCase("silent") || args[8].equalsIgnoreCase("s"));
// roll drop chance
if (random.nextDouble() > drop)
@ -83,13 +83,14 @@ public class GiveCommandTreeNode extends CommandTreeNode {
item.setAmount(amount.getRandomAmount());
// message
if (!silent) {
Message.RECEIVED_ITEM.format(ChatColor.YELLOW, "#item#", MMOUtils.getDisplayName(item), "#amount#",
(item.getAmount() > 1 ? " x" + item.getAmount() : "")).send(target);
if (!sender.equals(target))
sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.YELLOW + "Successfully gave " + ChatColor.GOLD
+ MMOUtils.getDisplayName(item) + (item.getAmount() > 1 ? " x" + item.getAmount() : "") + ChatColor.YELLOW + " to "
+ ChatColor.GOLD + target.getName() + ChatColor.YELLOW + ".");
if (!silent)
Message.RECEIVED_ITEM.format(ChatColor.YELLOW, "#item#", MMOUtils.getDisplayName(item), "#amount#",
(item.getAmount() > 1 ? " x" + item.getAmount() : "")).send(target);
}
// item
new SmartGive(target).give(item);