2016-03-02 19:28:01 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.command;
|
2013-05-15 12:56:23 +00:00
|
|
|
|
2015-11-15 23:32:04 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.banning.Ban;
|
2016-03-06 15:56:15 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
2015-10-19 17:43:46 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
2016-05-12 19:40:39 +00:00
|
|
|
import org.apache.commons.lang.StringUtils;
|
2013-05-15 12:56:23 +00:00
|
|
|
import org.bukkit.ChatColor;
|
2013-12-22 22:20:31 +00:00
|
|
|
import org.bukkit.Location;
|
2013-05-15 12:56:23 +00:00
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
2016-03-06 15:56:15 +00:00
|
|
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
2016-05-12 19:40:39 +00:00
|
|
|
@CommandParameters(description = "Temporarily bans a player for five minutes.", usage = "/<command> <player> [reason]", aliases = "noob")
|
2015-10-19 17:43:46 +00:00
|
|
|
public class Command_tban extends FreedomCommand
|
2013-07-02 18:31:22 +00:00
|
|
|
{
|
2015-11-22 18:26:47 +00:00
|
|
|
|
2013-05-15 12:56:23 +00:00
|
|
|
@Override
|
2015-11-22 18:26:47 +00:00
|
|
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
2013-05-15 12:56:23 +00:00
|
|
|
{
|
2016-05-12 19:40:39 +00:00
|
|
|
if (args.length < 1)
|
2013-05-15 12:56:23 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-04-26 11:55:24 +00:00
|
|
|
final Player player = getPlayer(args[0]);
|
2014-05-04 21:03:34 +00:00
|
|
|
|
2014-04-26 11:55:24 +00:00
|
|
|
if (player == null)
|
2013-05-15 12:56:23 +00:00
|
|
|
{
|
2016-03-02 19:28:01 +00:00
|
|
|
msg(FreedomCommand.PLAYER_NOT_FOUND, ChatColor.RED);
|
2013-05-15 12:56:23 +00:00
|
|
|
return true;
|
|
|
|
}
|
2014-01-14 19:37:08 +00:00
|
|
|
|
2016-05-12 19:40:39 +00:00
|
|
|
String reason;
|
|
|
|
if (args.length > 1)
|
|
|
|
{
|
|
|
|
reason = StringUtils.join(args, " ", 1, args.length);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
reason = "You have been temporarily banned for 5 minutes.";
|
|
|
|
}
|
|
|
|
|
2013-12-22 22:20:31 +00:00
|
|
|
// strike with lightning effect:
|
|
|
|
final Location targetPos = player.getLocation();
|
|
|
|
for (int x = -1; x <= 1; x++)
|
|
|
|
{
|
|
|
|
for (int z = -1; z <= 1; z++)
|
|
|
|
{
|
|
|
|
final Location strike_pos = new Location(targetPos.getWorld(), targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z);
|
2017-11-16 22:32:09 +00:00
|
|
|
targetPos.getWorld().strikeLightningEffect(strike_pos);
|
2013-12-22 22:20:31 +00:00
|
|
|
}
|
|
|
|
}
|
2013-05-15 12:56:23 +00:00
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
FUtil.adminAction(sender.getName(), "Tempbanning: " + player.getName() + " for 5 minutes.", true);
|
2016-05-12 19:40:39 +00:00
|
|
|
plugin.bm.addBan(Ban.forPlayer(player, sender, FUtil.parseDateOffset("5m"), reason));
|
2014-06-29 08:53:39 +00:00
|
|
|
|
2013-08-15 21:44:09 +00:00
|
|
|
player.kickPlayer(ChatColor.RED + "You have been temporarily banned for five minutes. Please read totalfreedom.me for more info.");
|
2013-05-15 12:56:23 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|