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

46 lines
1.1 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
{
//Allowing both formats /delhome khobbits house | /delhome khobbits:house
2011-11-18 12:06:59 +00:00
final String[] expandedArgs = args[0].split(":");
User user = ess.getUser(sender);
String name;
2011-11-18 12:06:59 +00:00
if (expandedArgs.length < 1)
{
throw new NotEnoughArgumentsException();
}
2011-11-18 12:06:59 +00:00
else if (expandedArgs.length > 1 && (user == null || user.isAuthorized("essentials.delhome.others")))
{
2011-11-18 12:06:59 +00:00
user = getPlayer(server, expandedArgs, 0, true);
name = expandedArgs[1];
}
else
{
if (user == null)
{
throw new NotEnoughArgumentsException();
}
2011-11-18 12:06:59 +00:00
name = expandedArgs[0];
}
user.delHome(name.toLowerCase(Locale.ENGLISH));
sender.sendMessage(_("deleteHome", name));
}
}