Adding essentials.delhome.others to allow people to delete other peoples homes.

This commit is contained in:
KHobbits 2011-08-26 05:12:29 +01:00
parent 3d913f9fcc
commit 016dd10060

View File

@ -16,26 +16,32 @@ public class Commanddelhome extends EssentialsCommand
@Override
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
{
User user;
//Allowing both formats /delhome khobbits house | /delhome khobbits:house
final String[] nameParts = args[0].split(":");
if (nameParts[0].length() != args[0].length())
{
args = nameParts;
}
User user = ess.getUser(sender);
String name;
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
else if (args.length < 2)
else if (args.length > 1 && (user == null || user.isAuthorized("essentials.delhome.others")))
{
user = getPlayer(server, args, 0);
name = args[1];
}
else
{
user = ess.getUser(sender);
if (user == null)
{
throw new NotEnoughArgumentsException();
}
name = args[0];
}
else
{
user = getPlayer(server, args, 0);
name = args[1];
}
user.delHome(name.toLowerCase());
sender.sendMessage(Util.format("deleteHome", name));
}