2011-03-19 22:39:51 +00:00
|
|
|
package com.earth2me.essentials.commands;
|
|
|
|
|
|
|
|
import com.earth2me.essentials.User;
|
2011-05-09 21:37:02 +00:00
|
|
|
import com.earth2me.essentials.Util;
|
2011-11-18 17:42:26 +00:00
|
|
|
import org.bukkit.Server;
|
2011-03-19 22:39:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
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-03-19 22:39:51 +00:00
|
|
|
{
|
2011-11-18 12:06:59 +00:00
|
|
|
final int bearing = (int)(user.getLocation().getYaw() + 180 + 360) % 360;
|
2011-03-19 22:39:51 +00:00
|
|
|
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));
|
2011-03-19 22:39:51 +00:00
|
|
|
}
|
|
|
|
}
|