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

45 lines
1.1 KiB
Java
Raw Normal View History

package com.earth2me.essentials.commands;
import com.earth2me.essentials.User;
2011-11-18 17:42:26 +00:00
import com.earth2me.essentials.Util;
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];
}
2011-08-23 14:37:09 +00:00
user.delHome(name.toLowerCase());
sender.sendMessage(Util.format("deleteHome", name));
}
}