Added a check to see if the target already had the 24 Karrat Trophy

master
Joey Hines 2018-10-12 11:03:06 -05:00
parent d59f8186da
commit a08100a101
1 changed files with 8 additions and 3 deletions

View File

@ -2,6 +2,7 @@ package xyz.etztech.qol.commands;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.advancement.Advancement;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -34,11 +35,15 @@ public class KaratTrophyCommand implements CommandExecutor {
} }
final Player player = argPlayer; 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; return true;
} }