2011-03-19 22:39:51 +00:00
|
|
|
package com.earth2me.essentials.commands;
|
|
|
|
|
2012-09-09 14:50:22 +00:00
|
|
|
import static com.earth2me.essentials.I18n._;
|
2011-11-18 17:42:26 +00:00
|
|
|
import com.earth2me.essentials.User;
|
2011-03-19 22:39:51 +00:00
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.Server;
|
2011-12-07 09:03:23 +00:00
|
|
|
import org.bukkit.command.CommandSender;
|
2011-03-19 22:39:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
public class Commandgetpos extends EssentialsCommand
|
|
|
|
{
|
|
|
|
public Commandgetpos()
|
|
|
|
{
|
|
|
|
super("getpos");
|
|
|
|
}
|
2012-03-24 21:07:49 +00:00
|
|
|
|
2011-03-19 22:39:51 +00:00
|
|
|
@Override
|
2011-11-18 12:06:59 +00:00
|
|
|
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
2011-03-19 22:39:51 +00:00
|
|
|
{
|
2011-12-07 09:03:23 +00:00
|
|
|
if (args.length > 0 && user.isAuthorized("essentials.getpos.others"))
|
|
|
|
{
|
|
|
|
final User otherUser = getPlayer(server, args, 0);
|
2012-03-24 21:07:49 +00:00
|
|
|
if (!otherUser.isHidden() || user.isAuthorized("essentials.list.hidden"))
|
|
|
|
{
|
|
|
|
outputPosition(user, otherUser.getLocation(), user.getLocation());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-12-07 09:03:23 +00:00
|
|
|
}
|
2012-03-24 21:07:49 +00:00
|
|
|
outputPosition(user, user.getLocation(), null);
|
2011-12-07 09:03:23 +00:00
|
|
|
}
|
2012-03-24 21:07:49 +00:00
|
|
|
|
2011-12-07 09:03:23 +00:00
|
|
|
@Override
|
|
|
|
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
|
|
|
{
|
|
|
|
if (args.length < 1)
|
|
|
|
{
|
|
|
|
throw new NotEnoughArgumentsException();
|
|
|
|
}
|
|
|
|
final User user = getPlayer(server, args, 0);
|
|
|
|
outputPosition(sender, user.getLocation(), null);
|
|
|
|
}
|
2012-03-24 21:07:49 +00:00
|
|
|
|
2011-12-07 09:03:23 +00:00
|
|
|
private void outputPosition(final CommandSender sender, final Location coords, final Location distance)
|
|
|
|
{
|
2012-09-09 14:50:22 +00:00
|
|
|
sender.sendMessage(_("currentWorld", coords.getWorld().getName()));
|
|
|
|
sender.sendMessage(_("posX", coords.getBlockX()));
|
|
|
|
sender.sendMessage(_("posY", coords.getBlockY()));
|
|
|
|
sender.sendMessage(_("posZ", coords.getBlockZ()));
|
|
|
|
sender.sendMessage(_("posYaw", (coords.getYaw() + 180 + 360) % 360));
|
|
|
|
sender.sendMessage(_("posPitch", coords.getPitch()));
|
2011-12-07 09:03:23 +00:00
|
|
|
if (distance != null && coords.getWorld().equals(distance.getWorld()))
|
|
|
|
{
|
2012-09-09 14:50:22 +00:00
|
|
|
sender.sendMessage(_("distance", coords.distance(distance)));
|
2011-12-07 09:03:23 +00:00
|
|
|
}
|
2011-03-19 22:39:51 +00:00
|
|
|
}
|
|
|
|
}
|