Fix empty argument in delhome.

This commit is contained in:
KHobbits 2011-11-28 02:54:19 +00:00
parent 6603d0997e
commit 05c90af1ee
3 changed files with 22 additions and 14 deletions

View File

@ -17,28 +17,34 @@ public class Commanddelhome extends EssentialsCommand
@Override @Override
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception 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 if (args.length < 1)
final String[] expandedArgs = args[0].split(":");
User user = ess.getUser(sender);
String name;
if (expandedArgs.length < 1)
{ {
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();
} }
else if (expandedArgs.length > 1 && (user == null || user.isAuthorized("essentials.delhome.others")))
User user = ess.getUser(sender);
String name;
final String[] expandedArg = args[0].split(":");
if (expandedArg.length > 1 && (user == null || user.isAuthorized("essentials.delhome.others")))
{ {
user = getPlayer(server, expandedArgs, 0, true); user = getPlayer(server, expandedArg, 0, true);
name = expandedArgs[1]; name = expandedArg[1];
}
else if (user == null)
{
throw new NotEnoughArgumentsException();
} }
else else
{ {
if (user == null) name = expandedArg[0];
{
throw new NotEnoughArgumentsException();
}
name = expandedArgs[0];
} }
//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)); user.delHome(name.toLowerCase(Locale.ENGLISH));
sender.sendMessage(_("deleteHome", name)); sender.sendMessage(_("deleteHome", name));
} }

View File

@ -38,6 +38,7 @@ public class Commandtp extends EssentialsCommand
default: default:
if (!user.isAuthorized("essentials.tpohere")) if (!user.isAuthorized("essentials.tpohere"))
{ {
//TODO: Translate this
throw new Exception("You need access to /tpohere to teleport other players."); throw new Exception("You need access to /tpohere to teleport other players.");
} }
user.sendMessage(_("teleporting")); user.sendMessage(_("teleporting"));

View File

@ -43,6 +43,7 @@ public class Commandweather extends EssentialsCommand
} }
} }
//TODO: Translate these
@Override @Override
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{ {