TF-EssentialsX/Essentials/src/com/earth2me/essentials/commands/Commanddelhome.java

52 lines
1.2 KiB
Java
Raw Normal View History

package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import java.util.Locale;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
public class Commanddelhome extends EssentialsCommand
{
public Commanddelhome()
{
super("delhome");
}
@Override
2011-11-18 12:06:59 +00:00
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
2011-11-28 02:54:19 +00:00
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
User user = ess.getUser(sender);
String name;
2011-11-28 02:54:19 +00:00
final String[] expandedArg = args[0].split(":");
if (expandedArg.length > 1 && (user == null || user.isAuthorized("essentials.delhome.others")))
{
2011-11-28 02:54:19 +00:00
user = getPlayer(server, expandedArg, 0, true);
name = expandedArg[1];
}
2011-11-28 02:54:19 +00:00
else if (user == null)
{
2011-11-28 02:54:19 +00:00
throw new NotEnoughArgumentsException();
}
else
{
2011-11-28 02:54:19 +00:00
name = expandedArg[0];
}
2011-11-28 02:54:19 +00:00
//TODO: Think up a nice error message
/*
* if (name.equalsIgnoreCase("bed")) {
* throw new Exception("You cannot remove the vanilla home point");
* }
*/
user.delHome(name.toLowerCase(Locale.ENGLISH));
sender.sendMessage(_("deleteHome", name));
}
}