From 7718f5416780261a137abe2ab86742511579bf7b Mon Sep 17 00:00:00 2001 From: Etzelia Date: Fri, 28 Sep 2018 23:15:05 -0500 Subject: [PATCH 1/9] Updated to EtzCore 1.3 Changed Maven Dependencies --- pom.xml | 8 +------- src/main/java/xyz/etztech/qol/QoL.java | 3 --- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index 592f269..dc17c88 100644 --- a/pom.xml +++ b/pom.xml @@ -37,7 +37,7 @@ xyz.etztech EtzCore - 1.2 + 1.3 compile @@ -58,12 +58,6 @@ 2.6 provided - - org.apache.httpcomponents - httpclient - 4.5.5 - provided - diff --git a/src/main/java/xyz/etztech/qol/QoL.java b/src/main/java/xyz/etztech/qol/QoL.java index 7c567b8..16deff9 100644 --- a/src/main/java/xyz/etztech/qol/QoL.java +++ b/src/main/java/xyz/etztech/qol/QoL.java @@ -15,12 +15,9 @@ import java.util.ArrayList; import java.util.List; import java.util.logging.Logger; -@MavenLibrary(group = "org.apache.httpcomponents", artifact = "httpcore", version = "4.4.9") -@MavenLibrary(group = "org.apache.httpcomponents", artifact = "httpclient", version = "4.5.5") @MavenLibrary(group = "net.ess3", artifact = "Essentials", version = "2.13.1", repository = "http://repo.ess3.net/content/groups/essentials") @MavenLibrary(group = "us.dynmap", artifact = "dynmap-api", version = "1.9.4", repository = "http://repo.mikeprimm.com/") @MavenLibrary(group = "commons-lang", artifact = "commons-lang", version = "2.6") -@MavenLibrary(group = "commons-logging", artifact = "commons-logging", version = "1.2") public class QoL extends MavenPlugin { private static QoL instance; From 55c1c92ea1713538a924fc6e81879b217f9c7b14 Mon Sep 17 00:00:00 2001 From: Etzelia Date: Mon, 8 Oct 2018 18:31:13 +0200 Subject: [PATCH 2/9] Updated EtzCore to 1.0.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index dc17c88..085cf1a 100644 --- a/pom.xml +++ b/pom.xml @@ -37,7 +37,7 @@ xyz.etztech EtzCore - 1.3 + 1.0.4 compile From 1a03c2fc720ddc989704b9e6a69dea3f86cfbea7 Mon Sep 17 00:00:00 2001 From: Joey Hines Date: Tue, 9 Oct 2018 16:50:22 -0500 Subject: [PATCH 3/9] Added death mute command --- src/main/java/xyz/etztech/qol/QoL.java | 16 ++++-- .../qol/commands/DeathMuteCommand.java | 56 +++++++++++++++++++ .../etztech/qol/listeners/DeathListener.java | 15 +++-- src/main/resources/plugin.yml | 6 ++ 4 files changed, 83 insertions(+), 10 deletions(-) create mode 100644 src/main/java/xyz/etztech/qol/commands/DeathMuteCommand.java diff --git a/src/main/java/xyz/etztech/qol/QoL.java b/src/main/java/xyz/etztech/qol/QoL.java index 16deff9..18f78c7 100644 --- a/src/main/java/xyz/etztech/qol/QoL.java +++ b/src/main/java/xyz/etztech/qol/QoL.java @@ -13,6 +13,7 @@ import xyz.etztech.qol.other.TPSRunnable; import java.util.ArrayList; import java.util.List; +import java.util.UUID; import java.util.logging.Logger; @MavenLibrary(group = "net.ess3", artifact = "Essentials", version = "2.13.1", repository = "http://repo.ess3.net/content/groups/essentials") @@ -28,6 +29,7 @@ public class QoL extends MavenPlugin { private Logger log = Logger.getLogger( "Minecraft" ); private static List mutes = new ArrayList<>(); + private static List deathMutes = new ArrayList<>(); private static boolean whitelist = false; private static boolean timeout = false; private static List audits = new ArrayList<>(); @@ -93,6 +95,8 @@ public class QoL extends MavenPlugin { this.getCommand("colors").setExecutor(colorsCommand); WorldInfoCommand worldInfoCommand = new WorldInfoCommand(this); this.getCommand("worldinfo").setExecutor(worldInfoCommand); + DeathMuteCommand deathMuteCommand = new DeathMuteCommand(this); + this.getCommand("deathmute").setExecutor(deathMuteCommand); if (getConfig().getStringList("list").size() > 0) { ListCommand listCommand = new ListCommand(this); @@ -218,12 +222,16 @@ public class QoL extends MavenPlugin { } } - - - public static boolean hasSM(Player player) { - return mutes.contains(player.getUniqueId().toString()); + public static void addDeathMute(Player player) { + deathMutes.add(player.getUniqueId()); } + + + public static boolean hasSM(Player player) { return mutes.contains(player.getUniqueId().toString()); } + + public static boolean hasDeathMute(Player player) { return deathMutes.contains(player.getUniqueId()); } + public static void removeSM(Player player) { mutes.remove(player.getUniqueId().toString()); } diff --git a/src/main/java/xyz/etztech/qol/commands/DeathMuteCommand.java b/src/main/java/xyz/etztech/qol/commands/DeathMuteCommand.java new file mode 100644 index 0000000..381f628 --- /dev/null +++ b/src/main/java/xyz/etztech/qol/commands/DeathMuteCommand.java @@ -0,0 +1,56 @@ +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 xyz.etztech.qol.EtzTechUtil; +import xyz.etztech.qol.Lang; +import xyz.etztech.qol.QoL; + +public class DeathMuteCommand implements CommandExecutor { + + QoL plugin; + + public DeathMuteCommand(QoL paramQoL) + { + this.plugin = paramQoL; + } + + @Override + public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) { + if (!commandSender.hasPermission("qol.deathmute")) { + EtzTechUtil.sms(commandSender, Lang.NO_PERMISSION.getDef()); + return true; + } + + if (args.length < 1) { + EtzTechUtil.sms(commandSender, ChatColor.RED + "/dm "); + return true; + } + + Player argPlayer = null; + for (Player onlinePlayer : Bukkit.getOnlinePlayers()) { + if (onlinePlayer.getName().equalsIgnoreCase(args[0])) { + argPlayer = onlinePlayer; + } + } + + if (argPlayer == null) { + EtzTechUtil.sms(commandSender, ChatColor.RED + "No player found."); + return true; + } + final Player player = argPlayer; + + + EtzTechUtil.sms(commandSender, ChatColor.GREEN + "Death Muting " + ChatColor.YELLOW + + player.getName()); + + QoL.addDeathMute(player); + return true; + } + + +} diff --git a/src/main/java/xyz/etztech/qol/listeners/DeathListener.java b/src/main/java/xyz/etztech/qol/listeners/DeathListener.java index c958dae..116db78 100644 --- a/src/main/java/xyz/etztech/qol/listeners/DeathListener.java +++ b/src/main/java/xyz/etztech/qol/listeners/DeathListener.java @@ -26,16 +26,19 @@ public class DeathListener implements Listener { @EventHandler public void onDeath(PlayerDeathEvent event) { String message = event.getDeathMessage(); + event.setDeathMessage(""); - Location location = event.getEntity().getLocation(); - String coords = StringUtils.join(Arrays.asList(location.getBlockX(), location.getBlockY(), location.getBlockZ()), ", "); + if (!plugin.hasDeathMute(event.getEntity().getPlayer())) { + Location location = event.getEntity().getLocation(); + String coords = StringUtils.join(Arrays.asList(location.getBlockX(), location.getBlockY(), location.getBlockZ()), ", "); - TextComponent newMessage = new TextComponent(message); - newMessage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Location: " + coords).create())); + TextComponent newMessage = new TextComponent(message); + newMessage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Location: " + coords).create())); - for (Player player : Bukkit.getOnlinePlayers()) { - player.spigot().sendMessage(newMessage); + for (Player player : Bukkit.getOnlinePlayers()) { + player.spigot().sendMessage(newMessage); + } } } } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 05091c3..c8672a2 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -33,6 +33,9 @@ commands: shadowmute: description: Shadow Mute command aliases: [sm] + deathmute: + description: Death mute command + aliases: [dm] whitelist: description: Whitelist command timeout: @@ -65,6 +68,9 @@ permissions: qol.shadowmute: description: Ability to use the Shadow Mute command default: op + qol.deathmute: + description: Ability to use the Death Mute command + default: op qol.auditable: description: Audits command usage default: op From 2f54beb84550b4999b349b4c38a3a16db8f33d0d Mon Sep 17 00:00:00 2001 From: Joey Hines Date: Tue, 9 Oct 2018 17:21:38 -0500 Subject: [PATCH 4/9] Changed Mutes to use UUIDs instead of strings of UUIDs. Also used Bukkit.getPlayer() in both ShadowMute and DeathMute. --- src/main/java/xyz/etztech/qol/QoL.java | 18 ++++++++++-------- .../etztech/qol/commands/DeathMuteCommand.java | 9 ++------- .../qol/commands/ShadowMuteCommand.java | 10 ++++------ 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/src/main/java/xyz/etztech/qol/QoL.java b/src/main/java/xyz/etztech/qol/QoL.java index 18f78c7..c84f8d8 100644 --- a/src/main/java/xyz/etztech/qol/QoL.java +++ b/src/main/java/xyz/etztech/qol/QoL.java @@ -28,7 +28,7 @@ public class QoL extends MavenPlugin { public static FileConfiguration config; private Logger log = Logger.getLogger( "Minecraft" ); - private static List mutes = new ArrayList<>(); + private static List mutes = new ArrayList<>(); private static List deathMutes = new ArrayList<>(); private static boolean whitelist = false; private static boolean timeout = false; @@ -217,23 +217,25 @@ public class QoL extends MavenPlugin { } public static void addSM(Player player) { - if (!mutes.contains(player.getUniqueId().toString())) { - mutes.add(player.getUniqueId().toString()); + if (!mutes.contains(player.getUniqueId())) { + mutes.add(player.getUniqueId()); } } public static void addDeathMute(Player player) { - deathMutes.add(player.getUniqueId()); + if (!deathMutes.contains(player.getUniqueId())) { + deathMutes.add(player.getUniqueId()); + } } - - - public static boolean hasSM(Player player) { return mutes.contains(player.getUniqueId().toString()); } + public static boolean hasSM(Player player) { + return mutes.contains(player.getUniqueId()); + } public static boolean hasDeathMute(Player player) { return deathMutes.contains(player.getUniqueId()); } public static void removeSM(Player player) { - mutes.remove(player.getUniqueId().toString()); + mutes.remove(player.getUniqueId()); } public static boolean getWhitelist() { diff --git a/src/main/java/xyz/etztech/qol/commands/DeathMuteCommand.java b/src/main/java/xyz/etztech/qol/commands/DeathMuteCommand.java index 381f628..d885c56 100644 --- a/src/main/java/xyz/etztech/qol/commands/DeathMuteCommand.java +++ b/src/main/java/xyz/etztech/qol/commands/DeathMuteCommand.java @@ -31,19 +31,14 @@ public class DeathMuteCommand implements CommandExecutor { return true; } - Player argPlayer = null; - for (Player onlinePlayer : Bukkit.getOnlinePlayers()) { - if (onlinePlayer.getName().equalsIgnoreCase(args[0])) { - argPlayer = onlinePlayer; - } - } + Player argPlayer = Bukkit.getPlayer(args[0]); if (argPlayer == null) { EtzTechUtil.sms(commandSender, ChatColor.RED + "No player found."); return true; } - final Player player = argPlayer; + final Player player = argPlayer; EtzTechUtil.sms(commandSender, ChatColor.GREEN + "Death Muting " + ChatColor.YELLOW + player.getName()); diff --git a/src/main/java/xyz/etztech/qol/commands/ShadowMuteCommand.java b/src/main/java/xyz/etztech/qol/commands/ShadowMuteCommand.java index 1e52dab..613ea97 100644 --- a/src/main/java/xyz/etztech/qol/commands/ShadowMuteCommand.java +++ b/src/main/java/xyz/etztech/qol/commands/ShadowMuteCommand.java @@ -8,11 +8,13 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.omg.CORBA.TypeCodePackage.BadKind; import xyz.etztech.qol.EtzTechUtil; import xyz.etztech.qol.Lang; import xyz.etztech.qol.QoL; import xyz.etztech.qol.other.ShadowMuteTime; +import java.io.BufferedReader; import java.util.HashMap; import java.util.Map; import java.util.concurrent.Executors; @@ -44,17 +46,13 @@ public class ShadowMuteCommand implements CommandExecutor { return true; } - Player argPlayer = null; - for (Player onlinePlayer : Bukkit.getOnlinePlayers()) { - if (onlinePlayer.getName().equalsIgnoreCase(args[0])) { - argPlayer = onlinePlayer; - } - } + Player argPlayer = Bukkit.getPlayer(args[0]); if (argPlayer == null) { EtzTechUtil.sms(commandSender, ChatColor.RED + "No player found."); return true; } + final Player player = argPlayer; ShadowMuteTime smt; From ed7cbbc6a094459ab4b4aaca5304dd184c4d9ed8 Mon Sep 17 00:00:00 2001 From: Joey Hines Date: Tue, 9 Oct 2018 18:09:40 -0500 Subject: [PATCH 5/9] Cleaned up imports --- .../xyz/etztech/qol/commands/ShadowMuteCommand.java | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/main/java/xyz/etztech/qol/commands/ShadowMuteCommand.java b/src/main/java/xyz/etztech/qol/commands/ShadowMuteCommand.java index 613ea97..160f75c 100644 --- a/src/main/java/xyz/etztech/qol/commands/ShadowMuteCommand.java +++ b/src/main/java/xyz/etztech/qol/commands/ShadowMuteCommand.java @@ -2,27 +2,15 @@ package xyz.etztech.qol.commands; import org.bukkit.Bukkit; import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.World; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import org.omg.CORBA.TypeCodePackage.BadKind; import xyz.etztech.qol.EtzTechUtil; import xyz.etztech.qol.Lang; import xyz.etztech.qol.QoL; import xyz.etztech.qol.other.ShadowMuteTime; -import java.io.BufferedReader; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - public class ShadowMuteCommand implements CommandExecutor { From bc59a8cdfb2eb552a56b3f74664c4c169a9fd917 Mon Sep 17 00:00:00 2001 From: Joey Hines Date: Fri, 12 Oct 2018 10:51:26 -0500 Subject: [PATCH 6/9] 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 7/9] 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 8/9] 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 9/9] 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