From a08100a1012a8682baea1df29675f3a900bdac68 Mon Sep 17 00:00:00 2001 From: Joey Hines Date: Fri, 12 Oct 2018 11:03:06 -0500 Subject: [PATCH] Added a check to see if the target already had the 24 Karrat Trophy --- .../xyz/etztech/qol/commands/KaratTrophyCommand.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/xyz/etztech/qol/commands/KaratTrophyCommand.java b/src/main/java/xyz/etztech/qol/commands/KaratTrophyCommand.java index 695e6ee..322f95a 100644 --- a/src/main/java/xyz/etztech/qol/commands/KaratTrophyCommand.java +++ b/src/main/java/xyz/etztech/qol/commands/KaratTrophyCommand.java @@ -2,6 +2,7 @@ package xyz.etztech.qol.commands; import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.advancement.Advancement; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -34,11 +35,15 @@ public class KaratTrophyCommand implements CommandExecutor { } final Player player = argPlayer; - EtzTechUtil.sms(commandSender, ChatColor.GREEN + "Awarding 24 Karat Trophy to " + player.getName()); - NamespacedKey adv = new NamespacedKey("carrotcraft", "24_karat_trophy"); + Advancement adv = Bukkit.getAdvancement(new NamespacedKey("carrotcraft", "24_karat_trophy")); - player.getAdvancementProgress(Bukkit.getAdvancement(adv)).awardCriteria("win"); + if (!player.getAdvancementProgress(adv).isDone()) { + EtzTechUtil.sms(commandSender, ChatColor.GREEN + "Awarding 24 Karat Trophy to " + player.getName()); + player.getAdvancementProgress(adv).awardCriteria("win"); + } else { + EtzTechUtil.sms(commandSender, ChatColor.RED + player.getName() + " already has the 24 Karat Trophy"); + } return true; }