86 lines
2.6 KiB
Java
86 lines
2.6 KiB
Java
|
package xyz.etztech.qol.commands;
|
||
|
|
||
|
import org.bukkit.Bukkit;
|
||
|
import org.bukkit.ChatColor;
|
||
|
import org.bukkit.Location;
|
||
|
import org.bukkit.World;
|
||
|
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;
|
||
|
|
||
|
import java.util.HashMap;
|
||
|
import java.util.Map;
|
||
|
import java.util.concurrent.Executors;
|
||
|
import java.util.concurrent.ScheduledExecutorService;
|
||
|
import java.util.concurrent.TimeUnit;
|
||
|
import java.util.regex.Matcher;
|
||
|
import java.util.regex.Pattern;
|
||
|
|
||
|
public class ShadowMuteCommand implements CommandExecutor {
|
||
|
|
||
|
|
||
|
QoL plugin;
|
||
|
|
||
|
public ShadowMuteCommand(QoL paramQoL)
|
||
|
{
|
||
|
this.plugin = paramQoL;
|
||
|
}
|
||
|
|
||
|
@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 = null;
|
||
|
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
||
|
if (onlinePlayer.getName().equalsIgnoreCase(args[0])) {
|
||
|
argPlayer = onlinePlayer;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
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;
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|