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

59 lines
957 B
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 Commandcompass extends EssentialsCommand
{
public Commandcompass()
{
super("compass");
}
@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-11-18 12:06:59 +00:00
final int bearing = (int)(user.getLocation().getYaw() + 180 + 360) % 360;
String dir;
2011-11-18 12:06:59 +00:00
if (bearing < 23)
2011-10-14 23:13:24 +00:00
{
dir = "N";
}
2011-11-18 12:06:59 +00:00
else if (bearing < 68)
2011-10-14 23:13:24 +00:00
{
dir = "NE";
}
2011-11-18 12:06:59 +00:00
else if (bearing < 113)
2011-10-14 23:13:24 +00:00
{
dir = "E";
}
2011-11-18 12:06:59 +00:00
else if (bearing < 158)
2011-10-14 23:13:24 +00:00
{
dir = "SE";
}
2011-11-18 12:06:59 +00:00
else if (bearing < 203)
2011-10-14 23:13:24 +00:00
{
dir = "S";
}
2011-11-18 12:06:59 +00:00
else if (bearing < 248)
2011-10-14 23:13:24 +00:00
{
dir = "SW";
}
2011-11-18 12:06:59 +00:00
else if (bearing < 293)
2011-10-14 23:13:24 +00:00
{
dir = "W";
}
2011-11-18 12:06:59 +00:00
else if (bearing < 338)
2011-10-14 23:13:24 +00:00
{
dir = "NW";
}
else
{
dir = "N";
}
2011-11-18 12:06:59 +00:00
user.sendMessage(Util.format("compassBearing", dir, bearing));
}
}