72 lines
2.2 KiB
Java
72 lines
2.2 KiB
Java
package xyz.etztech.qol.commands;
|
|
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.ChatColor;
|
|
import org.bukkit.command.Command;
|
|
import org.bukkit.command.CommandExecutor;
|
|
import org.bukkit.command.CommandSender;
|
|
import org.bukkit.entity.Player;
|
|
import xyz.etztech.qol.EtzTechUtil;
|
|
import xyz.etztech.qol.Lang;
|
|
import xyz.etztech.qol.QoL;
|
|
import xyz.etztech.qol.other.ShadowMuteTime;
|
|
|
|
public class ShadowMuteCommand implements CommandExecutor {
|
|
|
|
|
|
QoL plugin;
|
|
|
|
public ShadowMuteCommand(QoL paramQoL) {
|
|
this.plugin = paramQoL;
|
|
plugin.getCommand("shadowmute").setExecutor(this);
|
|
}
|
|
|
|
@Override
|
|
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) {
|
|
if (!commandSender.hasPermission("qol.shadowmute")) {
|
|
EtzTechUtil.sms(commandSender, Lang.NO_PERMISSION.getDef());
|
|
return true;
|
|
}
|
|
|
|
if (args.length < 2) {
|
|
EtzTechUtil.sms(commandSender, ChatColor.RED + "/sm <player> <time>");
|
|
EtzTechUtil.sms(commandSender, ChatColor.RED + "Time Format: 1h2m3s (1 hour, 2 minutes, and 3 seconds)");
|
|
return true;
|
|
}
|
|
|
|
Player argPlayer = Bukkit.getPlayer(args[0]);
|
|
|
|
if (argPlayer == null) {
|
|
EtzTechUtil.sms(commandSender, ChatColor.RED + "No player found.");
|
|
return true;
|
|
}
|
|
|
|
final Player player = argPlayer;
|
|
|
|
ShadowMuteTime smt;
|
|
try {
|
|
smt = ShadowMuteTime.parse(args[1]);
|
|
} catch (Exception ex) {
|
|
smt = new ShadowMuteTime();
|
|
commandSender.sendMessage(ChatColor.RED + ex.getMessage());
|
|
}
|
|
|
|
EtzTechUtil.sms(commandSender, ChatColor.GREEN + "Shadow Muting " + ChatColor.YELLOW +
|
|
player.getName() + ChatColor.GREEN + " for " + ChatColor.YELLOW + smt.toString());
|
|
QoL.addSM(player);
|
|
|
|
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
|
|
@Override
|
|
public void run() {
|
|
Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "Removing Shadow Mute for " + ChatColor.YELLOW + player.getName());
|
|
QoL.removeSM(player);
|
|
}
|
|
}, smt.toTicks());
|
|
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
}
|