summaryrefslogtreecommitdiffstats
path: root/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java
blob: f1800eb8e3bf43c189b55c0773f50f3ddb63ee07 (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
package com.earth2me.essentials.commands;

import com.earth2me.essentials.User;
import org.bukkit.Server;
import org.bukkit.inventory.Inventory;


public class Commandinvsee extends EssentialsCommand
{
	public Commandinvsee()
	{
		super("invsee");
	}

	//This method has a hidden param, which if given will display the equip slots. #easteregg
	@Override
	protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
	{
		if (args.length < 1)
		{
			throw new NotEnoughArgumentsException();
		}

		final User invUser = getPlayer(server, user, args, 0);
		Inventory inv;

		if (args.length > 1 && user.isAuthorized("essentials.invsee.equip"))
		{
			inv = server.createInventory(invUser.getBase(), 9, "Equipped");
			inv.setContents(invUser.getBase().getInventory().getArmorContents());
		}
		else
		{
			inv = invUser.getBase().getInventory();
		}
		user.getBase().closeInventory();
		user.getBase().openInventory(inv);
		user.setInvSee(true);
	}
}