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

40 lines
1.2 KiB
Java
Raw Normal View History

package com.earth2me.essentials.commands;
import com.earth2me.essentials.User;
2011-11-18 17:42:26 +00:00
import org.bukkit.Server;
2015-04-15 04:06:16 +00:00
import static com.earth2me.essentials.I18n.tl;
2015-04-15 04:06:16 +00:00
public class Commandcompass extends EssentialsCommand {
public Commandcompass() {
super("compass");
}
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 {
final int bearing = (int) (user.getLocation().getYaw() + 180 + 360) % 360;
String dir;
if (bearing < 23) {
dir = tl("north");
2015-04-15 04:06:16 +00:00
} else if (bearing < 68) {
dir = tl("northEast");
2015-04-15 04:06:16 +00:00
} else if (bearing < 113) {
dir = tl("east");
2015-04-15 04:06:16 +00:00
} else if (bearing < 158) {
dir = tl("southEast");
2015-04-15 04:06:16 +00:00
} else if (bearing < 203) {
dir = tl("south");
2015-04-15 04:06:16 +00:00
} else if (bearing < 248) {
dir = tl("southWest");
2015-04-15 04:06:16 +00:00
} else if (bearing < 293) {
dir = tl("west");
2015-04-15 04:06:16 +00:00
} else if (bearing < 338) {
dir = tl("northWest");
2015-04-15 04:06:16 +00:00
} else {
dir = tl("north");
2015-04-15 04:06:16 +00:00
}
user.sendMessage(tl("compassBearing", dir, bearing));
}
}