2013-09-12 04:42:27 +02:00
|
|
|
package com.gmail.nossr50.commands.player;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.command.TabExecutor;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
import com.gmail.nossr50.config.Config;
|
2013-10-28 20:12:24 +01:00
|
|
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
2013-09-12 04:42:27 +02:00
|
|
|
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
|
|
|
import com.gmail.nossr50.locale.LocaleLoader;
|
|
|
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
|
|
|
import com.gmail.nossr50.util.player.UserManager;
|
|
|
|
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
2013-10-31 22:30:05 +01:00
|
|
|
|
2013-09-12 04:42:27 +02:00
|
|
|
import com.google.common.collect.ImmutableList;
|
|
|
|
|
|
|
|
public class MccooldownCommand implements TabExecutor {
|
|
|
|
@Override
|
|
|
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
|
|
if (CommandUtils.noConsoleUsage(sender)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (args.length) {
|
|
|
|
case 0:
|
|
|
|
Player player = (Player) sender;
|
|
|
|
|
|
|
|
if (Config.getInstance().getCooldownUseBoard()) {
|
|
|
|
ScoreboardManager.enablePlayerCooldownScoreboard(player);
|
2013-10-28 18:04:06 +01:00
|
|
|
|
|
|
|
if (!Config.getInstance().getCooldownUseChat()) {
|
|
|
|
return true;
|
|
|
|
}
|
2013-09-12 04:42:27 +02:00
|
|
|
}
|
|
|
|
|
2013-10-28 20:12:24 +01:00
|
|
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
2013-09-12 04:42:27 +02:00
|
|
|
|
|
|
|
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Header"));
|
|
|
|
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
|
|
|
|
|
2013-11-22 18:32:23 +01:00
|
|
|
for (AbilityType ability : AbilityType.values()) {
|
2013-10-28 18:04:06 +01:00
|
|
|
if (!ability.getPermissions(player)) {
|
2013-09-12 04:42:27 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-10-28 20:12:24 +01:00
|
|
|
int seconds = mcMMOPlayer.calculateTimeRemaining(ability);
|
2013-09-12 04:42:27 +02:00
|
|
|
|
|
|
|
if (seconds <= 0) {
|
2013-10-28 18:04:06 +01:00
|
|
|
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.Y", ability.getName()));
|
2013-09-12 04:42:27 +02:00
|
|
|
}
|
|
|
|
else {
|
2013-10-28 18:04:06 +01:00
|
|
|
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.N", ability.getName(), seconds));
|
2013-09-12 04:42:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
|
|
|
return ImmutableList.of();
|
|
|
|
}
|
|
|
|
}
|