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

44 lines
1 KiB
Java
Raw Normal View History

package com.earth2me.essentials.commands;
import com.earth2me.essentials.OfflinePlayer;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
2011-11-18 17:42:26 +00:00
import org.bukkit.Server;
public class Commandtpo extends EssentialsCommand
{
public Commandtpo()
{
super("tpo");
}
@Override
2011-11-18 19:30:05 +00:00
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
//Just basically the old tp command
2011-11-18 19:30:05 +00:00
final User player = getPlayer(server, args, 0, true);
// Check if user is offline
2011-11-18 19:30:05 +00:00
if (player.getBase() instanceof OfflinePlayer)
{
throw new NoSuchFieldException(Util.i18n("playerNotFound"));
}
// Verify permission
2011-11-18 19:30:05 +00:00
if (!player.isHidden() || user.isAuthorized("essentials.teleport.hidden"))
{
2011-11-18 19:30:05 +00:00
user.getTeleport().now(player, false);
user.sendMessage(Util.i18n("teleporting"));
}
else
{
throw new NoSuchFieldException(Util.i18n("playerNotFound"));
}
}
}