mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-20 15:35:08 +00:00
53 lines
1.3 KiB
Java
53 lines
1.3 KiB
Java
![]() |
package com.earth2me.essentials.commands;
|
||
|
|
||
|
import org.bukkit.Server;
|
||
|
import org.bukkit.command.CommandSender;
|
||
|
import org.bukkit.craftbukkit.CraftServer;
|
||
|
import com.earth2me.essentials.Essentials;
|
||
|
import com.earth2me.essentials.User;
|
||
|
import com.earth2me.essentials.Util;
|
||
|
|
||
|
|
||
|
public class Commandtempban extends EssentialsCommand
|
||
|
{
|
||
|
public Commandtempban()
|
||
|
{
|
||
|
super("tempban");
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||
|
{
|
||
|
if (args.length < 2)
|
||
|
{
|
||
|
throw new NotEnoughArgumentsException();
|
||
|
}
|
||
|
|
||
|
User p = null;
|
||
|
try
|
||
|
{
|
||
|
p = getPlayer(server, args, 0);
|
||
|
}
|
||
|
catch (NoSuchFieldException ex)
|
||
|
{
|
||
|
p = ess.getOfflineUser(args[0]);
|
||
|
}
|
||
|
if (p == null)
|
||
|
{
|
||
|
sender.sendMessage("§cPlayer " + args[0] + " not found");
|
||
|
}
|
||
|
|
||
|
String time = getFinalArg(args, 1);
|
||
|
long banTimestamp = Util.parseDateDiff(time, true);
|
||
|
|
||
|
p = ess.getUser(server.matchPlayer(args[0]).get(0));
|
||
|
String banReason = "Temporary banned from server for " + Util.formatDateDiff(banTimestamp);
|
||
|
p.setBanReason(banReason);
|
||
|
p.setBanTimeout(banTimestamp);
|
||
|
p.kickPlayer(banReason);
|
||
|
((CraftServer)server).getHandle().a(p.getName());
|
||
|
sender.sendMessage("§cPlayer " + p.getName() + " banned");
|
||
|
Essentials.getStatic().loadBanList();
|
||
|
}
|
||
|
}
|