From bc59a8cdfb2eb552a56b3f74664c4c169a9fd917 Mon Sep 17 00:00:00 2001 From: Joey Hines Date: Fri, 12 Oct 2018 10:51:26 -0500 Subject: [PATCH] Added Karat Trophy command --- src/main/java/xyz/etztech/qol/QoL.java | 2 + .../qol/commands/KaratTrophyCommand.java | 45 +++++++++++++++++++ src/main/resources/plugin.yml | 6 +++ 3 files changed, 53 insertions(+) create mode 100644 src/main/java/xyz/etztech/qol/commands/KaratTrophyCommand.java diff --git a/src/main/java/xyz/etztech/qol/QoL.java b/src/main/java/xyz/etztech/qol/QoL.java index c84f8d8..532936e 100644 --- a/src/main/java/xyz/etztech/qol/QoL.java +++ b/src/main/java/xyz/etztech/qol/QoL.java @@ -97,6 +97,8 @@ public class QoL extends MavenPlugin { this.getCommand("worldinfo").setExecutor(worldInfoCommand); DeathMuteCommand deathMuteCommand = new DeathMuteCommand(this); this.getCommand("deathmute").setExecutor(deathMuteCommand); + KaratTrophyCommand karatTrophyCommand = new KaratTrophyCommand(this); + this.getCommand("karattrophy").setExecutor(karatTrophyCommand); if (getConfig().getStringList("list").size() > 0) { ListCommand listCommand = new ListCommand(this); diff --git a/src/main/java/xyz/etztech/qol/commands/KaratTrophyCommand.java b/src/main/java/xyz/etztech/qol/commands/KaratTrophyCommand.java new file mode 100644 index 0000000..a82f4b9 --- /dev/null +++ b/src/main/java/xyz/etztech/qol/commands/KaratTrophyCommand.java @@ -0,0 +1,45 @@ +package xyz.etztech.qol.commands; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.NamespacedKey; +import xyz.etztech.qol.EtzTechUtil; +import xyz.etztech.qol.Lang; +import xyz.etztech.qol.QoL; + +public class KaratTrophyCommand implements CommandExecutor { + + QoL plugin; + + public KaratTrophyCommand(QoL plugin) { + this.plugin = plugin; + } + + @Override + public boolean onCommand(CommandSender commandSender, Command command, String s, String args[]) { + if (!commandSender.hasPermission("qol.karat_trophy")) { + EtzTechUtil.sms(commandSender, Lang.NO_PERMISSION.getDef()); + return true; + } + + Player argPlayer = Bukkit.getPlayer(args[0]); + + if (argPlayer == null) { + EtzTechUtil.sms(commandSender, ChatColor.RED + "No player found."); + return true; + } + + final Player player = argPlayer; + EtzTechUtil.sms(commandSender, ChatColor.GREEN + "Awarding 24 Karat Trophy to " + player.getName()); + + NamespacedKey adv = new NamespacedKey("carrotcraft", "24_karat_trophy"); + + player.getAdvancementProgress(Bukkit.getAdvancement(adv)).awardCriteria("win"); + + return true; + } +} diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index c8672a2..ddb4f21 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -40,6 +40,8 @@ commands: description: Whitelist command timeout: description: Timeout command + karatTrophy: + description: karatTrophy permissions: qol.admin: description: Ability to reload the plugin @@ -71,6 +73,9 @@ permissions: qol.deathmute: description: Ability to use the Death Mute command default: op + qol.karatTrophy: + description: to use the Karat Trophy Command + default: op qol.auditable: description: Audits command usage default: op @@ -97,3 +102,4 @@ permissions: children: qol.timeout.bypass: true +