blob: 77b18aa318f7d21983e0c0f65a3b087d763e51b3 (
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
|
package com.earth2me.essentials.commands;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
public class Commandsethome extends EssentialsCommand
{
public Commandsethome()
{
super("sethome");
}
@Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
{
if (args.length > 0)
{
//Allowing both formats /sethome khobbits house | /sethome khobbits:house
final String[] nameParts = args[0].split(":");
if (nameParts[0].length() != args[0].length())
{
args = nameParts;
}
if (args.length < 2)
{
if (user.isAuthorized("essentials.sethome.multiple"))
{
if ((user.isAuthorized("essentials.sethome.multiple.unlimited")) || (user.getHomes().size() < ess.getSettings().getHomeLimit(user))
|| (user.getHomes().contains(args[0].toLowerCase())))
{
user.setHome(args[0].toLowerCase());
}
else
{
throw new Exception(Util.format("maxHomes", ess.getSettings().getHomeLimit(user)));
}
}
else {
throw new Exception(Util.format("maxHomes", 1));
}
}
else
{
if (user.isAuthorized("essentials.sethome.others"))
{
User usersHome = ess.getUser(ess.getServer().getPlayer(args[0]));
if (usersHome == null)
{
usersHome = ess.getOfflineUser(args[0]);
}
if (usersHome == null)
{
throw new Exception(Util.i18n("playerNotFound"));
}
String name = args[1].toLowerCase();
if (!user.isAuthorized("essentials.sethome.multiple"))
{
name = "home";
}
usersHome.setHome(name, user.getLocation());
}
}
}
else
{
user.setHome();
}
user.sendMessage(Util.i18n("homeSet"));
}
}
|