-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compat for 1.19, move NMS code to bukkitreflectionutil
- Loading branch information
1 parent
6e419b1
commit f57edf8
Showing
4 changed files
with
95 additions
and
255 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/main/java/dev/array21/harotorch/commands/CommandCooldown.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package dev.array21.harotorch.commands; | ||
|
||
import dev.array21.harotorch.HaroTorch; | ||
import dev.array21.harotorch.lang.LangHandler; | ||
import net.md_5.bungee.api.ChatColor; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
|
||
import java.util.HashMap; | ||
import java.util.UUID; | ||
|
||
public class CommandCooldown { | ||
public static boolean checkCommandCooldown(HaroTorch plugin, CommandSender sender, HashMap<UUID, Long> lastCommandTimestamps) { | ||
Integer commandCooldown = plugin.getConfigManifest().commandCooldown; | ||
if(commandCooldown != null && commandCooldown > 0) { | ||
Long lastCommandUseTimestamp = lastCommandTimestamps.get(((Player) sender).getUniqueId()); | ||
if(lastCommandUseTimestamp != null) { | ||
if(lastCommandUseTimestamp >= System.currentTimeMillis()) { | ||
sender.sendMessage(HaroTorch.getMessagePrefix() + ChatColor.GOLD + LangHandler.activeLang.getLangMessages().get("commandCooldown")); | ||
return true; | ||
} | ||
} | ||
|
||
lastCommandTimestamps.put(((Player) sender).getUniqueId(), System.currentTimeMillis() + (commandCooldown * 1000)); | ||
} | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.