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

import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;


public class CommandSource implements IReplyTo
{
	private CommandSource replyTo = null;
	protected CommandSender sender;

	public CommandSource(final CommandSender base)
	{
		this.sender = base;
	}

	public final CommandSender getSender()
	{
		return sender;
	}

	public final Player getPlayer()
	{
		if (sender instanceof Player)
		{
			return (Player)sender;
		}
		return null;
	}
	
	public final boolean isPlayer()
	{
		return (sender instanceof Player);
	}

	public final CommandSender setSender(final CommandSender base)
	{
		return this.sender = base;
	}
	
	
	public void sendMessage(String message)
	{
		if (!message.isEmpty())
		{
			sender.sendMessage(message);
		}
	}

	@Override
	public void setReplyTo(final CommandSource user)
	{
		replyTo = user;
	}

	@Override
	public CommandSource getReplyTo()
	{
		return replyTo;
	}
}