Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* */ package me.zdqnilo.basic.commands;
- /* */
- /* */ import java.util.HashMap;
- /* */ import java.util.Map;
- /* */ import java.util.UUID;
- /* */ import org.apache.commons.lang.StringUtils;
- /* */ import org.apache.commons.lang.time.DurationFormatUtils;
- /* */ import org.bukkit.Bukkit;
- /* */ import org.bukkit.Server;
- /* */ import org.bukkit.command.Command;
- /* */ import org.bukkit.command.CommandExecutor;
- /* */ import org.bukkit.command.CommandSender;
- /* */ import org.bukkit.entity.Player;
- /* */ import me.zdqnilo.basic.Basic;
- /* */ import me.zdqnilo.basic.listeners.StaffModeListener;
- /* */ import me.zdqnilo.basic.useful.ColorUtils;
- /* */ import me.zdqnilo.basic.useful.FancyMessage;
- /* */ import me.zdqnilo.basic.useful.TimeUtils;
- /* */
- /* */ public class ReportCommand implements CommandExecutor
- /* */ {
- /* 22 */ private final Basic basic = Basic.getInstance();
- /* */
- /* 24 */ private final Map<UUID, Long> report = new HashMap();
- private Map<Player, Integer> reportTimes = new HashMap<Player, Integer>();
- /* */
- /* */ public void setCooldown(Player player, long value)
- /* */ {
- /* 28 */ this.report.put(player.getUniqueId(), Long.valueOf(System.currentTimeMillis() + value));
- /* */ }
- /* */
- /* */ public void removeCooldown(Player player)
- /* */ {
- /* 33 */ if (isCooldownActive(player))
- /* */ {
- /* 35 */ this.report.remove(player.getUniqueId());
- /* */ }
- /* */ }
- /* */
- /* */ public boolean isCooldownActive(Player player)
- /* */ {
- /* 41 */ if (!this.report.containsKey(player.getUniqueId()))
- /* */ {
- /* 43 */ return false;
- /* */ }
- /* 45 */ return ((Long)this.report.get(player.getUniqueId())).longValue() > System.currentTimeMillis();
- /* */ }
- /* */
- /* */ public long getMillisecondLeft(Player player)
- /* */ {
- /* 50 */ if (!isCooldownActive(player))
- /* */ {
- /* 52 */ return -1L;
- /* */ }
- /* 54 */ return ((Long)this.report.get(player.getUniqueId())).longValue() - System.currentTimeMillis();
- /* */ }
- /* */
- /* */
- /* */ public boolean onCommand(CommandSender sender, Command command, String label, String[] arguments)
- /* */ {
- /* 60 */ if ((sender instanceof Player))
- /* */ {
- /* 62 */ Player player = (Player)sender;
- /* 63 */ if (arguments.length < 2)
- /* */ {
- /* 65 */ player.sendMessage(new ColorUtils().translateFromString("&cUsage: /" + label + " <playerName> <reason>"));
- /* 66 */ return true;
- /* */ }
- /* */
- /* 69 */ Player target = Bukkit.getServer().getPlayerExact(arguments[0]);
- /* 70 */ if ((target == null) || (this.basic.getStaffModeListener().isStaffModeActive(target)) || (this.basic.getStaffModeListener().isVanished(target)))
- /* */ {
- /* 72 */ player.sendMessage(new ColorUtils().translateFromString("&cPlayer named '" + arguments[0] + "' not found."));
- /* */
- /* */
- /* */ }
- /* 76 */ else if (target.equals(player))
- /* */ {
- /* 78 */ player.sendMessage(new ColorUtils().translateFromString("&cYou can not report yourself."));
- /* */
- /* */
- /* */ }
- /* 82 */ else if (isCooldownActive(player))
- /* */ {
- /* 84 */ player.sendMessage(new ColorUtils().translateFromString("&cYou can not report other player again for &6" + DurationFormatUtils.formatDurationWords(getMillisecondLeft(player), true, true) + "&c."));
- /* */ }
- /* */ else
- /* */ {
- /* 88 */ setCooldown(player, TimeUtils.parse("1m"));
- /* 89 */ for (Player staff : Bukkit.getServer().getOnlinePlayers())
- /* */ {
- /* 91 */ if (staff.hasPermission("basic.p.staff"))
- /* */ {
- /* 93 */ FancyMessage fancyMessage = new FancyMessage("");
- /* 94 */ fancyMessage.then(new ColorUtils().translateFromString("&7[&c&lReport&7] &7[Practice] &d" + target.getName() + "&7" + reportTimes + " &7reported by &d" + player.getName() + " &efor &e" + StringUtils.join(arguments, ' ', 1, arguments.length) + "&e."));
- /* 95 */ fancyMessage.tooltip(new ColorUtils().translateFromString("&aClick to teleport to " + target.getName()));
- /* 96 */ fancyMessage.command("/teleport " + target.getName());
- /* 97 */ fancyMessage.send(staff);
- /* */ }
- /* */ }
- /* 100 */ player.sendMessage(new ColorUtils().translateFromString("&eSucessfully reported the player &9" + target.getName() + " &afor &e" + StringUtils.join(arguments, ' ', 1, arguments.length) + "&e, report sent to all online staff members."));
- /* */ }
- /* */
- /* */
- /* */ }
- /* */ else
- /* */ {
- /* 107 */ sender.sendMessage(new ColorUtils().translateFromString("&cYou can not execute this command on console."));
- /* */ }
- /* 109 */ return true;
- /* */ }
- /* */ }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement