From bc59a8cdfb2eb552a56b3f74664c4c169a9fd917 Mon Sep 17 00:00:00 2001 From: Joey Hines Date: Fri, 12 Oct 2018 10:51:26 -0500 Subject: [PATCH 1/4] 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 + From d59f8186daa60daf6a4d3f104899bbb0b562e595 Mon Sep 17 00:00:00 2001 From: Joey Hines Date: Fri, 12 Oct 2018 10:52:29 -0500 Subject: [PATCH 2/4] fixed perm for KaratTrophy --- src/main/java/xyz/etztech/qol/commands/KaratTrophyCommand.java | 2 +- src/main/resources/plugin.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/xyz/etztech/qol/commands/KaratTrophyCommand.java b/src/main/java/xyz/etztech/qol/commands/KaratTrophyCommand.java index a82f4b9..695e6ee 100644 --- a/src/main/java/xyz/etztech/qol/commands/KaratTrophyCommand.java +++ b/src/main/java/xyz/etztech/qol/commands/KaratTrophyCommand.java @@ -21,7 +21,7 @@ public class KaratTrophyCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender commandSender, Command command, String s, String args[]) { - if (!commandSender.hasPermission("qol.karat_trophy")) { + if (!commandSender.hasPermission("qol.karattrophy")) { EtzTechUtil.sms(commandSender, Lang.NO_PERMISSION.getDef()); return true; } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index ddb4f21..80d97fa 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -73,7 +73,7 @@ permissions: qol.deathmute: description: Ability to use the Death Mute command default: op - qol.karatTrophy: + qol.karattrophy: description: to use the Karat Trophy Command default: op qol.auditable: From a08100a1012a8682baea1df29675f3a900bdac68 Mon Sep 17 00:00:00 2001 From: Joey Hines Date: Fri, 12 Oct 2018 11:03:06 -0500 Subject: [PATCH 3/4] 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; } From 7180b0982bcba8b2055cdaddfad323717986e255 Mon Sep 17 00:00:00 2001 From: Joey Hines Date: Fri, 12 Oct 2018 11:09:47 -0500 Subject: [PATCH 4/4] updated description for karattrophy --- src/main/resources/plugin.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 80d97fa..1456734 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -40,8 +40,9 @@ commands: description: Whitelist command timeout: description: Timeout command - karatTrophy: - description: karatTrophy + karattrophy: + description: 24 karat trophy command + aliases: [trophy] permissions: qol.admin: description: Ability to reload the plugin