From 1ac1583f6b81f086eb22c49bca34bb65e61e690f Mon Sep 17 00:00:00 2001 From: Sean W Date: Tue, 1 Sep 2020 23:51:30 +0100 Subject: [PATCH] Added sound check. --- src/config.yml | 4 ++-- .../projectlinks/Listener/CommandListener.java | 9 ++++++++- src/me/sean0402/projectlinks/OOP/Command.java | 10 +++++----- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/config.yml b/src/config.yml index db630d3..2559145 100644 --- a/src/config.yml +++ b/src/config.yml @@ -6,12 +6,12 @@ Commands: discord: Cost: 100 - Delay: 10 + Cooldown: 10 Actions: - "[sendMessage] &7Discord link: &cDISCORD.COM" twitter: Cost: 100 - Delay: 10 + Cooldown: 10 Actions: - "[sendMessage] &7Twitter link: &cTWITTER.COM" - "[broadcast] &7Follow our twitter!" diff --git a/src/me/sean0402/projectlinks/Listener/CommandListener.java b/src/me/sean0402/projectlinks/Listener/CommandListener.java index 24b506d..9f72294 100644 --- a/src/me/sean0402/projectlinks/Listener/CommandListener.java +++ b/src/me/sean0402/projectlinks/Listener/CommandListener.java @@ -5,6 +5,7 @@ import me.sean0402.projectlinks.ProjectLinks; import me.sean0402.projectlinks.utils.Utils; import org.bukkit.Bukkit; +import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -28,7 +29,7 @@ public void onCommandSend(PlayerCommandPreprocessEvent e) { for (Command command : ProjectLinks.commandList) { if (message.equalsIgnoreCase(command.getCommandName())) { e.setCancelled(true); - if (!manager.tryCooldown(e.getPlayer().getUniqueId(), command.getDelay())) { + if (!manager.tryCooldown(e.getPlayer().getUniqueId(), command.getCooldown())) { e.getPlayer().sendMessage(Utils.colour(ProjectLinks.getInstance().getConfig().getString("Messages.onCooldown").replace("%remaining%", String.valueOf(manager.getTimeReamining(e.getPlayer()))))); return; } @@ -50,6 +51,12 @@ private void runActions(Player player, Command command) { Bukkit.dispatchCommand(player, action); } else if (prefix.startsWith("[console]")) { Bukkit.dispatchCommand(Bukkit.getConsoleSender(), action); + } else if (prefix.startsWith("[sound]")) { + try { + player.playSound(player.getLocation(), Sound.valueOf(action), 1f, 1f); + } catch (Exception e) { + Utils.sendConsoleMessage("&c" + action + " &cis not a valid sound!"); + } } } } diff --git a/src/me/sean0402/projectlinks/OOP/Command.java b/src/me/sean0402/projectlinks/OOP/Command.java index 34956fd..fed0687 100644 --- a/src/me/sean0402/projectlinks/OOP/Command.java +++ b/src/me/sean0402/projectlinks/OOP/Command.java @@ -10,13 +10,13 @@ public class Command { private final String commandName; - private final long delay; + private final long cooldown; private final double cost; private final List actions; - public Command(String commandName, long delay, double cost, List commands) { + public Command(String commandName, long cooldown, double cost, List commands) { this.commandName = commandName != null ? commandName : "Command invalid."; - this.delay = delay; + this.cooldown = cooldown; this.cost = cost; this.actions = commands != null ? commands : new ArrayList<>(); } @@ -25,8 +25,8 @@ public String getCommandName() { return commandName; } - public long getDelay() { - return delay; + public long getCooldown() { + return cooldown; } public double getCost() {