summaryrefslogtreecommitdiffstats
path: root/Essentials/src/net/ess3/commands/Commandcompass.java
blob: e9dc2d2a03a861183d675f8a84d120176537a042 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package net.ess3.commands;

import static net.ess3.I18n._;
import net.ess3.api.IUser;


public class Commandcompass extends EssentialsCommand
{
	@Override
	public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
	{
		final int bearing = (int)(user.getPlayer().getLocation().getYaw() + 180 + 360) % 360;
		final String dir;
		if (bearing < 23)
		{
			dir = "N";
		}
		else if (bearing < 68)
		{
			dir = "NE";
		}
		else if (bearing < 113)
		{
			dir = "E";
		}
		else if (bearing < 158)
		{
			dir = "SE";
		}
		else if (bearing < 203)
		{
			dir = "S";
		}
		else if (bearing < 248)
		{
			dir = "SW";
		}
		else if (bearing < 293)
		{
			dir = "W";
		}
		else if (bearing < 338)
		{
			dir = "NW";
		}
		else
		{
			dir = "N";
		}
		user.sendMessage(_("compassBearing", dir, bearing));
	}
}