summaryrefslogtreecommitdiffstats
path: root/Essentials/src/com/earth2me/essentials/commands/Commandcompass.java
blob: eae10f0a5759bfaa54447d7fc568c6d5c119b1de (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
53
54
55
56
57
58
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
	public void run(Server server, User user, String commandLabel, String[] args) throws Exception
	{
		int r = (int)(user.getLocation().getYaw() + 180 + 360) % 360;
		String dir;
		if (r < 23)
		{
			dir = "N";
		}
		else if (r < 68)
		{
			dir = "NE";
		}
		else if (r < 113)
		{
			dir = "E";
		}
		else if (r < 158)
		{
			dir = "SE";
		}
		else if (r < 203)
		{
			dir = "S";
		}
		else if (r < 248)
		{
			dir = "SW";
		}
		else if (r < 293)
		{
			dir = "W";
		}
		else if (r < 338)
		{
			dir = "NW";
		}
		else
		{
			dir = "N";
		}
		user.sendMessage(Util.format("compassBearing", dir, r));
	}
}