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

62 lines
1.3 KiB
Java
Raw Normal View History

package com.earth2me.essentials.commands;
import org.bukkit.Server;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
public class Commandsethome extends EssentialsCommand
{
public Commandsethome()
{
super("sethome");
}
@Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
{
if (args.length > 0)
{
if (args.length < 2)
{
if (user.isAuthorized("essentials.sethome.multiple"))
{
2011-08-23 14:37:09 +00:00
if ((user.isAuthorized("essentials.sethome.multiple.unlimited")) || (user.getHomes().size() < ess.getSettings().getMultipleHomes())
|| (user.getHomes().contains(args[0].toLowerCase())))
{
2011-08-23 14:37:09 +00:00
user.setHome(args[0].toLowerCase());
}
else
{
throw new Exception(Util.format("maxHomes", ess.getSettings().getMultipleHomes()));
}
}
}
else
{
if (user.isAuthorized("essentials.sethome.others"))
{
User usersHome = ess.getUser(ess.getServer().getPlayer(args[0]));
if (usersHome == null)
{
usersHome = ess.getOfflineUser(args[0]);
}
2011-08-11 02:33:45 +00:00
if (usersHome == null)
{
throw new Exception(Util.i18n("playerNotFound"));
}
2011-08-23 14:37:09 +00:00
usersHome.setHome(args[1].toLowerCase(), user.getLocation());
}
}
}
2011-06-28 09:13:18 +00:00
else
{
user.setHome();
2011-06-28 09:13:18 +00:00
}
charge(user);
user.sendMessage(Util.i18n("homeSet"));
}
}