2011-03-19 22:39:51 +00:00
|
|
|
package com.earth2me.essentials.commands;
|
|
|
|
|
2013-10-16 19:59:39 +00:00
|
|
|
import com.earth2me.essentials.CommandSource;
|
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;
|
|
|
|
|
2017-06-11 00:17:43 +00:00
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
|
|
|
|
2015-04-15 04:06:16 +00:00
|
|
|
import static com.earth2me.essentials.I18n.tl;
|
|
|
|
|
2011-03-19 22:39:51 +00:00
|
|
|
|
2015-04-15 04:06:16 +00:00
|
|
|
public class Commandgetpos extends EssentialsCommand {
|
|
|
|
public Commandgetpos() {
|
|
|
|
super("getpos");
|
|
|
|
}
|
2012-03-24 21:07:49 +00:00
|
|
|
|
2015-04-15 04:06:16 +00:00
|
|
|
@Override
|
|
|
|
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
|
|
|
if (args.length > 0 && user.isAuthorized("essentials.getpos.others")) {
|
|
|
|
final User otherUser = getPlayer(server, user, args, 0);
|
|
|
|
outputPosition(user.getSource(), otherUser.getLocation(), user.getLocation());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
outputPosition(user.getSource(), user.getLocation(), null);
|
|
|
|
}
|
2012-03-24 21:07:49 +00:00
|
|
|
|
2015-04-15 04:06:16 +00:00
|
|
|
@Override
|
|
|
|
protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
|
|
|
if (args.length < 1) {
|
|
|
|
throw new NotEnoughArgumentsException();
|
|
|
|
}
|
|
|
|
final User user = getPlayer(server, args, 0, true, false);
|
|
|
|
outputPosition(sender, user.getLocation(), null);
|
|
|
|
}
|
2012-03-24 21:07:49 +00:00
|
|
|
|
2015-04-15 04:06:16 +00:00
|
|
|
private void outputPosition(final CommandSource sender, final Location coords, final Location distance) {
|
|
|
|
sender.sendMessage(tl("currentWorld", coords.getWorld().getName()));
|
|
|
|
sender.sendMessage(tl("posX", coords.getBlockX()));
|
|
|
|
sender.sendMessage(tl("posY", coords.getBlockY()));
|
|
|
|
sender.sendMessage(tl("posZ", coords.getBlockZ()));
|
2016-07-22 15:26:56 +00:00
|
|
|
sender.sendMessage(tl("posYaw", (coords.getYaw() + 360) % 360));
|
2015-04-15 04:06:16 +00:00
|
|
|
sender.sendMessage(tl("posPitch", coords.getPitch()));
|
|
|
|
if (distance != null && coords.getWorld().equals(distance.getWorld())) {
|
|
|
|
sender.sendMessage(tl("distance", coords.distance(distance)));
|
|
|
|
}
|
|
|
|
}
|
2017-06-11 00:17:43 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
protected List<String> getTabCompleteOptions(Server server, User user, String commandLabel, String[] args) {
|
|
|
|
if (args.length == 1 && user.isAuthorized("essentials.getpos.others")) {
|
|
|
|
return getPlayers(server, user);
|
|
|
|
} else {
|
|
|
|
return Collections.emptyList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected List<String> getTabCompleteOptions(Server server, CommandSource sender, String commandLabel, String[] args) {
|
|
|
|
if (args.length == 1) {
|
|
|
|
return getPlayers(server, sender);
|
|
|
|
} else {
|
|
|
|
return Collections.emptyList();
|
|
|
|
}
|
|
|
|
}
|
2011-03-19 22:39:51 +00:00
|
|
|
}
|