summaryrefslogtreecommitdiffstats
path: root/Essentials/src/com/earth2me/essentials/PlayerExtension.java
blob: e8969e1a58dffc882ddf296c1ddfff7cbb3e49f2 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package com.earth2me.essentials;

import org.bukkit.craftbukkit.entity.CraftPlayer;
import net.minecraft.server.EntityPlayer;
import net.minecraft.server.IInventory;
import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer;
import org.bukkit.entity.*;


public class PlayerExtension extends PlayerWrapper
{
	public PlayerExtension(Player base)
	{
		super(base);
	}

	public boolean isBanned()
	{
		return Essentials.getStatic().bans.contains(getName());
	}

	public boolean isIpBanned()
	{
		return Essentials.getStatic().bannedIps.contains(getAddress().getAddress().toString().replace("/", ""));
	}

	public float getCorrectedYaw()
	{
		float angle = (getLocation().getYaw() - 90.0f) % 360.0f;
		if (angle < 0) {
			angle += 360.0f;
		}
		return angle;
	}
	
	public void showInventory(IInventory inventory)
	{
		getHandle().a(inventory);
	}

	public void showInventory(CraftInventoryPlayer inventory)
	{
		showInventory((IInventory)inventory.getInventory());
	}

	public TargetBlock getTarget()
	{
		return new TargetBlock(getBase());
	}

	public String getGroup()
	{
		try
		{
			return com.nijikokun.bukkit.Permissions.Permissions.Security.getGroup(getWorld().getName(), getName());
		}
		catch (Throwable ex)
		{
			return "default";
		}
	}
	
	public boolean inGroup(String group)
	{
		try
		{
			return com.nijikokun.bukkit.Permissions.Permissions.Security.inGroup(getWorld().getName(), getName(), group);
		}
		catch (Throwable ex)
		{
			return false;
		}
	}

	public boolean canBuild()
	{
		try
		{
			return com.nijikokun.bukkit.Permissions.Permissions.Security.canGroupBuild(getWorld().getName(), getGroup());
		}
		catch (Throwable ex)
		{
			return true;
		}
	}

	public EntityPlayer getHandle()
	{
		return getCraftPlayer().getHandle();
	}

	public CraftPlayer getCraftPlayer()
	{
		return (CraftPlayer)base;
	}
}