summaryrefslogtreecommitdiffstats
path: root/Essentials/src/com/earth2me/essentials/PlayerExtension.java
blob: e72cf25f409b3cb9fa570d706c95dca9412edae8 (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
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.Player;


public class PlayerExtension extends PlayerWrapper
{
	protected final IEssentials ess;
	
	public PlayerExtension(Player base, IEssentials ess)
	{
		super(base);
		this.ess = ess;
	}

	public boolean isBanned()
	{
		return ess.getBans().isNameBanned(this.getName());
	}

	public boolean isIpBanned()
	{
		return ess.getBans().isIpBanned(getAddress().getAddress().getHostAddress());
	}

	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()
	{
		return ess.getPermissionsHandler().getGroup(base);
	}
	
	public boolean inGroup(String group)
	{
		return ess.getPermissionsHandler().inGroup(base, group);
	}

	public boolean canBuild()
	{
		return ess.getPermissionsHandler().canBuild(base, getGroup());
	}

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

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