Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.techresx.plugins.meow;
- import java.util.HashMap;
- import org.bukkit.ChatColor;
- import org.bukkit.Sound;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- import org.bukkit.plugin.java.JavaPlugin;
- public class meow extends JavaPlugin {
- private static final String prefix = "[Meow] ";
- private static Integer cooldownInSeconds = 30;
- private HashMap<String, Long> cooldown = new HashMap<String,Long>();
- public void onEnable() {
- loadConfiguration();
- System.out.println(prefix + "has been loaded.");
- }
- public void loadConfiguration(){
- getConfig().addDefault("CooldownInSeconds", 30);
- getConfig().options().copyDefaults(true);
- saveConfig();
- cooldownInSeconds = getConfig().getInt("CooldownInSeconds");
- }
- @Override
- public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
- {
- if(label.equalsIgnoreCase("meow")) {
- if(cooldown.containsKey(sender.getName()))
- {
- Long lastUse = cooldown.get(sender.getName());
- Long diff = System.currentTimeMillis() - lastUse;
- if(diff <= cooldownInSeconds * 1000)
- {
- sender.sendMessage(ChatColor.GOLD + prefix + ChatColor.RED + "Please wait " + Long.toString(cooldownInSeconds - (diff / 1000), 0) + " seconds to use this command again");
- return true;
- }
- }
- boolean self = false;
- if(args.length != 1)
- {
- self = true;
- }
- else if (!sender.getName().equalsIgnoreCase(args[0]))
- {
- Player p = getServer().getPlayer(args[0]);
- if(p != null && p.isOnline())
- {
- p.playSound(p.getLocation(), Sound.CAT_MEOW, 1, 0);
- p.sendMessage(ChatColor.GOLD + prefix + ChatColor.LIGHT_PURPLE + "You have been meow'd by " + sender.getName());
- cooldown.put(sender.getName(), System.currentTimeMillis());
- }
- else
- {
- sender.sendMessage(ChatColor.GOLD + prefix + ChatColor.RED + "Player is not online");
- }
- }
- else
- self = true;
- if(self)
- {
- sender.sendMessage(ChatColor.RED + "Don't meow yourself fool! Do /meow <player>");
- }
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement