From 9e43d7ff258184247403dc20d0de0142e98389c5 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Wed, 4 Nov 2020 18:59:20 +1300 Subject: [PATCH] Add cooldown for uploadlogs command --- .../commands/libsdisguises/LDUploadLogs.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDUploadLogs.java b/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDUploadLogs.java index 39cb2819..32134258 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDUploadLogs.java +++ b/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDUploadLogs.java @@ -21,11 +21,14 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedList; import java.util.List; +import java.util.concurrent.TimeUnit; /** * Created by libraryaddict on 18/06/2020. */ public class LDUploadLogs implements LDCommand { + private long lastUsed; + /** * Small modification of https://gist.github.com/jamezrin/12de49643d7be7150da362e86407113f */ @@ -116,6 +119,13 @@ public class LDUploadLogs implements LDCommand { @Override public void onCommand(CommandSender sender, String[] args) { + if (lastUsed + TimeUnit.MINUTES.toMillis(3) < System.currentTimeMillis()) { + sender.sendMessage(ChatColor.RED + + "You last used this command under 3 minutes ago! Restart the server or wait for this timer to " + + "disappear!"); + return; + } + File latest = new File("logs/latest.log"); File disguises = new File(LibsDisguises.getInstance().getDataFolder(), "disguises.yml"); File config = new File(LibsDisguises.getInstance().getDataFolder(), "config.yml"); @@ -197,6 +207,8 @@ public class LDUploadLogs implements LDCommand { URL configPaste = new GuestPaste("LibsDisguises config.yml", configText.toString()).paste(); URL disguisesPaste = new GuestPaste("LibsDisguises disguises.yml", disguiseText).paste(); + lastUsed = System.currentTimeMillis(); + new BukkitRunnable() { @Override public void run() {