[trunk] adding support to warp other players to warps, this requires the essentials.warp.otherplayers permission

git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1342 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
ementalo 2011-05-04 15:53:32 +00:00
parent d9a5b73ea4
commit 50780f7399
2 changed files with 30 additions and 18 deletions

View file

@ -4,6 +4,7 @@ import org.bukkit.Server;
import com.earth2me.essentials.Essentials; import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.Warps; import com.earth2me.essentials.Warps;
import org.bukkit.command.CommandSender;
public class Commandwarp extends EssentialsCommand public class Commandwarp extends EssentialsCommand
@ -16,7 +17,7 @@ public class Commandwarp extends EssentialsCommand
@Override @Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception public void run(Server server, User user, String commandLabel, String[] args) throws Exception
{ {
boolean perWarpPermission = ess.getSettings().getPerWarpPermission();
if (args.length == 0) if (args.length == 0)
{ {
if (!user.isAuthorized("essentials.warp.list")) if (!user.isAuthorized("essentials.warp.list"))
@ -34,7 +35,7 @@ public class Commandwarp extends EssentialsCommand
int i = 0; int i = 0;
for (String warpName : warps.getWarpNames()) for (String warpName : warps.getWarpNames())
{ {
if (perWarpPermission) if (ess.getSettings().getPerWarpPermission())
{ {
if (user.isAuthorized("essentials.warp." + warpName)) if (user.isAuthorized("essentials.warp." + warpName))
{ {
@ -52,26 +53,37 @@ public class Commandwarp extends EssentialsCommand
user.sendMessage(sb.toString()); user.sendMessage(sb.toString());
return; return;
} }
if (args.length > 0)
try
{ {
if (perWarpPermission) User otherUser = null;
if (args.length == 2 && user.isAuthorized("essentials.warp.otherplayers"))
{ {
if (user.isAuthorized("essentials.warp." + args[0])) otherUser = ess.getUser(server.getPlayer(args[1]));
if(otherUser == null)
{ {
user.charge(this); user.sendMessage("§cPlayer not found");
user.getTeleport().warp(args[0], this.getName());
return; return;
} }
user.sendMessage("§cYou do not have Permission to use that warp."); warpUser(otherUser, args[0]);
return;
} }
user.charge(this); warpUser(user, args[0]);
user.getTeleport().warp(args[0], this.getName());
}
catch (Exception ex)
{
user.sendMessage(ex.getMessage());
} }
} }
private void warpUser(User user, String name) throws Exception
{
if (ess.getSettings().getPerWarpPermission())
{
if (user.isAuthorized("essentials.warp." + name))
{
charge(user);
user.getTeleport().warp(name, this.getName());
return;
}
user.sendMessage("§cYou do not have Permission to use that warp.");
return;
}
charge(user);
user.getTeleport().warp(name, this.getName());
}
} }

View file

@ -309,7 +309,7 @@ commands:
aliases: [eunlimited] aliases: [eunlimited]
warp: warp:
description: List all warps or warp to the specified location. description: List all warps or warp to the specified location.
usage: /<command> <warp> usage: /<command> <warp> <player>
aliases: [ewarp] aliases: [ewarp]
weather: weather:
description: Setting the weather. description: Setting the weather.