示例#1
0
	@Override
	public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
	{
		ISettings settings = ess.getSettings();
		switch (args.length)
		{
		case 0:
			throw new NotEnoughArgumentsException();

		case 1:
			final IUser player = ess.getUserMap().matchUser(args[0], false, false);
			if (!player.getData().isTeleportEnabled())
			{
				throw new Exception(_("teleportDisabled", player.getPlayer().getDisplayName()));
			}
			if (user.getPlayer().getWorld() != player.getPlayer().getWorld() && settings.getData().getGeneral().isWorldTeleportPermissions()
				&& !Permissions.WORLD.isAuthorized(user, player.getPlayer().getWorld().getName()))
			{
				throw new Exception(_("noPerm", "essentials.world." + player.getPlayer().getWorld().getName()));
			}
			user.sendMessage(_("teleporting"));
			final Trade charge = new Trade(commandName, ess);
			charge.isAffordableFor(user);
			user.getTeleport().teleport(player.getPlayer(), charge, TeleportCause.COMMAND);
			throw new NoChargeException();

		default:
			if (!Permissions.TPOHERE.isAuthorized(user))
			{
				throw new Exception(_("needTpohere"));
			}
			user.sendMessage(_("teleporting"));
			
			final IUser target = ess.getUserMap().matchUser(args[0], false, false);
			
			final IUser toPlayer = ess.getUserMap().matchUser(args[1], false, false);

			if (!target.getData().isTeleportEnabled())
			{
				throw new Exception(_("teleportDisabled", target.getPlayer().getDisplayName()));
			}
			if (!toPlayer.getData().isTeleportEnabled())
			{
				throw new Exception(_("teleportDisabled", toPlayer.getPlayer().getDisplayName()));
			}
			if (target.getPlayer().getWorld() != toPlayer.getPlayer().getWorld() && settings.getData().getGeneral().isWorldTeleportPermissions()
				&& !Permissions.WORLD.isAuthorized(user, toPlayer.getPlayer().getWorld().getName()))
			{
				throw new Exception(_("noPerm", "essentials.world." + toPlayer.getPlayer().getWorld().getName()));
			}
			target.getTeleport().now(toPlayer.getPlayer(), false, TeleportCause.COMMAND);
			target.sendMessage(_("teleportAtoB", user.getPlayer().getDisplayName(), toPlayer.getPlayer().getDisplayName()));
			break;
		}
	}
示例#2
0
	@Override
	public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
	{
		ISettings settings = ess.getSettings();
		switch (args.length)
		{
		case 0:
			throw new NotEnoughArgumentsException();

		case 1:
			final IUser player = ess.getUserMap().matchUserExcludingHidden(args[0], user.getPlayer());
			if (!player.getData().isTeleportEnabled())
			{
				throw new Exception(_("{0} has teleportation disabled.", player.getPlayer().getDisplayName()));
			}
			if (settings.getData().getGeneral().isPerGroupTeleport() && !Permissions.PERGROUPTELEPORT.isAuthorized(
					user, ess.getRanks().getMainGroup(player)))
			{
				throw new Exception(_("You do not have the {0} permission.", "essentials.teleport.groups." + ess.getRanks().getMainGroup(player)));
			}
			if (user.getPlayer().getWorld() != player.getPlayer().getWorld() && settings.getData().getGeneral().isWorldTeleportPermissions() && !Permissions.WORLD.isAuthorized(
					user, player.getPlayer().getWorld().getName()))
			{
				throw new Exception(_("You do not have the {0} permission.", "essentials.world." + player.getPlayer().getWorld().getName()));
			}
			user.sendMessage(_("Teleporting..."));
			final Trade charge = new Trade(commandName, ess);
			charge.isAffordableFor(user);
			user.getTeleport().teleport(player.getPlayer(), charge, TeleportCause.COMMAND);
			throw new NoChargeException();

		default:
			if (!Permissions.TPOHERE.isAuthorized(user))
			{
				throw new Exception(_("needTpohere"));
			}
			user.sendMessage(_("Teleporting..."));

			final IUser target = ess.getUserMap().matchUserExcludingHidden(args[0], user.getPlayer());

			final IUser toPlayer = ess.getUserMap().matchUserExcludingHidden(args[1], user.getPlayer());

			if (!target.getData().isTeleportEnabled())
			{
				throw new Exception(_("{0} has teleportation disabled.", target.getPlayer().getDisplayName()));
			}
			if (!toPlayer.getData().isTeleportEnabled())
			{
				throw new Exception(_("{0} has teleportation disabled.", toPlayer.getPlayer().getDisplayName()));
			}
			if (target.getPlayer().getWorld() != toPlayer.getPlayer().getWorld() && settings.getData().getGeneral().isWorldTeleportPermissions() && !Permissions.WORLD.isAuthorized(
					user, toPlayer.getPlayer().getWorld().getName()))
			{
				throw new Exception(_("You do not have the {0} permission.", "essentials.world." + toPlayer.getPlayer().getWorld().getName()));
			}
			target.getTeleport().now(toPlayer.getPlayer(), false, TeleportCause.COMMAND);
			target.sendMessage(_("{0} teleported you to {1}.", user.getPlayer().getDisplayName(), toPlayer.getPlayer().getDisplayName()));
			break;
		}
	}
示例#3
0
	private void goHome(final IUser user, final IUser player, final String home, final Trade charge) throws Exception
	{
		final Location loc = player.getHome(home);
		if (loc == null)
		{
			throw new NotEnoughArgumentsException();
		}
		if (user.getPlayer().getWorld() != loc.getWorld() && ess.getSettings().getData().getGeneral().isWorldHomePermissions() && !Permissions.WORLD.isAuthorized(
				user, loc.getWorld().getName()))
		{
			throw new Exception(_("noPerm", "essentials.world." + loc.getWorld().getName()));
		}
		user.getTeleport().home(loc, charge);
	}